id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
sequence
docstring
stringlengths
3
47.2k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
91
247
500
edunola13/enolaphp-framework
src/Http/Models/En_HttpRequest.php
En_HttpRequest.init
private function init($config){ //Configuro valores basicos-genericos $this->getParams= filter_input_array(INPUT_GET); $this->postParams= filter_input_array(INPUT_POST); $this->attributes= array(); $this->session= new Session($config['SESSION_AUTOSTART']); $this->requestMethod= filter_input(INPUT_SERVER, 'REQUEST_METHOD'); $this->queryString= filter_input(INPUT_SERVER, 'QUERY_STRING'); $this->requestUri= filter_input(INPUT_SERVER, 'REQUEST_URI'); $this->httpHost= filter_input(INPUT_SERVER, 'HTTP_HOST'); $this->httpAccept= filter_input(INPUT_SERVER, 'HTTP_ACCEPT'); $this->httpAcceptLanguage= filter_input(INPUT_SERVER, 'HTTP_ACCEPT_LANGUAGE'); $this->httpUserAgent= filter_input(INPUT_SERVER, 'HTTP_USER_AGENT'); $this->clientIp= filter_input(INPUT_SERVER, 'REMOTE_ADDR'); //Configuro la URIAPP y defino varios valores propios de la Aplicaci贸n $this->realBaseUrl= $config['REAL_BASE_URL']; $this->baseUrlLocale= $config['BASEURL_LOCALE']; $this->uriApp= $config['URIAPP']; $this->uriAppLocale= $config['URIAPP_LOCALE']; $this->localeUri= $config['LOCALE_URI']; $this->locale= $config['LOCALE']; }
php
private function init($config){ //Configuro valores basicos-genericos $this->getParams= filter_input_array(INPUT_GET); $this->postParams= filter_input_array(INPUT_POST); $this->attributes= array(); $this->session= new Session($config['SESSION_AUTOSTART']); $this->requestMethod= filter_input(INPUT_SERVER, 'REQUEST_METHOD'); $this->queryString= filter_input(INPUT_SERVER, 'QUERY_STRING'); $this->requestUri= filter_input(INPUT_SERVER, 'REQUEST_URI'); $this->httpHost= filter_input(INPUT_SERVER, 'HTTP_HOST'); $this->httpAccept= filter_input(INPUT_SERVER, 'HTTP_ACCEPT'); $this->httpAcceptLanguage= filter_input(INPUT_SERVER, 'HTTP_ACCEPT_LANGUAGE'); $this->httpUserAgent= filter_input(INPUT_SERVER, 'HTTP_USER_AGENT'); $this->clientIp= filter_input(INPUT_SERVER, 'REMOTE_ADDR'); //Configuro la URIAPP y defino varios valores propios de la Aplicaci贸n $this->realBaseUrl= $config['REAL_BASE_URL']; $this->baseUrlLocale= $config['BASEURL_LOCALE']; $this->uriApp= $config['URIAPP']; $this->uriAppLocale= $config['URIAPP_LOCALE']; $this->localeUri= $config['LOCALE_URI']; $this->locale= $config['LOCALE']; }
[ "private", "function", "init", "(", "$", "config", ")", "{", "//Configuro valores basicos-genericos", "$", "this", "->", "getParams", "=", "filter_input_array", "(", "INPUT_GET", ")", ";", "$", "this", "->", "postParams", "=", "filter_input_array", "(", "INPUT_POST", ")", ";", "$", "this", "->", "attributes", "=", "array", "(", ")", ";", "$", "this", "->", "session", "=", "new", "Session", "(", "$", "config", "[", "'SESSION_AUTOSTART'", "]", ")", ";", "$", "this", "->", "requestMethod", "=", "filter_input", "(", "INPUT_SERVER", ",", "'REQUEST_METHOD'", ")", ";", "$", "this", "->", "queryString", "=", "filter_input", "(", "INPUT_SERVER", ",", "'QUERY_STRING'", ")", ";", "$", "this", "->", "requestUri", "=", "filter_input", "(", "INPUT_SERVER", ",", "'REQUEST_URI'", ")", ";", "$", "this", "->", "httpHost", "=", "filter_input", "(", "INPUT_SERVER", ",", "'HTTP_HOST'", ")", ";", "$", "this", "->", "httpAccept", "=", "filter_input", "(", "INPUT_SERVER", ",", "'HTTP_ACCEPT'", ")", ";", "$", "this", "->", "httpAcceptLanguage", "=", "filter_input", "(", "INPUT_SERVER", ",", "'HTTP_ACCEPT_LANGUAGE'", ")", ";", "$", "this", "->", "httpUserAgent", "=", "filter_input", "(", "INPUT_SERVER", ",", "'HTTP_USER_AGENT'", ")", ";", "$", "this", "->", "clientIp", "=", "filter_input", "(", "INPUT_SERVER", ",", "'REMOTE_ADDR'", ")", ";", "//Configuro la URIAPP y defino varios valores propios de la Aplicaci贸n ", "$", "this", "->", "realBaseUrl", "=", "$", "config", "[", "'REAL_BASE_URL'", "]", ";", "$", "this", "->", "baseUrlLocale", "=", "$", "config", "[", "'BASEURL_LOCALE'", "]", ";", "$", "this", "->", "uriApp", "=", "$", "config", "[", "'URIAPP'", "]", ";", "$", "this", "->", "uriAppLocale", "=", "$", "config", "[", "'URIAPP_LOCALE'", "]", ";", "$", "this", "->", "localeUri", "=", "$", "config", "[", "'LOCALE_URI'", "]", ";", "$", "this", "->", "locale", "=", "$", "config", "[", "'LOCALE'", "]", ";", "}" ]
Setea todas las propiedades de la instancia GET - POST - SERVER y FRAMEWORK @param array $config
[ "Setea", "todas", "las", "propiedades", "de", "la", "instancia", "GET", "-", "POST", "-", "SERVER", "y", "FRAMEWORK" ]
a962bfcd53d7bc129d8c9946aaa71d264285229d
https://github.com/edunola13/enolaphp-framework/blob/a962bfcd53d7bc129d8c9946aaa71d264285229d/src/Http/Models/En_HttpRequest.php#L84-L105
501
edunola13/enolaphp-framework
src/Http/Models/En_HttpRequest.php
En_HttpRequest.getParam
public function getParam($name){ if(isset($this->getParams[$name])){ return $this->getParams[$name]; }else{ return NULL; } }
php
public function getParam($name){ if(isset($this->getParams[$name])){ return $this->getParams[$name]; }else{ return NULL; } }
[ "public", "function", "getParam", "(", "$", "name", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "getParams", "[", "$", "name", "]", ")", ")", "{", "return", "$", "this", "->", "getParams", "[", "$", "name", "]", ";", "}", "else", "{", "return", "NULL", ";", "}", "}" ]
Devuelve un parametro GET si existe y si no devuelve NULL @param string $name @return null o string
[ "Devuelve", "un", "parametro", "GET", "si", "existe", "y", "si", "no", "devuelve", "NULL" ]
a962bfcd53d7bc129d8c9946aaa71d264285229d
https://github.com/edunola13/enolaphp-framework/blob/a962bfcd53d7bc129d8c9946aaa71d264285229d/src/Http/Models/En_HttpRequest.php#L112-L118
502
edunola13/enolaphp-framework
src/Http/Models/En_HttpRequest.php
En_HttpRequest.postParam
public function postParam($name){ if(isset($this->postParams[$name])){ return $this->postParams[$name]; }else{ return NULL; } }
php
public function postParam($name){ if(isset($this->postParams[$name])){ return $this->postParams[$name]; }else{ return NULL; } }
[ "public", "function", "postParam", "(", "$", "name", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "postParams", "[", "$", "name", "]", ")", ")", "{", "return", "$", "this", "->", "postParams", "[", "$", "name", "]", ";", "}", "else", "{", "return", "NULL", ";", "}", "}" ]
Devuelve un parametro POST si existe y si no devuelve NULL @param string $name @return null o string
[ "Devuelve", "un", "parametro", "POST", "si", "existe", "y", "si", "no", "devuelve", "NULL" ]
a962bfcd53d7bc129d8c9946aaa71d264285229d
https://github.com/edunola13/enolaphp-framework/blob/a962bfcd53d7bc129d8c9946aaa71d264285229d/src/Http/Models/En_HttpRequest.php#L124-L130
503
edunola13/enolaphp-framework
src/Http/Models/En_HttpRequest.php
En_HttpRequest.getCleanParam
public function getCleanParam($name){ if(isset($this->getParams[$name])){ return Security::clean_vars($this->getParams[$name]); }else{ return NULL; } }
php
public function getCleanParam($name){ if(isset($this->getParams[$name])){ return Security::clean_vars($this->getParams[$name]); }else{ return NULL; } }
[ "public", "function", "getCleanParam", "(", "$", "name", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "getParams", "[", "$", "name", "]", ")", ")", "{", "return", "Security", "::", "clean_vars", "(", "$", "this", "->", "getParams", "[", "$", "name", "]", ")", ";", "}", "else", "{", "return", "NULL", ";", "}", "}" ]
Devuelve un parametro GET limpiado si existe y si no devuelve NULL @param string $name @return null o string
[ "Devuelve", "un", "parametro", "GET", "limpiado", "si", "existe", "y", "si", "no", "devuelve", "NULL" ]
a962bfcd53d7bc129d8c9946aaa71d264285229d
https://github.com/edunola13/enolaphp-framework/blob/a962bfcd53d7bc129d8c9946aaa71d264285229d/src/Http/Models/En_HttpRequest.php#L136-L142
504
edunola13/enolaphp-framework
src/Http/Models/En_HttpRequest.php
En_HttpRequest.postCleanParam
public function postCleanParam($name){ if(isset($this->postParams[$name])){ return Security::clean_vars($this->postParams[$name]); }else{ return NULL; } }
php
public function postCleanParam($name){ if(isset($this->postParams[$name])){ return Security::clean_vars($this->postParams[$name]); }else{ return NULL; } }
[ "public", "function", "postCleanParam", "(", "$", "name", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "postParams", "[", "$", "name", "]", ")", ")", "{", "return", "Security", "::", "clean_vars", "(", "$", "this", "->", "postParams", "[", "$", "name", "]", ")", ";", "}", "else", "{", "return", "NULL", ";", "}", "}" ]
Devuelve un parametro POST limpiado si existe y si no devuelve NULL @param string $name @return null o string
[ "Devuelve", "un", "parametro", "POST", "limpiado", "si", "existe", "y", "si", "no", "devuelve", "NULL" ]
a962bfcd53d7bc129d8c9946aaa71d264285229d
https://github.com/edunola13/enolaphp-framework/blob/a962bfcd53d7bc129d8c9946aaa71d264285229d/src/Http/Models/En_HttpRequest.php#L148-L154
505
edunola13/enolaphp-framework
src/Http/Models/En_HttpRequest.php
En_HttpRequest.getHeader
public function getHeader($name){ $headers= $this->getHeaders(); if(isset($headers[$name])){ return $headers[$name]; }else{ return NULL; } }
php
public function getHeader($name){ $headers= $this->getHeaders(); if(isset($headers[$name])){ return $headers[$name]; }else{ return NULL; } }
[ "public", "function", "getHeader", "(", "$", "name", ")", "{", "$", "headers", "=", "$", "this", "->", "getHeaders", "(", ")", ";", "if", "(", "isset", "(", "$", "headers", "[", "$", "name", "]", ")", ")", "{", "return", "$", "headers", "[", "$", "name", "]", ";", "}", "else", "{", "return", "NULL", ";", "}", "}" ]
Retorna un header especifico o null si no existe @param string $name @return string
[ "Retorna", "un", "header", "especifico", "o", "null", "si", "no", "existe" ]
a962bfcd53d7bc129d8c9946aaa71d264285229d
https://github.com/edunola13/enolaphp-framework/blob/a962bfcd53d7bc129d8c9946aaa71d264285229d/src/Http/Models/En_HttpRequest.php#L167-L174
506
edunola13/enolaphp-framework
src/Http/Models/En_HttpRequest.php
En_HttpRequest.getToken
public function getToken(){ if(!$this->token){ if($this->getHeader('Authorization') != NULL){ $this->token= $this->getHeader('Authorization'); } if(!$this->token && $this->getParam('token')){ $this->token= $this->getParam('token'); } } return $this->token; }
php
public function getToken(){ if(!$this->token){ if($this->getHeader('Authorization') != NULL){ $this->token= $this->getHeader('Authorization'); } if(!$this->token && $this->getParam('token')){ $this->token= $this->getParam('token'); } } return $this->token; }
[ "public", "function", "getToken", "(", ")", "{", "if", "(", "!", "$", "this", "->", "token", ")", "{", "if", "(", "$", "this", "->", "getHeader", "(", "'Authorization'", ")", "!=", "NULL", ")", "{", "$", "this", "->", "token", "=", "$", "this", "->", "getHeader", "(", "'Authorization'", ")", ";", "}", "if", "(", "!", "$", "this", "->", "token", "&&", "$", "this", "->", "getParam", "(", "'token'", ")", ")", "{", "$", "this", "->", "token", "=", "$", "this", "->", "getParam", "(", "'token'", ")", ";", "}", "}", "return", "$", "this", "->", "token", ";", "}" ]
Retorna el token actual de la peticion Busca en el header Authorization o una variable get token @return string
[ "Retorna", "el", "token", "actual", "de", "la", "peticion", "Busca", "en", "el", "header", "Authorization", "o", "una", "variable", "get", "token" ]
a962bfcd53d7bc129d8c9946aaa71d264285229d
https://github.com/edunola13/enolaphp-framework/blob/a962bfcd53d7bc129d8c9946aaa71d264285229d/src/Http/Models/En_HttpRequest.php#L180-L190
507
oromedialab/zf2-lazy-form
src/Form/Base.php
Base.addFormElement
public function addFormElement(array $element, $options = array()) { if (array_key_exists($element['name'], $this->formElements)) { throw new \Exception('Form element "'.$element['name'].'" is already added, use replaceFormElement() or removeElement() instead'); } $this->formElements[$element['name']] = $element; if (!empty($options) && is_array($options)) { $this->formElementOptions[$element['name']] = $options; } return $this; }
php
public function addFormElement(array $element, $options = array()) { if (array_key_exists($element['name'], $this->formElements)) { throw new \Exception('Form element "'.$element['name'].'" is already added, use replaceFormElement() or removeElement() instead'); } $this->formElements[$element['name']] = $element; if (!empty($options) && is_array($options)) { $this->formElementOptions[$element['name']] = $options; } return $this; }
[ "public", "function", "addFormElement", "(", "array", "$", "element", ",", "$", "options", "=", "array", "(", ")", ")", "{", "if", "(", "array_key_exists", "(", "$", "element", "[", "'name'", "]", ",", "$", "this", "->", "formElements", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'Form element \"'", ".", "$", "element", "[", "'name'", "]", ".", "'\" is already added, use replaceFormElement() or removeElement() instead'", ")", ";", "}", "$", "this", "->", "formElements", "[", "$", "element", "[", "'name'", "]", "]", "=", "$", "element", ";", "if", "(", "!", "empty", "(", "$", "options", ")", "&&", "is_array", "(", "$", "options", ")", ")", "{", "$", "this", "->", "formElementOptions", "[", "$", "element", "[", "'name'", "]", "]", "=", "$", "options", ";", "}", "return", "$", "this", ";", "}" ]
Add form element using short syntax @param array $element @return $this
[ "Add", "form", "element", "using", "short", "syntax" ]
f98474ee389ceefb9ed0d9874322a81f4628e11e
https://github.com/oromedialab/zf2-lazy-form/blob/f98474ee389ceefb9ed0d9874322a81f4628e11e/src/Form/Base.php#L126-L136
508
oromedialab/zf2-lazy-form
src/Form/Base.php
Base.getFormElements
public function getFormElements() { $sm = $this->getServiceLocator(); $formElements = array(); $placeholders = $this->getPlaceholderParameters(); $replacePlaceholderWithValues = array(); foreach ($this->formElements as $element) { // Remove form element if it is available in the remove list if (in_array($element['name'], $this->removeElements)) { continue; } $formElement = $this->formatFormElement($element); // Replace placeholder with default values $replacePlaceholderWithValues = $sm->get($this->moduleService)->defaultConfig('placeholder'); // Replace placeholder with global form values if (!empty($placeholders) && is_array($placeholders)) { // Replace placeholder with global values if (array_key_exists('global', $placeholders) && !empty($placeholders['global']) && is_array($placeholders['global'])) { $replacePlaceholderWithValues = array_merge($replacePlaceholderWithValues, $placeholders['global']); } // Replace placeholder with element form values if (array_key_exists('element', $placeholders) && !empty($placeholders['element']) && is_array($placeholders['element'])) { if (array_key_exists($element['name'], $placeholders['element'])) { $replacePlaceholderWithValues = array_merge($replacePlaceholderWithValues, $placeholders['element'][$element['name']]); } } } $formElement = $this->searchAndReplacePlaceHolders($formElement, $replacePlaceholderWithValues); $formElements[] = $formElement; } return $formElements; }
php
public function getFormElements() { $sm = $this->getServiceLocator(); $formElements = array(); $placeholders = $this->getPlaceholderParameters(); $replacePlaceholderWithValues = array(); foreach ($this->formElements as $element) { // Remove form element if it is available in the remove list if (in_array($element['name'], $this->removeElements)) { continue; } $formElement = $this->formatFormElement($element); // Replace placeholder with default values $replacePlaceholderWithValues = $sm->get($this->moduleService)->defaultConfig('placeholder'); // Replace placeholder with global form values if (!empty($placeholders) && is_array($placeholders)) { // Replace placeholder with global values if (array_key_exists('global', $placeholders) && !empty($placeholders['global']) && is_array($placeholders['global'])) { $replacePlaceholderWithValues = array_merge($replacePlaceholderWithValues, $placeholders['global']); } // Replace placeholder with element form values if (array_key_exists('element', $placeholders) && !empty($placeholders['element']) && is_array($placeholders['element'])) { if (array_key_exists($element['name'], $placeholders['element'])) { $replacePlaceholderWithValues = array_merge($replacePlaceholderWithValues, $placeholders['element'][$element['name']]); } } } $formElement = $this->searchAndReplacePlaceHolders($formElement, $replacePlaceholderWithValues); $formElements[] = $formElement; } return $formElements; }
[ "public", "function", "getFormElements", "(", ")", "{", "$", "sm", "=", "$", "this", "->", "getServiceLocator", "(", ")", ";", "$", "formElements", "=", "array", "(", ")", ";", "$", "placeholders", "=", "$", "this", "->", "getPlaceholderParameters", "(", ")", ";", "$", "replacePlaceholderWithValues", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "formElements", "as", "$", "element", ")", "{", "// Remove form element if it is available in the remove list", "if", "(", "in_array", "(", "$", "element", "[", "'name'", "]", ",", "$", "this", "->", "removeElements", ")", ")", "{", "continue", ";", "}", "$", "formElement", "=", "$", "this", "->", "formatFormElement", "(", "$", "element", ")", ";", "// Replace placeholder with default values", "$", "replacePlaceholderWithValues", "=", "$", "sm", "->", "get", "(", "$", "this", "->", "moduleService", ")", "->", "defaultConfig", "(", "'placeholder'", ")", ";", "// Replace placeholder with global form values", "if", "(", "!", "empty", "(", "$", "placeholders", ")", "&&", "is_array", "(", "$", "placeholders", ")", ")", "{", "// Replace placeholder with global values", "if", "(", "array_key_exists", "(", "'global'", ",", "$", "placeholders", ")", "&&", "!", "empty", "(", "$", "placeholders", "[", "'global'", "]", ")", "&&", "is_array", "(", "$", "placeholders", "[", "'global'", "]", ")", ")", "{", "$", "replacePlaceholderWithValues", "=", "array_merge", "(", "$", "replacePlaceholderWithValues", ",", "$", "placeholders", "[", "'global'", "]", ")", ";", "}", "// Replace placeholder with element form values", "if", "(", "array_key_exists", "(", "'element'", ",", "$", "placeholders", ")", "&&", "!", "empty", "(", "$", "placeholders", "[", "'element'", "]", ")", "&&", "is_array", "(", "$", "placeholders", "[", "'element'", "]", ")", ")", "{", "if", "(", "array_key_exists", "(", "$", "element", "[", "'name'", "]", ",", "$", "placeholders", "[", "'element'", "]", ")", ")", "{", "$", "replacePlaceholderWithValues", "=", "array_merge", "(", "$", "replacePlaceholderWithValues", ",", "$", "placeholders", "[", "'element'", "]", "[", "$", "element", "[", "'name'", "]", "]", ")", ";", "}", "}", "}", "$", "formElement", "=", "$", "this", "->", "searchAndReplacePlaceHolders", "(", "$", "formElement", ",", "$", "replacePlaceholderWithValues", ")", ";", "$", "formElements", "[", "]", "=", "$", "formElement", ";", "}", "return", "$", "formElements", ";", "}" ]
Get form elements in array format with values merged from placeholder @return array $formElements
[ "Get", "form", "elements", "in", "array", "format", "with", "values", "merged", "from", "placeholder" ]
f98474ee389ceefb9ed0d9874322a81f4628e11e
https://github.com/oromedialab/zf2-lazy-form/blob/f98474ee389ceefb9ed0d9874322a81f4628e11e/src/Form/Base.php#L194-L225
509
oromedialab/zf2-lazy-form
src/Form/Base.php
Base.formatFormElement
protected function formatFormElement(array $element) { $sm = $this->getServiceLocator(); $result = array(); if (array_key_exists('lazy-set', $element)) { $result = $sm->get($this->moduleService)->lazySet($element['lazy-set']); } $result['name'] = $element['name']; $result['type'] = $element['type']; if (array_key_exists('label', $element)) { $result['options']['label'] = $element['label']; } return $result; }
php
protected function formatFormElement(array $element) { $sm = $this->getServiceLocator(); $result = array(); if (array_key_exists('lazy-set', $element)) { $result = $sm->get($this->moduleService)->lazySet($element['lazy-set']); } $result['name'] = $element['name']; $result['type'] = $element['type']; if (array_key_exists('label', $element)) { $result['options']['label'] = $element['label']; } return $result; }
[ "protected", "function", "formatFormElement", "(", "array", "$", "element", ")", "{", "$", "sm", "=", "$", "this", "->", "getServiceLocator", "(", ")", ";", "$", "result", "=", "array", "(", ")", ";", "if", "(", "array_key_exists", "(", "'lazy-set'", ",", "$", "element", ")", ")", "{", "$", "result", "=", "$", "sm", "->", "get", "(", "$", "this", "->", "moduleService", ")", "->", "lazySet", "(", "$", "element", "[", "'lazy-set'", "]", ")", ";", "}", "$", "result", "[", "'name'", "]", "=", "$", "element", "[", "'name'", "]", ";", "$", "result", "[", "'type'", "]", "=", "$", "element", "[", "'type'", "]", ";", "if", "(", "array_key_exists", "(", "'label'", ",", "$", "element", ")", ")", "{", "$", "result", "[", "'options'", "]", "[", "'label'", "]", "=", "$", "element", "[", "'label'", "]", ";", "}", "return", "$", "result", ";", "}" ]
Format form element by replacing keywords with values recognized by zend-form @param array $element @return array $result
[ "Format", "form", "element", "by", "replacing", "keywords", "with", "values", "recognized", "by", "zend", "-", "form" ]
f98474ee389ceefb9ed0d9874322a81f4628e11e
https://github.com/oromedialab/zf2-lazy-form/blob/f98474ee389ceefb9ed0d9874322a81f4628e11e/src/Form/Base.php#L233-L246
510
oromedialab/zf2-lazy-form
src/Form/Base.php
Base.addInputFilter
protected function addInputFilter() { $sm = $this->getServiceLocator(); if (empty($sm)) { throw new \Exception('Form must be initialized using FormElementManager, refer document for more information'); } $config = $sm->get($this->moduleService)->config(); foreach ($this->getFormElements() as $element) { // If element by name filters exist with value false, do not apply the filter for the element. if (array_key_exists('filters', $element) && false === $element['filters']) { continue; } // If validator by name not empty exist then set required to true, else. Set required to false $element['required'] = false; if (array_key_exists('validators', $element) && is_array($element['validators'])) { foreach ($element['validators'] as $validator) { if (in_array($validator['name'], array('NotEmpty'))) { $element['required'] = true; } // Allow validation on empty values for Callback validator if (in_array($validator['name'], array('Callback'))) { $callBackValidatorExist = true; $element['allow_empty'] = true; $element['continue_if_empty'] = true; } } } if (array_key_exists('type', $element)) { unset($element['type']); } $element['allow_empty'] = true; $element['continue_if_empty'] = true; $this->inputFilter->add($this->inputFactory->createInput($element)); } return $this->inputFilter; }
php
protected function addInputFilter() { $sm = $this->getServiceLocator(); if (empty($sm)) { throw new \Exception('Form must be initialized using FormElementManager, refer document for more information'); } $config = $sm->get($this->moduleService)->config(); foreach ($this->getFormElements() as $element) { // If element by name filters exist with value false, do not apply the filter for the element. if (array_key_exists('filters', $element) && false === $element['filters']) { continue; } // If validator by name not empty exist then set required to true, else. Set required to false $element['required'] = false; if (array_key_exists('validators', $element) && is_array($element['validators'])) { foreach ($element['validators'] as $validator) { if (in_array($validator['name'], array('NotEmpty'))) { $element['required'] = true; } // Allow validation on empty values for Callback validator if (in_array($validator['name'], array('Callback'))) { $callBackValidatorExist = true; $element['allow_empty'] = true; $element['continue_if_empty'] = true; } } } if (array_key_exists('type', $element)) { unset($element['type']); } $element['allow_empty'] = true; $element['continue_if_empty'] = true; $this->inputFilter->add($this->inputFactory->createInput($element)); } return $this->inputFilter; }
[ "protected", "function", "addInputFilter", "(", ")", "{", "$", "sm", "=", "$", "this", "->", "getServiceLocator", "(", ")", ";", "if", "(", "empty", "(", "$", "sm", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'Form must be initialized using FormElementManager, refer document for more information'", ")", ";", "}", "$", "config", "=", "$", "sm", "->", "get", "(", "$", "this", "->", "moduleService", ")", "->", "config", "(", ")", ";", "foreach", "(", "$", "this", "->", "getFormElements", "(", ")", "as", "$", "element", ")", "{", "// If element by name filters exist with value false, do not apply the filter for the element.", "if", "(", "array_key_exists", "(", "'filters'", ",", "$", "element", ")", "&&", "false", "===", "$", "element", "[", "'filters'", "]", ")", "{", "continue", ";", "}", "// If validator by name not empty exist then set required to true, else. Set required to false", "$", "element", "[", "'required'", "]", "=", "false", ";", "if", "(", "array_key_exists", "(", "'validators'", ",", "$", "element", ")", "&&", "is_array", "(", "$", "element", "[", "'validators'", "]", ")", ")", "{", "foreach", "(", "$", "element", "[", "'validators'", "]", "as", "$", "validator", ")", "{", "if", "(", "in_array", "(", "$", "validator", "[", "'name'", "]", ",", "array", "(", "'NotEmpty'", ")", ")", ")", "{", "$", "element", "[", "'required'", "]", "=", "true", ";", "}", "// Allow validation on empty values for Callback validator", "if", "(", "in_array", "(", "$", "validator", "[", "'name'", "]", ",", "array", "(", "'Callback'", ")", ")", ")", "{", "$", "callBackValidatorExist", "=", "true", ";", "$", "element", "[", "'allow_empty'", "]", "=", "true", ";", "$", "element", "[", "'continue_if_empty'", "]", "=", "true", ";", "}", "}", "}", "if", "(", "array_key_exists", "(", "'type'", ",", "$", "element", ")", ")", "{", "unset", "(", "$", "element", "[", "'type'", "]", ")", ";", "}", "$", "element", "[", "'allow_empty'", "]", "=", "true", ";", "$", "element", "[", "'continue_if_empty'", "]", "=", "true", ";", "$", "this", "->", "inputFilter", "->", "add", "(", "$", "this", "->", "inputFactory", "->", "createInput", "(", "$", "element", ")", ")", ";", "}", "return", "$", "this", "->", "inputFilter", ";", "}" ]
Add input filter to form elements - Skip filters if value is set to false - If NotEmpty validator is available, add required element with value true, else set required value to false - Remove type from element to avoid conflict with input filter @return Zend\InputFilter\InputFilter
[ "Add", "input", "filter", "to", "form", "elements", "-", "Skip", "filters", "if", "value", "is", "set", "to", "false", "-", "If", "NotEmpty", "validator", "is", "available", "add", "required", "element", "with", "value", "true", "else", "set", "required", "value", "to", "false", "-", "Remove", "type", "from", "element", "to", "avoid", "conflict", "with", "input", "filter" ]
f98474ee389ceefb9ed0d9874322a81f4628e11e
https://github.com/oromedialab/zf2-lazy-form/blob/f98474ee389ceefb9ed0d9874322a81f4628e11e/src/Form/Base.php#L256-L291
511
oromedialab/zf2-lazy-form
src/Form/Base.php
Base.setPlaceholderParameter
public function setPlaceholderParameter($name, $value, $elementName = null) { if (null != $elementName) { $this->placeholderParameters['element'][$elementName][$name] = $value; } else { $this->placeholderParameters['global'][$name] = $value; } return $this; }
php
public function setPlaceholderParameter($name, $value, $elementName = null) { if (null != $elementName) { $this->placeholderParameters['element'][$elementName][$name] = $value; } else { $this->placeholderParameters['global'][$name] = $value; } return $this; }
[ "public", "function", "setPlaceholderParameter", "(", "$", "name", ",", "$", "value", ",", "$", "elementName", "=", "null", ")", "{", "if", "(", "null", "!=", "$", "elementName", ")", "{", "$", "this", "->", "placeholderParameters", "[", "'element'", "]", "[", "$", "elementName", "]", "[", "$", "name", "]", "=", "$", "value", ";", "}", "else", "{", "$", "this", "->", "placeholderParameters", "[", "'global'", "]", "[", "$", "name", "]", "=", "$", "value", ";", "}", "return", "$", "this", ";", "}" ]
Replace place holder with given value in validators, filters, attributes or options @param string $name @param string $value @return $this
[ "Replace", "place", "holder", "with", "given", "value", "in", "validators", "filters", "attributes", "or", "options" ]
f98474ee389ceefb9ed0d9874322a81f4628e11e
https://github.com/oromedialab/zf2-lazy-form/blob/f98474ee389ceefb9ed0d9874322a81f4628e11e/src/Form/Base.php#L313-L321
512
oromedialab/zf2-lazy-form
src/Form/Base.php
Base.searchAndReplacePlaceHolders
protected function searchAndReplacePlaceHolders(array $element, array $placeHolders) { array_walk_recursive($element, function(&$v, $k, $ph){ if (is_string($v) && array_key_exists($v, $ph)) { $v = $ph[$v]; } }, $placeHolders); return $element; }
php
protected function searchAndReplacePlaceHolders(array $element, array $placeHolders) { array_walk_recursive($element, function(&$v, $k, $ph){ if (is_string($v) && array_key_exists($v, $ph)) { $v = $ph[$v]; } }, $placeHolders); return $element; }
[ "protected", "function", "searchAndReplacePlaceHolders", "(", "array", "$", "element", ",", "array", "$", "placeHolders", ")", "{", "array_walk_recursive", "(", "$", "element", ",", "function", "(", "&", "$", "v", ",", "$", "k", ",", "$", "ph", ")", "{", "if", "(", "is_string", "(", "$", "v", ")", "&&", "array_key_exists", "(", "$", "v", ",", "$", "ph", ")", ")", "{", "$", "v", "=", "$", "ph", "[", "$", "v", "]", ";", "}", "}", ",", "$", "placeHolders", ")", ";", "return", "$", "element", ";", "}" ]
Search and replace occurences of place holders in an element @param array $element @param array $placeholders @return array
[ "Search", "and", "replace", "occurences", "of", "place", "holders", "in", "an", "element" ]
f98474ee389ceefb9ed0d9874322a81f4628e11e
https://github.com/oromedialab/zf2-lazy-form/blob/f98474ee389ceefb9ed0d9874322a81f4628e11e/src/Form/Base.php#L340-L348
513
silverorange/Net_Notifier
Net/Notifier/Server.php
Net_Notifier_Server.handleSignal
public function handleSignal($signal) { switch ($signal) { case SIGINT: $this->log( 'Received SIGINT, shutting down.' . PHP_EOL, Net_Notifier_Logger::VERBOSITY_ALL ); $this->moribund = true; break; case SIGTERM: $this->log( 'Received SIGTERM, shutting down.' . PHP_EOL, Net_Notifier_Logger::VERBOSITY_ALL ); $this->moribund = true; break; } }
php
public function handleSignal($signal) { switch ($signal) { case SIGINT: $this->log( 'Received SIGINT, shutting down.' . PHP_EOL, Net_Notifier_Logger::VERBOSITY_ALL ); $this->moribund = true; break; case SIGTERM: $this->log( 'Received SIGTERM, shutting down.' . PHP_EOL, Net_Notifier_Logger::VERBOSITY_ALL ); $this->moribund = true; break; } }
[ "public", "function", "handleSignal", "(", "$", "signal", ")", "{", "switch", "(", "$", "signal", ")", "{", "case", "SIGINT", ":", "$", "this", "->", "log", "(", "'Received SIGINT, shutting down.'", ".", "PHP_EOL", ",", "Net_Notifier_Logger", "::", "VERBOSITY_ALL", ")", ";", "$", "this", "->", "moribund", "=", "true", ";", "break", ";", "case", "SIGTERM", ":", "$", "this", "->", "log", "(", "'Received SIGTERM, shutting down.'", ".", "PHP_EOL", ",", "Net_Notifier_Logger", "::", "VERBOSITY_ALL", ")", ";", "$", "this", "->", "moribund", "=", "true", ";", "break", ";", "}", "}" ]
Handles UNIX signals SIGTERM and SIGINT can be used to trigger a clean shutdown of this server. @param integer $signal the signal received. @return void
[ "Handles", "UNIX", "signals" ]
b446e27cd1bebd58ba89243cde1272c5d281d3fb
https://github.com/silverorange/Net_Notifier/blob/b446e27cd1bebd58ba89243cde1272c5d281d3fb/Net/Notifier/Server.php#L410-L429
514
silverorange/Net_Notifier
Net/Notifier/Server.php
Net_Notifier_Server.relayNotification
protected function relayNotification($message) { $message = json_encode($message); foreach ($this->listenClients as $client) { if ($client->getState() < Net_Notifier_WebSocket_Connection::STATE_CLOSING) { $this->log( sprintf( ' ... relaying message "%s" to %s ... ', $message, $client->getIPAddress() ), Net_Notifier_Logger::VERBOSITY_CLIENT ); $client->writeText($message); $this->log( 'done' . PHP_EOL, Net_Notifier_Logger::VERBOSITY_CLIENT, false ); } } }
php
protected function relayNotification($message) { $message = json_encode($message); foreach ($this->listenClients as $client) { if ($client->getState() < Net_Notifier_WebSocket_Connection::STATE_CLOSING) { $this->log( sprintf( ' ... relaying message "%s" to %s ... ', $message, $client->getIPAddress() ), Net_Notifier_Logger::VERBOSITY_CLIENT ); $client->writeText($message); $this->log( 'done' . PHP_EOL, Net_Notifier_Logger::VERBOSITY_CLIENT, false ); } } }
[ "protected", "function", "relayNotification", "(", "$", "message", ")", "{", "$", "message", "=", "json_encode", "(", "$", "message", ")", ";", "foreach", "(", "$", "this", "->", "listenClients", "as", "$", "client", ")", "{", "if", "(", "$", "client", "->", "getState", "(", ")", "<", "Net_Notifier_WebSocket_Connection", "::", "STATE_CLOSING", ")", "{", "$", "this", "->", "log", "(", "sprintf", "(", "' ... relaying message \"%s\" to %s ... '", ",", "$", "message", ",", "$", "client", "->", "getIPAddress", "(", ")", ")", ",", "Net_Notifier_Logger", "::", "VERBOSITY_CLIENT", ")", ";", "$", "client", "->", "writeText", "(", "$", "message", ")", ";", "$", "this", "->", "log", "(", "'done'", ".", "PHP_EOL", ",", "Net_Notifier_Logger", "::", "VERBOSITY_CLIENT", ",", "false", ")", ";", "}", "}", "}" ]
Notifies all connected clients of an event @param string $message the message being relayed. @return void
[ "Notifies", "all", "connected", "clients", "of", "an", "event" ]
b446e27cd1bebd58ba89243cde1272c5d281d3fb
https://github.com/silverorange/Net_Notifier/blob/b446e27cd1bebd58ba89243cde1272c5d281d3fb/Net/Notifier/Server.php#L441-L466
515
silverorange/Net_Notifier
Net/Notifier/Server.php
Net_Notifier_Server.connect
protected function connect() { $errstr = ''; $errno = 0; $this->log('creating socket ... ', Net_Notifier_Logger::VERBOSITY_ALL); try { $this->socket = new Net_Notifier_Socket_Server( sprintf( 'tcp://0.0.0.0:%s', $this->port ), null ); } catch (Net_Notifier_Socket_Exception $e) { $this->log( 'failed' . PHP_EOL, Net_Notifier_Logger::VERBOSITY_ALL, false ); throw $e; } $this->log('done' . PHP_EOL, Net_Notifier_Logger::VERBOSITY_ALL, false); $this->connected = true; }
php
protected function connect() { $errstr = ''; $errno = 0; $this->log('creating socket ... ', Net_Notifier_Logger::VERBOSITY_ALL); try { $this->socket = new Net_Notifier_Socket_Server( sprintf( 'tcp://0.0.0.0:%s', $this->port ), null ); } catch (Net_Notifier_Socket_Exception $e) { $this->log( 'failed' . PHP_EOL, Net_Notifier_Logger::VERBOSITY_ALL, false ); throw $e; } $this->log('done' . PHP_EOL, Net_Notifier_Logger::VERBOSITY_ALL, false); $this->connected = true; }
[ "protected", "function", "connect", "(", ")", "{", "$", "errstr", "=", "''", ";", "$", "errno", "=", "0", ";", "$", "this", "->", "log", "(", "'creating socket ... '", ",", "Net_Notifier_Logger", "::", "VERBOSITY_ALL", ")", ";", "try", "{", "$", "this", "->", "socket", "=", "new", "Net_Notifier_Socket_Server", "(", "sprintf", "(", "'tcp://0.0.0.0:%s'", ",", "$", "this", "->", "port", ")", ",", "null", ")", ";", "}", "catch", "(", "Net_Notifier_Socket_Exception", "$", "e", ")", "{", "$", "this", "->", "log", "(", "'failed'", ".", "PHP_EOL", ",", "Net_Notifier_Logger", "::", "VERBOSITY_ALL", ",", "false", ")", ";", "throw", "$", "e", ";", "}", "$", "this", "->", "log", "(", "'done'", ".", "PHP_EOL", ",", "Net_Notifier_Logger", "::", "VERBOSITY_ALL", ",", "false", ")", ";", "$", "this", "->", "connected", "=", "true", ";", "}" ]
Sets up this server's listen socket @return void
[ "Sets", "up", "this", "server", "s", "listen", "socket" ]
b446e27cd1bebd58ba89243cde1272c5d281d3fb
https://github.com/silverorange/Net_Notifier/blob/b446e27cd1bebd58ba89243cde1272c5d281d3fb/Net/Notifier/Server.php#L476-L503
516
silverorange/Net_Notifier
Net/Notifier/Server.php
Net_Notifier_Server.disconnect
protected function disconnect() { $this->log('closing sockets ... ', Net_Notifier_Logger::VERBOSITY_ALL); foreach ($this->clients as $client) { $client->startClose( Net_Notifier_WebSocket_Connection::CLOSE_GOING_AWAY, 'Server shutting down.' ); } $this->clients = array(); $this->socket = null; $this->log('done' . PHP_EOL, Net_Notifier_Logger::VERBOSITY_ALL, false); $this->connected = false; }
php
protected function disconnect() { $this->log('closing sockets ... ', Net_Notifier_Logger::VERBOSITY_ALL); foreach ($this->clients as $client) { $client->startClose( Net_Notifier_WebSocket_Connection::CLOSE_GOING_AWAY, 'Server shutting down.' ); } $this->clients = array(); $this->socket = null; $this->log('done' . PHP_EOL, Net_Notifier_Logger::VERBOSITY_ALL, false); $this->connected = false; }
[ "protected", "function", "disconnect", "(", ")", "{", "$", "this", "->", "log", "(", "'closing sockets ... '", ",", "Net_Notifier_Logger", "::", "VERBOSITY_ALL", ")", ";", "foreach", "(", "$", "this", "->", "clients", "as", "$", "client", ")", "{", "$", "client", "->", "startClose", "(", "Net_Notifier_WebSocket_Connection", "::", "CLOSE_GOING_AWAY", ",", "'Server shutting down.'", ")", ";", "}", "$", "this", "->", "clients", "=", "array", "(", ")", ";", "$", "this", "->", "socket", "=", "null", ";", "$", "this", "->", "log", "(", "'done'", ".", "PHP_EOL", ",", "Net_Notifier_Logger", "::", "VERBOSITY_ALL", ",", "false", ")", ";", "$", "this", "->", "connected", "=", "false", ";", "}" ]
Closes all client sockets and the server listen socket @return void
[ "Closes", "all", "client", "sockets", "and", "the", "server", "listen", "socket" ]
b446e27cd1bebd58ba89243cde1272c5d281d3fb
https://github.com/silverorange/Net_Notifier/blob/b446e27cd1bebd58ba89243cde1272c5d281d3fb/Net/Notifier/Server.php#L513-L530
517
silverorange/Net_Notifier
Net/Notifier/Server.php
Net_Notifier_Server.closeClient
protected function closeClient( Net_Notifier_WebSocket_Connection $client ) { $this->log( sprintf( 'closing client %s ... ', $client->getIPAddress() ), Net_Notifier_Logger::VERBOSITY_CLIENT ); if ($client->getState() < Net_Notifier_WebSocket_Connection::STATE_CLOSED) { $client->close(); } $key = array_search($client, $this->clients); unset($this->clients[$key]); $key = array_search($client, $this->listenClients); if ($key !== false) { unset($this->listenClients[$key]); } $this->log( 'done' . PHP_EOL, Net_Notifier_Logger::VERBOSITY_CLIENT, false ); }
php
protected function closeClient( Net_Notifier_WebSocket_Connection $client ) { $this->log( sprintf( 'closing client %s ... ', $client->getIPAddress() ), Net_Notifier_Logger::VERBOSITY_CLIENT ); if ($client->getState() < Net_Notifier_WebSocket_Connection::STATE_CLOSED) { $client->close(); } $key = array_search($client, $this->clients); unset($this->clients[$key]); $key = array_search($client, $this->listenClients); if ($key !== false) { unset($this->listenClients[$key]); } $this->log( 'done' . PHP_EOL, Net_Notifier_Logger::VERBOSITY_CLIENT, false ); }
[ "protected", "function", "closeClient", "(", "Net_Notifier_WebSocket_Connection", "$", "client", ")", "{", "$", "this", "->", "log", "(", "sprintf", "(", "'closing client %s ... '", ",", "$", "client", "->", "getIPAddress", "(", ")", ")", ",", "Net_Notifier_Logger", "::", "VERBOSITY_CLIENT", ")", ";", "if", "(", "$", "client", "->", "getState", "(", ")", "<", "Net_Notifier_WebSocket_Connection", "::", "STATE_CLOSED", ")", "{", "$", "client", "->", "close", "(", ")", ";", "}", "$", "key", "=", "array_search", "(", "$", "client", ",", "$", "this", "->", "clients", ")", ";", "unset", "(", "$", "this", "->", "clients", "[", "$", "key", "]", ")", ";", "$", "key", "=", "array_search", "(", "$", "client", ",", "$", "this", "->", "listenClients", ")", ";", "if", "(", "$", "key", "!==", "false", ")", "{", "unset", "(", "$", "this", "->", "listenClients", "[", "$", "key", "]", ")", ";", "}", "$", "this", "->", "log", "(", "'done'", ".", "PHP_EOL", ",", "Net_Notifier_Logger", "::", "VERBOSITY_CLIENT", ",", "false", ")", ";", "}" ]
Closes a client socket and removes the client from the list of clients @param Net_Notifier_WebSocket_Connection $client the client to close. @return void
[ "Closes", "a", "client", "socket", "and", "removes", "the", "client", "from", "the", "list", "of", "clients" ]
b446e27cd1bebd58ba89243cde1272c5d281d3fb
https://github.com/silverorange/Net_Notifier/blob/b446e27cd1bebd58ba89243cde1272c5d281d3fb/Net/Notifier/Server.php#L542-L570
518
silverorange/Net_Notifier
Net/Notifier/Server.php
Net_Notifier_Server.startCloseClient
protected function startCloseClient( Net_Notifier_WebSocket_Connection $client, $code = Net_Notifier_WebSocket_Connection::CLOSE_NORMAL, $reason = '' ) { $this->log( sprintf( 'disconnecting client from %s for reason "%s" ... ', $client->getIPAddress(), $reason ), Net_Notifier_Logger::VERBOSITY_CLIENT ); $client->startClose($code, $reason); $this->log( 'done' . PHP_EOL, Net_Notifier_Logger::VERBOSITY_CLIENT, false ); }
php
protected function startCloseClient( Net_Notifier_WebSocket_Connection $client, $code = Net_Notifier_WebSocket_Connection::CLOSE_NORMAL, $reason = '' ) { $this->log( sprintf( 'disconnecting client from %s for reason "%s" ... ', $client->getIPAddress(), $reason ), Net_Notifier_Logger::VERBOSITY_CLIENT ); $client->startClose($code, $reason); $this->log( 'done' . PHP_EOL, Net_Notifier_Logger::VERBOSITY_CLIENT, false ); }
[ "protected", "function", "startCloseClient", "(", "Net_Notifier_WebSocket_Connection", "$", "client", ",", "$", "code", "=", "Net_Notifier_WebSocket_Connection", "::", "CLOSE_NORMAL", ",", "$", "reason", "=", "''", ")", "{", "$", "this", "->", "log", "(", "sprintf", "(", "'disconnecting client from %s for reason \"%s\" ... '", ",", "$", "client", "->", "getIPAddress", "(", ")", ",", "$", "reason", ")", ",", "Net_Notifier_Logger", "::", "VERBOSITY_CLIENT", ")", ";", "$", "client", "->", "startClose", "(", "$", "code", ",", "$", "reason", ")", ";", "$", "this", "->", "log", "(", "'done'", ".", "PHP_EOL", ",", "Net_Notifier_Logger", "::", "VERBOSITY_CLIENT", ",", "false", ")", ";", "}" ]
Initiates the closing handshake for a client connection @param Net_Notifier_WebSocket_Connection $client the client to close. @param integer $code optional. The WebSocket close close reason code. If not specified, {@link Net_Notifier_WebSocket_Connection::CLOSE_NORMAL} is used. @param string $reason optional. A description of why the connection is being closed. @return void
[ "Initiates", "the", "closing", "handshake", "for", "a", "client", "connection" ]
b446e27cd1bebd58ba89243cde1272c5d281d3fb
https://github.com/silverorange/Net_Notifier/blob/b446e27cd1bebd58ba89243cde1272c5d281d3fb/Net/Notifier/Server.php#L590-L611
519
silverorange/Net_Notifier
Net/Notifier/Server.php
Net_Notifier_Server.&
protected function &getReadClients(&$read) { $clients = array(); foreach ($this->clients as $client) { if (in_array($client->getSocket()->getRawSocket(), $read)) { $clients[] = $client; } } return $clients; }
php
protected function &getReadClients(&$read) { $clients = array(); foreach ($this->clients as $client) { if (in_array($client->getSocket()->getRawSocket(), $read)) { $clients[] = $client; } } return $clients; }
[ "protected", "function", "&", "getReadClients", "(", "&", "$", "read", ")", "{", "$", "clients", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "clients", "as", "$", "client", ")", "{", "if", "(", "in_array", "(", "$", "client", "->", "getSocket", "(", ")", "->", "getRawSocket", "(", ")", ",", "$", "read", ")", ")", "{", "$", "clients", "[", "]", "=", "$", "client", ";", "}", "}", "return", "$", "clients", ";", "}" ]
Gets an array of client connections whose sockets were read @param array &$read an array of sockets that were read. @return array an array of {@link Net_Notifier_WebSocket_Connection} objects having sockets found in the given array of read sockets.
[ "Gets", "an", "array", "of", "client", "connections", "whose", "sockets", "were", "read" ]
b446e27cd1bebd58ba89243cde1272c5d281d3fb
https://github.com/silverorange/Net_Notifier/blob/b446e27cd1bebd58ba89243cde1272c5d281d3fb/Net/Notifier/Server.php#L625-L636
520
silverorange/Net_Notifier
Net/Notifier/Server.php
Net_Notifier_Server.&
protected function &getReadArray() { $readArray = array(); $readArray[] = $this->socket->getRawSocket(); foreach ($this->clients as $client) { if ($client->getState() < Net_Notifier_WebSocket_Connection::STATE_CLOSED) { $readArray[] = $client->getSocket()->getRawSocket(); } } return $readArray; }
php
protected function &getReadArray() { $readArray = array(); $readArray[] = $this->socket->getRawSocket(); foreach ($this->clients as $client) { if ($client->getState() < Net_Notifier_WebSocket_Connection::STATE_CLOSED) { $readArray[] = $client->getSocket()->getRawSocket(); } } return $readArray; }
[ "protected", "function", "&", "getReadArray", "(", ")", "{", "$", "readArray", "=", "array", "(", ")", ";", "$", "readArray", "[", "]", "=", "$", "this", "->", "socket", "->", "getRawSocket", "(", ")", ";", "foreach", "(", "$", "this", "->", "clients", "as", "$", "client", ")", "{", "if", "(", "$", "client", "->", "getState", "(", ")", "<", "Net_Notifier_WebSocket_Connection", "::", "STATE_CLOSED", ")", "{", "$", "readArray", "[", "]", "=", "$", "client", "->", "getSocket", "(", ")", "->", "getRawSocket", "(", ")", ";", "}", "}", "return", "$", "readArray", ";", "}" ]
Gets an array of sockets to check for reading @return array an aray of sockets to check for reading.
[ "Gets", "an", "array", "of", "sockets", "to", "check", "for", "reading" ]
b446e27cd1bebd58ba89243cde1272c5d281d3fb
https://github.com/silverorange/Net_Notifier/blob/b446e27cd1bebd58ba89243cde1272c5d281d3fb/Net/Notifier/Server.php#L646-L657
521
silverorange/Net_Notifier
Net/Notifier/Server.php
Net_Notifier_Server.log
protected function log( $message, $priority = Net_Notifier_Logger::VERBOSITY_MESSAGES, $timestamp = true ) { if ($this->logger instanceof Net_Notifier_Logger) { $this->logger->log($message, $priority, $timestamp); } return $this; }
php
protected function log( $message, $priority = Net_Notifier_Logger::VERBOSITY_MESSAGES, $timestamp = true ) { if ($this->logger instanceof Net_Notifier_Logger) { $this->logger->log($message, $priority, $timestamp); } return $this; }
[ "protected", "function", "log", "(", "$", "message", ",", "$", "priority", "=", "Net_Notifier_Logger", "::", "VERBOSITY_MESSAGES", ",", "$", "timestamp", "=", "true", ")", "{", "if", "(", "$", "this", "->", "logger", "instanceof", "Net_Notifier_Logger", ")", "{", "$", "this", "->", "logger", "->", "log", "(", "$", "message", ",", "$", "priority", ",", "$", "timestamp", ")", ";", "}", "return", "$", "this", ";", "}" ]
Logs a message with the specified priority @param string $message the message to log. @param integer $priority an optional verbosity level to display at. By default, this is {@link Net_Notifier_Logger::VERBOSITY_MESSAGES}. @param boolean $timestamp optional. Whether or not to include a timestamp with the logged message. If not specified, a timetamp is included. @return Net_Notifier_Server the current object, for fluent interface.
[ "Logs", "a", "message", "with", "the", "specified", "priority" ]
b446e27cd1bebd58ba89243cde1272c5d281d3fb
https://github.com/silverorange/Net_Notifier/blob/b446e27cd1bebd58ba89243cde1272c5d281d3fb/Net/Notifier/Server.php#L675-L685
522
marando/phpSOFA
src/Marando/IAU/iauAtic13.php
iauAtic13.Atic13
public static function Atic13($ri, $di, $date1, $date2, &$rc, &$dc, &$eo) { /* Star-independent astrometry parameters */ $astrom = new iauASTROM(); /* Star-independent astrometry parameters. */ IAU::Apci13($date1, $date2, $astrom, $eo); /* CIRS to ICRS astrometric. */ IAU::Aticq($ri, $di, $astrom, $rc, $dc); /* Finished. */ }
php
public static function Atic13($ri, $di, $date1, $date2, &$rc, &$dc, &$eo) { /* Star-independent astrometry parameters */ $astrom = new iauASTROM(); /* Star-independent astrometry parameters. */ IAU::Apci13($date1, $date2, $astrom, $eo); /* CIRS to ICRS astrometric. */ IAU::Aticq($ri, $di, $astrom, $rc, $dc); /* Finished. */ }
[ "public", "static", "function", "Atic13", "(", "$", "ri", ",", "$", "di", ",", "$", "date1", ",", "$", "date2", ",", "&", "$", "rc", ",", "&", "$", "dc", ",", "&", "$", "eo", ")", "{", "/* Star-independent astrometry parameters */", "$", "astrom", "=", "new", "iauASTROM", "(", ")", ";", "/* Star-independent astrometry parameters. */", "IAU", "::", "Apci13", "(", "$", "date1", ",", "$", "date2", ",", "$", "astrom", ",", "$", "eo", ")", ";", "/* CIRS to ICRS astrometric. */", "IAU", "::", "Aticq", "(", "$", "ri", ",", "$", "di", ",", "$", "astrom", ",", "$", "rc", ",", "$", "dc", ")", ";", "/* Finished. */", "}" ]
- - - - - - - - - - i a u A t i c 1 3 - - - - - - - - - - Transform star RA,Dec from geocentric CIRS to ICRS astrometric. This function is part of the International Astronomical Union's SOFA (Standards of Fundamental Astronomy) software collection. Status: support function. Given: ri,di double CIRS geocentric RA,Dec (radians) date1 double TDB as a 2-part... date2 double ...Julian Date (Note 1) Returned: rc,dc double ICRS astrometric RA,Dec (radians) eo double equation of the origins (ERA-GST, Note 4) Notes: 1) The TDB date date1+date2 is a Julian Date, apportioned in any convenient way between the two arguments. For example, JD(TDB)=2450123.7 could be expressed in any of these ways, among others: date1 date2 2450123.7 0.0 (JD method) 2451545.0 -1421.3 (J2000 method) 2400000.5 50123.2 (MJD method) 2450123.5 0.2 (date & time method) The JD method is the most natural and convenient to use in cases where the loss of several decimal digits of resolution is acceptable. The J2000 method is best matched to the way the argument is handled internally and will deliver the optimum resolution. The MJD method and the date & time methods are both good compromises between resolution and convenience. For most applications of this function the choice will not be at all critical. TT can be used instead of TDB without any significant impact on accuracy. 2) Iterative techniques are used for the aberration and light deflection corrections so that the functions iauAtic13 (or iauAticq) and iauAtci13 (or iauAtciq) are accurate inverses; even at the edge of the Sun's disk the discrepancy is only about 1 nanoarcsecond. 3) The available accuracy is better than 1 milliarcsecond, limited mainly by the precession-nutation model that is used, namely IAU 2000A/2006. Very close to solar system bodies, additional errors of up to several milliarcseconds can occur because of unmodeled light deflection; however, the Sun's contribution is taken into account, to first order. The accuracy limitations of the SOFA function iauEpv00 (used to compute Earth position and velocity) can contribute aberration errors of up to 5 microarcseconds. Light deflection at the Sun's limb is uncertain at the 0.4 mas level. 4) Should the transformation to (equinox based) J2000.0 mean place be required rather than (CIO based) ICRS coordinates, subtract the equation of the origins from the returned right ascension: RA = RI - EO. (The iauAnp function can then be applied, as required, to keep the result in the conventional 0-2pi range.) Called: iauApci13 astrometry parameters, ICRS-CIRS, 2013 iauAticq quick CIRS to ICRS astrometric This revision: 2013 October 9 SOFA release 2015-02-09 Copyright (C) 2015 IAU SOFA Board. See notes at end.
[ "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "i", "a", "u", "A", "t", "i", "c", "1", "3", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-" ]
757fa49fe335ae1210eaa7735473fd4388b13f07
https://github.com/marando/phpSOFA/blob/757fa49fe335ae1210eaa7735473fd4388b13f07/src/Marando/IAU/iauAtic13.php#L87-L98
523
it-blaster/uploadable-behavior
Behavior/UploadableBehavior.php
UploadableBehavior.preSave
public function preSave() { $script = ''; foreach ($this->getColumns() as $column) { $script .= $this->renderTemplate('preSave', array( 'column' => $this->getTable()->getColumn($column)->getFullyQualifiedName(), 'setter' => $this->getColumnSetter($column), 'getter' => $this->getColumnGetter($column) )); } return $script; }
php
public function preSave() { $script = ''; foreach ($this->getColumns() as $column) { $script .= $this->renderTemplate('preSave', array( 'column' => $this->getTable()->getColumn($column)->getFullyQualifiedName(), 'setter' => $this->getColumnSetter($column), 'getter' => $this->getColumnGetter($column) )); } return $script; }
[ "public", "function", "preSave", "(", ")", "{", "$", "script", "=", "''", ";", "foreach", "(", "$", "this", "->", "getColumns", "(", ")", "as", "$", "column", ")", "{", "$", "script", ".=", "$", "this", "->", "renderTemplate", "(", "'preSave'", ",", "array", "(", "'column'", "=>", "$", "this", "->", "getTable", "(", ")", "->", "getColumn", "(", "$", "column", ")", "->", "getFullyQualifiedName", "(", ")", ",", "'setter'", "=>", "$", "this", "->", "getColumnSetter", "(", "$", "column", ")", ",", "'getter'", "=>", "$", "this", "->", "getColumnGetter", "(", "$", "column", ")", ")", ")", ";", "}", "return", "$", "script", ";", "}" ]
Checks if need to move any uploaded files @return string
[ "Checks", "if", "need", "to", "move", "any", "uploaded", "files" ]
d49ca5c7c9c85466ef2be0144296a339634ed222
https://github.com/it-blaster/uploadable-behavior/blob/d49ca5c7c9c85466ef2be0144296a339634ed222/Behavior/UploadableBehavior.php#L147-L160
524
treehouselabs/feeder
src/TreeHouse/Feeder/Reader/AbstractReader.php
AbstractReader.read
public function read() { if (!$this->valid()) { return null; } // keep a local copy of the resource; the next() call could change the cached one $resource = $this->resource; $item = $this->current(); $this->next(); // serialize the item $event = new ResourceSerializeEvent($resource, $item); $this->eventDispatcher->dispatch(FeedEvents::RESOURCE_PRE_SERIALIZE, $event); $item = $this->serialize($item); $this->eventDispatcher->dispatch(FeedEvents::RESOURCE_POST_SERIALIZE, $event); return $item; }
php
public function read() { if (!$this->valid()) { return null; } // keep a local copy of the resource; the next() call could change the cached one $resource = $this->resource; $item = $this->current(); $this->next(); // serialize the item $event = new ResourceSerializeEvent($resource, $item); $this->eventDispatcher->dispatch(FeedEvents::RESOURCE_PRE_SERIALIZE, $event); $item = $this->serialize($item); $this->eventDispatcher->dispatch(FeedEvents::RESOURCE_POST_SERIALIZE, $event); return $item; }
[ "public", "function", "read", "(", ")", "{", "if", "(", "!", "$", "this", "->", "valid", "(", ")", ")", "{", "return", "null", ";", "}", "// keep a local copy of the resource; the next() call could change the cached one", "$", "resource", "=", "$", "this", "->", "resource", ";", "$", "item", "=", "$", "this", "->", "current", "(", ")", ";", "$", "this", "->", "next", "(", ")", ";", "// serialize the item", "$", "event", "=", "new", "ResourceSerializeEvent", "(", "$", "resource", ",", "$", "item", ")", ";", "$", "this", "->", "eventDispatcher", "->", "dispatch", "(", "FeedEvents", "::", "RESOURCE_PRE_SERIALIZE", ",", "$", "event", ")", ";", "$", "item", "=", "$", "this", "->", "serialize", "(", "$", "item", ")", ";", "$", "this", "->", "eventDispatcher", "->", "dispatch", "(", "FeedEvents", "::", "RESOURCE_POST_SERIALIZE", ",", "$", "event", ")", ";", "return", "$", "item", ";", "}" ]
Wrapper that implements various calls, so you can use the iterator in a simple while loop. @return ParameterBag
[ "Wrapper", "that", "implements", "various", "calls", "so", "you", "can", "use", "the", "iterator", "in", "a", "simple", "while", "loop", "." ]
756018648ae28e028cef572559bfebd4eb77127a
https://github.com/treehouselabs/feeder/blob/756018648ae28e028cef572559bfebd4eb77127a/src/TreeHouse/Feeder/Reader/AbstractReader.php#L129-L148
525
jmpantoja/planb-utils
src/Beautifier/Parser/Decorator/LineWidthDecorator.php
LineWidthDecorator.decorate
public function decorate(Style $style, string $value): string { if (!$style->isExpand()) { return $value; } $lineWidth = $style->getLineWidth(); $align = $style->getAlignValue(); return str_pad($value, $lineWidth, ' ', $align); }
php
public function decorate(Style $style, string $value): string { if (!$style->isExpand()) { return $value; } $lineWidth = $style->getLineWidth(); $align = $style->getAlignValue(); return str_pad($value, $lineWidth, ' ', $align); }
[ "public", "function", "decorate", "(", "Style", "$", "style", ",", "string", "$", "value", ")", ":", "string", "{", "if", "(", "!", "$", "style", "->", "isExpand", "(", ")", ")", "{", "return", "$", "value", ";", "}", "$", "lineWidth", "=", "$", "style", "->", "getLineWidth", "(", ")", ";", "$", "align", "=", "$", "style", "->", "getAlignValue", "(", ")", ";", "return", "str_pad", "(", "$", "value", ",", "$", "lineWidth", ",", "' '", ",", "$", "align", ")", ";", "}" ]
Decora un valor, aplicando un estilo @param \PlanB\Beautifier\Style\Style $style @param string $value @return string
[ "Decora", "un", "valor", "aplicando", "un", "estilo" ]
d17fbced4a285275928f8428ee56e269eb851690
https://github.com/jmpantoja/planb-utils/blob/d17fbced4a285275928f8428ee56e269eb851690/src/Beautifier/Parser/Decorator/LineWidthDecorator.php#L42-L52
526
samurai-fw/samurai
src/Console/Application.php
Application.inheritConfigure
public function inheritConfigure(Samurai\Application $app) { // environment $app->setEnv($this->getEnvFromEnvironmentVariables()); // application dir. $app->addAppPathUsePsr4(__DIR__, __NAMESPACE__, 'Samurai\\', self::PRIORITY_LOW); }
php
public function inheritConfigure(Samurai\Application $app) { // environment $app->setEnv($this->getEnvFromEnvironmentVariables()); // application dir. $app->addAppPathUsePsr4(__DIR__, __NAMESPACE__, 'Samurai\\', self::PRIORITY_LOW); }
[ "public", "function", "inheritConfigure", "(", "Samurai", "\\", "Application", "$", "app", ")", "{", "// environment", "$", "app", "->", "setEnv", "(", "$", "this", "->", "getEnvFromEnvironmentVariables", "(", ")", ")", ";", "// application dir.", "$", "app", "->", "addAppPathUsePsr4", "(", "__DIR__", ",", "__NAMESPACE__", ",", "'Samurai\\\\'", ",", "self", "::", "PRIORITY_LOW", ")", ";", "}" ]
configure from application console @access public @param Samurai\Application $app
[ "configure", "from", "application", "console" ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Console/Application.php#L70-L77
527
indigophp-archive/fuel-core
lib/Fuel/Orm/Observer/Sort.php
Sort.before_insert
public function before_insert(Orm\Model $obj) { if ($obj instanceof SortableInterface) { $max = $obj->getSortMax(); } else { $max = $obj->query()->max($this->_property); } $obj->{$this->_property} = $max + $this->_offset; }
php
public function before_insert(Orm\Model $obj) { if ($obj instanceof SortableInterface) { $max = $obj->getSortMax(); } else { $max = $obj->query()->max($this->_property); } $obj->{$this->_property} = $max + $this->_offset; }
[ "public", "function", "before_insert", "(", "Orm", "\\", "Model", "$", "obj", ")", "{", "if", "(", "$", "obj", "instanceof", "SortableInterface", ")", "{", "$", "max", "=", "$", "obj", "->", "getSortMax", "(", ")", ";", "}", "else", "{", "$", "max", "=", "$", "obj", "->", "query", "(", ")", "->", "max", "(", "$", "this", "->", "_property", ")", ";", "}", "$", "obj", "->", "{", "$", "this", "->", "_property", "}", "=", "$", "max", "+", "$", "this", "->", "_offset", ";", "}" ]
Sets the sort property to the current sort value @param Model Model object subject of this observer method
[ "Sets", "the", "sort", "property", "to", "the", "current", "sort", "value" ]
275462154fb7937f8e1c2c541b31d8e7c5760e39
https://github.com/indigophp-archive/fuel-core/blob/275462154fb7937f8e1c2c541b31d8e7c5760e39/lib/Fuel/Orm/Observer/Sort.php#L73-L85
528
vinala/kernel
src/Database/InOut/Mysql/Exporter.php
Exporter.stucture
public static function stucture($table) { $drop = "DROP TABLE IF EXISTS `$table`;"; $res = Driver::read('SHOW CREATE TABLE '.$table); $struct = $res[0]['Create Table']; // return "\n\n-- $table\n\n-- '$table' Table Structure\n$drop\n".$struct.";\n\n"; }
php
public static function stucture($table) { $drop = "DROP TABLE IF EXISTS `$table`;"; $res = Driver::read('SHOW CREATE TABLE '.$table); $struct = $res[0]['Create Table']; // return "\n\n-- $table\n\n-- '$table' Table Structure\n$drop\n".$struct.";\n\n"; }
[ "public", "static", "function", "stucture", "(", "$", "table", ")", "{", "$", "drop", "=", "\"DROP TABLE IF EXISTS `$table`;\"", ";", "$", "res", "=", "Driver", "::", "read", "(", "'SHOW CREATE TABLE '", ".", "$", "table", ")", ";", "$", "struct", "=", "$", "res", "[", "0", "]", "[", "'Create Table'", "]", ";", "//", "return", "\"\\n\\n-- $table\\n\\n-- '$table' Table Structure\\n$drop\\n\"", ".", "$", "struct", ".", "\";\\n\\n\"", ";", "}" ]
Get SQL query of table stucture. @param string $table name of table to export @return string table structure
[ "Get", "SQL", "query", "of", "table", "stucture", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Database/InOut/Mysql/Exporter.php#L23-L30
529
vinala/kernel
src/Database/InOut/Mysql/Exporter.php
Exporter.tables
public static function tables() { $tables = false; // $Tables = Driver::read('SHOW TABLES', Driver::INDEX); // die(var_dump($Tables)); // foreach ($Tables as $row) { $target_tables[] = $row[0]; } // if ($tables !== false) { $target_tables = array_intersect($target_tables, $tables); } // return $target_tables; }
php
public static function tables() { $tables = false; // $Tables = Driver::read('SHOW TABLES', Driver::INDEX); // die(var_dump($Tables)); // foreach ($Tables as $row) { $target_tables[] = $row[0]; } // if ($tables !== false) { $target_tables = array_intersect($target_tables, $tables); } // return $target_tables; }
[ "public", "static", "function", "tables", "(", ")", "{", "$", "tables", "=", "false", ";", "//", "$", "Tables", "=", "Driver", "::", "read", "(", "'SHOW TABLES'", ",", "Driver", "::", "INDEX", ")", ";", "// die(var_dump($Tables));", "//", "foreach", "(", "$", "Tables", "as", "$", "row", ")", "{", "$", "target_tables", "[", "]", "=", "$", "row", "[", "0", "]", ";", "}", "//", "if", "(", "$", "tables", "!==", "false", ")", "{", "$", "target_tables", "=", "array_intersect", "(", "$", "target_tables", ",", "$", "tables", ")", ";", "}", "//", "return", "$", "target_tables", ";", "}" ]
Get all data tables created in the current database. @return array
[ "Get", "all", "data", "tables", "created", "in", "the", "current", "database", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Database/InOut/Mysql/Exporter.php#L37-L53
530
vinala/kernel
src/Database/InOut/Mysql/Exporter.php
Exporter.info
public static function info() { $database = Config::get('database.database'); $host = Config::get('database.host'); $username = Config::get('database.username'); // return "\n\n-- Database : $database\n-- Host : $host\n-- User : $username\n"; }
php
public static function info() { $database = Config::get('database.database'); $host = Config::get('database.host'); $username = Config::get('database.username'); // return "\n\n-- Database : $database\n-- Host : $host\n-- User : $username\n"; }
[ "public", "static", "function", "info", "(", ")", "{", "$", "database", "=", "Config", "::", "get", "(", "'database.database'", ")", ";", "$", "host", "=", "Config", "::", "get", "(", "'database.host'", ")", ";", "$", "username", "=", "Config", "::", "get", "(", "'database.username'", ")", ";", "//", "return", "\"\\n\\n-- Database : $database\\n-- Host : $host\\n-- User : $username\\n\"", ";", "}" ]
Get info about database server connection. @return string
[ "Get", "info", "about", "database", "server", "connection", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Database/InOut/Mysql/Exporter.php#L74-L81
531
vinala/kernel
src/Database/InOut/Mysql/Exporter.php
Exporter.save
public static function save($file, $query) { $path = Application::$root."database/backup/$file"; // return (new Filesystem())->put($path, $query); }
php
public static function save($file, $query) { $path = Application::$root."database/backup/$file"; // return (new Filesystem())->put($path, $query); }
[ "public", "static", "function", "save", "(", "$", "file", ",", "$", "query", ")", "{", "$", "path", "=", "Application", "::", "$", "root", ".", "\"database/backup/$file\"", ";", "//", "return", "(", "new", "Filesystem", "(", ")", ")", "->", "put", "(", "$", "path", ",", "$", "query", ")", ";", "}" ]
Save exported data in sql file. @param timestamp $time the current time @param string $query the sql query @return Filesystem
[ "Save", "exported", "data", "in", "sql", "file", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Database/InOut/Mysql/Exporter.php#L91-L96
532
vinala/kernel
src/Database/InOut/Mysql/Exporter.php
Exporter.fetch
public static function fetch($tables) { foreach ($tables as $table) { $result = Driver::query("SELECT * FROM $table", Driver::INDEX); $fields = $result->columnCount(); $rows = $result->rowCount(); $data = Driver::read("SELECT * FROM $table", Driver::INDEX); // $content = (!isset($content) ? '' : $content).self::stucture($table); // $st_counter = 0; foreach ($data as $row) { if ($st_counter % 100 == 0 || $st_counter == 0) { $content .= "\n-- Table Data\nINSERT INTO ".$table.' VALUES'; } // $content .= "\n("; // for ($j = 0; $j < $fields; $j++) { $row[$j] = str_replace("\n", '\\n', addslashes($row[$j])); // if (isset($row[$j])) { if (!empty($row[$j])) { $content .= '"'.$row[$j].'"'; } else { $content .= 'NULL'; } } // else { $content .= '""'; } // if ($j < ($fields - 1)) { $content .= ','; } } // $content .= ')'; // if ((($st_counter + 1) % 100 == 0 && $st_counter != 0) || $st_counter + 1 == $rows) { $content .= ';'; } // else { $content .= ','; } // $st_counter = $st_counter + 1; } $content .= "\n\n\n"; } return $content; }
php
public static function fetch($tables) { foreach ($tables as $table) { $result = Driver::query("SELECT * FROM $table", Driver::INDEX); $fields = $result->columnCount(); $rows = $result->rowCount(); $data = Driver::read("SELECT * FROM $table", Driver::INDEX); // $content = (!isset($content) ? '' : $content).self::stucture($table); // $st_counter = 0; foreach ($data as $row) { if ($st_counter % 100 == 0 || $st_counter == 0) { $content .= "\n-- Table Data\nINSERT INTO ".$table.' VALUES'; } // $content .= "\n("; // for ($j = 0; $j < $fields; $j++) { $row[$j] = str_replace("\n", '\\n', addslashes($row[$j])); // if (isset($row[$j])) { if (!empty($row[$j])) { $content .= '"'.$row[$j].'"'; } else { $content .= 'NULL'; } } // else { $content .= '""'; } // if ($j < ($fields - 1)) { $content .= ','; } } // $content .= ')'; // if ((($st_counter + 1) % 100 == 0 && $st_counter != 0) || $st_counter + 1 == $rows) { $content .= ';'; } // else { $content .= ','; } // $st_counter = $st_counter + 1; } $content .= "\n\n\n"; } return $content; }
[ "public", "static", "function", "fetch", "(", "$", "tables", ")", "{", "foreach", "(", "$", "tables", "as", "$", "table", ")", "{", "$", "result", "=", "Driver", "::", "query", "(", "\"SELECT * FROM $table\"", ",", "Driver", "::", "INDEX", ")", ";", "$", "fields", "=", "$", "result", "->", "columnCount", "(", ")", ";", "$", "rows", "=", "$", "result", "->", "rowCount", "(", ")", ";", "$", "data", "=", "Driver", "::", "read", "(", "\"SELECT * FROM $table\"", ",", "Driver", "::", "INDEX", ")", ";", "//", "$", "content", "=", "(", "!", "isset", "(", "$", "content", ")", "?", "''", ":", "$", "content", ")", ".", "self", "::", "stucture", "(", "$", "table", ")", ";", "//", "$", "st_counter", "=", "0", ";", "foreach", "(", "$", "data", "as", "$", "row", ")", "{", "if", "(", "$", "st_counter", "%", "100", "==", "0", "||", "$", "st_counter", "==", "0", ")", "{", "$", "content", ".=", "\"\\n-- Table Data\\nINSERT INTO \"", ".", "$", "table", ".", "' VALUES'", ";", "}", "//", "$", "content", ".=", "\"\\n(\"", ";", "//", "for", "(", "$", "j", "=", "0", ";", "$", "j", "<", "$", "fields", ";", "$", "j", "++", ")", "{", "$", "row", "[", "$", "j", "]", "=", "str_replace", "(", "\"\\n\"", ",", "'\\\\n'", ",", "addslashes", "(", "$", "row", "[", "$", "j", "]", ")", ")", ";", "//", "if", "(", "isset", "(", "$", "row", "[", "$", "j", "]", ")", ")", "{", "if", "(", "!", "empty", "(", "$", "row", "[", "$", "j", "]", ")", ")", "{", "$", "content", ".=", "'\"'", ".", "$", "row", "[", "$", "j", "]", ".", "'\"'", ";", "}", "else", "{", "$", "content", ".=", "'NULL'", ";", "}", "}", "//", "else", "{", "$", "content", ".=", "'\"\"'", ";", "}", "//", "if", "(", "$", "j", "<", "(", "$", "fields", "-", "1", ")", ")", "{", "$", "content", ".=", "','", ";", "}", "}", "//", "$", "content", ".=", "')'", ";", "//", "if", "(", "(", "(", "$", "st_counter", "+", "1", ")", "%", "100", "==", "0", "&&", "$", "st_counter", "!=", "0", ")", "||", "$", "st_counter", "+", "1", "==", "$", "rows", ")", "{", "$", "content", ".=", "';'", ";", "}", "//", "else", "{", "$", "content", ".=", "','", ";", "}", "//", "$", "st_counter", "=", "$", "st_counter", "+", "1", ";", "}", "$", "content", ".=", "\"\\n\\n\\n\"", ";", "}", "return", "$", "content", ";", "}" ]
fetch data inside data tables. @param array $tables tables of database @return string
[ "fetch", "data", "inside", "data", "tables", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Database/InOut/Mysql/Exporter.php#L117-L173
533
vinala/kernel
src/Database/InOut/Mysql/Exporter.php
Exporter.export
public static function export($name) { $now = time(); // $tables = self::tables(); // $query = self::time($now).self::info(); $query .= self::database(); $query .= self::fetch($tables); // $file = ($name ?: config('database.database').'_'.$now).'.sql'; // self::file($file); // self::save($file, $query); // return true; }
php
public static function export($name) { $now = time(); // $tables = self::tables(); // $query = self::time($now).self::info(); $query .= self::database(); $query .= self::fetch($tables); // $file = ($name ?: config('database.database').'_'.$now).'.sql'; // self::file($file); // self::save($file, $query); // return true; }
[ "public", "static", "function", "export", "(", "$", "name", ")", "{", "$", "now", "=", "time", "(", ")", ";", "//", "$", "tables", "=", "self", "::", "tables", "(", ")", ";", "//", "$", "query", "=", "self", "::", "time", "(", "$", "now", ")", ".", "self", "::", "info", "(", ")", ";", "$", "query", ".=", "self", "::", "database", "(", ")", ";", "$", "query", ".=", "self", "::", "fetch", "(", "$", "tables", ")", ";", "//", "$", "file", "=", "(", "$", "name", "?", ":", "config", "(", "'database.database'", ")", ".", "'_'", ".", "$", "now", ")", ".", "'.sql'", ";", "//", "self", "::", "file", "(", "$", "file", ")", ";", "//", "self", "::", "save", "(", "$", "file", ",", "$", "query", ")", ";", "//", "return", "true", ";", "}" ]
Export the current database. @return bool
[ "Export", "the", "current", "database", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Database/InOut/Mysql/Exporter.php#L194-L211
534
etcinit/tutum-php
src/Chromabits/TutumClient/Support/EnvUtils.php
EnvUtils.getUuidFromUrl
protected function getUuidFromUrl(Url $url) { $segments = $url->getPathSegments(); if (count($segments) < 1) { throw new Exception('Invalid UUID'); } if (count($segments) < 2) { return $segments[0]; } return $segments[count($segments) - 2]; }
php
protected function getUuidFromUrl(Url $url) { $segments = $url->getPathSegments(); if (count($segments) < 1) { throw new Exception('Invalid UUID'); } if (count($segments) < 2) { return $segments[0]; } return $segments[count($segments) - 2]; }
[ "protected", "function", "getUuidFromUrl", "(", "Url", "$", "url", ")", "{", "$", "segments", "=", "$", "url", "->", "getPathSegments", "(", ")", ";", "if", "(", "count", "(", "$", "segments", ")", "<", "1", ")", "{", "throw", "new", "Exception", "(", "'Invalid UUID'", ")", ";", "}", "if", "(", "count", "(", "$", "segments", ")", "<", "2", ")", "{", "return", "$", "segments", "[", "0", "]", ";", "}", "return", "$", "segments", "[", "count", "(", "$", "segments", ")", "-", "2", "]", ";", "}" ]
Extract the last part of a URL which in Tutum's case is usually the UUID @param Url $url @return mixed @throws Exception
[ "Extract", "the", "last", "part", "of", "a", "URL" ]
39fb3375e0d47109a5da70a0e441efb8fd4f4008
https://github.com/etcinit/tutum-php/blob/39fb3375e0d47109a5da70a0e441efb8fd4f4008/src/Chromabits/TutumClient/Support/EnvUtils.php#L86-L99
535
rseyferth/chickenwire
src/ChickenWire/Model.php
Model._initializeCW
private static function _initializeCW($table) { // Is it an auth model? if (isset(static::$authModel) && static::$authModel !== false) { // Get my full class name $myClass = trim(get_called_class(), '\\ '); // Look up the auth object $myAuth = null; foreach (Auth::all() as $auth) { if (trim($auth->model, '\\ ') == $myClass) { $myAuth = $auth; break; } } // Still null? if (is_null($myAuth)) { // Not good... throw new \Exception("There was no Auth defined with model '" . $myClass . "'.", 1); } // Store it self::$auth = $myAuth; // Register auth save callback $table->callback->register("beforeSave", function (\ActiveRecord\Model $model) { $model->_setAuthValues(); }); } }
php
private static function _initializeCW($table) { // Is it an auth model? if (isset(static::$authModel) && static::$authModel !== false) { // Get my full class name $myClass = trim(get_called_class(), '\\ '); // Look up the auth object $myAuth = null; foreach (Auth::all() as $auth) { if (trim($auth->model, '\\ ') == $myClass) { $myAuth = $auth; break; } } // Still null? if (is_null($myAuth)) { // Not good... throw new \Exception("There was no Auth defined with model '" . $myClass . "'.", 1); } // Store it self::$auth = $myAuth; // Register auth save callback $table->callback->register("beforeSave", function (\ActiveRecord\Model $model) { $model->_setAuthValues(); }); } }
[ "private", "static", "function", "_initializeCW", "(", "$", "table", ")", "{", "// Is it an auth model?", "if", "(", "isset", "(", "static", "::", "$", "authModel", ")", "&&", "static", "::", "$", "authModel", "!==", "false", ")", "{", "// Get my full class name", "$", "myClass", "=", "trim", "(", "get_called_class", "(", ")", ",", "'\\\\ '", ")", ";", "// Look up the auth object", "$", "myAuth", "=", "null", ";", "foreach", "(", "Auth", "::", "all", "(", ")", "as", "$", "auth", ")", "{", "if", "(", "trim", "(", "$", "auth", "->", "model", ",", "'\\\\ '", ")", "==", "$", "myClass", ")", "{", "$", "myAuth", "=", "$", "auth", ";", "break", ";", "}", "}", "// Still null?", "if", "(", "is_null", "(", "$", "myAuth", ")", ")", "{", "// Not good...", "throw", "new", "\\", "Exception", "(", "\"There was no Auth defined with model '\"", ".", "$", "myClass", ".", "\"'.\"", ",", "1", ")", ";", "}", "// Store it", "self", "::", "$", "auth", "=", "$", "myAuth", ";", "// Register auth save callback", "$", "table", "->", "callback", "->", "register", "(", "\"beforeSave\"", ",", "function", "(", "\\", "ActiveRecord", "\\", "Model", "$", "model", ")", "{", "$", "model", "->", "_setAuthValues", "(", ")", ";", "}", ")", ";", "}", "}" ]
Initialize ChickenWire featues @param \ActiveRecord\Table The Table object to work with @return void
[ "Initialize", "ChickenWire", "featues" ]
74921f0a0d489366602e25df43eda894719e43d3
https://github.com/rseyferth/chickenwire/blob/74921f0a0d489366602e25df43eda894719e43d3/src/ChickenWire/Model.php#L93-L131
536
rseyferth/chickenwire
src/ChickenWire/Model.php
Model.resaltPassword
public function resaltPassword($password, $salt = '') { // No salt used..? $auth = self::$auth; if ($auth->useSalt == false) { throw new \Exception("This Auth does not use salting.", 1); } // Apply the values to the record $this->setAttributes(array( $auth->saltField => $salt, $auth->passwordField => $password )); }
php
public function resaltPassword($password, $salt = '') { // No salt used..? $auth = self::$auth; if ($auth->useSalt == false) { throw new \Exception("This Auth does not use salting.", 1); } // Apply the values to the record $this->setAttributes(array( $auth->saltField => $salt, $auth->passwordField => $password )); }
[ "public", "function", "resaltPassword", "(", "$", "password", ",", "$", "salt", "=", "''", ")", "{", "// No salt used..?", "$", "auth", "=", "self", "::", "$", "auth", ";", "if", "(", "$", "auth", "->", "useSalt", "==", "false", ")", "{", "throw", "new", "\\", "Exception", "(", "\"This Auth does not use salting.\"", ",", "1", ")", ";", "}", "// Apply the values to the record", "$", "this", "->", "setAttributes", "(", "array", "(", "$", "auth", "->", "saltField", "=>", "$", "salt", ",", "$", "auth", "->", "passwordField", "=>", "$", "password", ")", ")", ";", "}" ]
Re-encrypt the password @param string The plain text password to re-encrypt @param string Optional salt to encrypt with. If you leave this empty, a random salt will be generated. @return void
[ "Re", "-", "encrypt", "the", "password" ]
74921f0a0d489366602e25df43eda894719e43d3
https://github.com/rseyferth/chickenwire/blob/74921f0a0d489366602e25df43eda894719e43d3/src/ChickenWire/Model.php#L195-L210
537
rseyferth/activerecord
lib/Column.php
Column.cast
public function cast($value, $connection) { if ($value === null) return null; switch ($this->type) { case self::STRING: return (string)$value; case self::INTEGER: return (int)$value; case self::DECIMAL: return (double)$value; case self::DATETIME: case self::DATE: if (!$value) return null; if ($value instanceof DateTime) return $value; if ($value instanceof \DateTime) return new DateTime($value->format('Y-m-d H:i:s T')); return $connection->stringToDateTime($value); } return $value; }
php
public function cast($value, $connection) { if ($value === null) return null; switch ($this->type) { case self::STRING: return (string)$value; case self::INTEGER: return (int)$value; case self::DECIMAL: return (double)$value; case self::DATETIME: case self::DATE: if (!$value) return null; if ($value instanceof DateTime) return $value; if ($value instanceof \DateTime) return new DateTime($value->format('Y-m-d H:i:s T')); return $connection->stringToDateTime($value); } return $value; }
[ "public", "function", "cast", "(", "$", "value", ",", "$", "connection", ")", "{", "if", "(", "$", "value", "===", "null", ")", "return", "null", ";", "switch", "(", "$", "this", "->", "type", ")", "{", "case", "self", "::", "STRING", ":", "return", "(", "string", ")", "$", "value", ";", "case", "self", "::", "INTEGER", ":", "return", "(", "int", ")", "$", "value", ";", "case", "self", "::", "DECIMAL", ":", "return", "(", "double", ")", "$", "value", ";", "case", "self", "::", "DATETIME", ":", "case", "self", "::", "DATE", ":", "if", "(", "!", "$", "value", ")", "return", "null", ";", "if", "(", "$", "value", "instanceof", "DateTime", ")", "return", "$", "value", ";", "if", "(", "$", "value", "instanceof", "\\", "DateTime", ")", "return", "new", "DateTime", "(", "$", "value", "->", "format", "(", "'Y-m-d H:i:s T'", ")", ")", ";", "return", "$", "connection", "->", "stringToDateTime", "(", "$", "value", ")", ";", "}", "return", "$", "value", ";", "}" ]
Casts a value to the column's type. @param mixed $value The value to cast @param Connection $connection The Connection this column belongs to @return mixed type-casted value
[ "Casts", "a", "value", "to", "the", "column", "s", "type", "." ]
0e7b1cbddd6f967c3a09adf38753babd5f698e39
https://github.com/rseyferth/activerecord/blob/0e7b1cbddd6f967c3a09adf38753babd5f698e39/lib/Column.php#L112-L136
538
EarthlingInteractive/PHPCMIPREST
lib/EarthIT/CMIPREST/Util.php
EarthIT_CMIPREST_Util.cast
public static function cast( $value, $phpType ) { if( $phpType === null or $value === null ) return $value; switch( $phpType ) { case 'string': return (string)$value; case 'float': return (float)$value; case 'int': return (int)$value; case 'bool': if( is_bool($value) ) return $value; if( is_numeric($value) ) { if( $value == 1 ) return true; if( $value == 0 ) return false; } if( is_string($value) ) { if( in_array($value, array('yes','true','on')) ) return true; if( in_array($value, array('no','false','off','')) ) return false; } throw new Exception("Invalid boolean representation: ".var_export($value,true)); default: throw new Exception("Don't know how to cast to PHP type '$phpType'."); } }
php
public static function cast( $value, $phpType ) { if( $phpType === null or $value === null ) return $value; switch( $phpType ) { case 'string': return (string)$value; case 'float': return (float)$value; case 'int': return (int)$value; case 'bool': if( is_bool($value) ) return $value; if( is_numeric($value) ) { if( $value == 1 ) return true; if( $value == 0 ) return false; } if( is_string($value) ) { if( in_array($value, array('yes','true','on')) ) return true; if( in_array($value, array('no','false','off','')) ) return false; } throw new Exception("Invalid boolean representation: ".var_export($value,true)); default: throw new Exception("Don't know how to cast to PHP type '$phpType'."); } }
[ "public", "static", "function", "cast", "(", "$", "value", ",", "$", "phpType", ")", "{", "if", "(", "$", "phpType", "===", "null", "or", "$", "value", "===", "null", ")", "return", "$", "value", ";", "switch", "(", "$", "phpType", ")", "{", "case", "'string'", ":", "return", "(", "string", ")", "$", "value", ";", "case", "'float'", ":", "return", "(", "float", ")", "$", "value", ";", "case", "'int'", ":", "return", "(", "int", ")", "$", "value", ";", "case", "'bool'", ":", "if", "(", "is_bool", "(", "$", "value", ")", ")", "return", "$", "value", ";", "if", "(", "is_numeric", "(", "$", "value", ")", ")", "{", "if", "(", "$", "value", "==", "1", ")", "return", "true", ";", "if", "(", "$", "value", "==", "0", ")", "return", "false", ";", "}", "if", "(", "is_string", "(", "$", "value", ")", ")", "{", "if", "(", "in_array", "(", "$", "value", ",", "array", "(", "'yes'", ",", "'true'", ",", "'on'", ")", ")", ")", "return", "true", ";", "if", "(", "in_array", "(", "$", "value", ",", "array", "(", "'no'", ",", "'false'", ",", "'off'", ",", "''", ")", ")", ")", "return", "false", ";", "}", "throw", "new", "Exception", "(", "\"Invalid boolean representation: \"", ".", "var_export", "(", "$", "value", ",", "true", ")", ")", ";", "default", ":", "throw", "new", "Exception", "(", "\"Don't know how to cast to PHP type '$phpType'.\"", ")", ";", "}", "}" ]
Convert a value to the named PHP scalar type using PHP's default conversion. @deprecated use Storage_Util::cast
[ "Convert", "a", "value", "to", "the", "named", "PHP", "scalar", "type", "using", "PHP", "s", "default", "conversion", "." ]
db0398ea4fc07fa62f2de9ba43f2f3137170d9f0
https://github.com/EarthlingInteractive/PHPCMIPREST/blob/db0398ea4fc07fa62f2de9ba43f2f3137170d9f0/lib/EarthIT/CMIPREST/Util.php#L36-L57
539
EarthlingInteractive/PHPCMIPREST
lib/EarthIT/CMIPREST/Util.php
EarthIT_CMIPREST_Util.fieldPropertyValue
public static function fieldPropertyValue( EarthIT_Schema_Field $f, $propUri, $nonFakeDefault=null, $fakeDefault=null ) { $v = $f->getFirstPropertyValue($propUri); if( $v !== null ) return $v; $isFake = $f->getFirstPropertyValue(EarthIT_CMIPREST_NS::IS_FAKE_FIELD); return $isFake ? $fakeDefault : $nonFakeDefault; }
php
public static function fieldPropertyValue( EarthIT_Schema_Field $f, $propUri, $nonFakeDefault=null, $fakeDefault=null ) { $v = $f->getFirstPropertyValue($propUri); if( $v !== null ) return $v; $isFake = $f->getFirstPropertyValue(EarthIT_CMIPREST_NS::IS_FAKE_FIELD); return $isFake ? $fakeDefault : $nonFakeDefault; }
[ "public", "static", "function", "fieldPropertyValue", "(", "EarthIT_Schema_Field", "$", "f", ",", "$", "propUri", ",", "$", "nonFakeDefault", "=", "null", ",", "$", "fakeDefault", "=", "null", ")", "{", "$", "v", "=", "$", "f", "->", "getFirstPropertyValue", "(", "$", "propUri", ")", ";", "if", "(", "$", "v", "!==", "null", ")", "return", "$", "v", ";", "$", "isFake", "=", "$", "f", "->", "getFirstPropertyValue", "(", "EarthIT_CMIPREST_NS", "::", "IS_FAKE_FIELD", ")", ";", "return", "$", "isFake", "?", "$", "fakeDefault", ":", "$", "nonFakeDefault", ";", "}" ]
Get a field property value, taking into account whether the field is fake or not, and defaults for either case. @api
[ "Get", "a", "field", "property", "value", "taking", "into", "account", "whether", "the", "field", "is", "fake", "or", "not", "and", "defaults", "for", "either", "case", "." ]
db0398ea4fc07fa62f2de9ba43f2f3137170d9f0
https://github.com/EarthlingInteractive/PHPCMIPREST/blob/db0398ea4fc07fa62f2de9ba43f2f3137170d9f0/lib/EarthIT/CMIPREST/Util.php#L120-L126
540
EarthlingInteractive/PHPCMIPREST
lib/EarthIT/CMIPREST/Util.php
EarthIT_CMIPREST_Util.singleErrorResponse
public static function singleErrorResponse( $status, $message, array $notes=array(), array $headers=array() ) { return self::multiErrorResponse($status, array(self::errorStructure( $message, $notes )), $headers); }
php
public static function singleErrorResponse( $status, $message, array $notes=array(), array $headers=array() ) { return self::multiErrorResponse($status, array(self::errorStructure( $message, $notes )), $headers); }
[ "public", "static", "function", "singleErrorResponse", "(", "$", "status", ",", "$", "message", ",", "array", "$", "notes", "=", "array", "(", ")", ",", "array", "$", "headers", "=", "array", "(", ")", ")", "{", "return", "self", "::", "multiErrorResponse", "(", "$", "status", ",", "array", "(", "self", "::", "errorStructure", "(", "$", "message", ",", "$", "notes", ")", ")", ",", "$", "headers", ")", ";", "}" ]
Create a response to indicate a single error from a status code, message, and list of notes.
[ "Create", "a", "response", "to", "indicate", "a", "single", "error", "from", "a", "status", "code", "message", "and", "list", "of", "notes", "." ]
db0398ea4fc07fa62f2de9ba43f2f3137170d9f0
https://github.com/EarthlingInteractive/PHPCMIPREST/blob/db0398ea4fc07fa62f2de9ba43f2f3137170d9f0/lib/EarthIT/CMIPREST/Util.php#L268-L270
541
WellCommerce/Form
DataMapper/ModelDataMapper.php
ModelDataMapper.mapElementToModelData
protected function mapElementToModelData(ElementInterface $child) { $this->setModelValueFromElement($child); $children = $child->getChildren(); if ($children->count()) { $this->mapElementCollectionToModelData($children); } }
php
protected function mapElementToModelData(ElementInterface $child) { $this->setModelValueFromElement($child); $children = $child->getChildren(); if ($children->count()) { $this->mapElementCollectionToModelData($children); } }
[ "protected", "function", "mapElementToModelData", "(", "ElementInterface", "$", "child", ")", "{", "$", "this", "->", "setModelValueFromElement", "(", "$", "child", ")", ";", "$", "children", "=", "$", "child", "->", "getChildren", "(", ")", ";", "if", "(", "$", "children", "->", "count", "(", ")", ")", "{", "$", "this", "->", "mapElementCollectionToModelData", "(", "$", "children", ")", ";", "}", "}" ]
Maps element value to model data @param ElementInterface $child
[ "Maps", "element", "value", "to", "model", "data" ]
dad15dbdcf1d13f927fa86f5198bcb6abed1974a
https://github.com/WellCommerce/Form/blob/dad15dbdcf1d13f927fa86f5198bcb6abed1974a/DataMapper/ModelDataMapper.php#L62-L70
542
WellCommerce/Form
DataMapper/ModelDataMapper.php
ModelDataMapper.mapModelDataToElementCollection
protected function mapModelDataToElementCollection(ElementCollection $children) { foreach ($children->all() as $child) { $this->mapModelDataToElement($child); } }
php
protected function mapModelDataToElementCollection(ElementCollection $children) { foreach ($children->all() as $child) { $this->mapModelDataToElement($child); } }
[ "protected", "function", "mapModelDataToElementCollection", "(", "ElementCollection", "$", "children", ")", "{", "foreach", "(", "$", "children", "->", "all", "(", ")", "as", "$", "child", ")", "{", "$", "this", "->", "mapModelDataToElement", "(", "$", "child", ")", ";", "}", "}" ]
Maps data using recursion to all children @param ElementCollection $children
[ "Maps", "data", "using", "recursion", "to", "all", "children" ]
dad15dbdcf1d13f927fa86f5198bcb6abed1974a
https://github.com/WellCommerce/Form/blob/dad15dbdcf1d13f927fa86f5198bcb6abed1974a/DataMapper/ModelDataMapper.php#L93-L98
543
WellCommerce/Form
DataMapper/ModelDataMapper.php
ModelDataMapper.setDefaultElementValue
protected function setDefaultElementValue(ElementInterface $element) { $propertyPath = $element->getPropertyPath(); if ($propertyPath instanceof PropertyPathInterface) { if ($this->propertyAccessor->isReadable($this->data, $propertyPath)) { $value = $this->propertyAccessor->getValue($this->data, $propertyPath); if ($this->isEmptyValue($value)) { $value = $element->getDefaultValue(); } if ($element->hasTransformer() && is_object($value)) { $transformer = $element->getTransformer(); $value = $transformer->transform($value); } $element->setValue($value); } } }
php
protected function setDefaultElementValue(ElementInterface $element) { $propertyPath = $element->getPropertyPath(); if ($propertyPath instanceof PropertyPathInterface) { if ($this->propertyAccessor->isReadable($this->data, $propertyPath)) { $value = $this->propertyAccessor->getValue($this->data, $propertyPath); if ($this->isEmptyValue($value)) { $value = $element->getDefaultValue(); } if ($element->hasTransformer() && is_object($value)) { $transformer = $element->getTransformer(); $value = $transformer->transform($value); } $element->setValue($value); } } }
[ "protected", "function", "setDefaultElementValue", "(", "ElementInterface", "$", "element", ")", "{", "$", "propertyPath", "=", "$", "element", "->", "getPropertyPath", "(", ")", ";", "if", "(", "$", "propertyPath", "instanceof", "PropertyPathInterface", ")", "{", "if", "(", "$", "this", "->", "propertyAccessor", "->", "isReadable", "(", "$", "this", "->", "data", ",", "$", "propertyPath", ")", ")", "{", "$", "value", "=", "$", "this", "->", "propertyAccessor", "->", "getValue", "(", "$", "this", "->", "data", ",", "$", "propertyPath", ")", ";", "if", "(", "$", "this", "->", "isEmptyValue", "(", "$", "value", ")", ")", "{", "$", "value", "=", "$", "element", "->", "getDefaultValue", "(", ")", ";", "}", "if", "(", "$", "element", "->", "hasTransformer", "(", ")", "&&", "is_object", "(", "$", "value", ")", ")", "{", "$", "transformer", "=", "$", "element", "->", "getTransformer", "(", ")", ";", "$", "value", "=", "$", "transformer", "->", "transform", "(", "$", "value", ")", ";", "}", "$", "element", "->", "setValue", "(", "$", "value", ")", ";", "}", "}", "}" ]
Sets value for element @param ElementInterface $element
[ "Sets", "value", "for", "element" ]
dad15dbdcf1d13f927fa86f5198bcb6abed1974a
https://github.com/WellCommerce/Form/blob/dad15dbdcf1d13f927fa86f5198bcb6abed1974a/DataMapper/ModelDataMapper.php#L105-L124
544
WellCommerce/Form
DataMapper/ModelDataMapper.php
ModelDataMapper.setModelValueFromElement
protected function setModelValueFromElement(ElementInterface $child) { $propertyPath = $child->getPropertyPath(); if ($propertyPath instanceof PropertyPathInterface) { if ($this->propertyAccessor->isWritable($this->data, $propertyPath)) { if ($child->hasTransformer()) { $transformer = $child->getTransformer(); $transformer->reverseTransform($this->data, $propertyPath, $child->getValue()); } else { $this->propertyAccessor->setValue($this->data, $propertyPath, $child->getValue()); } } } }
php
protected function setModelValueFromElement(ElementInterface $child) { $propertyPath = $child->getPropertyPath(); if ($propertyPath instanceof PropertyPathInterface) { if ($this->propertyAccessor->isWritable($this->data, $propertyPath)) { if ($child->hasTransformer()) { $transformer = $child->getTransformer(); $transformer->reverseTransform($this->data, $propertyPath, $child->getValue()); } else { $this->propertyAccessor->setValue($this->data, $propertyPath, $child->getValue()); } } } }
[ "protected", "function", "setModelValueFromElement", "(", "ElementInterface", "$", "child", ")", "{", "$", "propertyPath", "=", "$", "child", "->", "getPropertyPath", "(", ")", ";", "if", "(", "$", "propertyPath", "instanceof", "PropertyPathInterface", ")", "{", "if", "(", "$", "this", "->", "propertyAccessor", "->", "isWritable", "(", "$", "this", "->", "data", ",", "$", "propertyPath", ")", ")", "{", "if", "(", "$", "child", "->", "hasTransformer", "(", ")", ")", "{", "$", "transformer", "=", "$", "child", "->", "getTransformer", "(", ")", ";", "$", "transformer", "->", "reverseTransform", "(", "$", "this", "->", "data", ",", "$", "propertyPath", ",", "$", "child", "->", "getValue", "(", ")", ")", ";", "}", "else", "{", "$", "this", "->", "propertyAccessor", "->", "setValue", "(", "$", "this", "->", "data", ",", "$", "propertyPath", ",", "$", "child", "->", "getValue", "(", ")", ")", ";", "}", "}", "}", "}" ]
Transforms value if needed or directly changes model property @param ElementInterface $child
[ "Transforms", "value", "if", "needed", "or", "directly", "changes", "model", "property" ]
dad15dbdcf1d13f927fa86f5198bcb6abed1974a
https://github.com/WellCommerce/Form/blob/dad15dbdcf1d13f927fa86f5198bcb6abed1974a/DataMapper/ModelDataMapper.php#L131-L145
545
hegotecnologia/support
src/Units/ServiceProvider.php
ServiceProvider.registerProviders
protected function registerProviders(Collection $providers) { // loop through providers to be registered. $providers->each(function ($providerClass) { // register a provider class. $this->app->register($providerClass); }); }
php
protected function registerProviders(Collection $providers) { // loop through providers to be registered. $providers->each(function ($providerClass) { // register a provider class. $this->app->register($providerClass); }); }
[ "protected", "function", "registerProviders", "(", "Collection", "$", "providers", ")", "{", "// loop through providers to be registered.", "$", "providers", "->", "each", "(", "function", "(", "$", "providerClass", ")", "{", "// register a provider class.", "$", "this", "->", "app", "->", "register", "(", "$", "providerClass", ")", ";", "}", ")", ";", "}" ]
Register Unit Custom ServiceProviders. @param Collection $providers
[ "Register", "Unit", "Custom", "ServiceProviders", "." ]
3862bdf82dd7d3a6f0cec1afd2a04531bd75e0cc
https://github.com/hegotecnologia/support/blob/3862bdf82dd7d3a6f0cec1afd2a04531bd75e0cc/src/Units/ServiceProvider.php#L52-L59
546
hegotecnologia/support
src/Units/ServiceProvider.php
ServiceProvider.unitPath
protected function unitPath($append = null) { $reflection = new \ReflectionClass($this); $realPath = realpath(dirname($reflection->getFileName()) . '/../'); if (!$append) { return $realPath; } return $realPath . '/' . $append; }
php
protected function unitPath($append = null) { $reflection = new \ReflectionClass($this); $realPath = realpath(dirname($reflection->getFileName()) . '/../'); if (!$append) { return $realPath; } return $realPath . '/' . $append; }
[ "protected", "function", "unitPath", "(", "$", "append", "=", "null", ")", "{", "$", "reflection", "=", "new", "\\", "ReflectionClass", "(", "$", "this", ")", ";", "$", "realPath", "=", "realpath", "(", "dirname", "(", "$", "reflection", "->", "getFileName", "(", ")", ")", ".", "'/../'", ")", ";", "if", "(", "!", "$", "append", ")", "{", "return", "$", "realPath", ";", "}", "return", "$", "realPath", ".", "'/'", ".", "$", "append", ";", "}" ]
Detects the unit base path so resources can be proper loaded on child classes. @param string $append @return string
[ "Detects", "the", "unit", "base", "path", "so", "resources", "can", "be", "proper", "loaded", "on", "child", "classes", "." ]
3862bdf82dd7d3a6f0cec1afd2a04531bd75e0cc
https://github.com/hegotecnologia/support/blob/3862bdf82dd7d3a6f0cec1afd2a04531bd75e0cc/src/Units/ServiceProvider.php#L95-L105
547
kamalkhan/php-parser
src/AppendSuffixVisitor.php
AppendSuffixVisitor.appendSuffix
protected function appendSuffix(Name $class) { if ($class->isFullyQualified()) { if (count($class->parts) == 1) { return $class; } return $this->append(new Name('\\' . $class->toString())); } if ($this->isImport) { if (!$this->groupImport && count($class->parts) == 1) { return $class; } return $this->append($class); } foreach ($this->importNodes as $import) { if (strcmp($import->getLast(), $class->toString()) === 0) { return $class; } } return $this->append($class); }
php
protected function appendSuffix(Name $class) { if ($class->isFullyQualified()) { if (count($class->parts) == 1) { return $class; } return $this->append(new Name('\\' . $class->toString())); } if ($this->isImport) { if (!$this->groupImport && count($class->parts) == 1) { return $class; } return $this->append($class); } foreach ($this->importNodes as $import) { if (strcmp($import->getLast(), $class->toString()) === 0) { return $class; } } return $this->append($class); }
[ "protected", "function", "appendSuffix", "(", "Name", "$", "class", ")", "{", "if", "(", "$", "class", "->", "isFullyQualified", "(", ")", ")", "{", "if", "(", "count", "(", "$", "class", "->", "parts", ")", "==", "1", ")", "{", "return", "$", "class", ";", "}", "return", "$", "this", "->", "append", "(", "new", "Name", "(", "'\\\\'", ".", "$", "class", "->", "toString", "(", ")", ")", ")", ";", "}", "if", "(", "$", "this", "->", "isImport", ")", "{", "if", "(", "!", "$", "this", "->", "groupImport", "&&", "count", "(", "$", "class", "->", "parts", ")", "==", "1", ")", "{", "return", "$", "class", ";", "}", "return", "$", "this", "->", "append", "(", "$", "class", ")", ";", "}", "foreach", "(", "$", "this", "->", "importNodes", "as", "$", "import", ")", "{", "if", "(", "strcmp", "(", "$", "import", "->", "getLast", "(", ")", ",", "$", "class", "->", "toString", "(", ")", ")", "===", "0", ")", "{", "return", "$", "class", ";", "}", "}", "return", "$", "this", "->", "append", "(", "$", "class", ")", ";", "}" ]
Append a suffix to the node. @param \PhpParse\Node\Name $class Name node @return \PhpParse\Node\Name Appended node
[ "Append", "a", "suffix", "to", "the", "node", "." ]
fc9dbd18455230e9d294d6666c3d923c21b27eba
https://github.com/kamalkhan/php-parser/blob/fc9dbd18455230e9d294d6666c3d923c21b27eba/src/AppendSuffixVisitor.php#L107-L127
548
phossa2/libs
src/Phossa2/Query/Traits/Clause/WhereTrait.php
WhereTrait.buildAndOr
protected function buildAndOr(array &$cls, array $where, $idx) { // AND OR if ($idx) { $cls[] = $where[2]; } // NOT if ($where[1]) { $cls[] = $where[1]; } }
php
protected function buildAndOr(array &$cls, array $where, $idx) { // AND OR if ($idx) { $cls[] = $where[2]; } // NOT if ($where[1]) { $cls[] = $where[1]; } }
[ "protected", "function", "buildAndOr", "(", "array", "&", "$", "cls", ",", "array", "$", "where", ",", "$", "idx", ")", "{", "// AND OR", "if", "(", "$", "idx", ")", "{", "$", "cls", "[", "]", "=", "$", "where", "[", "2", "]", ";", "}", "// NOT", "if", "(", "$", "where", "[", "1", "]", ")", "{", "$", "cls", "[", "]", "=", "$", "where", "[", "1", "]", ";", "}", "}" ]
build 'AND NOT' part of the clause part @param array &$cls @param array $where @param int $idx @access protected
[ "build", "AND", "NOT", "part", "of", "the", "clause", "part" ]
921e485c8cc29067f279da2cdd06f47a9bddd115
https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Query/Traits/Clause/WhereTrait.php#L263-L273
549
phossa2/libs
src/Phossa2/Query/Traits/Clause/WhereTrait.php
WhereTrait.buildCondition
protected function buildCondition(array $cls, array $where, array $settings) { if (!empty($where[3])) { $cls[] = $this->quoteItem( $where[3], $settings, $this->isRaw($where[3], $where[0]) ); } if (WhereInterface::NO_OPERATOR !== $where[4]) { $cls[] = $where[4]; } if (WhereInterface::NO_VALUE !== $where[5]) { $cls[] = $this->processValue( $where[5], $settings, (bool) preg_match('/\bbetween\b/i', $where[4]) ); } return join(' ', $cls); }
php
protected function buildCondition(array $cls, array $where, array $settings) { if (!empty($where[3])) { $cls[] = $this->quoteItem( $where[3], $settings, $this->isRaw($where[3], $where[0]) ); } if (WhereInterface::NO_OPERATOR !== $where[4]) { $cls[] = $where[4]; } if (WhereInterface::NO_VALUE !== $where[5]) { $cls[] = $this->processValue( $where[5], $settings, (bool) preg_match('/\bbetween\b/i', $where[4]) ); } return join(' ', $cls); }
[ "protected", "function", "buildCondition", "(", "array", "$", "cls", ",", "array", "$", "where", ",", "array", "$", "settings", ")", "{", "if", "(", "!", "empty", "(", "$", "where", "[", "3", "]", ")", ")", "{", "$", "cls", "[", "]", "=", "$", "this", "->", "quoteItem", "(", "$", "where", "[", "3", "]", ",", "$", "settings", ",", "$", "this", "->", "isRaw", "(", "$", "where", "[", "3", "]", ",", "$", "where", "[", "0", "]", ")", ")", ";", "}", "if", "(", "WhereInterface", "::", "NO_OPERATOR", "!==", "$", "where", "[", "4", "]", ")", "{", "$", "cls", "[", "]", "=", "$", "where", "[", "4", "]", ";", "}", "if", "(", "WhereInterface", "::", "NO_VALUE", "!==", "$", "where", "[", "5", "]", ")", "{", "$", "cls", "[", "]", "=", "$", "this", "->", "processValue", "(", "$", "where", "[", "5", "]", ",", "$", "settings", ",", "(", "bool", ")", "preg_match", "(", "'/\\bbetween\\b/i'", ",", "$", "where", "[", "4", "]", ")", ")", ";", "}", "return", "join", "(", "' '", ",", "$", "cls", ")", ";", "}" ]
Build 'col = val' part @param array $cls @param array $where @param array $settings @return string @access protected
[ "Build", "col", "=", "val", "part" ]
921e485c8cc29067f279da2cdd06f47a9bddd115
https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Query/Traits/Clause/WhereTrait.php#L284-L304
550
crater-framework/crater-php-framework
Logger.php
Logger.error_handler
public static function error_handler($number, $message, $file, $line) { $msg = "$message in $file on line $line"; if (($number !== E_NOTICE) && ($number < 2048)) { self::errorMessage($msg, true); self::customErrorMsg(); } return 0; }
php
public static function error_handler($number, $message, $file, $line) { $msg = "$message in $file on line $line"; if (($number !== E_NOTICE) && ($number < 2048)) { self::errorMessage($msg, true); self::customErrorMsg(); } return 0; }
[ "public", "static", "function", "error_handler", "(", "$", "number", ",", "$", "message", ",", "$", "file", ",", "$", "line", ")", "{", "$", "msg", "=", "\"$message in $file on line $line\"", ";", "if", "(", "(", "$", "number", "!==", "E_NOTICE", ")", "&&", "(", "$", "number", "<", "2048", ")", ")", "{", "self", "::", "errorMessage", "(", "$", "msg", ",", "true", ")", ";", "self", "::", "customErrorMsg", "(", ")", ";", "}", "return", "0", ";", "}" ]
Saves error message from exception @param int $number Error number @param string $message The error @param string $file File originated from @param int $line Line number
[ "Saves", "error", "message", "from", "exception" ]
ff7a4f69f8ee7beb37adee348b67d1be84c51ff1
https://github.com/crater-framework/crater-php-framework/blob/ff7a4f69f8ee7beb37adee348b67d1be84c51ff1/Logger.php#L46-L54
551
kiler129/CherryHttp
src/_legacyCode/HttpClient.php
HttpClient.processInputBuffer
protected function processInputBuffer() { //$this->logger->debug('Trying to process buffer of HttpClient'); if ($this->request === null) { //New request if (isset($this->inputBuffer[HttpRequest::MAX_HEADER_LENGTH])) { //Much faster than strlen ;) $this->logger->warning("Client $this sent headers larger than " . HttpRequest::MAX_HEADER_LENGTH . ' bytes'); $this->inputBuffer = ''; throw new HttpException('Server refused request exceeding ' . HttpRequest::MAX_HEADER_LENGTH . ' bytes', HttpCode::REQUEST_HEADER_FIELDS_TOO_LARGE, array(), true); } $headersBreakpoint = strpos($this->inputBuffer, "\r\n\r\n"); //Try to find headers breakpoint if ($headersBreakpoint === false) { //Not found, nothing to do //$this->logger->debug('Buffer doesn't contain full HTTP headers [yet]'); return; } //TODO: Refactor to 2x substr (based on $headersBreakpoint) - it's ~5% faster [but it need to be changed along with payloads support] list($headers, $this->inputBuffer) = explode("\r\n\r\n", $this->inputBuffer, 2); //$this->logger->debug('Got HTTP headers, creating HttpRequest...'); $this->request = new HttpRequest($headers, $this->logger); } //In future: else { add data to already created request } }
php
protected function processInputBuffer() { //$this->logger->debug('Trying to process buffer of HttpClient'); if ($this->request === null) { //New request if (isset($this->inputBuffer[HttpRequest::MAX_HEADER_LENGTH])) { //Much faster than strlen ;) $this->logger->warning("Client $this sent headers larger than " . HttpRequest::MAX_HEADER_LENGTH . ' bytes'); $this->inputBuffer = ''; throw new HttpException('Server refused request exceeding ' . HttpRequest::MAX_HEADER_LENGTH . ' bytes', HttpCode::REQUEST_HEADER_FIELDS_TOO_LARGE, array(), true); } $headersBreakpoint = strpos($this->inputBuffer, "\r\n\r\n"); //Try to find headers breakpoint if ($headersBreakpoint === false) { //Not found, nothing to do //$this->logger->debug('Buffer doesn't contain full HTTP headers [yet]'); return; } //TODO: Refactor to 2x substr (based on $headersBreakpoint) - it's ~5% faster [but it need to be changed along with payloads support] list($headers, $this->inputBuffer) = explode("\r\n\r\n", $this->inputBuffer, 2); //$this->logger->debug('Got HTTP headers, creating HttpRequest...'); $this->request = new HttpRequest($headers, $this->logger); } //In future: else { add data to already created request } }
[ "protected", "function", "processInputBuffer", "(", ")", "{", "//$this->logger->debug('Trying to process buffer of HttpClient');", "if", "(", "$", "this", "->", "request", "===", "null", ")", "{", "//New request", "if", "(", "isset", "(", "$", "this", "->", "inputBuffer", "[", "HttpRequest", "::", "MAX_HEADER_LENGTH", "]", ")", ")", "{", "//Much faster than strlen ;)", "$", "this", "->", "logger", "->", "warning", "(", "\"Client $this sent headers larger than \"", ".", "HttpRequest", "::", "MAX_HEADER_LENGTH", ".", "' bytes'", ")", ";", "$", "this", "->", "inputBuffer", "=", "''", ";", "throw", "new", "HttpException", "(", "'Server refused request exceeding '", ".", "HttpRequest", "::", "MAX_HEADER_LENGTH", ".", "' bytes'", ",", "HttpCode", "::", "REQUEST_HEADER_FIELDS_TOO_LARGE", ",", "array", "(", ")", ",", "true", ")", ";", "}", "$", "headersBreakpoint", "=", "strpos", "(", "$", "this", "->", "inputBuffer", ",", "\"\\r\\n\\r\\n\"", ")", ";", "//Try to find headers breakpoint", "if", "(", "$", "headersBreakpoint", "===", "false", ")", "{", "//Not found, nothing to do", "//$this->logger->debug('Buffer doesn't contain full HTTP headers [yet]');", "return", ";", "}", "//TODO: Refactor to 2x substr (based on $headersBreakpoint) - it's ~5% faster [but it need to be changed along with payloads support]", "list", "(", "$", "headers", ",", "$", "this", "->", "inputBuffer", ")", "=", "explode", "(", "\"\\r\\n\\r\\n\"", ",", "$", "this", "->", "inputBuffer", ",", "2", ")", ";", "//$this->logger->debug('Got HTTP headers, creating HttpRequest...');", "$", "this", "->", "request", "=", "new", "HttpRequest", "(", "$", "headers", ",", "$", "this", "->", "logger", ")", ";", "}", "//In future: else { add data to already created request }", "}" ]
Handles HTTP request collection @todo This method needs refactoring along with HttpRequest class. In current shape it cannot accept requests with additional data attached (eg. POST or PUT). @throws HttpException
[ "Handles", "HTTP", "request", "collection" ]
05927f26183cbd6fd5ccb0853befecdea279308d
https://github.com/kiler129/CherryHttp/blob/05927f26183cbd6fd5ccb0853befecdea279308d/src/_legacyCode/HttpClient.php#L21-L45
552
axypro/creator
helpers/Builder.php
Builder.build
public static function build(array $pointer, array $context) { if (array_key_exists('value', $pointer)) { return $pointer['value']; } if (!empty($pointer['classname'])) { $classname = NameResolver::resolve($pointer['classname'], $context); return self::buildByClassname($classname, $pointer, $context); } if (!empty($pointer['creator'])) { return Callback::call($pointer['creator'], [$pointer, $context]); } if (!empty($context['classname'])) { return self::buildByClassname($context['classname'], $pointer, $context); } if (!empty($context['creator'])) { return Callback::call($context['creator'], [$pointer, $context]); } throw new InvalidPointer(''); }
php
public static function build(array $pointer, array $context) { if (array_key_exists('value', $pointer)) { return $pointer['value']; } if (!empty($pointer['classname'])) { $classname = NameResolver::resolve($pointer['classname'], $context); return self::buildByClassname($classname, $pointer, $context); } if (!empty($pointer['creator'])) { return Callback::call($pointer['creator'], [$pointer, $context]); } if (!empty($context['classname'])) { return self::buildByClassname($context['classname'], $pointer, $context); } if (!empty($context['creator'])) { return Callback::call($context['creator'], [$pointer, $context]); } throw new InvalidPointer(''); }
[ "public", "static", "function", "build", "(", "array", "$", "pointer", ",", "array", "$", "context", ")", "{", "if", "(", "array_key_exists", "(", "'value'", ",", "$", "pointer", ")", ")", "{", "return", "$", "pointer", "[", "'value'", "]", ";", "}", "if", "(", "!", "empty", "(", "$", "pointer", "[", "'classname'", "]", ")", ")", "{", "$", "classname", "=", "NameResolver", "::", "resolve", "(", "$", "pointer", "[", "'classname'", "]", ",", "$", "context", ")", ";", "return", "self", "::", "buildByClassname", "(", "$", "classname", ",", "$", "pointer", ",", "$", "context", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "pointer", "[", "'creator'", "]", ")", ")", "{", "return", "Callback", "::", "call", "(", "$", "pointer", "[", "'creator'", "]", ",", "[", "$", "pointer", ",", "$", "context", "]", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "context", "[", "'classname'", "]", ")", ")", "{", "return", "self", "::", "buildByClassname", "(", "$", "context", "[", "'classname'", "]", ",", "$", "pointer", ",", "$", "context", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "context", "[", "'creator'", "]", ")", ")", "{", "return", "Callback", "::", "call", "(", "$", "context", "[", "'creator'", "]", ",", "[", "$", "pointer", ",", "$", "context", "]", ")", ";", "}", "throw", "new", "InvalidPointer", "(", "''", ")", ";", "}" ]
Builds an object by the pointer @param array $pointer the normalized pointer @param array $context the normalized context @return mixed the target object @throws \axy\creator\errors\InvalidPointer
[ "Builds", "an", "object", "by", "the", "pointer" ]
3d74e2201cdb93912d32b1d80d1fdc44018f132a
https://github.com/axypro/creator/blob/3d74e2201cdb93912d32b1d80d1fdc44018f132a/helpers/Builder.php#L28-L47
553
tekkla/core-framework
Core/Framework/Page/Head/Javascript/Javascript.php
Javascript.&
public function &block($script, $defer = false) { $script = new JavascriptObject(); $script->setType('block'); $script->setScript($script); $script->setDefer($defer); $this->add($script); return $script; }
php
public function &block($script, $defer = false) { $script = new JavascriptObject(); $script->setType('block'); $script->setScript($script); $script->setDefer($defer); $this->add($script); return $script; }
[ "public", "function", "&", "block", "(", "$", "script", ",", "$", "defer", "=", "false", ")", "{", "$", "script", "=", "new", "JavascriptObject", "(", ")", ";", "$", "script", "->", "setType", "(", "'block'", ")", ";", "$", "script", "->", "setScript", "(", "$", "script", ")", ";", "$", "script", "->", "setDefer", "(", "$", "defer", ")", ";", "$", "this", "->", "add", "(", "$", "script", ")", ";", "return", "$", "script", ";", "}" ]
Blocks with complete code. Use this for conditional scripts! @param string $script @param bool $defer @return JavascriptObject
[ "Blocks", "with", "complete", "code", ".", "Use", "this", "for", "conditional", "scripts!" ]
ad69e9f15ee3644b6ca376edc30d8f5555399892
https://github.com/tekkla/core-framework/blob/ad69e9f15ee3644b6ca376edc30d8f5555399892/Core/Framework/Page/Head/Javascript/Javascript.php#L234-L245
554
tekkla/core-framework
Core/Framework/Page/Head/Javascript/Javascript.php
Javascript.&
public function &bootstrap($version, $defer = false) { $url = $this->js_url . '/bootstrap-' . $version . '.min.js'; if (str_replace(BASEURL, BASEDIR, $url)) { return $this->file($url); } }
php
public function &bootstrap($version, $defer = false) { $url = $this->js_url . '/bootstrap-' . $version . '.min.js'; if (str_replace(BASEURL, BASEDIR, $url)) { return $this->file($url); } }
[ "public", "function", "&", "bootstrap", "(", "$", "version", ",", "$", "defer", "=", "false", ")", "{", "$", "url", "=", "$", "this", "->", "js_url", ".", "'/bootstrap-'", ".", "$", "version", ".", "'.min.js'", ";", "if", "(", "str_replace", "(", "BASEURL", ",", "BASEDIR", ",", "$", "url", ")", ")", "{", "return", "$", "this", "->", "file", "(", "$", "url", ")", ";", "}", "}" ]
Returns an file script block for the BS js lib @param string $version @param bool $from_cdn @return string
[ "Returns", "an", "file", "script", "block", "for", "the", "BS", "js", "lib" ]
ad69e9f15ee3644b6ca376edc30d8f5555399892
https://github.com/tekkla/core-framework/blob/ad69e9f15ee3644b6ca376edc30d8f5555399892/Core/Framework/Page/Head/Javascript/Javascript.php#L284-L291
555
samsonos/cms_app_navigation
src/CMSNav.php
CMSNav.getFieldList
public function getFieldList() { // Get additional fields of current structure $fields = dbQuery('\samson\cms\web\field\CMSField') ->join('\samson\cms\CMSNavField') ->cond('StructureID', $this->id) ->exec(); // Create list view $items = ''; // If structure has additional fields then add them to list if (sizeof($fields)) { foreach ($fields as $field) { $items .= m('structure')->view('form/field/field_item')->field($field)->structure($this)->output(); } } else { // Add empty row $items = m('structure')->view('form/field/empty_field')->output(); } // Return items view return $items; }
php
public function getFieldList() { // Get additional fields of current structure $fields = dbQuery('\samson\cms\web\field\CMSField') ->join('\samson\cms\CMSNavField') ->cond('StructureID', $this->id) ->exec(); // Create list view $items = ''; // If structure has additional fields then add them to list if (sizeof($fields)) { foreach ($fields as $field) { $items .= m('structure')->view('form/field/field_item')->field($field)->structure($this)->output(); } } else { // Add empty row $items = m('structure')->view('form/field/empty_field')->output(); } // Return items view return $items; }
[ "public", "function", "getFieldList", "(", ")", "{", "// Get additional fields of current structure", "$", "fields", "=", "dbQuery", "(", "'\\samson\\cms\\web\\field\\CMSField'", ")", "->", "join", "(", "'\\samson\\cms\\CMSNavField'", ")", "->", "cond", "(", "'StructureID'", ",", "$", "this", "->", "id", ")", "->", "exec", "(", ")", ";", "// Create list view", "$", "items", "=", "''", ";", "// If structure has additional fields then add them to list", "if", "(", "sizeof", "(", "$", "fields", ")", ")", "{", "foreach", "(", "$", "fields", "as", "$", "field", ")", "{", "$", "items", ".=", "m", "(", "'structure'", ")", "->", "view", "(", "'form/field/field_item'", ")", "->", "field", "(", "$", "field", ")", "->", "structure", "(", "$", "this", ")", "->", "output", "(", ")", ";", "}", "}", "else", "{", "// Add empty row", "$", "items", "=", "m", "(", "'structure'", ")", "->", "view", "(", "'form/field/empty_field'", ")", "->", "output", "(", ")", ";", "}", "// Return items view", "return", "$", "items", ";", "}" ]
Fet list of additional fields of current structure @return string Html view of list
[ "Fet", "list", "of", "additional", "fields", "of", "current", "structure" ]
76fb88cdf362cad777b308cc958062c8ffeb3540
https://github.com/samsonos/cms_app_navigation/blob/76fb88cdf362cad777b308cc958062c8ffeb3540/src/CMSNav.php#L60-L83
556
samsonos/cms_app_navigation
src/CMSNav.php
CMSNav.fillFields
public function fillFields() { // Fill the fields from $_POST array foreach ($_POST as $key => $val) { // Get int value form field parent id if ($key == 'ParentID' && $val == 0) { $this[$key] = null; // Get other fields } elseif ($key != 'StructureID') { $this[$key] = $val; } } // Save data about application $this['applicationGenerate'] = isset($_POST['generate-application'])&&($_POST['generate-application'] == true) ? 1 : 0; $this['applicationOutput'] = isset($_POST['output-application'])&&($_POST['output-application'] == true) ? 1 : 0; $this['applicationOutputStructure'] = isset($_POST['output-structure-application'])&&($_POST['output-structure-application'] == true) ? 1 : 0; $this['applicationRenderMain'] = isset($_POST['render-main-application'])&&($_POST['render-main-application'] == true) ? 1 : 0; // If application need to generate then set system property to 1 or 0 $this['system'] = isset($_POST['generate-application'])&&($_POST['generate-application'] == true) ? 1: 0; // Save icon $icon = isset($_POST['icon-application']) ? filter_var($_POST['icon-application']) : null; if (strlen($icon) > 0) { $this['applicationIcon'] = $icon; } /** TODO: Authenticated user can be not instance of user table */ if (!$this->query->entity('\samson\activerecord\user')->where('user_id', $this->UserID)->first()) { $this->UserID = 1; } // Save object $this->save(); if (isset($_POST['ParentID']) && $_POST['ParentID'] != 0) { // Create new relation $strRelation = new \samson\activerecord\structure_relation(false); $strRelation->parent_id = $_POST['ParentID']; $strRelation->child_id = $this->id; // Save relation $strRelation->save(); } }
php
public function fillFields() { // Fill the fields from $_POST array foreach ($_POST as $key => $val) { // Get int value form field parent id if ($key == 'ParentID' && $val == 0) { $this[$key] = null; // Get other fields } elseif ($key != 'StructureID') { $this[$key] = $val; } } // Save data about application $this['applicationGenerate'] = isset($_POST['generate-application'])&&($_POST['generate-application'] == true) ? 1 : 0; $this['applicationOutput'] = isset($_POST['output-application'])&&($_POST['output-application'] == true) ? 1 : 0; $this['applicationOutputStructure'] = isset($_POST['output-structure-application'])&&($_POST['output-structure-application'] == true) ? 1 : 0; $this['applicationRenderMain'] = isset($_POST['render-main-application'])&&($_POST['render-main-application'] == true) ? 1 : 0; // If application need to generate then set system property to 1 or 0 $this['system'] = isset($_POST['generate-application'])&&($_POST['generate-application'] == true) ? 1: 0; // Save icon $icon = isset($_POST['icon-application']) ? filter_var($_POST['icon-application']) : null; if (strlen($icon) > 0) { $this['applicationIcon'] = $icon; } /** TODO: Authenticated user can be not instance of user table */ if (!$this->query->entity('\samson\activerecord\user')->where('user_id', $this->UserID)->first()) { $this->UserID = 1; } // Save object $this->save(); if (isset($_POST['ParentID']) && $_POST['ParentID'] != 0) { // Create new relation $strRelation = new \samson\activerecord\structure_relation(false); $strRelation->parent_id = $_POST['ParentID']; $strRelation->child_id = $this->id; // Save relation $strRelation->save(); } }
[ "public", "function", "fillFields", "(", ")", "{", "// Fill the fields from $_POST array", "foreach", "(", "$", "_POST", "as", "$", "key", "=>", "$", "val", ")", "{", "// Get int value form field parent id", "if", "(", "$", "key", "==", "'ParentID'", "&&", "$", "val", "==", "0", ")", "{", "$", "this", "[", "$", "key", "]", "=", "null", ";", "// Get other fields", "}", "elseif", "(", "$", "key", "!=", "'StructureID'", ")", "{", "$", "this", "[", "$", "key", "]", "=", "$", "val", ";", "}", "}", "// Save data about application", "$", "this", "[", "'applicationGenerate'", "]", "=", "isset", "(", "$", "_POST", "[", "'generate-application'", "]", ")", "&&", "(", "$", "_POST", "[", "'generate-application'", "]", "==", "true", ")", "?", "1", ":", "0", ";", "$", "this", "[", "'applicationOutput'", "]", "=", "isset", "(", "$", "_POST", "[", "'output-application'", "]", ")", "&&", "(", "$", "_POST", "[", "'output-application'", "]", "==", "true", ")", "?", "1", ":", "0", ";", "$", "this", "[", "'applicationOutputStructure'", "]", "=", "isset", "(", "$", "_POST", "[", "'output-structure-application'", "]", ")", "&&", "(", "$", "_POST", "[", "'output-structure-application'", "]", "==", "true", ")", "?", "1", ":", "0", ";", "$", "this", "[", "'applicationRenderMain'", "]", "=", "isset", "(", "$", "_POST", "[", "'render-main-application'", "]", ")", "&&", "(", "$", "_POST", "[", "'render-main-application'", "]", "==", "true", ")", "?", "1", ":", "0", ";", "// If application need to generate then set system property to 1 or 0", "$", "this", "[", "'system'", "]", "=", "isset", "(", "$", "_POST", "[", "'generate-application'", "]", ")", "&&", "(", "$", "_POST", "[", "'generate-application'", "]", "==", "true", ")", "?", "1", ":", "0", ";", "// Save icon", "$", "icon", "=", "isset", "(", "$", "_POST", "[", "'icon-application'", "]", ")", "?", "filter_var", "(", "$", "_POST", "[", "'icon-application'", "]", ")", ":", "null", ";", "if", "(", "strlen", "(", "$", "icon", ")", ">", "0", ")", "{", "$", "this", "[", "'applicationIcon'", "]", "=", "$", "icon", ";", "}", "/** TODO: Authenticated user can be not instance of user table */", "if", "(", "!", "$", "this", "->", "query", "->", "entity", "(", "'\\samson\\activerecord\\user'", ")", "->", "where", "(", "'user_id'", ",", "$", "this", "->", "UserID", ")", "->", "first", "(", ")", ")", "{", "$", "this", "->", "UserID", "=", "1", ";", "}", "// Save object", "$", "this", "->", "save", "(", ")", ";", "if", "(", "isset", "(", "$", "_POST", "[", "'ParentID'", "]", ")", "&&", "$", "_POST", "[", "'ParentID'", "]", "!=", "0", ")", "{", "// Create new relation", "$", "strRelation", "=", "new", "\\", "samson", "\\", "activerecord", "\\", "structure_relation", "(", "false", ")", ";", "$", "strRelation", "->", "parent_id", "=", "$", "_POST", "[", "'ParentID'", "]", ";", "$", "strRelation", "->", "child_id", "=", "$", "this", "->", "id", ";", "// Save relation", "$", "strRelation", "->", "save", "(", ")", ";", "}", "}" ]
Filling the fields and creating relation of structure
[ "Filling", "the", "fields", "and", "creating", "relation", "of", "structure" ]
76fb88cdf362cad777b308cc958062c8ffeb3540
https://github.com/samsonos/cms_app_navigation/blob/76fb88cdf362cad777b308cc958062c8ffeb3540/src/CMSNav.php#L88-L136
557
GovTribe/laravel-kinvey
src/GovTribe/LaravelKinvey/Client/Plugins/KinveyEntityPathRewritePlugin.php
KinveyEntityPathRewritePlugin.beforePrepare
public function beforePrepare(Event $event) { $command = $event['command']; $operation = $command->getOperation(); if ($command->offsetGet('collection') === 'user' || $command->getClient()->getCollectionName() === 'user') { if (strstr($operation->getURI(), 'user') !== false) return; $operation->setURI('/user/{appKey}/{_id}'); } elseif ($command->offsetGet('collection') === 'files' || $command->getClient()->getCollectionName() === 'files') { if (strstr($operation->getURI(), 'files') !== false) return; $operation->setURI('/blob/{appKey}/{_id}'); $command->getRequestHeaders()->add('X-Kinvey-API-Version', 3); } elseif ($command->offsetGet('collection') === 'group' || $command->getClient()->getCollectionName() === 'group') { if (strstr($operation->getURI(), 'group') !== false) return; $operation->setURI('/group/{appKey}/{_id}'); } }
php
public function beforePrepare(Event $event) { $command = $event['command']; $operation = $command->getOperation(); if ($command->offsetGet('collection') === 'user' || $command->getClient()->getCollectionName() === 'user') { if (strstr($operation->getURI(), 'user') !== false) return; $operation->setURI('/user/{appKey}/{_id}'); } elseif ($command->offsetGet('collection') === 'files' || $command->getClient()->getCollectionName() === 'files') { if (strstr($operation->getURI(), 'files') !== false) return; $operation->setURI('/blob/{appKey}/{_id}'); $command->getRequestHeaders()->add('X-Kinvey-API-Version', 3); } elseif ($command->offsetGet('collection') === 'group' || $command->getClient()->getCollectionName() === 'group') { if (strstr($operation->getURI(), 'group') !== false) return; $operation->setURI('/group/{appKey}/{_id}'); } }
[ "public", "function", "beforePrepare", "(", "Event", "$", "event", ")", "{", "$", "command", "=", "$", "event", "[", "'command'", "]", ";", "$", "operation", "=", "$", "command", "->", "getOperation", "(", ")", ";", "if", "(", "$", "command", "->", "offsetGet", "(", "'collection'", ")", "===", "'user'", "||", "$", "command", "->", "getClient", "(", ")", "->", "getCollectionName", "(", ")", "===", "'user'", ")", "{", "if", "(", "strstr", "(", "$", "operation", "->", "getURI", "(", ")", ",", "'user'", ")", "!==", "false", ")", "return", ";", "$", "operation", "->", "setURI", "(", "'/user/{appKey}/{_id}'", ")", ";", "}", "elseif", "(", "$", "command", "->", "offsetGet", "(", "'collection'", ")", "===", "'files'", "||", "$", "command", "->", "getClient", "(", ")", "->", "getCollectionName", "(", ")", "===", "'files'", ")", "{", "if", "(", "strstr", "(", "$", "operation", "->", "getURI", "(", ")", ",", "'files'", ")", "!==", "false", ")", "return", ";", "$", "operation", "->", "setURI", "(", "'/blob/{appKey}/{_id}'", ")", ";", "$", "command", "->", "getRequestHeaders", "(", ")", "->", "add", "(", "'X-Kinvey-API-Version'", ",", "3", ")", ";", "}", "elseif", "(", "$", "command", "->", "offsetGet", "(", "'collection'", ")", "===", "'group'", "||", "$", "command", "->", "getClient", "(", ")", "->", "getCollectionName", "(", ")", "===", "'group'", ")", "{", "if", "(", "strstr", "(", "$", "operation", "->", "getURI", "(", ")", ",", "'group'", ")", "!==", "false", ")", "return", ";", "$", "operation", "->", "setURI", "(", "'/group/{appKey}/{_id}'", ")", ";", "}", "}" ]
If the query is targets the users or files collection, rewrite the URI. This allows the same entity commands to be used for data store entities as well as users and files. @param Guzzle\Common\Event @return void
[ "If", "the", "query", "is", "targets", "the", "users", "or", "files", "collection", "rewrite", "the", "URI", ".", "This", "allows", "the", "same", "entity", "commands", "to", "be", "used", "for", "data", "store", "entities", "as", "well", "as", "users", "and", "files", "." ]
8a25dafdf80a933384dfcfe8b70b0a7663fe9289
https://github.com/GovTribe/laravel-kinvey/blob/8a25dafdf80a933384dfcfe8b70b0a7663fe9289/src/GovTribe/LaravelKinvey/Client/Plugins/KinveyEntityPathRewritePlugin.php#L26-L48
558
Novusvetus/AutoGitIgnore
src/GitIgnoreBuilder.php
GitIgnoreBuilder.Go
public static function Go(Event $event) { $event->getIO()->writeError('<info>Updating .gitignore: </info>', false); $composer = $event->getComposer(); $repositoryManager = $composer->getRepositoryManager(); $installManager = $composer->getInstallationManager(); $extraConfiguration = $composer->getPackage()->getExtra(); // Check in composer extra configuration if devOnly option is set $devRequires = (array_key_exists('autogitignore', $extraConfiguration) && $extraConfiguration['autogitignore'] == 'devOnly'); // If devOnly option is set if ($devRequires) { // Grab original list of all require-dev packages $devRequires = array_keys($composer->getPackage()->getDevRequires()); // Grab original list of all require packages $requires = array_keys($composer->getPackage()->getRequires()); // Grab recursively require and require-dev packages foreach ($repositoryManager->getLocalRepository()->getPackages() as $package) { $devRequires = array_merge($devRequires, array_keys($package->getDevRequires())); $requires = array_merge($requires, array_keys($package->getRequires())); } // Remove duplicates $devRequires = array_unique($devRequires); $requires = array_unique($requires); // Sort packages sort($devRequires); sort($requires); } $packages = array(); foreach ($repositoryManager->getLocalRepository()->getPackages() as $package) { // Test if we need to ignore the package // If the option devOnly is set, we check that // the package is not in the list of require-dev // OR is set in the list of require packages // before skipping. if ($devRequires && (!in_array($package->getName(), $devRequires) || in_array($package->getName(), $requires))) { continue; } $path = $installManager->getInstallPath($package); $packages[] = '/' . preg_replace('~^' . preg_quote(str_replace('\\', '/', getcwd()) . '/') . '~', '', str_replace('\\', '/', realpath($path))) . '/'; } $packages = array_unique($packages); sort($packages); try { $gitIgnoreFile = GitIgnoreFile::create(getcwd() . DIRECTORY_SEPARATOR . '.gitignore'); $gitIgnoreFile->setLines($packages); $gitIgnoreFile->save(); } catch (Exception $exception) { $event->getIO()->writeError('<info>Failed - ' . $exception->getMessage() . '</info>'); return false; } $event->getIO()->writeError('<info>Done - ' . count($packages) . ' packages ignored.</info>'); return true; }
php
public static function Go(Event $event) { $event->getIO()->writeError('<info>Updating .gitignore: </info>', false); $composer = $event->getComposer(); $repositoryManager = $composer->getRepositoryManager(); $installManager = $composer->getInstallationManager(); $extraConfiguration = $composer->getPackage()->getExtra(); // Check in composer extra configuration if devOnly option is set $devRequires = (array_key_exists('autogitignore', $extraConfiguration) && $extraConfiguration['autogitignore'] == 'devOnly'); // If devOnly option is set if ($devRequires) { // Grab original list of all require-dev packages $devRequires = array_keys($composer->getPackage()->getDevRequires()); // Grab original list of all require packages $requires = array_keys($composer->getPackage()->getRequires()); // Grab recursively require and require-dev packages foreach ($repositoryManager->getLocalRepository()->getPackages() as $package) { $devRequires = array_merge($devRequires, array_keys($package->getDevRequires())); $requires = array_merge($requires, array_keys($package->getRequires())); } // Remove duplicates $devRequires = array_unique($devRequires); $requires = array_unique($requires); // Sort packages sort($devRequires); sort($requires); } $packages = array(); foreach ($repositoryManager->getLocalRepository()->getPackages() as $package) { // Test if we need to ignore the package // If the option devOnly is set, we check that // the package is not in the list of require-dev // OR is set in the list of require packages // before skipping. if ($devRequires && (!in_array($package->getName(), $devRequires) || in_array($package->getName(), $requires))) { continue; } $path = $installManager->getInstallPath($package); $packages[] = '/' . preg_replace('~^' . preg_quote(str_replace('\\', '/', getcwd()) . '/') . '~', '', str_replace('\\', '/', realpath($path))) . '/'; } $packages = array_unique($packages); sort($packages); try { $gitIgnoreFile = GitIgnoreFile::create(getcwd() . DIRECTORY_SEPARATOR . '.gitignore'); $gitIgnoreFile->setLines($packages); $gitIgnoreFile->save(); } catch (Exception $exception) { $event->getIO()->writeError('<info>Failed - ' . $exception->getMessage() . '</info>'); return false; } $event->getIO()->writeError('<info>Done - ' . count($packages) . ' packages ignored.</info>'); return true; }
[ "public", "static", "function", "Go", "(", "Event", "$", "event", ")", "{", "$", "event", "->", "getIO", "(", ")", "->", "writeError", "(", "'<info>Updating .gitignore: </info>'", ",", "false", ")", ";", "$", "composer", "=", "$", "event", "->", "getComposer", "(", ")", ";", "$", "repositoryManager", "=", "$", "composer", "->", "getRepositoryManager", "(", ")", ";", "$", "installManager", "=", "$", "composer", "->", "getInstallationManager", "(", ")", ";", "$", "extraConfiguration", "=", "$", "composer", "->", "getPackage", "(", ")", "->", "getExtra", "(", ")", ";", "// Check in composer extra configuration if devOnly option is set", "$", "devRequires", "=", "(", "array_key_exists", "(", "'autogitignore'", ",", "$", "extraConfiguration", ")", "&&", "$", "extraConfiguration", "[", "'autogitignore'", "]", "==", "'devOnly'", ")", ";", "// If devOnly option is set", "if", "(", "$", "devRequires", ")", "{", "// Grab original list of all require-dev packages", "$", "devRequires", "=", "array_keys", "(", "$", "composer", "->", "getPackage", "(", ")", "->", "getDevRequires", "(", ")", ")", ";", "// Grab original list of all require packages", "$", "requires", "=", "array_keys", "(", "$", "composer", "->", "getPackage", "(", ")", "->", "getRequires", "(", ")", ")", ";", "// Grab recursively require and require-dev packages", "foreach", "(", "$", "repositoryManager", "->", "getLocalRepository", "(", ")", "->", "getPackages", "(", ")", "as", "$", "package", ")", "{", "$", "devRequires", "=", "array_merge", "(", "$", "devRequires", ",", "array_keys", "(", "$", "package", "->", "getDevRequires", "(", ")", ")", ")", ";", "$", "requires", "=", "array_merge", "(", "$", "requires", ",", "array_keys", "(", "$", "package", "->", "getRequires", "(", ")", ")", ")", ";", "}", "// Remove duplicates", "$", "devRequires", "=", "array_unique", "(", "$", "devRequires", ")", ";", "$", "requires", "=", "array_unique", "(", "$", "requires", ")", ";", "// Sort packages", "sort", "(", "$", "devRequires", ")", ";", "sort", "(", "$", "requires", ")", ";", "}", "$", "packages", "=", "array", "(", ")", ";", "foreach", "(", "$", "repositoryManager", "->", "getLocalRepository", "(", ")", "->", "getPackages", "(", ")", "as", "$", "package", ")", "{", "// Test if we need to ignore the package", "// If the option devOnly is set, we check that", "// the package is not in the list of require-dev", "// OR is set in the list of require packages", "// before skipping.", "if", "(", "$", "devRequires", "&&", "(", "!", "in_array", "(", "$", "package", "->", "getName", "(", ")", ",", "$", "devRequires", ")", "||", "in_array", "(", "$", "package", "->", "getName", "(", ")", ",", "$", "requires", ")", ")", ")", "{", "continue", ";", "}", "$", "path", "=", "$", "installManager", "->", "getInstallPath", "(", "$", "package", ")", ";", "$", "packages", "[", "]", "=", "'/'", ".", "preg_replace", "(", "'~^'", ".", "preg_quote", "(", "str_replace", "(", "'\\\\'", ",", "'/'", ",", "getcwd", "(", ")", ")", ".", "'/'", ")", ".", "'~'", ",", "''", ",", "str_replace", "(", "'\\\\'", ",", "'/'", ",", "realpath", "(", "$", "path", ")", ")", ")", ".", "'/'", ";", "}", "$", "packages", "=", "array_unique", "(", "$", "packages", ")", ";", "sort", "(", "$", "packages", ")", ";", "try", "{", "$", "gitIgnoreFile", "=", "GitIgnoreFile", "::", "create", "(", "getcwd", "(", ")", ".", "DIRECTORY_SEPARATOR", ".", "'.gitignore'", ")", ";", "$", "gitIgnoreFile", "->", "setLines", "(", "$", "packages", ")", ";", "$", "gitIgnoreFile", "->", "save", "(", ")", ";", "}", "catch", "(", "Exception", "$", "exception", ")", "{", "$", "event", "->", "getIO", "(", ")", "->", "writeError", "(", "'<info>Failed - '", ".", "$", "exception", "->", "getMessage", "(", ")", ".", "'</info>'", ")", ";", "return", "false", ";", "}", "$", "event", "->", "getIO", "(", ")", "->", "writeError", "(", "'<info>Done - '", ".", "count", "(", "$", "packages", ")", ".", "' packages ignored.</info>'", ")", ";", "return", "true", ";", "}" ]
This runs the builder @param Composer\Script\Event $event The event which is fired by Composer @return bool Returns false, when there was an error
[ "This", "runs", "the", "builder" ]
b754f87c908cbf446787a1104ae12f76f3fad2c5
https://github.com/Novusvetus/AutoGitIgnore/blob/b754f87c908cbf446787a1104ae12f76f3fad2c5/src/GitIgnoreBuilder.php#L29-L94
559
indigophp-archive/sms
src/Gateway/SeemeGateway.php
SeemeGateway.call
protected function call(array $params) { $response = $this->client->get(null, array('query' => $params)); $result = $response->json(); if ($result['result'] == 'ERR') { throw new ResponseException($result['message'], $result['code']); } return $result; }
php
protected function call(array $params) { $response = $this->client->get(null, array('query' => $params)); $result = $response->json(); if ($result['result'] == 'ERR') { throw new ResponseException($result['message'], $result['code']); } return $result; }
[ "protected", "function", "call", "(", "array", "$", "params", ")", "{", "$", "response", "=", "$", "this", "->", "client", "->", "get", "(", "null", ",", "array", "(", "'query'", "=>", "$", "params", ")", ")", ";", "$", "result", "=", "$", "response", "->", "json", "(", ")", ";", "if", "(", "$", "result", "[", "'result'", "]", "==", "'ERR'", ")", "{", "throw", "new", "ResponseException", "(", "$", "result", "[", "'message'", "]", ",", "$", "result", "[", "'code'", "]", ")", ";", "}", "return", "$", "result", ";", "}" ]
Sends a request to server @param array $params Query parameters @return mixed @codeCoverageIgnore
[ "Sends", "a", "request", "to", "server" ]
c93ca2682c07565e89d69c9d6ae2e81c585300c8
https://github.com/indigophp-archive/sms/blob/c93ca2682c07565e89d69c9d6ae2e81c585300c8/src/Gateway/SeemeGateway.php#L136-L147
560
gossi/trixionary
src/model/Base/PositionQuery.php
PositionQuery.useSkillRelatedByStartPositionIdQuery
public function useSkillRelatedByStartPositionIdQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinSkillRelatedByStartPositionId($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'SkillRelatedByStartPositionId', '\gossi\trixionary\model\SkillQuery'); }
php
public function useSkillRelatedByStartPositionIdQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinSkillRelatedByStartPositionId($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'SkillRelatedByStartPositionId', '\gossi\trixionary\model\SkillQuery'); }
[ "public", "function", "useSkillRelatedByStartPositionIdQuery", "(", "$", "relationAlias", "=", "null", ",", "$", "joinType", "=", "Criteria", "::", "LEFT_JOIN", ")", "{", "return", "$", "this", "->", "joinSkillRelatedByStartPositionId", "(", "$", "relationAlias", ",", "$", "joinType", ")", "->", "useQuery", "(", "$", "relationAlias", "?", "$", "relationAlias", ":", "'SkillRelatedByStartPositionId'", ",", "'\\gossi\\trixionary\\model\\SkillQuery'", ")", ";", "}" ]
Use the SkillRelatedByStartPositionId relation Skill object @see useQuery() @param string $relationAlias optional alias for the relation, to be used as main alias in the secondary query @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' @return \gossi\trixionary\model\SkillQuery A secondary query class using the current class as primary query
[ "Use", "the", "SkillRelatedByStartPositionId", "relation", "Skill", "object" ]
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/PositionQuery.php#L573-L578
561
gossi/trixionary
src/model/Base/PositionQuery.php
PositionQuery.useSkillRelatedByEndPositionIdQuery
public function useSkillRelatedByEndPositionIdQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinSkillRelatedByEndPositionId($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'SkillRelatedByEndPositionId', '\gossi\trixionary\model\SkillQuery'); }
php
public function useSkillRelatedByEndPositionIdQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinSkillRelatedByEndPositionId($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'SkillRelatedByEndPositionId', '\gossi\trixionary\model\SkillQuery'); }
[ "public", "function", "useSkillRelatedByEndPositionIdQuery", "(", "$", "relationAlias", "=", "null", ",", "$", "joinType", "=", "Criteria", "::", "LEFT_JOIN", ")", "{", "return", "$", "this", "->", "joinSkillRelatedByEndPositionId", "(", "$", "relationAlias", ",", "$", "joinType", ")", "->", "useQuery", "(", "$", "relationAlias", "?", "$", "relationAlias", ":", "'SkillRelatedByEndPositionId'", ",", "'\\gossi\\trixionary\\model\\SkillQuery'", ")", ";", "}" ]
Use the SkillRelatedByEndPositionId relation Skill object @see useQuery() @param string $relationAlias optional alias for the relation, to be used as main alias in the secondary query @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' @return \gossi\trixionary\model\SkillQuery A secondary query class using the current class as primary query
[ "Use", "the", "SkillRelatedByEndPositionId", "relation", "Skill", "object" ]
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/PositionQuery.php#L646-L651
562
monomelodies/gentry
src/Argument.php
Argument.isPassedByReference
public function isPassedByReference() { if ($class = $this->reflection->getClass() and $class->isTrait() ) { return true; } if ($class = $this->reflection->getClass()) { $reflection = (new ReflectionClass($class))->getConstructor(); foreach ($reflection->getParameters() as $param) { if (!$param->isDefaultValueAvailable()) { return true; } } return false; } if ($this->reflection->isDefaultValueAvailable()) { return false; } // No default defined, but let's see if we can guess... if ($this->reflection->isArray()) { return false; } if (version_compare(phpversion(), '7.0', '>=') and $type = $this->reflection->getType() ) { return false; } if ($extracted = $this->extractParameterData()) { return false; } return true; }
php
public function isPassedByReference() { if ($class = $this->reflection->getClass() and $class->isTrait() ) { return true; } if ($class = $this->reflection->getClass()) { $reflection = (new ReflectionClass($class))->getConstructor(); foreach ($reflection->getParameters() as $param) { if (!$param->isDefaultValueAvailable()) { return true; } } return false; } if ($this->reflection->isDefaultValueAvailable()) { return false; } // No default defined, but let's see if we can guess... if ($this->reflection->isArray()) { return false; } if (version_compare(phpversion(), '7.0', '>=') and $type = $this->reflection->getType() ) { return false; } if ($extracted = $this->extractParameterData()) { return false; } return true; }
[ "public", "function", "isPassedByReference", "(", ")", "{", "if", "(", "$", "class", "=", "$", "this", "->", "reflection", "->", "getClass", "(", ")", "and", "$", "class", "->", "isTrait", "(", ")", ")", "{", "return", "true", ";", "}", "if", "(", "$", "class", "=", "$", "this", "->", "reflection", "->", "getClass", "(", ")", ")", "{", "$", "reflection", "=", "(", "new", "ReflectionClass", "(", "$", "class", ")", ")", "->", "getConstructor", "(", ")", ";", "foreach", "(", "$", "reflection", "->", "getParameters", "(", ")", "as", "$", "param", ")", "{", "if", "(", "!", "$", "param", "->", "isDefaultValueAvailable", "(", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}", "if", "(", "$", "this", "->", "reflection", "->", "isDefaultValueAvailable", "(", ")", ")", "{", "return", "false", ";", "}", "// No default defined, but let's see if we can guess...", "if", "(", "$", "this", "->", "reflection", "->", "isArray", "(", ")", ")", "{", "return", "false", ";", "}", "if", "(", "version_compare", "(", "phpversion", "(", ")", ",", "'7.0'", ",", "'>='", ")", "and", "$", "type", "=", "$", "this", "->", "reflection", "->", "getType", "(", ")", ")", "{", "return", "false", ";", "}", "if", "(", "$", "extracted", "=", "$", "this", "->", "extractParameterData", "(", ")", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
Guesstimate if the argument should be passed by reference. This is true for objects with constructor parameters without defaults, as well as other non-guessable defaults. @return bool
[ "Guesstimate", "if", "the", "argument", "should", "be", "passed", "by", "reference", ".", "This", "is", "true", "for", "objects", "with", "constructor", "parameters", "without", "defaults", "as", "well", "as", "other", "non", "-", "guessable", "defaults", "." ]
11d28d21c4a5524c0b311bf5ffcc9c2562053396
https://github.com/monomelodies/gentry/blob/11d28d21c4a5524c0b311bf5ffcc9c2562053396/src/Argument.php#L57-L89
563
monomelodies/gentry
src/Argument.php
Argument.getDefault
public function getDefault() { if ($this->reflection->isDefaultValueAvailable() and $default = $this->reflection->getDefaultValue() ) { if (is_scalar($default)) { return $default; } else { return $this->tostring($default); } } if ($this->reflection->isArray()) { return '[]'; } if ($this->isPassedByReference()) { return 'null'; } elseif ($this->reflection->getClass()) { // This gets injected as a new instance. return null; } $type = $this->getType(); if (!$type) { $type = $this->extractParameterData(); } // Guesstimated values: switch ($type) { case 'int': case 'integer': case 'float': return 0; case 'string': return "''"; case 'array': return '[]'; } return null; }
php
public function getDefault() { if ($this->reflection->isDefaultValueAvailable() and $default = $this->reflection->getDefaultValue() ) { if (is_scalar($default)) { return $default; } else { return $this->tostring($default); } } if ($this->reflection->isArray()) { return '[]'; } if ($this->isPassedByReference()) { return 'null'; } elseif ($this->reflection->getClass()) { // This gets injected as a new instance. return null; } $type = $this->getType(); if (!$type) { $type = $this->extractParameterData(); } // Guesstimated values: switch ($type) { case 'int': case 'integer': case 'float': return 0; case 'string': return "''"; case 'array': return '[]'; } return null; }
[ "public", "function", "getDefault", "(", ")", "{", "if", "(", "$", "this", "->", "reflection", "->", "isDefaultValueAvailable", "(", ")", "and", "$", "default", "=", "$", "this", "->", "reflection", "->", "getDefaultValue", "(", ")", ")", "{", "if", "(", "is_scalar", "(", "$", "default", ")", ")", "{", "return", "$", "default", ";", "}", "else", "{", "return", "$", "this", "->", "tostring", "(", "$", "default", ")", ";", "}", "}", "if", "(", "$", "this", "->", "reflection", "->", "isArray", "(", ")", ")", "{", "return", "'[]'", ";", "}", "if", "(", "$", "this", "->", "isPassedByReference", "(", ")", ")", "{", "return", "'null'", ";", "}", "elseif", "(", "$", "this", "->", "reflection", "->", "getClass", "(", ")", ")", "{", "// This gets injected as a new instance.", "return", "null", ";", "}", "$", "type", "=", "$", "this", "->", "getType", "(", ")", ";", "if", "(", "!", "$", "type", ")", "{", "$", "type", "=", "$", "this", "->", "extractParameterData", "(", ")", ";", "}", "// Guesstimated values:", "switch", "(", "$", "type", ")", "{", "case", "'int'", ":", "case", "'integer'", ":", "case", "'float'", ":", "return", "0", ";", "case", "'string'", ":", "return", "\"''\"", ";", "case", "'array'", ":", "return", "'[]'", ";", "}", "return", "null", ";", "}" ]
Return the default value for the requested parameter. @return string A stringified version of the default value.
[ "Return", "the", "default", "value", "for", "the", "requested", "parameter", "." ]
11d28d21c4a5524c0b311bf5ffcc9c2562053396
https://github.com/monomelodies/gentry/blob/11d28d21c4a5524c0b311bf5ffcc9c2562053396/src/Argument.php#L96-L130
564
monomelodies/gentry
src/Argument.php
Argument.getType
private function getType() { if ($class = $this->reflection->getClass()) { return $class->name; } if ($this->reflection->isArray()) { return 'array'; } if (version_compare(phpversion(), '7.0', '>=') and $type = $this->reflection->getType() ) { return $type; } return ''; }
php
private function getType() { if ($class = $this->reflection->getClass()) { return $class->name; } if ($this->reflection->isArray()) { return 'array'; } if (version_compare(phpversion(), '7.0', '>=') and $type = $this->reflection->getType() ) { return $type; } return ''; }
[ "private", "function", "getType", "(", ")", "{", "if", "(", "$", "class", "=", "$", "this", "->", "reflection", "->", "getClass", "(", ")", ")", "{", "return", "$", "class", "->", "name", ";", "}", "if", "(", "$", "this", "->", "reflection", "->", "isArray", "(", ")", ")", "{", "return", "'array'", ";", "}", "if", "(", "version_compare", "(", "phpversion", "(", ")", ",", "'7.0'", ",", "'>='", ")", "and", "$", "type", "=", "$", "this", "->", "reflection", "->", "getType", "(", ")", ")", "{", "return", "$", "type", ";", "}", "return", "''", ";", "}" ]
Internal helper method to guesstimate the argument's type hint. @return string
[ "Internal", "helper", "method", "to", "guesstimate", "the", "argument", "s", "type", "hint", "." ]
11d28d21c4a5524c0b311bf5ffcc9c2562053396
https://github.com/monomelodies/gentry/blob/11d28d21c4a5524c0b311bf5ffcc9c2562053396/src/Argument.php#L137-L151
565
monomelodies/gentry
src/Argument.php
Argument.tostring
private function tostring($value) { if (!isset($value)) { return 'null'; } if ($value === true) { return 'true'; } if ($value === false) { return 'false'; } if (is_array($value)) { $out = '['; $i = 0; foreach ($value as $key => $entry) { if ($i) { $out .= ', '; } $out .= $key.' => '.$this->tostring($entry); $i++; } $out .= ']'; return $out; } }
php
private function tostring($value) { if (!isset($value)) { return 'null'; } if ($value === true) { return 'true'; } if ($value === false) { return 'false'; } if (is_array($value)) { $out = '['; $i = 0; foreach ($value as $key => $entry) { if ($i) { $out .= ', '; } $out .= $key.' => '.$this->tostring($entry); $i++; } $out .= ']'; return $out; } }
[ "private", "function", "tostring", "(", "$", "value", ")", "{", "if", "(", "!", "isset", "(", "$", "value", ")", ")", "{", "return", "'null'", ";", "}", "if", "(", "$", "value", "===", "true", ")", "{", "return", "'true'", ";", "}", "if", "(", "$", "value", "===", "false", ")", "{", "return", "'false'", ";", "}", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "out", "=", "'['", ";", "$", "i", "=", "0", ";", "foreach", "(", "$", "value", "as", "$", "key", "=>", "$", "entry", ")", "{", "if", "(", "$", "i", ")", "{", "$", "out", ".=", "', '", ";", "}", "$", "out", ".=", "$", "key", ".", "' => '", ".", "$", "this", "->", "tostring", "(", "$", "entry", ")", ";", "$", "i", "++", ";", "}", "$", "out", ".=", "']'", ";", "return", "$", "out", ";", "}", "}" ]
Internal helper method to render a PHP variable as a string. @param mixed $value The value to render. @return string An echo'able representation.
[ "Internal", "helper", "method", "to", "render", "a", "PHP", "variable", "as", "a", "string", "." ]
11d28d21c4a5524c0b311bf5ffcc9c2562053396
https://github.com/monomelodies/gentry/blob/11d28d21c4a5524c0b311bf5ffcc9c2562053396/src/Argument.php#L179-L203
566
eix/core
src/php/main/Eix/Core/Responses/Http/Image.php
Image.setFileName
public function setFileName($fileName) { $this->fileName = $fileName; $this->setContentType(mime_content_type($this->fileName)); }
php
public function setFileName($fileName) { $this->fileName = $fileName; $this->setContentType(mime_content_type($this->fileName)); }
[ "public", "function", "setFileName", "(", "$", "fileName", ")", "{", "$", "this", "->", "fileName", "=", "$", "fileName", ";", "$", "this", "->", "setContentType", "(", "mime_content_type", "(", "$", "this", "->", "fileName", ")", ")", ";", "}" ]
Sets the name of the file that contains the image. @param string $fileName the file name
[ "Sets", "the", "name", "of", "the", "file", "that", "contains", "the", "image", "." ]
a5b4c09cc168221e85804fdfeb78e519a0415466
https://github.com/eix/core/blob/a5b4c09cc168221e85804fdfeb78e519a0415466/src/php/main/Eix/Core/Responses/Http/Image.php#L79-L83
567
praxisnetau/silverware-carousel
src/Components/CarouselComponent.php
CarouselComponent.setSlides
public function setSlides(SS_List $slides) { $list = ArrayList::create(); foreach ($slides as $slide) { $list->push($slide->setParentInstance($this)); } $this->slides = $list; }
php
public function setSlides(SS_List $slides) { $list = ArrayList::create(); foreach ($slides as $slide) { $list->push($slide->setParentInstance($this)); } $this->slides = $list; }
[ "public", "function", "setSlides", "(", "SS_List", "$", "slides", ")", "{", "$", "list", "=", "ArrayList", "::", "create", "(", ")", ";", "foreach", "(", "$", "slides", "as", "$", "slide", ")", "{", "$", "list", "->", "push", "(", "$", "slide", "->", "setParentInstance", "(", "$", "this", ")", ")", ";", "}", "$", "this", "->", "slides", "=", "$", "list", ";", "}" ]
Defines the slides property for the receiver. @param SS_List $slides @return $this
[ "Defines", "the", "slides", "property", "for", "the", "receiver", "." ]
e729f1362a6dda11be21f147c241532065eae2c6
https://github.com/praxisnetau/silverware-carousel/blob/e729f1362a6dda11be21f147c241532065eae2c6/src/Components/CarouselComponent.php#L296-L305
568
praxisnetau/silverware-carousel
src/Components/CarouselComponent.php
CarouselComponent.getWrapperAttributes
public function getWrapperAttributes() { $attributes = [ 'id' => $this->WrapperID, 'class' => $this->WrapperClass ]; $this->extend('updateWrapperAttributes', $attributes); $attributes = array_merge($attributes, $this->getWrapperDataAttributes()); return $attributes; }
php
public function getWrapperAttributes() { $attributes = [ 'id' => $this->WrapperID, 'class' => $this->WrapperClass ]; $this->extend('updateWrapperAttributes', $attributes); $attributes = array_merge($attributes, $this->getWrapperDataAttributes()); return $attributes; }
[ "public", "function", "getWrapperAttributes", "(", ")", "{", "$", "attributes", "=", "[", "'id'", "=>", "$", "this", "->", "WrapperID", ",", "'class'", "=>", "$", "this", "->", "WrapperClass", "]", ";", "$", "this", "->", "extend", "(", "'updateWrapperAttributes'", ",", "$", "attributes", ")", ";", "$", "attributes", "=", "array_merge", "(", "$", "attributes", ",", "$", "this", "->", "getWrapperDataAttributes", "(", ")", ")", ";", "return", "$", "attributes", ";", "}" ]
Answers an array of HTML tag attributes for the wrapper. @return array
[ "Answers", "an", "array", "of", "HTML", "tag", "attributes", "for", "the", "wrapper", "." ]
e729f1362a6dda11be21f147c241532065eae2c6
https://github.com/praxisnetau/silverware-carousel/blob/e729f1362a6dda11be21f147c241532065eae2c6/src/Components/CarouselComponent.php#L348-L360
569
lucifurious/kisma
src/Kisma/Core/Utility/Convert.php
Convert.toObject
public static function toObject( $object ) { // If we can't iterate over the thing, we bail if ( !is_object( $object ) && !is_array( $object ) && !( $object instanceof \Traversable ) ) { return null; } if ( is_array( $object ) ) { // Convert to an object $_properties = new \stdClass(); foreach ( $object as $_key => $_value ) { $_properties->{$_key} = $_value; } } else { $_me = new \ReflectionObject( $object ); $_properties = $_me->getProperties(); } // We'll return this $_obj = new \stdClass(); if ( !empty( $_properties ) ) { if ( is_object( $object ) ) { $_myClass = get_class( $object ); } else { $_myClass = '_array_'; } foreach ( $_properties as $_property ) { // Only want properties of $object hierarchy... if ( isset( $_property->class ) ) { $_class = new \ReflectionClass( $_property->class ); if ( !empty( $_class ) && !$_class->isInstance( $object ) && !$_class->isSubclassOf( $_myClass ) ) { unset( $_class ); continue; } unset( $_class ); } try { $_realPropertyName = $_propertyName = ltrim( $_property->name, '_ ' ); if ( false !== strpos( $_propertyName, '_' ) ) { $_propertyName = Inflector::tag( $_propertyName ); } $_getter = 'get' . $_propertyName; if ( method_exists( $object, $_getter ) ) { $_propertyValue = $object->{$_getter}(); if ( !is_scalar( $_propertyValue ) ) { $_propertyValue = self::toObject( $_propertyValue ); } $_obj->{$_realPropertyName} = $_propertyValue; } } catch ( \Exception $_ex ) { // Just ignore, not a valid property if we can't read it with a getter } } } return $_obj; }
php
public static function toObject( $object ) { // If we can't iterate over the thing, we bail if ( !is_object( $object ) && !is_array( $object ) && !( $object instanceof \Traversable ) ) { return null; } if ( is_array( $object ) ) { // Convert to an object $_properties = new \stdClass(); foreach ( $object as $_key => $_value ) { $_properties->{$_key} = $_value; } } else { $_me = new \ReflectionObject( $object ); $_properties = $_me->getProperties(); } // We'll return this $_obj = new \stdClass(); if ( !empty( $_properties ) ) { if ( is_object( $object ) ) { $_myClass = get_class( $object ); } else { $_myClass = '_array_'; } foreach ( $_properties as $_property ) { // Only want properties of $object hierarchy... if ( isset( $_property->class ) ) { $_class = new \ReflectionClass( $_property->class ); if ( !empty( $_class ) && !$_class->isInstance( $object ) && !$_class->isSubclassOf( $_myClass ) ) { unset( $_class ); continue; } unset( $_class ); } try { $_realPropertyName = $_propertyName = ltrim( $_property->name, '_ ' ); if ( false !== strpos( $_propertyName, '_' ) ) { $_propertyName = Inflector::tag( $_propertyName ); } $_getter = 'get' . $_propertyName; if ( method_exists( $object, $_getter ) ) { $_propertyValue = $object->{$_getter}(); if ( !is_scalar( $_propertyValue ) ) { $_propertyValue = self::toObject( $_propertyValue ); } $_obj->{$_realPropertyName} = $_propertyValue; } } catch ( \Exception $_ex ) { // Just ignore, not a valid property if we can't read it with a getter } } } return $_obj; }
[ "public", "static", "function", "toObject", "(", "$", "object", ")", "{", "//\tIf we can't iterate over the thing, we bail", "if", "(", "!", "is_object", "(", "$", "object", ")", "&&", "!", "is_array", "(", "$", "object", ")", "&&", "!", "(", "$", "object", "instanceof", "\\", "Traversable", ")", ")", "{", "return", "null", ";", "}", "if", "(", "is_array", "(", "$", "object", ")", ")", "{", "//\tConvert to an object", "$", "_properties", "=", "new", "\\", "stdClass", "(", ")", ";", "foreach", "(", "$", "object", "as", "$", "_key", "=>", "$", "_value", ")", "{", "$", "_properties", "->", "{", "$", "_key", "}", "=", "$", "_value", ";", "}", "}", "else", "{", "$", "_me", "=", "new", "\\", "ReflectionObject", "(", "$", "object", ")", ";", "$", "_properties", "=", "$", "_me", "->", "getProperties", "(", ")", ";", "}", "//\tWe'll return this", "$", "_obj", "=", "new", "\\", "stdClass", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "_properties", ")", ")", "{", "if", "(", "is_object", "(", "$", "object", ")", ")", "{", "$", "_myClass", "=", "get_class", "(", "$", "object", ")", ";", "}", "else", "{", "$", "_myClass", "=", "'_array_'", ";", "}", "foreach", "(", "$", "_properties", "as", "$", "_property", ")", "{", "//\tOnly want properties of $object hierarchy...", "if", "(", "isset", "(", "$", "_property", "->", "class", ")", ")", "{", "$", "_class", "=", "new", "\\", "ReflectionClass", "(", "$", "_property", "->", "class", ")", ";", "if", "(", "!", "empty", "(", "$", "_class", ")", "&&", "!", "$", "_class", "->", "isInstance", "(", "$", "object", ")", "&&", "!", "$", "_class", "->", "isSubclassOf", "(", "$", "_myClass", ")", ")", "{", "unset", "(", "$", "_class", ")", ";", "continue", ";", "}", "unset", "(", "$", "_class", ")", ";", "}", "try", "{", "$", "_realPropertyName", "=", "$", "_propertyName", "=", "ltrim", "(", "$", "_property", "->", "name", ",", "'_ '", ")", ";", "if", "(", "false", "!==", "strpos", "(", "$", "_propertyName", ",", "'_'", ")", ")", "{", "$", "_propertyName", "=", "Inflector", "::", "tag", "(", "$", "_propertyName", ")", ";", "}", "$", "_getter", "=", "'get'", ".", "$", "_propertyName", ";", "if", "(", "method_exists", "(", "$", "object", ",", "$", "_getter", ")", ")", "{", "$", "_propertyValue", "=", "$", "object", "->", "{", "$", "_getter", "}", "(", ")", ";", "if", "(", "!", "is_scalar", "(", "$", "_propertyValue", ")", ")", "{", "$", "_propertyValue", "=", "self", "::", "toObject", "(", "$", "_propertyValue", ")", ";", "}", "$", "_obj", "->", "{", "$", "_realPropertyName", "}", "=", "$", "_propertyValue", ";", "}", "}", "catch", "(", "\\", "Exception", "$", "_ex", ")", "{", "//\tJust ignore, not a valid property if we can't read it with a getter", "}", "}", "}", "return", "$", "_obj", ";", "}" ]
Dynamically generates the object from the declared properties of the given object or array @param array|object $object @return \stdClass
[ "Dynamically", "generates", "the", "object", "from", "the", "declared", "properties", "of", "the", "given", "object", "or", "array" ]
4cc9954249da4e535b52f154e728935f07e648ae
https://github.com/lucifurious/kisma/blob/4cc9954249da4e535b52f154e728935f07e648ae/src/Kisma/Core/Utility/Convert.php#L38-L123
570
lucifurious/kisma
src/Kisma/Core/Utility/Convert.php
Convert.createArray
public static function createArray( $data ) { $_result = array(); $_count = func_num_args(); for ( $_i = 0; $_i < $_count; $_i++ ) { // Any other columns to touch? if ( null !== ( $_arg = func_get_arg( $_i ) ) ) { if ( !is_array( $_arg ) ) { $_result[] = $_arg; } else { foreach ( $_arg as $_value ) { $_result[] = $_value; } } } } // Return the fresh array... return $_result; }
php
public static function createArray( $data ) { $_result = array(); $_count = func_num_args(); for ( $_i = 0; $_i < $_count; $_i++ ) { // Any other columns to touch? if ( null !== ( $_arg = func_get_arg( $_i ) ) ) { if ( !is_array( $_arg ) ) { $_result[] = $_arg; } else { foreach ( $_arg as $_value ) { $_result[] = $_value; } } } } // Return the fresh array... return $_result; }
[ "public", "static", "function", "createArray", "(", "$", "data", ")", "{", "$", "_result", "=", "array", "(", ")", ";", "$", "_count", "=", "func_num_args", "(", ")", ";", "for", "(", "$", "_i", "=", "0", ";", "$", "_i", "<", "$", "_count", ";", "$", "_i", "++", ")", "{", "//\tAny other columns to touch?", "if", "(", "null", "!==", "(", "$", "_arg", "=", "func_get_arg", "(", "$", "_i", ")", ")", ")", "{", "if", "(", "!", "is_array", "(", "$", "_arg", ")", ")", "{", "$", "_result", "[", "]", "=", "$", "_arg", ";", "}", "else", "{", "foreach", "(", "$", "_arg", "as", "$", "_value", ")", "{", "$", "_result", "[", "]", "=", "$", "_value", ";", "}", "}", "}", "}", "//\tReturn the fresh array...", "return", "$", "_result", ";", "}" ]
Takes parameters and returns an array of the values. @param string|array $data One or more values to read and put into the return array. @return array
[ "Takes", "parameters", "and", "returns", "an", "array", "of", "the", "values", "." ]
4cc9954249da4e535b52f154e728935f07e648ae
https://github.com/lucifurious/kisma/blob/4cc9954249da4e535b52f154e728935f07e648ae/src/Kisma/Core/Utility/Convert.php#L132-L158
571
lucifurious/kisma
src/Kisma/Core/Utility/Convert.php
Convert.toArray
public static function toArray( $object ) { if ( is_object( $object ) ) { return get_object_vars( $object ); } if ( is_array( $object ) ) { return array_map( array( __CLASS__, 'toArray' ), $object ); } // Return array return $object; }
php
public static function toArray( $object ) { if ( is_object( $object ) ) { return get_object_vars( $object ); } if ( is_array( $object ) ) { return array_map( array( __CLASS__, 'toArray' ), $object ); } // Return array return $object; }
[ "public", "static", "function", "toArray", "(", "$", "object", ")", "{", "if", "(", "is_object", "(", "$", "object", ")", ")", "{", "return", "get_object_vars", "(", "$", "object", ")", ";", "}", "if", "(", "is_array", "(", "$", "object", ")", ")", "{", "return", "array_map", "(", "array", "(", "__CLASS__", ",", "'toArray'", ")", ",", "$", "object", ")", ";", "}", "// Return array", "return", "$", "object", ";", "}" ]
Down and dirty object to array function @static @param object $object @return array
[ "Down", "and", "dirty", "object", "to", "array", "function" ]
4cc9954249da4e535b52f154e728935f07e648ae
https://github.com/lucifurious/kisma/blob/4cc9954249da4e535b52f154e728935f07e648ae/src/Kisma/Core/Utility/Convert.php#L169-L189
572
lucifurious/kisma
src/Kisma/Core/Utility/Convert.php
Convert.kvpToString
public static function kvpToString( $array, $uppercaseKeys = false, $trueConvert = 1, $falseConvert = 0 ) { $_result = array(); foreach ( Option::clean( $array ) as $_key => $_value ) { if ( null !== $_value ) { if ( false === $_value ) { $_value = $falseConvert; } else if ( true === $_value ) { $_value = $trueConvert; } else if ( is_array( $_value ) ) { $_value = trim( implode( ' ', $_value ) ); } $_result[] = ( false !== $uppercaseKeys ? strtoupper( $_key ) : strtolower( $_key ) ) . '="' . $_value . '"'; } } return trim( implode( ' ', $_result ) ); }
php
public static function kvpToString( $array, $uppercaseKeys = false, $trueConvert = 1, $falseConvert = 0 ) { $_result = array(); foreach ( Option::clean( $array ) as $_key => $_value ) { if ( null !== $_value ) { if ( false === $_value ) { $_value = $falseConvert; } else if ( true === $_value ) { $_value = $trueConvert; } else if ( is_array( $_value ) ) { $_value = trim( implode( ' ', $_value ) ); } $_result[] = ( false !== $uppercaseKeys ? strtoupper( $_key ) : strtolower( $_key ) ) . '="' . $_value . '"'; } } return trim( implode( ' ', $_result ) ); }
[ "public", "static", "function", "kvpToString", "(", "$", "array", ",", "$", "uppercaseKeys", "=", "false", ",", "$", "trueConvert", "=", "1", ",", "$", "falseConvert", "=", "0", ")", "{", "$", "_result", "=", "array", "(", ")", ";", "foreach", "(", "Option", "::", "clean", "(", "$", "array", ")", "as", "$", "_key", "=>", "$", "_value", ")", "{", "if", "(", "null", "!==", "$", "_value", ")", "{", "if", "(", "false", "===", "$", "_value", ")", "{", "$", "_value", "=", "$", "falseConvert", ";", "}", "else", "if", "(", "true", "===", "$", "_value", ")", "{", "$", "_value", "=", "$", "trueConvert", ";", "}", "else", "if", "(", "is_array", "(", "$", "_value", ")", ")", "{", "$", "_value", "=", "trim", "(", "implode", "(", "' '", ",", "$", "_value", ")", ")", ";", "}", "$", "_result", "[", "]", "=", "(", "false", "!==", "$", "uppercaseKeys", "?", "strtoupper", "(", "$", "_key", ")", ":", "strtolower", "(", "$", "_key", ")", ")", ".", "'=\"'", ".", "$", "_value", ".", "'\"'", ";", "}", "}", "return", "trim", "(", "implode", "(", "' '", ",", "$", "_result", ")", ")", ";", "}" ]
Takes a KVP traversable and converts to a ' key="value" ' string suitable for framing. @param array|object $array @param bool $uppercaseKeys If TRUE, the "key" portion will be uppercased @param int $trueConvert The value to substitute for boolean true @param int $falseConvert The value to substitute for boolean false @return string
[ "Takes", "a", "KVP", "traversable", "and", "converts", "to", "a", "key", "=", "value", "string", "suitable", "for", "framing", "." ]
4cc9954249da4e535b52f154e728935f07e648ae
https://github.com/lucifurious/kisma/blob/4cc9954249da4e535b52f154e728935f07e648ae/src/Kisma/Core/Utility/Convert.php#L230-L256
573
tacone/datasource
src/EloquentCache.php
EloquentCache.all
public static function all($parent) { is_eloquent_object($parent, true); $cache = static::getCache(); if (isset($cache[$parent])) { return $cache[$parent]; } return []; }
php
public static function all($parent) { is_eloquent_object($parent, true); $cache = static::getCache(); if (isset($cache[$parent])) { return $cache[$parent]; } return []; }
[ "public", "static", "function", "all", "(", "$", "parent", ")", "{", "is_eloquent_object", "(", "$", "parent", ",", "true", ")", ";", "$", "cache", "=", "static", "::", "getCache", "(", ")", ";", "if", "(", "isset", "(", "$", "cache", "[", "$", "parent", "]", ")", ")", "{", "return", "$", "cache", "[", "$", "parent", "]", ";", "}", "return", "[", "]", ";", "}" ]
Returns the cached relations for a given parent model. @param $model @return array
[ "Returns", "the", "cached", "relations", "for", "a", "given", "parent", "model", "." ]
9cf4423764ba14e9bbd9fa7d5cdbed27d70001f3
https://github.com/tacone/datasource/blob/9cf4423764ba14e9bbd9fa7d5cdbed27d70001f3/src/EloquentCache.php#L96-L105
574
wasabi-cms/core
src/View/Helper/EmailHelper.php
EmailHelper.bigActionButton
public function bigActionButton($linkText, array $url, $bgColor = '#368ee0', $textColor = "#ffffff") { return $this->_View->element('Wasabi/Core.Email/big-action-button', [ 'linkText' => $linkText, 'url' => $this->Url->build($url, true), 'bgColor' => $bgColor, 'textColor' => $textColor ]); }
php
public function bigActionButton($linkText, array $url, $bgColor = '#368ee0', $textColor = "#ffffff") { return $this->_View->element('Wasabi/Core.Email/big-action-button', [ 'linkText' => $linkText, 'url' => $this->Url->build($url, true), 'bgColor' => $bgColor, 'textColor' => $textColor ]); }
[ "public", "function", "bigActionButton", "(", "$", "linkText", ",", "array", "$", "url", ",", "$", "bgColor", "=", "'#368ee0'", ",", "$", "textColor", "=", "\"#ffffff\"", ")", "{", "return", "$", "this", "->", "_View", "->", "element", "(", "'Wasabi/Core.Email/big-action-button'", ",", "[", "'linkText'", "=>", "$", "linkText", ",", "'url'", "=>", "$", "this", "->", "Url", "->", "build", "(", "$", "url", ",", "true", ")", ",", "'bgColor'", "=>", "$", "bgColor", ",", "'textColor'", "=>", "$", "textColor", "]", ")", ";", "}" ]
Render a big action button. @param string $linkText The button text to display. @param array $url The url the button should link to. @param string $bgColor The background color. @param string $textColor The text color. @return string
[ "Render", "a", "big", "action", "button", "." ]
0eadbb64d2fc201bacc63c93814adeca70e08f90
https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/View/Helper/EmailHelper.php#L45-L53
575
wasabi-cms/core
src/View/Helper/EmailHelper.php
EmailHelper.linkToCmsHomepage
public function linkToCmsHomepage() { return $this->Html->link( preg_replace('/https{0,1}:\/{2}/', '', $this->Url->build('/', true)), $this->Url->build('/', true) ); }
php
public function linkToCmsHomepage() { return $this->Html->link( preg_replace('/https{0,1}:\/{2}/', '', $this->Url->build('/', true)), $this->Url->build('/', true) ); }
[ "public", "function", "linkToCmsHomepage", "(", ")", "{", "return", "$", "this", "->", "Html", "->", "link", "(", "preg_replace", "(", "'/https{0,1}:\\/{2}/'", ",", "''", ",", "$", "this", "->", "Url", "->", "build", "(", "'/'", ",", "true", ")", ")", ",", "$", "this", "->", "Url", "->", "build", "(", "'/'", ",", "true", ")", ")", ";", "}" ]
Link to the home page. @return string
[ "Link", "to", "the", "home", "page", "." ]
0eadbb64d2fc201bacc63c93814adeca70e08f90
https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/View/Helper/EmailHelper.php#L60-L66
576
clubdeuce/custom-sidebars
includes/class-custom-sidebars.php
Custom_Sidebars.init
public function init() { $posts = array(); if ( ! $posts = wp_cache_get( 'sidebars', 'custom_sidebars' ) ) { $args = array( 'post_type' => Custom_Sidebars::get_post_types(), 'meta_query' => array( array( 'key' => '_custom_sidebar', 'value' => true, ) ) ); $query = new WP_Query( $args ); if ( $query->have_posts() ) { $posts = $query->posts; } wp_cache_set( 'sidebars', 'custom_sidebars' ); } foreach ( $posts as $post ) { $args = apply_filters( 'custom_sidebar_args', array( 'name' => sprintf( __( 'Sidebar: %s', 'custom_sidebars' ), $post->post_title ), 'id' => $this->get_sidebar_id( $post->ID ), 'description' => sprintf( __( 'This sidebar will appear on the %s single page.', 'cd-sidebar' ), $post->post_title ), 'class' => '', 'before_widget' => '<aside id="%1$s" class="widget %2$s">', 'after_widget' => '</aside>', 'before_title' => '<h2 class="widget-title">', 'after_title' => '</h2>', ) ); register_sidebar( $args ); } }
php
public function init() { $posts = array(); if ( ! $posts = wp_cache_get( 'sidebars', 'custom_sidebars' ) ) { $args = array( 'post_type' => Custom_Sidebars::get_post_types(), 'meta_query' => array( array( 'key' => '_custom_sidebar', 'value' => true, ) ) ); $query = new WP_Query( $args ); if ( $query->have_posts() ) { $posts = $query->posts; } wp_cache_set( 'sidebars', 'custom_sidebars' ); } foreach ( $posts as $post ) { $args = apply_filters( 'custom_sidebar_args', array( 'name' => sprintf( __( 'Sidebar: %s', 'custom_sidebars' ), $post->post_title ), 'id' => $this->get_sidebar_id( $post->ID ), 'description' => sprintf( __( 'This sidebar will appear on the %s single page.', 'cd-sidebar' ), $post->post_title ), 'class' => '', 'before_widget' => '<aside id="%1$s" class="widget %2$s">', 'after_widget' => '</aside>', 'before_title' => '<h2 class="widget-title">', 'after_title' => '</h2>', ) ); register_sidebar( $args ); } }
[ "public", "function", "init", "(", ")", "{", "$", "posts", "=", "array", "(", ")", ";", "if", "(", "!", "$", "posts", "=", "wp_cache_get", "(", "'sidebars'", ",", "'custom_sidebars'", ")", ")", "{", "$", "args", "=", "array", "(", "'post_type'", "=>", "Custom_Sidebars", "::", "get_post_types", "(", ")", ",", "'meta_query'", "=>", "array", "(", "array", "(", "'key'", "=>", "'_custom_sidebar'", ",", "'value'", "=>", "true", ",", ")", ")", ")", ";", "$", "query", "=", "new", "WP_Query", "(", "$", "args", ")", ";", "if", "(", "$", "query", "->", "have_posts", "(", ")", ")", "{", "$", "posts", "=", "$", "query", "->", "posts", ";", "}", "wp_cache_set", "(", "'sidebars'", ",", "'custom_sidebars'", ")", ";", "}", "foreach", "(", "$", "posts", "as", "$", "post", ")", "{", "$", "args", "=", "apply_filters", "(", "'custom_sidebar_args'", ",", "array", "(", "'name'", "=>", "sprintf", "(", "__", "(", "'Sidebar: %s'", ",", "'custom_sidebars'", ")", ",", "$", "post", "->", "post_title", ")", ",", "'id'", "=>", "$", "this", "->", "get_sidebar_id", "(", "$", "post", "->", "ID", ")", ",", "'description'", "=>", "sprintf", "(", "__", "(", "'This sidebar will appear on the %s single page.'", ",", "'cd-sidebar'", ")", ",", "$", "post", "->", "post_title", ")", ",", "'class'", "=>", "''", ",", "'before_widget'", "=>", "'<aside id=\"%1$s\" class=\"widget %2$s\">'", ",", "'after_widget'", "=>", "'</aside>'", ",", "'before_title'", "=>", "'<h2 class=\"widget-title\">'", ",", "'after_title'", "=>", "'</h2>'", ",", ")", ")", ";", "register_sidebar", "(", "$", "args", ")", ";", "}", "}" ]
The WP admin_init action callback Get all pages and posts and add sidebars for each individual post
[ "The", "WP", "admin_init", "action", "callback" ]
69418b2710c2896749dc365e5c63aa9431342310
https://github.com/clubdeuce/custom-sidebars/blob/69418b2710c2896749dc365e5c63aa9431342310/includes/class-custom-sidebars.php#L64-L103
577
clubdeuce/custom-sidebars
includes/class-custom-sidebars.php
Custom_Sidebars.get_sidebar
public static function get_sidebar( $post_id = null ) { if ( empty( $post_id ) ) { $post_id = get_post()->ID; } $sidebar = get_post_meta( $post_id, '_custom_sidebar_id', true ); if ( $sidebar == false && isset( self::$default_sidebar_id ) ) { $sidebar = self::$default_sidebar_id; } return $sidebar; }
php
public static function get_sidebar( $post_id = null ) { if ( empty( $post_id ) ) { $post_id = get_post()->ID; } $sidebar = get_post_meta( $post_id, '_custom_sidebar_id', true ); if ( $sidebar == false && isset( self::$default_sidebar_id ) ) { $sidebar = self::$default_sidebar_id; } return $sidebar; }
[ "public", "static", "function", "get_sidebar", "(", "$", "post_id", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "post_id", ")", ")", "{", "$", "post_id", "=", "get_post", "(", ")", "->", "ID", ";", "}", "$", "sidebar", "=", "get_post_meta", "(", "$", "post_id", ",", "'_custom_sidebar_id'", ",", "true", ")", ";", "if", "(", "$", "sidebar", "==", "false", "&&", "isset", "(", "self", "::", "$", "default_sidebar_id", ")", ")", "{", "$", "sidebar", "=", "self", "::", "$", "default_sidebar_id", ";", "}", "return", "$", "sidebar", ";", "}" ]
Get the sidebar_id assigned to a specific post
[ "Get", "the", "sidebar_id", "assigned", "to", "a", "specific", "post" ]
69418b2710c2896749dc365e5c63aa9431342310
https://github.com/clubdeuce/custom-sidebars/blob/69418b2710c2896749dc365e5c63aa9431342310/includes/class-custom-sidebars.php#L131-L145
578
clubdeuce/custom-sidebars
includes/class-custom-sidebars.php
Custom_Sidebars.sidebars_widgets
public function sidebars_widgets( $sidebar_widgets ) { if ( ! is_admin() && ! empty( $this->get_sidebar() ) ) { foreach ( $sidebar_widgets as $key => $widgets ) { $sidebar_widgets[ $key ] = $sidebar_widgets[ $this->get_sidebar() ]; } } return $sidebar_widgets; }
php
public function sidebars_widgets( $sidebar_widgets ) { if ( ! is_admin() && ! empty( $this->get_sidebar() ) ) { foreach ( $sidebar_widgets as $key => $widgets ) { $sidebar_widgets[ $key ] = $sidebar_widgets[ $this->get_sidebar() ]; } } return $sidebar_widgets; }
[ "public", "function", "sidebars_widgets", "(", "$", "sidebar_widgets", ")", "{", "if", "(", "!", "is_admin", "(", ")", "&&", "!", "empty", "(", "$", "this", "->", "get_sidebar", "(", ")", ")", ")", "{", "foreach", "(", "$", "sidebar_widgets", "as", "$", "key", "=>", "$", "widgets", ")", "{", "$", "sidebar_widgets", "[", "$", "key", "]", "=", "$", "sidebar_widgets", "[", "$", "this", "->", "get_sidebar", "(", ")", "]", ";", "}", "}", "return", "$", "sidebar_widgets", ";", "}" ]
Filter the sidebar widgets This method is hooked to the WP filter sidebars_widgets. Since we have no way to know what sidebar is currently being called, this method replaces the array of widgets for ALL registered sidebars with the widgets assigned to the sidebar specified for use on this particular post/page. This is a carpet-bomb approach that should be more specific, but current limitiations in the WP infrastructure require it to be done this way. @param array $sidebar_widgets @return array $sidebar_widgets The filtered widget array @since 0.3
[ "Filter", "the", "sidebar", "widgets" ]
69418b2710c2896749dc365e5c63aa9431342310
https://github.com/clubdeuce/custom-sidebars/blob/69418b2710c2896749dc365e5c63aa9431342310/includes/class-custom-sidebars.php#L171-L181
579
flowcode/AmulenMediaBundle
src/Flowcode/MediaBundle/Controller/AdminMediaController.php
AdminMediaController.createCreateForm
private function createCreateForm(Media $entity) { $types = $this->container->getParameter('flowcode_media.media_types'); $class = $types[$entity->getMediaType()]["class_type"]; $form = $this->createForm(new $class(), $entity, array( 'action' => $this->generateUrl('admin_media_create', array("type" => $entity->getMediaType())), 'method' => 'POST', )); $form->add('submit', 'submit', array('label' => 'Create')); return $form; }
php
private function createCreateForm(Media $entity) { $types = $this->container->getParameter('flowcode_media.media_types'); $class = $types[$entity->getMediaType()]["class_type"]; $form = $this->createForm(new $class(), $entity, array( 'action' => $this->generateUrl('admin_media_create', array("type" => $entity->getMediaType())), 'method' => 'POST', )); $form->add('submit', 'submit', array('label' => 'Create')); return $form; }
[ "private", "function", "createCreateForm", "(", "Media", "$", "entity", ")", "{", "$", "types", "=", "$", "this", "->", "container", "->", "getParameter", "(", "'flowcode_media.media_types'", ")", ";", "$", "class", "=", "$", "types", "[", "$", "entity", "->", "getMediaType", "(", ")", "]", "[", "\"class_type\"", "]", ";", "$", "form", "=", "$", "this", "->", "createForm", "(", "new", "$", "class", "(", ")", ",", "$", "entity", ",", "array", "(", "'action'", "=>", "$", "this", "->", "generateUrl", "(", "'admin_media_create'", ",", "array", "(", "\"type\"", "=>", "$", "entity", "->", "getMediaType", "(", ")", ")", ")", ",", "'method'", "=>", "'POST'", ",", ")", ")", ";", "$", "form", "->", "add", "(", "'submit'", ",", "'submit'", ",", "array", "(", "'label'", "=>", "'Create'", ")", ")", ";", "return", "$", "form", ";", "}" ]
Creates a form to create a Media entity. @param Media $entity The entity @return \Symfony\Component\Form\Form The form
[ "Creates", "a", "form", "to", "create", "a", "Media", "entity", "." ]
3be28720ff108cca1480de609872d29283776643
https://github.com/flowcode/AmulenMediaBundle/blob/3be28720ff108cca1480de609872d29283776643/src/Flowcode/MediaBundle/Controller/AdminMediaController.php#L97-L110
580
flowcode/AmulenMediaBundle
src/Flowcode/MediaBundle/Controller/AdminMediaController.php
AdminMediaController.newAction
public function newAction($type) { $entity = new Media(); $entity->setMediaType($type); $form = $this->createCreateForm($entity); return array( 'entity' => $entity, 'form' => $form->createView(), ); }
php
public function newAction($type) { $entity = new Media(); $entity->setMediaType($type); $form = $this->createCreateForm($entity); return array( 'entity' => $entity, 'form' => $form->createView(), ); }
[ "public", "function", "newAction", "(", "$", "type", ")", "{", "$", "entity", "=", "new", "Media", "(", ")", ";", "$", "entity", "->", "setMediaType", "(", "$", "type", ")", ";", "$", "form", "=", "$", "this", "->", "createCreateForm", "(", "$", "entity", ")", ";", "return", "array", "(", "'entity'", "=>", "$", "entity", ",", "'form'", "=>", "$", "form", "->", "createView", "(", ")", ",", ")", ";", "}" ]
Displays a form to create a new Media entity. @Route("/new/{type}", name="admin_media_new") @Method("GET") @Template()
[ "Displays", "a", "form", "to", "create", "a", "new", "Media", "entity", "." ]
3be28720ff108cca1480de609872d29283776643
https://github.com/flowcode/AmulenMediaBundle/blob/3be28720ff108cca1480de609872d29283776643/src/Flowcode/MediaBundle/Controller/AdminMediaController.php#L131-L140
581
zerospam/sdk-framework
src/Request/Api/BaseRequest.php
BaseRequest.addArgument
public function addArgument(IArgument $arg): IRequest { if ($arg instanceof IMergeableArgument) { if (!isset($this->mergeableArguments[$arg->getKey()])) { $this->mergeableArguments[$arg->getKey()] = new ArgMerger($arg::glue()); } $this->mergeableArguments[$arg->getKey()]->addArgument($arg); return $this; } if ($arg instanceof IStackableArgument) { if (!isset($this->stackableArguments[$arg->getKey()])) { $this->stackableArguments[$arg->getKey()] = new ArgCollector(); } $this->stackableArguments[$arg->getKey()]->addArgument($arg); return $this; } $this->arguments[$arg->getKey()] = $arg; return $this; }
php
public function addArgument(IArgument $arg): IRequest { if ($arg instanceof IMergeableArgument) { if (!isset($this->mergeableArguments[$arg->getKey()])) { $this->mergeableArguments[$arg->getKey()] = new ArgMerger($arg::glue()); } $this->mergeableArguments[$arg->getKey()]->addArgument($arg); return $this; } if ($arg instanceof IStackableArgument) { if (!isset($this->stackableArguments[$arg->getKey()])) { $this->stackableArguments[$arg->getKey()] = new ArgCollector(); } $this->stackableArguments[$arg->getKey()]->addArgument($arg); return $this; } $this->arguments[$arg->getKey()] = $arg; return $this; }
[ "public", "function", "addArgument", "(", "IArgument", "$", "arg", ")", ":", "IRequest", "{", "if", "(", "$", "arg", "instanceof", "IMergeableArgument", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "mergeableArguments", "[", "$", "arg", "->", "getKey", "(", ")", "]", ")", ")", "{", "$", "this", "->", "mergeableArguments", "[", "$", "arg", "->", "getKey", "(", ")", "]", "=", "new", "ArgMerger", "(", "$", "arg", "::", "glue", "(", ")", ")", ";", "}", "$", "this", "->", "mergeableArguments", "[", "$", "arg", "->", "getKey", "(", ")", "]", "->", "addArgument", "(", "$", "arg", ")", ";", "return", "$", "this", ";", "}", "if", "(", "$", "arg", "instanceof", "IStackableArgument", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "stackableArguments", "[", "$", "arg", "->", "getKey", "(", ")", "]", ")", ")", "{", "$", "this", "->", "stackableArguments", "[", "$", "arg", "->", "getKey", "(", ")", "]", "=", "new", "ArgCollector", "(", ")", ";", "}", "$", "this", "->", "stackableArguments", "[", "$", "arg", "->", "getKey", "(", ")", "]", "->", "addArgument", "(", "$", "arg", ")", ";", "return", "$", "this", ";", "}", "$", "this", "->", "arguments", "[", "$", "arg", "->", "getKey", "(", ")", "]", "=", "$", "arg", ";", "return", "$", "this", ";", "}" ]
Add a request argument. @param IArgument $arg @return $this
[ "Add", "a", "request", "argument", "." ]
6780b81584619cb177d5d5e14fd7e87a9d8e48fd
https://github.com/zerospam/sdk-framework/blob/6780b81584619cb177d5d5e14fd7e87a9d8e48fd/src/Request/Api/BaseRequest.php#L65-L90
582
zerospam/sdk-framework
src/Request/Api/BaseRequest.php
BaseRequest.removeArgument
public function removeArgument(IArgument $arg): IRequest { if ($arg instanceof IMergeableArgument) { if (!isset($this->mergeableArguments[$arg->getKey()])) { throw new \InvalidArgumentException("This argument doesn't exists"); } $this->mergeableArguments[$arg->getKey()]->removeArgument($arg); if ($this->mergeableArguments[$arg->getKey()]->isEmpty()) { unset($this->mergeableArguments[$arg->getKey()]); } } elseif ($arg instanceof IStackableArgument) { if (!isset($this->stackableArguments[$arg->getKey()])) { throw new \InvalidArgumentException("This argument doesn't exists"); } $this->stackableArguments[$arg->getKey()]->removeArgument($arg); if ($this->stackableArguments[$arg->getKey()]->isEmpty()) { unset($this->stackableArguments[$arg->getKey()]); } } else { unset($this->arguments[$arg->getKey()]); } return $this; }
php
public function removeArgument(IArgument $arg): IRequest { if ($arg instanceof IMergeableArgument) { if (!isset($this->mergeableArguments[$arg->getKey()])) { throw new \InvalidArgumentException("This argument doesn't exists"); } $this->mergeableArguments[$arg->getKey()]->removeArgument($arg); if ($this->mergeableArguments[$arg->getKey()]->isEmpty()) { unset($this->mergeableArguments[$arg->getKey()]); } } elseif ($arg instanceof IStackableArgument) { if (!isset($this->stackableArguments[$arg->getKey()])) { throw new \InvalidArgumentException("This argument doesn't exists"); } $this->stackableArguments[$arg->getKey()]->removeArgument($arg); if ($this->stackableArguments[$arg->getKey()]->isEmpty()) { unset($this->stackableArguments[$arg->getKey()]); } } else { unset($this->arguments[$arg->getKey()]); } return $this; }
[ "public", "function", "removeArgument", "(", "IArgument", "$", "arg", ")", ":", "IRequest", "{", "if", "(", "$", "arg", "instanceof", "IMergeableArgument", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "mergeableArguments", "[", "$", "arg", "->", "getKey", "(", ")", "]", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"This argument doesn't exists\"", ")", ";", "}", "$", "this", "->", "mergeableArguments", "[", "$", "arg", "->", "getKey", "(", ")", "]", "->", "removeArgument", "(", "$", "arg", ")", ";", "if", "(", "$", "this", "->", "mergeableArguments", "[", "$", "arg", "->", "getKey", "(", ")", "]", "->", "isEmpty", "(", ")", ")", "{", "unset", "(", "$", "this", "->", "mergeableArguments", "[", "$", "arg", "->", "getKey", "(", ")", "]", ")", ";", "}", "}", "elseif", "(", "$", "arg", "instanceof", "IStackableArgument", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "stackableArguments", "[", "$", "arg", "->", "getKey", "(", ")", "]", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"This argument doesn't exists\"", ")", ";", "}", "$", "this", "->", "stackableArguments", "[", "$", "arg", "->", "getKey", "(", ")", "]", "->", "removeArgument", "(", "$", "arg", ")", ";", "if", "(", "$", "this", "->", "stackableArguments", "[", "$", "arg", "->", "getKey", "(", ")", "]", "->", "isEmpty", "(", ")", ")", "{", "unset", "(", "$", "this", "->", "stackableArguments", "[", "$", "arg", "->", "getKey", "(", ")", "]", ")", ";", "}", "}", "else", "{", "unset", "(", "$", "this", "->", "arguments", "[", "$", "arg", "->", "getKey", "(", ")", "]", ")", ";", "}", "return", "$", "this", ";", "}" ]
Remove a request argument. @param IArgument $arg @return $this
[ "Remove", "a", "request", "argument", "." ]
6780b81584619cb177d5d5e14fd7e87a9d8e48fd
https://github.com/zerospam/sdk-framework/blob/6780b81584619cb177d5d5e14fd7e87a9d8e48fd/src/Request/Api/BaseRequest.php#L99-L124
583
zerospam/sdk-framework
src/Request/Api/BaseRequest.php
BaseRequest.requestOptions
public function requestOptions(): array { /** * Don't set any JSON if it's a get request */ if ($this->requestType()->is(RequestType::HTTP_GET())) { return []; } $options = [ RequestOptions::JSON => $this->toArray(), ]; return $options; }
php
public function requestOptions(): array { /** * Don't set any JSON if it's a get request */ if ($this->requestType()->is(RequestType::HTTP_GET())) { return []; } $options = [ RequestOptions::JSON => $this->toArray(), ]; return $options; }
[ "public", "function", "requestOptions", "(", ")", ":", "array", "{", "/**\n * Don't set any JSON if it's a get request\n */", "if", "(", "$", "this", "->", "requestType", "(", ")", "->", "is", "(", "RequestType", "::", "HTTP_GET", "(", ")", ")", ")", "{", "return", "[", "]", ";", "}", "$", "options", "=", "[", "RequestOptions", "::", "JSON", "=>", "$", "this", "->", "toArray", "(", ")", ",", "]", ";", "return", "$", "options", ";", "}" ]
Options for this request to be used by the client. @throws \ReflectionException @return array
[ "Options", "for", "this", "request", "to", "be", "used", "by", "the", "client", "." ]
6780b81584619cb177d5d5e14fd7e87a9d8e48fd
https://github.com/zerospam/sdk-framework/blob/6780b81584619cb177d5d5e14fd7e87a9d8e48fd/src/Request/Api/BaseRequest.php#L199-L212
584
zerospam/sdk-framework
src/Request/Api/BaseRequest.php
BaseRequest.generateUrl
private function generateUrl(): string { static $re = '/\%5B\d+\%5D/m'; static $subst = '%5B%5D'; $query = []; /** * @var IArgument */ foreach ($this->arguments as $key => $value) { $query[$key] = $value->toPrimitive(); } foreach ($this->mergeableArguments as $key => $value) { $query[$key] = $value->toPrimitive(); } foreach ($this->stackableArguments as $key => $value) { $query[$key] = $value->toArray(); } $queryArg = http_build_query($query, null, '&', PHP_QUERY_RFC3986); $fullUrl = $this->routeUrl() . '?' . preg_replace($re, $subst, $queryArg); return $fullUrl; }
php
private function generateUrl(): string { static $re = '/\%5B\d+\%5D/m'; static $subst = '%5B%5D'; $query = []; /** * @var IArgument */ foreach ($this->arguments as $key => $value) { $query[$key] = $value->toPrimitive(); } foreach ($this->mergeableArguments as $key => $value) { $query[$key] = $value->toPrimitive(); } foreach ($this->stackableArguments as $key => $value) { $query[$key] = $value->toArray(); } $queryArg = http_build_query($query, null, '&', PHP_QUERY_RFC3986); $fullUrl = $this->routeUrl() . '?' . preg_replace($re, $subst, $queryArg); return $fullUrl; }
[ "private", "function", "generateUrl", "(", ")", ":", "string", "{", "static", "$", "re", "=", "'/\\%5B\\d+\\%5D/m'", ";", "static", "$", "subst", "=", "'%5B%5D'", ";", "$", "query", "=", "[", "]", ";", "/**\n * @var IArgument\n */", "foreach", "(", "$", "this", "->", "arguments", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "query", "[", "$", "key", "]", "=", "$", "value", "->", "toPrimitive", "(", ")", ";", "}", "foreach", "(", "$", "this", "->", "mergeableArguments", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "query", "[", "$", "key", "]", "=", "$", "value", "->", "toPrimitive", "(", ")", ";", "}", "foreach", "(", "$", "this", "->", "stackableArguments", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "query", "[", "$", "key", "]", "=", "$", "value", "->", "toArray", "(", ")", ";", "}", "$", "queryArg", "=", "http_build_query", "(", "$", "query", ",", "null", ",", "'&'", ",", "PHP_QUERY_RFC3986", ")", ";", "$", "fullUrl", "=", "$", "this", "->", "routeUrl", "(", ")", ".", "'?'", ".", "preg_replace", "(", "$", "re", ",", "$", "subst", ",", "$", "queryArg", ")", ";", "return", "$", "fullUrl", ";", "}" ]
Generate the URL Takes care of removing the "include[0]" and replace by "include[]" @return string
[ "Generate", "the", "URL" ]
6780b81584619cb177d5d5e14fd7e87a9d8e48fd
https://github.com/zerospam/sdk-framework/blob/6780b81584619cb177d5d5e14fd7e87a9d8e48fd/src/Request/Api/BaseRequest.php#L267-L293
585
rybakdigital/fapi
Component/HttpKernel/Kernel.php
Kernel.handle
public function handle(Request $request) { try { $this->loadConfiguration(); // Now that Configuration is loaded let's resolve controller // for given request. $calls = $this->resolveController($request); $controller = $calls['controller']; $callable = $calls['callable']; // Resolve arguments before calling controller $res = $controller->$callable(); // Check if controller returned Response // and if so let's use it as our response if (is_a($res, 'Symfony\Component\HttpFoundation\Response')) { $this->response = $res; } } catch (\Exception $e) { $error = new \StdClass; $error->message = $e->getMessage(); $error->code = $e->getCode(); $this->response->setStatusCode($e->getCode()); $this->response->setContent(json_encode($error)); $this->response->headers->set('Content-Type', 'application/json'); } // Send response if ($request->getRequestFormat() == 'json') { $this->response->headers->set('Content-Type', 'application/json'); } $this->response->send(); }
php
public function handle(Request $request) { try { $this->loadConfiguration(); // Now that Configuration is loaded let's resolve controller // for given request. $calls = $this->resolveController($request); $controller = $calls['controller']; $callable = $calls['callable']; // Resolve arguments before calling controller $res = $controller->$callable(); // Check if controller returned Response // and if so let's use it as our response if (is_a($res, 'Symfony\Component\HttpFoundation\Response')) { $this->response = $res; } } catch (\Exception $e) { $error = new \StdClass; $error->message = $e->getMessage(); $error->code = $e->getCode(); $this->response->setStatusCode($e->getCode()); $this->response->setContent(json_encode($error)); $this->response->headers->set('Content-Type', 'application/json'); } // Send response if ($request->getRequestFormat() == 'json') { $this->response->headers->set('Content-Type', 'application/json'); } $this->response->send(); }
[ "public", "function", "handle", "(", "Request", "$", "request", ")", "{", "try", "{", "$", "this", "->", "loadConfiguration", "(", ")", ";", "// Now that Configuration is loaded let's resolve controller", "// for given request.", "$", "calls", "=", "$", "this", "->", "resolveController", "(", "$", "request", ")", ";", "$", "controller", "=", "$", "calls", "[", "'controller'", "]", ";", "$", "callable", "=", "$", "calls", "[", "'callable'", "]", ";", "// Resolve arguments before calling controller", "$", "res", "=", "$", "controller", "->", "$", "callable", "(", ")", ";", "// Check if controller returned Response", "// and if so let's use it as our response", "if", "(", "is_a", "(", "$", "res", ",", "'Symfony\\Component\\HttpFoundation\\Response'", ")", ")", "{", "$", "this", "->", "response", "=", "$", "res", ";", "}", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "error", "=", "new", "\\", "StdClass", ";", "$", "error", "->", "message", "=", "$", "e", "->", "getMessage", "(", ")", ";", "$", "error", "->", "code", "=", "$", "e", "->", "getCode", "(", ")", ";", "$", "this", "->", "response", "->", "setStatusCode", "(", "$", "e", "->", "getCode", "(", ")", ")", ";", "$", "this", "->", "response", "->", "setContent", "(", "json_encode", "(", "$", "error", ")", ")", ";", "$", "this", "->", "response", "->", "headers", "->", "set", "(", "'Content-Type'", ",", "'application/json'", ")", ";", "}", "// Send response", "if", "(", "$", "request", "->", "getRequestFormat", "(", ")", "==", "'json'", ")", "{", "$", "this", "->", "response", "->", "headers", "->", "set", "(", "'Content-Type'", ",", "'application/json'", ")", ";", "}", "$", "this", "->", "response", "->", "send", "(", ")", ";", "}" ]
Handles request. @param Request $request
[ "Handles", "request", "." ]
739dfa0fc0b17ab8e8ac8f8e86484f7e62b21027
https://github.com/rybakdigital/fapi/blob/739dfa0fc0b17ab8e8ac8f8e86484f7e62b21027/Component/HttpKernel/Kernel.php#L53-L89
586
rybakdigital/fapi
Component/HttpKernel/Kernel.php
Kernel.loadConfig
public function loadConfig($fileName) { // Check if the given file exists if (file_exists($fileName)) { $file = file_get_contents($fileName); } else { // So the file can not be located // Check in config folder if (file_exists($this->getRootDir() . '/config/' . $fileName)) { $file = file_get_contents($this->getRootDir() . '/config/' . $fileName); } else { throw new \InvalidArgumentException(sprintf('The file "%s" does not exist.', $fileName)); } } $array = Yaml::parse($file); // make sure we dealing with array first if (is_array($array)) { // Discover configuration foreach ($array as $key => $params) { // Import Resources if ($key == 'imports') { foreach ($params as $resource) { foreach ($resource as $key => $resourceName) { if ($key == 'resource') { $this->loadConfig($resourceName); } } } // Direct parameters input } elseif ($key == 'parameters') { foreach ($params as $paramName => $param) { $this->config->setParameter($paramName, $param); } // Save parameters in the Config } else { $this->config->setParameter($key, $params); } } } return $this->config; }
php
public function loadConfig($fileName) { // Check if the given file exists if (file_exists($fileName)) { $file = file_get_contents($fileName); } else { // So the file can not be located // Check in config folder if (file_exists($this->getRootDir() . '/config/' . $fileName)) { $file = file_get_contents($this->getRootDir() . '/config/' . $fileName); } else { throw new \InvalidArgumentException(sprintf('The file "%s" does not exist.', $fileName)); } } $array = Yaml::parse($file); // make sure we dealing with array first if (is_array($array)) { // Discover configuration foreach ($array as $key => $params) { // Import Resources if ($key == 'imports') { foreach ($params as $resource) { foreach ($resource as $key => $resourceName) { if ($key == 'resource') { $this->loadConfig($resourceName); } } } // Direct parameters input } elseif ($key == 'parameters') { foreach ($params as $paramName => $param) { $this->config->setParameter($paramName, $param); } // Save parameters in the Config } else { $this->config->setParameter($key, $params); } } } return $this->config; }
[ "public", "function", "loadConfig", "(", "$", "fileName", ")", "{", "// Check if the given file exists", "if", "(", "file_exists", "(", "$", "fileName", ")", ")", "{", "$", "file", "=", "file_get_contents", "(", "$", "fileName", ")", ";", "}", "else", "{", "// So the file can not be located", "// Check in config folder", "if", "(", "file_exists", "(", "$", "this", "->", "getRootDir", "(", ")", ".", "'/config/'", ".", "$", "fileName", ")", ")", "{", "$", "file", "=", "file_get_contents", "(", "$", "this", "->", "getRootDir", "(", ")", ".", "'/config/'", ".", "$", "fileName", ")", ";", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'The file \"%s\" does not exist.'", ",", "$", "fileName", ")", ")", ";", "}", "}", "$", "array", "=", "Yaml", "::", "parse", "(", "$", "file", ")", ";", "// make sure we dealing with array first", "if", "(", "is_array", "(", "$", "array", ")", ")", "{", "// Discover configuration", "foreach", "(", "$", "array", "as", "$", "key", "=>", "$", "params", ")", "{", "// Import Resources", "if", "(", "$", "key", "==", "'imports'", ")", "{", "foreach", "(", "$", "params", "as", "$", "resource", ")", "{", "foreach", "(", "$", "resource", "as", "$", "key", "=>", "$", "resourceName", ")", "{", "if", "(", "$", "key", "==", "'resource'", ")", "{", "$", "this", "->", "loadConfig", "(", "$", "resourceName", ")", ";", "}", "}", "}", "// Direct parameters input", "}", "elseif", "(", "$", "key", "==", "'parameters'", ")", "{", "foreach", "(", "$", "params", "as", "$", "paramName", "=>", "$", "param", ")", "{", "$", "this", "->", "config", "->", "setParameter", "(", "$", "paramName", ",", "$", "param", ")", ";", "}", "// Save parameters in the Config", "}", "else", "{", "$", "this", "->", "config", "->", "setParameter", "(", "$", "key", ",", "$", "params", ")", ";", "}", "}", "}", "return", "$", "this", "->", "config", ";", "}" ]
Loads app Configuration. @return ConfigInterface
[ "Loads", "app", "Configuration", "." ]
739dfa0fc0b17ab8e8ac8f8e86484f7e62b21027
https://github.com/rybakdigital/fapi/blob/739dfa0fc0b17ab8e8ac8f8e86484f7e62b21027/Component/HttpKernel/Kernel.php#L131-L174
587
rybakdigital/fapi
Component/HttpKernel/Kernel.php
Kernel.resolveController
public function resolveController(Request $request) { // First let's get routing and ask routing to resolve route $route = $this ->getRouting($request) ->resolveRoute(); // Get Controller class name $controllerClass = $route->getController(); // Get Callable name $callable = $route->getCalls(); // Check class and method are not empty if (!empty($controllerClass)) { // Check class exist if (!class_exists($controllerClass)) { throw new \Exception("Class ".$controllerClass." not found."); } // Check method exists if (!method_exists($controllerClass, $callable)) { throw new \Exception("Method ".$callable." not found in class " . $controllerClass); } return array( 'controller' => new $controllerClass($this->getConfig(), $request), 'callable' => $callable ); } }
php
public function resolveController(Request $request) { // First let's get routing and ask routing to resolve route $route = $this ->getRouting($request) ->resolveRoute(); // Get Controller class name $controllerClass = $route->getController(); // Get Callable name $callable = $route->getCalls(); // Check class and method are not empty if (!empty($controllerClass)) { // Check class exist if (!class_exists($controllerClass)) { throw new \Exception("Class ".$controllerClass." not found."); } // Check method exists if (!method_exists($controllerClass, $callable)) { throw new \Exception("Method ".$callable." not found in class " . $controllerClass); } return array( 'controller' => new $controllerClass($this->getConfig(), $request), 'callable' => $callable ); } }
[ "public", "function", "resolveController", "(", "Request", "$", "request", ")", "{", "// First let's get routing and ask routing to resolve route", "$", "route", "=", "$", "this", "->", "getRouting", "(", "$", "request", ")", "->", "resolveRoute", "(", ")", ";", "// Get Controller class name", "$", "controllerClass", "=", "$", "route", "->", "getController", "(", ")", ";", "// Get Callable name", "$", "callable", "=", "$", "route", "->", "getCalls", "(", ")", ";", "// Check class and method are not empty", "if", "(", "!", "empty", "(", "$", "controllerClass", ")", ")", "{", "// Check class exist", "if", "(", "!", "class_exists", "(", "$", "controllerClass", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "\"Class \"", ".", "$", "controllerClass", ".", "\" not found.\"", ")", ";", "}", "// Check method exists", "if", "(", "!", "method_exists", "(", "$", "controllerClass", ",", "$", "callable", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "\"Method \"", ".", "$", "callable", ".", "\" not found in class \"", ".", "$", "controllerClass", ")", ";", "}", "return", "array", "(", "'controller'", "=>", "new", "$", "controllerClass", "(", "$", "this", "->", "getConfig", "(", ")", ",", "$", "request", ")", ",", "'callable'", "=>", "$", "callable", ")", ";", "}", "}" ]
Resolves controller for a given request. @param Request $request @return array array(ControllerInterface, callable)
[ "Resolves", "controller", "for", "a", "given", "request", "." ]
739dfa0fc0b17ab8e8ac8f8e86484f7e62b21027
https://github.com/rybakdigital/fapi/blob/739dfa0fc0b17ab8e8ac8f8e86484f7e62b21027/Component/HttpKernel/Kernel.php#L182-L212
588
rybakdigital/fapi
Component/HttpKernel/Kernel.php
Kernel.getRouting
public function getRouting(Request $request) { // Check if router class has been defined in config parameters if ($this->getConfig()->hasParameter('routing')) { $routerClass = $this->getConfig()->getParameter('routing'); $router = new $routerClass(); return $router; } $router = new Router($request); return $router; }
php
public function getRouting(Request $request) { // Check if router class has been defined in config parameters if ($this->getConfig()->hasParameter('routing')) { $routerClass = $this->getConfig()->getParameter('routing'); $router = new $routerClass(); return $router; } $router = new Router($request); return $router; }
[ "public", "function", "getRouting", "(", "Request", "$", "request", ")", "{", "// Check if router class has been defined in config parameters", "if", "(", "$", "this", "->", "getConfig", "(", ")", "->", "hasParameter", "(", "'routing'", ")", ")", "{", "$", "routerClass", "=", "$", "this", "->", "getConfig", "(", ")", "->", "getParameter", "(", "'routing'", ")", ";", "$", "router", "=", "new", "$", "routerClass", "(", ")", ";", "return", "$", "router", ";", "}", "$", "router", "=", "new", "Router", "(", "$", "request", ")", ";", "return", "$", "router", ";", "}" ]
Gets routing system. @return RouterInterface
[ "Gets", "routing", "system", "." ]
739dfa0fc0b17ab8e8ac8f8e86484f7e62b21027
https://github.com/rybakdigital/fapi/blob/739dfa0fc0b17ab8e8ac8f8e86484f7e62b21027/Component/HttpKernel/Kernel.php#L219-L233
589
eix/core
src/php/main/Eix/Core/Requests/Http.php
Http.parsePath
private function parsePath() { $components = array(); $uri = $this->getUri(); if ($uri !== false) { Logger::get()->debug('Parsing URI: ' . $uri); // Add the URL parameters. $components = $this->getHttpParameters(); $matched = false; foreach (self::getRoutes() as $route) { if (preg_match("#^{$route['uri']}$#", $uri, $matches)) { Logger::get()->debug('Found a matching route: ' . $route['uri']); foreach ($route as $name => $value) { switch ($name) { case 'uri': // Ignore. break; default: if (is_numeric($value)) { // If the value is a number, it refers to a // regex block in the route. if (isset($matches[$value])) { $components[$name] = $matches[$value]; } } else { // Otherwise it's the parameter's value. $components[$name] = $value; } break; } } $matched = true; break; } } // If no matching routes have been found, the request is not // considered valid. if (!$matched) { throw new Exception("No routes match URI '{$uri}'.", 404); } } return $components; }
php
private function parsePath() { $components = array(); $uri = $this->getUri(); if ($uri !== false) { Logger::get()->debug('Parsing URI: ' . $uri); // Add the URL parameters. $components = $this->getHttpParameters(); $matched = false; foreach (self::getRoutes() as $route) { if (preg_match("#^{$route['uri']}$#", $uri, $matches)) { Logger::get()->debug('Found a matching route: ' . $route['uri']); foreach ($route as $name => $value) { switch ($name) { case 'uri': // Ignore. break; default: if (is_numeric($value)) { // If the value is a number, it refers to a // regex block in the route. if (isset($matches[$value])) { $components[$name] = $matches[$value]; } } else { // Otherwise it's the parameter's value. $components[$name] = $value; } break; } } $matched = true; break; } } // If no matching routes have been found, the request is not // considered valid. if (!$matched) { throw new Exception("No routes match URI '{$uri}'.", 404); } } return $components; }
[ "private", "function", "parsePath", "(", ")", "{", "$", "components", "=", "array", "(", ")", ";", "$", "uri", "=", "$", "this", "->", "getUri", "(", ")", ";", "if", "(", "$", "uri", "!==", "false", ")", "{", "Logger", "::", "get", "(", ")", "->", "debug", "(", "'Parsing URI: '", ".", "$", "uri", ")", ";", "// Add the URL parameters.", "$", "components", "=", "$", "this", "->", "getHttpParameters", "(", ")", ";", "$", "matched", "=", "false", ";", "foreach", "(", "self", "::", "getRoutes", "(", ")", "as", "$", "route", ")", "{", "if", "(", "preg_match", "(", "\"#^{$route['uri']}$#\"", ",", "$", "uri", ",", "$", "matches", ")", ")", "{", "Logger", "::", "get", "(", ")", "->", "debug", "(", "'Found a matching route: '", ".", "$", "route", "[", "'uri'", "]", ")", ";", "foreach", "(", "$", "route", "as", "$", "name", "=>", "$", "value", ")", "{", "switch", "(", "$", "name", ")", "{", "case", "'uri'", ":", "// Ignore.", "break", ";", "default", ":", "if", "(", "is_numeric", "(", "$", "value", ")", ")", "{", "// If the value is a number, it refers to a", "// regex block in the route.", "if", "(", "isset", "(", "$", "matches", "[", "$", "value", "]", ")", ")", "{", "$", "components", "[", "$", "name", "]", "=", "$", "matches", "[", "$", "value", "]", ";", "}", "}", "else", "{", "// Otherwise it's the parameter's value.", "$", "components", "[", "$", "name", "]", "=", "$", "value", ";", "}", "break", ";", "}", "}", "$", "matched", "=", "true", ";", "break", ";", "}", "}", "// If no matching routes have been found, the request is not", "// considered valid.", "if", "(", "!", "$", "matched", ")", "{", "throw", "new", "Exception", "(", "\"No routes match URI '{$uri}'.\"", ",", "404", ")", ";", "}", "}", "return", "$", "components", ";", "}" ]
Extracts the responder, action and parameter from an HTTP request.
[ "Extracts", "the", "responder", "action", "and", "parameter", "from", "an", "HTTP", "request", "." ]
a5b4c09cc168221e85804fdfeb78e519a0415466
https://github.com/eix/core/blob/a5b4c09cc168221e85804fdfeb78e519a0415466/src/php/main/Eix/Core/Requests/Http.php#L38-L85
590
eix/core
src/php/main/Eix/Core/Requests/Http.php
Http.getAcceptedContentTypes
public function getAcceptedContentTypes() { if (empty($this->acceptedContentTypes)) { // Values will be stored in this array $this->acceptedContentTypes = array(); // Accept header is case insensitive, and whitespace isn鈥檛 important. $acceptHeader = strtolower(str_replace(' ', '', @$_SERVER['HTTP_ACCEPT'] ?: '*/*')); // Extract the content types from the header. $acceptHeaderItems = explode(',', $acceptHeader); foreach ($acceptHeaderItems as $contentType) { // The default quality is 1. $quality = 1; // Check whether a quality is specified. if (strpos($contentType, ';q=')) { list($contentType, $quality) = explode(';q=', $contentType); } $this->acceptedContentTypes[$contentType] = $quality; } // Sort the content types by relevance. arsort($this->acceptedContentTypes); } return $this->acceptedContentTypes; }
php
public function getAcceptedContentTypes() { if (empty($this->acceptedContentTypes)) { // Values will be stored in this array $this->acceptedContentTypes = array(); // Accept header is case insensitive, and whitespace isn鈥檛 important. $acceptHeader = strtolower(str_replace(' ', '', @$_SERVER['HTTP_ACCEPT'] ?: '*/*')); // Extract the content types from the header. $acceptHeaderItems = explode(',', $acceptHeader); foreach ($acceptHeaderItems as $contentType) { // The default quality is 1. $quality = 1; // Check whether a quality is specified. if (strpos($contentType, ';q=')) { list($contentType, $quality) = explode(';q=', $contentType); } $this->acceptedContentTypes[$contentType] = $quality; } // Sort the content types by relevance. arsort($this->acceptedContentTypes); } return $this->acceptedContentTypes; }
[ "public", "function", "getAcceptedContentTypes", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "acceptedContentTypes", ")", ")", "{", "// Values will be stored in this array", "$", "this", "->", "acceptedContentTypes", "=", "array", "(", ")", ";", "// Accept header is case insensitive, and whitespace isn鈥檛 important.", "$", "acceptHeader", "=", "strtolower", "(", "str_replace", "(", "' '", ",", "''", ",", "@", "$", "_SERVER", "[", "'HTTP_ACCEPT'", "]", "?", ":", "'*/*'", ")", ")", ";", "// Extract the content types from the header.", "$", "acceptHeaderItems", "=", "explode", "(", "','", ",", "$", "acceptHeader", ")", ";", "foreach", "(", "$", "acceptHeaderItems", "as", "$", "contentType", ")", "{", "// The default quality is 1.", "$", "quality", "=", "1", ";", "// Check whether a quality is specified.", "if", "(", "strpos", "(", "$", "contentType", ",", "';q='", ")", ")", "{", "list", "(", "$", "contentType", ",", "$", "quality", ")", "=", "explode", "(", "';q='", ",", "$", "contentType", ")", ";", "}", "$", "this", "->", "acceptedContentTypes", "[", "$", "contentType", "]", "=", "$", "quality", ";", "}", "// Sort the content types by relevance.", "arsort", "(", "$", "this", "->", "acceptedContentTypes", ")", ";", "}", "return", "$", "this", "->", "acceptedContentTypes", ";", "}" ]
Reads the Accepted header in the request, and returns a list of content types sorted by preference.
[ "Reads", "the", "Accepted", "header", "in", "the", "request", "and", "returns", "a", "list", "of", "content", "types", "sorted", "by", "preference", "." ]
a5b4c09cc168221e85804fdfeb78e519a0415466
https://github.com/eix/core/blob/a5b4c09cc168221e85804fdfeb78e519a0415466/src/php/main/Eix/Core/Requests/Http.php#L91-L116
591
eix/core
src/php/main/Eix/Core/Requests/Http.php
Http.getLocale
public function getLocale() { // Use the intl extension if present. if (class_exists('\Locale')) { $locale = \Locale::acceptFromHttp(@$_SERVER['HTTP_ACCEPT_LANGUAGE']); } // If no locale was obtained, resort to the default one. if (empty($locale)) { $locale = Application::getSettings()->locale->default; } return $locale; }
php
public function getLocale() { // Use the intl extension if present. if (class_exists('\Locale')) { $locale = \Locale::acceptFromHttp(@$_SERVER['HTTP_ACCEPT_LANGUAGE']); } // If no locale was obtained, resort to the default one. if (empty($locale)) { $locale = Application::getSettings()->locale->default; } return $locale; }
[ "public", "function", "getLocale", "(", ")", "{", "// Use the intl extension if present.", "if", "(", "class_exists", "(", "'\\Locale'", ")", ")", "{", "$", "locale", "=", "\\", "Locale", "::", "acceptFromHttp", "(", "@", "$", "_SERVER", "[", "'HTTP_ACCEPT_LANGUAGE'", "]", ")", ";", "}", "// If no locale was obtained, resort to the default one.", "if", "(", "empty", "(", "$", "locale", ")", ")", "{", "$", "locale", "=", "Application", "::", "getSettings", "(", ")", "->", "locale", "->", "default", ";", "}", "return", "$", "locale", ";", "}" ]
Finds out which locale the request would want for the response.
[ "Finds", "out", "which", "locale", "the", "request", "would", "want", "for", "the", "response", "." ]
a5b4c09cc168221e85804fdfeb78e519a0415466
https://github.com/eix/core/blob/a5b4c09cc168221e85804fdfeb78e519a0415466/src/php/main/Eix/Core/Requests/Http.php#L121-L134
592
eix/core
src/php/main/Eix/Core/Requests/Http.php
Http.getParameters
public function getParameters() { // If the parameters property is null, it still hasn't been set. Parse // the path components first. if (is_null($this->parameters)) { $this->parameters = $this->parsePath(); } return $this->parameters; }
php
public function getParameters() { // If the parameters property is null, it still hasn't been set. Parse // the path components first. if (is_null($this->parameters)) { $this->parameters = $this->parsePath(); } return $this->parameters; }
[ "public", "function", "getParameters", "(", ")", "{", "// If the parameters property is null, it still hasn't been set. Parse", "// the path components first.", "if", "(", "is_null", "(", "$", "this", "->", "parameters", ")", ")", "{", "$", "this", "->", "parameters", "=", "$", "this", "->", "parsePath", "(", ")", ";", "}", "return", "$", "this", "->", "parameters", ";", "}" ]
Returns an array with all the request's parameters.
[ "Returns", "an", "array", "with", "all", "the", "request", "s", "parameters", "." ]
a5b4c09cc168221e85804fdfeb78e519a0415466
https://github.com/eix/core/blob/a5b4c09cc168221e85804fdfeb78e519a0415466/src/php/main/Eix/Core/Requests/Http.php#L139-L148
593
eix/core
src/php/main/Eix/Core/Requests/Http.php
Http.getUri
private function getUri() { if (empty($this->uri) && ($this->uri !== false)) { $this->uri = $_SERVER['REQUEST_URI']; // Remove the parameters from the URI. $paramsStart = strpos($this->uri, '?'); if ($paramsStart !== false) { $this->uri = substr($this->uri, 0, $paramsStart); } } return $this->uri; }
php
private function getUri() { if (empty($this->uri) && ($this->uri !== false)) { $this->uri = $_SERVER['REQUEST_URI']; // Remove the parameters from the URI. $paramsStart = strpos($this->uri, '?'); if ($paramsStart !== false) { $this->uri = substr($this->uri, 0, $paramsStart); } } return $this->uri; }
[ "private", "function", "getUri", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "uri", ")", "&&", "(", "$", "this", "->", "uri", "!==", "false", ")", ")", "{", "$", "this", "->", "uri", "=", "$", "_SERVER", "[", "'REQUEST_URI'", "]", ";", "// Remove the parameters from the URI.", "$", "paramsStart", "=", "strpos", "(", "$", "this", "->", "uri", ",", "'?'", ")", ";", "if", "(", "$", "paramsStart", "!==", "false", ")", "{", "$", "this", "->", "uri", "=", "substr", "(", "$", "this", "->", "uri", ",", "0", ",", "$", "paramsStart", ")", ";", "}", "}", "return", "$", "this", "->", "uri", ";", "}" ]
Returns the current request's URI, finding it out if needed. @return string
[ "Returns", "the", "current", "request", "s", "URI", "finding", "it", "out", "if", "needed", "." ]
a5b4c09cc168221e85804fdfeb78e519a0415466
https://github.com/eix/core/blob/a5b4c09cc168221e85804fdfeb78e519a0415466/src/php/main/Eix/Core/Requests/Http.php#L198-L211
594
eix/core
src/php/main/Eix/Core/Requests/Http.php
Http.getHttpParameters
private function getHttpParameters() { if (empty($this->httpParameters)) { // Discover the parameters from the server data. $uri = $_SERVER['REQUEST_URI']; $paramsStart = strpos($uri, '?'); if ($paramsStart !== false) { // Separate the parameters in the URL. parse_str(substr($uri, $paramsStart + 1), $this->httpParameters); } // Get POST parameters as well. $this->httpParameters = array_merge($this->httpParameters, $_POST); // Get files too. $this->httpParameters = array_merge($this->httpParameters, $_FILES); } return $this->httpParameters; }
php
private function getHttpParameters() { if (empty($this->httpParameters)) { // Discover the parameters from the server data. $uri = $_SERVER['REQUEST_URI']; $paramsStart = strpos($uri, '?'); if ($paramsStart !== false) { // Separate the parameters in the URL. parse_str(substr($uri, $paramsStart + 1), $this->httpParameters); } // Get POST parameters as well. $this->httpParameters = array_merge($this->httpParameters, $_POST); // Get files too. $this->httpParameters = array_merge($this->httpParameters, $_FILES); } return $this->httpParameters; }
[ "private", "function", "getHttpParameters", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "httpParameters", ")", ")", "{", "// Discover the parameters from the server data.", "$", "uri", "=", "$", "_SERVER", "[", "'REQUEST_URI'", "]", ";", "$", "paramsStart", "=", "strpos", "(", "$", "uri", ",", "'?'", ")", ";", "if", "(", "$", "paramsStart", "!==", "false", ")", "{", "// Separate the parameters in the URL.", "parse_str", "(", "substr", "(", "$", "uri", ",", "$", "paramsStart", "+", "1", ")", ",", "$", "this", "->", "httpParameters", ")", ";", "}", "// Get POST parameters as well.", "$", "this", "->", "httpParameters", "=", "array_merge", "(", "$", "this", "->", "httpParameters", ",", "$", "_POST", ")", ";", "// Get files too.", "$", "this", "->", "httpParameters", "=", "array_merge", "(", "$", "this", "->", "httpParameters", ",", "$", "_FILES", ")", ";", "}", "return", "$", "this", "->", "httpParameters", ";", "}" ]
Returns the parameters that came in the HTTP request. @return type
[ "Returns", "the", "parameters", "that", "came", "in", "the", "HTTP", "request", "." ]
a5b4c09cc168221e85804fdfeb78e519a0415466
https://github.com/eix/core/blob/a5b4c09cc168221e85804fdfeb78e519a0415466/src/php/main/Eix/Core/Requests/Http.php#L218-L237
595
eix/core
src/php/main/Eix/Core/Requests/Http.php
Http.getRoutes
public static function getRoutes() { if (empty(self::$routes)) { // If no routes have been set, try the standard file. if (is_readable(self::ROUTES_FILE_LOCATION)) { // Decode the JSON routes file into an array. self::$routes = json_decode( file_get_contents(self::ROUTES_FILE_LOCATION), true ); } // No valid routes have been found. if (empty(self::$routes)) { throw new Exception('No routes could be obtained. Please check the route configuration file.'); } } return self::$routes; }
php
public static function getRoutes() { if (empty(self::$routes)) { // If no routes have been set, try the standard file. if (is_readable(self::ROUTES_FILE_LOCATION)) { // Decode the JSON routes file into an array. self::$routes = json_decode( file_get_contents(self::ROUTES_FILE_LOCATION), true ); } // No valid routes have been found. if (empty(self::$routes)) { throw new Exception('No routes could be obtained. Please check the route configuration file.'); } } return self::$routes; }
[ "public", "static", "function", "getRoutes", "(", ")", "{", "if", "(", "empty", "(", "self", "::", "$", "routes", ")", ")", "{", "// If no routes have been set, try the standard file.", "if", "(", "is_readable", "(", "self", "::", "ROUTES_FILE_LOCATION", ")", ")", "{", "// Decode the JSON routes file into an array.", "self", "::", "$", "routes", "=", "json_decode", "(", "file_get_contents", "(", "self", "::", "ROUTES_FILE_LOCATION", ")", ",", "true", ")", ";", "}", "// No valid routes have been found.", "if", "(", "empty", "(", "self", "::", "$", "routes", ")", ")", "{", "throw", "new", "Exception", "(", "'No routes could be obtained. Please check the route configuration file.'", ")", ";", "}", "}", "return", "self", "::", "$", "routes", ";", "}" ]
Returns the URL-Responder map. @throws Exception if no usable routes source is available.
[ "Returns", "the", "URL", "-", "Responder", "map", "." ]
a5b4c09cc168221e85804fdfeb78e519a0415466
https://github.com/eix/core/blob/a5b4c09cc168221e85804fdfeb78e519a0415466/src/php/main/Eix/Core/Requests/Http.php#L244-L262
596
eix/core
src/php/main/Eix/Core/Requests/Http.php
Http.getContentTypeToken
public static function getContentTypeToken($contentType) { $token = null; switch ($contentType) { case 'text/html': $token = 'Html'; break; /* case 'application/xhtml+xml': $token = 'Xhtml'; break; */ case 'application/json': case 'text/json': $token = 'Json'; break; case 'application/xml': case 'text/xml': $token = 'Xml'; break; case 'image/png': case 'image/jpeg': case 'image/*': $token = 'Image'; break; case '*/*': $token = 'All'; break; default: throw new \InvalidArgumentException("Content type '{$contentType}' is not supported."); } return $token; }
php
public static function getContentTypeToken($contentType) { $token = null; switch ($contentType) { case 'text/html': $token = 'Html'; break; /* case 'application/xhtml+xml': $token = 'Xhtml'; break; */ case 'application/json': case 'text/json': $token = 'Json'; break; case 'application/xml': case 'text/xml': $token = 'Xml'; break; case 'image/png': case 'image/jpeg': case 'image/*': $token = 'Image'; break; case '*/*': $token = 'All'; break; default: throw new \InvalidArgumentException("Content type '{$contentType}' is not supported."); } return $token; }
[ "public", "static", "function", "getContentTypeToken", "(", "$", "contentType", ")", "{", "$", "token", "=", "null", ";", "switch", "(", "$", "contentType", ")", "{", "case", "'text/html'", ":", "$", "token", "=", "'Html'", ";", "break", ";", "/*\n case 'application/xhtml+xml':\n $token = 'Xhtml';\n break;\n */", "case", "'application/json'", ":", "case", "'text/json'", ":", "$", "token", "=", "'Json'", ";", "break", ";", "case", "'application/xml'", ":", "case", "'text/xml'", ":", "$", "token", "=", "'Xml'", ";", "break", ";", "case", "'image/png'", ":", "case", "'image/jpeg'", ":", "case", "'image/*'", ":", "$", "token", "=", "'Image'", ";", "break", ";", "case", "'*/*'", ":", "$", "token", "=", "'All'", ";", "break", ";", "default", ":", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Content type '{$contentType}' is not supported.\"", ")", ";", "}", "return", "$", "token", ";", "}" ]
Produces a token that uniquely identifies a content type and can be used as part of a method name. @param string $contentType the content type to get a token for. @param string $default a default content type
[ "Produces", "a", "token", "that", "uniquely", "identifies", "a", "content", "type", "and", "can", "be", "used", "as", "part", "of", "a", "method", "name", "." ]
a5b4c09cc168221e85804fdfeb78e519a0415466
https://github.com/eix/core/blob/a5b4c09cc168221e85804fdfeb78e519a0415466/src/php/main/Eix/Core/Requests/Http.php#L289-L322
597
pgraham/database
src/DatabaseConnection.php
DatabaseConnection.beginTransaction
public function beginTransaction() { if ($this->inTransaction) { return false; } $this->inTransaction = $this->pdo->beginTransaction(); return $this->inTransaction; }
php
public function beginTransaction() { if ($this->inTransaction) { return false; } $this->inTransaction = $this->pdo->beginTransaction(); return $this->inTransaction; }
[ "public", "function", "beginTransaction", "(", ")", "{", "if", "(", "$", "this", "->", "inTransaction", ")", "{", "return", "false", ";", "}", "$", "this", "->", "inTransaction", "=", "$", "this", "->", "pdo", "->", "beginTransaction", "(", ")", ";", "return", "$", "this", "->", "inTransaction", ";", "}" ]
Normalize to only a single transactions. In order to take advantange of drivers that support nested transactions access the underlying PDO object directly. @return boolean
[ "Normalize", "to", "only", "a", "single", "transactions", ".", "In", "order", "to", "take", "advantange", "of", "drivers", "that", "support", "nested", "transactions", "access", "the", "underlying", "PDO", "object", "directly", "." ]
b325425da23273536772d4fe62da4b669b78601b
https://github.com/pgraham/database/blob/b325425da23273536772d4fe62da4b669b78601b/src/DatabaseConnection.php#L106-L113
598
pgraham/database
src/DatabaseConnection.php
DatabaseConnection.connectTo
public function connectTo($schema) { $info = clone $this->getInfo(); $info->setSchema($schema); return new DatabaseConnection($info); }
php
public function connectTo($schema) { $info = clone $this->getInfo(); $info->setSchema($schema); return new DatabaseConnection($info); }
[ "public", "function", "connectTo", "(", "$", "schema", ")", "{", "$", "info", "=", "clone", "$", "this", "->", "getInfo", "(", ")", ";", "$", "info", "->", "setSchema", "(", "$", "schema", ")", ";", "return", "new", "DatabaseConnection", "(", "$", "info", ")", ";", "}" ]
Create a new database connection to the given schema using the same credentials and options as the current connection. The current connection is not closed. @param string $schema
[ "Create", "a", "new", "database", "connection", "to", "the", "given", "schema", "using", "the", "same", "credentials", "and", "options", "as", "the", "current", "connection", ".", "The", "current", "connection", "is", "not", "closed", "." ]
b325425da23273536772d4fe62da4b669b78601b
https://github.com/pgraham/database/blob/b325425da23273536772d4fe62da4b669b78601b/src/DatabaseConnection.php#L178-L182
599
pgraham/database
src/DatabaseConnection.php
DatabaseConnection.exec
public function exec($statement) { try { return $this->pdo->exec($statement); } catch (PDOException $e) { throw $this->exceptionAdapter->adapt($e, $statement); } }
php
public function exec($statement) { try { return $this->pdo->exec($statement); } catch (PDOException $e) { throw $this->exceptionAdapter->adapt($e, $statement); } }
[ "public", "function", "exec", "(", "$", "statement", ")", "{", "try", "{", "return", "$", "this", "->", "pdo", "->", "exec", "(", "$", "statement", ")", ";", "}", "catch", "(", "PDOException", "$", "e", ")", "{", "throw", "$", "this", "->", "exceptionAdapter", "->", "adapt", "(", "$", "e", ",", "$", "statement", ")", ";", "}", "}" ]
Executes the given SQL query and returns a QueryResult object containing the results of the query. @return StatementResult @throws zpt\db\exception\DatabaseException Wraps any encountered PDOExceptions.
[ "Executes", "the", "given", "SQL", "query", "and", "returns", "a", "QueryResult", "object", "containing", "the", "results", "of", "the", "query", "." ]
b325425da23273536772d4fe62da4b669b78601b
https://github.com/pgraham/database/blob/b325425da23273536772d4fe62da4b669b78601b/src/DatabaseConnection.php#L192-L198