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
2,600
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/session/driver.php
Session_Driver.rotate
public function rotate($force = true) { // do we have a session? if ( ! empty($this->keys)) { // existing session. need to rotate the session id? if ($force or ($this->config['rotation_time'] and $this->keys['created'] + $this->config['rotation_time'] <= $this->time->get_timestamp())) { // generate a new session id, and update the create timestamp $this->keys['previous_id'] = $this->keys['session_id']; $this->keys['session_id'] = $this->_new_session_id(); $this->keys['created'] = $this->time->get_timestamp(); $this->keys['updated'] = $this->keys['created']; } } return $this; }
php
public function rotate($force = true) { // do we have a session? if ( ! empty($this->keys)) { // existing session. need to rotate the session id? if ($force or ($this->config['rotation_time'] and $this->keys['created'] + $this->config['rotation_time'] <= $this->time->get_timestamp())) { // generate a new session id, and update the create timestamp $this->keys['previous_id'] = $this->keys['session_id']; $this->keys['session_id'] = $this->_new_session_id(); $this->keys['created'] = $this->time->get_timestamp(); $this->keys['updated'] = $this->keys['created']; } } return $this; }
[ "public", "function", "rotate", "(", "$", "force", "=", "true", ")", "{", "// do we have a session?", "if", "(", "!", "empty", "(", "$", "this", "->", "keys", ")", ")", "{", "// existing session. need to rotate the session id?", "if", "(", "$", "force", "or", "(", "$", "this", "->", "config", "[", "'rotation_time'", "]", "and", "$", "this", "->", "keys", "[", "'created'", "]", "+", "$", "this", "->", "config", "[", "'rotation_time'", "]", "<=", "$", "this", "->", "time", "->", "get_timestamp", "(", ")", ")", ")", "{", "// generate a new session id, and update the create timestamp", "$", "this", "->", "keys", "[", "'previous_id'", "]", "=", "$", "this", "->", "keys", "[", "'session_id'", "]", ";", "$", "this", "->", "keys", "[", "'session_id'", "]", "=", "$", "this", "->", "_new_session_id", "(", ")", ";", "$", "this", "->", "keys", "[", "'created'", "]", "=", "$", "this", "->", "time", "->", "get_timestamp", "(", ")", ";", "$", "this", "->", "keys", "[", "'updated'", "]", "=", "$", "this", "->", "keys", "[", "'created'", "]", ";", "}", "}", "return", "$", "this", ";", "}" ]
force a session_id rotation @access public @param boolean, if true, force a session id rotation @return Fuel\Core\Session_Driver
[ "force", "a", "session_id", "rotation" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/session/driver.php#L214-L231
2,601
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/session/driver.php
Session_Driver.set_flash
public function set_flash($name, $value) { if (strpos($name, '.') !== false) { $keys = explode('.', $name, 2); $name = array_shift($keys); } else { $keys = false; } if ($keys) { if (isset($this->flash[$this->config['flash_id'].'::'.$name]['value'])) { $this->flash[$this->config['flash_id'].'::'.$name]['state'] = 'new'; } else { $this->flash[$this->config['flash_id'].'::'.$name] = array('state' => 'new', 'value' => array()); } \Arr::set($this->flash[$this->config['flash_id'].'::'.$name]['value'], $keys[0], $value); } else { $this->flash[$this->config['flash_id'].'::'.$name] = array('state' => 'new', 'value' => $value); } return $this; }
php
public function set_flash($name, $value) { if (strpos($name, '.') !== false) { $keys = explode('.', $name, 2); $name = array_shift($keys); } else { $keys = false; } if ($keys) { if (isset($this->flash[$this->config['flash_id'].'::'.$name]['value'])) { $this->flash[$this->config['flash_id'].'::'.$name]['state'] = 'new'; } else { $this->flash[$this->config['flash_id'].'::'.$name] = array('state' => 'new', 'value' => array()); } \Arr::set($this->flash[$this->config['flash_id'].'::'.$name]['value'], $keys[0], $value); } else { $this->flash[$this->config['flash_id'].'::'.$name] = array('state' => 'new', 'value' => $value); } return $this; }
[ "public", "function", "set_flash", "(", "$", "name", ",", "$", "value", ")", "{", "if", "(", "strpos", "(", "$", "name", ",", "'.'", ")", "!==", "false", ")", "{", "$", "keys", "=", "explode", "(", "'.'", ",", "$", "name", ",", "2", ")", ";", "$", "name", "=", "array_shift", "(", "$", "keys", ")", ";", "}", "else", "{", "$", "keys", "=", "false", ";", "}", "if", "(", "$", "keys", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "flash", "[", "$", "this", "->", "config", "[", "'flash_id'", "]", ".", "'::'", ".", "$", "name", "]", "[", "'value'", "]", ")", ")", "{", "$", "this", "->", "flash", "[", "$", "this", "->", "config", "[", "'flash_id'", "]", ".", "'::'", ".", "$", "name", "]", "[", "'state'", "]", "=", "'new'", ";", "}", "else", "{", "$", "this", "->", "flash", "[", "$", "this", "->", "config", "[", "'flash_id'", "]", ".", "'::'", ".", "$", "name", "]", "=", "array", "(", "'state'", "=>", "'new'", ",", "'value'", "=>", "array", "(", ")", ")", ";", "}", "\\", "Arr", "::", "set", "(", "$", "this", "->", "flash", "[", "$", "this", "->", "config", "[", "'flash_id'", "]", ".", "'::'", ".", "$", "name", "]", "[", "'value'", "]", ",", "$", "keys", "[", "0", "]", ",", "$", "value", ")", ";", "}", "else", "{", "$", "this", "->", "flash", "[", "$", "this", "->", "config", "[", "'flash_id'", "]", ".", "'::'", ".", "$", "name", "]", "=", "array", "(", "'state'", "=>", "'new'", ",", "'value'", "=>", "$", "value", ")", ";", "}", "return", "$", "this", ";", "}" ]
set session flash variables @param string name of the variable to set @param mixed value @access public @return Fuel\Core\Session_Driver
[ "set", "session", "flash", "variables" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/session/driver.php#L243-L273
2,602
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/session/driver.php
Session_Driver.keep_flash
public function keep_flash($name) { if (is_null($name)) { foreach($this->flash as $key => $value) { $this->flash[$key]['state'] = 'new'; } } elseif (isset($this->flash[$this->config['flash_id'].'::'.$name])) { $this->flash[$this->config['flash_id'].'::'.$name]['state'] = 'new'; } return $this; }
php
public function keep_flash($name) { if (is_null($name)) { foreach($this->flash as $key => $value) { $this->flash[$key]['state'] = 'new'; } } elseif (isset($this->flash[$this->config['flash_id'].'::'.$name])) { $this->flash[$this->config['flash_id'].'::'.$name]['state'] = 'new'; } return $this; }
[ "public", "function", "keep_flash", "(", "$", "name", ")", "{", "if", "(", "is_null", "(", "$", "name", ")", ")", "{", "foreach", "(", "$", "this", "->", "flash", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "this", "->", "flash", "[", "$", "key", "]", "[", "'state'", "]", "=", "'new'", ";", "}", "}", "elseif", "(", "isset", "(", "$", "this", "->", "flash", "[", "$", "this", "->", "config", "[", "'flash_id'", "]", ".", "'::'", ".", "$", "name", "]", ")", ")", "{", "$", "this", "->", "flash", "[", "$", "this", "->", "config", "[", "'flash_id'", "]", ".", "'::'", ".", "$", "name", "]", "[", "'state'", "]", "=", "'new'", ";", "}", "return", "$", "this", ";", "}" ]
keep session flash variables @access public @param string name of the variable to keep @return Fuel\Core\Session_Driver
[ "keep", "session", "flash", "variables" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/session/driver.php#L344-L359
2,603
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/session/driver.php
Session_Driver.delete_flash
public function delete_flash($name) { if (is_null($name)) { $this->flash = array(); } elseif (isset($this->flash[$this->config['flash_id'].'::'.$name])) { unset($this->flash[$this->config['flash_id'].'::'.$name]); } return $this; }
php
public function delete_flash($name) { if (is_null($name)) { $this->flash = array(); } elseif (isset($this->flash[$this->config['flash_id'].'::'.$name])) { unset($this->flash[$this->config['flash_id'].'::'.$name]); } return $this; }
[ "public", "function", "delete_flash", "(", "$", "name", ")", "{", "if", "(", "is_null", "(", "$", "name", ")", ")", "{", "$", "this", "->", "flash", "=", "array", "(", ")", ";", "}", "elseif", "(", "isset", "(", "$", "this", "->", "flash", "[", "$", "this", "->", "config", "[", "'flash_id'", "]", ".", "'::'", ".", "$", "name", "]", ")", ")", "{", "unset", "(", "$", "this", "->", "flash", "[", "$", "this", "->", "config", "[", "'flash_id'", "]", ".", "'::'", ".", "$", "name", "]", ")", ";", "}", "return", "$", "this", ";", "}" ]
delete session flash variables @param string name of the variable to delete @param mixed value @access public @return Fuel\Core\Session_Driver
[ "delete", "session", "flash", "variables" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/session/driver.php#L371-L383
2,604
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/session/driver.php
Session_Driver.get_config
public function get_config($name) { return isset($this->config[$name]) ? $this->config[$name] : null; }
php
public function get_config($name) { return isset($this->config[$name]) ? $this->config[$name] : null; }
[ "public", "function", "get_config", "(", "$", "name", ")", "{", "return", "isset", "(", "$", "this", "->", "config", "[", "$", "name", "]", ")", "?", "$", "this", "->", "config", "[", "$", "name", "]", ":", "null", ";", "}" ]
get a runtime config value @param string name of the config variable to get @access public @return mixed
[ "get", "a", "runtime", "config", "value" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/session/driver.php#L423-L426
2,605
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/session/driver.php
Session_Driver.set_config
public function set_config($name, $value = null) { if (isset($this->config[$name])) $this->config[$name] = $value; return $this; }
php
public function set_config($name, $value = null) { if (isset($this->config[$name])) $this->config[$name] = $value; return $this; }
[ "public", "function", "set_config", "(", "$", "name", ",", "$", "value", "=", "null", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "config", "[", "$", "name", "]", ")", ")", "$", "this", "->", "config", "[", "$", "name", "]", "=", "$", "value", ";", "return", "$", "this", ";", "}" ]
set a runtime config value @param string name of the config variable to set @access public @return Fuel\Core\Session_Driver
[ "set", "a", "runtime", "config", "value" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/session/driver.php#L437-L442
2,606
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/session/driver.php
Session_Driver._cleanup_flash
protected function _cleanup_flash() { foreach($this->flash as $key => $value) { if ($value['state'] === 'expire') { unset($this->flash[$key]); } } }
php
protected function _cleanup_flash() { foreach($this->flash as $key => $value) { if ($value['state'] === 'expire') { unset($this->flash[$key]); } } }
[ "protected", "function", "_cleanup_flash", "(", ")", "{", "foreach", "(", "$", "this", "->", "flash", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "$", "value", "[", "'state'", "]", "===", "'expire'", ")", "{", "unset", "(", "$", "this", "->", "flash", "[", "$", "key", "]", ")", ";", "}", "}", "}" ]
removes flash variables marked as old @access private @return void
[ "removes", "flash", "variables", "marked", "as", "old" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/session/driver.php#L452-L461
2,607
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/session/driver.php
Session_Driver._new_session_id
protected function _new_session_id() { $session_id = ''; while (strlen($session_id) < 32) { $session_id .= mt_rand(0, mt_getrandmax()); } return md5(uniqid($session_id, TRUE)); }
php
protected function _new_session_id() { $session_id = ''; while (strlen($session_id) < 32) { $session_id .= mt_rand(0, mt_getrandmax()); } return md5(uniqid($session_id, TRUE)); }
[ "protected", "function", "_new_session_id", "(", ")", "{", "$", "session_id", "=", "''", ";", "while", "(", "strlen", "(", "$", "session_id", ")", "<", "32", ")", "{", "$", "session_id", ".=", "mt_rand", "(", "0", ",", "mt_getrandmax", "(", ")", ")", ";", "}", "return", "md5", "(", "uniqid", "(", "$", "session_id", ",", "TRUE", ")", ")", ";", "}" ]
generate a new session id @access private @return void
[ "generate", "a", "new", "session", "id" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/session/driver.php#L471-L479
2,608
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/session/driver.php
Session_Driver._set_cookie
protected function _set_cookie($payload = array()) { if ($this->config['enable_cookie']) { $payload = $this->_serialize($payload); // encrypt the payload if needed $this->config['encrypt_cookie'] and $payload = \Crypt::encode($payload); // make sure it doesn't exceed the cookie size specification if (strlen($payload) > 4000) { throw new \FuelException('The session data stored by the application in the cookie exceeds 4Kb. Select a different session storage driver.'); } // write the session cookie if ($this->config['expire_on_close']) { return \Cookie::set($this->config['cookie_name'], $payload, 0, $this->config['cookie_path'], $this->config['cookie_domain'], null, $this->config['cookie_http_only']); } else { return \Cookie::set($this->config['cookie_name'], $payload, $this->config['expiration_time'], $this->config['cookie_path'], $this->config['cookie_domain'], null, $this->config['cookie_http_only']); } } }
php
protected function _set_cookie($payload = array()) { if ($this->config['enable_cookie']) { $payload = $this->_serialize($payload); // encrypt the payload if needed $this->config['encrypt_cookie'] and $payload = \Crypt::encode($payload); // make sure it doesn't exceed the cookie size specification if (strlen($payload) > 4000) { throw new \FuelException('The session data stored by the application in the cookie exceeds 4Kb. Select a different session storage driver.'); } // write the session cookie if ($this->config['expire_on_close']) { return \Cookie::set($this->config['cookie_name'], $payload, 0, $this->config['cookie_path'], $this->config['cookie_domain'], null, $this->config['cookie_http_only']); } else { return \Cookie::set($this->config['cookie_name'], $payload, $this->config['expiration_time'], $this->config['cookie_path'], $this->config['cookie_domain'], null, $this->config['cookie_http_only']); } } }
[ "protected", "function", "_set_cookie", "(", "$", "payload", "=", "array", "(", ")", ")", "{", "if", "(", "$", "this", "->", "config", "[", "'enable_cookie'", "]", ")", "{", "$", "payload", "=", "$", "this", "->", "_serialize", "(", "$", "payload", ")", ";", "// encrypt the payload if needed", "$", "this", "->", "config", "[", "'encrypt_cookie'", "]", "and", "$", "payload", "=", "\\", "Crypt", "::", "encode", "(", "$", "payload", ")", ";", "// make sure it doesn't exceed the cookie size specification", "if", "(", "strlen", "(", "$", "payload", ")", ">", "4000", ")", "{", "throw", "new", "\\", "FuelException", "(", "'The session data stored by the application in the cookie exceeds 4Kb. Select a different session storage driver.'", ")", ";", "}", "// write the session cookie", "if", "(", "$", "this", "->", "config", "[", "'expire_on_close'", "]", ")", "{", "return", "\\", "Cookie", "::", "set", "(", "$", "this", "->", "config", "[", "'cookie_name'", "]", ",", "$", "payload", ",", "0", ",", "$", "this", "->", "config", "[", "'cookie_path'", "]", ",", "$", "this", "->", "config", "[", "'cookie_domain'", "]", ",", "null", ",", "$", "this", "->", "config", "[", "'cookie_http_only'", "]", ")", ";", "}", "else", "{", "return", "\\", "Cookie", "::", "set", "(", "$", "this", "->", "config", "[", "'cookie_name'", "]", ",", "$", "payload", ",", "$", "this", "->", "config", "[", "'expiration_time'", "]", ",", "$", "this", "->", "config", "[", "'cookie_path'", "]", ",", "$", "this", "->", "config", "[", "'cookie_domain'", "]", ",", "null", ",", "$", "this", "->", "config", "[", "'cookie_http_only'", "]", ")", ";", "}", "}", "}" ]
write a cookie @access private @param array, cookie payload @return void
[ "write", "a", "cookie" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/session/driver.php#L490-L515
2,609
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/session/driver.php
Session_Driver._get_cookie
protected function _get_cookie() { // was the cookie value posted? $cookie = \Input::post($this->config['post_cookie_name'], false); // if not found, fetch the regular cookie if ($cookie === false) { $cookie = \Cookie::get($this->config['cookie_name'], false); } // if not found, was a session-id present in the HTTP header? if ($cookie === false) { $cookie = \Input::headers($this->config['http_header_name'], false); } // if not found, check the URL for a cookie if ($cookie === false) { $cookie = \Input::get($this->config['cookie_name'], false); } if ($cookie !== false) { // fetch the payload $this->config['encrypt_cookie'] and $cookie = \Crypt::decode($cookie); $cookie = $this->_unserialize($cookie); // validate the cookie format: must be an array if (is_array($cookie)) { // cookies use nested arrays, other drivers have a string value if (($this->config['driver'] === 'cookie' and ! is_array($cookie[0])) or ($this->config['driver'] !== 'cookie' and ! is_string($cookie[0]))) { // invalid specific format logger('DEBUG', 'Error: Invalid session cookie specific format'); $cookie = false; } } // or a string containing the session id elseif (is_string($cookie) and strlen($cookie) == 32) { $cookie = array($cookie); } // invalid general format else { logger('DEBUG', 'Error: Invalid session cookie general format'); $cookie = false; } } // and the result return $cookie; }
php
protected function _get_cookie() { // was the cookie value posted? $cookie = \Input::post($this->config['post_cookie_name'], false); // if not found, fetch the regular cookie if ($cookie === false) { $cookie = \Cookie::get($this->config['cookie_name'], false); } // if not found, was a session-id present in the HTTP header? if ($cookie === false) { $cookie = \Input::headers($this->config['http_header_name'], false); } // if not found, check the URL for a cookie if ($cookie === false) { $cookie = \Input::get($this->config['cookie_name'], false); } if ($cookie !== false) { // fetch the payload $this->config['encrypt_cookie'] and $cookie = \Crypt::decode($cookie); $cookie = $this->_unserialize($cookie); // validate the cookie format: must be an array if (is_array($cookie)) { // cookies use nested arrays, other drivers have a string value if (($this->config['driver'] === 'cookie' and ! is_array($cookie[0])) or ($this->config['driver'] !== 'cookie' and ! is_string($cookie[0]))) { // invalid specific format logger('DEBUG', 'Error: Invalid session cookie specific format'); $cookie = false; } } // or a string containing the session id elseif (is_string($cookie) and strlen($cookie) == 32) { $cookie = array($cookie); } // invalid general format else { logger('DEBUG', 'Error: Invalid session cookie general format'); $cookie = false; } } // and the result return $cookie; }
[ "protected", "function", "_get_cookie", "(", ")", "{", "// was the cookie value posted?", "$", "cookie", "=", "\\", "Input", "::", "post", "(", "$", "this", "->", "config", "[", "'post_cookie_name'", "]", ",", "false", ")", ";", "// if not found, fetch the regular cookie", "if", "(", "$", "cookie", "===", "false", ")", "{", "$", "cookie", "=", "\\", "Cookie", "::", "get", "(", "$", "this", "->", "config", "[", "'cookie_name'", "]", ",", "false", ")", ";", "}", "// if not found, was a session-id present in the HTTP header?", "if", "(", "$", "cookie", "===", "false", ")", "{", "$", "cookie", "=", "\\", "Input", "::", "headers", "(", "$", "this", "->", "config", "[", "'http_header_name'", "]", ",", "false", ")", ";", "}", "// if not found, check the URL for a cookie", "if", "(", "$", "cookie", "===", "false", ")", "{", "$", "cookie", "=", "\\", "Input", "::", "get", "(", "$", "this", "->", "config", "[", "'cookie_name'", "]", ",", "false", ")", ";", "}", "if", "(", "$", "cookie", "!==", "false", ")", "{", "// fetch the payload", "$", "this", "->", "config", "[", "'encrypt_cookie'", "]", "and", "$", "cookie", "=", "\\", "Crypt", "::", "decode", "(", "$", "cookie", ")", ";", "$", "cookie", "=", "$", "this", "->", "_unserialize", "(", "$", "cookie", ")", ";", "// validate the cookie format: must be an array", "if", "(", "is_array", "(", "$", "cookie", ")", ")", "{", "// cookies use nested arrays, other drivers have a string value", "if", "(", "(", "$", "this", "->", "config", "[", "'driver'", "]", "===", "'cookie'", "and", "!", "is_array", "(", "$", "cookie", "[", "0", "]", ")", ")", "or", "(", "$", "this", "->", "config", "[", "'driver'", "]", "!==", "'cookie'", "and", "!", "is_string", "(", "$", "cookie", "[", "0", "]", ")", ")", ")", "{", "// invalid specific format", "logger", "(", "'DEBUG'", ",", "'Error: Invalid session cookie specific format'", ")", ";", "$", "cookie", "=", "false", ";", "}", "}", "// or a string containing the session id", "elseif", "(", "is_string", "(", "$", "cookie", ")", "and", "strlen", "(", "$", "cookie", ")", "==", "32", ")", "{", "$", "cookie", "=", "array", "(", "$", "cookie", ")", ";", "}", "// invalid general format", "else", "{", "logger", "(", "'DEBUG'", ",", "'Error: Invalid session cookie general format'", ")", ";", "$", "cookie", "=", "false", ";", "}", "}", "// and the result", "return", "$", "cookie", ";", "}" ]
read a cookie @access private @return void
[ "read", "a", "cookie" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/session/driver.php#L525-L583
2,610
cityware/city-snmp
src/MIBS/Entity.php
Entity.physicalClass
public function physicalClass($translate = false) { $classes = $this->getSNMP()->walk1d(self::OID_ENTITY_PHYSICAL_CLASS); if (!$translate) { return $classes; } return $this->getSNMP()->translate($classes, self::$ENTITY_PHSYICAL_CLASS); }
php
public function physicalClass($translate = false) { $classes = $this->getSNMP()->walk1d(self::OID_ENTITY_PHYSICAL_CLASS); if (!$translate) { return $classes; } return $this->getSNMP()->translate($classes, self::$ENTITY_PHSYICAL_CLASS); }
[ "public", "function", "physicalClass", "(", "$", "translate", "=", "false", ")", "{", "$", "classes", "=", "$", "this", "->", "getSNMP", "(", ")", "->", "walk1d", "(", "self", "::", "OID_ENTITY_PHYSICAL_CLASS", ")", ";", "if", "(", "!", "$", "translate", ")", "{", "return", "$", "classes", ";", "}", "return", "$", "this", "->", "getSNMP", "(", ")", "->", "translate", "(", "$", "classes", ",", "self", "::", "$", "ENTITY_PHSYICAL_CLASS", ")", ";", "}" ]
Returns an associate array of entPhysicalClass e.g. [1005] => 10 / port @param boolean $translate If true, return the string representation via self::$ENTITY_PHSYICAL_CLASS @return array Associate array of entPhysicalClass
[ "Returns", "an", "associate", "array", "of", "entPhysicalClass" ]
831b7485b6c932a84f081d5ceeb9c5f4e7a8641d
https://github.com/cityware/city-snmp/blob/831b7485b6c932a84f081d5ceeb9c5f4e7a8641d/src/MIBS/Entity.php#L118-L126
2,611
blar/hash
lib/Blar/Hash/Hash.php
Hash.compare
public static function compare($hash1, $hash2): bool { if(!is_string($hash1)) { $hash1 = (string) $hash1; } if(!is_string($hash2)) { $hash2 = (string) $hash2; } return hash_equals($hash1, $hash2); }
php
public static function compare($hash1, $hash2): bool { if(!is_string($hash1)) { $hash1 = (string) $hash1; } if(!is_string($hash2)) { $hash2 = (string) $hash2; } return hash_equals($hash1, $hash2); }
[ "public", "static", "function", "compare", "(", "$", "hash1", ",", "$", "hash2", ")", ":", "bool", "{", "if", "(", "!", "is_string", "(", "$", "hash1", ")", ")", "{", "$", "hash1", "=", "(", "string", ")", "$", "hash1", ";", "}", "if", "(", "!", "is_string", "(", "$", "hash2", ")", ")", "{", "$", "hash2", "=", "(", "string", ")", "$", "hash2", ";", "}", "return", "hash_equals", "(", "$", "hash1", ",", "$", "hash2", ")", ";", "}" ]
Compare to hashes. Minimize timing attacks. @param string $hash1 Known hash @param string $hash2 User hash @return bool
[ "Compare", "to", "hashes", ".", "Minimize", "timing", "attacks", "." ]
29557fe61fcf3eaf9471cdfef896ab3b21bb0468
https://github.com/blar/hash/blob/29557fe61fcf3eaf9471cdfef896ab3b21bb0468/lib/Blar/Hash/Hash.php#L127-L135
2,612
phlexible/phlexible
src/Phlexible/Bundle/GuiBundle/Controller/AssetController.php
AssetController.scriptsMapAction
public function scriptsMapAction() { $scriptsBuilder = $this->get('phlexible_gui.asset.scripts_builder'); $asset = $scriptsBuilder->build(); return new BinaryFileResponse($asset->getMapAsset(), 200, array('Content-Type' => 'application/json;charset=UTF-8')); }
php
public function scriptsMapAction() { $scriptsBuilder = $this->get('phlexible_gui.asset.scripts_builder'); $asset = $scriptsBuilder->build(); return new BinaryFileResponse($asset->getMapAsset(), 200, array('Content-Type' => 'application/json;charset=UTF-8')); }
[ "public", "function", "scriptsMapAction", "(", ")", "{", "$", "scriptsBuilder", "=", "$", "this", "->", "get", "(", "'phlexible_gui.asset.scripts_builder'", ")", ";", "$", "asset", "=", "$", "scriptsBuilder", "->", "build", "(", ")", ";", "return", "new", "BinaryFileResponse", "(", "$", "asset", "->", "getMapAsset", "(", ")", ",", "200", ",", "array", "(", "'Content-Type'", "=>", "'application/json;charset=UTF-8'", ")", ")", ";", "}" ]
Output scripts map. @return Response @Route("/gui.js.map", name="asset_scripts_map")
[ "Output", "scripts", "map", "." ]
132f24924c9bb0dbb6c1ea84db0a463f97fa3893
https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/GuiBundle/Controller/AssetController.php#L53-L59
2,613
phlexible/phlexible
src/Phlexible/Bundle/GuiBundle/Controller/AssetController.php
AssetController.cssAction
public function cssAction(Request $request) { $baseUrlContentFilter = $this->get('phlexible_gui.asset.base_url_content_filter'); $baseUrlContentFilter->setBasePath($request->getBasePath()); $baseUrlContentFilter->setBaseUrl($request->getBaseUrl()); $cssBuilder = $this->get('phlexible_gui.asset.css_builder'); $asset = $cssBuilder->build(); $response = new BinaryFileResponse($asset, 200, array('Content-Type' => 'text/css;charset=UTF-8')); if ($asset->getMapAsset()) { $response->headers->set('X-SourceMap', $this->generateUrl('asset_css_map')); } return $response; }
php
public function cssAction(Request $request) { $baseUrlContentFilter = $this->get('phlexible_gui.asset.base_url_content_filter'); $baseUrlContentFilter->setBasePath($request->getBasePath()); $baseUrlContentFilter->setBaseUrl($request->getBaseUrl()); $cssBuilder = $this->get('phlexible_gui.asset.css_builder'); $asset = $cssBuilder->build(); $response = new BinaryFileResponse($asset, 200, array('Content-Type' => 'text/css;charset=UTF-8')); if ($asset->getMapAsset()) { $response->headers->set('X-SourceMap', $this->generateUrl('asset_css_map')); } return $response; }
[ "public", "function", "cssAction", "(", "Request", "$", "request", ")", "{", "$", "baseUrlContentFilter", "=", "$", "this", "->", "get", "(", "'phlexible_gui.asset.base_url_content_filter'", ")", ";", "$", "baseUrlContentFilter", "->", "setBasePath", "(", "$", "request", "->", "getBasePath", "(", ")", ")", ";", "$", "baseUrlContentFilter", "->", "setBaseUrl", "(", "$", "request", "->", "getBaseUrl", "(", ")", ")", ";", "$", "cssBuilder", "=", "$", "this", "->", "get", "(", "'phlexible_gui.asset.css_builder'", ")", ";", "$", "asset", "=", "$", "cssBuilder", "->", "build", "(", ")", ";", "$", "response", "=", "new", "BinaryFileResponse", "(", "$", "asset", ",", "200", ",", "array", "(", "'Content-Type'", "=>", "'text/css;charset=UTF-8'", ")", ")", ";", "if", "(", "$", "asset", "->", "getMapAsset", "(", ")", ")", "{", "$", "response", "->", "headers", "->", "set", "(", "'X-SourceMap'", ",", "$", "this", "->", "generateUrl", "(", "'asset_css_map'", ")", ")", ";", "}", "return", "$", "response", ";", "}" ]
Output css. @param Request $request @return Response @Route("/gui.css", name="asset_css")
[ "Output", "css", "." ]
132f24924c9bb0dbb6c1ea84db0a463f97fa3893
https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/GuiBundle/Controller/AssetController.php#L69-L85
2,614
phlexible/phlexible
src/Phlexible/Bundle/GuiBundle/Controller/AssetController.php
AssetController.cssMapAction
public function cssMapAction(Request $request) { $baseUrlContentFilter = $this->get('phlexible_gui.asset.base_url_content_filter'); $baseUrlContentFilter->setBasePath($request->getBasePath()); $baseUrlContentFilter->setBaseUrl($request->getBaseUrl()); $cssBuilder = $this->get('phlexible_gui.asset.css_builder'); $asset = $cssBuilder->build(); return new BinaryFileResponse($asset->getMapAsset(), 200, array('Content-Type' => 'application/json;charset=UTF-8')); }
php
public function cssMapAction(Request $request) { $baseUrlContentFilter = $this->get('phlexible_gui.asset.base_url_content_filter'); $baseUrlContentFilter->setBasePath($request->getBasePath()); $baseUrlContentFilter->setBaseUrl($request->getBaseUrl()); $cssBuilder = $this->get('phlexible_gui.asset.css_builder'); $asset = $cssBuilder->build(); return new BinaryFileResponse($asset->getMapAsset(), 200, array('Content-Type' => 'application/json;charset=UTF-8')); }
[ "public", "function", "cssMapAction", "(", "Request", "$", "request", ")", "{", "$", "baseUrlContentFilter", "=", "$", "this", "->", "get", "(", "'phlexible_gui.asset.base_url_content_filter'", ")", ";", "$", "baseUrlContentFilter", "->", "setBasePath", "(", "$", "request", "->", "getBasePath", "(", ")", ")", ";", "$", "baseUrlContentFilter", "->", "setBaseUrl", "(", "$", "request", "->", "getBaseUrl", "(", ")", ")", ";", "$", "cssBuilder", "=", "$", "this", "->", "get", "(", "'phlexible_gui.asset.css_builder'", ")", ";", "$", "asset", "=", "$", "cssBuilder", "->", "build", "(", ")", ";", "return", "new", "BinaryFileResponse", "(", "$", "asset", "->", "getMapAsset", "(", ")", ",", "200", ",", "array", "(", "'Content-Type'", "=>", "'application/json;charset=UTF-8'", ")", ")", ";", "}" ]
Output css map. @param Request $request @return Response @Route("/gui.css.map", name="asset_css_map")
[ "Output", "css", "map", "." ]
132f24924c9bb0dbb6c1ea84db0a463f97fa3893
https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/GuiBundle/Controller/AssetController.php#L95-L106
2,615
phlexible/phlexible
src/Phlexible/Bundle/GuiBundle/Controller/AssetController.php
AssetController.iconsAction
public function iconsAction(Request $request) { $iconsBuilder = $this->get('phlexible_gui.asset.icons_builder'); $asset = $iconsBuilder->build($request->getBasePath()); return new BinaryFileResponse($asset, 200, array('Content-Type' => 'text/css;charset=UTF-8')); }
php
public function iconsAction(Request $request) { $iconsBuilder = $this->get('phlexible_gui.asset.icons_builder'); $asset = $iconsBuilder->build($request->getBasePath()); return new BinaryFileResponse($asset, 200, array('Content-Type' => 'text/css;charset=UTF-8')); }
[ "public", "function", "iconsAction", "(", "Request", "$", "request", ")", "{", "$", "iconsBuilder", "=", "$", "this", "->", "get", "(", "'phlexible_gui.asset.icons_builder'", ")", ";", "$", "asset", "=", "$", "iconsBuilder", "->", "build", "(", "$", "request", "->", "getBasePath", "(", ")", ")", ";", "return", "new", "BinaryFileResponse", "(", "$", "asset", ",", "200", ",", "array", "(", "'Content-Type'", "=>", "'text/css;charset=UTF-8'", ")", ")", ";", "}" ]
Output icon styles. @param Request $request @return Response @Route("/gui-icons.css", name="asset_icons")
[ "Output", "icon", "styles", "." ]
132f24924c9bb0dbb6c1ea84db0a463f97fa3893
https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/GuiBundle/Controller/AssetController.php#L116-L122
2,616
phlexible/phlexible
src/Phlexible/Bundle/GuiBundle/Controller/AssetController.php
AssetController.translationsAction
public function translationsAction(Request $request, $language) { $translationBuilder = $this->get('phlexible_gui.asset.translations_builder'); $asset = $translationBuilder->build($language); return new BinaryFileResponse($asset, 200, array('Content-Type' => 'text/javascript;charset=UTF-8')); }
php
public function translationsAction(Request $request, $language) { $translationBuilder = $this->get('phlexible_gui.asset.translations_builder'); $asset = $translationBuilder->build($language); return new BinaryFileResponse($asset, 200, array('Content-Type' => 'text/javascript;charset=UTF-8')); }
[ "public", "function", "translationsAction", "(", "Request", "$", "request", ",", "$", "language", ")", "{", "$", "translationBuilder", "=", "$", "this", "->", "get", "(", "'phlexible_gui.asset.translations_builder'", ")", ";", "$", "asset", "=", "$", "translationBuilder", "->", "build", "(", "$", "language", ")", ";", "return", "new", "BinaryFileResponse", "(", "$", "asset", ",", "200", ",", "array", "(", "'Content-Type'", "=>", "'text/javascript;charset=UTF-8'", ")", ")", ";", "}" ]
Output translations. @param Request $request @param string $language @return Response @Route("/translations-{language}.js", name="asset_translations")
[ "Output", "translations", "." ]
132f24924c9bb0dbb6c1ea84db0a463f97fa3893
https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/GuiBundle/Controller/AssetController.php#L133-L139
2,617
GinoPane/php-nano-http-status
src/NanoHttpStatus.php
NanoHttpStatus.getMessage
public function getMessage(int $code): string { return $this->statusExists($code) ? $this->statuses[$code] : self::UNDEFINED_STATUS_MESSAGE; }
php
public function getMessage(int $code): string { return $this->statusExists($code) ? $this->statuses[$code] : self::UNDEFINED_STATUS_MESSAGE; }
[ "public", "function", "getMessage", "(", "int", "$", "code", ")", ":", "string", "{", "return", "$", "this", "->", "statusExists", "(", "$", "code", ")", "?", "$", "this", "->", "statuses", "[", "$", "code", "]", ":", "self", "::", "UNDEFINED_STATUS_MESSAGE", ";", "}" ]
Returns relevant status message if status exists, 'Undefined Status' is returned otherwise @param int $code @return string
[ "Returns", "relevant", "status", "message", "if", "status", "exists", "Undefined", "Status", "is", "returned", "otherwise" ]
7d75dbc47710149d9b119ff4622413ca15e3c407
https://github.com/GinoPane/php-nano-http-status/blob/7d75dbc47710149d9b119ff4622413ca15e3c407/src/NanoHttpStatus.php#L121-L124
2,618
zepi/turbo-base
Zepi/Web/UserInterface/src/Form/Field/ExtendedEntitySelect.php
ExtendedEntitySelect.executeFormUpdateRequest
public function executeFormUpdateRequest(WebRequest $request, Response $response, Form $form) { $responseData = array('csrf' => $form->generateCsrfToken($request)); // If the search param not set return with an empty response if (!$request->hasParam('form-extended-entity-select-query')) { $responseData['data'] = array(); $response->setOutput(json_encode($responseData), true); return; } $query = $request->getParam('form-extended-entity-select-query'); $entities = $this->getAvailableValues($query); if ($entities === false) { $response->setOutput(json_encode(array('error' => true)), true); return; } $data = array(); foreach ($entities as $entity) { $data[] = array('id' => $entity->getId(), 'name' => (string) $entity); } $responseData['data'] = $data; $response->setOutput(json_encode($responseData), true); }
php
public function executeFormUpdateRequest(WebRequest $request, Response $response, Form $form) { $responseData = array('csrf' => $form->generateCsrfToken($request)); // If the search param not set return with an empty response if (!$request->hasParam('form-extended-entity-select-query')) { $responseData['data'] = array(); $response->setOutput(json_encode($responseData), true); return; } $query = $request->getParam('form-extended-entity-select-query'); $entities = $this->getAvailableValues($query); if ($entities === false) { $response->setOutput(json_encode(array('error' => true)), true); return; } $data = array(); foreach ($entities as $entity) { $data[] = array('id' => $entity->getId(), 'name' => (string) $entity); } $responseData['data'] = $data; $response->setOutput(json_encode($responseData), true); }
[ "public", "function", "executeFormUpdateRequest", "(", "WebRequest", "$", "request", ",", "Response", "$", "response", ",", "Form", "$", "form", ")", "{", "$", "responseData", "=", "array", "(", "'csrf'", "=>", "$", "form", "->", "generateCsrfToken", "(", "$", "request", ")", ")", ";", "// If the search param not set return with an empty response", "if", "(", "!", "$", "request", "->", "hasParam", "(", "'form-extended-entity-select-query'", ")", ")", "{", "$", "responseData", "[", "'data'", "]", "=", "array", "(", ")", ";", "$", "response", "->", "setOutput", "(", "json_encode", "(", "$", "responseData", ")", ",", "true", ")", ";", "return", ";", "}", "$", "query", "=", "$", "request", "->", "getParam", "(", "'form-extended-entity-select-query'", ")", ";", "$", "entities", "=", "$", "this", "->", "getAvailableValues", "(", "$", "query", ")", ";", "if", "(", "$", "entities", "===", "false", ")", "{", "$", "response", "->", "setOutput", "(", "json_encode", "(", "array", "(", "'error'", "=>", "true", ")", ")", ",", "true", ")", ";", "return", ";", "}", "$", "data", "=", "array", "(", ")", ";", "foreach", "(", "$", "entities", "as", "$", "entity", ")", "{", "$", "data", "[", "]", "=", "array", "(", "'id'", "=>", "$", "entity", "->", "getId", "(", ")", ",", "'name'", "=>", "(", "string", ")", "$", "entity", ")", ";", "}", "$", "responseData", "[", "'data'", "]", "=", "$", "data", ";", "$", "response", "->", "setOutput", "(", "json_encode", "(", "$", "responseData", ")", ",", "true", ")", ";", "}" ]
Executes the form update request @param \Zepi\Turbo\Request\WebRequest $request @param \Zepi\Turbo\Response\Response $response @param \Zepi\Web\UserInterface\Form\Form $form
[ "Executes", "the", "form", "update", "request" ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Web/UserInterface/src/Form/Field/ExtendedEntitySelect.php#L116-L143
2,619
jaztec/jaztec-admin
src/JaztecAdmin/Controller/IndexController.php
IndexController.indexAction
public function indexAction() { $this->layout('jaztec-admin/layout'); $sm = $this->getServiceLocator(); $bootstrap = $sm->get('kjsencha.bootstrap'); return $bootstrap->getViewModel(); }
php
public function indexAction() { $this->layout('jaztec-admin/layout'); $sm = $this->getServiceLocator(); $bootstrap = $sm->get('kjsencha.bootstrap'); return $bootstrap->getViewModel(); }
[ "public", "function", "indexAction", "(", ")", "{", "$", "this", "->", "layout", "(", "'jaztec-admin/layout'", ")", ";", "$", "sm", "=", "$", "this", "->", "getServiceLocator", "(", ")", ";", "$", "bootstrap", "=", "$", "sm", "->", "get", "(", "'kjsencha.bootstrap'", ")", ";", "return", "$", "bootstrap", "->", "getViewModel", "(", ")", ";", "}" ]
Fires the ExtJs application. @return \Zend\View\ViewModel
[ "Fires", "the", "ExtJs", "application", "." ]
c05b84077f05ed26529e2795f6adfe7b4ebd0edf
https://github.com/jaztec/jaztec-admin/blob/c05b84077f05ed26529e2795f6adfe7b4ebd0edf/src/JaztecAdmin/Controller/IndexController.php#L20-L28
2,620
tekkla/core-html
Core/Html/FormDesigner/FormGroup.php
FormGroup.&
public function &addControl($control, $name='', $label = '', $value = '', $description = '', $unbound = false) { $string = new CamelCase($control); $control = $this->factory->create('FormDesigner\Controls\\' . $string->camelize() . 'Control'); // Set name $control->setName($name); // set contols name if ($unbound && method_exists($control, 'setUnbound')) { $control->setUnbound(); $control->removename(); } // Label set? if (! empty($label) && method_exists($control, 'setLabel')) { $control->setLabel($label); } if (! empty($value) && method_exists($control, 'setValue')) { $control->setValue($value); } if (! empty($description) && method_exists($control, 'setDescription')) { $control->setDescription($description); } if ($control instanceof Button) { $control->noLabel(); } // Create element $this->elementFactory('control', $control); return $control; }
php
public function &addControl($control, $name='', $label = '', $value = '', $description = '', $unbound = false) { $string = new CamelCase($control); $control = $this->factory->create('FormDesigner\Controls\\' . $string->camelize() . 'Control'); // Set name $control->setName($name); // set contols name if ($unbound && method_exists($control, 'setUnbound')) { $control->setUnbound(); $control->removename(); } // Label set? if (! empty($label) && method_exists($control, 'setLabel')) { $control->setLabel($label); } if (! empty($value) && method_exists($control, 'setValue')) { $control->setValue($value); } if (! empty($description) && method_exists($control, 'setDescription')) { $control->setDescription($description); } if ($control instanceof Button) { $control->noLabel(); } // Create element $this->elementFactory('control', $control); return $control; }
[ "public", "function", "&", "addControl", "(", "$", "control", ",", "$", "name", "=", "''", ",", "$", "label", "=", "''", ",", "$", "value", "=", "''", ",", "$", "description", "=", "''", ",", "$", "unbound", "=", "false", ")", "{", "$", "string", "=", "new", "CamelCase", "(", "$", "control", ")", ";", "$", "control", "=", "$", "this", "->", "factory", "->", "create", "(", "'FormDesigner\\Controls\\\\'", ".", "$", "string", "->", "camelize", "(", ")", ".", "'Control'", ")", ";", "// Set name", "$", "control", "->", "setName", "(", "$", "name", ")", ";", "// set contols name", "if", "(", "$", "unbound", "&&", "method_exists", "(", "$", "control", ",", "'setUnbound'", ")", ")", "{", "$", "control", "->", "setUnbound", "(", ")", ";", "$", "control", "->", "removename", "(", ")", ";", "}", "// Label set?", "if", "(", "!", "empty", "(", "$", "label", ")", "&&", "method_exists", "(", "$", "control", ",", "'setLabel'", ")", ")", "{", "$", "control", "->", "setLabel", "(", "$", "label", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "value", ")", "&&", "method_exists", "(", "$", "control", ",", "'setValue'", ")", ")", "{", "$", "control", "->", "setValue", "(", "$", "value", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "description", ")", "&&", "method_exists", "(", "$", "control", ",", "'setDescription'", ")", ")", "{", "$", "control", "->", "setDescription", "(", "$", "description", ")", ";", "}", "if", "(", "$", "control", "instanceof", "Button", ")", "{", "$", "control", "->", "noLabel", "(", ")", ";", "}", "// Create element", "$", "this", "->", "elementFactory", "(", "'control'", ",", "$", "control", ")", ";", "return", "$", "control", ";", "}" ]
Creates a formcontrol and adds it by it's name to the controls list. @param string $type The type of control to create @param string $name Name of the control. Ths name is used to bind the control to a model field. @return \Core\Html\Form\AbstractForm
[ "Creates", "a", "formcontrol", "and", "adds", "it", "by", "it", "s", "name", "to", "the", "controls", "list", "." ]
00bf3fa8e060e8aadf1c341f6e3c548c7a76cfd3
https://github.com/tekkla/core-html/blob/00bf3fa8e060e8aadf1c341f6e3c548c7a76cfd3/Core/Html/FormDesigner/FormGroup.php#L124-L160
2,621
tekkla/core-html
Core/Html/FormDesigner/FormGroup.php
FormGroup.&
public function &addElement($element, $args = []) { $element = $this->factory->create($element, $args); $this->elementFactory('factory', $element); return $element; }
php
public function &addElement($element, $args = []) { $element = $this->factory->create($element, $args); $this->elementFactory('factory', $element); return $element; }
[ "public", "function", "&", "addElement", "(", "$", "element", ",", "$", "args", "=", "[", "]", ")", "{", "$", "element", "=", "$", "this", "->", "factory", "->", "create", "(", "$", "element", ",", "$", "args", ")", ";", "$", "this", "->", "elementFactory", "(", "'factory'", ",", "$", "element", ")", ";", "return", "$", "element", ";", "}" ]
Create an new html object and adds it as new FormElement @param string $element Name/Path of element to create @param array $args Optional arguments to be passed on element creation call. @return \Core\Html\AbstractHtml
[ "Create", "an", "new", "html", "object", "and", "adds", "it", "as", "new", "FormElement" ]
00bf3fa8e060e8aadf1c341f6e3c548c7a76cfd3
https://github.com/tekkla/core-html/blob/00bf3fa8e060e8aadf1c341f6e3c548c7a76cfd3/Core/Html/FormDesigner/FormGroup.php#L187-L194
2,622
tekkla/core-html
Core/Html/FormDesigner/FormGroup.php
FormGroup.&
public function &addGroup($unshift = false) { /* @var $group FormGroup */ $group = $this->factory->create('FormDesigner\FormGroup'); $this->elementFactory('group', $group, $unshift); $group->injectFormDesigner($this->fd); $group->injectParentGroup($this); return $group; }
php
public function &addGroup($unshift = false) { /* @var $group FormGroup */ $group = $this->factory->create('FormDesigner\FormGroup'); $this->elementFactory('group', $group, $unshift); $group->injectFormDesigner($this->fd); $group->injectParentGroup($this); return $group; }
[ "public", "function", "&", "addGroup", "(", "$", "unshift", "=", "false", ")", "{", "/* @var $group FormGroup */", "$", "group", "=", "$", "this", "->", "factory", "->", "create", "(", "'FormDesigner\\FormGroup'", ")", ";", "$", "this", "->", "elementFactory", "(", "'group'", ",", "$", "group", ",", "$", "unshift", ")", ";", "$", "group", "->", "injectFormDesigner", "(", "$", "this", "->", "fd", ")", ";", "$", "group", "->", "injectParentGroup", "(", "$", "this", ")", ";", "return", "$", "group", ";", "}" ]
Creates a new FormGroup objects and adds it as new FormElement @param bool $unshift Optional flag to add group at beginning of controls array. @return \Core\Html\FormDesigner\FormGroup
[ "Creates", "a", "new", "FormGroup", "objects", "and", "adds", "it", "as", "new", "FormElement" ]
00bf3fa8e060e8aadf1c341f6e3c548c7a76cfd3
https://github.com/tekkla/core-html/blob/00bf3fa8e060e8aadf1c341f6e3c548c7a76cfd3/Core/Html/FormDesigner/FormGroup.php#L204-L215
2,623
tekkla/core-html
Core/Html/FormDesigner/FormGroup.php
FormGroup.elementFactory
private function elementFactory($type, $content, $unshift = false) { $element = $this->factory->create('FormDesigner\FormElement'); $element->setContent($content); if ($unshift == true) { array_unshift($this->elements, $element); } else { $this->elements[] = $element; } return $element; }
php
private function elementFactory($type, $content, $unshift = false) { $element = $this->factory->create('FormDesigner\FormElement'); $element->setContent($content); if ($unshift == true) { array_unshift($this->elements, $element); } else { $this->elements[] = $element; } return $element; }
[ "private", "function", "elementFactory", "(", "$", "type", ",", "$", "content", ",", "$", "unshift", "=", "false", ")", "{", "$", "element", "=", "$", "this", "->", "factory", "->", "create", "(", "'FormDesigner\\FormElement'", ")", ";", "$", "element", "->", "setContent", "(", "$", "content", ")", ";", "if", "(", "$", "unshift", "==", "true", ")", "{", "array_unshift", "(", "$", "this", "->", "elements", ",", "$", "element", ")", ";", "}", "else", "{", "$", "this", "->", "elements", "[", "]", "=", "$", "element", ";", "}", "return", "$", "element", ";", "}" ]
Factory mehtod to create new FormElement object within this group object. @param string $type Elementtype to create @param string|AbstractForm|AbstractHtml|FormGroup $content Content of the element to create @param bool $unshift Optional boolean flag to add element on top of elements stack of this group @return \Core\Html\FormDesigner\FormElement
[ "Factory", "mehtod", "to", "create", "new", "FormElement", "object", "within", "this", "group", "object", "." ]
00bf3fa8e060e8aadf1c341f6e3c548c7a76cfd3
https://github.com/tekkla/core-html/blob/00bf3fa8e060e8aadf1c341f6e3c548c7a76cfd3/Core/Html/FormDesigner/FormGroup.php#L229-L242
2,624
ekyna/GoogleBundle
Twig/GoogleExtension.php
GoogleExtension.getGoogleTracking
public function getGoogleTracking() { /** @var \Ekyna\Bundle\GoogleBundle\Model\TrackingCode $trackingCode */ $trackingCode = $this->settingManager->getParameter('google.tracking_code'); if (!$this->debug && 0 < strlen($trackingCode->getPropertyId())) { $domain = $trackingCode->getDomain(); if (0 === strlen($domain)) { $domain = 'auto'; } if (in_array($trackingCode->getDomain(), ['none', 'auto'])) { $domain = sprintf("'%s'", $domain); } else { $domain = sprintf("{'cookieDomain': '%s'}", $domain); } return sprintf(self::GA_TRACKING_CODE, $trackingCode->getPropertyId(), $domain); } return ''; }
php
public function getGoogleTracking() { /** @var \Ekyna\Bundle\GoogleBundle\Model\TrackingCode $trackingCode */ $trackingCode = $this->settingManager->getParameter('google.tracking_code'); if (!$this->debug && 0 < strlen($trackingCode->getPropertyId())) { $domain = $trackingCode->getDomain(); if (0 === strlen($domain)) { $domain = 'auto'; } if (in_array($trackingCode->getDomain(), ['none', 'auto'])) { $domain = sprintf("'%s'", $domain); } else { $domain = sprintf("{'cookieDomain': '%s'}", $domain); } return sprintf(self::GA_TRACKING_CODE, $trackingCode->getPropertyId(), $domain); } return ''; }
[ "public", "function", "getGoogleTracking", "(", ")", "{", "/** @var \\Ekyna\\Bundle\\GoogleBundle\\Model\\TrackingCode $trackingCode */", "$", "trackingCode", "=", "$", "this", "->", "settingManager", "->", "getParameter", "(", "'google.tracking_code'", ")", ";", "if", "(", "!", "$", "this", "->", "debug", "&&", "0", "<", "strlen", "(", "$", "trackingCode", "->", "getPropertyId", "(", ")", ")", ")", "{", "$", "domain", "=", "$", "trackingCode", "->", "getDomain", "(", ")", ";", "if", "(", "0", "===", "strlen", "(", "$", "domain", ")", ")", "{", "$", "domain", "=", "'auto'", ";", "}", "if", "(", "in_array", "(", "$", "trackingCode", "->", "getDomain", "(", ")", ",", "[", "'none'", ",", "'auto'", "]", ")", ")", "{", "$", "domain", "=", "sprintf", "(", "\"'%s'\"", ",", "$", "domain", ")", ";", "}", "else", "{", "$", "domain", "=", "sprintf", "(", "\"{'cookieDomain': '%s'}\"", ",", "$", "domain", ")", ";", "}", "return", "sprintf", "(", "self", "::", "GA_TRACKING_CODE", ",", "$", "trackingCode", "->", "getPropertyId", "(", ")", ",", "$", "domain", ")", ";", "}", "return", "''", ";", "}" ]
Renders the google analytics tracking code. @return string
[ "Renders", "the", "google", "analytics", "tracking", "code", "." ]
b6689522de5911b8de332b18c07154eafc5f3589
https://github.com/ekyna/GoogleBundle/blob/b6689522de5911b8de332b18c07154eafc5f3589/Twig/GoogleExtension.php#L63-L80
2,625
rawebone/Injector
library/RegisterResolver.php
RegisterResolver.registerObject
public function registerObject($service, $object) { if (!is_object($object)) { throw new ResolutionException("Service '$service' cannot be register as it's value is invalid"); } $this->services[$service] = function () use ($object) { return $object; }; }
php
public function registerObject($service, $object) { if (!is_object($object)) { throw new ResolutionException("Service '$service' cannot be register as it's value is invalid"); } $this->services[$service] = function () use ($object) { return $object; }; }
[ "public", "function", "registerObject", "(", "$", "service", ",", "$", "object", ")", "{", "if", "(", "!", "is_object", "(", "$", "object", ")", ")", "{", "throw", "new", "ResolutionException", "(", "\"Service '$service' cannot be register as it's value is invalid\"", ")", ";", "}", "$", "this", "->", "services", "[", "$", "service", "]", "=", "function", "(", ")", "use", "(", "$", "object", ")", "{", "return", "$", "object", ";", "}", ";", "}" ]
Registers an object with the container. @param string $service @param object $object @see register
[ "Registers", "an", "object", "with", "the", "container", "." ]
a3a8ef90f4df92686fd502dbc1d423f40a57bff3
https://github.com/rawebone/Injector/blob/a3a8ef90f4df92686fd502dbc1d423f40a57bff3/library/RegisterResolver.php#L61-L68
2,626
mandango/MandangoBundle
Validator/Constraint/UniqueDocumentValidator.php
UniqueDocumentValidator.isValid
public function isValid($value, Constraint $constraint) { $document = $this->parseDocument($value); $fields = $this->parseFields($constraint->fields); $caseInsensitive = $this->parseCaseInsensitive($constraint->caseInsensitive); $query = $this->createQuery($document, $fields, $caseInsensitive); $numberResults = $query->count(); if (0 === $numberResults) { return true; } if (1 === $numberResults) { $result = $query->one(); if ($result === $document) { return true; } } if ($this->context) { $this->addFieldViolation($fields[0], $constraint->message); } return false; }
php
public function isValid($value, Constraint $constraint) { $document = $this->parseDocument($value); $fields = $this->parseFields($constraint->fields); $caseInsensitive = $this->parseCaseInsensitive($constraint->caseInsensitive); $query = $this->createQuery($document, $fields, $caseInsensitive); $numberResults = $query->count(); if (0 === $numberResults) { return true; } if (1 === $numberResults) { $result = $query->one(); if ($result === $document) { return true; } } if ($this->context) { $this->addFieldViolation($fields[0], $constraint->message); } return false; }
[ "public", "function", "isValid", "(", "$", "value", ",", "Constraint", "$", "constraint", ")", "{", "$", "document", "=", "$", "this", "->", "parseDocument", "(", "$", "value", ")", ";", "$", "fields", "=", "$", "this", "->", "parseFields", "(", "$", "constraint", "->", "fields", ")", ";", "$", "caseInsensitive", "=", "$", "this", "->", "parseCaseInsensitive", "(", "$", "constraint", "->", "caseInsensitive", ")", ";", "$", "query", "=", "$", "this", "->", "createQuery", "(", "$", "document", ",", "$", "fields", ",", "$", "caseInsensitive", ")", ";", "$", "numberResults", "=", "$", "query", "->", "count", "(", ")", ";", "if", "(", "0", "===", "$", "numberResults", ")", "{", "return", "true", ";", "}", "if", "(", "1", "===", "$", "numberResults", ")", "{", "$", "result", "=", "$", "query", "->", "one", "(", ")", ";", "if", "(", "$", "result", "===", "$", "document", ")", "{", "return", "true", ";", "}", "}", "if", "(", "$", "this", "->", "context", ")", "{", "$", "this", "->", "addFieldViolation", "(", "$", "fields", "[", "0", "]", ",", "$", "constraint", "->", "message", ")", ";", "}", "return", "false", ";", "}" ]
Validates the document uniqueness. @param value $value The document. @param Constraint $constraint The constraint. @return Boolean Whether or not the document is unique.
[ "Validates", "the", "document", "uniqueness", "." ]
36e2ff4cc43989abbb3bd2f84cd7909c0f39d5b9
https://github.com/mandango/MandangoBundle/blob/36e2ff4cc43989abbb3bd2f84cd7909c0f39d5b9/Validator/Constraint/UniqueDocumentValidator.php#L46-L71
2,627
pdenis/SnideTravinizerBundle
Repository/Yaml/RepoRepository.php
RepoRepository.findAll
public function findAll() { $repos = array(); foreach ($this->getRows() as $row) { $repo = $this->createNew(); $repo->setId($row['id']); $repo->setSlug($row['slug']); $repo->setType($row['type']); $repo->setQualityBadgeHash($row['qualityBadgeHash']); $repo->setCoverageBadgeHash($row['coverageBadgeHash']); $repos[] = $repo; } return $repos; }
php
public function findAll() { $repos = array(); foreach ($this->getRows() as $row) { $repo = $this->createNew(); $repo->setId($row['id']); $repo->setSlug($row['slug']); $repo->setType($row['type']); $repo->setQualityBadgeHash($row['qualityBadgeHash']); $repo->setCoverageBadgeHash($row['coverageBadgeHash']); $repos[] = $repo; } return $repos; }
[ "public", "function", "findAll", "(", ")", "{", "$", "repos", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "getRows", "(", ")", "as", "$", "row", ")", "{", "$", "repo", "=", "$", "this", "->", "createNew", "(", ")", ";", "$", "repo", "->", "setId", "(", "$", "row", "[", "'id'", "]", ")", ";", "$", "repo", "->", "setSlug", "(", "$", "row", "[", "'slug'", "]", ")", ";", "$", "repo", "->", "setType", "(", "$", "row", "[", "'type'", "]", ")", ";", "$", "repo", "->", "setQualityBadgeHash", "(", "$", "row", "[", "'qualityBadgeHash'", "]", ")", ";", "$", "repo", "->", "setCoverageBadgeHash", "(", "$", "row", "[", "'coverageBadgeHash'", "]", ")", ";", "$", "repos", "[", "]", "=", "$", "repo", ";", "}", "return", "$", "repos", ";", "}" ]
Retrieve all repos @return array
[ "Retrieve", "all", "repos" ]
53a6fd647280d81a496018d379e4b5c446f81729
https://github.com/pdenis/SnideTravinizerBundle/blob/53a6fd647280d81a496018d379e4b5c446f81729/Repository/Yaml/RepoRepository.php#L59-L74
2,628
pdenis/SnideTravinizerBundle
Repository/Yaml/RepoRepository.php
RepoRepository.find
public function find($id) { foreach ($this->findAll() as $repo) { if ($id == $repo->getId()) { return $repo; } } return null; }
php
public function find($id) { foreach ($this->findAll() as $repo) { if ($id == $repo->getId()) { return $repo; } } return null; }
[ "public", "function", "find", "(", "$", "id", ")", "{", "foreach", "(", "$", "this", "->", "findAll", "(", ")", "as", "$", "repo", ")", "{", "if", "(", "$", "id", "==", "$", "repo", "->", "getId", "(", ")", ")", "{", "return", "$", "repo", ";", "}", "}", "return", "null", ";", "}" ]
Find repo by ID @param $id Repo id @return Repo|null
[ "Find", "repo", "by", "ID" ]
53a6fd647280d81a496018d379e4b5c446f81729
https://github.com/pdenis/SnideTravinizerBundle/blob/53a6fd647280d81a496018d379e4b5c446f81729/Repository/Yaml/RepoRepository.php#L98-L107
2,629
pdenis/SnideTravinizerBundle
Repository/Yaml/RepoRepository.php
RepoRepository.findBySlug
public function findBySlug($slug) { foreach ($this->findAll() as $repo) { if ($slug == $repo->getSlug()) { return $repo; } } return null; }
php
public function findBySlug($slug) { foreach ($this->findAll() as $repo) { if ($slug == $repo->getSlug()) { return $repo; } } return null; }
[ "public", "function", "findBySlug", "(", "$", "slug", ")", "{", "foreach", "(", "$", "this", "->", "findAll", "(", ")", "as", "$", "repo", ")", "{", "if", "(", "$", "slug", "==", "$", "repo", "->", "getSlug", "(", ")", ")", "{", "return", "$", "repo", ";", "}", "}", "return", "null", ";", "}" ]
Find repo by Slug @param string $slug Repo Slug @return Repo|null
[ "Find", "repo", "by", "Slug" ]
53a6fd647280d81a496018d379e4b5c446f81729
https://github.com/pdenis/SnideTravinizerBundle/blob/53a6fd647280d81a496018d379e4b5c446f81729/Repository/Yaml/RepoRepository.php#L115-L124
2,630
hiqdev/composer-asset-plugin
src/PackageManager.php
PackageManager.writeJson
public function writeJson($path, array $config) { $jsonFile = new JsonFile($path); $jsonFile->write($this->prepareConfig($config)); }
php
public function writeJson($path, array $config) { $jsonFile = new JsonFile($path); $jsonFile->write($this->prepareConfig($config)); }
[ "public", "function", "writeJson", "(", "$", "path", ",", "array", "$", "config", ")", "{", "$", "jsonFile", "=", "new", "JsonFile", "(", "$", "path", ")", ";", "$", "jsonFile", "->", "write", "(", "$", "this", "->", "prepareConfig", "(", "$", "config", ")", ")", ";", "}" ]
Saves JSON config to the given path. @param string $path @param array $config @throws \Exception
[ "Saves", "JSON", "config", "to", "the", "given", "path", "." ]
cdc55b07612334705e802197a39f41a0adca204c
https://github.com/hiqdev/composer-asset-plugin/blob/cdc55b07612334705e802197a39f41a0adca204c/src/PackageManager.php#L152-L156
2,631
hiqdev/composer-asset-plugin
src/PackageManager.php
PackageManager.hasDependencies
public function hasDependencies() { foreach ($this->dependencies as $key) { if (isset($this->config[$key]) && $this->config[$key]) { return true; } } return false; }
php
public function hasDependencies() { foreach ($this->dependencies as $key) { if (isset($this->config[$key]) && $this->config[$key]) { return true; } } return false; }
[ "public", "function", "hasDependencies", "(", ")", "{", "foreach", "(", "$", "this", "->", "dependencies", "as", "$", "key", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "config", "[", "$", "key", "]", ")", "&&", "$", "this", "->", "config", "[", "$", "key", "]", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Returns if the package manager has nonempty dependency list. @return bool
[ "Returns", "if", "the", "package", "manager", "has", "nonempty", "dependency", "list", "." ]
cdc55b07612334705e802197a39f41a0adca204c
https://github.com/hiqdev/composer-asset-plugin/blob/cdc55b07612334705e802197a39f41a0adca204c/src/PackageManager.php#L244-L253
2,632
hiqdev/composer-asset-plugin
src/PackageManager.php
PackageManager.perform
protected function perform($action) { $this->plugin->io->writeError('running ' . $this->getBin()); if ($this->passthru([$action])) { $this->plugin->io->writeError('<error>failed ' . $this->name . ' ' . $action . '</error>'); } }
php
protected function perform($action) { $this->plugin->io->writeError('running ' . $this->getBin()); if ($this->passthru([$action])) { $this->plugin->io->writeError('<error>failed ' . $this->name . ' ' . $action . '</error>'); } }
[ "protected", "function", "perform", "(", "$", "action", ")", "{", "$", "this", "->", "plugin", "->", "io", "->", "writeError", "(", "'running '", ".", "$", "this", "->", "getBin", "(", ")", ")", ";", "if", "(", "$", "this", "->", "passthru", "(", "[", "$", "action", "]", ")", ")", "{", "$", "this", "->", "plugin", "->", "io", "->", "writeError", "(", "'<error>failed '", ".", "$", "this", "->", "name", ".", "' '", ".", "$", "action", ".", "'</error>'", ")", ";", "}", "}" ]
Run installation. Specific for every package manager. @param string $action the action name @void
[ "Run", "installation", ".", "Specific", "for", "every", "package", "manager", "." ]
cdc55b07612334705e802197a39f41a0adca204c
https://github.com/hiqdev/composer-asset-plugin/blob/cdc55b07612334705e802197a39f41a0adca204c/src/PackageManager.php#L284-L290
2,633
hiqdev/composer-asset-plugin
src/PackageManager.php
PackageManager.prepareCommand
public function prepareCommand(array $arguments = []) { $result = ''; foreach ($arguments as $a) { $result .= ' ' . escapeshellarg($a); } return $result; }
php
public function prepareCommand(array $arguments = []) { $result = ''; foreach ($arguments as $a) { $result .= ' ' . escapeshellarg($a); } return $result; }
[ "public", "function", "prepareCommand", "(", "array", "$", "arguments", "=", "[", "]", ")", "{", "$", "result", "=", "''", ";", "foreach", "(", "$", "arguments", "as", "$", "a", ")", "{", "$", "result", ".=", "' '", ".", "escapeshellarg", "(", "$", "a", ")", ";", "}", "return", "$", "result", ";", "}" ]
Prepares given command arguments. @param array $arguments @return string
[ "Prepares", "given", "command", "arguments", "." ]
cdc55b07612334705e802197a39f41a0adca204c
https://github.com/hiqdev/composer-asset-plugin/blob/cdc55b07612334705e802197a39f41a0adca204c/src/PackageManager.php#L308-L316
2,634
hiqdev/composer-asset-plugin
src/PackageManager.php
PackageManager.getBin
public function getBin() { if ($this->bin === null) { $this->bin = $this->detectBin(); } return $this->bin; }
php
public function getBin() { if ($this->bin === null) { $this->bin = $this->detectBin(); } return $this->bin; }
[ "public", "function", "getBin", "(", ")", "{", "if", "(", "$", "this", "->", "bin", "===", "null", ")", "{", "$", "this", "->", "bin", "=", "$", "this", "->", "detectBin", "(", ")", ";", "}", "return", "$", "this", "->", "bin", ";", "}" ]
Get path to the binary executable file. @return string
[ "Get", "path", "to", "the", "binary", "executable", "file", "." ]
cdc55b07612334705e802197a39f41a0adca204c
https://github.com/hiqdev/composer-asset-plugin/blob/cdc55b07612334705e802197a39f41a0adca204c/src/PackageManager.php#L332-L339
2,635
hiqdev/composer-asset-plugin
src/PackageManager.php
PackageManager.detectBin
public function detectBin() { $pathes = [ static::buildPath([$this->plugin->getVendorDir(), 'bin', $this->phpBin]), static::buildPath([$this->plugin->getComposer()->getConfig()->get('home'), 'vendor', 'bin', $this->phpBin]), ]; foreach ($pathes as $path) { if (file_exists($path)) { return $path; } } return $this->name; }
php
public function detectBin() { $pathes = [ static::buildPath([$this->plugin->getVendorDir(), 'bin', $this->phpBin]), static::buildPath([$this->plugin->getComposer()->getConfig()->get('home'), 'vendor', 'bin', $this->phpBin]), ]; foreach ($pathes as $path) { if (file_exists($path)) { return $path; } } return $this->name; }
[ "public", "function", "detectBin", "(", ")", "{", "$", "pathes", "=", "[", "static", "::", "buildPath", "(", "[", "$", "this", "->", "plugin", "->", "getVendorDir", "(", ")", ",", "'bin'", ",", "$", "this", "->", "phpBin", "]", ")", ",", "static", "::", "buildPath", "(", "[", "$", "this", "->", "plugin", "->", "getComposer", "(", ")", "->", "getConfig", "(", ")", "->", "get", "(", "'home'", ")", ",", "'vendor'", ",", "'bin'", ",", "$", "this", "->", "phpBin", "]", ")", ",", "]", ";", "foreach", "(", "$", "pathes", "as", "$", "path", ")", "{", "if", "(", "file_exists", "(", "$", "path", ")", ")", "{", "return", "$", "path", ";", "}", "}", "return", "$", "this", "->", "name", ";", "}" ]
Find path to the binary. @return string
[ "Find", "path", "to", "the", "binary", "." ]
cdc55b07612334705e802197a39f41a0adca204c
https://github.com/hiqdev/composer-asset-plugin/blob/cdc55b07612334705e802197a39f41a0adca204c/src/PackageManager.php#L345-L358
2,636
pr0ggy/mockleton
src/MockableSingletonBehavior.php
MockableSingletonBehavior.registerSingletonInstance
public static function registerSingletonInstance($instance) { self::verifyInstanceNotYetRegistered(); self::verifyInstanceType($instance); self::$instance = $instance; }
php
public static function registerSingletonInstance($instance) { self::verifyInstanceNotYetRegistered(); self::verifyInstanceType($instance); self::$instance = $instance; }
[ "public", "static", "function", "registerSingletonInstance", "(", "$", "instance", ")", "{", "self", "::", "verifyInstanceNotYetRegistered", "(", ")", ";", "self", "::", "verifyInstanceType", "(", "$", "instance", ")", ";", "self", "::", "$", "instance", "=", "$", "instance", ";", "}" ]
Registers a specific instance of the class to use as the singleton instance @param static $instance the instance to register as the singleton instance @throws \TypeError if the given instance argument does not match the type of the context object @throws \RuntimeException if an instance has already been registered
[ "Registers", "a", "specific", "instance", "of", "the", "class", "to", "use", "as", "the", "singleton", "instance" ]
8b56edddbb040cfd1b9df66a54aee2b8824252ee
https://github.com/pr0ggy/mockleton/blob/8b56edddbb040cfd1b9df66a54aee2b8824252ee/src/MockableSingletonBehavior.php#L26-L31
2,637
Sowapps/orpheus-entitydescriptor
src/EntityDescriptor/PermanentEntity.php
PermanentEntity.putValue
public function putValue($field, $value) { $this->validateValue($field, $value); $this->setValue($field, $value); }
php
public function putValue($field, $value) { $this->validateValue($field, $value); $this->setValue($field, $value); }
[ "public", "function", "putValue", "(", "$", "field", ",", "$", "value", ")", "{", "$", "this", "->", "validateValue", "(", "$", "field", ",", "$", "value", ")", ";", "$", "this", "->", "setValue", "(", "$", "field", ",", "$", "value", ")", ";", "}" ]
Validate field value and set it @param string $field @param mixed $value
[ "Validate", "field", "value", "and", "set", "it" ]
b9cc04c42e7955b11f37a70ee7cd2a518f5983b2
https://github.com/Sowapps/orpheus-entitydescriptor/blob/b9cc04c42e7955b11f37a70ee7cd2a518f5983b2/src/EntityDescriptor/PermanentEntity.php#L76-L79
2,638
Sowapps/orpheus-entitydescriptor
src/EntityDescriptor/PermanentEntity.php
PermanentEntity.getEntityObject
public static function getEntityObject($objType, $objID=null) { if( is_object($objType) ) { $objID = $objType->entity_id; $objType = $objType->entity_type; } $class = isset(static::$entityClasses[$objType]) ? static::$entityClasses[$objType] : $objType; return $class::load($objID); }
php
public static function getEntityObject($objType, $objID=null) { if( is_object($objType) ) { $objID = $objType->entity_id; $objType = $objType->entity_type; } $class = isset(static::$entityClasses[$objType]) ? static::$entityClasses[$objType] : $objType; return $class::load($objID); }
[ "public", "static", "function", "getEntityObject", "(", "$", "objType", ",", "$", "objID", "=", "null", ")", "{", "if", "(", "is_object", "(", "$", "objType", ")", ")", "{", "$", "objID", "=", "$", "objType", "->", "entity_id", ";", "$", "objType", "=", "$", "objType", "->", "entity_type", ";", "}", "$", "class", "=", "isset", "(", "static", "::", "$", "entityClasses", "[", "$", "objType", "]", ")", "?", "static", "::", "$", "entityClasses", "[", "$", "objType", "]", ":", "$", "objType", ";", "return", "$", "class", "::", "load", "(", "$", "objID", ")", ";", "}" ]
Get entity instance by type and id @param string $objType @param string $objID @return PermanentEntity
[ "Get", "entity", "instance", "by", "type", "and", "id" ]
b9cc04c42e7955b11f37a70ee7cd2a518f5983b2
https://github.com/Sowapps/orpheus-entitydescriptor/blob/b9cc04c42e7955b11f37a70ee7cd2a518f5983b2/src/EntityDescriptor/PermanentEntity.php#L121-L128
2,639
Sowapps/orpheus-entitydescriptor
src/EntityDescriptor/PermanentEntity.php
PermanentEntity.parseFieldValue
protected static function parseFieldValue($name, $value) { $field = static::$validator->getField($name); if( $field ) { $field->getType()->parseValue($field, $value); } return parent::parseFieldValue($name, $value); }
php
protected static function parseFieldValue($name, $value) { $field = static::$validator->getField($name); if( $field ) { $field->getType()->parseValue($field, $value); } return parent::parseFieldValue($name, $value); }
[ "protected", "static", "function", "parseFieldValue", "(", "$", "name", ",", "$", "value", ")", "{", "$", "field", "=", "static", "::", "$", "validator", "->", "getField", "(", "$", "name", ")", ";", "if", "(", "$", "field", ")", "{", "$", "field", "->", "getType", "(", ")", "->", "parseValue", "(", "$", "field", ",", "$", "value", ")", ";", "}", "return", "parent", "::", "parseFieldValue", "(", "$", "name", ",", "$", "value", ")", ";", "}" ]
Parse the value from SQL scalar to PHP type @param string $name The field name to parse @param string $value The field value to parse @return string The parse $value @see PermanentObject::formatFieldValue()
[ "Parse", "the", "value", "from", "SQL", "scalar", "to", "PHP", "type" ]
b9cc04c42e7955b11f37a70ee7cd2a518f5983b2
https://github.com/Sowapps/orpheus-entitydescriptor/blob/b9cc04c42e7955b11f37a70ee7cd2a518f5983b2/src/EntityDescriptor/PermanentEntity.php#L170-L176
2,640
Sowapps/orpheus-entitydescriptor
src/EntityDescriptor/PermanentEntity.php
PermanentEntity.formatFieldValue
protected static function formatFieldValue($name, $value) { $field = static::$validator->getField($name); if( $field ) { $field->getType()->formatValue($field, $value); } return parent::formatFieldValue($name, $value); }
php
protected static function formatFieldValue($name, $value) { $field = static::$validator->getField($name); if( $field ) { $field->getType()->formatValue($field, $value); } return parent::formatFieldValue($name, $value); }
[ "protected", "static", "function", "formatFieldValue", "(", "$", "name", ",", "$", "value", ")", "{", "$", "field", "=", "static", "::", "$", "validator", "->", "getField", "(", "$", "name", ")", ";", "if", "(", "$", "field", ")", "{", "$", "field", "->", "getType", "(", ")", "->", "formatValue", "(", "$", "field", ",", "$", "value", ")", ";", "}", "return", "parent", "::", "formatFieldValue", "(", "$", "name", ",", "$", "value", ")", ";", "}" ]
Format the value from PHP type to SQL scalar @param string $name The field name to format @param mixed $value The field value to format @return string The formatted $Value @see PermanentObject::formatValue()
[ "Format", "the", "value", "from", "PHP", "type", "to", "SQL", "scalar" ]
b9cc04c42e7955b11f37a70ee7cd2a518f5983b2
https://github.com/Sowapps/orpheus-entitydescriptor/blob/b9cc04c42e7955b11f37a70ee7cd2a518f5983b2/src/EntityDescriptor/PermanentEntity.php#L186-L192
2,641
Sowapps/orpheus-entitydescriptor
src/EntityDescriptor/PermanentEntity.php
PermanentEntity.listKnownEntities
public static function listKnownEntities() { $entities = array(); foreach( static::$knownEntities as $class => &$state ) { if( $state == null ) { $state = class_exists($class, true) && is_subclass_of($class, 'Orpheus\EntityDescriptor\PermanentEntity'); } if( $state === true ) { $entities[] = $class; } } return $entities; }
php
public static function listKnownEntities() { $entities = array(); foreach( static::$knownEntities as $class => &$state ) { if( $state == null ) { $state = class_exists($class, true) && is_subclass_of($class, 'Orpheus\EntityDescriptor\PermanentEntity'); } if( $state === true ) { $entities[] = $class; } } return $entities; }
[ "public", "static", "function", "listKnownEntities", "(", ")", "{", "$", "entities", "=", "array", "(", ")", ";", "foreach", "(", "static", "::", "$", "knownEntities", "as", "$", "class", "=>", "&", "$", "state", ")", "{", "if", "(", "$", "state", "==", "null", ")", "{", "$", "state", "=", "class_exists", "(", "$", "class", ",", "true", ")", "&&", "is_subclass_of", "(", "$", "class", ",", "'Orpheus\\EntityDescriptor\\PermanentEntity'", ")", ";", "}", "if", "(", "$", "state", "===", "true", ")", "{", "$", "entities", "[", "]", "=", "$", "class", ";", "}", "}", "return", "$", "entities", ";", "}" ]
List all known entities @return string[]
[ "List", "all", "known", "entities" ]
b9cc04c42e7955b11f37a70ee7cd2a518f5983b2
https://github.com/Sowapps/orpheus-entitydescriptor/blob/b9cc04c42e7955b11f37a70ee7cd2a518f5983b2/src/EntityDescriptor/PermanentEntity.php#L218-L229
2,642
magicphp/framework
src/magicphp/app.class.php
App.Append
public static function Append($sName, $sDirectory){ $oThis = self::CreateInstanceIfNotExists(); if(array_key_exists($sName, $oThis->aModules)){ return $oThis->aModules[$sName]; } else{ $oModule = new Module($sName, $sDirectory); $oThis->aModules[$sName] = $oModule; return $oModule; } }
php
public static function Append($sName, $sDirectory){ $oThis = self::CreateInstanceIfNotExists(); if(array_key_exists($sName, $oThis->aModules)){ return $oThis->aModules[$sName]; } else{ $oModule = new Module($sName, $sDirectory); $oThis->aModules[$sName] = $oModule; return $oModule; } }
[ "public", "static", "function", "Append", "(", "$", "sName", ",", "$", "sDirectory", ")", "{", "$", "oThis", "=", "self", "::", "CreateInstanceIfNotExists", "(", ")", ";", "if", "(", "array_key_exists", "(", "$", "sName", ",", "$", "oThis", "->", "aModules", ")", ")", "{", "return", "$", "oThis", "->", "aModules", "[", "$", "sName", "]", ";", "}", "else", "{", "$", "oModule", "=", "new", "Module", "(", "$", "sName", ",", "$", "sDirectory", ")", ";", "$", "oThis", "->", "aModules", "[", "$", "sName", "]", "=", "$", "oModule", ";", "return", "$", "oModule", ";", "}", "}" ]
Function to append a module @static @param string $sName Module name @param string $sDirectory Path of module @return \Module
[ "Function", "to", "append", "a", "module" ]
199934b61c46ec596c27d4fb0355b216dde51d58
https://github.com/magicphp/framework/blob/199934b61c46ec596c27d4fb0355b216dde51d58/src/magicphp/app.class.php#L44-L55
2,643
popy-dev/popy-calendar
src/ValueObject/TimeOffset.php
TimeOffset.buildFromDateTimeInterface
public static function buildFromDateTimeInterface(DateTimeInterface $date) { $parts = explode('|', $date->format('Z|I|T')); return new static((int)$parts[0], (bool)$parts[1], $parts[2]); }
php
public static function buildFromDateTimeInterface(DateTimeInterface $date) { $parts = explode('|', $date->format('Z|I|T')); return new static((int)$parts[0], (bool)$parts[1], $parts[2]); }
[ "public", "static", "function", "buildFromDateTimeInterface", "(", "DateTimeInterface", "$", "date", ")", "{", "$", "parts", "=", "explode", "(", "'|'", ",", "$", "date", "->", "format", "(", "'Z|I|T'", ")", ")", ";", "return", "new", "static", "(", "(", "int", ")", "$", "parts", "[", "0", "]", ",", "(", "bool", ")", "$", "parts", "[", "1", "]", ",", "$", "parts", "[", "2", "]", ")", ";", "}" ]
Instanciates a TimeOffset from a DateTimeInterface, using the format method to extract properties. @param DateTimeInterface $date @return static
[ "Instanciates", "a", "TimeOffset", "from", "a", "DateTimeInterface", "using", "the", "format", "method", "to", "extract", "properties", "." ]
989048be18451c813cfce926229c6aaddd1b0639
https://github.com/popy-dev/popy-calendar/blob/989048be18451c813cfce926229c6aaddd1b0639/src/ValueObject/TimeOffset.php#L60-L65
2,644
popy-dev/popy-calendar
src/ValueObject/TimeOffset.php
TimeOffset.buildTimeZone
public function buildTimeZone() { if (null !== $this->value) { $sign = $this->value < 0 ? '-' : '+'; $value = intval(abs($this->value) / 60); return new DateTimeZone(sprintf( '%s%02d:%02d', $sign, intval($value / 60), $value % 60 )); } }
php
public function buildTimeZone() { if (null !== $this->value) { $sign = $this->value < 0 ? '-' : '+'; $value = intval(abs($this->value) / 60); return new DateTimeZone(sprintf( '%s%02d:%02d', $sign, intval($value / 60), $value % 60 )); } }
[ "public", "function", "buildTimeZone", "(", ")", "{", "if", "(", "null", "!==", "$", "this", "->", "value", ")", "{", "$", "sign", "=", "$", "this", "->", "value", "<", "0", "?", "'-'", ":", "'+'", ";", "$", "value", "=", "intval", "(", "abs", "(", "$", "this", "->", "value", ")", "/", "60", ")", ";", "return", "new", "DateTimeZone", "(", "sprintf", "(", "'%s%02d:%02d'", ",", "$", "sign", ",", "intval", "(", "$", "value", "/", "60", ")", ",", "$", "value", "%", "60", ")", ")", ";", "}", "}" ]
Build a DateTimeZone object based on TimeOffset properties, if possible. @return DateTimeZone|null
[ "Build", "a", "DateTimeZone", "object", "based", "on", "TimeOffset", "properties", "if", "possible", "." ]
989048be18451c813cfce926229c6aaddd1b0639
https://github.com/popy-dev/popy-calendar/blob/989048be18451c813cfce926229c6aaddd1b0639/src/ValueObject/TimeOffset.php#L148-L161
2,645
face-orm/face
lib/Face/Traits/EntityFaceTrait.php
EntityFaceTrait.faceGetter
public function faceGetter($needle) { // look the type of $needle then dispatch if ( $needle instanceof \Face\Core\EntityFaceElement ) { /* if is already a face element, dont beed anymore work */ $element=$needle; } else if (is_string($needle)) { /* * if it is a string the string can be the name of the element or a chain of elements separated by a dot * e.g * - first form : "elementName" * - secnd form : "elementName1.elementName2.elementName3" */ // TODO catch "this.elementName" case for dont instanciate a Navigator not needed for performances if (false!==strpos($needle, ".")) { return (new Navigator($needle))->chainGet($this); // "elementName1.elementName2.elementName3" case } else { $element=$this->getEntityFace()->getElement($needle); // "elementName" case } } else { throw new BadParameterException("Variable of type '".gettype($needle)."' is not a valide type for faceGetter"); } // if has a getter, it can be a custom callable annonymous function, or the name of the the method to call on this object if ($element->hasGetter()) { $getter = $element->getGetter(); if (is_string($getter)) { //method of this object return $this->$getter(); } elseif (is_callable($getter)) { // custom callable return $getter(); } else { throw new \Exception('Getter is set but it is not usable : '.var_export($getter, true)); } // else we use the property directly } else { $property = $element->getPropertyName(); return $this->$property; } // TODO throw exception on no way to get element }
php
public function faceGetter($needle) { // look the type of $needle then dispatch if ( $needle instanceof \Face\Core\EntityFaceElement ) { /* if is already a face element, dont beed anymore work */ $element=$needle; } else if (is_string($needle)) { /* * if it is a string the string can be the name of the element or a chain of elements separated by a dot * e.g * - first form : "elementName" * - secnd form : "elementName1.elementName2.elementName3" */ // TODO catch "this.elementName" case for dont instanciate a Navigator not needed for performances if (false!==strpos($needle, ".")) { return (new Navigator($needle))->chainGet($this); // "elementName1.elementName2.elementName3" case } else { $element=$this->getEntityFace()->getElement($needle); // "elementName" case } } else { throw new BadParameterException("Variable of type '".gettype($needle)."' is not a valide type for faceGetter"); } // if has a getter, it can be a custom callable annonymous function, or the name of the the method to call on this object if ($element->hasGetter()) { $getter = $element->getGetter(); if (is_string($getter)) { //method of this object return $this->$getter(); } elseif (is_callable($getter)) { // custom callable return $getter(); } else { throw new \Exception('Getter is set but it is not usable : '.var_export($getter, true)); } // else we use the property directly } else { $property = $element->getPropertyName(); return $this->$property; } // TODO throw exception on no way to get element }
[ "public", "function", "faceGetter", "(", "$", "needle", ")", "{", "// look the type of $needle then dispatch", "if", "(", "$", "needle", "instanceof", "\\", "Face", "\\", "Core", "\\", "EntityFaceElement", ")", "{", "/* if is already a face element, dont beed anymore work */", "$", "element", "=", "$", "needle", ";", "}", "else", "if", "(", "is_string", "(", "$", "needle", ")", ")", "{", "/*\n * if it is a string the string can be the name of the element or a chain of elements separated by a dot\n * e.g \n * - first form : \"elementName\"\n * - secnd form : \"elementName1.elementName2.elementName3\"\n */", "// TODO catch \"this.elementName\" case for dont instanciate a Navigator not needed for performances", "if", "(", "false", "!==", "strpos", "(", "$", "needle", ",", "\".\"", ")", ")", "{", "return", "(", "new", "Navigator", "(", "$", "needle", ")", ")", "->", "chainGet", "(", "$", "this", ")", ";", "// \"elementName1.elementName2.elementName3\" case", "}", "else", "{", "$", "element", "=", "$", "this", "->", "getEntityFace", "(", ")", "->", "getElement", "(", "$", "needle", ")", ";", "// \"elementName\" case", "}", "}", "else", "{", "throw", "new", "BadParameterException", "(", "\"Variable of type '\"", ".", "gettype", "(", "$", "needle", ")", ".", "\"' is not a valide type for faceGetter\"", ")", ";", "}", "// if has a getter, it can be a custom callable annonymous function, or the name of the the method to call on this object", "if", "(", "$", "element", "->", "hasGetter", "(", ")", ")", "{", "$", "getter", "=", "$", "element", "->", "getGetter", "(", ")", ";", "if", "(", "is_string", "(", "$", "getter", ")", ")", "{", "//method of this object", "return", "$", "this", "->", "$", "getter", "(", ")", ";", "}", "elseif", "(", "is_callable", "(", "$", "getter", ")", ")", "{", "// custom callable", "return", "$", "getter", "(", ")", ";", "}", "else", "{", "throw", "new", "\\", "Exception", "(", "'Getter is set but it is not usable : '", ".", "var_export", "(", "$", "getter", ",", "true", ")", ")", ";", "}", "// else we use the property directly", "}", "else", "{", "$", "property", "=", "$", "element", "->", "getPropertyName", "(", ")", ";", "return", "$", "this", "->", "$", "property", ";", "}", "// TODO throw exception on no way to get element", "}" ]
take the given element and use the right way for getting the value on this instance @param \Face\Core\EntityFaceElement|string $element the element to get or the path to the element @return mixed
[ "take", "the", "given", "element", "and", "use", "the", "right", "way", "for", "getting", "the", "value", "on", "this", "instance" ]
85b412c66ff41d0fe73b7e7b69bc9a5ac5f7f428
https://github.com/face-orm/face/blob/85b412c66ff41d0fe73b7e7b69bc9a5ac5f7f428/lib/Face/Traits/EntityFaceTrait.php#L22-L68
2,646
face-orm/face
lib/Face/Traits/EntityFaceTrait.php
EntityFaceTrait.faceQueryBuilder
public static function faceQueryBuilder(Config $config = null) { if(null == $config) { return new SelectBuilder(self::getEntityFace()); }else{ return new SelectBuilder(self::getEntityFace($config->getFaceLoader())); } }
php
public static function faceQueryBuilder(Config $config = null) { if(null == $config) { return new SelectBuilder(self::getEntityFace()); }else{ return new SelectBuilder(self::getEntityFace($config->getFaceLoader())); } }
[ "public", "static", "function", "faceQueryBuilder", "(", "Config", "$", "config", "=", "null", ")", "{", "if", "(", "null", "==", "$", "config", ")", "{", "return", "new", "SelectBuilder", "(", "self", "::", "getEntityFace", "(", ")", ")", ";", "}", "else", "{", "return", "new", "SelectBuilder", "(", "self", "::", "getEntityFace", "(", "$", "config", "->", "getFaceLoader", "(", ")", ")", ")", ";", "}", "}" ]
Shortcut to construct a FQuery @return SelectBuilder
[ "Shortcut", "to", "construct", "a", "FQuery" ]
85b412c66ff41d0fe73b7e7b69bc9a5ac5f7f428
https://github.com/face-orm/face/blob/85b412c66ff41d0fe73b7e7b69bc9a5ac5f7f428/lib/Face/Traits/EntityFaceTrait.php#L190-L197
2,647
face-orm/face
lib/Face/Traits/EntityFaceTrait.php
EntityFaceTrait.faceQueryBy
public static function faceQueryBy($item, $itemValue, $pdo) { if (self::getEntityFace()->getDirectElement($item)) { $fQuery = self::faceQueryBuilder(); if (is_array($itemValue)) { $fQuery->whereIN("~$item", $itemValue); } else { $fQuery->where("~$item=:itemValue") ->bindValue(":itemValue", $itemValue); } return ORM::execute($fQuery, $pdo); } }
php
public static function faceQueryBy($item, $itemValue, $pdo) { if (self::getEntityFace()->getDirectElement($item)) { $fQuery = self::faceQueryBuilder(); if (is_array($itemValue)) { $fQuery->whereIN("~$item", $itemValue); } else { $fQuery->where("~$item=:itemValue") ->bindValue(":itemValue", $itemValue); } return ORM::execute($fQuery, $pdo); } }
[ "public", "static", "function", "faceQueryBy", "(", "$", "item", ",", "$", "itemValue", ",", "$", "pdo", ")", "{", "if", "(", "self", "::", "getEntityFace", "(", ")", "->", "getDirectElement", "(", "$", "item", ")", ")", "{", "$", "fQuery", "=", "self", "::", "faceQueryBuilder", "(", ")", ";", "if", "(", "is_array", "(", "$", "itemValue", ")", ")", "{", "$", "fQuery", "->", "whereIN", "(", "\"~$item\"", ",", "$", "itemValue", ")", ";", "}", "else", "{", "$", "fQuery", "->", "where", "(", "\"~$item=:itemValue\"", ")", "->", "bindValue", "(", "\":itemValue\"", ",", "$", "itemValue", ")", ";", "}", "return", "ORM", "::", "execute", "(", "$", "fQuery", ",", "$", "pdo", ")", ";", "}", "}" ]
Fast querying by only specifying one field @param $item string name of the item (without the leading tild) e.g : "id" @param $itemValue string|array value to find. You may specify an array to use an WHERE item IN (...) instead of WHERE item = ... @param $pdo @return \Face\Sql\Result\ResultSet
[ "Fast", "querying", "by", "only", "specifying", "one", "field" ]
85b412c66ff41d0fe73b7e7b69bc9a5ac5f7f428
https://github.com/face-orm/face/blob/85b412c66ff41d0fe73b7e7b69bc9a5ac5f7f428/lib/Face/Traits/EntityFaceTrait.php#L206-L221
2,648
face-orm/face
lib/Face/Traits/EntityFaceTrait.php
EntityFaceTrait.queryString
public static function queryString($string, $options = []) { $joins = []; $selectedColumns = []; // if (is_array($options)) { // if (isset($options["join"])) { // foreach ($options["join"] as $j) { // $joins["this.$j"] = self::getEntityFace()->getElement($j)->getFace(); // } // } // // if (isset($options["select"])) { // foreach ($options["select"] as $k => $j) { // $basePath = is_numeric($k) ? $j : $k; // // if (!StringUtils::beginsWith("this", $basePath)) { // $basePath = "this." . $basePath; // } // // $basePath = substr($basePath, 0, strrpos($basePath, ".")); // // self::__queryStringDoColumnRecursive($selectedColumns, $k, $j, $basePath); // // // } // } // // } $qS = new \Face\Sql\Query\QueryString(self::getEntityFace(), $string, $joins, $selectedColumns); return $qS; }
php
public static function queryString($string, $options = []) { $joins = []; $selectedColumns = []; // if (is_array($options)) { // if (isset($options["join"])) { // foreach ($options["join"] as $j) { // $joins["this.$j"] = self::getEntityFace()->getElement($j)->getFace(); // } // } // // if (isset($options["select"])) { // foreach ($options["select"] as $k => $j) { // $basePath = is_numeric($k) ? $j : $k; // // if (!StringUtils::beginsWith("this", $basePath)) { // $basePath = "this." . $basePath; // } // // $basePath = substr($basePath, 0, strrpos($basePath, ".")); // // self::__queryStringDoColumnRecursive($selectedColumns, $k, $j, $basePath); // // // } // } // // } $qS = new \Face\Sql\Query\QueryString(self::getEntityFace(), $string, $joins, $selectedColumns); return $qS; }
[ "public", "static", "function", "queryString", "(", "$", "string", ",", "$", "options", "=", "[", "]", ")", "{", "$", "joins", "=", "[", "]", ";", "$", "selectedColumns", "=", "[", "]", ";", "// if (is_array($options)) {", "// if (isset($options[\"join\"])) {", "// foreach ($options[\"join\"] as $j) {", "// $joins[\"this.$j\"] = self::getEntityFace()->getElement($j)->getFace();", "// }", "// }", "//", "// if (isset($options[\"select\"])) {", "// foreach ($options[\"select\"] as $k => $j) {", "// $basePath = is_numeric($k) ? $j : $k;", "//", "// if (!StringUtils::beginsWith(\"this\", $basePath)) {", "// $basePath = \"this.\" . $basePath;", "// }", "//", "// $basePath = substr($basePath, 0, strrpos($basePath, \".\"));", "//", "// self::__queryStringDoColumnRecursive($selectedColumns, $k, $j, $basePath);", "//", "//", "// }", "// }", "//", "// }", "$", "qS", "=", "new", "\\", "Face", "\\", "Sql", "\\", "Query", "\\", "QueryString", "(", "self", "::", "getEntityFace", "(", ")", ",", "$", "string", ",", "$", "joins", ",", "$", "selectedColumns", ")", ";", "return", "$", "qS", ";", "}" ]
shortcut to create a @see \Face\Sql\Query\QueryString @param string $string the SQL query @param array $options fields to select and It doesnt work anymore, to be fixed in 1.0
[ "shortcut", "to", "create", "a" ]
85b412c66ff41d0fe73b7e7b69bc9a5ac5f7f428
https://github.com/face-orm/face/blob/85b412c66ff41d0fe73b7e7b69bc9a5ac5f7f428/lib/Face/Traits/EntityFaceTrait.php#L228-L262
2,649
sgoendoer/sonic
examples/AccessControlManagerExample.php
AccessControlManagerExample.loadAccessControlRulesForUOID
protected function loadAccessControlRulesForUOID($gid, $uoid) { $rules = array(); if($gid == '28B6TE8T9NUO202C5NZIUTNQSP88E70B8JAWH4FQ58OJOB8LIF' && $uoid =='4802C8DE6UZZ5BICQI830A8P8BW3YB5EBPGXWNRH1EP7H838V7:a9ddbc2102bf86d1') { $rules[] = (new AccessControlRuleObjectBuilder()) ->owner(Sonic::getContextGlobalID()) ->index(1) ->directive(AccessControlRuleObject::DIRECTIVE_ALLOW) ->entityType(AccessControlRuleObject::ENTITY_TYPE_INDIVIDUAL) ->entityID('28B6TE8T9NUO202C5NZIUTNQSP88E70B8JAWH4FQ58OJOB8LIF') // use Bob's GID ->targetType(AccessControlRuleObject::TARGET_TYPE_CONTENT) ->target('4802C8DE6UZZ5BICQI830A8P8BW3YB5EBPGXWNRH1EP7H838V7:a9ddbc2102bf86d1') // Alice's person object ->accessType(AccessControlRuleObject::WILDCARD) ->build(); } return $rules; }
php
protected function loadAccessControlRulesForUOID($gid, $uoid) { $rules = array(); if($gid == '28B6TE8T9NUO202C5NZIUTNQSP88E70B8JAWH4FQ58OJOB8LIF' && $uoid =='4802C8DE6UZZ5BICQI830A8P8BW3YB5EBPGXWNRH1EP7H838V7:a9ddbc2102bf86d1') { $rules[] = (new AccessControlRuleObjectBuilder()) ->owner(Sonic::getContextGlobalID()) ->index(1) ->directive(AccessControlRuleObject::DIRECTIVE_ALLOW) ->entityType(AccessControlRuleObject::ENTITY_TYPE_INDIVIDUAL) ->entityID('28B6TE8T9NUO202C5NZIUTNQSP88E70B8JAWH4FQ58OJOB8LIF') // use Bob's GID ->targetType(AccessControlRuleObject::TARGET_TYPE_CONTENT) ->target('4802C8DE6UZZ5BICQI830A8P8BW3YB5EBPGXWNRH1EP7H838V7:a9ddbc2102bf86d1') // Alice's person object ->accessType(AccessControlRuleObject::WILDCARD) ->build(); } return $rules; }
[ "protected", "function", "loadAccessControlRulesForUOID", "(", "$", "gid", ",", "$", "uoid", ")", "{", "$", "rules", "=", "array", "(", ")", ";", "if", "(", "$", "gid", "==", "'28B6TE8T9NUO202C5NZIUTNQSP88E70B8JAWH4FQ58OJOB8LIF'", "&&", "$", "uoid", "==", "'4802C8DE6UZZ5BICQI830A8P8BW3YB5EBPGXWNRH1EP7H838V7:a9ddbc2102bf86d1'", ")", "{", "$", "rules", "[", "]", "=", "(", "new", "AccessControlRuleObjectBuilder", "(", ")", ")", "->", "owner", "(", "Sonic", "::", "getContextGlobalID", "(", ")", ")", "->", "index", "(", "1", ")", "->", "directive", "(", "AccessControlRuleObject", "::", "DIRECTIVE_ALLOW", ")", "->", "entityType", "(", "AccessControlRuleObject", "::", "ENTITY_TYPE_INDIVIDUAL", ")", "->", "entityID", "(", "'28B6TE8T9NUO202C5NZIUTNQSP88E70B8JAWH4FQ58OJOB8LIF'", ")", "// use Bob's GID", "->", "targetType", "(", "AccessControlRuleObject", "::", "TARGET_TYPE_CONTENT", ")", "->", "target", "(", "'4802C8DE6UZZ5BICQI830A8P8BW3YB5EBPGXWNRH1EP7H838V7:a9ddbc2102bf86d1'", ")", "// Alice's person object", "->", "accessType", "(", "AccessControlRuleObject", "::", "WILDCARD", ")", "->", "build", "(", ")", ";", "}", "return", "$", "rules", ";", "}" ]
for demonstration purposes, only one rule is created for a specific data object for a specific user @param $gid The GlobalID requesting entitiy @param $uoid The UOID of the content or wildcard (*) @return array of AccessControlRuleObjects, NULL if no rules were found
[ "for", "demonstration", "purposes", "only", "one", "rule", "is", "created", "for", "a", "specific", "data", "object", "for", "a", "specific", "user" ]
2c32ebd78607dc3e8558f10a0b7bf881d37fc168
https://github.com/sgoendoer/sonic/blob/2c32ebd78607dc3e8558f10a0b7bf881d37fc168/examples/AccessControlManagerExample.php#L19-L38
2,650
samsonos/cms_app_field
src/CMSField.php
CMSField.getParentClasses
public static function getParentClasses($className) { $result = array(); $class = new \ReflectionClass($className); if( false === $class ) { return $result; } do { $name = $class->getName(); $result[] = $name; $class = $class->getParentClass(); } while( false !== $class ); return $result; }
php
public static function getParentClasses($className) { $result = array(); $class = new \ReflectionClass($className); if( false === $class ) { return $result; } do { $name = $class->getName(); $result[] = $name; $class = $class->getParentClass(); } while( false !== $class ); return $result; }
[ "public", "static", "function", "getParentClasses", "(", "$", "className", ")", "{", "$", "result", "=", "array", "(", ")", ";", "$", "class", "=", "new", "\\", "ReflectionClass", "(", "$", "className", ")", ";", "if", "(", "false", "===", "$", "class", ")", "{", "return", "$", "result", ";", "}", "do", "{", "$", "name", "=", "$", "class", "->", "getName", "(", ")", ";", "$", "result", "[", "]", "=", "$", "name", ";", "$", "class", "=", "$", "class", "->", "getParentClass", "(", ")", ";", "}", "while", "(", "false", "!==", "$", "class", ")", ";", "return", "$", "result", ";", "}" ]
Get all class names of passed class @param $className @return array
[ "Get", "all", "class", "names", "of", "passed", "class" ]
7040f2889858491d43ae77534e78f5676ae80a78
https://github.com/samsonos/cms_app_field/blob/7040f2889858491d43ae77534e78f5676ae80a78/src/CMSField.php#L78-L90
2,651
samsonos/cms_app_field
src/CMSField.php
CMSField.update
public function update($structureID = 0) { // Fill the fields from $_POST array foreach ($_POST as $key => $val) { $this[$key]=$val; } $this->save(); /** @var \samson\cms\web\navigation\CMSNav $cmsnav */ // If isset current structure if (dbQuery('\samson\cms\web\navigation\CMSNav')->id($structureID)->first($cmsnav)) { // If structure has not relation with current field if (!dbQuery('structurefield')->StructureID($cmsnav->id)->FieldID($this->id)->first()) { // Create new relation between structure and field $strField = new \samson\activerecord\structurefield(false); $strField->FieldID = $this->id; $strField->StructureID = $cmsnav->id; $strField->Active = 1; // Save relation $strField->save(); } } }
php
public function update($structureID = 0) { // Fill the fields from $_POST array foreach ($_POST as $key => $val) { $this[$key]=$val; } $this->save(); /** @var \samson\cms\web\navigation\CMSNav $cmsnav */ // If isset current structure if (dbQuery('\samson\cms\web\navigation\CMSNav')->id($structureID)->first($cmsnav)) { // If structure has not relation with current field if (!dbQuery('structurefield')->StructureID($cmsnav->id)->FieldID($this->id)->first()) { // Create new relation between structure and field $strField = new \samson\activerecord\structurefield(false); $strField->FieldID = $this->id; $strField->StructureID = $cmsnav->id; $strField->Active = 1; // Save relation $strField->save(); } } }
[ "public", "function", "update", "(", "$", "structureID", "=", "0", ")", "{", "// Fill the fields from $_POST array", "foreach", "(", "$", "_POST", "as", "$", "key", "=>", "$", "val", ")", "{", "$", "this", "[", "$", "key", "]", "=", "$", "val", ";", "}", "$", "this", "->", "save", "(", ")", ";", "/** @var \\samson\\cms\\web\\navigation\\CMSNav $cmsnav */", "// If isset current structure", "if", "(", "dbQuery", "(", "'\\samson\\cms\\web\\navigation\\CMSNav'", ")", "->", "id", "(", "$", "structureID", ")", "->", "first", "(", "$", "cmsnav", ")", ")", "{", "// If structure has not relation with current field", "if", "(", "!", "dbQuery", "(", "'structurefield'", ")", "->", "StructureID", "(", "$", "cmsnav", "->", "id", ")", "->", "FieldID", "(", "$", "this", "->", "id", ")", "->", "first", "(", ")", ")", "{", "// Create new relation between structure and field", "$", "strField", "=", "new", "\\", "samson", "\\", "activerecord", "\\", "structurefield", "(", "false", ")", ";", "$", "strField", "->", "FieldID", "=", "$", "this", "->", "id", ";", "$", "strField", "->", "StructureID", "=", "$", "cmsnav", "->", "id", ";", "$", "strField", "->", "Active", "=", "1", ";", "// Save relation", "$", "strField", "->", "save", "(", ")", ";", "}", "}", "}" ]
Updating field and creating relation with structure @param int $structureID
[ "Updating", "field", "and", "creating", "relation", "with", "structure" ]
7040f2889858491d43ae77534e78f5676ae80a78
https://github.com/samsonos/cms_app_field/blob/7040f2889858491d43ae77534e78f5676ae80a78/src/CMSField.php#L117-L143
2,652
easy-system/es-view-helpers
src/Helper/Placeholder.php
Placeholder.setCaptureType
public function setCaptureType($type) { if ($type === static::SET || $type === static::APPEND || $type === static::PREPEND ) { $this->captureType = $type; return $this; } throw new InvalidArgumentException(sprintf( 'Invalid capture type provided; must be any of the capture ' . 'type constants, "%s" received.', is_scalar($type) ? $type : gettype($type) )); }
php
public function setCaptureType($type) { if ($type === static::SET || $type === static::APPEND || $type === static::PREPEND ) { $this->captureType = $type; return $this; } throw new InvalidArgumentException(sprintf( 'Invalid capture type provided; must be any of the capture ' . 'type constants, "%s" received.', is_scalar($type) ? $type : gettype($type) )); }
[ "public", "function", "setCaptureType", "(", "$", "type", ")", "{", "if", "(", "$", "type", "===", "static", "::", "SET", "||", "$", "type", "===", "static", "::", "APPEND", "||", "$", "type", "===", "static", "::", "PREPEND", ")", "{", "$", "this", "->", "captureType", "=", "$", "type", ";", "return", "$", "this", ";", "}", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'Invalid capture type provided; must be any of the capture '", ".", "'type constants, \"%s\" received.'", ",", "is_scalar", "(", "$", "type", ")", "?", "$", "type", ":", "gettype", "(", "$", "type", ")", ")", ")", ";", "}" ]
Sets the type of capture. @param string $type Any of the capture type constants @throws \InvalidArgumentException If invalid capture type provided @return self
[ "Sets", "the", "type", "of", "capture", "." ]
39755d07dea63d525fb85d989bb095c89d805e9a
https://github.com/easy-system/es-view-helpers/blob/39755d07dea63d525fb85d989bb095c89d805e9a/src/Helper/Placeholder.php#L131-L147
2,653
easy-system/es-view-helpers
src/Helper/Placeholder.php
Placeholder.attach
public function attach($value, $capture = null) { if (null === $capture) { $capture = $this->captureType; } switch ($capture) { case self::APPEND: $this->append($value); break; case self::PREPEND: $this->prepend($value); break; case self::SET: $this->set($value); break; default: throw new InvalidArgumentException(sprintf( 'Invalid capture type provided; must be any of the capture ' . 'type constants, "%s" received.', is_scalar($capture) ? $capture : gettype($capture) )); } return $this; }
php
public function attach($value, $capture = null) { if (null === $capture) { $capture = $this->captureType; } switch ($capture) { case self::APPEND: $this->append($value); break; case self::PREPEND: $this->prepend($value); break; case self::SET: $this->set($value); break; default: throw new InvalidArgumentException(sprintf( 'Invalid capture type provided; must be any of the capture ' . 'type constants, "%s" received.', is_scalar($capture) ? $capture : gettype($capture) )); } return $this; }
[ "public", "function", "attach", "(", "$", "value", ",", "$", "capture", "=", "null", ")", "{", "if", "(", "null", "===", "$", "capture", ")", "{", "$", "capture", "=", "$", "this", "->", "captureType", ";", "}", "switch", "(", "$", "capture", ")", "{", "case", "self", "::", "APPEND", ":", "$", "this", "->", "append", "(", "$", "value", ")", ";", "break", ";", "case", "self", "::", "PREPEND", ":", "$", "this", "->", "prepend", "(", "$", "value", ")", ";", "break", ";", "case", "self", "::", "SET", ":", "$", "this", "->", "set", "(", "$", "value", ")", ";", "break", ";", "default", ":", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'Invalid capture type provided; must be any of the capture '", ".", "'type constants, \"%s\" received.'", ",", "is_scalar", "(", "$", "capture", ")", "?", "$", "capture", ":", "gettype", "(", "$", "capture", ")", ")", ")", ";", "}", "return", "$", "this", ";", "}" ]
Attaches the value. @param mixed $value The value @param null|string $capture Optional; any of the capture type constants @throws \InvalidArgumentException If invalid capture type provided @return self
[ "Attaches", "the", "value", "." ]
39755d07dea63d525fb85d989bb095c89d805e9a
https://github.com/easy-system/es-view-helpers/blob/39755d07dea63d525fb85d989bb095c89d805e9a/src/Helper/Placeholder.php#L347-L372
2,654
easy-system/es-view-helpers
src/Helper/Placeholder.php
Placeholder.captureStart
public function captureStart($type = null) { if ($this->captureStarted) { throw new RuntimeException('Capture is already started.'); } if (null !== $type) { $this->setCaptureType($type); } $this->captureStarted = true; ob_start(); return $this; }
php
public function captureStart($type = null) { if ($this->captureStarted) { throw new RuntimeException('Capture is already started.'); } if (null !== $type) { $this->setCaptureType($type); } $this->captureStarted = true; ob_start(); return $this; }
[ "public", "function", "captureStart", "(", "$", "type", "=", "null", ")", "{", "if", "(", "$", "this", "->", "captureStarted", ")", "{", "throw", "new", "RuntimeException", "(", "'Capture is already started.'", ")", ";", "}", "if", "(", "null", "!==", "$", "type", ")", "{", "$", "this", "->", "setCaptureType", "(", "$", "type", ")", ";", "}", "$", "this", "->", "captureStarted", "=", "true", ";", "ob_start", "(", ")", ";", "return", "$", "this", ";", "}" ]
Starts the capture. @param null|string $type Optional; any of the capture type constants @throws \RuntimeException If capture is already started @return self
[ "Starts", "the", "capture", "." ]
39755d07dea63d525fb85d989bb095c89d805e9a
https://github.com/easy-system/es-view-helpers/blob/39755d07dea63d525fb85d989bb095c89d805e9a/src/Helper/Placeholder.php#L393-L406
2,655
easy-system/es-view-helpers
src/Helper/Placeholder.php
Placeholder.captureEnd
public function captureEnd(array $params = []) { if (! $this->captureStarted) { throw new RuntimeException('Capture has not been started.'); } $params['capture'] = ob_get_clean(); $this->attach($params); $this->captureStarted = false; return $this; }
php
public function captureEnd(array $params = []) { if (! $this->captureStarted) { throw new RuntimeException('Capture has not been started.'); } $params['capture'] = ob_get_clean(); $this->attach($params); $this->captureStarted = false; return $this; }
[ "public", "function", "captureEnd", "(", "array", "$", "params", "=", "[", "]", ")", "{", "if", "(", "!", "$", "this", "->", "captureStarted", ")", "{", "throw", "new", "RuntimeException", "(", "'Capture has not been started.'", ")", ";", "}", "$", "params", "[", "'capture'", "]", "=", "ob_get_clean", "(", ")", ";", "$", "this", "->", "attach", "(", "$", "params", ")", ";", "$", "this", "->", "captureStarted", "=", "false", ";", "return", "$", "this", ";", "}" ]
Ends the capture. @param array $params Optional; the capture parameters @throws \RuntimeException If the capture has not been started @return self
[ "Ends", "the", "capture", "." ]
39755d07dea63d525fb85d989bb095c89d805e9a
https://github.com/easy-system/es-view-helpers/blob/39755d07dea63d525fb85d989bb095c89d805e9a/src/Helper/Placeholder.php#L417-L427
2,656
easy-system/es-view-helpers
src/Helper/Placeholder.php
Placeholder.toString
public function toString($indent = null) { $indent = ($indent !== null) ? $this->getWhitespace($indent) : $this->getIndent(); $return = $this->prefix; $keys = array_keys($this->container); $lastIndex = end($keys); foreach ($this->container as $index => $item) { $item = array_merge($this->defaultParams, (array) $item); $return .= vsprintf($this->wrapper, $item); if ($index !== $lastIndex) { $return .= $this->separator; } } $return .= $this->postfix; return preg_replace("/(\r\n?|\n)[ ]*/", '$1' . $indent, $return); }
php
public function toString($indent = null) { $indent = ($indent !== null) ? $this->getWhitespace($indent) : $this->getIndent(); $return = $this->prefix; $keys = array_keys($this->container); $lastIndex = end($keys); foreach ($this->container as $index => $item) { $item = array_merge($this->defaultParams, (array) $item); $return .= vsprintf($this->wrapper, $item); if ($index !== $lastIndex) { $return .= $this->separator; } } $return .= $this->postfix; return preg_replace("/(\r\n?|\n)[ ]*/", '$1' . $indent, $return); }
[ "public", "function", "toString", "(", "$", "indent", "=", "null", ")", "{", "$", "indent", "=", "(", "$", "indent", "!==", "null", ")", "?", "$", "this", "->", "getWhitespace", "(", "$", "indent", ")", ":", "$", "this", "->", "getIndent", "(", ")", ";", "$", "return", "=", "$", "this", "->", "prefix", ";", "$", "keys", "=", "array_keys", "(", "$", "this", "->", "container", ")", ";", "$", "lastIndex", "=", "end", "(", "$", "keys", ")", ";", "foreach", "(", "$", "this", "->", "container", "as", "$", "index", "=>", "$", "item", ")", "{", "$", "item", "=", "array_merge", "(", "$", "this", "->", "defaultParams", ",", "(", "array", ")", "$", "item", ")", ";", "$", "return", ".=", "vsprintf", "(", "$", "this", "->", "wrapper", ",", "$", "item", ")", ";", "if", "(", "$", "index", "!==", "$", "lastIndex", ")", "{", "$", "return", ".=", "$", "this", "->", "separator", ";", "}", "}", "$", "return", ".=", "$", "this", "->", "postfix", ";", "return", "preg_replace", "(", "\"/(\\r\\n?|\\n)[ ]*/\"", ",", "'$1'", ".", "$", "indent", ",", "$", "return", ")", ";", "}" ]
Renders the placeholder. @param null|string|int $indent Optional; the indent @return string The string representation of placeholder
[ "Renders", "the", "placeholder", "." ]
39755d07dea63d525fb85d989bb095c89d805e9a
https://github.com/easy-system/es-view-helpers/blob/39755d07dea63d525fb85d989bb095c89d805e9a/src/Helper/Placeholder.php#L452-L471
2,657
flipbox/skeleton
src/Helpers/ArrayHelper.php
ArrayHelper.getFirstValue
public static function getFirstValue($arr) { if (count($arr)) { if (isset($arr[0])) { return $arr[0]; } else { $keys = array_keys($arr); return $arr[$keys[0]]; } } return null; }
php
public static function getFirstValue($arr) { if (count($arr)) { if (isset($arr[0])) { return $arr[0]; } else { $keys = array_keys($arr); return $arr[$keys[0]]; } } return null; }
[ "public", "static", "function", "getFirstValue", "(", "$", "arr", ")", "{", "if", "(", "count", "(", "$", "arr", ")", ")", "{", "if", "(", "isset", "(", "$", "arr", "[", "0", "]", ")", ")", "{", "return", "$", "arr", "[", "0", "]", ";", "}", "else", "{", "$", "keys", "=", "array_keys", "(", "$", "arr", ")", ";", "return", "$", "arr", "[", "$", "keys", "[", "0", "]", "]", ";", "}", "}", "return", "null", ";", "}" ]
Returns the first value in a given array. @param $arr @return mixed
[ "Returns", "the", "first", "value", "in", "a", "given", "array", "." ]
98ed2a8f4c201f34135e6573f3071b2a75a67907
https://github.com/flipbox/skeleton/blob/98ed2a8f4c201f34135e6573f3071b2a75a67907/src/Helpers/ArrayHelper.php#L228-L240
2,658
flipbox/skeleton
src/Helpers/ArrayHelper.php
ArrayHelper.matches
public static function matches($keys = [], $array = []): array { if (!empty($keys) && !empty($array)) { $matchingProperties = []; foreach ($keys as $property) { if ($matchedAttribute = static::getValue($array, $property)) { $matchingProperties[$property] = $matchedAttribute; } } return $matchingProperties; } return $array; }
php
public static function matches($keys = [], $array = []): array { if (!empty($keys) && !empty($array)) { $matchingProperties = []; foreach ($keys as $property) { if ($matchedAttribute = static::getValue($array, $property)) { $matchingProperties[$property] = $matchedAttribute; } } return $matchingProperties; } return $array; }
[ "public", "static", "function", "matches", "(", "$", "keys", "=", "[", "]", ",", "$", "array", "=", "[", "]", ")", ":", "array", "{", "if", "(", "!", "empty", "(", "$", "keys", ")", "&&", "!", "empty", "(", "$", "array", ")", ")", "{", "$", "matchingProperties", "=", "[", "]", ";", "foreach", "(", "$", "keys", "as", "$", "property", ")", "{", "if", "(", "$", "matchedAttribute", "=", "static", "::", "getValue", "(", "$", "array", ",", "$", "property", ")", ")", "{", "$", "matchingProperties", "[", "$", "property", "]", "=", "$", "matchedAttribute", ";", "}", "}", "return", "$", "matchingProperties", ";", "}", "return", "$", "array", ";", "}" ]
Finds matching values from two arrays @param array $keys @param array $array @return array
[ "Finds", "matching", "values", "from", "two", "arrays" ]
98ed2a8f4c201f34135e6573f3071b2a75a67907
https://github.com/flipbox/skeleton/blob/98ed2a8f4c201f34135e6573f3071b2a75a67907/src/Helpers/ArrayHelper.php#L250-L265
2,659
joffreydemetz/registry
src/Registry.php
Registry.set
public function set($path, $value) { $old = null; if ( $nodes = explode('.', $path) ){ $node = $this->data; for($i=0, $n=count($nodes)-1; $i<$n; $i++){ if ( !isset($node->{$nodes[$i]}) && ($i != $n) ){ $node->{$nodes[$i]} = new \stdClass; } $node = $node->{$nodes[$i]}; } if ( isset($node->{$nodes[$i]}) ){ $old = $node->{$nodes[$i]}; } $node->{$nodes[$i]} = $value; } return $old; }
php
public function set($path, $value) { $old = null; if ( $nodes = explode('.', $path) ){ $node = $this->data; for($i=0, $n=count($nodes)-1; $i<$n; $i++){ if ( !isset($node->{$nodes[$i]}) && ($i != $n) ){ $node->{$nodes[$i]} = new \stdClass; } $node = $node->{$nodes[$i]}; } if ( isset($node->{$nodes[$i]}) ){ $old = $node->{$nodes[$i]}; } $node->{$nodes[$i]} = $value; } return $old; }
[ "public", "function", "set", "(", "$", "path", ",", "$", "value", ")", "{", "$", "old", "=", "null", ";", "if", "(", "$", "nodes", "=", "explode", "(", "'.'", ",", "$", "path", ")", ")", "{", "$", "node", "=", "$", "this", "->", "data", ";", "for", "(", "$", "i", "=", "0", ",", "$", "n", "=", "count", "(", "$", "nodes", ")", "-", "1", ";", "$", "i", "<", "$", "n", ";", "$", "i", "++", ")", "{", "if", "(", "!", "isset", "(", "$", "node", "->", "{", "$", "nodes", "[", "$", "i", "]", "}", ")", "&&", "(", "$", "i", "!=", "$", "n", ")", ")", "{", "$", "node", "->", "{", "$", "nodes", "[", "$", "i", "]", "}", "=", "new", "\\", "stdClass", ";", "}", "$", "node", "=", "$", "node", "->", "{", "$", "nodes", "[", "$", "i", "]", "}", ";", "}", "if", "(", "isset", "(", "$", "node", "->", "{", "$", "nodes", "[", "$", "i", "]", "}", ")", ")", "{", "$", "old", "=", "$", "node", "->", "{", "$", "nodes", "[", "$", "i", "]", "}", ";", "}", "$", "node", "->", "{", "$", "nodes", "[", "$", "i", "]", "}", "=", "$", "value", ";", "}", "return", "$", "old", ";", "}" ]
Set a registry value @param string $path Registry Path (e.g. joomla.content.showauthor) @param mixed $value Value of entry @return mixed The value of the that has been set
[ "Set", "a", "registry", "value" ]
b96f1a78f04871f62deb1187f54b80a742b17938
https://github.com/joffreydemetz/registry/blob/b96f1a78f04871f62deb1187f54b80a742b17938/src/Registry.php#L128-L148
2,660
joffreydemetz/registry
src/Registry.php
Registry.bindData
protected function bindData(&$parent, $data) { if ( is_object($data) ){ $data = get_object_vars($data); } else { $data = (array) $data; } foreach($data as $k => $v){ if ( (is_array($v) && ArrayHelper::isAssociative($v)) || is_object($v) ){ $parent->$k = new \stdClass; $this->bindData($parent->$k, $v); } else { $parent->$k = $v; } } }
php
protected function bindData(&$parent, $data) { if ( is_object($data) ){ $data = get_object_vars($data); } else { $data = (array) $data; } foreach($data as $k => $v){ if ( (is_array($v) && ArrayHelper::isAssociative($v)) || is_object($v) ){ $parent->$k = new \stdClass; $this->bindData($parent->$k, $v); } else { $parent->$k = $v; } } }
[ "protected", "function", "bindData", "(", "&", "$", "parent", ",", "$", "data", ")", "{", "if", "(", "is_object", "(", "$", "data", ")", ")", "{", "$", "data", "=", "get_object_vars", "(", "$", "data", ")", ";", "}", "else", "{", "$", "data", "=", "(", "array", ")", "$", "data", ";", "}", "foreach", "(", "$", "data", "as", "$", "k", "=>", "$", "v", ")", "{", "if", "(", "(", "is_array", "(", "$", "v", ")", "&&", "ArrayHelper", "::", "isAssociative", "(", "$", "v", ")", ")", "||", "is_object", "(", "$", "v", ")", ")", "{", "$", "parent", "->", "$", "k", "=", "new", "\\", "stdClass", ";", "$", "this", "->", "bindData", "(", "$", "parent", "->", "$", "k", ",", "$", "v", ")", ";", "}", "else", "{", "$", "parent", "->", "$", "k", "=", "$", "v", ";", "}", "}", "}" ]
Recursively bind data to a parent object @param object &$parent The parent object on which to attach the data values @param mixed $data An array or object of data to bind to the parent object @return void
[ "Recursively", "bind", "data", "to", "a", "parent", "object" ]
b96f1a78f04871f62deb1187f54b80a742b17938
https://github.com/joffreydemetz/registry/blob/b96f1a78f04871f62deb1187f54b80a742b17938/src/Registry.php#L248-L266
2,661
joffreydemetz/registry
src/Registry.php
Registry.asArray
protected function asArray($data) { $array = []; foreach(get_object_vars((object)$data) as $k => $v){ if ( is_object($v) ){ $array[$k] = $this->asArray($v); } else { $array[$k] = $v; } } return $array; }
php
protected function asArray($data) { $array = []; foreach(get_object_vars((object)$data) as $k => $v){ if ( is_object($v) ){ $array[$k] = $this->asArray($v); } else { $array[$k] = $v; } } return $array; }
[ "protected", "function", "asArray", "(", "$", "data", ")", "{", "$", "array", "=", "[", "]", ";", "foreach", "(", "get_object_vars", "(", "(", "object", ")", "$", "data", ")", "as", "$", "k", "=>", "$", "v", ")", "{", "if", "(", "is_object", "(", "$", "v", ")", ")", "{", "$", "array", "[", "$", "k", "]", "=", "$", "this", "->", "asArray", "(", "$", "v", ")", ";", "}", "else", "{", "$", "array", "[", "$", "k", "]", "=", "$", "v", ";", "}", "}", "return", "$", "array", ";", "}" ]
Recursively convert an object of data to an array. @param object $data An object of data to return as an array. @return array Array representation of the input object.
[ "Recursively", "convert", "an", "object", "of", "data", "to", "an", "array", "." ]
b96f1a78f04871f62deb1187f54b80a742b17938
https://github.com/joffreydemetz/registry/blob/b96f1a78f04871f62deb1187f54b80a742b17938/src/Registry.php#L367-L381
2,662
InnoGr/FivePercent-Api
src/EventListener/LoggerSubscriber.php
LoggerSubscriber.onPreDispatch
public function onPreDispatch(ActionDispatchEvent $event) { $message = sprintf( 'Match callable "%s" for action "%s".', Reflection::getCalledMethod($event->getCallable()->getReflection()), $event->getAction()->getName() ); $this->logger->debug($message); }
php
public function onPreDispatch(ActionDispatchEvent $event) { $message = sprintf( 'Match callable "%s" for action "%s".', Reflection::getCalledMethod($event->getCallable()->getReflection()), $event->getAction()->getName() ); $this->logger->debug($message); }
[ "public", "function", "onPreDispatch", "(", "ActionDispatchEvent", "$", "event", ")", "{", "$", "message", "=", "sprintf", "(", "'Match callable \"%s\" for action \"%s\".'", ",", "Reflection", "::", "getCalledMethod", "(", "$", "event", "->", "getCallable", "(", ")", "->", "getReflection", "(", ")", ")", ",", "$", "event", "->", "getAction", "(", ")", "->", "getName", "(", ")", ")", ";", "$", "this", "->", "logger", "->", "debug", "(", "$", "message", ")", ";", "}" ]
On pre dispatch event @param ActionDispatchEvent $event
[ "On", "pre", "dispatch", "event" ]
57b78ddc3c9d91a7139c276711e5792824ceab9c
https://github.com/InnoGr/FivePercent-Api/blob/57b78ddc3c9d91a7139c276711e5792824ceab9c/src/EventListener/LoggerSubscriber.php#L49-L58
2,663
InnoGr/FivePercent-Api
src/EventListener/LoggerSubscriber.php
LoggerSubscriber.onPostDispatch
public function onPostDispatch(ActionDispatchEvent $event) { $message = sprintf( 'Complete handle API method "%s". Response object: %s', $event->getAction()->getName(), get_class($event->getResponse()) ); $this->logger->debug($message); }
php
public function onPostDispatch(ActionDispatchEvent $event) { $message = sprintf( 'Complete handle API method "%s". Response object: %s', $event->getAction()->getName(), get_class($event->getResponse()) ); $this->logger->debug($message); }
[ "public", "function", "onPostDispatch", "(", "ActionDispatchEvent", "$", "event", ")", "{", "$", "message", "=", "sprintf", "(", "'Complete handle API method \"%s\". Response object: %s'", ",", "$", "event", "->", "getAction", "(", ")", "->", "getName", "(", ")", ",", "get_class", "(", "$", "event", "->", "getResponse", "(", ")", ")", ")", ";", "$", "this", "->", "logger", "->", "debug", "(", "$", "message", ")", ";", "}" ]
On post dispatch @param ActionDispatchEvent $event
[ "On", "post", "dispatch" ]
57b78ddc3c9d91a7139c276711e5792824ceab9c
https://github.com/InnoGr/FivePercent-Api/blob/57b78ddc3c9d91a7139c276711e5792824ceab9c/src/EventListener/LoggerSubscriber.php#L65-L74
2,664
InnoGr/FivePercent-Api
src/EventListener/LoggerSubscriber.php
LoggerSubscriber.onView
public function onView(ActionViewEvent $event) { $message = sprintf( 'The action "%s" return not ResponseInterface instance. Try create Response instance via result data...', $event->getAction()->getName() ); $this->logger->debug($message); }
php
public function onView(ActionViewEvent $event) { $message = sprintf( 'The action "%s" return not ResponseInterface instance. Try create Response instance via result data...', $event->getAction()->getName() ); $this->logger->debug($message); }
[ "public", "function", "onView", "(", "ActionViewEvent", "$", "event", ")", "{", "$", "message", "=", "sprintf", "(", "'The action \"%s\" return not ResponseInterface instance. Try create Response instance via result data...'", ",", "$", "event", "->", "getAction", "(", ")", "->", "getName", "(", ")", ")", ";", "$", "this", "->", "logger", "->", "debug", "(", "$", "message", ")", ";", "}" ]
On view event @param ActionViewEvent $event
[ "On", "view", "event" ]
57b78ddc3c9d91a7139c276711e5792824ceab9c
https://github.com/InnoGr/FivePercent-Api/blob/57b78ddc3c9d91a7139c276711e5792824ceab9c/src/EventListener/LoggerSubscriber.php#L81-L89
2,665
las93/attila
Attila/lib/Entity.php
Entity.autoLoadEntity
public static function autoLoadEntity($sEntity, array $aSql, $sPrefix = '', $bAddOnStdClass = false, $sEntityNamespace = null) { if ($sEntity === '') { return; } if ($sEntityNamespace !== null) { self::setEntityNamespace($sEntityNamespace); } $sEntityName = self::$_sEntityNamespace.$sEntity; if (!class_exists($sEntityName)) { return; } $oEntityCall = new $sEntityName; $oReflectionClass = new \ReflectionClass($sEntityName); $oReflectionProperties = $oReflectionClass->getProperties(); foreach ($oReflectionProperties as $aProperty) { if (preg_match('/@map ([a-zA-Z_]+)/', $aProperty->getDocComment(), $aMatch)) { $sEntitieRealName = $aMatch[1]; } else { $sEntitieRealName = $aProperty->getName(); } if (method_exists($oEntityCall, 'set_'.$aProperty->getName())) { if (isset($aSql[$sPrefix.$sEntitieRealName])) { $sMethodName = 'set_'.$aProperty->getName(); $oEntityCall->$sMethodName($aSql[$sPrefix.$sEntitieRealName]); } } } if ($bAddOnStdClass === true) { foreach ($aSql as $sKey => $asField) { if (preg_match('/^\.[^.]+$/', $sKey)) { $sParameterName = str_replace('.', '', $sKey); $oEntityCall->$sParameterName = $aSql[$sKey]; } } } return $oEntityCall; }
php
public static function autoLoadEntity($sEntity, array $aSql, $sPrefix = '', $bAddOnStdClass = false, $sEntityNamespace = null) { if ($sEntity === '') { return; } if ($sEntityNamespace !== null) { self::setEntityNamespace($sEntityNamespace); } $sEntityName = self::$_sEntityNamespace.$sEntity; if (!class_exists($sEntityName)) { return; } $oEntityCall = new $sEntityName; $oReflectionClass = new \ReflectionClass($sEntityName); $oReflectionProperties = $oReflectionClass->getProperties(); foreach ($oReflectionProperties as $aProperty) { if (preg_match('/@map ([a-zA-Z_]+)/', $aProperty->getDocComment(), $aMatch)) { $sEntitieRealName = $aMatch[1]; } else { $sEntitieRealName = $aProperty->getName(); } if (method_exists($oEntityCall, 'set_'.$aProperty->getName())) { if (isset($aSql[$sPrefix.$sEntitieRealName])) { $sMethodName = 'set_'.$aProperty->getName(); $oEntityCall->$sMethodName($aSql[$sPrefix.$sEntitieRealName]); } } } if ($bAddOnStdClass === true) { foreach ($aSql as $sKey => $asField) { if (preg_match('/^\.[^.]+$/', $sKey)) { $sParameterName = str_replace('.', '', $sKey); $oEntityCall->$sParameterName = $aSql[$sKey]; } } } return $oEntityCall; }
[ "public", "static", "function", "autoLoadEntity", "(", "$", "sEntity", ",", "array", "$", "aSql", ",", "$", "sPrefix", "=", "''", ",", "$", "bAddOnStdClass", "=", "false", ",", "$", "sEntityNamespace", "=", "null", ")", "{", "if", "(", "$", "sEntity", "===", "''", ")", "{", "return", ";", "}", "if", "(", "$", "sEntityNamespace", "!==", "null", ")", "{", "self", "::", "setEntityNamespace", "(", "$", "sEntityNamespace", ")", ";", "}", "$", "sEntityName", "=", "self", "::", "$", "_sEntityNamespace", ".", "$", "sEntity", ";", "if", "(", "!", "class_exists", "(", "$", "sEntityName", ")", ")", "{", "return", ";", "}", "$", "oEntityCall", "=", "new", "$", "sEntityName", ";", "$", "oReflectionClass", "=", "new", "\\", "ReflectionClass", "(", "$", "sEntityName", ")", ";", "$", "oReflectionProperties", "=", "$", "oReflectionClass", "->", "getProperties", "(", ")", ";", "foreach", "(", "$", "oReflectionProperties", "as", "$", "aProperty", ")", "{", "if", "(", "preg_match", "(", "'/@map ([a-zA-Z_]+)/'", ",", "$", "aProperty", "->", "getDocComment", "(", ")", ",", "$", "aMatch", ")", ")", "{", "$", "sEntitieRealName", "=", "$", "aMatch", "[", "1", "]", ";", "}", "else", "{", "$", "sEntitieRealName", "=", "$", "aProperty", "->", "getName", "(", ")", ";", "}", "if", "(", "method_exists", "(", "$", "oEntityCall", ",", "'set_'", ".", "$", "aProperty", "->", "getName", "(", ")", ")", ")", "{", "if", "(", "isset", "(", "$", "aSql", "[", "$", "sPrefix", ".", "$", "sEntitieRealName", "]", ")", ")", "{", "$", "sMethodName", "=", "'set_'", ".", "$", "aProperty", "->", "getName", "(", ")", ";", "$", "oEntityCall", "->", "$", "sMethodName", "(", "$", "aSql", "[", "$", "sPrefix", ".", "$", "sEntitieRealName", "]", ")", ";", "}", "}", "}", "if", "(", "$", "bAddOnStdClass", "===", "true", ")", "{", "foreach", "(", "$", "aSql", "as", "$", "sKey", "=>", "$", "asField", ")", "{", "if", "(", "preg_match", "(", "'/^\\.[^.]+$/'", ",", "$", "sKey", ")", ")", "{", "$", "sParameterName", "=", "str_replace", "(", "'.'", ",", "''", ",", "$", "sKey", ")", ";", "$", "oEntityCall", "->", "$", "sParameterName", "=", "$", "aSql", "[", "$", "sKey", "]", ";", "}", "}", "}", "return", "$", "oEntityCall", ";", "}" ]
auto load the domain by a sql return exemple : autoLoadDomain('GenericUpdate', array('Generic_Message' => 'OK', 'Generic_Result' => 1), 'Generic'); A domain is an container of properties, getters and setters without crud methods (just a container) You could give an object in entry!!! @access public @param string $sEntity domain that we want load @param array $aSql results in array by the sql array('id' => 1, 'title' => 'super'); @param string $sPrefix prefixe for the sql returns @param bool $bAddOnStdClass add the parameter when there arent method of entity @param string $sEntityNamespace change the default portal for the entity @return object
[ "auto", "load", "the", "domain", "by", "a", "sql", "return" ]
ad73611956ee96a95170a6340f110a948cfe5965
https://github.com/las93/attila/blob/ad73611956ee96a95170a6340f110a948cfe5965/Attila/lib/Entity.php#L70-L121
2,666
las93/attila
Attila/lib/Entity.php
Entity.getAllEntity
public static function getAllEntity($oEntityCall, $bReturnNotNulOnly = false) { if (!is_object($oEntityCall)) { return array(); } $oReflectionClass = new \ReflectionClass(get_class($oEntityCall)); $oReflectionMethod = $oReflectionClass->getMethods(); $aFieldsToReturn = array(); foreach ($oReflectionMethod as $aMethod) { if (preg_match('/^get_[a-zA-Z_]+/', $aMethod->getName())) { $sMethodsCall = $aMethod->getName(); $sFieldName = preg_replace('/^get_/', '', $aMethod->getName()); if ($oEntityCall->$sMethodsCall() !== null || ($oEntityCall->$sMethodsCall() === null && $bReturnNotNulOnly === false)) { $aFieldsToReturn[$sFieldName] = $oEntityCall->$sMethodsCall(); } } } $oReflectionProperties = $oReflectionClass->getProperties(); foreach ($oEntityCall as $sKey => $aProperty) { $aFieldsToReturn[$sKey] = self::getAllEntity($aProperty, $bReturnNotNulOnly); } return $aFieldsToReturn; }
php
public static function getAllEntity($oEntityCall, $bReturnNotNulOnly = false) { if (!is_object($oEntityCall)) { return array(); } $oReflectionClass = new \ReflectionClass(get_class($oEntityCall)); $oReflectionMethod = $oReflectionClass->getMethods(); $aFieldsToReturn = array(); foreach ($oReflectionMethod as $aMethod) { if (preg_match('/^get_[a-zA-Z_]+/', $aMethod->getName())) { $sMethodsCall = $aMethod->getName(); $sFieldName = preg_replace('/^get_/', '', $aMethod->getName()); if ($oEntityCall->$sMethodsCall() !== null || ($oEntityCall->$sMethodsCall() === null && $bReturnNotNulOnly === false)) { $aFieldsToReturn[$sFieldName] = $oEntityCall->$sMethodsCall(); } } } $oReflectionProperties = $oReflectionClass->getProperties(); foreach ($oEntityCall as $sKey => $aProperty) { $aFieldsToReturn[$sKey] = self::getAllEntity($aProperty, $bReturnNotNulOnly); } return $aFieldsToReturn; }
[ "public", "static", "function", "getAllEntity", "(", "$", "oEntityCall", ",", "$", "bReturnNotNulOnly", "=", "false", ")", "{", "if", "(", "!", "is_object", "(", "$", "oEntityCall", ")", ")", "{", "return", "array", "(", ")", ";", "}", "$", "oReflectionClass", "=", "new", "\\", "ReflectionClass", "(", "get_class", "(", "$", "oEntityCall", ")", ")", ";", "$", "oReflectionMethod", "=", "$", "oReflectionClass", "->", "getMethods", "(", ")", ";", "$", "aFieldsToReturn", "=", "array", "(", ")", ";", "foreach", "(", "$", "oReflectionMethod", "as", "$", "aMethod", ")", "{", "if", "(", "preg_match", "(", "'/^get_[a-zA-Z_]+/'", ",", "$", "aMethod", "->", "getName", "(", ")", ")", ")", "{", "$", "sMethodsCall", "=", "$", "aMethod", "->", "getName", "(", ")", ";", "$", "sFieldName", "=", "preg_replace", "(", "'/^get_/'", ",", "''", ",", "$", "aMethod", "->", "getName", "(", ")", ")", ";", "if", "(", "$", "oEntityCall", "->", "$", "sMethodsCall", "(", ")", "!==", "null", "||", "(", "$", "oEntityCall", "->", "$", "sMethodsCall", "(", ")", "===", "null", "&&", "$", "bReturnNotNulOnly", "===", "false", ")", ")", "{", "$", "aFieldsToReturn", "[", "$", "sFieldName", "]", "=", "$", "oEntityCall", "->", "$", "sMethodsCall", "(", ")", ";", "}", "}", "}", "$", "oReflectionProperties", "=", "$", "oReflectionClass", "->", "getProperties", "(", ")", ";", "foreach", "(", "$", "oEntityCall", "as", "$", "sKey", "=>", "$", "aProperty", ")", "{", "$", "aFieldsToReturn", "[", "$", "sKey", "]", "=", "self", "::", "getAllEntity", "(", "$", "aProperty", ",", "$", "bReturnNotNulOnly", ")", ";", "}", "return", "$", "aFieldsToReturn", ";", "}" ]
get all field of entity in array @access public @param object $oEntityCall domain that we want load @param bool $bReturnNotNulOnly if we return the null response @return array
[ "get", "all", "field", "of", "entity", "in", "array" ]
ad73611956ee96a95170a6340f110a948cfe5965
https://github.com/las93/attila/blob/ad73611956ee96a95170a6340f110a948cfe5965/Attila/lib/Entity.php#L131-L162
2,667
praxigento/mobi_mod_wallet
Plugin/Magento/Quote/Model/Quote/Relation.php
Relation.aroundProcessRelation
public function aroundProcessRelation( \Magento\Quote\Model\Quote\Relation $subject, \Closure $proceed, \Magento\Framework\Model\AbstractModel $object ) { $proceed($object); assert($object instanceof \Magento\Quote\Model\Quote); $quoteId = $object->getId(); /** @var \Magento\Quote\Model\Quote\Address $addrShipping */ $addrShipping = $object->getShippingAddress(); $total = $addrShipping->getData(\Praxigento\Wallet\Model\Quote\Address\Total\Partial::CODE_TOTAL); $baseTotal = $addrShipping->getData(\Praxigento\Wallet\Model\Quote\Address\Total\Partial::CODE_BASE_TOTAL); /* check if current total exist */ /** @var \Praxigento\Wallet\Repo\Data\Partial\Quote $exist */ $exist = $this->daoPartialQuote->getById($quoteId); if ($exist) { /* there is record in registry */ $baseTotalExist = $exist->getBasePartialAmount(); if ($baseTotalExist == $baseTotal) { /* amount is equal to stored, do nothing */ } elseif (abs($baseTotal) < Cfg::DEF_ZERO) { /* amount is zero, remove data from registry */ $this->daoPartialQuote->deleteById($quoteId); } else { /* update saved value */ $exist->setPartialAmount($total); $exist->setBasePartialAmount($baseTotal); $this->daoPartialQuote->updateById($quoteId, $exist); } } elseif (abs($baseTotal) > Cfg::DEF_ZERO) { /* create new record in registry */ $baseCurr = $object->getBaseCurrencyCode(); $curr = $object->getQuoteCurrencyCode(); $data = new \Praxigento\Wallet\Repo\Data\Partial\Quote(); $data->setQuoteRef($quoteId); $data->setPartialAmount($total); $data->setCurrency($curr); $data->setBasePartialAmount($baseTotal); $data->setBaseCurrency($baseCurr); $this->daoPartialQuote->create($data); } }
php
public function aroundProcessRelation( \Magento\Quote\Model\Quote\Relation $subject, \Closure $proceed, \Magento\Framework\Model\AbstractModel $object ) { $proceed($object); assert($object instanceof \Magento\Quote\Model\Quote); $quoteId = $object->getId(); /** @var \Magento\Quote\Model\Quote\Address $addrShipping */ $addrShipping = $object->getShippingAddress(); $total = $addrShipping->getData(\Praxigento\Wallet\Model\Quote\Address\Total\Partial::CODE_TOTAL); $baseTotal = $addrShipping->getData(\Praxigento\Wallet\Model\Quote\Address\Total\Partial::CODE_BASE_TOTAL); /* check if current total exist */ /** @var \Praxigento\Wallet\Repo\Data\Partial\Quote $exist */ $exist = $this->daoPartialQuote->getById($quoteId); if ($exist) { /* there is record in registry */ $baseTotalExist = $exist->getBasePartialAmount(); if ($baseTotalExist == $baseTotal) { /* amount is equal to stored, do nothing */ } elseif (abs($baseTotal) < Cfg::DEF_ZERO) { /* amount is zero, remove data from registry */ $this->daoPartialQuote->deleteById($quoteId); } else { /* update saved value */ $exist->setPartialAmount($total); $exist->setBasePartialAmount($baseTotal); $this->daoPartialQuote->updateById($quoteId, $exist); } } elseif (abs($baseTotal) > Cfg::DEF_ZERO) { /* create new record in registry */ $baseCurr = $object->getBaseCurrencyCode(); $curr = $object->getQuoteCurrencyCode(); $data = new \Praxigento\Wallet\Repo\Data\Partial\Quote(); $data->setQuoteRef($quoteId); $data->setPartialAmount($total); $data->setCurrency($curr); $data->setBasePartialAmount($baseTotal); $data->setBaseCurrency($baseCurr); $this->daoPartialQuote->create($data); } }
[ "public", "function", "aroundProcessRelation", "(", "\\", "Magento", "\\", "Quote", "\\", "Model", "\\", "Quote", "\\", "Relation", "$", "subject", ",", "\\", "Closure", "$", "proceed", ",", "\\", "Magento", "\\", "Framework", "\\", "Model", "\\", "AbstractModel", "$", "object", ")", "{", "$", "proceed", "(", "$", "object", ")", ";", "assert", "(", "$", "object", "instanceof", "\\", "Magento", "\\", "Quote", "\\", "Model", "\\", "Quote", ")", ";", "$", "quoteId", "=", "$", "object", "->", "getId", "(", ")", ";", "/** @var \\Magento\\Quote\\Model\\Quote\\Address $addrShipping */", "$", "addrShipping", "=", "$", "object", "->", "getShippingAddress", "(", ")", ";", "$", "total", "=", "$", "addrShipping", "->", "getData", "(", "\\", "Praxigento", "\\", "Wallet", "\\", "Model", "\\", "Quote", "\\", "Address", "\\", "Total", "\\", "Partial", "::", "CODE_TOTAL", ")", ";", "$", "baseTotal", "=", "$", "addrShipping", "->", "getData", "(", "\\", "Praxigento", "\\", "Wallet", "\\", "Model", "\\", "Quote", "\\", "Address", "\\", "Total", "\\", "Partial", "::", "CODE_BASE_TOTAL", ")", ";", "/* check if current total exist */", "/** @var \\Praxigento\\Wallet\\Repo\\Data\\Partial\\Quote $exist */", "$", "exist", "=", "$", "this", "->", "daoPartialQuote", "->", "getById", "(", "$", "quoteId", ")", ";", "if", "(", "$", "exist", ")", "{", "/* there is record in registry */", "$", "baseTotalExist", "=", "$", "exist", "->", "getBasePartialAmount", "(", ")", ";", "if", "(", "$", "baseTotalExist", "==", "$", "baseTotal", ")", "{", "/* amount is equal to stored, do nothing */", "}", "elseif", "(", "abs", "(", "$", "baseTotal", ")", "<", "Cfg", "::", "DEF_ZERO", ")", "{", "/* amount is zero, remove data from registry */", "$", "this", "->", "daoPartialQuote", "->", "deleteById", "(", "$", "quoteId", ")", ";", "}", "else", "{", "/* update saved value */", "$", "exist", "->", "setPartialAmount", "(", "$", "total", ")", ";", "$", "exist", "->", "setBasePartialAmount", "(", "$", "baseTotal", ")", ";", "$", "this", "->", "daoPartialQuote", "->", "updateById", "(", "$", "quoteId", ",", "$", "exist", ")", ";", "}", "}", "elseif", "(", "abs", "(", "$", "baseTotal", ")", ">", "Cfg", "::", "DEF_ZERO", ")", "{", "/* create new record in registry */", "$", "baseCurr", "=", "$", "object", "->", "getBaseCurrencyCode", "(", ")", ";", "$", "curr", "=", "$", "object", "->", "getQuoteCurrencyCode", "(", ")", ";", "$", "data", "=", "new", "\\", "Praxigento", "\\", "Wallet", "\\", "Repo", "\\", "Data", "\\", "Partial", "\\", "Quote", "(", ")", ";", "$", "data", "->", "setQuoteRef", "(", "$", "quoteId", ")", ";", "$", "data", "->", "setPartialAmount", "(", "$", "total", ")", ";", "$", "data", "->", "setCurrency", "(", "$", "curr", ")", ";", "$", "data", "->", "setBasePartialAmount", "(", "$", "baseTotal", ")", ";", "$", "data", "->", "setBaseCurrency", "(", "$", "baseCurr", ")", ";", "$", "this", "->", "daoPartialQuote", "->", "create", "(", "$", "data", ")", ";", "}", "}" ]
Process original relations then save partial payment totals. @param \Magento\Quote\Model\Quote\Relation $subject @param \Closure $proceed @param \Magento\Framework\Model\AbstractModel $object @SuppressWarnings(PHPMD.UnusedFormalParameter)
[ "Process", "original", "relations", "then", "save", "partial", "payment", "totals", "." ]
8f4789645f2e3c95b1323984aa67215b1647fa39
https://github.com/praxigento/mobi_mod_wallet/blob/8f4789645f2e3c95b1323984aa67215b1647fa39/Plugin/Magento/Quote/Model/Quote/Relation.php#L33-L74
2,668
praxisnetau/silverware-google
src/API/GoogleAPI.php
GoogleAPI.getAPIKey
public function getAPIKey() { $key = SiteConfig::current_site_config()->GoogleAPIKey; if (!$key) { $key = self::config()->api_key; } return $key; }
php
public function getAPIKey() { $key = SiteConfig::current_site_config()->GoogleAPIKey; if (!$key) { $key = self::config()->api_key; } return $key; }
[ "public", "function", "getAPIKey", "(", ")", "{", "$", "key", "=", "SiteConfig", "::", "current_site_config", "(", ")", "->", "GoogleAPIKey", ";", "if", "(", "!", "$", "key", ")", "{", "$", "key", "=", "self", "::", "config", "(", ")", "->", "api_key", ";", "}", "return", "$", "key", ";", "}" ]
Answers the API key from site or YAML configuration. @return string
[ "Answers", "the", "API", "key", "from", "site", "or", "YAML", "configuration", "." ]
573632d33fe99c9d943fec8733fa5bbce57586f5
https://github.com/praxisnetau/silverware-google/blob/573632d33fe99c9d943fec8733fa5bbce57586f5/src/API/GoogleAPI.php#L43-L52
2,669
praxisnetau/silverware-google
src/API/GoogleAPI.php
GoogleAPI.getAPILanguage
public function getAPILanguage() { $lang = SiteConfig::current_site_config()->GoogleAPILanguage; if (!$lang) { $lang = self::config()->api_language; } return $lang; }
php
public function getAPILanguage() { $lang = SiteConfig::current_site_config()->GoogleAPILanguage; if (!$lang) { $lang = self::config()->api_language; } return $lang; }
[ "public", "function", "getAPILanguage", "(", ")", "{", "$", "lang", "=", "SiteConfig", "::", "current_site_config", "(", ")", "->", "GoogleAPILanguage", ";", "if", "(", "!", "$", "lang", ")", "{", "$", "lang", "=", "self", "::", "config", "(", ")", "->", "api_language", ";", "}", "return", "$", "lang", ";", "}" ]
Answers the API language from site or YAML configuration. @return string
[ "Answers", "the", "API", "language", "from", "site", "or", "YAML", "configuration", "." ]
573632d33fe99c9d943fec8733fa5bbce57586f5
https://github.com/praxisnetau/silverware-google/blob/573632d33fe99c9d943fec8733fa5bbce57586f5/src/API/GoogleAPI.php#L69-L78
2,670
praxisnetau/silverware-google
src/API/GoogleAPI.php
GoogleAPI.getAnalyticsTrackingID
public function getAnalyticsTrackingID() { $id = SiteConfig::current_site_config()->GoogleAnalyticsTrackingID; if (!$id) { $id = self::config()->analytics_tracking_id; } return $id; }
php
public function getAnalyticsTrackingID() { $id = SiteConfig::current_site_config()->GoogleAnalyticsTrackingID; if (!$id) { $id = self::config()->analytics_tracking_id; } return $id; }
[ "public", "function", "getAnalyticsTrackingID", "(", ")", "{", "$", "id", "=", "SiteConfig", "::", "current_site_config", "(", ")", "->", "GoogleAnalyticsTrackingID", ";", "if", "(", "!", "$", "id", ")", "{", "$", "id", "=", "self", "::", "config", "(", ")", "->", "analytics_tracking_id", ";", "}", "return", "$", "id", ";", "}" ]
Answers the analytics tracking ID from site or YAML configuration. @return string
[ "Answers", "the", "analytics", "tracking", "ID", "from", "site", "or", "YAML", "configuration", "." ]
573632d33fe99c9d943fec8733fa5bbce57586f5
https://github.com/praxisnetau/silverware-google/blob/573632d33fe99c9d943fec8733fa5bbce57586f5/src/API/GoogleAPI.php#L85-L94
2,671
praxisnetau/silverware-google
src/API/GoogleAPI.php
GoogleAPI.getVerificationCode
public function getVerificationCode() { $code = SiteConfig::current_site_config()->GoogleVerificationCode; if (!$code) { $code = self::config()->verification_code; } return $code; }
php
public function getVerificationCode() { $code = SiteConfig::current_site_config()->GoogleVerificationCode; if (!$code) { $code = self::config()->verification_code; } return $code; }
[ "public", "function", "getVerificationCode", "(", ")", "{", "$", "code", "=", "SiteConfig", "::", "current_site_config", "(", ")", "->", "GoogleVerificationCode", ";", "if", "(", "!", "$", "code", ")", "{", "$", "code", "=", "self", "::", "config", "(", ")", "->", "verification_code", ";", "}", "return", "$", "code", ";", "}" ]
Answers the site verification code from site or YAML configuration. @return string
[ "Answers", "the", "site", "verification", "code", "from", "site", "or", "YAML", "configuration", "." ]
573632d33fe99c9d943fec8733fa5bbce57586f5
https://github.com/praxisnetau/silverware-google/blob/573632d33fe99c9d943fec8733fa5bbce57586f5/src/API/GoogleAPI.php#L101-L110
2,672
praxisnetau/silverware-google
src/API/GoogleAPI.php
GoogleAPI.isAnalyticsEnabled
public function isAnalyticsEnabled() { $enabled = SiteConfig::current_site_config()->GoogleAnalyticsEnabled; if (!$enabled) { $enabled = self::config()->analytics_enabled; } return (boolean) $enabled; }
php
public function isAnalyticsEnabled() { $enabled = SiteConfig::current_site_config()->GoogleAnalyticsEnabled; if (!$enabled) { $enabled = self::config()->analytics_enabled; } return (boolean) $enabled; }
[ "public", "function", "isAnalyticsEnabled", "(", ")", "{", "$", "enabled", "=", "SiteConfig", "::", "current_site_config", "(", ")", "->", "GoogleAnalyticsEnabled", ";", "if", "(", "!", "$", "enabled", ")", "{", "$", "enabled", "=", "self", "::", "config", "(", ")", "->", "analytics_enabled", ";", "}", "return", "(", "boolean", ")", "$", "enabled", ";", "}" ]
Answers true if analytics is enabled for the site. @return boolean
[ "Answers", "true", "if", "analytics", "is", "enabled", "for", "the", "site", "." ]
573632d33fe99c9d943fec8733fa5bbce57586f5
https://github.com/praxisnetau/silverware-google/blob/573632d33fe99c9d943fec8733fa5bbce57586f5/src/API/GoogleAPI.php#L117-L126
2,673
philiplb/CRUDlexUser
src/CRUDlex/UserProvider.php
UserProvider.loadUserRolesViaData
protected function loadUserRolesViaData($userId) { $crudRoles = $this->userRoleIdentifier->listEntries(['user' => $userId], ['user' => '=']); $roles = ['ROLE_USER']; if ($crudRoles !== null) { foreach ($crudRoles as $crudRole) { $role = $crudRole->get('role'); $roles[] = $role['name']; } } return $roles; }
php
protected function loadUserRolesViaData($userId) { $crudRoles = $this->userRoleIdentifier->listEntries(['user' => $userId], ['user' => '=']); $roles = ['ROLE_USER']; if ($crudRoles !== null) { foreach ($crudRoles as $crudRole) { $role = $crudRole->get('role'); $roles[] = $role['name']; } } return $roles; }
[ "protected", "function", "loadUserRolesViaData", "(", "$", "userId", ")", "{", "$", "crudRoles", "=", "$", "this", "->", "userRoleIdentifier", "->", "listEntries", "(", "[", "'user'", "=>", "$", "userId", "]", ",", "[", "'user'", "=>", "'='", "]", ")", ";", "$", "roles", "=", "[", "'ROLE_USER'", "]", ";", "if", "(", "$", "crudRoles", "!==", "null", ")", "{", "foreach", "(", "$", "crudRoles", "as", "$", "crudRole", ")", "{", "$", "role", "=", "$", "crudRole", "->", "get", "(", "'role'", ")", ";", "$", "roles", "[", "]", "=", "$", "role", "[", "'name'", "]", ";", "}", "}", "return", "$", "roles", ";", "}" ]
Loads the roles of an user via an AbstractData instance. @param mixed $userId the id of the user @return string[] the roles of the user
[ "Loads", "the", "roles", "of", "an", "user", "via", "an", "AbstractData", "instance", "." ]
011c70106786ded665200a1b6b61234800c2b802
https://github.com/philiplb/CRUDlexUser/blob/011c70106786ded665200a1b6b61234800c2b802/src/CRUDlex/UserProvider.php#L65-L76
2,674
philiplb/CRUDlexUser
src/CRUDlex/UserProvider.php
UserProvider.loadUserRolesViaManyToMany
protected function loadUserRolesViaManyToMany($user) { $roles = ['ROLE_USER']; if (is_string($this->userRoleIdentifier)) { foreach ($user->get($this->userRoleIdentifier) as $role) { $roles[] = $role['name']; } } return $roles; }
php
protected function loadUserRolesViaManyToMany($user) { $roles = ['ROLE_USER']; if (is_string($this->userRoleIdentifier)) { foreach ($user->get($this->userRoleIdentifier) as $role) { $roles[] = $role['name']; } } return $roles; }
[ "protected", "function", "loadUserRolesViaManyToMany", "(", "$", "user", ")", "{", "$", "roles", "=", "[", "'ROLE_USER'", "]", ";", "if", "(", "is_string", "(", "$", "this", "->", "userRoleIdentifier", ")", ")", "{", "foreach", "(", "$", "user", "->", "get", "(", "$", "this", "->", "userRoleIdentifier", ")", "as", "$", "role", ")", "{", "$", "roles", "[", "]", "=", "$", "role", "[", "'name'", "]", ";", "}", "}", "return", "$", "roles", ";", "}" ]
Loads the roles of an user via a many-to-many relationship @param Entity $user the id of the user @return string[] the roles of the user
[ "Loads", "the", "roles", "of", "an", "user", "via", "a", "many", "-", "to", "-", "many", "relationship" ]
011c70106786ded665200a1b6b61234800c2b802
https://github.com/philiplb/CRUDlexUser/blob/011c70106786ded665200a1b6b61234800c2b802/src/CRUDlex/UserProvider.php#L87-L96
2,675
philiplb/CRUDlexUser
src/CRUDlex/UserProvider.php
UserProvider.loadUserByUsername
public function loadUserByUsername($username) { $users = $this->userData->listEntries([$this->usernameField => $username], [$this->usernameField => '='], 0, 1); if (count($users) === 0) { throw new UsernameNotFoundException(); } $user = $users[0]; $roles = is_string($this->userRoleIdentifier) ? $this->loadUserRolesViaManyToMany($user) : $this->loadUserRolesViaData($user->get('id')); $userObj = new User($this->usernameField, $this->passwordField, $this->saltField, $user, $roles); return $userObj; }
php
public function loadUserByUsername($username) { $users = $this->userData->listEntries([$this->usernameField => $username], [$this->usernameField => '='], 0, 1); if (count($users) === 0) { throw new UsernameNotFoundException(); } $user = $users[0]; $roles = is_string($this->userRoleIdentifier) ? $this->loadUserRolesViaManyToMany($user) : $this->loadUserRolesViaData($user->get('id')); $userObj = new User($this->usernameField, $this->passwordField, $this->saltField, $user, $roles); return $userObj; }
[ "public", "function", "loadUserByUsername", "(", "$", "username", ")", "{", "$", "users", "=", "$", "this", "->", "userData", "->", "listEntries", "(", "[", "$", "this", "->", "usernameField", "=>", "$", "username", "]", ",", "[", "$", "this", "->", "usernameField", "=>", "'='", "]", ",", "0", ",", "1", ")", ";", "if", "(", "count", "(", "$", "users", ")", "===", "0", ")", "{", "throw", "new", "UsernameNotFoundException", "(", ")", ";", "}", "$", "user", "=", "$", "users", "[", "0", "]", ";", "$", "roles", "=", "is_string", "(", "$", "this", "->", "userRoleIdentifier", ")", "?", "$", "this", "->", "loadUserRolesViaManyToMany", "(", "$", "user", ")", ":", "$", "this", "->", "loadUserRolesViaData", "(", "$", "user", "->", "get", "(", "'id'", ")", ")", ";", "$", "userObj", "=", "new", "User", "(", "$", "this", "->", "usernameField", ",", "$", "this", "->", "passwordField", ",", "$", "this", "->", "saltField", ",", "$", "user", ",", "$", "roles", ")", ";", "return", "$", "userObj", ";", "}" ]
Loads and returns an user by username. Throws an UsernameNotFoundException on not existing username. @param string $username the username @return User the loaded user
[ "Loads", "and", "returns", "an", "user", "by", "username", ".", "Throws", "an", "UsernameNotFoundException", "on", "not", "existing", "username", "." ]
011c70106786ded665200a1b6b61234800c2b802
https://github.com/philiplb/CRUDlexUser/blob/011c70106786ded665200a1b6b61234800c2b802/src/CRUDlex/UserProvider.php#L138-L151
2,676
diatem-net/jin-webapp
src/WebApp/Utils/Breadcrumb.php
Breadcrumb.add
public static function add($label, $urlCode = null, $addedArgs = array()) { self::$items[] = new BreadcrumbItem($label, $urlCode, $addedArgs); }
php
public static function add($label, $urlCode = null, $addedArgs = array()) { self::$items[] = new BreadcrumbItem($label, $urlCode, $addedArgs); }
[ "public", "static", "function", "add", "(", "$", "label", ",", "$", "urlCode", "=", "null", ",", "$", "addedArgs", "=", "array", "(", ")", ")", "{", "self", "::", "$", "items", "[", "]", "=", "new", "BreadcrumbItem", "(", "$", "label", ",", "$", "urlCode", ",", "$", "addedArgs", ")", ";", "}" ]
Add a new item to the breadcrumb @param string $label Label of the breadcrumb item @param string $urlCode (optional) Url code for the breadcrumb item @param array $addedArgs (optional) Additional arguments
[ "Add", "a", "new", "item", "to", "the", "breadcrumb" ]
43e85f780c3841a536e3a5d41929523e5aacd272
https://github.com/diatem-net/jin-webapp/blob/43e85f780c3841a536e3a5d41929523e5aacd272/src/WebApp/Utils/Breadcrumb.php#L27-L30
2,677
AnonymPHP/Anonym-Library
src/Anonym/Cron/Crontab/Crontab.php
Crontab.render
public function render() { $path = $this->resolvePathVariable(); $content = "PATH=$path \n". implode(PHP_EOL, $this->getJobs()); return $content; }
php
public function render() { $path = $this->resolvePathVariable(); $content = "PATH=$path \n". implode(PHP_EOL, $this->getJobs()); return $content; }
[ "public", "function", "render", "(", ")", "{", "$", "path", "=", "$", "this", "->", "resolvePathVariable", "(", ")", ";", "$", "content", "=", "\"PATH=$path \\n\"", ".", "implode", "(", "PHP_EOL", ",", "$", "this", "->", "getJobs", "(", ")", ")", ";", "return", "$", "content", ";", "}" ]
Render the crontab and associated jobs @return string
[ "Render", "the", "crontab", "and", "associated", "jobs" ]
c967ad804f84e8fb204593a0959cda2fed5ae075
https://github.com/AnonymPHP/Anonym-Library/blob/c967ad804f84e8fb204593a0959cda2fed5ae075/src/Anonym/Cron/Crontab/Crontab.php#L70-L75
2,678
AnonymPHP/Anonym-Library
src/Anonym/Cron/Crontab/Crontab.php
Crontab.jobExists
public function jobExists($job = '') { $process = new Process('crontab -l'); $process->run(); $output = ($process->getIncrementalOutput()); $jobs = array_filter(explode(PHP_EOL, $output), function($line) { return '' != trim($line); }); return is_array($jobs) ? array_search($job, $jobs) : false; }
php
public function jobExists($job = '') { $process = new Process('crontab -l'); $process->run(); $output = ($process->getIncrementalOutput()); $jobs = array_filter(explode(PHP_EOL, $output), function($line) { return '' != trim($line); }); return is_array($jobs) ? array_search($job, $jobs) : false; }
[ "public", "function", "jobExists", "(", "$", "job", "=", "''", ")", "{", "$", "process", "=", "new", "Process", "(", "'crontab -l'", ")", ";", "$", "process", "->", "run", "(", ")", ";", "$", "output", "=", "(", "$", "process", "->", "getIncrementalOutput", "(", ")", ")", ";", "$", "jobs", "=", "array_filter", "(", "explode", "(", "PHP_EOL", ",", "$", "output", ")", ",", "function", "(", "$", "line", ")", "{", "return", "''", "!=", "trim", "(", "$", "line", ")", ";", "}", ")", ";", "return", "is_array", "(", "$", "jobs", ")", "?", "array_search", "(", "$", "job", ",", "$", "jobs", ")", ":", "false", ";", "}" ]
search job in jobs @param string $job @return mixed
[ "search", "job", "in", "jobs" ]
c967ad804f84e8fb204593a0959cda2fed5ae075
https://github.com/AnonymPHP/Anonym-Library/blob/c967ad804f84e8fb204593a0959cda2fed5ae075/src/Anonym/Cron/Crontab/Crontab.php#L223-L235
2,679
kiler129/CherryHttp
src/_legacyCode/HttpRequest.php
HttpRequest.parseHeader
private function parseHeader($header) { //$this->logger->debug('Parsing request header'); $header = explode("\n", $header); //Now it contains header lines $statusLine = explode(' ', trim($header[0]), 3); //Eg.: GET /file HTTP/1.1 will be parsed into [GET, /file, HTTP/1.1] if (!isset($statusLine[2]) || substr($statusLine[2], 0, 5) !== 'HTTP/') { throw new HttpException('Request is not HTTP complaint.', HttpCode::BAD_REQUEST, array(), true); } if (isset($statusLine[1][self::MAX_URI_LENGTH])) { //Much faster than using strlen(...) > MAX_URI_LENGTH throw new HttpException('URI should be equal or less than ' . self::MAX_URI_LENGTH . ' characters', HttpCode::REQUEST_URI_TOO_LONG); } $this->method = $statusLine[0]; $fullUri = explode('?', $statusLine[1], 2); //URL + query string, eg. [/file, var1=test&var2=foo&bar=derp] $this->uri = $fullUri[0]; if (isset($fullUri[1])) { $this->queryString = $fullUri[1]; } $this->protocolVersion = substr($statusLine[2], 5); //Everything after HTTP/ is http version number if ($this->protocolVersion !== '1.1' && $this->protocolVersion !== '1.0') { throw new HttpException('Requested HTTP version is not supported', HttpCode::VERSION_NOT_SUPPORTED, array(), true); } unset($header[0]); //Status line $this->populateHeaders($header); //Everything left from header is actually http headers $this->isRequestCollected = true; //$this->logger->debug('Got HTTP headers, request is collected'); }
php
private function parseHeader($header) { //$this->logger->debug('Parsing request header'); $header = explode("\n", $header); //Now it contains header lines $statusLine = explode(' ', trim($header[0]), 3); //Eg.: GET /file HTTP/1.1 will be parsed into [GET, /file, HTTP/1.1] if (!isset($statusLine[2]) || substr($statusLine[2], 0, 5) !== 'HTTP/') { throw new HttpException('Request is not HTTP complaint.', HttpCode::BAD_REQUEST, array(), true); } if (isset($statusLine[1][self::MAX_URI_LENGTH])) { //Much faster than using strlen(...) > MAX_URI_LENGTH throw new HttpException('URI should be equal or less than ' . self::MAX_URI_LENGTH . ' characters', HttpCode::REQUEST_URI_TOO_LONG); } $this->method = $statusLine[0]; $fullUri = explode('?', $statusLine[1], 2); //URL + query string, eg. [/file, var1=test&var2=foo&bar=derp] $this->uri = $fullUri[0]; if (isset($fullUri[1])) { $this->queryString = $fullUri[1]; } $this->protocolVersion = substr($statusLine[2], 5); //Everything after HTTP/ is http version number if ($this->protocolVersion !== '1.1' && $this->protocolVersion !== '1.0') { throw new HttpException('Requested HTTP version is not supported', HttpCode::VERSION_NOT_SUPPORTED, array(), true); } unset($header[0]); //Status line $this->populateHeaders($header); //Everything left from header is actually http headers $this->isRequestCollected = true; //$this->logger->debug('Got HTTP headers, request is collected'); }
[ "private", "function", "parseHeader", "(", "$", "header", ")", "{", "//$this->logger->debug('Parsing request header');", "$", "header", "=", "explode", "(", "\"\\n\"", ",", "$", "header", ")", ";", "//Now it contains header lines", "$", "statusLine", "=", "explode", "(", "' '", ",", "trim", "(", "$", "header", "[", "0", "]", ")", ",", "3", ")", ";", "//Eg.: GET /file HTTP/1.1 will be parsed into [GET, /file, HTTP/1.1]", "if", "(", "!", "isset", "(", "$", "statusLine", "[", "2", "]", ")", "||", "substr", "(", "$", "statusLine", "[", "2", "]", ",", "0", ",", "5", ")", "!==", "'HTTP/'", ")", "{", "throw", "new", "HttpException", "(", "'Request is not HTTP complaint.'", ",", "HttpCode", "::", "BAD_REQUEST", ",", "array", "(", ")", ",", "true", ")", ";", "}", "if", "(", "isset", "(", "$", "statusLine", "[", "1", "]", "[", "self", "::", "MAX_URI_LENGTH", "]", ")", ")", "{", "//Much faster than using strlen(...) > MAX_URI_LENGTH", "throw", "new", "HttpException", "(", "'URI should be equal or less than '", ".", "self", "::", "MAX_URI_LENGTH", ".", "' characters'", ",", "HttpCode", "::", "REQUEST_URI_TOO_LONG", ")", ";", "}", "$", "this", "->", "method", "=", "$", "statusLine", "[", "0", "]", ";", "$", "fullUri", "=", "explode", "(", "'?'", ",", "$", "statusLine", "[", "1", "]", ",", "2", ")", ";", "//URL + query string, eg. [/file, var1=test&var2=foo&bar=derp]", "$", "this", "->", "uri", "=", "$", "fullUri", "[", "0", "]", ";", "if", "(", "isset", "(", "$", "fullUri", "[", "1", "]", ")", ")", "{", "$", "this", "->", "queryString", "=", "$", "fullUri", "[", "1", "]", ";", "}", "$", "this", "->", "protocolVersion", "=", "substr", "(", "$", "statusLine", "[", "2", "]", ",", "5", ")", ";", "//Everything after HTTP/ is http version number", "if", "(", "$", "this", "->", "protocolVersion", "!==", "'1.1'", "&&", "$", "this", "->", "protocolVersion", "!==", "'1.0'", ")", "{", "throw", "new", "HttpException", "(", "'Requested HTTP version is not supported'", ",", "HttpCode", "::", "VERSION_NOT_SUPPORTED", ",", "array", "(", ")", ",", "true", ")", ";", "}", "unset", "(", "$", "header", "[", "0", "]", ")", ";", "//Status line", "$", "this", "->", "populateHeaders", "(", "$", "header", ")", ";", "//Everything left from header is actually http headers", "$", "this", "->", "isRequestCollected", "=", "true", ";", "//$this->logger->debug('Got HTTP headers, request is collected');", "}" ]
Parses HTTP header & populates http headers @param string $header HTTP request header including status line & all headers @throws HttpException Raised if request header is not RFC-complaint
[ "Parses", "HTTP", "header", "&", "populates", "http", "headers" ]
05927f26183cbd6fd5ccb0853befecdea279308d
https://github.com/kiler129/CherryHttp/blob/05927f26183cbd6fd5ccb0853befecdea279308d/src/_legacyCode/HttpRequest.php#L44-L78
2,680
indigophp/hydra
src/Hydrator/Generated/Generator.php
Generator.getHydratorClass
public function getHydratorClass($class) { $inflector = $this->configuration->getInflector(); $realClass = $inflector->getUserClassName($class); $hydratorClass = $inflector->getGeneratedClassName($realClass, ['generator' => get_class($this)]); if (!class_exists($hydratorClass)) { $ast = $this->generateAst($realClass, $hydratorClass); $this->configuration->getGeneratorStrategy()->generate($ast); $this->configuration->getAutoloader()->__invoke($hydratorClass); } return $hydratorClass; }
php
public function getHydratorClass($class) { $inflector = $this->configuration->getInflector(); $realClass = $inflector->getUserClassName($class); $hydratorClass = $inflector->getGeneratedClassName($realClass, ['generator' => get_class($this)]); if (!class_exists($hydratorClass)) { $ast = $this->generateAst($realClass, $hydratorClass); $this->configuration->getGeneratorStrategy()->generate($ast); $this->configuration->getAutoloader()->__invoke($hydratorClass); } return $hydratorClass; }
[ "public", "function", "getHydratorClass", "(", "$", "class", ")", "{", "$", "inflector", "=", "$", "this", "->", "configuration", "->", "getInflector", "(", ")", ";", "$", "realClass", "=", "$", "inflector", "->", "getUserClassName", "(", "$", "class", ")", ";", "$", "hydratorClass", "=", "$", "inflector", "->", "getGeneratedClassName", "(", "$", "realClass", ",", "[", "'generator'", "=>", "get_class", "(", "$", "this", ")", "]", ")", ";", "if", "(", "!", "class_exists", "(", "$", "hydratorClass", ")", ")", "{", "$", "ast", "=", "$", "this", "->", "generateAst", "(", "$", "realClass", ",", "$", "hydratorClass", ")", ";", "$", "this", "->", "configuration", "->", "getGeneratorStrategy", "(", ")", "->", "generate", "(", "$", "ast", ")", ";", "$", "this", "->", "configuration", "->", "getAutoloader", "(", ")", "->", "__invoke", "(", "$", "hydratorClass", ")", ";", "}", "return", "$", "hydratorClass", ";", "}" ]
Returns a hydrator class for a class name @param string $class @return string
[ "Returns", "a", "hydrator", "class", "for", "a", "class", "name" ]
2d459fa4822cf88a9f46ce4eec78698d6eaa13a8
https://github.com/indigophp/hydra/blob/2d459fa4822cf88a9f46ce4eec78698d6eaa13a8/src/Hydrator/Generated/Generator.php#L54-L69
2,681
indigophp/hydra
src/Hydrator/Generated/Generator.php
Generator.generateAst
protected function generateAst($realClass, $hydratorClass) { $originalClass = new \ReflectionClass($realClass); $builder = new ClassBuilder; $traverser = new NodeTraverser; $ast = $builder->fromReflection($originalClass); // Remove unused methods $traverser->addVisitor(new MethodDisablerVisitor(function() { return false; })); // Implement new methods and interfaces, extend original class $this->addMethodVisitors($originalClass, $traverser); $traverser->addVisitor(new ClassExtensionVisitor($realClass, $realClass)); $traverser->addVisitor(new ClassImplementorVisitor($realClass, ['Indigo\\Hydra\\Hydrator'])); // Renames class $traverser->addVisitor(new ClassRenamerVisitor($originalClass, $hydratorClass)); return $traverser->traverse($ast); }
php
protected function generateAst($realClass, $hydratorClass) { $originalClass = new \ReflectionClass($realClass); $builder = new ClassBuilder; $traverser = new NodeTraverser; $ast = $builder->fromReflection($originalClass); // Remove unused methods $traverser->addVisitor(new MethodDisablerVisitor(function() { return false; })); // Implement new methods and interfaces, extend original class $this->addMethodVisitors($originalClass, $traverser); $traverser->addVisitor(new ClassExtensionVisitor($realClass, $realClass)); $traverser->addVisitor(new ClassImplementorVisitor($realClass, ['Indigo\\Hydra\\Hydrator'])); // Renames class $traverser->addVisitor(new ClassRenamerVisitor($originalClass, $hydratorClass)); return $traverser->traverse($ast); }
[ "protected", "function", "generateAst", "(", "$", "realClass", ",", "$", "hydratorClass", ")", "{", "$", "originalClass", "=", "new", "\\", "ReflectionClass", "(", "$", "realClass", ")", ";", "$", "builder", "=", "new", "ClassBuilder", ";", "$", "traverser", "=", "new", "NodeTraverser", ";", "$", "ast", "=", "$", "builder", "->", "fromReflection", "(", "$", "originalClass", ")", ";", "// Remove unused methods", "$", "traverser", "->", "addVisitor", "(", "new", "MethodDisablerVisitor", "(", "function", "(", ")", "{", "return", "false", ";", "}", ")", ")", ";", "// Implement new methods and interfaces, extend original class", "$", "this", "->", "addMethodVisitors", "(", "$", "originalClass", ",", "$", "traverser", ")", ";", "$", "traverser", "->", "addVisitor", "(", "new", "ClassExtensionVisitor", "(", "$", "realClass", ",", "$", "realClass", ")", ")", ";", "$", "traverser", "->", "addVisitor", "(", "new", "ClassImplementorVisitor", "(", "$", "realClass", ",", "[", "'Indigo\\\\Hydra\\\\Hydrator'", "]", ")", ")", ";", "// Renames class", "$", "traverser", "->", "addVisitor", "(", "new", "ClassRenamerVisitor", "(", "$", "originalClass", ",", "$", "hydratorClass", ")", ")", ";", "return", "$", "traverser", "->", "traverse", "(", "$", "ast", ")", ";", "}" ]
Generates an AST out of a given reflection class and a target hydrator name @param string $realClass @param string $hydratorClass @return \PhpParser\Node[]
[ "Generates", "an", "AST", "out", "of", "a", "given", "reflection", "class", "and", "a", "target", "hydrator", "name" ]
2d459fa4822cf88a9f46ce4eec78698d6eaa13a8
https://github.com/indigophp/hydra/blob/2d459fa4822cf88a9f46ce4eec78698d6eaa13a8/src/Hydrator/Generated/Generator.php#L79-L99
2,682
indigophp/hydra
src/Hydrator/Generated/Generator.php
Generator.addMethodVisitors
protected function addMethodVisitors(\ReflectionClass $originalClass, NodeTraverser $traverser) { $accessibleProperties = $this->getProperties( $originalClass, \ReflectionProperty::IS_PUBLIC | \ReflectionProperty::IS_PROTECTED ); $propertyWriters = $this->getPropertyWriters($originalClass); $traverser->addVisitor(new Visitor\ConstructorMethod($accessibleProperties, $propertyWriters)); $traverser->addVisitor(new Visitor\HydrateMethod($accessibleProperties, $propertyWriters)); $traverser->addVisitor(new Visitor\ExtractMethod($accessibleProperties, $propertyWriters)); }
php
protected function addMethodVisitors(\ReflectionClass $originalClass, NodeTraverser $traverser) { $accessibleProperties = $this->getProperties( $originalClass, \ReflectionProperty::IS_PUBLIC | \ReflectionProperty::IS_PROTECTED ); $propertyWriters = $this->getPropertyWriters($originalClass); $traverser->addVisitor(new Visitor\ConstructorMethod($accessibleProperties, $propertyWriters)); $traverser->addVisitor(new Visitor\HydrateMethod($accessibleProperties, $propertyWriters)); $traverser->addVisitor(new Visitor\ExtractMethod($accessibleProperties, $propertyWriters)); }
[ "protected", "function", "addMethodVisitors", "(", "\\", "ReflectionClass", "$", "originalClass", ",", "NodeTraverser", "$", "traverser", ")", "{", "$", "accessibleProperties", "=", "$", "this", "->", "getProperties", "(", "$", "originalClass", ",", "\\", "ReflectionProperty", "::", "IS_PUBLIC", "|", "\\", "ReflectionProperty", "::", "IS_PROTECTED", ")", ";", "$", "propertyWriters", "=", "$", "this", "->", "getPropertyWriters", "(", "$", "originalClass", ")", ";", "$", "traverser", "->", "addVisitor", "(", "new", "Visitor", "\\", "ConstructorMethod", "(", "$", "accessibleProperties", ",", "$", "propertyWriters", ")", ")", ";", "$", "traverser", "->", "addVisitor", "(", "new", "Visitor", "\\", "HydrateMethod", "(", "$", "accessibleProperties", ",", "$", "propertyWriters", ")", ")", ";", "$", "traverser", "->", "addVisitor", "(", "new", "Visitor", "\\", "ExtractMethod", "(", "$", "accessibleProperties", ",", "$", "propertyWriters", ")", ")", ";", "}" ]
Adds method visitors @param \ReflectionClass $originalClass @param NodeTraverser $traverser
[ "Adds", "method", "visitors" ]
2d459fa4822cf88a9f46ce4eec78698d6eaa13a8
https://github.com/indigophp/hydra/blob/2d459fa4822cf88a9f46ce4eec78698d6eaa13a8/src/Hydrator/Generated/Generator.php#L107-L119
2,683
indigophp/hydra
src/Hydrator/Generated/Generator.php
Generator.getPropertyWriters
protected function getPropertyWriters(\ReflectionClass $originalClass) { $propertyWriters = $this->getProperties($originalClass, \ReflectionProperty::IS_PRIVATE); foreach ($propertyWriters as &$property) { $property = new PropertyAccessor($property, 'Writer'); } return $propertyWriters; }
php
protected function getPropertyWriters(\ReflectionClass $originalClass) { $propertyWriters = $this->getProperties($originalClass, \ReflectionProperty::IS_PRIVATE); foreach ($propertyWriters as &$property) { $property = new PropertyAccessor($property, 'Writer'); } return $propertyWriters; }
[ "protected", "function", "getPropertyWriters", "(", "\\", "ReflectionClass", "$", "originalClass", ")", "{", "$", "propertyWriters", "=", "$", "this", "->", "getProperties", "(", "$", "originalClass", ",", "\\", "ReflectionProperty", "::", "IS_PRIVATE", ")", ";", "foreach", "(", "$", "propertyWriters", "as", "&", "$", "property", ")", "{", "$", "property", "=", "new", "PropertyAccessor", "(", "$", "property", ",", "'Writer'", ")", ";", "}", "return", "$", "propertyWriters", ";", "}" ]
Retrieves instance of private property writers @param \ReflectionClass $originalClass @return PropertyAccessor[]
[ "Retrieves", "instance", "of", "private", "property", "writers" ]
2d459fa4822cf88a9f46ce4eec78698d6eaa13a8
https://github.com/indigophp/hydra/blob/2d459fa4822cf88a9f46ce4eec78698d6eaa13a8/src/Hydrator/Generated/Generator.php#L146-L155
2,684
studyportals/Cache
src/MemcacheCache.php
MemcacheCache.set
public function set($name, $value, $ttl = 0){ $name = trim($name); if($name == ''){ throw new CacheException('Cache-entry name cannot be empty'); } $name = $this->_prependPrefix($name); if(is_resource($value)){ throw new CacheException('Cannot cache values of type "resource"'); } if(!$this->validateValueSize($value)){ ExceptionHandler::notice("Value in $name is too big to be stored in memcache."); } // A 30 day+ TTL is interpreted as a timestamp by memcached if($ttl > 2592000){ $ttl = time() + $ttl; } // Name cannot be longer than 250 characters assert('strlen($name) <= 250'); if(strlen($name) > 250) return false; $result = $this->_Memcache->set($name, $value, 0, $ttl); if($result === false && !Memcache::isConnected($this->_Memcache)){ throw new CacheException("Failed to set '$name', Memcache appears to be disconnected!?"); } return $result; }
php
public function set($name, $value, $ttl = 0){ $name = trim($name); if($name == ''){ throw new CacheException('Cache-entry name cannot be empty'); } $name = $this->_prependPrefix($name); if(is_resource($value)){ throw new CacheException('Cannot cache values of type "resource"'); } if(!$this->validateValueSize($value)){ ExceptionHandler::notice("Value in $name is too big to be stored in memcache."); } // A 30 day+ TTL is interpreted as a timestamp by memcached if($ttl > 2592000){ $ttl = time() + $ttl; } // Name cannot be longer than 250 characters assert('strlen($name) <= 250'); if(strlen($name) > 250) return false; $result = $this->_Memcache->set($name, $value, 0, $ttl); if($result === false && !Memcache::isConnected($this->_Memcache)){ throw new CacheException("Failed to set '$name', Memcache appears to be disconnected!?"); } return $result; }
[ "public", "function", "set", "(", "$", "name", ",", "$", "value", ",", "$", "ttl", "=", "0", ")", "{", "$", "name", "=", "trim", "(", "$", "name", ")", ";", "if", "(", "$", "name", "==", "''", ")", "{", "throw", "new", "CacheException", "(", "'Cache-entry name cannot be empty'", ")", ";", "}", "$", "name", "=", "$", "this", "->", "_prependPrefix", "(", "$", "name", ")", ";", "if", "(", "is_resource", "(", "$", "value", ")", ")", "{", "throw", "new", "CacheException", "(", "'Cannot cache values of type \"resource\"'", ")", ";", "}", "if", "(", "!", "$", "this", "->", "validateValueSize", "(", "$", "value", ")", ")", "{", "ExceptionHandler", "::", "notice", "(", "\"Value in $name is too big to be stored in memcache.\"", ")", ";", "}", "// A 30 day+ TTL is interpreted as a timestamp by memcached", "if", "(", "$", "ttl", ">", "2592000", ")", "{", "$", "ttl", "=", "time", "(", ")", "+", "$", "ttl", ";", "}", "// Name cannot be longer than 250 characters", "assert", "(", "'strlen($name) <= 250'", ")", ";", "if", "(", "strlen", "(", "$", "name", ")", ">", "250", ")", "return", "false", ";", "$", "result", "=", "$", "this", "->", "_Memcache", "->", "set", "(", "$", "name", ",", "$", "value", ",", "0", ",", "$", "ttl", ")", ";", "if", "(", "$", "result", "===", "false", "&&", "!", "Memcache", "::", "isConnected", "(", "$", "this", "->", "_Memcache", ")", ")", "{", "throw", "new", "CacheException", "(", "\"Failed to set '$name', Memcache appears\n\t\t\t\tto be disconnected!?\"", ")", ";", "}", "return", "$", "result", ";", "}" ]
Add an entry to the MemcacheCache. @param string $name @param mixed $value @param integer $ttl @return boolean @throws CacheException
[ "Add", "an", "entry", "to", "the", "MemcacheCache", "." ]
f24264b18bea49e97fa8a630cdda595d5b026600
https://github.com/studyportals/Cache/blob/f24264b18bea49e97fa8a630cdda595d5b026600/src/MemcacheCache.php#L77-L119
2,685
studyportals/Cache
src/MemcacheCache.php
MemcacheCache.get
public function get($name, &$error = false){ // If disabled, return nothing so that this cache is overwritten if(!$this->_enabled){ return null; } $name = $this->_prependPrefix($name); error_clear_last(); $value = @$this->_Memcache->get($name); // Attempt to separate "real" errors from missing cache entries $last_error = error_get_last(); if($value === false && $last_error !== null && $last_error['type'] === E_WARNING){ $error = true; return null; } if($value === false){ $value = null; } return $value; }
php
public function get($name, &$error = false){ // If disabled, return nothing so that this cache is overwritten if(!$this->_enabled){ return null; } $name = $this->_prependPrefix($name); error_clear_last(); $value = @$this->_Memcache->get($name); // Attempt to separate "real" errors from missing cache entries $last_error = error_get_last(); if($value === false && $last_error !== null && $last_error['type'] === E_WARNING){ $error = true; return null; } if($value === false){ $value = null; } return $value; }
[ "public", "function", "get", "(", "$", "name", ",", "&", "$", "error", "=", "false", ")", "{", "// If disabled, return nothing so that this cache is overwritten", "if", "(", "!", "$", "this", "->", "_enabled", ")", "{", "return", "null", ";", "}", "$", "name", "=", "$", "this", "->", "_prependPrefix", "(", "$", "name", ")", ";", "error_clear_last", "(", ")", ";", "$", "value", "=", "@", "$", "this", "->", "_Memcache", "->", "get", "(", "$", "name", ")", ";", "// Attempt to separate \"real\" errors from missing cache entries", "$", "last_error", "=", "error_get_last", "(", ")", ";", "if", "(", "$", "value", "===", "false", "&&", "$", "last_error", "!==", "null", "&&", "$", "last_error", "[", "'type'", "]", "===", "E_WARNING", ")", "{", "$", "error", "=", "true", ";", "return", "null", ";", "}", "if", "(", "$", "value", "===", "false", ")", "{", "$", "value", "=", "null", ";", "}", "return", "$", "value", ";", "}" ]
Retrieve an entry from the MemcacheCache. @param string $name @param boolean &$error @return mixed @see Cache::get() @see Memcache::get()
[ "Retrieve", "an", "entry", "from", "the", "MemcacheCache", "." ]
f24264b18bea49e97fa8a630cdda595d5b026600
https://github.com/studyportals/Cache/blob/f24264b18bea49e97fa8a630cdda595d5b026600/src/MemcacheCache.php#L131-L163
2,686
studyportals/Cache
src/MemcacheCache.php
MemcacheCache.delete
public function delete($name){ $name = $this->_prependPrefix($name); $result = @$this->_Memcache->delete($name); return $result; }
php
public function delete($name){ $name = $this->_prependPrefix($name); $result = @$this->_Memcache->delete($name); return $result; }
[ "public", "function", "delete", "(", "$", "name", ")", "{", "$", "name", "=", "$", "this", "->", "_prependPrefix", "(", "$", "name", ")", ";", "$", "result", "=", "@", "$", "this", "->", "_Memcache", "->", "delete", "(", "$", "name", ")", ";", "return", "$", "result", ";", "}" ]
Delete an entry from the MemcacheCache. @param string $name @return boolean @see Cache::delete() @see Memcache::delete()
[ "Delete", "an", "entry", "from", "the", "MemcacheCache", "." ]
f24264b18bea49e97fa8a630cdda595d5b026600
https://github.com/studyportals/Cache/blob/f24264b18bea49e97fa8a630cdda595d5b026600/src/MemcacheCache.php#L174-L181
2,687
bishopb/vanilla
applications/dashboard/controllers/class.notificationscontroller.php
NotificationsController.Initialize
public function Initialize() { $this->Head = new HeadModule($this); $this->AddJsFile('jquery.js'); $this->AddJsFile('jquery.livequery.js'); $this->AddJsFile('jquery.form.js'); $this->AddJsFile('jquery.popup.js'); $this->AddJsFile('jquery.gardenhandleajaxform.js'); $this->AddJsFile('global.js'); $this->AddCssFile('style.css'); $this->AddModule('GuestModule'); parent::Initialize(); }
php
public function Initialize() { $this->Head = new HeadModule($this); $this->AddJsFile('jquery.js'); $this->AddJsFile('jquery.livequery.js'); $this->AddJsFile('jquery.form.js'); $this->AddJsFile('jquery.popup.js'); $this->AddJsFile('jquery.gardenhandleajaxform.js'); $this->AddJsFile('global.js'); $this->AddCssFile('style.css'); $this->AddModule('GuestModule'); parent::Initialize(); }
[ "public", "function", "Initialize", "(", ")", "{", "$", "this", "->", "Head", "=", "new", "HeadModule", "(", "$", "this", ")", ";", "$", "this", "->", "AddJsFile", "(", "'jquery.js'", ")", ";", "$", "this", "->", "AddJsFile", "(", "'jquery.livequery.js'", ")", ";", "$", "this", "->", "AddJsFile", "(", "'jquery.form.js'", ")", ";", "$", "this", "->", "AddJsFile", "(", "'jquery.popup.js'", ")", ";", "$", "this", "->", "AddJsFile", "(", "'jquery.gardenhandleajaxform.js'", ")", ";", "$", "this", "->", "AddJsFile", "(", "'global.js'", ")", ";", "$", "this", "->", "AddCssFile", "(", "'style.css'", ")", ";", "$", "this", "->", "AddModule", "(", "'GuestModule'", ")", ";", "parent", "::", "Initialize", "(", ")", ";", "}" ]
CSS, JS and module includes.
[ "CSS", "JS", "and", "module", "includes", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/controllers/class.notificationscontroller.php#L25-L36
2,688
bishopb/vanilla
applications/dashboard/controllers/class.notificationscontroller.php
NotificationsController.Inform
public function Inform() { $this->DeliveryType(DELIVERY_TYPE_BOOL); $this->DeliveryMethod(DELIVERY_METHOD_JSON); // Retrieve all notifications and inform them. NotificationsController::InformNotifications($this); $this->FireEvent('BeforeInformNotifications'); $this->Render(); }
php
public function Inform() { $this->DeliveryType(DELIVERY_TYPE_BOOL); $this->DeliveryMethod(DELIVERY_METHOD_JSON); // Retrieve all notifications and inform them. NotificationsController::InformNotifications($this); $this->FireEvent('BeforeInformNotifications'); $this->Render(); }
[ "public", "function", "Inform", "(", ")", "{", "$", "this", "->", "DeliveryType", "(", "DELIVERY_TYPE_BOOL", ")", ";", "$", "this", "->", "DeliveryMethod", "(", "DELIVERY_METHOD_JSON", ")", ";", "// Retrieve all notifications and inform them.", "NotificationsController", "::", "InformNotifications", "(", "$", "this", ")", ";", "$", "this", "->", "FireEvent", "(", "'BeforeInformNotifications'", ")", ";", "$", "this", "->", "Render", "(", ")", ";", "}" ]
Adds inform messages to response for inclusion in pages dynamically. @since 2.0.18 @access public
[ "Adds", "inform", "messages", "to", "response", "for", "inclusion", "in", "pages", "dynamically", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/controllers/class.notificationscontroller.php#L44-L53
2,689
bishopb/vanilla
applications/dashboard/controllers/class.notificationscontroller.php
NotificationsController.InformNotifications
public static function InformNotifications($Sender) { $Session = Gdn::Session(); if (!$Session->IsValid()) return; $ActivityModel = new ActivityModel(); // Get five pending notifications. $Where = array( 'NotifyUserID' => Gdn::Session()->UserID, 'Notified' => ActivityModel::SENT_PENDING); // If we're in the middle of a visit only get very recent notifications. $Where['DateUpdated >'] = Gdn_Format::ToDateTime(strtotime('-5 minutes')); $Activities = $ActivityModel->GetWhere($Where, 0, 5)->ResultArray(); $ActivityIDs = ConsolidateArrayValuesByKey($Activities, 'ActivityID'); $ActivityModel->SetNotified($ActivityIDs); foreach ($Activities as $Activity) { if ($Activity['Photo']) $UserPhoto = Anchor( Img($Activity['Photo'], array('class' => 'ProfilePhotoMedium')), $Activity['Url'], 'Icon'); else $UserPhoto = ''; $Excerpt = Gdn_Format::Display($Activity['Story']); $ActivityClass = ' Activity-'.$Activity['ActivityType']; $Sender->InformMessage( $UserPhoto .Wrap($Activity['Headline'], 'div', array('class' => 'Title')) .Wrap($Excerpt, 'div', array('class' => 'Excerpt')), 'Dismissable AutoDismiss'.$ActivityClass.($UserPhoto == '' ? '' : ' HasIcon') ); } }
php
public static function InformNotifications($Sender) { $Session = Gdn::Session(); if (!$Session->IsValid()) return; $ActivityModel = new ActivityModel(); // Get five pending notifications. $Where = array( 'NotifyUserID' => Gdn::Session()->UserID, 'Notified' => ActivityModel::SENT_PENDING); // If we're in the middle of a visit only get very recent notifications. $Where['DateUpdated >'] = Gdn_Format::ToDateTime(strtotime('-5 minutes')); $Activities = $ActivityModel->GetWhere($Where, 0, 5)->ResultArray(); $ActivityIDs = ConsolidateArrayValuesByKey($Activities, 'ActivityID'); $ActivityModel->SetNotified($ActivityIDs); foreach ($Activities as $Activity) { if ($Activity['Photo']) $UserPhoto = Anchor( Img($Activity['Photo'], array('class' => 'ProfilePhotoMedium')), $Activity['Url'], 'Icon'); else $UserPhoto = ''; $Excerpt = Gdn_Format::Display($Activity['Story']); $ActivityClass = ' Activity-'.$Activity['ActivityType']; $Sender->InformMessage( $UserPhoto .Wrap($Activity['Headline'], 'div', array('class' => 'Title')) .Wrap($Excerpt, 'div', array('class' => 'Excerpt')), 'Dismissable AutoDismiss'.$ActivityClass.($UserPhoto == '' ? '' : ' HasIcon') ); } }
[ "public", "static", "function", "InformNotifications", "(", "$", "Sender", ")", "{", "$", "Session", "=", "Gdn", "::", "Session", "(", ")", ";", "if", "(", "!", "$", "Session", "->", "IsValid", "(", ")", ")", "return", ";", "$", "ActivityModel", "=", "new", "ActivityModel", "(", ")", ";", "// Get five pending notifications.", "$", "Where", "=", "array", "(", "'NotifyUserID'", "=>", "Gdn", "::", "Session", "(", ")", "->", "UserID", ",", "'Notified'", "=>", "ActivityModel", "::", "SENT_PENDING", ")", ";", "// If we're in the middle of a visit only get very recent notifications.", "$", "Where", "[", "'DateUpdated >'", "]", "=", "Gdn_Format", "::", "ToDateTime", "(", "strtotime", "(", "'-5 minutes'", ")", ")", ";", "$", "Activities", "=", "$", "ActivityModel", "->", "GetWhere", "(", "$", "Where", ",", "0", ",", "5", ")", "->", "ResultArray", "(", ")", ";", "$", "ActivityIDs", "=", "ConsolidateArrayValuesByKey", "(", "$", "Activities", ",", "'ActivityID'", ")", ";", "$", "ActivityModel", "->", "SetNotified", "(", "$", "ActivityIDs", ")", ";", "foreach", "(", "$", "Activities", "as", "$", "Activity", ")", "{", "if", "(", "$", "Activity", "[", "'Photo'", "]", ")", "$", "UserPhoto", "=", "Anchor", "(", "Img", "(", "$", "Activity", "[", "'Photo'", "]", ",", "array", "(", "'class'", "=>", "'ProfilePhotoMedium'", ")", ")", ",", "$", "Activity", "[", "'Url'", "]", ",", "'Icon'", ")", ";", "else", "$", "UserPhoto", "=", "''", ";", "$", "Excerpt", "=", "Gdn_Format", "::", "Display", "(", "$", "Activity", "[", "'Story'", "]", ")", ";", "$", "ActivityClass", "=", "' Activity-'", ".", "$", "Activity", "[", "'ActivityType'", "]", ";", "$", "Sender", "->", "InformMessage", "(", "$", "UserPhoto", ".", "Wrap", "(", "$", "Activity", "[", "'Headline'", "]", ",", "'div'", ",", "array", "(", "'class'", "=>", "'Title'", ")", ")", ".", "Wrap", "(", "$", "Excerpt", ",", "'div'", ",", "array", "(", "'class'", "=>", "'Excerpt'", ")", ")", ",", "'Dismissable AutoDismiss'", ".", "$", "ActivityClass", ".", "(", "$", "UserPhoto", "==", "''", "?", "''", ":", "' HasIcon'", ")", ")", ";", "}", "}" ]
Grabs all new notifications and adds them to the sender's inform queue. This method gets called by dashboard's hooks file to display new notifications on every pageload. @since 2.0.18 @access public @param Gdn_Controller $Sender The object calling this method.
[ "Grabs", "all", "new", "notifications", "and", "adds", "them", "to", "the", "sender", "s", "inform", "queue", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/controllers/class.notificationscontroller.php#L66-L104
2,690
phossa2/libs
src/Phossa2/Di/Traits/ScopeTrait.php
ScopeTrait.scopedInfo
protected function scopedInfo(/*# string */ $id)/*# : array */ { // split into raw id and scope (if any) list($rawId, $scope) = $this->splitId($id); // use the default scope if no scope given if (empty($scope)) { // use the default $scope = $this->default_scope; // honor predefined scope over the default $def = $this->getResolver()->getService($rawId); if (is_array($def) && isset($def['scope'])) { $scope = $def['scope']; } } return [$rawId, $scope]; }
php
protected function scopedInfo(/*# string */ $id)/*# : array */ { // split into raw id and scope (if any) list($rawId, $scope) = $this->splitId($id); // use the default scope if no scope given if (empty($scope)) { // use the default $scope = $this->default_scope; // honor predefined scope over the default $def = $this->getResolver()->getService($rawId); if (is_array($def) && isset($def['scope'])) { $scope = $def['scope']; } } return [$rawId, $scope]; }
[ "protected", "function", "scopedInfo", "(", "/*# string */", "$", "id", ")", "/*# : array */", "{", "// split into raw id and scope (if any)", "list", "(", "$", "rawId", ",", "$", "scope", ")", "=", "$", "this", "->", "splitId", "(", "$", "id", ")", ";", "// use the default scope if no scope given", "if", "(", "empty", "(", "$", "scope", ")", ")", "{", "// use the default", "$", "scope", "=", "$", "this", "->", "default_scope", ";", "// honor predefined scope over the default", "$", "def", "=", "$", "this", "->", "getResolver", "(", ")", "->", "getService", "(", "$", "rawId", ")", ";", "if", "(", "is_array", "(", "$", "def", ")", "&&", "isset", "(", "$", "def", "[", "'scope'", "]", ")", ")", "{", "$", "scope", "=", "$", "def", "[", "'scope'", "]", ";", "}", "}", "return", "[", "$", "rawId", ",", "$", "scope", "]", ";", "}" ]
Returns the raw id and the scope base on default or defined @param string $id @return array [rawId, scope] @access protected
[ "Returns", "the", "raw", "id", "and", "the", "scope", "base", "on", "default", "or", "defined" ]
921e485c8cc29067f279da2cdd06f47a9bddd115
https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Di/Traits/ScopeTrait.php#L106-L124
2,691
phossa2/libs
src/Phossa2/Di/Traits/ScopeTrait.php
ScopeTrait.scopedData
protected function scopedData($data, /*# string */ $scope)/*# : array */ { if (is_array($data) && isset($data['class'])) { $data['scope'] = $scope; } else { $data = ['class' => $data, 'scope' => $scope]; } return $data; }
php
protected function scopedData($data, /*# string */ $scope)/*# : array */ { if (is_array($data) && isset($data['class'])) { $data['scope'] = $scope; } else { $data = ['class' => $data, 'scope' => $scope]; } return $data; }
[ "protected", "function", "scopedData", "(", "$", "data", ",", "/*# string */", "$", "scope", ")", "/*# : array */", "{", "if", "(", "is_array", "(", "$", "data", ")", "&&", "isset", "(", "$", "data", "[", "'class'", "]", ")", ")", "{", "$", "data", "[", "'scope'", "]", "=", "$", "scope", ";", "}", "else", "{", "$", "data", "=", "[", "'class'", "=>", "$", "data", ",", "'scope'", "=>", "$", "scope", "]", ";", "}", "return", "$", "data", ";", "}" ]
Append scope to data @param mixed $data @param string $scope @return array @access protected
[ "Append", "scope", "to", "data" ]
921e485c8cc29067f279da2cdd06f47a9bddd115
https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Di/Traits/ScopeTrait.php#L134-L142
2,692
patternseek/dependencyinjector
lib/DependencyInjector.php
DependencyInjector.injectIntoMethod
public function injectIntoMethod( $object, $methodName = "injectDependencies" ){ $ref = new \ReflectionClass($object); try{ $refMethod = $ref->getMethod( $methodName ); }catch( ReflectionException $e ){ return null; } $toInject = []; foreach ($refMethod->getParameters() as $p) { $className = $p->getClass()->name; if( $className === "Pimple\\Container" ){ $toInject[] = $this->container; }else{ $toInject[] = $this->container[ $className ]; } } return $refMethod->invoke( $object, ... $toInject ); }
php
public function injectIntoMethod( $object, $methodName = "injectDependencies" ){ $ref = new \ReflectionClass($object); try{ $refMethod = $ref->getMethod( $methodName ); }catch( ReflectionException $e ){ return null; } $toInject = []; foreach ($refMethod->getParameters() as $p) { $className = $p->getClass()->name; if( $className === "Pimple\\Container" ){ $toInject[] = $this->container; }else{ $toInject[] = $this->container[ $className ]; } } return $refMethod->invoke( $object, ... $toInject ); }
[ "public", "function", "injectIntoMethod", "(", "$", "object", ",", "$", "methodName", "=", "\"injectDependencies\"", ")", "{", "$", "ref", "=", "new", "\\", "ReflectionClass", "(", "$", "object", ")", ";", "try", "{", "$", "refMethod", "=", "$", "ref", "->", "getMethod", "(", "$", "methodName", ")", ";", "}", "catch", "(", "ReflectionException", "$", "e", ")", "{", "return", "null", ";", "}", "$", "toInject", "=", "[", "]", ";", "foreach", "(", "$", "refMethod", "->", "getParameters", "(", ")", "as", "$", "p", ")", "{", "$", "className", "=", "$", "p", "->", "getClass", "(", ")", "->", "name", ";", "if", "(", "$", "className", "===", "\"Pimple\\\\Container\"", ")", "{", "$", "toInject", "[", "]", "=", "$", "this", "->", "container", ";", "}", "else", "{", "$", "toInject", "[", "]", "=", "$", "this", "->", "container", "[", "$", "className", "]", ";", "}", "}", "return", "$", "refMethod", "->", "invoke", "(", "$", "object", ",", "...", "$", "toInject", ")", ";", "}" ]
Inject dependencies from, or including, the Pimple container, into a given method on a given object @param $object @param $methodName @return mixed The method's return value
[ "Inject", "dependencies", "from", "or", "including", "the", "Pimple", "container", "into", "a", "given", "method", "on", "a", "given", "object" ]
0f0373f2e1bb5949700aabf4f3d0fb95ed59ddc0
https://github.com/patternseek/dependencyinjector/blob/0f0373f2e1bb5949700aabf4f3d0fb95ed59ddc0/lib/DependencyInjector.php#L68-L86
2,693
patternseek/dependencyinjector
lib/DependencyInjector.php
DependencyInjector.injectIntoConstructor
public function injectIntoConstructor( $classToBuildName, array $toInject=[] ){ $ref = new \ReflectionClass($classToBuildName); try{ $constr = $ref->getConstructor(); }catch( ReflectionException $e ){ return null; } $numToSkip = count($toInject); foreach ($constr->getParameters() as $p) { if( $numToSkip > 0 ){ $numToSkip--; continue; } $classToInjectName = $p->getClass()->name; if( $classToInjectName === "Pimple\\Container" ){ $toInject[] = $this->container; }else{ $toInject[] = $this->container[ $classToInjectName ]; } } return new $classToBuildName( ... $toInject ); }
php
public function injectIntoConstructor( $classToBuildName, array $toInject=[] ){ $ref = new \ReflectionClass($classToBuildName); try{ $constr = $ref->getConstructor(); }catch( ReflectionException $e ){ return null; } $numToSkip = count($toInject); foreach ($constr->getParameters() as $p) { if( $numToSkip > 0 ){ $numToSkip--; continue; } $classToInjectName = $p->getClass()->name; if( $classToInjectName === "Pimple\\Container" ){ $toInject[] = $this->container; }else{ $toInject[] = $this->container[ $classToInjectName ]; } } return new $classToBuildName( ... $toInject ); }
[ "public", "function", "injectIntoConstructor", "(", "$", "classToBuildName", ",", "array", "$", "toInject", "=", "[", "]", ")", "{", "$", "ref", "=", "new", "\\", "ReflectionClass", "(", "$", "classToBuildName", ")", ";", "try", "{", "$", "constr", "=", "$", "ref", "->", "getConstructor", "(", ")", ";", "}", "catch", "(", "ReflectionException", "$", "e", ")", "{", "return", "null", ";", "}", "$", "numToSkip", "=", "count", "(", "$", "toInject", ")", ";", "foreach", "(", "$", "constr", "->", "getParameters", "(", ")", "as", "$", "p", ")", "{", "if", "(", "$", "numToSkip", ">", "0", ")", "{", "$", "numToSkip", "--", ";", "continue", ";", "}", "$", "classToInjectName", "=", "$", "p", "->", "getClass", "(", ")", "->", "name", ";", "if", "(", "$", "classToInjectName", "===", "\"Pimple\\\\Container\"", ")", "{", "$", "toInject", "[", "]", "=", "$", "this", "->", "container", ";", "}", "else", "{", "$", "toInject", "[", "]", "=", "$", "this", "->", "container", "[", "$", "classToInjectName", "]", ";", "}", "}", "return", "new", "$", "classToBuildName", "(", "...", "$", "toInject", ")", ";", "}" ]
Inject dependencies from, or including, the Pimple container, into a a given class's constructor Optionally providing a number of arguments to the constructor to prepend. @param string $classToBuildName @param array $toInject @return bool Whether the method was found
[ "Inject", "dependencies", "from", "or", "including", "the", "Pimple", "container", "into", "a", "a", "given", "class", "s", "constructor", "Optionally", "providing", "a", "number", "of", "arguments", "to", "the", "constructor", "to", "prepend", "." ]
0f0373f2e1bb5949700aabf4f3d0fb95ed59ddc0
https://github.com/patternseek/dependencyinjector/blob/0f0373f2e1bb5949700aabf4f3d0fb95ed59ddc0/lib/DependencyInjector.php#L96-L118
2,694
dzentota/zoya-coin
src/Zoya/Coin/Fibonacci.php
Fibonacci.fib
public function fib($n) { if ($n < 3) return 1; $k = $n / 2; $a = $this->fib($k + 1); $b = $this->fib($k); if ($n % 2 == 1) { return $a * $a + $b * $b; } else { return $b * (2 * $a - $b); } }
php
public function fib($n) { if ($n < 3) return 1; $k = $n / 2; $a = $this->fib($k + 1); $b = $this->fib($k); if ($n % 2 == 1) { return $a * $a + $b * $b; } else { return $b * (2 * $a - $b); } }
[ "public", "function", "fib", "(", "$", "n", ")", "{", "if", "(", "$", "n", "<", "3", ")", "return", "1", ";", "$", "k", "=", "$", "n", "/", "2", ";", "$", "a", "=", "$", "this", "->", "fib", "(", "$", "k", "+", "1", ")", ";", "$", "b", "=", "$", "this", "->", "fib", "(", "$", "k", ")", ";", "if", "(", "$", "n", "%", "2", "==", "1", ")", "{", "return", "$", "a", "*", "$", "a", "+", "$", "b", "*", "$", "b", ";", "}", "else", "{", "return", "$", "b", "*", "(", "2", "*", "$", "a", "-", "$", "b", ")", ";", "}", "}" ]
Returns n'th Fibonacci number @see https://en.wikipedia.org/wiki/Fibonacci_number @param $n @return int
[ "Returns", "n", "th", "Fibonacci", "number" ]
92ef80f767f0313f0723b10b868842bb11ef4b3c
https://github.com/dzentota/zoya-coin/blob/92ef80f767f0313f0723b10b868842bb11ef4b3c/src/Zoya/Coin/Fibonacci.php#L18-L29
2,695
jeromeklam/freefw
src/FreeFW/Storage/PDOStorage.php
PDOStorage.select
public function select(\FreeFW\Core\StorageModel &$p_model, array $p_conditions = []) { $source = $p_model::getSource(); $properties = $p_model::getProperties(); $values = []; $result = \FreeFW\DI\DI::get('FreeFW::Model::ResultSet'); /** * @var \FreeFW\Model\Condition $oneCondition */ $where = ''; foreach ($p_conditions as $idx => $oneCondition) { $part = $this->renderCondition($oneCondition); if ($where != '') { $where = $where . ' AND '; } $where = $where . $part['sql']; $values = array_merge($values, $part['values']); } // Build query $sql = 'SELECT * FROM ' . $source . ' WHERE ' . $where; $this->logger->debug('PDOStorage.select : ' . $sql); // I got all, run query... try { // Get PDO and execute $query = $this->provider->prepare($sql, array(\PDO::ATTR_CURSOR => \PDO::CURSOR_FWDONLY)); if ($query->execute($values)) { while ($row = $query->fetch(\PDO::FETCH_OBJ)) { $model = clone($p_model); $model ->init() ->setFromArray($row) ; $result[] = $model; } } else { $this->logger->debug('PDOStorage.select.error : ' . print_r($query->errorInfo(), true)); $localErr = $query->errorInfo(); $code = 0; $message = 'PDOStorage.select.error : ' . print_r($query->errorInfo(), true); die($message); if (is_array($localErr) && count($localErr) > 1) { $code = intval($localErr[0]); $message = $localErr[2]; } $p_model->addError($code, $message); } } catch (\Exception $ex) { var_dump($ex); } return $result; }
php
public function select(\FreeFW\Core\StorageModel &$p_model, array $p_conditions = []) { $source = $p_model::getSource(); $properties = $p_model::getProperties(); $values = []; $result = \FreeFW\DI\DI::get('FreeFW::Model::ResultSet'); /** * @var \FreeFW\Model\Condition $oneCondition */ $where = ''; foreach ($p_conditions as $idx => $oneCondition) { $part = $this->renderCondition($oneCondition); if ($where != '') { $where = $where . ' AND '; } $where = $where . $part['sql']; $values = array_merge($values, $part['values']); } // Build query $sql = 'SELECT * FROM ' . $source . ' WHERE ' . $where; $this->logger->debug('PDOStorage.select : ' . $sql); // I got all, run query... try { // Get PDO and execute $query = $this->provider->prepare($sql, array(\PDO::ATTR_CURSOR => \PDO::CURSOR_FWDONLY)); if ($query->execute($values)) { while ($row = $query->fetch(\PDO::FETCH_OBJ)) { $model = clone($p_model); $model ->init() ->setFromArray($row) ; $result[] = $model; } } else { $this->logger->debug('PDOStorage.select.error : ' . print_r($query->errorInfo(), true)); $localErr = $query->errorInfo(); $code = 0; $message = 'PDOStorage.select.error : ' . print_r($query->errorInfo(), true); die($message); if (is_array($localErr) && count($localErr) > 1) { $code = intval($localErr[0]); $message = $localErr[2]; } $p_model->addError($code, $message); } } catch (\Exception $ex) { var_dump($ex); } return $result; }
[ "public", "function", "select", "(", "\\", "FreeFW", "\\", "Core", "\\", "StorageModel", "&", "$", "p_model", ",", "array", "$", "p_conditions", "=", "[", "]", ")", "{", "$", "source", "=", "$", "p_model", "::", "getSource", "(", ")", ";", "$", "properties", "=", "$", "p_model", "::", "getProperties", "(", ")", ";", "$", "values", "=", "[", "]", ";", "$", "result", "=", "\\", "FreeFW", "\\", "DI", "\\", "DI", "::", "get", "(", "'FreeFW::Model::ResultSet'", ")", ";", "/**\n * @var \\FreeFW\\Model\\Condition $oneCondition\n */", "$", "where", "=", "''", ";", "foreach", "(", "$", "p_conditions", "as", "$", "idx", "=>", "$", "oneCondition", ")", "{", "$", "part", "=", "$", "this", "->", "renderCondition", "(", "$", "oneCondition", ")", ";", "if", "(", "$", "where", "!=", "''", ")", "{", "$", "where", "=", "$", "where", ".", "' AND '", ";", "}", "$", "where", "=", "$", "where", ".", "$", "part", "[", "'sql'", "]", ";", "$", "values", "=", "array_merge", "(", "$", "values", ",", "$", "part", "[", "'values'", "]", ")", ";", "}", "// Build query", "$", "sql", "=", "'SELECT * FROM '", ".", "$", "source", ".", "' WHERE '", ".", "$", "where", ";", "$", "this", "->", "logger", "->", "debug", "(", "'PDOStorage.select : '", ".", "$", "sql", ")", ";", "// I got all, run query...", "try", "{", "// Get PDO and execute", "$", "query", "=", "$", "this", "->", "provider", "->", "prepare", "(", "$", "sql", ",", "array", "(", "\\", "PDO", "::", "ATTR_CURSOR", "=>", "\\", "PDO", "::", "CURSOR_FWDONLY", ")", ")", ";", "if", "(", "$", "query", "->", "execute", "(", "$", "values", ")", ")", "{", "while", "(", "$", "row", "=", "$", "query", "->", "fetch", "(", "\\", "PDO", "::", "FETCH_OBJ", ")", ")", "{", "$", "model", "=", "clone", "(", "$", "p_model", ")", ";", "$", "model", "->", "init", "(", ")", "->", "setFromArray", "(", "$", "row", ")", ";", "$", "result", "[", "]", "=", "$", "model", ";", "}", "}", "else", "{", "$", "this", "->", "logger", "->", "debug", "(", "'PDOStorage.select.error : '", ".", "print_r", "(", "$", "query", "->", "errorInfo", "(", ")", ",", "true", ")", ")", ";", "$", "localErr", "=", "$", "query", "->", "errorInfo", "(", ")", ";", "$", "code", "=", "0", ";", "$", "message", "=", "'PDOStorage.select.error : '", ".", "print_r", "(", "$", "query", "->", "errorInfo", "(", ")", ",", "true", ")", ";", "die", "(", "$", "message", ")", ";", "if", "(", "is_array", "(", "$", "localErr", ")", "&&", "count", "(", "$", "localErr", ")", ">", "1", ")", "{", "$", "code", "=", "intval", "(", "$", "localErr", "[", "0", "]", ")", ";", "$", "message", "=", "$", "localErr", "[", "2", "]", ";", "}", "$", "p_model", "->", "addError", "(", "$", "code", ",", "$", "message", ")", ";", "}", "}", "catch", "(", "\\", "Exception", "$", "ex", ")", "{", "var_dump", "(", "$", "ex", ")", ";", "}", "return", "$", "result", ";", "}" ]
Select the model @param \FreeFW\Core\StorageModel $p_model @param array $p_conditions @return \FreeFW\Model\ResultSet
[ "Select", "the", "model" ]
16ecf24192375c920a070296f396b9d3fd994a1e
https://github.com/jeromeklam/freefw/blob/16ecf24192375c920a070296f396b9d3fd994a1e/src/FreeFW/Storage/PDOStorage.php#L291-L341
2,696
jeromeklam/freefw
src/FreeFW/Storage/PDOStorage.php
PDOStorage.renderConditionField
protected function renderConditionField(\FreeFW\Interfaces\ConditionInterface $p_field) { if ($p_field instanceof \FreeFW\Model\ConditionMember) { $field = $p_field->getField(); return $this->renderModelField($field); } else { if ($p_field instanceof \FreeFW\Model\ConditionValue) { $value = $p_field->getField(); return $this->renderValueField($value); } else { throw new \FreeFW\Core\FreeFWStorageException( sprintf('Unknown condition objecte !') ); } } }
php
protected function renderConditionField(\FreeFW\Interfaces\ConditionInterface $p_field) { if ($p_field instanceof \FreeFW\Model\ConditionMember) { $field = $p_field->getField(); return $this->renderModelField($field); } else { if ($p_field instanceof \FreeFW\Model\ConditionValue) { $value = $p_field->getField(); return $this->renderValueField($value); } else { throw new \FreeFW\Core\FreeFWStorageException( sprintf('Unknown condition objecte !') ); } } }
[ "protected", "function", "renderConditionField", "(", "\\", "FreeFW", "\\", "Interfaces", "\\", "ConditionInterface", "$", "p_field", ")", "{", "if", "(", "$", "p_field", "instanceof", "\\", "FreeFW", "\\", "Model", "\\", "ConditionMember", ")", "{", "$", "field", "=", "$", "p_field", "->", "getField", "(", ")", ";", "return", "$", "this", "->", "renderModelField", "(", "$", "field", ")", ";", "}", "else", "{", "if", "(", "$", "p_field", "instanceof", "\\", "FreeFW", "\\", "Model", "\\", "ConditionValue", ")", "{", "$", "value", "=", "$", "p_field", "->", "getField", "(", ")", ";", "return", "$", "this", "->", "renderValueField", "(", "$", "value", ")", ";", "}", "else", "{", "throw", "new", "\\", "FreeFW", "\\", "Core", "\\", "FreeFWStorageException", "(", "sprintf", "(", "'Unknown condition objecte !'", ")", ")", ";", "}", "}", "}" ]
Render a condition @param \FreeFW\Interfaces\ConditionInterface $p_field @throws \FreeFW\Core\FreeFWStorageException @return array
[ "Render", "a", "condition" ]
16ecf24192375c920a070296f396b9d3fd994a1e
https://github.com/jeromeklam/freefw/blob/16ecf24192375c920a070296f396b9d3fd994a1e/src/FreeFW/Storage/PDOStorage.php#L404-L419
2,697
jeromeklam/freefw
src/FreeFW/Storage/PDOStorage.php
PDOStorage.renderCondition
protected function renderCondition(\FreeFW\Model\Condition $p_condition) { $result = []; $left = $p_condition->getLeftMember(); $right = $p_condition->getRightMember(); $oper = $p_condition->getOperator(); switch ($oper) { case \FreeFW\Storage\Storage::COND_LOWER: case \FreeFW\Storage\Storage::COND_LOWER_EQUAL: case \FreeFW\Storage\Storage::COND_GREATER: case \FreeFW\Storage\Storage::COND_GREATER_EQUAL: case \FreeFW\Storage\Storage::COND_EQUAL: if ($left !== null && $right !== null) { $leftDatas = $this->renderConditionField($left); $rightDatas = $this->renderConditionField($right); $result = [ 'sql' => $leftDatas['id'] . ' ' . $oper . ' ' . $rightDatas['id'], 'values' => [], 'type' => false ]; if ($leftDatas['type'] === false) { $result['values'][$leftDatas['id']] = $leftDatas['value']; } else { $result['type'] = $leftDatas['type']; } if ($rightDatas['type'] === false) { $result['values'][$rightDatas['id']] = $rightDatas['value']; } else { $result['type'] = $rightDatas['type']; } } else { throw new \FreeFW\Core\FreeFWStorageException( sprintf('Wrong fields for %s condition', $oper) ); } break; default: throw new \FreeFW\Core\FreeFWStorageException( sprintf('Unknown condition : %s !', $oper) ); break; } return $result; }
php
protected function renderCondition(\FreeFW\Model\Condition $p_condition) { $result = []; $left = $p_condition->getLeftMember(); $right = $p_condition->getRightMember(); $oper = $p_condition->getOperator(); switch ($oper) { case \FreeFW\Storage\Storage::COND_LOWER: case \FreeFW\Storage\Storage::COND_LOWER_EQUAL: case \FreeFW\Storage\Storage::COND_GREATER: case \FreeFW\Storage\Storage::COND_GREATER_EQUAL: case \FreeFW\Storage\Storage::COND_EQUAL: if ($left !== null && $right !== null) { $leftDatas = $this->renderConditionField($left); $rightDatas = $this->renderConditionField($right); $result = [ 'sql' => $leftDatas['id'] . ' ' . $oper . ' ' . $rightDatas['id'], 'values' => [], 'type' => false ]; if ($leftDatas['type'] === false) { $result['values'][$leftDatas['id']] = $leftDatas['value']; } else { $result['type'] = $leftDatas['type']; } if ($rightDatas['type'] === false) { $result['values'][$rightDatas['id']] = $rightDatas['value']; } else { $result['type'] = $rightDatas['type']; } } else { throw new \FreeFW\Core\FreeFWStorageException( sprintf('Wrong fields for %s condition', $oper) ); } break; default: throw new \FreeFW\Core\FreeFWStorageException( sprintf('Unknown condition : %s !', $oper) ); break; } return $result; }
[ "protected", "function", "renderCondition", "(", "\\", "FreeFW", "\\", "Model", "\\", "Condition", "$", "p_condition", ")", "{", "$", "result", "=", "[", "]", ";", "$", "left", "=", "$", "p_condition", "->", "getLeftMember", "(", ")", ";", "$", "right", "=", "$", "p_condition", "->", "getRightMember", "(", ")", ";", "$", "oper", "=", "$", "p_condition", "->", "getOperator", "(", ")", ";", "switch", "(", "$", "oper", ")", "{", "case", "\\", "FreeFW", "\\", "Storage", "\\", "Storage", "::", "COND_LOWER", ":", "case", "\\", "FreeFW", "\\", "Storage", "\\", "Storage", "::", "COND_LOWER_EQUAL", ":", "case", "\\", "FreeFW", "\\", "Storage", "\\", "Storage", "::", "COND_GREATER", ":", "case", "\\", "FreeFW", "\\", "Storage", "\\", "Storage", "::", "COND_GREATER_EQUAL", ":", "case", "\\", "FreeFW", "\\", "Storage", "\\", "Storage", "::", "COND_EQUAL", ":", "if", "(", "$", "left", "!==", "null", "&&", "$", "right", "!==", "null", ")", "{", "$", "leftDatas", "=", "$", "this", "->", "renderConditionField", "(", "$", "left", ")", ";", "$", "rightDatas", "=", "$", "this", "->", "renderConditionField", "(", "$", "right", ")", ";", "$", "result", "=", "[", "'sql'", "=>", "$", "leftDatas", "[", "'id'", "]", ".", "' '", ".", "$", "oper", ".", "' '", ".", "$", "rightDatas", "[", "'id'", "]", ",", "'values'", "=>", "[", "]", ",", "'type'", "=>", "false", "]", ";", "if", "(", "$", "leftDatas", "[", "'type'", "]", "===", "false", ")", "{", "$", "result", "[", "'values'", "]", "[", "$", "leftDatas", "[", "'id'", "]", "]", "=", "$", "leftDatas", "[", "'value'", "]", ";", "}", "else", "{", "$", "result", "[", "'type'", "]", "=", "$", "leftDatas", "[", "'type'", "]", ";", "}", "if", "(", "$", "rightDatas", "[", "'type'", "]", "===", "false", ")", "{", "$", "result", "[", "'values'", "]", "[", "$", "rightDatas", "[", "'id'", "]", "]", "=", "$", "rightDatas", "[", "'value'", "]", ";", "}", "else", "{", "$", "result", "[", "'type'", "]", "=", "$", "rightDatas", "[", "'type'", "]", ";", "}", "}", "else", "{", "throw", "new", "\\", "FreeFW", "\\", "Core", "\\", "FreeFWStorageException", "(", "sprintf", "(", "'Wrong fields for %s condition'", ",", "$", "oper", ")", ")", ";", "}", "break", ";", "default", ":", "throw", "new", "\\", "FreeFW", "\\", "Core", "\\", "FreeFWStorageException", "(", "sprintf", "(", "'Unknown condition : %s !'", ",", "$", "oper", ")", ")", ";", "break", ";", "}", "return", "$", "result", ";", "}" ]
Render a full condition @param \FreeFW\Model\Condition $p_condition @throws \FreeFW\Core\FreeFWStorageException
[ "Render", "a", "full", "condition" ]
16ecf24192375c920a070296f396b9d3fd994a1e
https://github.com/jeromeklam/freefw/blob/16ecf24192375c920a070296f396b9d3fd994a1e/src/FreeFW/Storage/PDOStorage.php#L428-L471
2,698
jeromeklam/freefw
src/FreeFW/Storage/PDOStorage.php
PDOStorage.renderModelField
protected function renderModelField(string $p_field) { $parts = explode('.', $p_field); $class = $parts[0]; $field = $parts[1]; if (!array_key_exists($class, self::$models)) { self::$models[$class] = \FreeFW\DI\DI::get($class); } $model = self::$models[$class]; $source = $model::getSource(); $properties = $model::getProperties(); $type = \FreeFW\Constants::TYPE_STRING; if (array_key_exists($field, $properties)) { $real = $source . '.' . $properties[$field][FFCST::PROPERTY_PRIVATE]; $type = $properties[$field][FFCST::PROPERTY_TYPE]; } else { throw new \FreeFW\Core\FreeFWStorageException( sprintf('Unknown field : %s !', $p_field) ); } return [ 'id' => $real, 'value' => $p_field, 'type' => $type ]; }
php
protected function renderModelField(string $p_field) { $parts = explode('.', $p_field); $class = $parts[0]; $field = $parts[1]; if (!array_key_exists($class, self::$models)) { self::$models[$class] = \FreeFW\DI\DI::get($class); } $model = self::$models[$class]; $source = $model::getSource(); $properties = $model::getProperties(); $type = \FreeFW\Constants::TYPE_STRING; if (array_key_exists($field, $properties)) { $real = $source . '.' . $properties[$field][FFCST::PROPERTY_PRIVATE]; $type = $properties[$field][FFCST::PROPERTY_TYPE]; } else { throw new \FreeFW\Core\FreeFWStorageException( sprintf('Unknown field : %s !', $p_field) ); } return [ 'id' => $real, 'value' => $p_field, 'type' => $type ]; }
[ "protected", "function", "renderModelField", "(", "string", "$", "p_field", ")", "{", "$", "parts", "=", "explode", "(", "'.'", ",", "$", "p_field", ")", ";", "$", "class", "=", "$", "parts", "[", "0", "]", ";", "$", "field", "=", "$", "parts", "[", "1", "]", ";", "if", "(", "!", "array_key_exists", "(", "$", "class", ",", "self", "::", "$", "models", ")", ")", "{", "self", "::", "$", "models", "[", "$", "class", "]", "=", "\\", "FreeFW", "\\", "DI", "\\", "DI", "::", "get", "(", "$", "class", ")", ";", "}", "$", "model", "=", "self", "::", "$", "models", "[", "$", "class", "]", ";", "$", "source", "=", "$", "model", "::", "getSource", "(", ")", ";", "$", "properties", "=", "$", "model", "::", "getProperties", "(", ")", ";", "$", "type", "=", "\\", "FreeFW", "\\", "Constants", "::", "TYPE_STRING", ";", "if", "(", "array_key_exists", "(", "$", "field", ",", "$", "properties", ")", ")", "{", "$", "real", "=", "$", "source", ".", "'.'", ".", "$", "properties", "[", "$", "field", "]", "[", "FFCST", "::", "PROPERTY_PRIVATE", "]", ";", "$", "type", "=", "$", "properties", "[", "$", "field", "]", "[", "FFCST", "::", "PROPERTY_TYPE", "]", ";", "}", "else", "{", "throw", "new", "\\", "FreeFW", "\\", "Core", "\\", "FreeFWStorageException", "(", "sprintf", "(", "'Unknown field : %s !'", ",", "$", "p_field", ")", ")", ";", "}", "return", "[", "'id'", "=>", "$", "real", ",", "'value'", "=>", "$", "p_field", ",", "'type'", "=>", "$", "type", "]", ";", "}" ]
Render a model field @param string $p_field @throws \FreeFW\Core\FreeFWStorageException
[ "Render", "a", "model", "field" ]
16ecf24192375c920a070296f396b9d3fd994a1e
https://github.com/jeromeklam/freefw/blob/16ecf24192375c920a070296f396b9d3fd994a1e/src/FreeFW/Storage/PDOStorage.php#L480-L505
2,699
jeromeklam/freefw
src/FreeFW/Storage/PDOStorage.php
PDOStorage.renderValueField
protected function renderValueField($p_value) { self::$uniqid = self::$uniqid + 1; return [ 'id' => ':i' . rand(10, 99) . '_' . self::$uniqid, 'value' => $p_value, 'type' => false ]; }
php
protected function renderValueField($p_value) { self::$uniqid = self::$uniqid + 1; return [ 'id' => ':i' . rand(10, 99) . '_' . self::$uniqid, 'value' => $p_value, 'type' => false ]; }
[ "protected", "function", "renderValueField", "(", "$", "p_value", ")", "{", "self", "::", "$", "uniqid", "=", "self", "::", "$", "uniqid", "+", "1", ";", "return", "[", "'id'", "=>", "':i'", ".", "rand", "(", "10", ",", "99", ")", ".", "'_'", ".", "self", "::", "$", "uniqid", ",", "'value'", "=>", "$", "p_value", ",", "'type'", "=>", "false", "]", ";", "}" ]
Render a value @param mixed $p_value @return []
[ "Render", "a", "value" ]
16ecf24192375c920a070296f396b9d3fd994a1e
https://github.com/jeromeklam/freefw/blob/16ecf24192375c920a070296f396b9d3fd994a1e/src/FreeFW/Storage/PDOStorage.php#L514-L522