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
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
239,900
Clastic/BackofficeBundle
Form/TabHelper.php
TabHelper.createTab
public function createTab($name, $label, $options = array()) { $options = array_replace( $options, array( 'label' => $label, 'inherit_data' => true, )); $tab = $this->formBuilder->create($name, TabsTabType::class, $options); $this->formBuilder->get('tabs')->add($tab); return $tab; }
php
public function createTab($name, $label, $options = array()) { $options = array_replace( $options, array( 'label' => $label, 'inherit_data' => true, )); $tab = $this->formBuilder->create($name, TabsTabType::class, $options); $this->formBuilder->get('tabs')->add($tab); return $tab; }
[ "public", "function", "createTab", "(", "$", "name", ",", "$", "label", ",", "$", "options", "=", "array", "(", ")", ")", "{", "$", "options", "=", "array_replace", "(", "$", "options", ",", "array", "(", "'label'", "=>", "$", "label", ",", "'inherit_data'", "=>", "true", ",", ")", ")", ";", "$", "tab", "=", "$", "this", "->", "formBuilder", "->", "create", "(", "$", "name", ",", "TabsTabType", "::", "class", ",", "$", "options", ")", ";", "$", "this", "->", "formBuilder", "->", "get", "(", "'tabs'", ")", "->", "add", "(", "$", "tab", ")", ";", "return", "$", "tab", ";", "}" ]
Create a new tab and nest it under the tabs. @param string $name @param string $label @param array $options @return FormBuilderInterface The created tab.
[ "Create", "a", "new", "tab", "and", "nest", "it", "under", "the", "tabs", "." ]
f40b2589a56ef37507d22788c3e8faa996e71758
https://github.com/Clastic/BackofficeBundle/blob/f40b2589a56ef37507d22788c3e8faa996e71758/Form/TabHelper.php#L54-L67
239,901
mooti/framework
src/Application/Rest/BaseController.php
BaseController.render
public function render($content, Response $response) { $response->setStatusCode(Response::HTTP_OK); $response->headers->set('Content-Type', 'application/json'); $response->setContent(json_encode($content)); return $response; }
php
public function render($content, Response $response) { $response->setStatusCode(Response::HTTP_OK); $response->headers->set('Content-Type', 'application/json'); $response->setContent(json_encode($content)); return $response; }
[ "public", "function", "render", "(", "$", "content", ",", "Response", "$", "response", ")", "{", "$", "response", "->", "setStatusCode", "(", "Response", "::", "HTTP_OK", ")", ";", "$", "response", "->", "headers", "->", "set", "(", "'Content-Type'", ",", "'application/json'", ")", ";", "$", "response", "->", "setContent", "(", "json_encode", "(", "$", "content", ")", ")", ";", "return", "$", "response", ";", "}" ]
Renders any given content as a json string @param mixed $content This can be serializable data type. @param Response $response The response object @return Response $response
[ "Renders", "any", "given", "content", "as", "a", "json", "string" ]
078da6699c5c6c7ac4e5a3d36751d645ad8aa93e
https://github.com/mooti/framework/blob/078da6699c5c6c7ac4e5a3d36751d645ad8aa93e/src/Application/Rest/BaseController.php#L32-L39
239,902
magicphp/framework
src/magicphp/session.class.php
Session.Start
public static function Start($sName, $sSessionDiretory = null){ $oThis = self::CreateInstanceIfNotExists(); if(!empty($sName)){ $sName = md5($sName); if(!is_null($sSessionDiretory)){ @session_save_path($sSessionDiretory); Storage::Set("session.path", $sSessionDiretory); } @session_name($sName); $sSessionName = session_name(); if($sSessionName != $sName) $oThis->sName = $sSessionName; else $oThis->sName = $sName; $bSession = session_start(); if($bSession){ Storage::Set("session.name", $oThis->sName); Storage::Set("session.id", session_id()); switch($_SERVER["SERVER_ADDR"]){ case "127.0.0.1"://Setting to developer mode case "::1": $iTimeout = time()+3600; session_cache_expire(60); //Increases the cache time of the session to 60 minutes session_cache_limiter("nocache"); //Sets the cache limiter to 'nocache' Storage::Set("session.timeout", $iTimeout); //Setting the timeout session ends break; default: $iTimeout = time()+900; session_cache_expire(15); //Shortens the session cache for 15 minutes session_cache_limiter("private"); //Sets the cache limiter to 'private' Storage::Set("session.timeout", $iTimeout); //Setting the timeout session ends break; } //Recording session information Storage::Set("session.cache.limiter", session_cache_limiter()); Storage::Set("session.cache.expire", session_cache_expire()); Storage::Set("session.cookie.enable", array_key_exists($sName, $_COOKIE)); //Verifying authentication information if(array_key_exists($oThis->sName, $_SESSION)){ if(array_key_exists("authentication", $_SESSION[$oThis->sName])) $oThis->aAuth = $_SESSION[$oThis->sName]["authentication"]; if(!empty($oThis->aAuth)){ Storage::Set("user.id", $oThis->aAuth["id"]); Storage::Set("user.name", $oThis->aAuth["name"]); Storage::Set("user.username", $oThis->aAuth["username"]); Storage::Set("user.root", $oThis->aAuth["root"]); Storage::Set("session.timeout.login", $oThis->aAuth["timeout"]); } } Storage::Set("session.enabled", true); $oThis->bStarted = true; return true; } else{ Storage::Set("session.enabled", false); return false; } } else{ Storage::Set("session.enabled", false); return false; } }
php
public static function Start($sName, $sSessionDiretory = null){ $oThis = self::CreateInstanceIfNotExists(); if(!empty($sName)){ $sName = md5($sName); if(!is_null($sSessionDiretory)){ @session_save_path($sSessionDiretory); Storage::Set("session.path", $sSessionDiretory); } @session_name($sName); $sSessionName = session_name(); if($sSessionName != $sName) $oThis->sName = $sSessionName; else $oThis->sName = $sName; $bSession = session_start(); if($bSession){ Storage::Set("session.name", $oThis->sName); Storage::Set("session.id", session_id()); switch($_SERVER["SERVER_ADDR"]){ case "127.0.0.1"://Setting to developer mode case "::1": $iTimeout = time()+3600; session_cache_expire(60); //Increases the cache time of the session to 60 minutes session_cache_limiter("nocache"); //Sets the cache limiter to 'nocache' Storage::Set("session.timeout", $iTimeout); //Setting the timeout session ends break; default: $iTimeout = time()+900; session_cache_expire(15); //Shortens the session cache for 15 minutes session_cache_limiter("private"); //Sets the cache limiter to 'private' Storage::Set("session.timeout", $iTimeout); //Setting the timeout session ends break; } //Recording session information Storage::Set("session.cache.limiter", session_cache_limiter()); Storage::Set("session.cache.expire", session_cache_expire()); Storage::Set("session.cookie.enable", array_key_exists($sName, $_COOKIE)); //Verifying authentication information if(array_key_exists($oThis->sName, $_SESSION)){ if(array_key_exists("authentication", $_SESSION[$oThis->sName])) $oThis->aAuth = $_SESSION[$oThis->sName]["authentication"]; if(!empty($oThis->aAuth)){ Storage::Set("user.id", $oThis->aAuth["id"]); Storage::Set("user.name", $oThis->aAuth["name"]); Storage::Set("user.username", $oThis->aAuth["username"]); Storage::Set("user.root", $oThis->aAuth["root"]); Storage::Set("session.timeout.login", $oThis->aAuth["timeout"]); } } Storage::Set("session.enabled", true); $oThis->bStarted = true; return true; } else{ Storage::Set("session.enabled", false); return false; } } else{ Storage::Set("session.enabled", false); return false; } }
[ "public", "static", "function", "Start", "(", "$", "sName", ",", "$", "sSessionDiretory", "=", "null", ")", "{", "$", "oThis", "=", "self", "::", "CreateInstanceIfNotExists", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "sName", ")", ")", "{", "$", "sName", "=", "md5", "(", "$", "sName", ")", ";", "if", "(", "!", "is_null", "(", "$", "sSessionDiretory", ")", ")", "{", "@", "session_save_path", "(", "$", "sSessionDiretory", ")", ";", "Storage", "::", "Set", "(", "\"session.path\"", ",", "$", "sSessionDiretory", ")", ";", "}", "@", "session_name", "(", "$", "sName", ")", ";", "$", "sSessionName", "=", "session_name", "(", ")", ";", "if", "(", "$", "sSessionName", "!=", "$", "sName", ")", "$", "oThis", "->", "sName", "=", "$", "sSessionName", ";", "else", "$", "oThis", "->", "sName", "=", "$", "sName", ";", "$", "bSession", "=", "session_start", "(", ")", ";", "if", "(", "$", "bSession", ")", "{", "Storage", "::", "Set", "(", "\"session.name\"", ",", "$", "oThis", "->", "sName", ")", ";", "Storage", "::", "Set", "(", "\"session.id\"", ",", "session_id", "(", ")", ")", ";", "switch", "(", "$", "_SERVER", "[", "\"SERVER_ADDR\"", "]", ")", "{", "case", "\"127.0.0.1\"", ":", "//Setting to developer mode", "case", "\"::1\"", ":", "$", "iTimeout", "=", "time", "(", ")", "+", "3600", ";", "session_cache_expire", "(", "60", ")", ";", "//Increases the cache time of the session to 60 minutes", "session_cache_limiter", "(", "\"nocache\"", ")", ";", "//Sets the cache limiter to 'nocache'", "Storage", "::", "Set", "(", "\"session.timeout\"", ",", "$", "iTimeout", ")", ";", "//Setting the timeout session ends", "break", ";", "default", ":", "$", "iTimeout", "=", "time", "(", ")", "+", "900", ";", "session_cache_expire", "(", "15", ")", ";", "//Shortens the session cache for 15 minutes", "session_cache_limiter", "(", "\"private\"", ")", ";", "//Sets the cache limiter to 'private'", "Storage", "::", "Set", "(", "\"session.timeout\"", ",", "$", "iTimeout", ")", ";", "//Setting the timeout session ends", "break", ";", "}", "//Recording session information", "Storage", "::", "Set", "(", "\"session.cache.limiter\"", ",", "session_cache_limiter", "(", ")", ")", ";", "Storage", "::", "Set", "(", "\"session.cache.expire\"", ",", "session_cache_expire", "(", ")", ")", ";", "Storage", "::", "Set", "(", "\"session.cookie.enable\"", ",", "array_key_exists", "(", "$", "sName", ",", "$", "_COOKIE", ")", ")", ";", "//Verifying authentication information", "if", "(", "array_key_exists", "(", "$", "oThis", "->", "sName", ",", "$", "_SESSION", ")", ")", "{", "if", "(", "array_key_exists", "(", "\"authentication\"", ",", "$", "_SESSION", "[", "$", "oThis", "->", "sName", "]", ")", ")", "$", "oThis", "->", "aAuth", "=", "$", "_SESSION", "[", "$", "oThis", "->", "sName", "]", "[", "\"authentication\"", "]", ";", "if", "(", "!", "empty", "(", "$", "oThis", "->", "aAuth", ")", ")", "{", "Storage", "::", "Set", "(", "\"user.id\"", ",", "$", "oThis", "->", "aAuth", "[", "\"id\"", "]", ")", ";", "Storage", "::", "Set", "(", "\"user.name\"", ",", "$", "oThis", "->", "aAuth", "[", "\"name\"", "]", ")", ";", "Storage", "::", "Set", "(", "\"user.username\"", ",", "$", "oThis", "->", "aAuth", "[", "\"username\"", "]", ")", ";", "Storage", "::", "Set", "(", "\"user.root\"", ",", "$", "oThis", "->", "aAuth", "[", "\"root\"", "]", ")", ";", "Storage", "::", "Set", "(", "\"session.timeout.login\"", ",", "$", "oThis", "->", "aAuth", "[", "\"timeout\"", "]", ")", ";", "}", "}", "Storage", "::", "Set", "(", "\"session.enabled\"", ",", "true", ")", ";", "$", "oThis", "->", "bStarted", "=", "true", ";", "return", "true", ";", "}", "else", "{", "Storage", "::", "Set", "(", "\"session.enabled\"", ",", "false", ")", ";", "return", "false", ";", "}", "}", "else", "{", "Storage", "::", "Set", "(", "\"session.enabled\"", ",", "false", ")", ";", "return", "false", ";", "}", "}" ]
Function to start session @static @access public @param string $sName Session name @param string $sSessionDiretory Storage directory sessions @return boolean
[ "Function", "to", "start", "session" ]
199934b61c46ec596c27d4fb0355b216dde51d58
https://github.com/magicphp/framework/blob/199934b61c46ec596c27d4fb0355b216dde51d58/src/magicphp/session.class.php#L61-L134
239,903
magicphp/framework
src/magicphp/session.class.php
Session.Login
public static function Login($mId, $sUsername, $sName, $iTimeout = 3600, $bRoot = false){ $oThis = self::CreateInstanceIfNotExists(); if($oThis->bStarted){ $iTimeout = time()+$iTimeout; $oThis->aAuth = array("id" => $mId, "name" => $sName, "username" => $sUsername, "timeout" => $iTimeout, "root" => $bRoot); $_SESSION[$oThis->sName]["authentication"] = $oThis->aAuth; if(!empty($oThis->aAuth)){ Storage::Set("user.id", $oThis->aAuth["id"]); Storage::Set("user.name", $oThis->aAuth["name"]); Storage::Set("user.username", $oThis->aAuth["username"]); Storage::Set("user.root", $oThis->aAuth["root"]); Storage::Set("session.timeout.login", $iTimeout); } } }
php
public static function Login($mId, $sUsername, $sName, $iTimeout = 3600, $bRoot = false){ $oThis = self::CreateInstanceIfNotExists(); if($oThis->bStarted){ $iTimeout = time()+$iTimeout; $oThis->aAuth = array("id" => $mId, "name" => $sName, "username" => $sUsername, "timeout" => $iTimeout, "root" => $bRoot); $_SESSION[$oThis->sName]["authentication"] = $oThis->aAuth; if(!empty($oThis->aAuth)){ Storage::Set("user.id", $oThis->aAuth["id"]); Storage::Set("user.name", $oThis->aAuth["name"]); Storage::Set("user.username", $oThis->aAuth["username"]); Storage::Set("user.root", $oThis->aAuth["root"]); Storage::Set("session.timeout.login", $iTimeout); } } }
[ "public", "static", "function", "Login", "(", "$", "mId", ",", "$", "sUsername", ",", "$", "sName", ",", "$", "iTimeout", "=", "3600", ",", "$", "bRoot", "=", "false", ")", "{", "$", "oThis", "=", "self", "::", "CreateInstanceIfNotExists", "(", ")", ";", "if", "(", "$", "oThis", "->", "bStarted", ")", "{", "$", "iTimeout", "=", "time", "(", ")", "+", "$", "iTimeout", ";", "$", "oThis", "->", "aAuth", "=", "array", "(", "\"id\"", "=>", "$", "mId", ",", "\"name\"", "=>", "$", "sName", ",", "\"username\"", "=>", "$", "sUsername", ",", "\"timeout\"", "=>", "$", "iTimeout", ",", "\"root\"", "=>", "$", "bRoot", ")", ";", "$", "_SESSION", "[", "$", "oThis", "->", "sName", "]", "[", "\"authentication\"", "]", "=", "$", "oThis", "->", "aAuth", ";", "if", "(", "!", "empty", "(", "$", "oThis", "->", "aAuth", ")", ")", "{", "Storage", "::", "Set", "(", "\"user.id\"", ",", "$", "oThis", "->", "aAuth", "[", "\"id\"", "]", ")", ";", "Storage", "::", "Set", "(", "\"user.name\"", ",", "$", "oThis", "->", "aAuth", "[", "\"name\"", "]", ")", ";", "Storage", "::", "Set", "(", "\"user.username\"", ",", "$", "oThis", "->", "aAuth", "[", "\"username\"", "]", ")", ";", "Storage", "::", "Set", "(", "\"user.root\"", ",", "$", "oThis", "->", "aAuth", "[", "\"root\"", "]", ")", ";", "Storage", "::", "Set", "(", "\"session.timeout.login\"", ",", "$", "iTimeout", ")", ";", "}", "}", "}" ]
Function to perform the login session @static @access public @param mixed $mId User ID @param string $sUsername Username @param string $sName Name @param integer $iTimeout Maximum time of permanence in the session @param boolean $bRoot Defines the user as root @return void
[ "Function", "to", "perform", "the", "login", "session" ]
199934b61c46ec596c27d4fb0355b216dde51d58
https://github.com/magicphp/framework/blob/199934b61c46ec596c27d4fb0355b216dde51d58/src/magicphp/session.class.php#L160-L176
239,904
magicphp/framework
src/magicphp/session.class.php
Session.Logout
public static function Logout(){ $oThis = self::CreateInstanceIfNotExists(); if($oThis->bStarted){ session_unset(); unset($_SESSION[$oThis->sName]["authentication"]); unset($oThis->aAuth); } }
php
public static function Logout(){ $oThis = self::CreateInstanceIfNotExists(); if($oThis->bStarted){ session_unset(); unset($_SESSION[$oThis->sName]["authentication"]); unset($oThis->aAuth); } }
[ "public", "static", "function", "Logout", "(", ")", "{", "$", "oThis", "=", "self", "::", "CreateInstanceIfNotExists", "(", ")", ";", "if", "(", "$", "oThis", "->", "bStarted", ")", "{", "session_unset", "(", ")", ";", "unset", "(", "$", "_SESSION", "[", "$", "oThis", "->", "sName", "]", "[", "\"authentication\"", "]", ")", ";", "unset", "(", "$", "oThis", "->", "aAuth", ")", ";", "}", "}" ]
Function to logout @static @access public @return void
[ "Function", "to", "logout" ]
199934b61c46ec596c27d4fb0355b216dde51d58
https://github.com/magicphp/framework/blob/199934b61c46ec596c27d4fb0355b216dde51d58/src/magicphp/session.class.php#L185-L193
239,905
magicphp/framework
src/magicphp/session.class.php
Session.CheckAuthentication
public static function CheckAuthentication(){ $oThis = self::CreateInstanceIfNotExists(); $bReturn = ($oThis->bStarted) ? (!empty($oThis->aAuth["id"]) && !empty($oThis->aAuth["username"]) && ((intval($oThis->aAuth["timeout"]) > time()) || (intval($oThis->aAuth["timeout"]) <= 0))) : false; return $bReturn; }
php
public static function CheckAuthentication(){ $oThis = self::CreateInstanceIfNotExists(); $bReturn = ($oThis->bStarted) ? (!empty($oThis->aAuth["id"]) && !empty($oThis->aAuth["username"]) && ((intval($oThis->aAuth["timeout"]) > time()) || (intval($oThis->aAuth["timeout"]) <= 0))) : false; return $bReturn; }
[ "public", "static", "function", "CheckAuthentication", "(", ")", "{", "$", "oThis", "=", "self", "::", "CreateInstanceIfNotExists", "(", ")", ";", "$", "bReturn", "=", "(", "$", "oThis", "->", "bStarted", ")", "?", "(", "!", "empty", "(", "$", "oThis", "->", "aAuth", "[", "\"id\"", "]", ")", "&&", "!", "empty", "(", "$", "oThis", "->", "aAuth", "[", "\"username\"", "]", ")", "&&", "(", "(", "intval", "(", "$", "oThis", "->", "aAuth", "[", "\"timeout\"", "]", ")", ">", "time", "(", ")", ")", "||", "(", "intval", "(", "$", "oThis", "->", "aAuth", "[", "\"timeout\"", "]", ")", "<=", "0", ")", ")", ")", ":", "false", ";", "return", "$", "bReturn", ";", "}" ]
Function to check the authentication session @static @access public @return boolean
[ "Function", "to", "check", "the", "authentication", "session" ]
199934b61c46ec596c27d4fb0355b216dde51d58
https://github.com/magicphp/framework/blob/199934b61c46ec596c27d4fb0355b216dde51d58/src/magicphp/session.class.php#L202-L206
239,906
magicphp/framework
src/magicphp/session.class.php
Session.Has
public static function Has($sKey){ $oThis = self::CreateInstanceIfNotExists(); if($oThis->bStarted) return array_key_exists($sKey, $_SESSION[$oThis->sName]); else return false; }
php
public static function Has($sKey){ $oThis = self::CreateInstanceIfNotExists(); if($oThis->bStarted) return array_key_exists($sKey, $_SESSION[$oThis->sName]); else return false; }
[ "public", "static", "function", "Has", "(", "$", "sKey", ")", "{", "$", "oThis", "=", "self", "::", "CreateInstanceIfNotExists", "(", ")", ";", "if", "(", "$", "oThis", "->", "bStarted", ")", "return", "array_key_exists", "(", "$", "sKey", ",", "$", "_SESSION", "[", "$", "oThis", "->", "sName", "]", ")", ";", "else", "return", "false", ";", "}" ]
Function to check existence of record in the session @static @param string $sKey Search Key @return boolean
[ "Function", "to", "check", "existence", "of", "record", "in", "the", "session" ]
199934b61c46ec596c27d4fb0355b216dde51d58
https://github.com/magicphp/framework/blob/199934b61c46ec596c27d4fb0355b216dde51d58/src/magicphp/session.class.php#L215-L222
239,907
magicphp/framework
src/magicphp/session.class.php
Session.Set
public static function Set($sKey, $mValue){ $oThis = self::CreateInstanceIfNotExists(); if($oThis->bStarted){ if($sKey != "name" && $sKey != "id" && $sKey != "authentication"){ $_SESSION[$oThis->sName][$sKey] = $mValue; return true; } else{ return false; } } else{ return false; } }
php
public static function Set($sKey, $mValue){ $oThis = self::CreateInstanceIfNotExists(); if($oThis->bStarted){ if($sKey != "name" && $sKey != "id" && $sKey != "authentication"){ $_SESSION[$oThis->sName][$sKey] = $mValue; return true; } else{ return false; } } else{ return false; } }
[ "public", "static", "function", "Set", "(", "$", "sKey", ",", "$", "mValue", ")", "{", "$", "oThis", "=", "self", "::", "CreateInstanceIfNotExists", "(", ")", ";", "if", "(", "$", "oThis", "->", "bStarted", ")", "{", "if", "(", "$", "sKey", "!=", "\"name\"", "&&", "$", "sKey", "!=", "\"id\"", "&&", "$", "sKey", "!=", "\"authentication\"", ")", "{", "$", "_SESSION", "[", "$", "oThis", "->", "sName", "]", "[", "$", "sKey", "]", "=", "$", "mValue", ";", "return", "true", ";", "}", "else", "{", "return", "false", ";", "}", "}", "else", "{", "return", "false", ";", "}", "}" ]
Function to set data in a session @static @access public @param string $sKey Search Key @param mixed $mValue Data to be stored @return boolean
[ "Function", "to", "set", "data", "in", "a", "session" ]
199934b61c46ec596c27d4fb0355b216dde51d58
https://github.com/magicphp/framework/blob/199934b61c46ec596c27d4fb0355b216dde51d58/src/magicphp/session.class.php#L233-L248
239,908
magicphp/framework
src/magicphp/session.class.php
Session.Get
public static function Get($sKey){ $oThis = self::CreateInstanceIfNotExists(); if($oThis->bStarted) return (!empty($_SESSION[$oThis->sName][$sKey])) ? $_SESSION[$oThis->sName][$sKey] : false; else return null; }
php
public static function Get($sKey){ $oThis = self::CreateInstanceIfNotExists(); if($oThis->bStarted) return (!empty($_SESSION[$oThis->sName][$sKey])) ? $_SESSION[$oThis->sName][$sKey] : false; else return null; }
[ "public", "static", "function", "Get", "(", "$", "sKey", ")", "{", "$", "oThis", "=", "self", "::", "CreateInstanceIfNotExists", "(", ")", ";", "if", "(", "$", "oThis", "->", "bStarted", ")", "return", "(", "!", "empty", "(", "$", "_SESSION", "[", "$", "oThis", "->", "sName", "]", "[", "$", "sKey", "]", ")", ")", "?", "$", "_SESSION", "[", "$", "oThis", "->", "sName", "]", "[", "$", "sKey", "]", ":", "false", ";", "else", "return", "null", ";", "}" ]
Function to return information stored in session @static @access public @param string $sKey Search Key @return mixed
[ "Function", "to", "return", "information", "stored", "in", "session" ]
199934b61c46ec596c27d4fb0355b216dde51d58
https://github.com/magicphp/framework/blob/199934b61c46ec596c27d4fb0355b216dde51d58/src/magicphp/session.class.php#L258-L265
239,909
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/cache.php
Cache.forge
public static function forge($identifier, $config = array()) { // load the default config $defaults = \Config::get('cache', array()); // $config can be either an array of config settings or the name of the storage driver if ( ! empty($config) and ! is_array($config) and ! is_null($config)) { $config = array('driver' => $config); } // Overwrite default values with given config $config = array_merge($defaults, (array) $config); if (empty($config['driver'])) { throw new \FuelException('No cache driver given or no default cache driver set.'); } $class = '\\Cache_Storage_'.ucfirst($config['driver']); // Convert the name to a string when necessary $identifier = call_user_func($class.'::stringify_identifier', $identifier); // Return instance of the requested cache object return new $class($identifier, $config); }
php
public static function forge($identifier, $config = array()) { // load the default config $defaults = \Config::get('cache', array()); // $config can be either an array of config settings or the name of the storage driver if ( ! empty($config) and ! is_array($config) and ! is_null($config)) { $config = array('driver' => $config); } // Overwrite default values with given config $config = array_merge($defaults, (array) $config); if (empty($config['driver'])) { throw new \FuelException('No cache driver given or no default cache driver set.'); } $class = '\\Cache_Storage_'.ucfirst($config['driver']); // Convert the name to a string when necessary $identifier = call_user_func($class.'::stringify_identifier', $identifier); // Return instance of the requested cache object return new $class($identifier, $config); }
[ "public", "static", "function", "forge", "(", "$", "identifier", ",", "$", "config", "=", "array", "(", ")", ")", "{", "// load the default config", "$", "defaults", "=", "\\", "Config", "::", "get", "(", "'cache'", ",", "array", "(", ")", ")", ";", "// $config can be either an array of config settings or the name of the storage driver", "if", "(", "!", "empty", "(", "$", "config", ")", "and", "!", "is_array", "(", "$", "config", ")", "and", "!", "is_null", "(", "$", "config", ")", ")", "{", "$", "config", "=", "array", "(", "'driver'", "=>", "$", "config", ")", ";", "}", "// Overwrite default values with given config", "$", "config", "=", "array_merge", "(", "$", "defaults", ",", "(", "array", ")", "$", "config", ")", ";", "if", "(", "empty", "(", "$", "config", "[", "'driver'", "]", ")", ")", "{", "throw", "new", "\\", "FuelException", "(", "'No cache driver given or no default cache driver set.'", ")", ";", "}", "$", "class", "=", "'\\\\Cache_Storage_'", ".", "ucfirst", "(", "$", "config", "[", "'driver'", "]", ")", ";", "// Convert the name to a string when necessary", "$", "identifier", "=", "call_user_func", "(", "$", "class", ".", "'::stringify_identifier'", ",", "$", "identifier", ")", ";", "// Return instance of the requested cache object", "return", "new", "$", "class", "(", "$", "identifier", ",", "$", "config", ")", ";", "}" ]
Creates a new cache instance. @param mixed The identifier of the cache, can be anything but empty @param array|string Either an array of settings or the storage driver to be used @return Cache_Storage_Driver The new cache object
[ "Creates", "a", "new", "cache", "instance", "." ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/cache.php#L38-L64
239,910
FlexPress/component-routing
src/FlexPress/Components/Routing/Router.php
Router.route
public function route() { $this->routes->rewind(); while ($this->routes->valid()) { $route = $this->routes->current(); if ($route->run()) { return; } $this->routes->next(); } throw new \RuntimeException("FlexPress router: No route found - please make sure you have setup routes."); }
php
public function route() { $this->routes->rewind(); while ($this->routes->valid()) { $route = $this->routes->current(); if ($route->run()) { return; } $this->routes->next(); } throw new \RuntimeException("FlexPress router: No route found - please make sure you have setup routes."); }
[ "public", "function", "route", "(", ")", "{", "$", "this", "->", "routes", "->", "rewind", "(", ")", ";", "while", "(", "$", "this", "->", "routes", "->", "valid", "(", ")", ")", "{", "$", "route", "=", "$", "this", "->", "routes", "->", "current", "(", ")", ";", "if", "(", "$", "route", "->", "run", "(", ")", ")", "{", "return", ";", "}", "$", "this", "->", "routes", "->", "next", "(", ")", ";", "}", "throw", "new", "\\", "RuntimeException", "(", "\"FlexPress router: No route found - please make sure you have setup routes.\"", ")", ";", "}" ]
Runs through all the routes and runs them @author Tim Perry
[ "Runs", "through", "all", "the", "routes", "and", "runs", "them" ]
c1a0c6f1f4522a54e21ee18a8b24adfc1cc28f56
https://github.com/FlexPress/component-routing/blob/c1a0c6f1f4522a54e21ee18a8b24adfc1cc28f56/src/FlexPress/Components/Routing/Router.php#L37-L50
239,911
FlexPress/component-routing
src/FlexPress/Components/Routing/Router.php
Router.replaceFilterFunctions
protected function replaceFilterFunctions(array $conditions) { foreach ($conditions as $key => $condition) { if (is_string($condition)) { $conditions[$key] = $this->filters[$condition]; } } return $conditions; }
php
protected function replaceFilterFunctions(array $conditions) { foreach ($conditions as $key => $condition) { if (is_string($condition)) { $conditions[$key] = $this->filters[$condition]; } } return $conditions; }
[ "protected", "function", "replaceFilterFunctions", "(", "array", "$", "conditions", ")", "{", "foreach", "(", "$", "conditions", "as", "$", "key", "=>", "$", "condition", ")", "{", "if", "(", "is_string", "(", "$", "condition", ")", ")", "{", "$", "conditions", "[", "$", "key", "]", "=", "$", "this", "->", "filters", "[", "$", "condition", "]", ";", "}", "}", "return", "$", "conditions", ";", "}" ]
Replaces the string reference @param $conditions @return string @author Tim Perry
[ "Replaces", "the", "string", "reference" ]
c1a0c6f1f4522a54e21ee18a8b24adfc1cc28f56
https://github.com/FlexPress/component-routing/blob/c1a0c6f1f4522a54e21ee18a8b24adfc1cc28f56/src/FlexPress/Components/Routing/Router.php#L94-L107
239,912
seanmorris/theme
source/Theme.php
Theme.resolveList
public static function resolveList($renderKey, $stopClass = null, $type = null) { $viewListList = static::resolve($renderKey, $stopClass, $type); $finalList = []; foreach($viewListList as $theme => $viewList) { foreach($viewList as $view) { if(is_array($view)) { $finalList = array_merge($finalList, $view); } else { $finalList[] = $view; } } } return array_unique($finalList); }
php
public static function resolveList($renderKey, $stopClass = null, $type = null) { $viewListList = static::resolve($renderKey, $stopClass, $type); $finalList = []; foreach($viewListList as $theme => $viewList) { foreach($viewList as $view) { if(is_array($view)) { $finalList = array_merge($finalList, $view); } else { $finalList[] = $view; } } } return array_unique($finalList); }
[ "public", "static", "function", "resolveList", "(", "$", "renderKey", ",", "$", "stopClass", "=", "null", ",", "$", "type", "=", "null", ")", "{", "$", "viewListList", "=", "static", "::", "resolve", "(", "$", "renderKey", ",", "$", "stopClass", ",", "$", "type", ")", ";", "$", "finalList", "=", "[", "]", ";", "foreach", "(", "$", "viewListList", "as", "$", "theme", "=>", "$", "viewList", ")", "{", "foreach", "(", "$", "viewList", "as", "$", "view", ")", "{", "if", "(", "is_array", "(", "$", "view", ")", ")", "{", "$", "finalList", "=", "array_merge", "(", "$", "finalList", ",", "$", "view", ")", ";", "}", "else", "{", "$", "finalList", "[", "]", "=", "$", "view", ";", "}", "}", "}", "return", "array_unique", "(", "$", "finalList", ")", ";", "}" ]
Resolves a list of classes or other string values for a given renderKey. @param string $renderKey string to resolve values for. @param string $stopClass stop searching the calling context if this class is found. @param string $type type of list to resolve. @return list of string classes or string values mapped from renderKey
[ "Resolves", "a", "list", "of", "classes", "or", "other", "string", "values", "for", "a", "given", "renderKey", "." ]
97554e153312026c7db4af8ae3653d20fe9d117d
https://github.com/seanmorris/theme/blob/97554e153312026c7db4af8ae3653d20fe9d117d/source/Theme.php#L35-L56
239,913
seanmorris/theme
source/Theme.php
Theme.resolveFirst
public static function resolveFirst($renderKey, $stopClass = null, $type = null) { $viewListList = static::resolve($renderKey, $stopClass, $type); $viewList = current($viewListList); if(!$viewList) { return; } $view = current($viewList); return $view; }
php
public static function resolveFirst($renderKey, $stopClass = null, $type = null) { $viewListList = static::resolve($renderKey, $stopClass, $type); $viewList = current($viewListList); if(!$viewList) { return; } $view = current($viewList); return $view; }
[ "public", "static", "function", "resolveFirst", "(", "$", "renderKey", ",", "$", "stopClass", "=", "null", ",", "$", "type", "=", "null", ")", "{", "$", "viewListList", "=", "static", "::", "resolve", "(", "$", "renderKey", ",", "$", "stopClass", ",", "$", "type", ")", ";", "$", "viewList", "=", "current", "(", "$", "viewListList", ")", ";", "if", "(", "!", "$", "viewList", ")", "{", "return", ";", "}", "$", "view", "=", "current", "(", "$", "viewList", ")", ";", "return", "$", "view", ";", "}" ]
Resolves a single class or other string value for a given renderKey. @param string $renderKey string to resolve values for. @param string $stopClass stop searching the calling context if this class is found. @param string $type type of list to resolve. @return string class or string value mapped from renderKey
[ "Resolves", "a", "single", "class", "or", "other", "string", "value", "for", "a", "given", "renderKey", "." ]
97554e153312026c7db4af8ae3653d20fe9d117d
https://github.com/seanmorris/theme/blob/97554e153312026c7db4af8ae3653d20fe9d117d/source/Theme.php#L68-L81
239,914
seanmorris/theme
source/Theme.php
Theme.render
public static function render($object, array $vars = [], $type = null) { if($view = static::resolveFirst($object, null, $type)) { return new $view(['object' => $object] + $vars); } }
php
public static function render($object, array $vars = [], $type = null) { if($view = static::resolveFirst($object, null, $type)) { return new $view(['object' => $object] + $vars); } }
[ "public", "static", "function", "render", "(", "$", "object", ",", "array", "$", "vars", "=", "[", "]", ",", "$", "type", "=", "null", ")", "{", "if", "(", "$", "view", "=", "static", "::", "resolveFirst", "(", "$", "object", ",", "null", ",", "$", "type", ")", ")", "{", "return", "new", "$", "view", "(", "[", "'object'", "=>", "$", "object", "]", "+", "$", "vars", ")", ";", "}", "}" ]
Render a given object with a view provided by the theme. @param object $renderKey string to resolve values for. @param array $vars additional variables passed on to view @param type string type of view to return @return object View object ready to be rendered..
[ "Render", "a", "given", "object", "with", "a", "view", "provided", "by", "the", "theme", "." ]
97554e153312026c7db4af8ae3653d20fe9d117d
https://github.com/seanmorris/theme/blob/97554e153312026c7db4af8ae3653d20fe9d117d/source/Theme.php#L258-L264
239,915
seanmorris/theme
source/Theme.php
Theme.wrap
public static function wrap($body, $vars = []) { if(isset(static::$wrap)) { if($body instanceof \SeanMorris\Theme\View) { $body = $body->render(); } foreach(static::$wrap as $wrapper) { $body = new $wrapper(['body' => $body] + $vars); } } return $body; }
php
public static function wrap($body, $vars = []) { if(isset(static::$wrap)) { if($body instanceof \SeanMorris\Theme\View) { $body = $body->render(); } foreach(static::$wrap as $wrapper) { $body = new $wrapper(['body' => $body] + $vars); } } return $body; }
[ "public", "static", "function", "wrap", "(", "$", "body", ",", "$", "vars", "=", "[", "]", ")", "{", "if", "(", "isset", "(", "static", "::", "$", "wrap", ")", ")", "{", "if", "(", "$", "body", "instanceof", "\\", "SeanMorris", "\\", "Theme", "\\", "View", ")", "{", "$", "body", "=", "$", "body", "->", "render", "(", ")", ";", "}", "foreach", "(", "static", "::", "$", "wrap", "as", "$", "wrapper", ")", "{", "$", "body", "=", "new", "$", "wrapper", "(", "[", "'body'", "=>", "$", "body", "]", "+", "$", "vars", ")", ";", "}", "}", "return", "$", "body", ";", "}" ]
Wrap text with the default trim. @param string $body Value to be wrapped. @return object Wrap view with body.
[ "Wrap", "text", "with", "the", "default", "trim", "." ]
97554e153312026c7db4af8ae3653d20fe9d117d
https://github.com/seanmorris/theme/blob/97554e153312026c7db4af8ae3653d20fe9d117d/source/Theme.php#L289-L305
239,916
seanmorris/theme
source/Theme.php
Theme.selectType
protected static function selectType($views, $type) { if(!is_array($views)) { return $views; } if($type === FALSE) { return $views; } if(!$type) { return current($views); } if(!isset($views[$type])) { return null; } return $views[$type]; }
php
protected static function selectType($views, $type) { if(!is_array($views)) { return $views; } if($type === FALSE) { return $views; } if(!$type) { return current($views); } if(!isset($views[$type])) { return null; } return $views[$type]; }
[ "protected", "static", "function", "selectType", "(", "$", "views", ",", "$", "type", ")", "{", "if", "(", "!", "is_array", "(", "$", "views", ")", ")", "{", "return", "$", "views", ";", "}", "if", "(", "$", "type", "===", "FALSE", ")", "{", "return", "$", "views", ";", "}", "if", "(", "!", "$", "type", ")", "{", "return", "current", "(", "$", "views", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "views", "[", "$", "type", "]", ")", ")", "{", "return", "null", ";", "}", "return", "$", "views", "[", "$", "type", "]", ";", "}" ]
Selects view type when provided and available @param array|object|bool $views List of views by type if available, single view class, or FALSE if no view found. @param string $type Type of view to select. @return object View object ready to be rendered..
[ "Selects", "view", "type", "when", "provided", "and", "available" ]
97554e153312026c7db4af8ae3653d20fe9d117d
https://github.com/seanmorris/theme/blob/97554e153312026c7db4af8ae3653d20fe9d117d/source/Theme.php#L316-L339
239,917
spoom-php/sql
src/extension/Expression/Statement.php
Statement.supportFilter
protected function supportFilter( array $list = [], bool $enable = true ) { foreach( $list as $type ) { if( !$enable ) unset( $this->_filter[ $type ] ); else if( !isset( $this->_filter[ $type ] ) ) $this->_filter[ $type ] = []; } return $this; }
php
protected function supportFilter( array $list = [], bool $enable = true ) { foreach( $list as $type ) { if( !$enable ) unset( $this->_filter[ $type ] ); else if( !isset( $this->_filter[ $type ] ) ) $this->_filter[ $type ] = []; } return $this; }
[ "protected", "function", "supportFilter", "(", "array", "$", "list", "=", "[", "]", ",", "bool", "$", "enable", "=", "true", ")", "{", "foreach", "(", "$", "list", "as", "$", "type", ")", "{", "if", "(", "!", "$", "enable", ")", "unset", "(", "$", "this", "->", "_filter", "[", "$", "type", "]", ")", ";", "else", "if", "(", "!", "isset", "(", "$", "this", "->", "_filter", "[", "$", "type", "]", ")", ")", "$", "this", "->", "_filter", "[", "$", "type", "]", "=", "[", "]", ";", "}", "return", "$", "this", ";", "}" ]
Add or remove support for a filter type @param array $list List of types @param bool $enable @return $this
[ "Add", "or", "remove", "support", "for", "a", "filter", "type" ]
575440c4909ee12851f7d208f4a3998fc4c26f37
https://github.com/spoom-php/sql/blob/575440c4909ee12851f7d208f4a3998fc4c26f37/src/extension/Expression/Statement.php#L427-L434
239,918
spoom-php/sql
src/extension/Expression/Statement.php
Statement.supportCustom
protected function supportCustom( array $list = [], bool $enable = true ) { foreach( $list as $name ) { if( !$enable ) unset( $this->_custom[ $name ] ); else if( !isset( $this->_custom[ $name ] ) ) $this->_custom[ $name ] = []; } return $this; }
php
protected function supportCustom( array $list = [], bool $enable = true ) { foreach( $list as $name ) { if( !$enable ) unset( $this->_custom[ $name ] ); else if( !isset( $this->_custom[ $name ] ) ) $this->_custom[ $name ] = []; } return $this; }
[ "protected", "function", "supportCustom", "(", "array", "$", "list", "=", "[", "]", ",", "bool", "$", "enable", "=", "true", ")", "{", "foreach", "(", "$", "list", "as", "$", "name", ")", "{", "if", "(", "!", "$", "enable", ")", "unset", "(", "$", "this", "->", "_custom", "[", "$", "name", "]", ")", ";", "else", "if", "(", "!", "isset", "(", "$", "this", "->", "_custom", "[", "$", "name", "]", ")", ")", "$", "this", "->", "_custom", "[", "$", "name", "]", "=", "[", "]", ";", "}", "return", "$", "this", ";", "}" ]
Add or remove support for a custom @param array $list List of customs @param bool $enable @return $this
[ "Add", "or", "remove", "support", "for", "a", "custom" ]
575440c4909ee12851f7d208f4a3998fc4c26f37
https://github.com/spoom-php/sql/blob/575440c4909ee12851f7d208f4a3998fc4c26f37/src/extension/Expression/Statement.php#L443-L450
239,919
leodido/conversio
library/Conversion.php
Conversion.setAdapter
public function setAdapter($adapter) { if (!is_string($adapter) && !$adapter instanceof ConversionAlgorithmInterface) { throw new Exception\InvalidArgumentException(sprintf( '"%s" expects a string or an instance of ConversionAlgorithmInterface; received "%s"', __METHOD__, is_object($adapter) ? get_class($adapter) : gettype($adapter) )); } if (is_string($adapter)) { if (!class_exists($adapter)) { throw new Exception\RuntimeException(sprintf( '"%s" unable to load adapter; class "%s" not found', __METHOD__, $adapter )); } $adapter = new $adapter(); if (!$adapter instanceof ConversionAlgorithmInterface) { throw new Exception\InvalidArgumentException(sprintf( '"%s" expects a string representing an instance of ConversionAlgorithmInterface; received "%s"', __METHOD__, is_object($adapter) ? get_class($adapter) : gettype($adapter) )); } } $this->adapter = $adapter; return $this; }
php
public function setAdapter($adapter) { if (!is_string($adapter) && !$adapter instanceof ConversionAlgorithmInterface) { throw new Exception\InvalidArgumentException(sprintf( '"%s" expects a string or an instance of ConversionAlgorithmInterface; received "%s"', __METHOD__, is_object($adapter) ? get_class($adapter) : gettype($adapter) )); } if (is_string($adapter)) { if (!class_exists($adapter)) { throw new Exception\RuntimeException(sprintf( '"%s" unable to load adapter; class "%s" not found', __METHOD__, $adapter )); } $adapter = new $adapter(); if (!$adapter instanceof ConversionAlgorithmInterface) { throw new Exception\InvalidArgumentException(sprintf( '"%s" expects a string representing an instance of ConversionAlgorithmInterface; received "%s"', __METHOD__, is_object($adapter) ? get_class($adapter) : gettype($adapter) )); } } $this->adapter = $adapter; return $this; }
[ "public", "function", "setAdapter", "(", "$", "adapter", ")", "{", "if", "(", "!", "is_string", "(", "$", "adapter", ")", "&&", "!", "$", "adapter", "instanceof", "ConversionAlgorithmInterface", ")", "{", "throw", "new", "Exception", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'\"%s\" expects a string or an instance of ConversionAlgorithmInterface; received \"%s\"'", ",", "__METHOD__", ",", "is_object", "(", "$", "adapter", ")", "?", "get_class", "(", "$", "adapter", ")", ":", "gettype", "(", "$", "adapter", ")", ")", ")", ";", "}", "if", "(", "is_string", "(", "$", "adapter", ")", ")", "{", "if", "(", "!", "class_exists", "(", "$", "adapter", ")", ")", "{", "throw", "new", "Exception", "\\", "RuntimeException", "(", "sprintf", "(", "'\"%s\" unable to load adapter; class \"%s\" not found'", ",", "__METHOD__", ",", "$", "adapter", ")", ")", ";", "}", "$", "adapter", "=", "new", "$", "adapter", "(", ")", ";", "if", "(", "!", "$", "adapter", "instanceof", "ConversionAlgorithmInterface", ")", "{", "throw", "new", "Exception", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'\"%s\" expects a string representing an instance of ConversionAlgorithmInterface; received \"%s\"'", ",", "__METHOD__", ",", "is_object", "(", "$", "adapter", ")", "?", "get_class", "(", "$", "adapter", ")", ":", "gettype", "(", "$", "adapter", ")", ")", ")", ";", "}", "}", "$", "this", "->", "adapter", "=", "$", "adapter", ";", "return", "$", "this", ";", "}" ]
Sets conversion adapter @param string|ConversionAlgorithmInterface $adapter Adapter to use @return $this @throws Exception\InvalidArgumentException @throws Exception\RuntimeException
[ "Sets", "conversion", "adapter" ]
ebbb626b0cf2a44729af6d46d753b5a4b06d9835
https://github.com/leodido/conversio/blob/ebbb626b0cf2a44729af6d46d753b5a4b06d9835/library/Conversion.php#L62-L91
239,920
leodido/conversio
library/Conversion.php
Conversion.getAdapter
public function getAdapter() { if (!$this->adapter) { throw new Exception\RuntimeException(sprintf( '"%s" unable to load adapter; adapter not found', __METHOD__ )); } if (method_exists($this->adapter, 'setOptions')) { $this->adapter->setOptions($this->getAdapterOptions()); } return $this->adapter; }
php
public function getAdapter() { if (!$this->adapter) { throw new Exception\RuntimeException(sprintf( '"%s" unable to load adapter; adapter not found', __METHOD__ )); } if (method_exists($this->adapter, 'setOptions')) { $this->adapter->setOptions($this->getAdapterOptions()); } return $this->adapter; }
[ "public", "function", "getAdapter", "(", ")", "{", "if", "(", "!", "$", "this", "->", "adapter", ")", "{", "throw", "new", "Exception", "\\", "RuntimeException", "(", "sprintf", "(", "'\"%s\" unable to load adapter; adapter not found'", ",", "__METHOD__", ")", ")", ";", "}", "if", "(", "method_exists", "(", "$", "this", "->", "adapter", ",", "'setOptions'", ")", ")", "{", "$", "this", "->", "adapter", "->", "setOptions", "(", "$", "this", "->", "getAdapterOptions", "(", ")", ")", ";", "}", "return", "$", "this", "->", "adapter", ";", "}" ]
Returns the current adapter @return ConversionAlgorithmInterface @throws Exception\RuntimeException
[ "Returns", "the", "current", "adapter" ]
ebbb626b0cf2a44729af6d46d753b5a4b06d9835
https://github.com/leodido/conversio/blob/ebbb626b0cf2a44729af6d46d753b5a4b06d9835/library/Conversion.php#L99-L112
239,921
leodido/conversio
library/Conversion.php
Conversion.setAdapterOptions
public function setAdapterOptions($options) { if (!is_array($options) && !$options instanceof AbstractOptions) { throw new Exception\InvalidArgumentException(sprintf( '"%s" expects an array or a valid instance of "%s"; received "%s"', __METHOD__, 'Zend\Stdlib\AbstractOptions', is_object($options) ? get_class($options) : gettype($options) )); } $this->adapterOptions = $options; $this->options = $options; return $this; }
php
public function setAdapterOptions($options) { if (!is_array($options) && !$options instanceof AbstractOptions) { throw new Exception\InvalidArgumentException(sprintf( '"%s" expects an array or a valid instance of "%s"; received "%s"', __METHOD__, 'Zend\Stdlib\AbstractOptions', is_object($options) ? get_class($options) : gettype($options) )); } $this->adapterOptions = $options; $this->options = $options; return $this; }
[ "public", "function", "setAdapterOptions", "(", "$", "options", ")", "{", "if", "(", "!", "is_array", "(", "$", "options", ")", "&&", "!", "$", "options", "instanceof", "AbstractOptions", ")", "{", "throw", "new", "Exception", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'\"%s\" expects an array or a valid instance of \"%s\"; received \"%s\"'", ",", "__METHOD__", ",", "'Zend\\Stdlib\\AbstractOptions'", ",", "is_object", "(", "$", "options", ")", "?", "get_class", "(", "$", "options", ")", ":", "gettype", "(", "$", "options", ")", ")", ")", ";", "}", "$", "this", "->", "adapterOptions", "=", "$", "options", ";", "$", "this", "->", "options", "=", "$", "options", ";", "return", "$", "this", ";", "}" ]
Set adapter options @param array|AbstractOptions $options @return $this
[ "Set", "adapter", "options" ]
ebbb626b0cf2a44729af6d46d753b5a4b06d9835
https://github.com/leodido/conversio/blob/ebbb626b0cf2a44729af6d46d753b5a4b06d9835/library/Conversion.php#L130-L144
239,922
leodido/conversio
library/Conversion.php
Conversion.getAbstractOptions
protected function getAbstractOptions() { $optClass = self::getOptionsFullQualifiedClassName($this->adapter); // Does the option class exist? if (!class_exists($optClass)) { throw new Exception\DomainException( sprintf( '"%s" expects that an options class ("%s") for the current adapter exists', __METHOD__, $optClass ) ); } $opts = new $optClass(); if (!$opts instanceof AbstractOptions) { throw new Exception\DomainException(sprintf( '"%s" expects the options class to resolve to a valid "%s" instance; received "%s"', __METHOD__, 'Zend\Stdlib\AbstractOptions', $optClass )); } return $opts; }
php
protected function getAbstractOptions() { $optClass = self::getOptionsFullQualifiedClassName($this->adapter); // Does the option class exist? if (!class_exists($optClass)) { throw new Exception\DomainException( sprintf( '"%s" expects that an options class ("%s") for the current adapter exists', __METHOD__, $optClass ) ); } $opts = new $optClass(); if (!$opts instanceof AbstractOptions) { throw new Exception\DomainException(sprintf( '"%s" expects the options class to resolve to a valid "%s" instance; received "%s"', __METHOD__, 'Zend\Stdlib\AbstractOptions', $optClass )); } return $opts; }
[ "protected", "function", "getAbstractOptions", "(", ")", "{", "$", "optClass", "=", "self", "::", "getOptionsFullQualifiedClassName", "(", "$", "this", "->", "adapter", ")", ";", "// Does the option class exist?", "if", "(", "!", "class_exists", "(", "$", "optClass", ")", ")", "{", "throw", "new", "Exception", "\\", "DomainException", "(", "sprintf", "(", "'\"%s\" expects that an options class (\"%s\") for the current adapter exists'", ",", "__METHOD__", ",", "$", "optClass", ")", ")", ";", "}", "$", "opts", "=", "new", "$", "optClass", "(", ")", ";", "if", "(", "!", "$", "opts", "instanceof", "AbstractOptions", ")", "{", "throw", "new", "Exception", "\\", "DomainException", "(", "sprintf", "(", "'\"%s\" expects the options class to resolve to a valid \"%s\" instance; received \"%s\"'", ",", "__METHOD__", ",", "'Zend\\Stdlib\\AbstractOptions'", ",", "$", "optClass", ")", ")", ";", "}", "return", "$", "opts", ";", "}" ]
Instantiate and retrieve the options of the current adapter It also checks that an appropriate options class exists. @return AbstractOptions
[ "Instantiate", "and", "retrieve", "the", "options", "of", "the", "current", "adapter" ]
ebbb626b0cf2a44729af6d46d753b5a4b06d9835
https://github.com/leodido/conversio/blob/ebbb626b0cf2a44729af6d46d753b5a4b06d9835/library/Conversion.php#L176-L199
239,923
leodido/conversio
library/Conversion.php
Conversion.getOptions
public function getOptions($option = null) { $this->getAdapterOptions(); if ($option !== null) { if (!isset($this->options[$option])) { throw new Exception\RuntimeException(sprintf( 'Options "%s" not found', $option )); } return $this->options[$option]; } return $this->options; }
php
public function getOptions($option = null) { $this->getAdapterOptions(); if ($option !== null) { if (!isset($this->options[$option])) { throw new Exception\RuntimeException(sprintf( 'Options "%s" not found', $option )); } return $this->options[$option]; } return $this->options; }
[ "public", "function", "getOptions", "(", "$", "option", "=", "null", ")", "{", "$", "this", "->", "getAdapterOptions", "(", ")", ";", "if", "(", "$", "option", "!==", "null", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "options", "[", "$", "option", "]", ")", ")", "{", "throw", "new", "Exception", "\\", "RuntimeException", "(", "sprintf", "(", "'Options \"%s\" not found'", ",", "$", "option", ")", ")", ";", "}", "return", "$", "this", "->", "options", "[", "$", "option", "]", ";", "}", "return", "$", "this", "->", "options", ";", "}" ]
Get individual or all options from underlying adapter options object @param string|null $option @return mixed|array
[ "Get", "individual", "or", "all", "options", "from", "underlying", "adapter", "options", "object" ]
ebbb626b0cf2a44729af6d46d753b5a4b06d9835
https://github.com/leodido/conversio/blob/ebbb626b0cf2a44729af6d46d753b5a4b06d9835/library/Conversion.php#L235-L248
239,924
leodido/conversio
library/Conversion.php
Conversion.getOptionsFullQualifiedClassName
public static function getOptionsFullQualifiedClassName($adapter) { if (!$adapter) { throw new Exception\InvalidArgumentException(sprintf( '"%s" unable to load adapter; adapter not found', __METHOD__ )); } if (!$adapter instanceof ConversionAlgorithmInterface) { throw new Exception\InvalidArgumentException(sprintf( '"%s" expects an instance of ConversionAlgorithmInterface; received "%s"', __METHOD__, is_object($adapter) ? get_class($adapter) : gettype($adapter) )); } $adapterClass = get_class($adapter); $namespace = substr($adapterClass, 0, strrpos($adapterClass, '\\')); return $namespace . '\\Options\\' . $adapter->getName() . 'Options'; }
php
public static function getOptionsFullQualifiedClassName($adapter) { if (!$adapter) { throw new Exception\InvalidArgumentException(sprintf( '"%s" unable to load adapter; adapter not found', __METHOD__ )); } if (!$adapter instanceof ConversionAlgorithmInterface) { throw new Exception\InvalidArgumentException(sprintf( '"%s" expects an instance of ConversionAlgorithmInterface; received "%s"', __METHOD__, is_object($adapter) ? get_class($adapter) : gettype($adapter) )); } $adapterClass = get_class($adapter); $namespace = substr($adapterClass, 0, strrpos($adapterClass, '\\')); return $namespace . '\\Options\\' . $adapter->getName() . 'Options'; }
[ "public", "static", "function", "getOptionsFullQualifiedClassName", "(", "$", "adapter", ")", "{", "if", "(", "!", "$", "adapter", ")", "{", "throw", "new", "Exception", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'\"%s\" unable to load adapter; adapter not found'", ",", "__METHOD__", ")", ")", ";", "}", "if", "(", "!", "$", "adapter", "instanceof", "ConversionAlgorithmInterface", ")", "{", "throw", "new", "Exception", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'\"%s\" expects an instance of ConversionAlgorithmInterface; received \"%s\"'", ",", "__METHOD__", ",", "is_object", "(", "$", "adapter", ")", "?", "get_class", "(", "$", "adapter", ")", ":", "gettype", "(", "$", "adapter", ")", ")", ")", ";", "}", "$", "adapterClass", "=", "get_class", "(", "$", "adapter", ")", ";", "$", "namespace", "=", "substr", "(", "$", "adapterClass", ",", "0", ",", "strrpos", "(", "$", "adapterClass", ",", "'\\\\'", ")", ")", ";", "return", "$", "namespace", ".", "'\\\\Options\\\\'", ".", "$", "adapter", "->", "getName", "(", ")", ".", "'Options'", ";", "}" ]
Recreate the full qualified class name of options class for the supplied adapter @param ConversionAlgorithmInterface|null $adapter @return string @throws Exception\InvalidArgumentException
[ "Recreate", "the", "full", "qualified", "class", "name", "of", "options", "class", "for", "the", "supplied", "adapter" ]
ebbb626b0cf2a44729af6d46d753b5a4b06d9835
https://github.com/leodido/conversio/blob/ebbb626b0cf2a44729af6d46d753b5a4b06d9835/library/Conversion.php#L268-L287
239,925
MESD/JasperReportViewerBundle
Util/FormCompletenessChecker.php
FormCompletenessChecker.isComplete
public static function isComplete(Form $form) { //Set the return value to true by default $ret = true; //Foreach child of the form foreach($form->all() as $child) { //If the child is required, check that its set if ($child->isRequired()) { if ($child->isEmpty()) { $ret = false; break; } } } //Return return $ret; }
php
public static function isComplete(Form $form) { //Set the return value to true by default $ret = true; //Foreach child of the form foreach($form->all() as $child) { //If the child is required, check that its set if ($child->isRequired()) { if ($child->isEmpty()) { $ret = false; break; } } } //Return return $ret; }
[ "public", "static", "function", "isComplete", "(", "Form", "$", "form", ")", "{", "//Set the return value to true by default", "$", "ret", "=", "true", ";", "//Foreach child of the form", "foreach", "(", "$", "form", "->", "all", "(", ")", "as", "$", "child", ")", "{", "//If the child is required, check that its set", "if", "(", "$", "child", "->", "isRequired", "(", ")", ")", "{", "if", "(", "$", "child", "->", "isEmpty", "(", ")", ")", "{", "$", "ret", "=", "false", ";", "break", ";", "}", "}", "}", "//Return", "return", "$", "ret", ";", "}" ]
Checks if the required fields of a form have values @param Form $form The form to check @return boolean Whether the required fields are set
[ "Checks", "if", "the", "required", "fields", "of", "a", "form", "have", "values" ]
d51ff079ba79b35c549a7ac472a305d416060d86
https://github.com/MESD/JasperReportViewerBundle/blob/d51ff079ba79b35c549a7ac472a305d416060d86/Util/FormCompletenessChecker.php#L21-L39
239,926
koinephp/Core
lib/Koine/KoineString.php
KoineString.at
public function at($start = null, $length = null) { return new self(mb_substr((string) $this, $start, $length, 'UTF-8')); }
php
public function at($start = null, $length = null) { return new self(mb_substr((string) $this, $start, $length, 'UTF-8')); }
[ "public", "function", "at", "(", "$", "start", "=", "null", ",", "$", "length", "=", "null", ")", "{", "return", "new", "self", "(", "mb_substr", "(", "(", "string", ")", "$", "this", ",", "$", "start", ",", "$", "length", ",", "'UTF-8'", ")", ")", ";", "}" ]
Returns part of a string Known bug in php 5.3.3 @see https://bugs.php.net/bug.php?id=62703 @param int start @param int $length the length of the string from the starting point @return KoineString
[ "Returns", "part", "of", "a", "string", "Known", "bug", "in", "php", "5", ".", "3", ".", "3" ]
9b9543f1b4699fd515590f2f94654bad098821ff
https://github.com/koinephp/Core/blob/9b9543f1b4699fd515590f2f94654bad098821ff/lib/Koine/KoineString.php#L161-L164
239,927
joegreen88/zf1-component-http
src/Zend/Http/Response/Stream.php
Zend_Http_Response_Stream.fromStream
public static function fromStream($response_str, $stream) { $code = self::extractCode($response_str); $headers = self::extractHeaders($response_str); $version = self::extractVersion($response_str); $message = self::extractMessage($response_str); return new self($code, $headers, $stream, $version, $message); }
php
public static function fromStream($response_str, $stream) { $code = self::extractCode($response_str); $headers = self::extractHeaders($response_str); $version = self::extractVersion($response_str); $message = self::extractMessage($response_str); return new self($code, $headers, $stream, $version, $message); }
[ "public", "static", "function", "fromStream", "(", "$", "response_str", ",", "$", "stream", ")", "{", "$", "code", "=", "self", "::", "extractCode", "(", "$", "response_str", ")", ";", "$", "headers", "=", "self", "::", "extractHeaders", "(", "$", "response_str", ")", ";", "$", "version", "=", "self", "::", "extractVersion", "(", "$", "response_str", ")", ";", "$", "message", "=", "self", "::", "extractMessage", "(", "$", "response_str", ")", ";", "return", "new", "self", "(", "$", "code", ",", "$", "headers", ",", "$", "stream", ",", "$", "version", ",", "$", "message", ")", ";", "}" ]
Create a new Zend_Http_Response_Stream object from a string @param string $response_str @param resource $stream @return Zend_Http_Response_Stream
[ "Create", "a", "new", "Zend_Http_Response_Stream", "object", "from", "a", "string" ]
39e834e8f0393cf4223d099a0acaab5fa05e9ad4
https://github.com/joegreen88/zf1-component-http/blob/39e834e8f0393cf4223d099a0acaab5fa05e9ad4/src/Zend/Http/Response/Stream.php#L156-L164
239,928
joegreen88/zf1-component-http
src/Zend/Http/Response/Stream.php
Zend_Http_Response_Stream.readStream
protected function readStream() { if(!is_resource($this->stream)) { return ''; } if(isset($headers['content-length'])) { $this->body = stream_get_contents($this->stream, $headers['content-length']); } else { $this->body = stream_get_contents($this->stream); } fclose($this->stream); $this->stream = null; }
php
protected function readStream() { if(!is_resource($this->stream)) { return ''; } if(isset($headers['content-length'])) { $this->body = stream_get_contents($this->stream, $headers['content-length']); } else { $this->body = stream_get_contents($this->stream); } fclose($this->stream); $this->stream = null; }
[ "protected", "function", "readStream", "(", ")", "{", "if", "(", "!", "is_resource", "(", "$", "this", "->", "stream", ")", ")", "{", "return", "''", ";", "}", "if", "(", "isset", "(", "$", "headers", "[", "'content-length'", "]", ")", ")", "{", "$", "this", "->", "body", "=", "stream_get_contents", "(", "$", "this", "->", "stream", ",", "$", "headers", "[", "'content-length'", "]", ")", ";", "}", "else", "{", "$", "this", "->", "body", "=", "stream_get_contents", "(", "$", "this", "->", "stream", ")", ";", "}", "fclose", "(", "$", "this", "->", "stream", ")", ";", "$", "this", "->", "stream", "=", "null", ";", "}" ]
Read stream content and return it as string Function reads the remainder of the body from the stream and closes the stream. @return string
[ "Read", "stream", "content", "and", "return", "it", "as", "string" ]
39e834e8f0393cf4223d099a0acaab5fa05e9ad4
https://github.com/joegreen88/zf1-component-http/blob/39e834e8f0393cf4223d099a0acaab5fa05e9ad4/src/Zend/Http/Response/Stream.php#L209-L222
239,929
phlexible/phlexible
src/Phlexible/Bundle/UserBundle/Controller/RolesController.php
RolesController.listAction
public function listAction() { $roleHierarchy = $this->container->getParameter('security.role_hierarchy.roles'); $roles = []; foreach (array_keys($roleHierarchy) as $role) { $roles[] = ['id' => $role, 'name' => $role]; } return new JsonResponse($roles); }
php
public function listAction() { $roleHierarchy = $this->container->getParameter('security.role_hierarchy.roles'); $roles = []; foreach (array_keys($roleHierarchy) as $role) { $roles[] = ['id' => $role, 'name' => $role]; } return new JsonResponse($roles); }
[ "public", "function", "listAction", "(", ")", "{", "$", "roleHierarchy", "=", "$", "this", "->", "container", "->", "getParameter", "(", "'security.role_hierarchy.roles'", ")", ";", "$", "roles", "=", "[", "]", ";", "foreach", "(", "array_keys", "(", "$", "roleHierarchy", ")", "as", "$", "role", ")", "{", "$", "roles", "[", "]", "=", "[", "'id'", "=>", "$", "role", ",", "'name'", "=>", "$", "role", "]", ";", "}", "return", "new", "JsonResponse", "(", "$", "roles", ")", ";", "}" ]
List roles. @return JsonResponse @Route("", name="users_roles_list") @Method("GET") @ApiDoc( description="Returns a list of roles" )
[ "List", "roles", "." ]
132f24924c9bb0dbb6c1ea84db0a463f97fa3893
https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/UserBundle/Controller/RolesController.php#L40-L50
239,930
agalbourdin/agl-core
src/Data/Ini.php
Ini.loadFile
public function loadFile($pFile, $pParseKeys = false) { $this->_content = parse_ini_file($pFile, true); if ($pParseKeys) { $this->_parseKeys($this->_content); } return $this; }
php
public function loadFile($pFile, $pParseKeys = false) { $this->_content = parse_ini_file($pFile, true); if ($pParseKeys) { $this->_parseKeys($this->_content); } return $this; }
[ "public", "function", "loadFile", "(", "$", "pFile", ",", "$", "pParseKeys", "=", "false", ")", "{", "$", "this", "->", "_content", "=", "parse_ini_file", "(", "$", "pFile", ",", "true", ")", ";", "if", "(", "$", "pParseKeys", ")", "{", "$", "this", "->", "_parseKeys", "(", "$", "this", "->", "_content", ")", ";", "}", "return", "$", "this", ";", "}" ]
Load the INI file content into the _content variable, as a multidimensional array. @var bool $pParseKeys Parse the keys to create multidimensional arrays @return Ini
[ "Load", "the", "INI", "file", "content", "into", "the", "_content", "variable", "as", "a", "multidimensional", "array", "." ]
1db556f9a49488aa9fab6887fefb7141a79ad97d
https://github.com/agalbourdin/agl-core/blob/1db556f9a49488aa9fab6887fefb7141a79ad97d/src/Data/Ini.php#L68-L76
239,931
veridu/idos-sdk-php
src/idOS/SDK.php
SDK.create
public static function create( AuthInterface $authentication, bool $throwsExceptions = false, string $baseUrl = 'https://api.idos.io/1.0/' ) : self { return new static( $authentication, new Client(), $throwsExceptions, $baseUrl ); }
php
public static function create( AuthInterface $authentication, bool $throwsExceptions = false, string $baseUrl = 'https://api.idos.io/1.0/' ) : self { return new static( $authentication, new Client(), $throwsExceptions, $baseUrl ); }
[ "public", "static", "function", "create", "(", "AuthInterface", "$", "authentication", ",", "bool", "$", "throwsExceptions", "=", "false", ",", "string", "$", "baseUrl", "=", "'https://api.idos.io/1.0/'", ")", ":", "self", "{", "return", "new", "static", "(", "$", "authentication", ",", "new", "Client", "(", ")", ",", "$", "throwsExceptions", ",", "$", "baseUrl", ")", ";", "}" ]
Creates the SDK instance. @param \idOS\Auth\AuthInterface $authentication @param bool $throwsExceptions @param string $baseUrl @return self instance
[ "Creates", "the", "SDK", "instance", "." ]
e56757bed10404756f2f0485a4b7f55794192008
https://github.com/veridu/idos-sdk-php/blob/e56757bed10404756f2f0485a4b7f55794192008/src/idOS/SDK.php#L47-L58
239,932
veridu/idos-sdk-php
src/idOS/SDK.php
SDK.getEndpointClassName
protected function getEndpointClassName(string $name) : string { $className = sprintf( '%s\\%s\\%s', 'idOS', 'Endpoint', ucfirst($name) ); if (! class_exists($className)) { throw new \RuntimeException( sprintf( 'Invalid endpoint name "%s" (%s)', $name, $className ) ); } return $className; }
php
protected function getEndpointClassName(string $name) : string { $className = sprintf( '%s\\%s\\%s', 'idOS', 'Endpoint', ucfirst($name) ); if (! class_exists($className)) { throw new \RuntimeException( sprintf( 'Invalid endpoint name "%s" (%s)', $name, $className ) ); } return $className; }
[ "protected", "function", "getEndpointClassName", "(", "string", "$", "name", ")", ":", "string", "{", "$", "className", "=", "sprintf", "(", "'%s\\\\%s\\\\%s'", ",", "'idOS'", ",", "'Endpoint'", ",", "ucfirst", "(", "$", "name", ")", ")", ";", "if", "(", "!", "class_exists", "(", "$", "className", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "sprintf", "(", "'Invalid endpoint name \"%s\" (%s)'", ",", "$", "name", ",", "$", "className", ")", ")", ";", "}", "return", "$", "className", ";", "}" ]
Returns the name of the endpoint class. @param string $name @return string className
[ "Returns", "the", "name", "of", "the", "endpoint", "class", "." ]
e56757bed10404756f2f0485a4b7f55794192008
https://github.com/veridu/idos-sdk-php/blob/e56757bed10404756f2f0485a4b7f55794192008/src/idOS/SDK.php#L213-L232
239,933
vincenttouzet/AdminConfigurationBundle
Configuration/AdminConfigurationBuilder.php
AdminConfigurationBuilder.addSection
public function addSection($name, $label, $position=0) { $sectionManager = $this->container->get('admin.configuration.configsection_manager'); $section = $sectionManager->getRepository()->findOneByName($name); if (!$section) { $section = new ConfigSection(); $section->setName($name); $section->setSLabel($label); $section->setPosition($position); $sectionManager->create($section); return true; } return false; }
php
public function addSection($name, $label, $position=0) { $sectionManager = $this->container->get('admin.configuration.configsection_manager'); $section = $sectionManager->getRepository()->findOneByName($name); if (!$section) { $section = new ConfigSection(); $section->setName($name); $section->setSLabel($label); $section->setPosition($position); $sectionManager->create($section); return true; } return false; }
[ "public", "function", "addSection", "(", "$", "name", ",", "$", "label", ",", "$", "position", "=", "0", ")", "{", "$", "sectionManager", "=", "$", "this", "->", "container", "->", "get", "(", "'admin.configuration.configsection_manager'", ")", ";", "$", "section", "=", "$", "sectionManager", "->", "getRepository", "(", ")", "->", "findOneByName", "(", "$", "name", ")", ";", "if", "(", "!", "$", "section", ")", "{", "$", "section", "=", "new", "ConfigSection", "(", ")", ";", "$", "section", "->", "setName", "(", "$", "name", ")", ";", "$", "section", "->", "setSLabel", "(", "$", "label", ")", ";", "$", "section", "->", "setPosition", "(", "$", "position", ")", ";", "$", "sectionManager", "->", "create", "(", "$", "section", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Add a ConfigSection If a ConfigSection with the same name exists then it does nothing @param string $name Name @param string $label Label @param integer $position Position @return boolean
[ "Add", "a", "ConfigSection", "If", "a", "ConfigSection", "with", "the", "same", "name", "exists", "then", "it", "does", "nothing" ]
8e7edd0810d88aa1d1be4bd303bcc14cbfd0caeb
https://github.com/vincenttouzet/AdminConfigurationBundle/blob/8e7edd0810d88aa1d1be4bd303bcc14cbfd0caeb/Configuration/AdminConfigurationBuilder.php#L66-L81
239,934
vincenttouzet/AdminConfigurationBundle
Configuration/AdminConfigurationBuilder.php
AdminConfigurationBuilder.addGroup
public function addGroup($sectionName, $name, $label, $position=0) { $groupManager = $this->container->get('admin.configuration.configgroup_manager'); $sectionManager = $this->container->get('admin.configuration.configsection_manager'); $group = $groupManager->getRepository()->findOneBySectionAndGroupName($sectionName, $name); $section = $sectionManager->getRepository()->findOneByName($sectionName); if (!$section) { throw new AdminConfigurationBuilderException(sprintf('The section "%s" does not exist.', $sectionName)); } if (!$group && $section) { $group = new ConfigGroup(); $group->setConfigSection($section); $group->setName($name); $group->setGLabel($label); $group->setPosition($position); $groupManager->create($group); return true; } return false; }
php
public function addGroup($sectionName, $name, $label, $position=0) { $groupManager = $this->container->get('admin.configuration.configgroup_manager'); $sectionManager = $this->container->get('admin.configuration.configsection_manager'); $group = $groupManager->getRepository()->findOneBySectionAndGroupName($sectionName, $name); $section = $sectionManager->getRepository()->findOneByName($sectionName); if (!$section) { throw new AdminConfigurationBuilderException(sprintf('The section "%s" does not exist.', $sectionName)); } if (!$group && $section) { $group = new ConfigGroup(); $group->setConfigSection($section); $group->setName($name); $group->setGLabel($label); $group->setPosition($position); $groupManager->create($group); return true; } return false; }
[ "public", "function", "addGroup", "(", "$", "sectionName", ",", "$", "name", ",", "$", "label", ",", "$", "position", "=", "0", ")", "{", "$", "groupManager", "=", "$", "this", "->", "container", "->", "get", "(", "'admin.configuration.configgroup_manager'", ")", ";", "$", "sectionManager", "=", "$", "this", "->", "container", "->", "get", "(", "'admin.configuration.configsection_manager'", ")", ";", "$", "group", "=", "$", "groupManager", "->", "getRepository", "(", ")", "->", "findOneBySectionAndGroupName", "(", "$", "sectionName", ",", "$", "name", ")", ";", "$", "section", "=", "$", "sectionManager", "->", "getRepository", "(", ")", "->", "findOneByName", "(", "$", "sectionName", ")", ";", "if", "(", "!", "$", "section", ")", "{", "throw", "new", "AdminConfigurationBuilderException", "(", "sprintf", "(", "'The section \"%s\" does not exist.'", ",", "$", "sectionName", ")", ")", ";", "}", "if", "(", "!", "$", "group", "&&", "$", "section", ")", "{", "$", "group", "=", "new", "ConfigGroup", "(", ")", ";", "$", "group", "->", "setConfigSection", "(", "$", "section", ")", ";", "$", "group", "->", "setName", "(", "$", "name", ")", ";", "$", "group", "->", "setGLabel", "(", "$", "label", ")", ";", "$", "group", "->", "setPosition", "(", "$", "position", ")", ";", "$", "groupManager", "->", "create", "(", "$", "group", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Add a ConfigGroup If a ConfigGroup with this name and within this section already exist then it does nothing @param string $sectionName Section name @param string $name Group name @param string $label Group label @param integer $position Group position @return boolean
[ "Add", "a", "ConfigGroup", "If", "a", "ConfigGroup", "with", "this", "name", "and", "within", "this", "section", "already", "exist", "then", "it", "does", "nothing" ]
8e7edd0810d88aa1d1be4bd303bcc14cbfd0caeb
https://github.com/vincenttouzet/AdminConfigurationBundle/blob/8e7edd0810d88aa1d1be4bd303bcc14cbfd0caeb/Configuration/AdminConfigurationBuilder.php#L94-L115
239,935
vincenttouzet/AdminConfigurationBundle
Configuration/AdminConfigurationBuilder.php
AdminConfigurationBuilder.addType
public function addType($identifier, $label, $formType, $options = array()) { $typeManager = $this->container->get('admin.configuration.configtype_manager'); $type = $typeManager->getRepository()->findOneByIdentifier($identifier); if (!$type) { $type = new ConfigType(); $type->setIdentifier($identifier); $type->setTLabel($label); $type->setFormType($formType); if ( is_array($options) && count($options) ) { $type->setOptions(json_encode($options)); } $typeManager->create($type); return true; } return false; }
php
public function addType($identifier, $label, $formType, $options = array()) { $typeManager = $this->container->get('admin.configuration.configtype_manager'); $type = $typeManager->getRepository()->findOneByIdentifier($identifier); if (!$type) { $type = new ConfigType(); $type->setIdentifier($identifier); $type->setTLabel($label); $type->setFormType($formType); if ( is_array($options) && count($options) ) { $type->setOptions(json_encode($options)); } $typeManager->create($type); return true; } return false; }
[ "public", "function", "addType", "(", "$", "identifier", ",", "$", "label", ",", "$", "formType", ",", "$", "options", "=", "array", "(", ")", ")", "{", "$", "typeManager", "=", "$", "this", "->", "container", "->", "get", "(", "'admin.configuration.configtype_manager'", ")", ";", "$", "type", "=", "$", "typeManager", "->", "getRepository", "(", ")", "->", "findOneByIdentifier", "(", "$", "identifier", ")", ";", "if", "(", "!", "$", "type", ")", "{", "$", "type", "=", "new", "ConfigType", "(", ")", ";", "$", "type", "->", "setIdentifier", "(", "$", "identifier", ")", ";", "$", "type", "->", "setTLabel", "(", "$", "label", ")", ";", "$", "type", "->", "setFormType", "(", "$", "formType", ")", ";", "if", "(", "is_array", "(", "$", "options", ")", "&&", "count", "(", "$", "options", ")", ")", "{", "$", "type", "->", "setOptions", "(", "json_encode", "(", "$", "options", ")", ")", ";", "}", "$", "typeManager", "->", "create", "(", "$", "type", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Add a ConfigType If a ConfigType with this identifier already exists then it does nothing @param string $identifier Type identifier @param string $label Type label @param string $formType Form type @param array $options Form options @return boolean
[ "Add", "a", "ConfigType", "If", "a", "ConfigType", "with", "this", "identifier", "already", "exists", "then", "it", "does", "nothing" ]
8e7edd0810d88aa1d1be4bd303bcc14cbfd0caeb
https://github.com/vincenttouzet/AdminConfigurationBundle/blob/8e7edd0810d88aa1d1be4bd303bcc14cbfd0caeb/Configuration/AdminConfigurationBuilder.php#L128-L146
239,936
budkit/budkit-framework
src/Budkit/Session/Store.php
Store.getUploadProgress
final public static function getUploadProgress($formName) { $key = ini_get("session.upload_progress.prefix") . $formName; if (!empty($_SESSION[$key])) { $current = $_SESSION[$key]["bytes_processed"]; $total = $_SESSION[$key]["content_length"]; return $current < $total ? ceil($current / $total * 100) : 100; } else { return 100; } }
php
final public static function getUploadProgress($formName) { $key = ini_get("session.upload_progress.prefix") . $formName; if (!empty($_SESSION[$key])) { $current = $_SESSION[$key]["bytes_processed"]; $total = $_SESSION[$key]["content_length"]; return $current < $total ? ceil($current / $total * 100) : 100; } else { return 100; } }
[ "final", "public", "static", "function", "getUploadProgress", "(", "$", "formName", ")", "{", "$", "key", "=", "ini_get", "(", "\"session.upload_progress.prefix\"", ")", ".", "$", "formName", ";", "if", "(", "!", "empty", "(", "$", "_SESSION", "[", "$", "key", "]", ")", ")", "{", "$", "current", "=", "$", "_SESSION", "[", "$", "key", "]", "[", "\"bytes_processed\"", "]", ";", "$", "total", "=", "$", "_SESSION", "[", "$", "key", "]", "[", "\"content_length\"", "]", ";", "return", "$", "current", "<", "$", "total", "?", "ceil", "(", "$", "current", "/", "$", "total", "*", "100", ")", ":", "100", ";", "}", "else", "{", "return", "100", ";", "}", "}" ]
Gets the Upload progressName @param type $formName @return int
[ "Gets", "the", "Upload", "progressName" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Session/Store.php#L115-L126
239,937
budkit/budkit-framework
src/Budkit/Session/Store.php
Store.start
final public function start($killPrevious = FALSE) { //starts this session if not creates a new one //$self = (!isset($this) || !is_a($this, "Library\Session")) ? self::getInstance() : $this; //@TODO Check if there is an existing session! //If there is any previous and killprevious is false, //simply do a garbage collection and return; //if we can't read the session if (($session = $this->read()) !== FALSE) { $this->update($session); } else { $this->create(); } //Carbage collection $this->gc(); }
php
final public function start($killPrevious = FALSE) { //starts this session if not creates a new one //$self = (!isset($this) || !is_a($this, "Library\Session")) ? self::getInstance() : $this; //@TODO Check if there is an existing session! //If there is any previous and killprevious is false, //simply do a garbage collection and return; //if we can't read the session if (($session = $this->read()) !== FALSE) { $this->update($session); } else { $this->create(); } //Carbage collection $this->gc(); }
[ "final", "public", "function", "start", "(", "$", "killPrevious", "=", "FALSE", ")", "{", "//starts this session if not creates a new one", "//$self = (!isset($this) || !is_a($this, \"Library\\Session\")) ? self::getInstance() : $this;", "//@TODO Check if there is an existing session!", "//If there is any previous and killprevious is false,", "//simply do a garbage collection and return;", "//if we can't read the session", "if", "(", "(", "$", "session", "=", "$", "this", "->", "read", "(", ")", ")", "!==", "FALSE", ")", "{", "$", "this", "->", "update", "(", "$", "session", ")", ";", "}", "else", "{", "$", "this", "->", "create", "(", ")", ";", "}", "//Carbage collection", "$", "this", "->", "gc", "(", ")", ";", "}" ]
Starts a session @param type $killPrevious @return void
[ "Starts", "a", "session" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Session/Store.php#L134-L150
239,938
budkit/budkit-framework
src/Budkit/Session/Store.php
Store.getSplash
final public function getSplash() { $userIp = md5($this->input->serialize($this->input->getVar('REMOTE_ADDR', \IS\STRING, '', 'server'))); $userAgent = md5($this->input->serialize($this->input->getVar('HTTP_USER_AGENT', \IS\STRING, '', 'server'))); $userDomain = md5($this->input->serialize((string)$this->uri->getHost())); //throw in a token for specific id of browser, $token = (string)$this->generateToken(); $splash = array( "ip" => $userIp, "agent" => $userAgent, "domain" => $userDomain, "token" => $token ); return $splash; }
php
final public function getSplash() { $userIp = md5($this->input->serialize($this->input->getVar('REMOTE_ADDR', \IS\STRING, '', 'server'))); $userAgent = md5($this->input->serialize($this->input->getVar('HTTP_USER_AGENT', \IS\STRING, '', 'server'))); $userDomain = md5($this->input->serialize((string)$this->uri->getHost())); //throw in a token for specific id of browser, $token = (string)$this->generateToken(); $splash = array( "ip" => $userIp, "agent" => $userAgent, "domain" => $userDomain, "token" => $token ); return $splash; }
[ "final", "public", "function", "getSplash", "(", ")", "{", "$", "userIp", "=", "md5", "(", "$", "this", "->", "input", "->", "serialize", "(", "$", "this", "->", "input", "->", "getVar", "(", "'REMOTE_ADDR'", ",", "\\", "IS", "\\", "STRING", ",", "''", ",", "'server'", ")", ")", ")", ";", "$", "userAgent", "=", "md5", "(", "$", "this", "->", "input", "->", "serialize", "(", "$", "this", "->", "input", "->", "getVar", "(", "'HTTP_USER_AGENT'", ",", "\\", "IS", "\\", "STRING", ",", "''", ",", "'server'", ")", ")", ")", ";", "$", "userDomain", "=", "md5", "(", "$", "this", "->", "input", "->", "serialize", "(", "(", "string", ")", "$", "this", "->", "uri", "->", "getHost", "(", ")", ")", ")", ";", "//throw in a token for specific id of browser,", "$", "token", "=", "(", "string", ")", "$", "this", "->", "generateToken", "(", ")", ";", "$", "splash", "=", "array", "(", "\"ip\"", "=>", "$", "userIp", ",", "\"agent\"", "=>", "$", "userAgent", ",", "\"domain\"", "=>", "$", "userDomain", ",", "\"token\"", "=>", "$", "token", ")", ";", "return", "$", "splash", ";", "}" ]
Gets session parameters and develop a 'splash' @return type
[ "Gets", "session", "parameters", "and", "develop", "a", "splash" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Session/Store.php#L157-L175
239,939
budkit/budkit-framework
src/Budkit/Session/Store.php
Store.create
final public function create() { $self = $this; $splash = $self->getSplash(); $sessId = $this->generateId($splash); session_id($sessId); //Must be called before the sesion start to generate the Id session_cache_limiter('none'); session_name(md5($self->cookie . $splash['agent'] . $splash['ip'] . $splash['domain'])); session_start(); //Create the default namespace; affix to splash; //The default namespace will contain vars such as -request count, - last session start time, -last session response time, etc //The dfault namespace will also contain, instantiated objects? // $defaultReg = new Registry("default"); $self->registry['default'] = $defaultReg; //update the cookie with the expiry time //Create the authenticated namespace and lock it! $self->set("handler", $this->authenticator, "auth"); $this->write($sessId, $splash); }
php
final public function create() { $self = $this; $splash = $self->getSplash(); $sessId = $this->generateId($splash); session_id($sessId); //Must be called before the sesion start to generate the Id session_cache_limiter('none'); session_name(md5($self->cookie . $splash['agent'] . $splash['ip'] . $splash['domain'])); session_start(); //Create the default namespace; affix to splash; //The default namespace will contain vars such as -request count, - last session start time, -last session response time, etc //The dfault namespace will also contain, instantiated objects? // $defaultReg = new Registry("default"); $self->registry['default'] = $defaultReg; //update the cookie with the expiry time //Create the authenticated namespace and lock it! $self->set("handler", $this->authenticator, "auth"); $this->write($sessId, $splash); }
[ "final", "public", "function", "create", "(", ")", "{", "$", "self", "=", "$", "this", ";", "$", "splash", "=", "$", "self", "->", "getSplash", "(", ")", ";", "$", "sessId", "=", "$", "this", "->", "generateId", "(", "$", "splash", ")", ";", "session_id", "(", "$", "sessId", ")", ";", "//Must be called before the sesion start to generate the Id", "session_cache_limiter", "(", "'none'", ")", ";", "session_name", "(", "md5", "(", "$", "self", "->", "cookie", ".", "$", "splash", "[", "'agent'", "]", ".", "$", "splash", "[", "'ip'", "]", ".", "$", "splash", "[", "'domain'", "]", ")", ")", ";", "session_start", "(", ")", ";", "//Create the default namespace; affix to splash;", "//The default namespace will contain vars such as -request count, - last session start time, -last session response time, etc", "//The dfault namespace will also contain, instantiated objects?", "//", "$", "defaultReg", "=", "new", "Registry", "(", "\"default\"", ")", ";", "$", "self", "->", "registry", "[", "'default'", "]", "=", "$", "defaultReg", ";", "//update the cookie with the expiry time", "//Create the authenticated namespace and lock it!", "$", "self", "->", "set", "(", "\"handler\"", ",", "$", "this", "->", "authenticator", ",", "\"auth\"", ")", ";", "$", "this", "->", "write", "(", "$", "sessId", ",", "$", "splash", ")", ";", "}" ]
Creates a new session. Will only create a session if none is found The 'default' and 'auth' namespaces are also added The 'auth' namespace is locked and unwrittable, @return void
[ "Creates", "a", "new", "session", "." ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Session/Store.php#L186-L212
239,940
budkit/budkit-framework
src/Budkit/Session/Store.php
Store.getAuthority
final public function getAuthority() { $self = $this; $auth = $self->get("handler", "auth"); //$authority = \Platform\Authorize::getInstance(); if (is_a($auth, Authenticate::class)) { if (isset($auth->authenticated)) { //Read Rights if we have a userId //$self->authority = $authority->getPermissions($auth); } } //return $self->authority; }
php
final public function getAuthority() { $self = $this; $auth = $self->get("handler", "auth"); //$authority = \Platform\Authorize::getInstance(); if (is_a($auth, Authenticate::class)) { if (isset($auth->authenticated)) { //Read Rights if we have a userId //$self->authority = $authority->getPermissions($auth); } } //return $self->authority; }
[ "final", "public", "function", "getAuthority", "(", ")", "{", "$", "self", "=", "$", "this", ";", "$", "auth", "=", "$", "self", "->", "get", "(", "\"handler\"", ",", "\"auth\"", ")", ";", "//$authority = \\Platform\\Authorize::getInstance();", "if", "(", "is_a", "(", "$", "auth", ",", "Authenticate", "::", "class", ")", ")", "{", "if", "(", "isset", "(", "$", "auth", "->", "authenticated", ")", ")", "{", "//Read Rights if we have a userId", "//$self->authority = $authority->getPermissions($auth);", "}", "}", "//return $self->authority;", "}" ]
Reads the authenticated user's right, @return Authority
[ "Reads", "the", "authenticated", "user", "s", "right" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Session/Store.php#L219-L235
239,941
budkit/budkit-framework
src/Budkit/Session/Store.php
Store.isAuthenticated
final public function isAuthenticated() { $self = $this; $auth = $self->get("handler", "auth"); if (is_a($auth, Authenticate::class)) { if (isset($auth->authenticated)) { return (bool)$auth->authenticated; } } return false; }
php
final public function isAuthenticated() { $self = $this; $auth = $self->get("handler", "auth"); if (is_a($auth, Authenticate::class)) { if (isset($auth->authenticated)) { return (bool)$auth->authenticated; } } return false; }
[ "final", "public", "function", "isAuthenticated", "(", ")", "{", "$", "self", "=", "$", "this", ";", "$", "auth", "=", "$", "self", "->", "get", "(", "\"handler\"", ",", "\"auth\"", ")", ";", "if", "(", "is_a", "(", "$", "auth", ",", "Authenticate", "::", "class", ")", ")", "{", "if", "(", "isset", "(", "$", "auth", "->", "authenticated", ")", ")", "{", "return", "(", "bool", ")", "$", "auth", "->", "authenticated", ";", "}", "}", "return", "false", ";", "}" ]
Determines whether a user has been Authenticated to this browser; @return boolean True or false depending on auth status
[ "Determines", "whether", "a", "user", "has", "been", "Authenticated", "to", "this", "browser", ";" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Session/Store.php#L243-L256
239,942
budkit/budkit-framework
src/Budkit/Session/Store.php
Store.generateId
final public function generateId($splash) { $encryptor = $this->encryptor; $input = $this->input; $sessId = md5($encryptor->getKey() . $input->serialize($splash)); return $sessId; }
php
final public function generateId($splash) { $encryptor = $this->encryptor; $input = $this->input; $sessId = md5($encryptor->getKey() . $input->serialize($splash)); return $sessId; }
[ "final", "public", "function", "generateId", "(", "$", "splash", ")", "{", "$", "encryptor", "=", "$", "this", "->", "encryptor", ";", "$", "input", "=", "$", "this", "->", "input", ";", "$", "sessId", "=", "md5", "(", "$", "encryptor", "->", "getKey", "(", ")", ".", "$", "input", "->", "serialize", "(", "$", "splash", ")", ")", ";", "return", "$", "sessId", ";", "}" ]
Generates the session Id @param type $splash @return type
[ "Generates", "the", "session", "Id" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Session/Store.php#L332-L340
239,943
budkit/budkit-framework
src/Budkit/Session/Store.php
Store.read
final public function read($id = Null) { $self = $this; $input = $this->input; $uri = $this->uri; //$dbo = Database::getInstance(); $splash = $self->getSplash(); //Do we have a cookie? $sessCookie = md5($self->cookie . $splash['agent'] . $splash['ip'] . $splash['domain']); $sessId = $input->getCookie($sessCookie); if (empty($sessId) || !$sessId) { //we will have to create a new session return false; } $userIp = md5($input->serialize($input->getVar('REMOTE_ADDR', \IS\STRING, '', 'server'))); $userAgent = md5($input->serialize($input->getVar('HTTP_USER_AGENT', \IS\STRING, '', 'server'))); $userDomain = md5($input->serialize((string)$uri->getHost())); //Read the session //$_handler = ucfirst($self->store); $handler = $this->handler; $object = $handler->read($splash, $self, $sessId); //If this is not an object then we have a problem if (!is_object($object)) return false; //Redecorate $splash = array( "ip" => $userIp, "agent" => $userAgent, "domain" => $userDomain, "token" => $object->session_token ); $testId = $self->generateId($splash); if ($testId <> $sessId) { $this->destroy($sessId); return false; //will lead to re-creation } //check if expired $now = time(); if ($object->session_expires < $now) { $this->destroy($sessId); return false; //Will lead to re-creation of a new one } $self->ip = $object->session_ip; $self->agent = $object->session_agent; $self->token = $object->session_token; $self->id = $sessId; //@TODO Restore the registry //which hopefully should contain auth and other serialized info in namespsaces $registry = new Registry("default"); //Validate? if (!empty($object->session_registry)) { //First get an instance of the registry, just to be sure its loaded $registry = $input->unserialize($object->session_registry); $self->registry = $registry; $_SESSION = $self->getNamespace("default")->getAllData(); } else { //just re-create a default registry $_SESSION = array(); //Session is array; //Because we can't restore $self->registry['default'] = $registry; } //Update total requests in the default namespace; $reqCount = $self->get("totalRequests"); $newCount = $reqCount + 1; //Set a total Requests Count $self->set("totalRequests", $newCount); //Return the session Id, to pass to self::update return $sessId; }
php
final public function read($id = Null) { $self = $this; $input = $this->input; $uri = $this->uri; //$dbo = Database::getInstance(); $splash = $self->getSplash(); //Do we have a cookie? $sessCookie = md5($self->cookie . $splash['agent'] . $splash['ip'] . $splash['domain']); $sessId = $input->getCookie($sessCookie); if (empty($sessId) || !$sessId) { //we will have to create a new session return false; } $userIp = md5($input->serialize($input->getVar('REMOTE_ADDR', \IS\STRING, '', 'server'))); $userAgent = md5($input->serialize($input->getVar('HTTP_USER_AGENT', \IS\STRING, '', 'server'))); $userDomain = md5($input->serialize((string)$uri->getHost())); //Read the session //$_handler = ucfirst($self->store); $handler = $this->handler; $object = $handler->read($splash, $self, $sessId); //If this is not an object then we have a problem if (!is_object($object)) return false; //Redecorate $splash = array( "ip" => $userIp, "agent" => $userAgent, "domain" => $userDomain, "token" => $object->session_token ); $testId = $self->generateId($splash); if ($testId <> $sessId) { $this->destroy($sessId); return false; //will lead to re-creation } //check if expired $now = time(); if ($object->session_expires < $now) { $this->destroy($sessId); return false; //Will lead to re-creation of a new one } $self->ip = $object->session_ip; $self->agent = $object->session_agent; $self->token = $object->session_token; $self->id = $sessId; //@TODO Restore the registry //which hopefully should contain auth and other serialized info in namespsaces $registry = new Registry("default"); //Validate? if (!empty($object->session_registry)) { //First get an instance of the registry, just to be sure its loaded $registry = $input->unserialize($object->session_registry); $self->registry = $registry; $_SESSION = $self->getNamespace("default")->getAllData(); } else { //just re-create a default registry $_SESSION = array(); //Session is array; //Because we can't restore $self->registry['default'] = $registry; } //Update total requests in the default namespace; $reqCount = $self->get("totalRequests"); $newCount = $reqCount + 1; //Set a total Requests Count $self->set("totalRequests", $newCount); //Return the session Id, to pass to self::update return $sessId; }
[ "final", "public", "function", "read", "(", "$", "id", "=", "Null", ")", "{", "$", "self", "=", "$", "this", ";", "$", "input", "=", "$", "this", "->", "input", ";", "$", "uri", "=", "$", "this", "->", "uri", ";", "//$dbo = Database::getInstance();", "$", "splash", "=", "$", "self", "->", "getSplash", "(", ")", ";", "//Do we have a cookie?", "$", "sessCookie", "=", "md5", "(", "$", "self", "->", "cookie", ".", "$", "splash", "[", "'agent'", "]", ".", "$", "splash", "[", "'ip'", "]", ".", "$", "splash", "[", "'domain'", "]", ")", ";", "$", "sessId", "=", "$", "input", "->", "getCookie", "(", "$", "sessCookie", ")", ";", "if", "(", "empty", "(", "$", "sessId", ")", "||", "!", "$", "sessId", ")", "{", "//we will have to create a new session", "return", "false", ";", "}", "$", "userIp", "=", "md5", "(", "$", "input", "->", "serialize", "(", "$", "input", "->", "getVar", "(", "'REMOTE_ADDR'", ",", "\\", "IS", "\\", "STRING", ",", "''", ",", "'server'", ")", ")", ")", ";", "$", "userAgent", "=", "md5", "(", "$", "input", "->", "serialize", "(", "$", "input", "->", "getVar", "(", "'HTTP_USER_AGENT'", ",", "\\", "IS", "\\", "STRING", ",", "''", ",", "'server'", ")", ")", ")", ";", "$", "userDomain", "=", "md5", "(", "$", "input", "->", "serialize", "(", "(", "string", ")", "$", "uri", "->", "getHost", "(", ")", ")", ")", ";", "//Read the session", "//$_handler = ucfirst($self->store);", "$", "handler", "=", "$", "this", "->", "handler", ";", "$", "object", "=", "$", "handler", "->", "read", "(", "$", "splash", ",", "$", "self", ",", "$", "sessId", ")", ";", "//If this is not an object then we have a problem", "if", "(", "!", "is_object", "(", "$", "object", ")", ")", "return", "false", ";", "//Redecorate", "$", "splash", "=", "array", "(", "\"ip\"", "=>", "$", "userIp", ",", "\"agent\"", "=>", "$", "userAgent", ",", "\"domain\"", "=>", "$", "userDomain", ",", "\"token\"", "=>", "$", "object", "->", "session_token", ")", ";", "$", "testId", "=", "$", "self", "->", "generateId", "(", "$", "splash", ")", ";", "if", "(", "$", "testId", "<>", "$", "sessId", ")", "{", "$", "this", "->", "destroy", "(", "$", "sessId", ")", ";", "return", "false", ";", "//will lead to re-creation", "}", "//check if expired", "$", "now", "=", "time", "(", ")", ";", "if", "(", "$", "object", "->", "session_expires", "<", "$", "now", ")", "{", "$", "this", "->", "destroy", "(", "$", "sessId", ")", ";", "return", "false", ";", "//Will lead to re-creation of a new one", "}", "$", "self", "->", "ip", "=", "$", "object", "->", "session_ip", ";", "$", "self", "->", "agent", "=", "$", "object", "->", "session_agent", ";", "$", "self", "->", "token", "=", "$", "object", "->", "session_token", ";", "$", "self", "->", "id", "=", "$", "sessId", ";", "//@TODO Restore the registry", "//which hopefully should contain auth and other serialized info in namespsaces", "$", "registry", "=", "new", "Registry", "(", "\"default\"", ")", ";", "//Validate?", "if", "(", "!", "empty", "(", "$", "object", "->", "session_registry", ")", ")", "{", "//First get an instance of the registry, just to be sure its loaded", "$", "registry", "=", "$", "input", "->", "unserialize", "(", "$", "object", "->", "session_registry", ")", ";", "$", "self", "->", "registry", "=", "$", "registry", ";", "$", "_SESSION", "=", "$", "self", "->", "getNamespace", "(", "\"default\"", ")", "->", "getAllData", "(", ")", ";", "}", "else", "{", "//just re-create a default registry", "$", "_SESSION", "=", "array", "(", ")", ";", "//Session is array;", "//Because we can't restore", "$", "self", "->", "registry", "[", "'default'", "]", "=", "$", "registry", ";", "}", "//Update total requests in the default namespace;", "$", "reqCount", "=", "$", "self", "->", "get", "(", "\"totalRequests\"", ")", ";", "$", "newCount", "=", "$", "reqCount", "+", "1", ";", "//Set a total Requests Count", "$", "self", "->", "set", "(", "\"totalRequests\"", ",", "$", "newCount", ")", ";", "//Return the session Id, to pass to self::update", "return", "$", "sessId", ";", "}" ]
Reads session data from session stores @param string $id @return Boolean False on failed and session ID on success
[ "Reads", "session", "data", "from", "session", "stores" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Session/Store.php#L348-L433
239,944
budkit/budkit-framework
src/Budkit/Session/Store.php
Store.update
final public function update($sessId, $userdata = array()) { if (empty($sessId)) { return false; } $self = $this; //updates a started session for exp time //stores data for the registry $now = time(); $newExpires = $now + $self->life; $update = array( "session_lastactive" => $now, "session_expires" => $newExpires ); $self->id = $sessId; //If isset registry and is not empty, store userdata; if (isset($self->registry) && is_array($self->registry)) { $userdata = $this->input->serialize($self->registry); $update["session_registry"] = $userdata; } //Read the session $handler = $this->handler; //Must be called before the sesion start to generate the Id session_id($sessId); //session_start(); if (!$handler->update($update, $self, $self->id)) { return false; } return true; }
php
final public function update($sessId, $userdata = array()) { if (empty($sessId)) { return false; } $self = $this; //updates a started session for exp time //stores data for the registry $now = time(); $newExpires = $now + $self->life; $update = array( "session_lastactive" => $now, "session_expires" => $newExpires ); $self->id = $sessId; //If isset registry and is not empty, store userdata; if (isset($self->registry) && is_array($self->registry)) { $userdata = $this->input->serialize($self->registry); $update["session_registry"] = $userdata; } //Read the session $handler = $this->handler; //Must be called before the sesion start to generate the Id session_id($sessId); //session_start(); if (!$handler->update($update, $self, $self->id)) { return false; } return true; }
[ "final", "public", "function", "update", "(", "$", "sessId", ",", "$", "userdata", "=", "array", "(", ")", ")", "{", "if", "(", "empty", "(", "$", "sessId", ")", ")", "{", "return", "false", ";", "}", "$", "self", "=", "$", "this", ";", "//updates a started session for exp time", "//stores data for the registry", "$", "now", "=", "time", "(", ")", ";", "$", "newExpires", "=", "$", "now", "+", "$", "self", "->", "life", ";", "$", "update", "=", "array", "(", "\"session_lastactive\"", "=>", "$", "now", ",", "\"session_expires\"", "=>", "$", "newExpires", ")", ";", "$", "self", "->", "id", "=", "$", "sessId", ";", "//If isset registry and is not empty, store userdata;", "if", "(", "isset", "(", "$", "self", "->", "registry", ")", "&&", "is_array", "(", "$", "self", "->", "registry", ")", ")", "{", "$", "userdata", "=", "$", "this", "->", "input", "->", "serialize", "(", "$", "self", "->", "registry", ")", ";", "$", "update", "[", "\"session_registry\"", "]", "=", "$", "userdata", ";", "}", "//Read the session", "$", "handler", "=", "$", "this", "->", "handler", ";", "//Must be called before the sesion start to generate the Id", "session_id", "(", "$", "sessId", ")", ";", "//session_start();", "if", "(", "!", "$", "handler", "->", "update", "(", "$", "update", ",", "$", "self", ",", "$", "self", "->", "id", ")", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
Updates a user session store on state change @param type $sessId @param type $userdata @return type
[ "Updates", "a", "user", "session", "store", "on", "state", "change" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Session/Store.php#L442-L478
239,945
budkit/budkit-framework
src/Budkit/Session/Store.php
Store.restart
final public function restart() { $id = $this->getId(); $this->destroy($id); $this->create(); $this->gc(); }
php
final public function restart() { $id = $this->getId(); $this->destroy($id); $this->create(); $this->gc(); }
[ "final", "public", "function", "restart", "(", ")", "{", "$", "id", "=", "$", "this", "->", "getId", "(", ")", ";", "$", "this", "->", "destroy", "(", "$", "id", ")", ";", "$", "this", "->", "create", "(", ")", ";", "$", "this", "->", "gc", "(", ")", ";", "}" ]
Destroys any previous session and starts a new one Hopefully @return void
[ "Destroys", "any", "previous", "session", "and", "starts", "a", "new", "one", "Hopefully" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Session/Store.php#L486-L494
239,946
budkit/budkit-framework
src/Budkit/Session/Store.php
Store.destroy
final public function destroy($id = "") { $id = !empty($id) ? $id : $this->getId(); $now = time(); if (empty($id)) { return false; } setcookie(session_name(), '', $now - 42000, '/'); if (session_id()) { @session_unset(); @session_destroy(); } //Delete from db; //Do a garbage collection $this->gc($id); }
php
final public function destroy($id = "") { $id = !empty($id) ? $id : $this->getId(); $now = time(); if (empty($id)) { return false; } setcookie(session_name(), '', $now - 42000, '/'); if (session_id()) { @session_unset(); @session_destroy(); } //Delete from db; //Do a garbage collection $this->gc($id); }
[ "final", "public", "function", "destroy", "(", "$", "id", "=", "\"\"", ")", "{", "$", "id", "=", "!", "empty", "(", "$", "id", ")", "?", "$", "id", ":", "$", "this", "->", "getId", "(", ")", ";", "$", "now", "=", "time", "(", ")", ";", "if", "(", "empty", "(", "$", "id", ")", ")", "{", "return", "false", ";", "}", "setcookie", "(", "session_name", "(", ")", ",", "''", ",", "$", "now", "-", "42000", ",", "'/'", ")", ";", "if", "(", "session_id", "(", ")", ")", "{", "@", "session_unset", "(", ")", ";", "@", "session_destroy", "(", ")", ";", "}", "//Delete from db;", "//Do a garbage collection", "$", "this", "->", "gc", "(", "$", "id", ")", ";", "}" ]
Destroys a redundant session @param type $id @param type $restart
[ "Destroys", "a", "redundant", "session" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Session/Store.php#L502-L522
239,947
budkit/budkit-framework
src/Budkit/Session/Store.php
Store.write
final public function write($sessId, $data = array()) { //Writes user data to the db; $self = $this; //expires $expires = time() + $self->life; //Sets the cookie //$output->setCookie($self->cookie, $sessId."0".$data['token'], $expires); //$output->setCookie($sessId, $data['token'], $expires); $cookie = session_get_cookie_params(); //Cookie parameters session_set_cookie_params($expires, $cookie['path'], $cookie['domain'], true); $self->id = session_id(); $userdata = $this->input->serialize($self->registry); //last modified = now; //expires = now + life ; $handler = $this->handler; if (!$handler->write($userdata, $data, $self, $sessId, $expires)) { return false; } return true; }
php
final public function write($sessId, $data = array()) { //Writes user data to the db; $self = $this; //expires $expires = time() + $self->life; //Sets the cookie //$output->setCookie($self->cookie, $sessId."0".$data['token'], $expires); //$output->setCookie($sessId, $data['token'], $expires); $cookie = session_get_cookie_params(); //Cookie parameters session_set_cookie_params($expires, $cookie['path'], $cookie['domain'], true); $self->id = session_id(); $userdata = $this->input->serialize($self->registry); //last modified = now; //expires = now + life ; $handler = $this->handler; if (!$handler->write($userdata, $data, $self, $sessId, $expires)) { return false; } return true; }
[ "final", "public", "function", "write", "(", "$", "sessId", ",", "$", "data", "=", "array", "(", ")", ")", "{", "//Writes user data to the db;", "$", "self", "=", "$", "this", ";", "//expires", "$", "expires", "=", "time", "(", ")", "+", "$", "self", "->", "life", ";", "//Sets the cookie", "//$output->setCookie($self->cookie, $sessId.\"0\".$data['token'], $expires);", "//$output->setCookie($sessId, $data['token'], $expires);", "$", "cookie", "=", "session_get_cookie_params", "(", ")", ";", "//Cookie parameters", "session_set_cookie_params", "(", "$", "expires", ",", "$", "cookie", "[", "'path'", "]", ",", "$", "cookie", "[", "'domain'", "]", ",", "true", ")", ";", "$", "self", "->", "id", "=", "session_id", "(", ")", ";", "$", "userdata", "=", "$", "this", "->", "input", "->", "serialize", "(", "$", "self", "->", "registry", ")", ";", "//last modified = now;", "//expires = now + life ;", "$", "handler", "=", "$", "this", "->", "handler", ";", "if", "(", "!", "$", "handler", "->", "write", "(", "$", "userdata", ",", "$", "data", ",", "$", "self", ",", "$", "sessId", ",", "$", "expires", ")", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
Writes data to session stores @param type $data @param type $sessId @return type
[ "Writes", "data", "to", "session", "stores" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Session/Store.php#L531-L560
239,948
budkit/budkit-framework
src/Budkit/Session/Store.php
Store.lock
final public function lock($namespace) { //locks a namespace in this session to prevent editing if (empty($namespace)) { //@TODO throw an exception, //we don't know what namespace this is return false; } $session = $this; //unlocks a namespace if (isset($session->registry[$namespace]) && !$session->isLocked($namespace)) { $session->registry[$namespace]->lock(); return true; } return false; }
php
final public function lock($namespace) { //locks a namespace in this session to prevent editing if (empty($namespace)) { //@TODO throw an exception, //we don't know what namespace this is return false; } $session = $this; //unlocks a namespace if (isset($session->registry[$namespace]) && !$session->isLocked($namespace)) { $session->registry[$namespace]->lock(); return true; } return false; }
[ "final", "public", "function", "lock", "(", "$", "namespace", ")", "{", "//locks a namespace in this session to prevent editing", "if", "(", "empty", "(", "$", "namespace", ")", ")", "{", "//@TODO throw an exception,", "//we don't know what namespace this is", "return", "false", ";", "}", "$", "session", "=", "$", "this", ";", "//unlocks a namespace", "if", "(", "isset", "(", "$", "session", "->", "registry", "[", "$", "namespace", "]", ")", "&&", "!", "$", "session", "->", "isLocked", "(", "$", "namespace", ")", ")", "{", "$", "session", "->", "registry", "[", "$", "namespace", "]", "->", "lock", "(", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Locks a namespaced registry to prevent further edits @param type $namespace @return type
[ "Locks", "a", "namespaced", "registry", "to", "prevent", "further", "edits" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Session/Store.php#L652-L668
239,949
budkit/budkit-framework
src/Budkit/Session/Store.php
Store.isLocked
final public function isLocked($namespace) { if (empty($namespace)) { return true; //just say its locked } //checks if a namespace in this session is locked $session = $this; //unlocks a namespace if (isset($session->registry[$namespace])) { return $session->registry[$namespace]->isLocked(); } return false; }
php
final public function isLocked($namespace) { if (empty($namespace)) { return true; //just say its locked } //checks if a namespace in this session is locked $session = $this; //unlocks a namespace if (isset($session->registry[$namespace])) { return $session->registry[$namespace]->isLocked(); } return false; }
[ "final", "public", "function", "isLocked", "(", "$", "namespace", ")", "{", "if", "(", "empty", "(", "$", "namespace", ")", ")", "{", "return", "true", ";", "//just say its locked", "}", "//checks if a namespace in this session is locked", "$", "session", "=", "$", "this", ";", "//unlocks a namespace", "if", "(", "isset", "(", "$", "session", "->", "registry", "[", "$", "namespace", "]", ")", ")", "{", "return", "$", "session", "->", "registry", "[", "$", "namespace", "]", "->", "isLocked", "(", ")", ";", "}", "return", "false", ";", "}" ]
Determines whether a namespaced registry is locked @param type $namespace @return type
[ "Determines", "whether", "a", "namespaced", "registry", "is", "locked" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Session/Store.php#L676-L691
239,950
budkit/budkit-framework
src/Budkit/Session/Store.php
Store.get
final public function get($varname, $namespace = 'default') { //gets a registry var, stored in a namespace of this session id $session = $this; if (!isset($namespace) || empty($namespace)) { //@TODO Throw an exception, we need a name or use the default; return false; } //@TODO, check if the regitry is not locked before adding $registry = $session->getNamespace($namespace); return $registry->get($varname); }
php
final public function get($varname, $namespace = 'default') { //gets a registry var, stored in a namespace of this session id $session = $this; if (!isset($namespace) || empty($namespace)) { //@TODO Throw an exception, we need a name or use the default; return false; } //@TODO, check if the regitry is not locked before adding $registry = $session->getNamespace($namespace); return $registry->get($varname); }
[ "final", "public", "function", "get", "(", "$", "varname", ",", "$", "namespace", "=", "'default'", ")", "{", "//gets a registry var, stored in a namespace of this session id", "$", "session", "=", "$", "this", ";", "if", "(", "!", "isset", "(", "$", "namespace", ")", "||", "empty", "(", "$", "namespace", ")", ")", "{", "//@TODO Throw an exception, we need a name or use the default;", "return", "false", ";", "}", "//@TODO, check if the regitry is not locked before adding", "$", "registry", "=", "$", "session", "->", "getNamespace", "(", "$", "namespace", ")", ";", "return", "$", "registry", "->", "get", "(", "$", "varname", ")", ";", "}" ]
Gets a namespaced registry value, stored in the session @param type $varname @param type $namespace @return type
[ "Gets", "a", "namespaced", "registry", "value", "stored", "in", "the", "session" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Session/Store.php#L739-L753
239,951
budkit/budkit-framework
src/Budkit/Session/Store.php
Store.set
final public function set($varname, $value = NULL, $namespace = 'default') { //stores a value to a varname in a namespace of this session $session = $this; if (!isset($namespace) || empty($namespace)) { //@TODO Throw an exception, we need a name or use the default; throw new Exception("Cannot set new Session variable to unknown '{$namespace}' namespace"); return false; } //If we don't have a registry to that namespace; if (!isset($session->registry[$namespace])) { //Create it; $registry = new Registry($namespace); $session->registry[$namespace] = $registry; } //echo $namespace; //@TODO, check if the regitry is not locked before adding if (!$session->isLocked($namespace)) { $registry = $session->getNamespace($namespace); $registry->set($varname, $value); } //If auth is locked return $session; }
php
final public function set($varname, $value = NULL, $namespace = 'default') { //stores a value to a varname in a namespace of this session $session = $this; if (!isset($namespace) || empty($namespace)) { //@TODO Throw an exception, we need a name or use the default; throw new Exception("Cannot set new Session variable to unknown '{$namespace}' namespace"); return false; } //If we don't have a registry to that namespace; if (!isset($session->registry[$namespace])) { //Create it; $registry = new Registry($namespace); $session->registry[$namespace] = $registry; } //echo $namespace; //@TODO, check if the regitry is not locked before adding if (!$session->isLocked($namespace)) { $registry = $session->getNamespace($namespace); $registry->set($varname, $value); } //If auth is locked return $session; }
[ "final", "public", "function", "set", "(", "$", "varname", ",", "$", "value", "=", "NULL", ",", "$", "namespace", "=", "'default'", ")", "{", "//stores a value to a varname in a namespace of this session", "$", "session", "=", "$", "this", ";", "if", "(", "!", "isset", "(", "$", "namespace", ")", "||", "empty", "(", "$", "namespace", ")", ")", "{", "//@TODO Throw an exception, we need a name or use the default;", "throw", "new", "Exception", "(", "\"Cannot set new Session variable to unknown '{$namespace}' namespace\"", ")", ";", "return", "false", ";", "}", "//If we don't have a registry to that namespace;", "if", "(", "!", "isset", "(", "$", "session", "->", "registry", "[", "$", "namespace", "]", ")", ")", "{", "//Create it;", "$", "registry", "=", "new", "Registry", "(", "$", "namespace", ")", ";", "$", "session", "->", "registry", "[", "$", "namespace", "]", "=", "$", "registry", ";", "}", "//echo $namespace;", "//@TODO, check if the regitry is not locked before adding", "if", "(", "!", "$", "session", "->", "isLocked", "(", "$", "namespace", ")", ")", "{", "$", "registry", "=", "$", "session", "->", "getNamespace", "(", "$", "namespace", ")", ";", "$", "registry", "->", "set", "(", "$", "varname", ",", "$", "value", ")", ";", "}", "//If auth is locked", "return", "$", "session", ";", "}" ]
Sets a value for storage in a namespaced registry @param type $varname @param type $value @param type $namespace @return Session
[ "Sets", "a", "value", "for", "storage", "in", "a", "namespaced", "registry" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Session/Store.php#L763-L791
239,952
budkit/budkit-framework
src/Budkit/Session/Store.php
Store.remove
final public function remove($varname = '', $namespace = 'default') { //if the registry is empty and the namespace is not default //delete the registry; //stores a value to a varname in a namespace of this session $session = $this; //echo $namespace; //@TODO, check if the regitry is not locked before adding if (!$session->isLocked($namespace)) { $registry = $session->getNamespace($namespace); $registry->delete($varname); } //If auth is locked return $session; }
php
final public function remove($varname = '', $namespace = 'default') { //if the registry is empty and the namespace is not default //delete the registry; //stores a value to a varname in a namespace of this session $session = $this; //echo $namespace; //@TODO, check if the regitry is not locked before adding if (!$session->isLocked($namespace)) { $registry = $session->getNamespace($namespace); $registry->delete($varname); } //If auth is locked return $session; }
[ "final", "public", "function", "remove", "(", "$", "varname", "=", "''", ",", "$", "namespace", "=", "'default'", ")", "{", "//if the registry is empty and the namespace is not default", "//delete the registry;", "//stores a value to a varname in a namespace of this session", "$", "session", "=", "$", "this", ";", "//echo $namespace;", "//@TODO, check if the regitry is not locked before adding", "if", "(", "!", "$", "session", "->", "isLocked", "(", "$", "namespace", ")", ")", "{", "$", "registry", "=", "$", "session", "->", "getNamespace", "(", "$", "namespace", ")", ";", "$", "registry", "->", "delete", "(", "$", "varname", ")", ";", "}", "//If auth is locked", "return", "$", "session", ";", "}" ]
Removes a value from the session registry @param type $varname @param type $value @param type $namespace
[ "Removes", "a", "value", "from", "the", "session", "registry" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Session/Store.php#L800-L818
239,953
netcore/translations
src/Controllers/LanguagesController.php
LanguagesController.copyFallbackTranslations
private function copyFallbackTranslations($newLocale) { \DB::transaction(function () use ($newLocale) { $existingTranslations = Translation::get(); $fallbackLanguage = Language::whereIsFallback(1)->first(); if ($fallbackLanguage) { $fallbackIsoCode = $fallbackLanguage->iso_code; $fallbackTranslations = Translation::whereLocale($fallbackIsoCode)->get(); if ($fallbackTranslations) { $copiedTranslationsWithNewLocale = $fallbackTranslations->map(function ($translation) use ( $newLocale ) { unset($translation->id); $translation->locale = mb_strtolower($newLocale); return $translation; })->toArray(); $translationsToCreate = []; foreach ($copiedTranslationsWithNewLocale as $translation) { // Safety feature - dont create entry if it already exists // This might happen if administrator creates new language, deletes it, and then creates again $exists = $existingTranslations ->where('group', $translation['group']) ->where('key', $translation['key']) ->where('locale', $translation['locale']) ->first(); if (!$exists) { $translationsToCreate[] = $translation; } } foreach (array_chunk($translationsToCreate, 300) as $chunk) { Translation::insert($chunk); } } } }); }
php
private function copyFallbackTranslations($newLocale) { \DB::transaction(function () use ($newLocale) { $existingTranslations = Translation::get(); $fallbackLanguage = Language::whereIsFallback(1)->first(); if ($fallbackLanguage) { $fallbackIsoCode = $fallbackLanguage->iso_code; $fallbackTranslations = Translation::whereLocale($fallbackIsoCode)->get(); if ($fallbackTranslations) { $copiedTranslationsWithNewLocale = $fallbackTranslations->map(function ($translation) use ( $newLocale ) { unset($translation->id); $translation->locale = mb_strtolower($newLocale); return $translation; })->toArray(); $translationsToCreate = []; foreach ($copiedTranslationsWithNewLocale as $translation) { // Safety feature - dont create entry if it already exists // This might happen if administrator creates new language, deletes it, and then creates again $exists = $existingTranslations ->where('group', $translation['group']) ->where('key', $translation['key']) ->where('locale', $translation['locale']) ->first(); if (!$exists) { $translationsToCreate[] = $translation; } } foreach (array_chunk($translationsToCreate, 300) as $chunk) { Translation::insert($chunk); } } } }); }
[ "private", "function", "copyFallbackTranslations", "(", "$", "newLocale", ")", "{", "\\", "DB", "::", "transaction", "(", "function", "(", ")", "use", "(", "$", "newLocale", ")", "{", "$", "existingTranslations", "=", "Translation", "::", "get", "(", ")", ";", "$", "fallbackLanguage", "=", "Language", "::", "whereIsFallback", "(", "1", ")", "->", "first", "(", ")", ";", "if", "(", "$", "fallbackLanguage", ")", "{", "$", "fallbackIsoCode", "=", "$", "fallbackLanguage", "->", "iso_code", ";", "$", "fallbackTranslations", "=", "Translation", "::", "whereLocale", "(", "$", "fallbackIsoCode", ")", "->", "get", "(", ")", ";", "if", "(", "$", "fallbackTranslations", ")", "{", "$", "copiedTranslationsWithNewLocale", "=", "$", "fallbackTranslations", "->", "map", "(", "function", "(", "$", "translation", ")", "use", "(", "$", "newLocale", ")", "{", "unset", "(", "$", "translation", "->", "id", ")", ";", "$", "translation", "->", "locale", "=", "mb_strtolower", "(", "$", "newLocale", ")", ";", "return", "$", "translation", ";", "}", ")", "->", "toArray", "(", ")", ";", "$", "translationsToCreate", "=", "[", "]", ";", "foreach", "(", "$", "copiedTranslationsWithNewLocale", "as", "$", "translation", ")", "{", "// Safety feature - dont create entry if it already exists", "// This might happen if administrator creates new language, deletes it, and then creates again", "$", "exists", "=", "$", "existingTranslations", "->", "where", "(", "'group'", ",", "$", "translation", "[", "'group'", "]", ")", "->", "where", "(", "'key'", ",", "$", "translation", "[", "'key'", "]", ")", "->", "where", "(", "'locale'", ",", "$", "translation", "[", "'locale'", "]", ")", "->", "first", "(", ")", ";", "if", "(", "!", "$", "exists", ")", "{", "$", "translationsToCreate", "[", "]", "=", "$", "translation", ";", "}", "}", "foreach", "(", "array_chunk", "(", "$", "translationsToCreate", ",", "300", ")", "as", "$", "chunk", ")", "{", "Translation", "::", "insert", "(", "$", "chunk", ")", ";", "}", "}", "}", "}", ")", ";", "}" ]
Copies translations from fallback language to new language @param $newLocale
[ "Copies", "translations", "from", "fallback", "language", "to", "new", "language" ]
0f0c8d8b4748ee161921bfdc30683391c4fe7d7e
https://github.com/netcore/translations/blob/0f0c8d8b4748ee161921bfdc30683391c4fe7d7e/src/Controllers/LanguagesController.php#L178-L223
239,954
integratedfordevelopers/integrated-page-bundle
Services/UrlResolver.php
UrlResolver.getContentTypePageUrl
public function getContentTypePageUrl(ContentTypePage $page, ContentInterface $document) { return $this->router->generate( $this->getRouteName($page), $this->getRoutingParamaters($page, $document) ); }
php
public function getContentTypePageUrl(ContentTypePage $page, ContentInterface $document) { return $this->router->generate( $this->getRouteName($page), $this->getRoutingParamaters($page, $document) ); }
[ "public", "function", "getContentTypePageUrl", "(", "ContentTypePage", "$", "page", ",", "ContentInterface", "$", "document", ")", "{", "return", "$", "this", "->", "router", "->", "generate", "(", "$", "this", "->", "getRouteName", "(", "$", "page", ")", ",", "$", "this", "->", "getRoutingParamaters", "(", "$", "page", ",", "$", "document", ")", ")", ";", "}" ]
todo INTEGRATED-440 add Slug and getReferenceByRelationIdto ContentInterface @param ContentTypePage $page @param ContentInterface $document @return string
[ "todo", "INTEGRATED", "-", "440", "add", "Slug", "and", "getReferenceByRelationIdto", "ContentInterface" ]
a1a8640c2b5af2ef6e2f7806fcffa7009bb5294e
https://github.com/integratedfordevelopers/integrated-page-bundle/blob/a1a8640c2b5af2ef6e2f7806fcffa7009bb5294e/Services/UrlResolver.php#L127-L133
239,955
victorhaggqvist/sl-api-client-php
src/SL/Client.php
Client.slReseplanerare2Trip
public function slReseplanerare2Trip($originId, $destId, array $options = []) { $params = [ 'key' => $this->slReseplanerare2key, 'originId' => $originId, 'destId' => $destId ]; $params = array_merge($params, $options); $url = $this->SlReseplanerare2URL.'/trip.json'; $request = $this->client->request('GET', $url, [ 'query' => $params ]); $json = json_decode($request->getBody(), true); return $json; }
php
public function slReseplanerare2Trip($originId, $destId, array $options = []) { $params = [ 'key' => $this->slReseplanerare2key, 'originId' => $originId, 'destId' => $destId ]; $params = array_merge($params, $options); $url = $this->SlReseplanerare2URL.'/trip.json'; $request = $this->client->request('GET', $url, [ 'query' => $params ]); $json = json_decode($request->getBody(), true); return $json; }
[ "public", "function", "slReseplanerare2Trip", "(", "$", "originId", ",", "$", "destId", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "params", "=", "[", "'key'", "=>", "$", "this", "->", "slReseplanerare2key", ",", "'originId'", "=>", "$", "originId", ",", "'destId'", "=>", "$", "destId", "]", ";", "$", "params", "=", "array_merge", "(", "$", "params", ",", "$", "options", ")", ";", "$", "url", "=", "$", "this", "->", "SlReseplanerare2URL", ".", "'/trip.json'", ";", "$", "request", "=", "$", "this", "->", "client", "->", "request", "(", "'GET'", ",", "$", "url", ",", "[", "'query'", "=>", "$", "params", "]", ")", ";", "$", "json", "=", "json_decode", "(", "$", "request", "->", "getBody", "(", ")", ",", "true", ")", ";", "return", "$", "json", ";", "}" ]
SL Reseplanerare 2 -> Trip See https://www.trafiklab.se/api/sl-reseplanerare-2 @link https://www.trafiklab.se/api/sl-reseplanerare-2 @param string $originId SiteID from @param string $destId SiteID to @param array $options Any extra options @return mixed
[ "SL", "Reseplanerare", "2", "-", ">", "Trip" ]
e9d2f09931b6c50196adaae71cb201cc96e90de0
https://github.com/victorhaggqvist/sl-api-client-php/blob/e9d2f09931b6c50196adaae71cb201cc96e90de0/src/SL/Client.php#L105-L121
239,956
victorhaggqvist/sl-api-client-php
src/SL/Client.php
Client.slReseplanerare2Geometry
public function slReseplanerare2Geometry($ref) { $url = $this->SlReseplanerare2URL.'/geometry.json'; $params = [ 'key' => $this->slReseplanerare2key, 'ref' => $ref ]; $request = $this->client->request('GET', $url, [ 'query' => $params ]); $json = json_decode($request->getBody(), true); return $json; }
php
public function slReseplanerare2Geometry($ref) { $url = $this->SlReseplanerare2URL.'/geometry.json'; $params = [ 'key' => $this->slReseplanerare2key, 'ref' => $ref ]; $request = $this->client->request('GET', $url, [ 'query' => $params ]); $json = json_decode($request->getBody(), true); return $json; }
[ "public", "function", "slReseplanerare2Geometry", "(", "$", "ref", ")", "{", "$", "url", "=", "$", "this", "->", "SlReseplanerare2URL", ".", "'/geometry.json'", ";", "$", "params", "=", "[", "'key'", "=>", "$", "this", "->", "slReseplanerare2key", ",", "'ref'", "=>", "$", "ref", "]", ";", "$", "request", "=", "$", "this", "->", "client", "->", "request", "(", "'GET'", ",", "$", "url", ",", "[", "'query'", "=>", "$", "params", "]", ")", ";", "$", "json", "=", "json_decode", "(", "$", "request", "->", "getBody", "(", ")", ",", "true", ")", ";", "return", "$", "json", ";", "}" ]
SL Reseplanerare 2 -> Geometry See https://www.trafiklab.se/api/sl-reseplanerare-2 @link https://www.trafiklab.se/api/sl-reseplanerare-2 @param string $ref @return mixed
[ "SL", "Reseplanerare", "2", "-", ">", "Geometry" ]
e9d2f09931b6c50196adaae71cb201cc96e90de0
https://github.com/victorhaggqvist/sl-api-client-php/blob/e9d2f09931b6c50196adaae71cb201cc96e90de0/src/SL/Client.php#L132-L146
239,957
victorhaggqvist/sl-api-client-php
src/SL/Client.php
Client.slReseplanerare2JourneyDetail
public function slReseplanerare2JourneyDetail($ref) { $url = $this->SlReseplanerare2URL.'/journeydetail.json'; $params = [ 'key' => $this->slReseplanerare2key, 'ref' => $ref ]; $request = $this->client->request('GET', $url, [ 'query' => $params ]); $resp = $this->client->send($request); $json = json_decode($resp->getBody(), true); return $json; }
php
public function slReseplanerare2JourneyDetail($ref) { $url = $this->SlReseplanerare2URL.'/journeydetail.json'; $params = [ 'key' => $this->slReseplanerare2key, 'ref' => $ref ]; $request = $this->client->request('GET', $url, [ 'query' => $params ]); $resp = $this->client->send($request); $json = json_decode($resp->getBody(), true); return $json; }
[ "public", "function", "slReseplanerare2JourneyDetail", "(", "$", "ref", ")", "{", "$", "url", "=", "$", "this", "->", "SlReseplanerare2URL", ".", "'/journeydetail.json'", ";", "$", "params", "=", "[", "'key'", "=>", "$", "this", "->", "slReseplanerare2key", ",", "'ref'", "=>", "$", "ref", "]", ";", "$", "request", "=", "$", "this", "->", "client", "->", "request", "(", "'GET'", ",", "$", "url", ",", "[", "'query'", "=>", "$", "params", "]", ")", ";", "$", "resp", "=", "$", "this", "->", "client", "->", "send", "(", "$", "request", ")", ";", "$", "json", "=", "json_decode", "(", "$", "resp", "->", "getBody", "(", ")", ",", "true", ")", ";", "return", "$", "json", ";", "}" ]
SL Reseplanerare 2 -> JourneyDetail See https://www.trafiklab.se/api/sl-reseplanerare-2 @link https://www.trafiklab.se/api/sl-reseplanerare-2 @param string $ref @return mixed
[ "SL", "Reseplanerare", "2", "-", ">", "JourneyDetail" ]
e9d2f09931b6c50196adaae71cb201cc96e90de0
https://github.com/victorhaggqvist/sl-api-client-php/blob/e9d2f09931b6c50196adaae71cb201cc96e90de0/src/SL/Client.php#L157-L172
239,958
konservs/brilliant.framework
libraries/HTML/BHTML.php
BHTML.out_head
public function out_head(){ $this->frameworks_process(); if($this->lazyload){ $this->lazyload_prepare(); } //Outputing $tab=' '; echo($tab.'<title>'.$this->title.'</title>'.PHP_EOL); if(!empty($this->link_canonical)){ echo($tab.'<link rel="canonical" href="'.$this->link_canonical.'" />'.PHP_EOL); } //Add meta info... foreach($this->meta as $mi){ echo($tab.'<meta'); if(!empty($mi['name'])){ echo(' name="'.$mi['name'].'"'); } if(!empty($mi['http_equiv'])){ echo(' http-equiv="'.$mi['http_equiv'].'"'); } echo(' content="'.htmlspecialchars($mi['content']).'"'); echo('>'.PHP_EOL); } //Add CSS, author, etc. foreach($this->link as $lnk){ echo($tab.'<link'); foreach($lnk as $key=>$value){ echo(' '.$key.'="'.htmlspecialchars($value).'"'); } echo(' />'.PHP_EOL); } //sort js with priority $this->js_sort(); //Outputing style declaration... foreach($this->style as $style){ echo($tab.'<style>'); echo($style); echo($tab.'</style>'.PHP_EOL); } //Add javascript... foreach($this->js as $js){ echo($tab.'<script type="text/javascript"'); if(!empty($js['src'])){ echo(' src="'.$js['src'].'"'); } echo('>'.$js['val'].'</script>'.PHP_EOL); } }
php
public function out_head(){ $this->frameworks_process(); if($this->lazyload){ $this->lazyload_prepare(); } //Outputing $tab=' '; echo($tab.'<title>'.$this->title.'</title>'.PHP_EOL); if(!empty($this->link_canonical)){ echo($tab.'<link rel="canonical" href="'.$this->link_canonical.'" />'.PHP_EOL); } //Add meta info... foreach($this->meta as $mi){ echo($tab.'<meta'); if(!empty($mi['name'])){ echo(' name="'.$mi['name'].'"'); } if(!empty($mi['http_equiv'])){ echo(' http-equiv="'.$mi['http_equiv'].'"'); } echo(' content="'.htmlspecialchars($mi['content']).'"'); echo('>'.PHP_EOL); } //Add CSS, author, etc. foreach($this->link as $lnk){ echo($tab.'<link'); foreach($lnk as $key=>$value){ echo(' '.$key.'="'.htmlspecialchars($value).'"'); } echo(' />'.PHP_EOL); } //sort js with priority $this->js_sort(); //Outputing style declaration... foreach($this->style as $style){ echo($tab.'<style>'); echo($style); echo($tab.'</style>'.PHP_EOL); } //Add javascript... foreach($this->js as $js){ echo($tab.'<script type="text/javascript"'); if(!empty($js['src'])){ echo(' src="'.$js['src'].'"'); } echo('>'.$js['val'].'</script>'.PHP_EOL); } }
[ "public", "function", "out_head", "(", ")", "{", "$", "this", "->", "frameworks_process", "(", ")", ";", "if", "(", "$", "this", "->", "lazyload", ")", "{", "$", "this", "->", "lazyload_prepare", "(", ")", ";", "}", "//Outputing", "$", "tab", "=", "' '", ";", "echo", "(", "$", "tab", ".", "'<title>'", ".", "$", "this", "->", "title", ".", "'</title>'", ".", "PHP_EOL", ")", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "link_canonical", ")", ")", "{", "echo", "(", "$", "tab", ".", "'<link rel=\"canonical\" href=\"'", ".", "$", "this", "->", "link_canonical", ".", "'\" />'", ".", "PHP_EOL", ")", ";", "}", "//Add meta info...", "foreach", "(", "$", "this", "->", "meta", "as", "$", "mi", ")", "{", "echo", "(", "$", "tab", ".", "'<meta'", ")", ";", "if", "(", "!", "empty", "(", "$", "mi", "[", "'name'", "]", ")", ")", "{", "echo", "(", "' name=\"'", ".", "$", "mi", "[", "'name'", "]", ".", "'\"'", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "mi", "[", "'http_equiv'", "]", ")", ")", "{", "echo", "(", "' http-equiv=\"'", ".", "$", "mi", "[", "'http_equiv'", "]", ".", "'\"'", ")", ";", "}", "echo", "(", "' content=\"'", ".", "htmlspecialchars", "(", "$", "mi", "[", "'content'", "]", ")", ".", "'\"'", ")", ";", "echo", "(", "'>'", ".", "PHP_EOL", ")", ";", "}", "//Add CSS, author, etc.", "foreach", "(", "$", "this", "->", "link", "as", "$", "lnk", ")", "{", "echo", "(", "$", "tab", ".", "'<link'", ")", ";", "foreach", "(", "$", "lnk", "as", "$", "key", "=>", "$", "value", ")", "{", "echo", "(", "' '", ".", "$", "key", ".", "'=\"'", ".", "htmlspecialchars", "(", "$", "value", ")", ".", "'\"'", ")", ";", "}", "echo", "(", "' />'", ".", "PHP_EOL", ")", ";", "}", "//sort js with priority", "$", "this", "->", "js_sort", "(", ")", ";", "//Outputing style declaration...", "foreach", "(", "$", "this", "->", "style", "as", "$", "style", ")", "{", "echo", "(", "$", "tab", ".", "'<style>'", ")", ";", "echo", "(", "$", "style", ")", ";", "echo", "(", "$", "tab", ".", "'</style>'", ".", "PHP_EOL", ")", ";", "}", "//Add javascript...", "foreach", "(", "$", "this", "->", "js", "as", "$", "js", ")", "{", "echo", "(", "$", "tab", ".", "'<script type=\"text/javascript\"'", ")", ";", "if", "(", "!", "empty", "(", "$", "js", "[", "'src'", "]", ")", ")", "{", "echo", "(", "' src=\"'", ".", "$", "js", "[", "'src'", "]", ".", "'\"'", ")", ";", "}", "echo", "(", "'>'", ".", "$", "js", "[", "'val'", "]", ".", "'</script>'", ".", "PHP_EOL", ")", ";", "}", "}" ]
Output the head of the document
[ "Output", "the", "head", "of", "the", "document" ]
95f03f1917f746fee98bea8a906ba0588c87762d
https://github.com/konservs/brilliant.framework/blob/95f03f1917f746fee98bea8a906ba0588c87762d/libraries/HTML/BHTML.php#L371-L418
239,959
nofw/error
src/Psr3ErrorHandler.php
Psr3ErrorHandler.getLevel
private function getLevel(\Throwable $t, array $context): string { // Check if the severity matches a PSR-3 log level if ( false === $this->ignoreSeverity && isset($context[Context::SEVERITY]) && is_string($context[Context::SEVERITY]) && $this->validateLevel($context[Context::SEVERITY]) ) { return $context[Context::SEVERITY]; } // Find the log level based on the error in the level map (avoid looping through the whole array) // Note: this ignores the order defined in the map. $class = get_class($t); if (isset($this->levelMap[$class]) && $this->validateLevel($this->levelMap[$class])) { return $this->levelMap[$class]; } // Find the log level based on the error in the level map foreach ($this->levelMap as $className => $candidate) { if ($t instanceof $className && $this->validateLevel($candidate)) { return $candidate; } } // Return the default log level return self::DEFAULT_LOG_LEVEL; }
php
private function getLevel(\Throwable $t, array $context): string { // Check if the severity matches a PSR-3 log level if ( false === $this->ignoreSeverity && isset($context[Context::SEVERITY]) && is_string($context[Context::SEVERITY]) && $this->validateLevel($context[Context::SEVERITY]) ) { return $context[Context::SEVERITY]; } // Find the log level based on the error in the level map (avoid looping through the whole array) // Note: this ignores the order defined in the map. $class = get_class($t); if (isset($this->levelMap[$class]) && $this->validateLevel($this->levelMap[$class])) { return $this->levelMap[$class]; } // Find the log level based on the error in the level map foreach ($this->levelMap as $className => $candidate) { if ($t instanceof $className && $this->validateLevel($candidate)) { return $candidate; } } // Return the default log level return self::DEFAULT_LOG_LEVEL; }
[ "private", "function", "getLevel", "(", "\\", "Throwable", "$", "t", ",", "array", "$", "context", ")", ":", "string", "{", "// Check if the severity matches a PSR-3 log level", "if", "(", "false", "===", "$", "this", "->", "ignoreSeverity", "&&", "isset", "(", "$", "context", "[", "Context", "::", "SEVERITY", "]", ")", "&&", "is_string", "(", "$", "context", "[", "Context", "::", "SEVERITY", "]", ")", "&&", "$", "this", "->", "validateLevel", "(", "$", "context", "[", "Context", "::", "SEVERITY", "]", ")", ")", "{", "return", "$", "context", "[", "Context", "::", "SEVERITY", "]", ";", "}", "// Find the log level based on the error in the level map (avoid looping through the whole array)", "// Note: this ignores the order defined in the map.", "$", "class", "=", "get_class", "(", "$", "t", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "levelMap", "[", "$", "class", "]", ")", "&&", "$", "this", "->", "validateLevel", "(", "$", "this", "->", "levelMap", "[", "$", "class", "]", ")", ")", "{", "return", "$", "this", "->", "levelMap", "[", "$", "class", "]", ";", "}", "// Find the log level based on the error in the level map", "foreach", "(", "$", "this", "->", "levelMap", "as", "$", "className", "=>", "$", "candidate", ")", "{", "if", "(", "$", "t", "instanceof", "$", "className", "&&", "$", "this", "->", "validateLevel", "(", "$", "candidate", ")", ")", "{", "return", "$", "candidate", ";", "}", "}", "// Return the default log level", "return", "self", "::", "DEFAULT_LOG_LEVEL", ";", "}" ]
Determines the level for the error.
[ "Determines", "the", "level", "for", "the", "error", "." ]
3cf05913c13d41ae336aeb8cb3a4451bf9cac2b5
https://github.com/nofw/error/blob/3cf05913c13d41ae336aeb8cb3a4451bf9cac2b5/src/Psr3ErrorHandler.php#L111-L139
239,960
sios13/simox
src/Database/Database.php
Database.buildQuery
public function buildQuery( $table_name, $type, $params = null ) { if ( $type == "find" ) { $sub_sql = isset($params["sub_sql"]) ? $params["sub_sql"] : null; $sql = "SELECT * FROM $table_name"; if ( isset($sub_sql) ) { $sql .= " " . $sub_sql; } $sql .= ";"; } else if ( $type == "update" ) { $columns = isset($params["columns"]) ? $params["columns"] : null; $sql = "UPDATE $table_name SET "; foreach ( $columns as $column ) { $sql .= $column["name"] . "=:" . $column["name"] . ","; } $sql = rtrim( $sql, ", " ); $sql .= " WHERE "; foreach ( $columns as $column ) { $sql .= $column["name"] . "=:snap_" . $column["name"] . " AND "; } $sql = rtrim( $sql, " AND " ); $sql .= ";"; } else if ( $type == "insert" ) { $columns = isset($params["columns"]) ? $params["columns"] : null; $sql = "INSERT INTO $table_name ("; foreach ( $columns as $column ) { $sql .= $column["name"] . ", ";; } $sql = rtrim( $sql, ", " ); $sql .= ") VALUES ("; foreach ( $columns as $column ) { $sql .= ":" . $column["name"] . ", "; } $sql = rtrim( $sql, ", " ); $sql .= ");"; } return $this->prepare( $sql ); }
php
public function buildQuery( $table_name, $type, $params = null ) { if ( $type == "find" ) { $sub_sql = isset($params["sub_sql"]) ? $params["sub_sql"] : null; $sql = "SELECT * FROM $table_name"; if ( isset($sub_sql) ) { $sql .= " " . $sub_sql; } $sql .= ";"; } else if ( $type == "update" ) { $columns = isset($params["columns"]) ? $params["columns"] : null; $sql = "UPDATE $table_name SET "; foreach ( $columns as $column ) { $sql .= $column["name"] . "=:" . $column["name"] . ","; } $sql = rtrim( $sql, ", " ); $sql .= " WHERE "; foreach ( $columns as $column ) { $sql .= $column["name"] . "=:snap_" . $column["name"] . " AND "; } $sql = rtrim( $sql, " AND " ); $sql .= ";"; } else if ( $type == "insert" ) { $columns = isset($params["columns"]) ? $params["columns"] : null; $sql = "INSERT INTO $table_name ("; foreach ( $columns as $column ) { $sql .= $column["name"] . ", ";; } $sql = rtrim( $sql, ", " ); $sql .= ") VALUES ("; foreach ( $columns as $column ) { $sql .= ":" . $column["name"] . ", "; } $sql = rtrim( $sql, ", " ); $sql .= ");"; } return $this->prepare( $sql ); }
[ "public", "function", "buildQuery", "(", "$", "table_name", ",", "$", "type", ",", "$", "params", "=", "null", ")", "{", "if", "(", "$", "type", "==", "\"find\"", ")", "{", "$", "sub_sql", "=", "isset", "(", "$", "params", "[", "\"sub_sql\"", "]", ")", "?", "$", "params", "[", "\"sub_sql\"", "]", ":", "null", ";", "$", "sql", "=", "\"SELECT * FROM $table_name\"", ";", "if", "(", "isset", "(", "$", "sub_sql", ")", ")", "{", "$", "sql", ".=", "\" \"", ".", "$", "sub_sql", ";", "}", "$", "sql", ".=", "\";\"", ";", "}", "else", "if", "(", "$", "type", "==", "\"update\"", ")", "{", "$", "columns", "=", "isset", "(", "$", "params", "[", "\"columns\"", "]", ")", "?", "$", "params", "[", "\"columns\"", "]", ":", "null", ";", "$", "sql", "=", "\"UPDATE $table_name SET \"", ";", "foreach", "(", "$", "columns", "as", "$", "column", ")", "{", "$", "sql", ".=", "$", "column", "[", "\"name\"", "]", ".", "\"=:\"", ".", "$", "column", "[", "\"name\"", "]", ".", "\",\"", ";", "}", "$", "sql", "=", "rtrim", "(", "$", "sql", ",", "\", \"", ")", ";", "$", "sql", ".=", "\" WHERE \"", ";", "foreach", "(", "$", "columns", "as", "$", "column", ")", "{", "$", "sql", ".=", "$", "column", "[", "\"name\"", "]", ".", "\"=:snap_\"", ".", "$", "column", "[", "\"name\"", "]", ".", "\" AND \"", ";", "}", "$", "sql", "=", "rtrim", "(", "$", "sql", ",", "\" AND \"", ")", ";", "$", "sql", ".=", "\";\"", ";", "}", "else", "if", "(", "$", "type", "==", "\"insert\"", ")", "{", "$", "columns", "=", "isset", "(", "$", "params", "[", "\"columns\"", "]", ")", "?", "$", "params", "[", "\"columns\"", "]", ":", "null", ";", "$", "sql", "=", "\"INSERT INTO $table_name (\"", ";", "foreach", "(", "$", "columns", "as", "$", "column", ")", "{", "$", "sql", ".=", "$", "column", "[", "\"name\"", "]", ".", "\", \"", ";", ";", "}", "$", "sql", "=", "rtrim", "(", "$", "sql", ",", "\", \"", ")", ";", "$", "sql", ".=", "\") VALUES (\"", ";", "foreach", "(", "$", "columns", "as", "$", "column", ")", "{", "$", "sql", ".=", "\":\"", ".", "$", "column", "[", "\"name\"", "]", ".", "\", \"", ";", "}", "$", "sql", "=", "rtrim", "(", "$", "sql", ",", "\", \"", ")", ";", "$", "sql", ".=", "\");\"", ";", "}", "return", "$", "this", "->", "prepare", "(", "$", "sql", ")", ";", "}" ]
Builds a query, returns a query object
[ "Builds", "a", "query", "returns", "a", "query", "object" ]
8be964949ef179aba7eceb3fc6439815a1af2ad2
https://github.com/sios13/simox/blob/8be964949ef179aba7eceb3fc6439815a1af2ad2/src/Database/Database.php#L25-L87
239,961
easy-system/es-container
src/Parameters/ParametersTrait.php
ParametersTrait.getParam
public function getParam($key, $default = null) { if (isset($this->parameters[$key])) { return $this->parameters[$key]; } return $default; }
php
public function getParam($key, $default = null) { if (isset($this->parameters[$key])) { return $this->parameters[$key]; } return $default; }
[ "public", "function", "getParam", "(", "$", "key", ",", "$", "default", "=", "null", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "parameters", "[", "$", "key", "]", ")", ")", "{", "return", "$", "this", "->", "parameters", "[", "$", "key", "]", ";", "}", "return", "$", "default", ";", "}" ]
Gets the parameter. @param int|string $key The key of parameter @param mixed $default The default value of parameter @return mixed Returns parameter value if any, $default otherwise
[ "Gets", "the", "parameter", "." ]
0e917d8ff2c3622f53b82d34436295539858be7d
https://github.com/easy-system/es-container/blob/0e917d8ff2c3622f53b82d34436295539858be7d/src/Parameters/ParametersTrait.php#L63-L70
239,962
phlexible/tree-bundle
Controller/LinkController.php
LinkController.recurseLinkNodes
private function recurseLinkNodes(array $nodes, $language, $mode, TreeNodeInterface $targetNode = null) { $elementService = $this->get('phlexible_element.element_service'); $iconResolver = $this->get('phlexible_element.icon_resolver'); $data = []; foreach ($nodes as $node) { /* @var $node \Phlexible\Bundle\TreeBundle\Model\TreeNodeInterface */ $element = $elementService->findElement($node->getTypeId()); $elementVersion = $elementService->findLatestElementVersion($element); $elementtype = $elementService->findElementtype($element); $tid = $node->getId(); $tree = $node->getTree(); $children = $tree->getChildren($node); $dataNode = [ 'id' => $node->getId(), 'eid' => $node->getTypeId(), 'text' => $elementVersion->getBackendTitle($language, $element->getMasterLanguage()).' ['.$tid.']', 'icon' => $iconResolver->resolveTreeNode($node, $language), 'children' => !$tree->hasChildren($node) ? [] : $mode === self::MODE_NOET_TARGET && $tree->isParentOf($node, $targetNode) ? $this->recurseLinkNodes($children, $language, $mode, $targetNode) : false, 'leaf' => !$tree->hasChildren($node), 'expanded' => false, ]; /* $leafCount = 0; if (is_array($dataNode['children'])) { foreach($dataNode['children'] as $child) { $leafCount += $child['leafCount']; if (!isset($child['disabled']) || !$child['disabled']) { ++$leafCount; } } } $dataNode['leafCount'] = $leafCount; */ $data[] = $dataNode; } return $data; }
php
private function recurseLinkNodes(array $nodes, $language, $mode, TreeNodeInterface $targetNode = null) { $elementService = $this->get('phlexible_element.element_service'); $iconResolver = $this->get('phlexible_element.icon_resolver'); $data = []; foreach ($nodes as $node) { /* @var $node \Phlexible\Bundle\TreeBundle\Model\TreeNodeInterface */ $element = $elementService->findElement($node->getTypeId()); $elementVersion = $elementService->findLatestElementVersion($element); $elementtype = $elementService->findElementtype($element); $tid = $node->getId(); $tree = $node->getTree(); $children = $tree->getChildren($node); $dataNode = [ 'id' => $node->getId(), 'eid' => $node->getTypeId(), 'text' => $elementVersion->getBackendTitle($language, $element->getMasterLanguage()).' ['.$tid.']', 'icon' => $iconResolver->resolveTreeNode($node, $language), 'children' => !$tree->hasChildren($node) ? [] : $mode === self::MODE_NOET_TARGET && $tree->isParentOf($node, $targetNode) ? $this->recurseLinkNodes($children, $language, $mode, $targetNode) : false, 'leaf' => !$tree->hasChildren($node), 'expanded' => false, ]; /* $leafCount = 0; if (is_array($dataNode['children'])) { foreach($dataNode['children'] as $child) { $leafCount += $child['leafCount']; if (!isset($child['disabled']) || !$child['disabled']) { ++$leafCount; } } } $dataNode['leafCount'] = $leafCount; */ $data[] = $dataNode; } return $data; }
[ "private", "function", "recurseLinkNodes", "(", "array", "$", "nodes", ",", "$", "language", ",", "$", "mode", ",", "TreeNodeInterface", "$", "targetNode", "=", "null", ")", "{", "$", "elementService", "=", "$", "this", "->", "get", "(", "'phlexible_element.element_service'", ")", ";", "$", "iconResolver", "=", "$", "this", "->", "get", "(", "'phlexible_element.icon_resolver'", ")", ";", "$", "data", "=", "[", "]", ";", "foreach", "(", "$", "nodes", "as", "$", "node", ")", "{", "/* @var $node \\Phlexible\\Bundle\\TreeBundle\\Model\\TreeNodeInterface */", "$", "element", "=", "$", "elementService", "->", "findElement", "(", "$", "node", "->", "getTypeId", "(", ")", ")", ";", "$", "elementVersion", "=", "$", "elementService", "->", "findLatestElementVersion", "(", "$", "element", ")", ";", "$", "elementtype", "=", "$", "elementService", "->", "findElementtype", "(", "$", "element", ")", ";", "$", "tid", "=", "$", "node", "->", "getId", "(", ")", ";", "$", "tree", "=", "$", "node", "->", "getTree", "(", ")", ";", "$", "children", "=", "$", "tree", "->", "getChildren", "(", "$", "node", ")", ";", "$", "dataNode", "=", "[", "'id'", "=>", "$", "node", "->", "getId", "(", ")", ",", "'eid'", "=>", "$", "node", "->", "getTypeId", "(", ")", ",", "'text'", "=>", "$", "elementVersion", "->", "getBackendTitle", "(", "$", "language", ",", "$", "element", "->", "getMasterLanguage", "(", ")", ")", ".", "' ['", ".", "$", "tid", ".", "']'", ",", "'icon'", "=>", "$", "iconResolver", "->", "resolveTreeNode", "(", "$", "node", ",", "$", "language", ")", ",", "'children'", "=>", "!", "$", "tree", "->", "hasChildren", "(", "$", "node", ")", "?", "[", "]", ":", "$", "mode", "===", "self", "::", "MODE_NOET_TARGET", "&&", "$", "tree", "->", "isParentOf", "(", "$", "node", ",", "$", "targetNode", ")", "?", "$", "this", "->", "recurseLinkNodes", "(", "$", "children", ",", "$", "language", ",", "$", "mode", ",", "$", "targetNode", ")", ":", "false", ",", "'leaf'", "=>", "!", "$", "tree", "->", "hasChildren", "(", "$", "node", ")", ",", "'expanded'", "=>", "false", ",", "]", ";", "/*\n $leafCount = 0;\n if (is_array($dataNode['children']))\n {\n foreach($dataNode['children'] as $child)\n {\n $leafCount += $child['leafCount'];\n if (!isset($child['disabled']) || !$child['disabled'])\n {\n ++$leafCount;\n }\n }\n }\n $dataNode['leafCount'] = $leafCount;\n */", "$", "data", "[", "]", "=", "$", "dataNode", ";", "}", "return", "$", "data", ";", "}" ]
Recurse over tree nodes. @param array $nodes @param string $language @param int $mode @param TreeNodeInterface $targetNode @return array
[ "Recurse", "over", "tree", "nodes", "." ]
0fd07efdf1edf2d0f74f71519c476d534457701c
https://github.com/phlexible/tree-bundle/blob/0fd07efdf1edf2d0f74f71519c476d534457701c/Controller/LinkController.php#L431-L483
239,963
phlexible/tree-bundle
Controller/LinkController.php
LinkController.recursiveTreeStrip
private function recursiveTreeStrip(array $data) { if (count($data) === 1 && !empty($data[0]['children'])) { return $this->recursiveTreeStrip($data[0]['children']); } return $data; }
php
private function recursiveTreeStrip(array $data) { if (count($data) === 1 && !empty($data[0]['children'])) { return $this->recursiveTreeStrip($data[0]['children']); } return $data; }
[ "private", "function", "recursiveTreeStrip", "(", "array", "$", "data", ")", "{", "if", "(", "count", "(", "$", "data", ")", "===", "1", "&&", "!", "empty", "(", "$", "data", "[", "0", "]", "[", "'children'", "]", ")", ")", "{", "return", "$", "this", "->", "recursiveTreeStrip", "(", "$", "data", "[", "0", "]", "[", "'children'", "]", ")", ";", "}", "return", "$", "data", ";", "}" ]
Strip all disabled nodes recursivly. @param array $data @return array
[ "Strip", "all", "disabled", "nodes", "recursivly", "." ]
0fd07efdf1edf2d0f74f71519c476d534457701c
https://github.com/phlexible/tree-bundle/blob/0fd07efdf1edf2d0f74f71519c476d534457701c/Controller/LinkController.php#L492-L499
239,964
joomlatools/joomlatools-platform-categories
administrator/components/com_categories/controllers/categories.php
CategoriesControllerCategories.getModel
public function getModel($name = 'Category', $prefix = 'CategoriesModel', $config = array('ignore_request' => true)) { return parent::getModel($name, $prefix, $config); }
php
public function getModel($name = 'Category', $prefix = 'CategoriesModel', $config = array('ignore_request' => true)) { return parent::getModel($name, $prefix, $config); }
[ "public", "function", "getModel", "(", "$", "name", "=", "'Category'", ",", "$", "prefix", "=", "'CategoriesModel'", ",", "$", "config", "=", "array", "(", "'ignore_request'", "=>", "true", ")", ")", "{", "return", "parent", "::", "getModel", "(", "$", "name", ",", "$", "prefix", ",", "$", "config", ")", ";", "}" ]
Proxy for getModel @param string $name The model name. Optional. @param string $prefix The class prefix. Optional. @param array $config The array of possible config values. Optional. @return JModelLegacy The model. @since 1.6
[ "Proxy", "for", "getModel" ]
9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350
https://github.com/joomlatools/joomlatools-platform-categories/blob/9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350/administrator/components/com_categories/controllers/categories.php#L32-L35
239,965
joomlatools/joomlatools-platform-categories
administrator/components/com_categories/controllers/categories.php
CategoriesControllerCategories.rebuild
public function rebuild() { JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); $extension = $this->input->get('extension'); $this->setRedirect(JRoute::_('index.php?option=com_categories&view=categories&extension=' . $extension, false)); /** @var CategoriesModelCategory $model */ $model = $this->getModel(); if ($model->rebuild()) { // Rebuild succeeded. $this->setMessage(JText::_('COM_CATEGORIES_REBUILD_SUCCESS')); return true; } // Rebuild failed. $this->setMessage(JText::_('COM_CATEGORIES_REBUILD_FAILURE')); return false; }
php
public function rebuild() { JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); $extension = $this->input->get('extension'); $this->setRedirect(JRoute::_('index.php?option=com_categories&view=categories&extension=' . $extension, false)); /** @var CategoriesModelCategory $model */ $model = $this->getModel(); if ($model->rebuild()) { // Rebuild succeeded. $this->setMessage(JText::_('COM_CATEGORIES_REBUILD_SUCCESS')); return true; } // Rebuild failed. $this->setMessage(JText::_('COM_CATEGORIES_REBUILD_FAILURE')); return false; }
[ "public", "function", "rebuild", "(", ")", "{", "JSession", "::", "checkToken", "(", ")", "or", "jexit", "(", "JText", "::", "_", "(", "'JINVALID_TOKEN'", ")", ")", ";", "$", "extension", "=", "$", "this", "->", "input", "->", "get", "(", "'extension'", ")", ";", "$", "this", "->", "setRedirect", "(", "JRoute", "::", "_", "(", "'index.php?option=com_categories&view=categories&extension='", ".", "$", "extension", ",", "false", ")", ")", ";", "/** @var CategoriesModelCategory $model */", "$", "model", "=", "$", "this", "->", "getModel", "(", ")", ";", "if", "(", "$", "model", "->", "rebuild", "(", ")", ")", "{", "// Rebuild succeeded.", "$", "this", "->", "setMessage", "(", "JText", "::", "_", "(", "'COM_CATEGORIES_REBUILD_SUCCESS'", ")", ")", ";", "return", "true", ";", "}", "// Rebuild failed.", "$", "this", "->", "setMessage", "(", "JText", "::", "_", "(", "'COM_CATEGORIES_REBUILD_FAILURE'", ")", ")", ";", "return", "false", ";", "}" ]
Rebuild the nested set tree. @return bool False on failure or error, true on success. @since 1.6
[ "Rebuild", "the", "nested", "set", "tree", "." ]
9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350
https://github.com/joomlatools/joomlatools-platform-categories/blob/9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350/administrator/components/com_categories/controllers/categories.php#L44-L66
239,966
joomlatools/joomlatools-platform-categories
administrator/components/com_categories/controllers/categories.php
CategoriesControllerCategories.saveorder
public function saveorder() { JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); JLog::add('CategoriesControllerCategories::saveorder() is deprecated. Function will be removed in 4.0', JLog::WARNING, 'deprecated'); // Get the arrays from the Request $order = $this->input->post->get('order', null, 'array'); $originalOrder = explode(',', $this->input->getString('original_order_values')); // Make sure something has changed if (!($order === $originalOrder)) { parent::saveorder(); } else { // Nothing to reorder $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_list, false)); return true; } }
php
public function saveorder() { JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); JLog::add('CategoriesControllerCategories::saveorder() is deprecated. Function will be removed in 4.0', JLog::WARNING, 'deprecated'); // Get the arrays from the Request $order = $this->input->post->get('order', null, 'array'); $originalOrder = explode(',', $this->input->getString('original_order_values')); // Make sure something has changed if (!($order === $originalOrder)) { parent::saveorder(); } else { // Nothing to reorder $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_list, false)); return true; } }
[ "public", "function", "saveorder", "(", ")", "{", "JSession", "::", "checkToken", "(", ")", "or", "jexit", "(", "JText", "::", "_", "(", "'JINVALID_TOKEN'", ")", ")", ";", "JLog", "::", "add", "(", "'CategoriesControllerCategories::saveorder() is deprecated. Function will be removed in 4.0'", ",", "JLog", "::", "WARNING", ",", "'deprecated'", ")", ";", "// Get the arrays from the Request", "$", "order", "=", "$", "this", "->", "input", "->", "post", "->", "get", "(", "'order'", ",", "null", ",", "'array'", ")", ";", "$", "originalOrder", "=", "explode", "(", "','", ",", "$", "this", "->", "input", "->", "getString", "(", "'original_order_values'", ")", ")", ";", "// Make sure something has changed", "if", "(", "!", "(", "$", "order", "===", "$", "originalOrder", ")", ")", "{", "parent", "::", "saveorder", "(", ")", ";", "}", "else", "{", "// Nothing to reorder", "$", "this", "->", "setRedirect", "(", "JRoute", "::", "_", "(", "'index.php?option='", ".", "$", "this", "->", "option", ".", "'&view='", ".", "$", "this", "->", "view_list", ",", "false", ")", ")", ";", "return", "true", ";", "}", "}" ]
Save the manual order inputs from the categories list page. @return void @since 1.6 @see JControllerAdmin::saveorder() @deprecated 4.0
[ "Save", "the", "manual", "order", "inputs", "from", "the", "categories", "list", "page", "." ]
9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350
https://github.com/joomlatools/joomlatools-platform-categories/blob/9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350/administrator/components/com_categories/controllers/categories.php#L77-L99
239,967
joomlatools/joomlatools-platform-categories
administrator/components/com_categories/controllers/categories.php
CategoriesControllerCategories.delete
public function delete() { JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); // Get items to remove from the request. $cid = $this->input->get('cid', array(), 'array'); $extension = $this->input->getCmd('extension', null); if (!is_array($cid) || count($cid) < 1) { JError::raiseWarning(500, JText::_($this->text_prefix . '_NO_ITEM_SELECTED')); } else { // Get the model. /** @var CategoriesModelCategory $model */ $model = $this->getModel(); // Make sure the item ids are integers $cid = ArrayHelper::toInteger($cid); // Remove the items. if ($model->delete($cid)) { $this->setMessage(JText::plural($this->text_prefix . '_N_ITEMS_DELETED', count($cid))); } else { $this->setMessage($model->getError()); } } $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&extension=' . $extension, false)); }
php
public function delete() { JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); // Get items to remove from the request. $cid = $this->input->get('cid', array(), 'array'); $extension = $this->input->getCmd('extension', null); if (!is_array($cid) || count($cid) < 1) { JError::raiseWarning(500, JText::_($this->text_prefix . '_NO_ITEM_SELECTED')); } else { // Get the model. /** @var CategoriesModelCategory $model */ $model = $this->getModel(); // Make sure the item ids are integers $cid = ArrayHelper::toInteger($cid); // Remove the items. if ($model->delete($cid)) { $this->setMessage(JText::plural($this->text_prefix . '_N_ITEMS_DELETED', count($cid))); } else { $this->setMessage($model->getError()); } } $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&extension=' . $extension, false)); }
[ "public", "function", "delete", "(", ")", "{", "JSession", "::", "checkToken", "(", ")", "or", "jexit", "(", "JText", "::", "_", "(", "'JINVALID_TOKEN'", ")", ")", ";", "// Get items to remove from the request.", "$", "cid", "=", "$", "this", "->", "input", "->", "get", "(", "'cid'", ",", "array", "(", ")", ",", "'array'", ")", ";", "$", "extension", "=", "$", "this", "->", "input", "->", "getCmd", "(", "'extension'", ",", "null", ")", ";", "if", "(", "!", "is_array", "(", "$", "cid", ")", "||", "count", "(", "$", "cid", ")", "<", "1", ")", "{", "JError", "::", "raiseWarning", "(", "500", ",", "JText", "::", "_", "(", "$", "this", "->", "text_prefix", ".", "'_NO_ITEM_SELECTED'", ")", ")", ";", "}", "else", "{", "// Get the model.", "/** @var CategoriesModelCategory $model */", "$", "model", "=", "$", "this", "->", "getModel", "(", ")", ";", "// Make sure the item ids are integers", "$", "cid", "=", "ArrayHelper", "::", "toInteger", "(", "$", "cid", ")", ";", "// Remove the items.", "if", "(", "$", "model", "->", "delete", "(", "$", "cid", ")", ")", "{", "$", "this", "->", "setMessage", "(", "JText", "::", "plural", "(", "$", "this", "->", "text_prefix", ".", "'_N_ITEMS_DELETED'", ",", "count", "(", "$", "cid", ")", ")", ")", ";", "}", "else", "{", "$", "this", "->", "setMessage", "(", "$", "model", "->", "getError", "(", ")", ")", ";", "}", "}", "$", "this", "->", "setRedirect", "(", "JRoute", "::", "_", "(", "'index.php?option='", ".", "$", "this", "->", "option", ".", "'&extension='", ".", "$", "extension", ",", "false", ")", ")", ";", "}" ]
Deletes and returns correctly. @return void @since 3.1.2
[ "Deletes", "and", "returns", "correctly", "." ]
9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350
https://github.com/joomlatools/joomlatools-platform-categories/blob/9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350/administrator/components/com_categories/controllers/categories.php#L108-L141
239,968
joomlatools/joomlatools-platform-categories
administrator/components/com_categories/controllers/categories.php
CategoriesControllerCategories.checkin
public function checkin() { // Process parent checkin method. $result = parent::checkin(); // Overrride the redirect Uri. $redirectUri = 'index.php?option=' . $this->option . '&view=' . $this->view_list . '&extension=' . $this->input->get('extension', '', 'CMD'); $this->setRedirect(JRoute::_($redirectUri, false), $this->message, $this->messageType); return $result; }
php
public function checkin() { // Process parent checkin method. $result = parent::checkin(); // Overrride the redirect Uri. $redirectUri = 'index.php?option=' . $this->option . '&view=' . $this->view_list . '&extension=' . $this->input->get('extension', '', 'CMD'); $this->setRedirect(JRoute::_($redirectUri, false), $this->message, $this->messageType); return $result; }
[ "public", "function", "checkin", "(", ")", "{", "// Process parent checkin method.", "$", "result", "=", "parent", "::", "checkin", "(", ")", ";", "// Overrride the redirect Uri.", "$", "redirectUri", "=", "'index.php?option='", ".", "$", "this", "->", "option", ".", "'&view='", ".", "$", "this", "->", "view_list", ".", "'&extension='", ".", "$", "this", "->", "input", "->", "get", "(", "'extension'", ",", "''", ",", "'CMD'", ")", ";", "$", "this", "->", "setRedirect", "(", "JRoute", "::", "_", "(", "$", "redirectUri", ",", "false", ")", ",", "$", "this", "->", "message", ",", "$", "this", "->", "messageType", ")", ";", "return", "$", "result", ";", "}" ]
Check in of one or more records. Overrides JControllerAdmin::checkin to redirect to URL with extension. @return boolean True on success @since 3.6.0
[ "Check", "in", "of", "one", "or", "more", "records", "." ]
9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350
https://github.com/joomlatools/joomlatools-platform-categories/blob/9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350/administrator/components/com_categories/controllers/categories.php#L152-L162
239,969
xinc-develop/xinc-core
src/Plugin/Property/Plugin.php
Plugin.parsePropertyFile
public function parsePropertyFile(BuildInterface $build, $fileName) { $activeProperty = false; $trimNextLine = false; $arr = array(); $fh = fopen($fileName, 'r'); if (is_resource($fh)) { while ($line = fgets($fh)) { if (preg_match('/^[!#].*/', $line)) { // comment } elseif (preg_match("/^.*?([\._-\w]+?)\s*[=:]+\s*(.*)$/", $line, $matches)) { // we have a key definition $activeProperty = true; $key = $matches[1]; $valuePart = $matches[2]; $arr[$key] = trim($valuePart); if ($arr[$key]{strlen($arr[$key]) - 1} == '\\') { $arr[$key] = substr($arr[$key], 0, -1); $trimNextLine = true; } else { $trimNextLine = false; } } elseif ($activeProperty) { $trimmed = trim($line); if (empty($trimmed)) { $activeProperty = false; continue; } elseif ($trimNextLine) { $line = $trimmed; } else { $line = rtrim($line); } $arr[$key] .= "\n".$line; if ($arr[$key]{strlen($arr[$key]) - 1} == '\\') { $arr[$key] = substr($arr[$key], 0, -1); $trimNextLine = true; } else { $trimNextLine = false; } } } foreach ($arr as $key => $value) { $build->debug('Setting property "${'.$key.'}" to "'.$value.'"'); $build->setProperty($key, stripcslashes($value)); } } else { $build->error('Cannot read from property file: '.$fileName); } }
php
public function parsePropertyFile(BuildInterface $build, $fileName) { $activeProperty = false; $trimNextLine = false; $arr = array(); $fh = fopen($fileName, 'r'); if (is_resource($fh)) { while ($line = fgets($fh)) { if (preg_match('/^[!#].*/', $line)) { // comment } elseif (preg_match("/^.*?([\._-\w]+?)\s*[=:]+\s*(.*)$/", $line, $matches)) { // we have a key definition $activeProperty = true; $key = $matches[1]; $valuePart = $matches[2]; $arr[$key] = trim($valuePart); if ($arr[$key]{strlen($arr[$key]) - 1} == '\\') { $arr[$key] = substr($arr[$key], 0, -1); $trimNextLine = true; } else { $trimNextLine = false; } } elseif ($activeProperty) { $trimmed = trim($line); if (empty($trimmed)) { $activeProperty = false; continue; } elseif ($trimNextLine) { $line = $trimmed; } else { $line = rtrim($line); } $arr[$key] .= "\n".$line; if ($arr[$key]{strlen($arr[$key]) - 1} == '\\') { $arr[$key] = substr($arr[$key], 0, -1); $trimNextLine = true; } else { $trimNextLine = false; } } } foreach ($arr as $key => $value) { $build->debug('Setting property "${'.$key.'}" to "'.$value.'"'); $build->setProperty($key, stripcslashes($value)); } } else { $build->error('Cannot read from property file: '.$fileName); } }
[ "public", "function", "parsePropertyFile", "(", "BuildInterface", "$", "build", ",", "$", "fileName", ")", "{", "$", "activeProperty", "=", "false", ";", "$", "trimNextLine", "=", "false", ";", "$", "arr", "=", "array", "(", ")", ";", "$", "fh", "=", "fopen", "(", "$", "fileName", ",", "'r'", ")", ";", "if", "(", "is_resource", "(", "$", "fh", ")", ")", "{", "while", "(", "$", "line", "=", "fgets", "(", "$", "fh", ")", ")", "{", "if", "(", "preg_match", "(", "'/^[!#].*/'", ",", "$", "line", ")", ")", "{", "// comment", "}", "elseif", "(", "preg_match", "(", "\"/^.*?([\\._-\\w]+?)\\s*[=:]+\\s*(.*)$/\"", ",", "$", "line", ",", "$", "matches", ")", ")", "{", "// we have a key definition", "$", "activeProperty", "=", "true", ";", "$", "key", "=", "$", "matches", "[", "1", "]", ";", "$", "valuePart", "=", "$", "matches", "[", "2", "]", ";", "$", "arr", "[", "$", "key", "]", "=", "trim", "(", "$", "valuePart", ")", ";", "if", "(", "$", "arr", "[", "$", "key", "]", "{", "strlen", "(", "$", "arr", "[", "$", "key", "]", ")", "-", "1", "}", "==", "'\\\\'", ")", "{", "$", "arr", "[", "$", "key", "]", "=", "substr", "(", "$", "arr", "[", "$", "key", "]", ",", "0", ",", "-", "1", ")", ";", "$", "trimNextLine", "=", "true", ";", "}", "else", "{", "$", "trimNextLine", "=", "false", ";", "}", "}", "elseif", "(", "$", "activeProperty", ")", "{", "$", "trimmed", "=", "trim", "(", "$", "line", ")", ";", "if", "(", "empty", "(", "$", "trimmed", ")", ")", "{", "$", "activeProperty", "=", "false", ";", "continue", ";", "}", "elseif", "(", "$", "trimNextLine", ")", "{", "$", "line", "=", "$", "trimmed", ";", "}", "else", "{", "$", "line", "=", "rtrim", "(", "$", "line", ")", ";", "}", "$", "arr", "[", "$", "key", "]", ".=", "\"\\n\"", ".", "$", "line", ";", "if", "(", "$", "arr", "[", "$", "key", "]", "{", "strlen", "(", "$", "arr", "[", "$", "key", "]", ")", "-", "1", "}", "==", "'\\\\'", ")", "{", "$", "arr", "[", "$", "key", "]", "=", "substr", "(", "$", "arr", "[", "$", "key", "]", ",", "0", ",", "-", "1", ")", ";", "$", "trimNextLine", "=", "true", ";", "}", "else", "{", "$", "trimNextLine", "=", "false", ";", "}", "}", "}", "foreach", "(", "$", "arr", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "build", "->", "debug", "(", "'Setting property \"${'", ".", "$", "key", ".", "'}\" to \"'", ".", "$", "value", ".", "'\"'", ")", ";", "$", "build", "->", "setProperty", "(", "$", "key", ",", "stripcslashes", "(", "$", "value", ")", ")", ";", "}", "}", "else", "{", "$", "build", "->", "error", "(", "'Cannot read from property file: '", ".", "$", "fileName", ")", ";", "}", "}" ]
loads properties from a property file. @param BuildInterface $build @param string $fileName
[ "loads", "properties", "from", "a", "property", "file", "." ]
4bb69a6afe19e1186950a3122cbfe0989823e0d6
https://github.com/xinc-develop/xinc-core/blob/4bb69a6afe19e1186950a3122cbfe0989823e0d6/src/Plugin/Property/Plugin.php#L44-L92
239,970
znframework/package-services
Restful.php
Restful._customRequest
protected function _customRequest($url, $data, $type) { $response = $this->curl->init($this->url ?? $url) ->option('returntransfer', true) ->option('customrequest', strtoupper($type)) ->option('ssl_verifypeer', $this->sslVerifyPeer) ->option('postfields', $data) ->exec(); return $this->_result($response); }
php
protected function _customRequest($url, $data, $type) { $response = $this->curl->init($this->url ?? $url) ->option('returntransfer', true) ->option('customrequest', strtoupper($type)) ->option('ssl_verifypeer', $this->sslVerifyPeer) ->option('postfields', $data) ->exec(); return $this->_result($response); }
[ "protected", "function", "_customRequest", "(", "$", "url", ",", "$", "data", ",", "$", "type", ")", "{", "$", "response", "=", "$", "this", "->", "curl", "->", "init", "(", "$", "this", "->", "url", "??", "$", "url", ")", "->", "option", "(", "'returntransfer'", ",", "true", ")", "->", "option", "(", "'customrequest'", ",", "strtoupper", "(", "$", "type", ")", ")", "->", "option", "(", "'ssl_verifypeer'", ",", "$", "this", "->", "sslVerifyPeer", ")", "->", "option", "(", "'postfields'", ",", "$", "data", ")", "->", "exec", "(", ")", ";", "return", "$", "this", "->", "_result", "(", "$", "response", ")", ";", "}" ]
Protected Custom Request
[ "Protected", "Custom", "Request" ]
d603667191e2e386cbc2119836c5bed9e3ade141
https://github.com/znframework/package-services/blob/d603667191e2e386cbc2119836c5bed9e3ade141/Restful.php#L288-L298
239,971
uthando-cms/uthando-session-manager
src/UthandoSessionManager/Session/SaveHandler/DbTableGateway.php
DbTableGateway.gc
public function gc($maxlifetime) { $platform = $this->tableGateway->getAdapter()->getPlatform(); $where = new Where(); $where->lessThan( $this->options->getModifiedColumn(), new Expression('(' . time() . ' - ' . $platform->quoteIdentifier($this->options->getLifetimeColumn()) . ')') ); $rows = $this->tableGateway->select($where); $ids = []; /* @var \UthandoSessionManager\Model\SessionModel $row */ foreach ($rows as $row) { $ids[] = $row->{$this->options->getIdColumn()}; } if (count($ids) > 0) { $where = new Where(); $result = (bool) $this->tableGateway->delete( $where->in($this->options->getIdColumn(), $ids) ); } else { $result = false; } return $result; }
php
public function gc($maxlifetime) { $platform = $this->tableGateway->getAdapter()->getPlatform(); $where = new Where(); $where->lessThan( $this->options->getModifiedColumn(), new Expression('(' . time() . ' - ' . $platform->quoteIdentifier($this->options->getLifetimeColumn()) . ')') ); $rows = $this->tableGateway->select($where); $ids = []; /* @var \UthandoSessionManager\Model\SessionModel $row */ foreach ($rows as $row) { $ids[] = $row->{$this->options->getIdColumn()}; } if (count($ids) > 0) { $where = new Where(); $result = (bool) $this->tableGateway->delete( $where->in($this->options->getIdColumn(), $ids) ); } else { $result = false; } return $result; }
[ "public", "function", "gc", "(", "$", "maxlifetime", ")", "{", "$", "platform", "=", "$", "this", "->", "tableGateway", "->", "getAdapter", "(", ")", "->", "getPlatform", "(", ")", ";", "$", "where", "=", "new", "Where", "(", ")", ";", "$", "where", "->", "lessThan", "(", "$", "this", "->", "options", "->", "getModifiedColumn", "(", ")", ",", "new", "Expression", "(", "'('", ".", "time", "(", ")", ".", "' - '", ".", "$", "platform", "->", "quoteIdentifier", "(", "$", "this", "->", "options", "->", "getLifetimeColumn", "(", ")", ")", ".", "')'", ")", ")", ";", "$", "rows", "=", "$", "this", "->", "tableGateway", "->", "select", "(", "$", "where", ")", ";", "$", "ids", "=", "[", "]", ";", "/* @var \\UthandoSessionManager\\Model\\SessionModel $row */", "foreach", "(", "$", "rows", "as", "$", "row", ")", "{", "$", "ids", "[", "]", "=", "$", "row", "->", "{", "$", "this", "->", "options", "->", "getIdColumn", "(", ")", "}", ";", "}", "if", "(", "count", "(", "$", "ids", ")", ">", "0", ")", "{", "$", "where", "=", "new", "Where", "(", ")", ";", "$", "result", "=", "(", "bool", ")", "$", "this", "->", "tableGateway", "->", "delete", "(", "$", "where", "->", "in", "(", "$", "this", "->", "options", "->", "getIdColumn", "(", ")", ",", "$", "ids", ")", ")", ";", "}", "else", "{", "$", "result", "=", "false", ";", "}", "return", "$", "result", ";", "}" ]
Garbage Collection Only delete sessions that have expired. @param int $maxlifetime @return true
[ "Garbage", "Collection", "Only", "delete", "sessions", "that", "have", "expired", "." ]
3bfb0a478d6101d6e6748d8528a2a7fee44af408
https://github.com/uthando-cms/uthando-session-manager/blob/3bfb0a478d6101d6e6748d8528a2a7fee44af408/src/UthandoSessionManager/Session/SaveHandler/DbTableGateway.php#L31-L60
239,972
setrun/setrun-component-user
src/repositories/UserRepository.php
UserRepository.save
public function save(User $user) : bool { if (!$user->save()) { throw new \RuntimeException($this->i18n->t('setrun/user', 'Saving error')); } return true; }
php
public function save(User $user) : bool { if (!$user->save()) { throw new \RuntimeException($this->i18n->t('setrun/user', 'Saving error')); } return true; }
[ "public", "function", "save", "(", "User", "$", "user", ")", ":", "bool", "{", "if", "(", "!", "$", "user", "->", "save", "(", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "$", "this", "->", "i18n", "->", "t", "(", "'setrun/user'", ",", "'Saving error'", ")", ")", ";", "}", "return", "true", ";", "}" ]
Save user. @param User $user @return bool
[ "Save", "user", "." ]
6aca4c62f099918032b66da1f94d7565694a0735
https://github.com/setrun/setrun-component-user/blob/6aca4c62f099918032b66da1f94d7565694a0735/src/repositories/UserRepository.php#L138-L144
239,973
setrun/setrun-component-user
src/repositories/UserRepository.php
UserRepository.remove
public function remove(User $user) : bool { if (!$user->delete()) { throw new \RuntimeException($this->i18n->t('setrun/user', 'Removing error')); } return true; }
php
public function remove(User $user) : bool { if (!$user->delete()) { throw new \RuntimeException($this->i18n->t('setrun/user', 'Removing error')); } return true; }
[ "public", "function", "remove", "(", "User", "$", "user", ")", ":", "bool", "{", "if", "(", "!", "$", "user", "->", "delete", "(", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "$", "this", "->", "i18n", "->", "t", "(", "'setrun/user'", ",", "'Removing error'", ")", ")", ";", "}", "return", "true", ";", "}" ]
Remove user. @param User $user @return bool
[ "Remove", "user", "." ]
6aca4c62f099918032b66da1f94d7565694a0735
https://github.com/setrun/setrun-component-user/blob/6aca4c62f099918032b66da1f94d7565694a0735/src/repositories/UserRepository.php#L151-L157
239,974
setrun/setrun-component-user
src/repositories/UserRepository.php
UserRepository.getBy
public function getBy(array $condition) : User { if (!$user = User::find()->andWhere($condition)->limit(1)->one()) { throw new NotFoundException($this->i18n->t('setrun/user', 'User not found')); } return $user; }
php
public function getBy(array $condition) : User { if (!$user = User::find()->andWhere($condition)->limit(1)->one()) { throw new NotFoundException($this->i18n->t('setrun/user', 'User not found')); } return $user; }
[ "public", "function", "getBy", "(", "array", "$", "condition", ")", ":", "User", "{", "if", "(", "!", "$", "user", "=", "User", "::", "find", "(", ")", "->", "andWhere", "(", "$", "condition", ")", "->", "limit", "(", "1", ")", "->", "one", "(", ")", ")", "{", "throw", "new", "NotFoundException", "(", "$", "this", "->", "i18n", "->", "t", "(", "'setrun/user'", ",", "'User not found'", ")", ")", ";", "}", "return", "$", "user", ";", "}" ]
Get user by condition. @param array $condition @return User|array
[ "Get", "user", "by", "condition", "." ]
6aca4c62f099918032b66da1f94d7565694a0735
https://github.com/setrun/setrun-component-user/blob/6aca4c62f099918032b66da1f94d7565694a0735/src/repositories/UserRepository.php#L164-L170
239,975
jakecleary/ultrapress-library
src/Ultra/View/View.php
View.load
private static function load($path) { $path = str_replace('.', '/', $path); $path = FULL_PATH . $path; if(substr($path, -4) != '.php') { $path = $path . '.php'; } return $path; }
php
private static function load($path) { $path = str_replace('.', '/', $path); $path = FULL_PATH . $path; if(substr($path, -4) != '.php') { $path = $path . '.php'; } return $path; }
[ "private", "static", "function", "load", "(", "$", "path", ")", "{", "$", "path", "=", "str_replace", "(", "'.'", ",", "'/'", ",", "$", "path", ")", ";", "$", "path", "=", "FULL_PATH", ".", "$", "path", ";", "if", "(", "substr", "(", "$", "path", ",", "-", "4", ")", "!=", "'.php'", ")", "{", "$", "path", "=", "$", "path", ".", "'.php'", ";", "}", "return", "$", "path", ";", "}" ]
Grab a file, while specifying an optional subdirectory of views. @param string $file The path of file relative to / @return string The full path to the file
[ "Grab", "a", "file", "while", "specifying", "an", "optional", "subdirectory", "of", "views", "." ]
84ca5d1dae8eb16de8c886787575ea41f9332ae2
https://github.com/jakecleary/ultrapress-library/blob/84ca5d1dae8eb16de8c886787575ea41f9332ae2/src/Ultra/View/View.php#L18-L30
239,976
jakecleary/ultrapress-library
src/Ultra/View/View.php
View.get
public static function get($file, $data = []) { $path = self::load('views.' . $file); extract($data, EXTR_SKIP); include $path; }
php
public static function get($file, $data = []) { $path = self::load('views.' . $file); extract($data, EXTR_SKIP); include $path; }
[ "public", "static", "function", "get", "(", "$", "file", ",", "$", "data", "=", "[", "]", ")", "{", "$", "path", "=", "self", "::", "load", "(", "'views.'", ".", "$", "file", ")", ";", "extract", "(", "$", "data", ",", "EXTR_SKIP", ")", ";", "include", "$", "path", ";", "}" ]
Include a view with data. @param string $file The template you want to display @param object $item The optional data of the current object in the loop
[ "Include", "a", "view", "with", "data", "." ]
84ca5d1dae8eb16de8c886787575ea41f9332ae2
https://github.com/jakecleary/ultrapress-library/blob/84ca5d1dae8eb16de8c886787575ea41f9332ae2/src/Ultra/View/View.php#L38-L45
239,977
jakecleary/ultrapress-library
src/Ultra/View/View.php
View.parse
private static function parse($file, $data) { $file = file_get_contents($file, FILE_USE_INCLUDE_PATH); // Go through each variable and replace the values foreach($data as $key => $value) { $pattern = '{{{' . $key . '}}}'; $file = preg_replace($pattern, $value, $file); } if(!!$file) { return $file; } return false; }
php
private static function parse($file, $data) { $file = file_get_contents($file, FILE_USE_INCLUDE_PATH); // Go through each variable and replace the values foreach($data as $key => $value) { $pattern = '{{{' . $key . '}}}'; $file = preg_replace($pattern, $value, $file); } if(!!$file) { return $file; } return false; }
[ "private", "static", "function", "parse", "(", "$", "file", ",", "$", "data", ")", "{", "$", "file", "=", "file_get_contents", "(", "$", "file", ",", "FILE_USE_INCLUDE_PATH", ")", ";", "// Go through each variable and replace the values", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "pattern", "=", "'{{{'", ".", "$", "key", ".", "'}}}'", ";", "$", "file", "=", "preg_replace", "(", "$", "pattern", ",", "$", "value", ",", "$", "file", ")", ";", "}", "if", "(", "!", "!", "$", "file", ")", "{", "return", "$", "file", ";", "}", "return", "false", ";", "}" ]
Parse a template with some data. @param string $file The template file we want the data to be put into @param array $data The data structure @return string|boolean The filled-put template OR false
[ "Parse", "a", "template", "with", "some", "data", "." ]
84ca5d1dae8eb16de8c886787575ea41f9332ae2
https://github.com/jakecleary/ultrapress-library/blob/84ca5d1dae8eb16de8c886787575ea41f9332ae2/src/Ultra/View/View.php#L69-L86
239,978
kiler129/CherryHttp
src/IO/Exception/BufferOverflowException.php
BufferOverflowException.setOverflowMagnitude
public function setOverflowMagnitude($magnitude) { if ($magnitude < 0) { throw new \LogicException('Overflow magnitude cannot be negative.'); } if (!is_numeric($magnitude)) { throw new \InvalidArgumentException('Overflow magnitude should be a number.'); } $this->overflowMagnitude = $magnitude; }
php
public function setOverflowMagnitude($magnitude) { if ($magnitude < 0) { throw new \LogicException('Overflow magnitude cannot be negative.'); } if (!is_numeric($magnitude)) { throw new \InvalidArgumentException('Overflow magnitude should be a number.'); } $this->overflowMagnitude = $magnitude; }
[ "public", "function", "setOverflowMagnitude", "(", "$", "magnitude", ")", "{", "if", "(", "$", "magnitude", "<", "0", ")", "{", "throw", "new", "\\", "LogicException", "(", "'Overflow magnitude cannot be negative.'", ")", ";", "}", "if", "(", "!", "is_numeric", "(", "$", "magnitude", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Overflow magnitude should be a number.'", ")", ";", "}", "$", "this", "->", "overflowMagnitude", "=", "$", "magnitude", ";", "}" ]
Sets how big overflow is. @param number $magnitude Positive number. @throws \InvalidArgumentException Non-numeric magnitude specified. @throws \LogicException Negative magnitude specified.
[ "Sets", "how", "big", "overflow", "is", "." ]
05927f26183cbd6fd5ccb0853befecdea279308d
https://github.com/kiler129/CherryHttp/blob/05927f26183cbd6fd5ccb0853befecdea279308d/src/IO/Exception/BufferOverflowException.php#L42-L53
239,979
mooti/framework
src/Config/AbstractConfig.php
AbstractConfig.getFilepath
public function getFilepath() { if (isset($this->dirPath)) { $filepath = $this->dirPath .'/'.$this->filename; } else { $fileSystem = $this->createNew(FileSystem::class); $filepath = $fileSystem->getCurrentWorkingDirectory() .'/'.$this->filename; } return $filepath; }
php
public function getFilepath() { if (isset($this->dirPath)) { $filepath = $this->dirPath .'/'.$this->filename; } else { $fileSystem = $this->createNew(FileSystem::class); $filepath = $fileSystem->getCurrentWorkingDirectory() .'/'.$this->filename; } return $filepath; }
[ "public", "function", "getFilepath", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "dirPath", ")", ")", "{", "$", "filepath", "=", "$", "this", "->", "dirPath", ".", "'/'", ".", "$", "this", "->", "filename", ";", "}", "else", "{", "$", "fileSystem", "=", "$", "this", "->", "createNew", "(", "FileSystem", "::", "class", ")", ";", "$", "filepath", "=", "$", "fileSystem", "->", "getCurrentWorkingDirectory", "(", ")", ".", "'/'", ".", "$", "this", "->", "filename", ";", "}", "return", "$", "filepath", ";", "}" ]
Get the full file path of the config file @return string The full file path
[ "Get", "the", "full", "file", "path", "of", "the", "config", "file" ]
078da6699c5c6c7ac4e5a3d36751d645ad8aa93e
https://github.com/mooti/framework/blob/078da6699c5c6c7ac4e5a3d36751d645ad8aa93e/src/Config/AbstractConfig.php#L113-L122
239,980
mooti/framework
src/Config/AbstractConfig.php
AbstractConfig.validateConfig
public function validateConfig(array $rules, array $configData) { $validator = $this->createNew(Validator::class); if ($validator->isValid($rules, $configData) == false) { throw new DataValidationException('The config is invalid: ' . print_r($validator->getErrors(), 1)); } }
php
public function validateConfig(array $rules, array $configData) { $validator = $this->createNew(Validator::class); if ($validator->isValid($rules, $configData) == false) { throw new DataValidationException('The config is invalid: ' . print_r($validator->getErrors(), 1)); } }
[ "public", "function", "validateConfig", "(", "array", "$", "rules", ",", "array", "$", "configData", ")", "{", "$", "validator", "=", "$", "this", "->", "createNew", "(", "Validator", "::", "class", ")", ";", "if", "(", "$", "validator", "->", "isValid", "(", "$", "rules", ",", "$", "configData", ")", "==", "false", ")", "{", "throw", "new", "DataValidationException", "(", "'The config is invalid: '", ".", "print_r", "(", "$", "validator", "->", "getErrors", "(", ")", ",", "1", ")", ")", ";", "}", "}" ]
Validate some config data @param array $rules The config rules @param array $configData The config data @throws Mooti\Framework\Exception\DataValidationException
[ "Validate", "some", "config", "data" ]
078da6699c5c6c7ac4e5a3d36751d645ad8aa93e
https://github.com/mooti/framework/blob/078da6699c5c6c7ac4e5a3d36751d645ad8aa93e/src/Config/AbstractConfig.php#L132-L139
239,981
mooti/framework
src/Config/AbstractConfig.php
AbstractConfig.open
public function open() { $fileSystem = $this->createNew(FileSystem::class); $filepath = $this->getFilepath(); $contents = $fileSystem->fileGetContents($filepath); $this->configData = json_decode($contents, true); if (isset($this->configData) == false) { throw new MalformedDataException('The contents of the file "'.$filepath.'" are not valid json'); } $this->validateConfig($this->rules, $this->configData); }
php
public function open() { $fileSystem = $this->createNew(FileSystem::class); $filepath = $this->getFilepath(); $contents = $fileSystem->fileGetContents($filepath); $this->configData = json_decode($contents, true); if (isset($this->configData) == false) { throw new MalformedDataException('The contents of the file "'.$filepath.'" are not valid json'); } $this->validateConfig($this->rules, $this->configData); }
[ "public", "function", "open", "(", ")", "{", "$", "fileSystem", "=", "$", "this", "->", "createNew", "(", "FileSystem", "::", "class", ")", ";", "$", "filepath", "=", "$", "this", "->", "getFilepath", "(", ")", ";", "$", "contents", "=", "$", "fileSystem", "->", "fileGetContents", "(", "$", "filepath", ")", ";", "$", "this", "->", "configData", "=", "json_decode", "(", "$", "contents", ",", "true", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "configData", ")", "==", "false", ")", "{", "throw", "new", "MalformedDataException", "(", "'The contents of the file \"'", ".", "$", "filepath", ".", "'\" are not valid json'", ")", ";", "}", "$", "this", "->", "validateConfig", "(", "$", "this", "->", "rules", ",", "$", "this", "->", "configData", ")", ";", "}" ]
Open the config file and populate the config data @throws Mooti\Framework\Exception\MalformedDataException
[ "Open", "the", "config", "file", "and", "populate", "the", "config", "data" ]
078da6699c5c6c7ac4e5a3d36751d645ad8aa93e
https://github.com/mooti/framework/blob/078da6699c5c6c7ac4e5a3d36751d645ad8aa93e/src/Config/AbstractConfig.php#L146-L160
239,982
mooti/framework
src/Config/AbstractConfig.php
AbstractConfig.save
public function save() { $filepath = $this->getFilepath(); $this->validateConfig($this->rules, $this->configData); $fileSystem = $this->createNew(FileSystem::class); $fileSystem->filePutContents($filepath, json_encode($this->configData, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); }
php
public function save() { $filepath = $this->getFilepath(); $this->validateConfig($this->rules, $this->configData); $fileSystem = $this->createNew(FileSystem::class); $fileSystem->filePutContents($filepath, json_encode($this->configData, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); }
[ "public", "function", "save", "(", ")", "{", "$", "filepath", "=", "$", "this", "->", "getFilepath", "(", ")", ";", "$", "this", "->", "validateConfig", "(", "$", "this", "->", "rules", ",", "$", "this", "->", "configData", ")", ";", "$", "fileSystem", "=", "$", "this", "->", "createNew", "(", "FileSystem", "::", "class", ")", ";", "$", "fileSystem", "->", "filePutContents", "(", "$", "filepath", ",", "json_encode", "(", "$", "this", "->", "configData", ",", "JSON_PRETTY_PRINT", "|", "JSON_UNESCAPED_SLASHES", ")", ")", ";", "}" ]
Save the config file based on the config data
[ "Save", "the", "config", "file", "based", "on", "the", "config", "data" ]
078da6699c5c6c7ac4e5a3d36751d645ad8aa93e
https://github.com/mooti/framework/blob/078da6699c5c6c7ac4e5a3d36751d645ad8aa93e/src/Config/AbstractConfig.php#L166-L172
239,983
mcfedr/youtubelivestreamsbundle
src/Mcfedr/YouTube/LiveStreamsBundle/Streams/YouTubeStreamsLoader.php
YouTubeStreamsLoader.getStreams
public function getStreams($channelId = null) { if (!$channelId) { $channelId = $this->channelId; } if (!$channelId) { throw new MissingChannelIdException("You must specify the channel id"); } if ($this->cache) { $data = $this->cache->fetch($this->getCacheKey($channelId)); if ($data !== false) { return $data; } } $searchResponse = $this->client->get( 'search', [ 'query' => [ 'part' => 'id', 'channelId' => $channelId, 'eventType' => 'live', 'type' => 'video', 'maxResults' => 50 ] ] ); $searchData = json_decode($searchResponse->getBody()->getContents(), true); $videosResponse = $this->client->get( 'videos', [ 'query' => [ 'part' => 'id,snippet,liveStreamingDetails', 'id' => implode( ',', array_map( function ($video) { return $video['id']['videoId']; }, $searchData['items'] ) ) ] ] ); $videosData = json_decode($videosResponse->getBody()->getContents(), true); $streams = array_map( function ($video) { return [ 'name' => $video['snippet']['title'], 'thumb' => $video['snippet']['thumbnails']['high']['url'], 'videoId' => $video['id'] ]; }, array_values( array_filter( $videosData['items'], function ($video) { return !isset($video['liveStreamingDetails']['actualEndTime']); } ) ) ); if ($this->cache && $this->cacheTimeout > 0) { $this->cache->save($this->getCacheKey($channelId), $streams, $this->cacheTimeout); } return $streams; }
php
public function getStreams($channelId = null) { if (!$channelId) { $channelId = $this->channelId; } if (!$channelId) { throw new MissingChannelIdException("You must specify the channel id"); } if ($this->cache) { $data = $this->cache->fetch($this->getCacheKey($channelId)); if ($data !== false) { return $data; } } $searchResponse = $this->client->get( 'search', [ 'query' => [ 'part' => 'id', 'channelId' => $channelId, 'eventType' => 'live', 'type' => 'video', 'maxResults' => 50 ] ] ); $searchData = json_decode($searchResponse->getBody()->getContents(), true); $videosResponse = $this->client->get( 'videos', [ 'query' => [ 'part' => 'id,snippet,liveStreamingDetails', 'id' => implode( ',', array_map( function ($video) { return $video['id']['videoId']; }, $searchData['items'] ) ) ] ] ); $videosData = json_decode($videosResponse->getBody()->getContents(), true); $streams = array_map( function ($video) { return [ 'name' => $video['snippet']['title'], 'thumb' => $video['snippet']['thumbnails']['high']['url'], 'videoId' => $video['id'] ]; }, array_values( array_filter( $videosData['items'], function ($video) { return !isset($video['liveStreamingDetails']['actualEndTime']); } ) ) ); if ($this->cache && $this->cacheTimeout > 0) { $this->cache->save($this->getCacheKey($channelId), $streams, $this->cacheTimeout); } return $streams; }
[ "public", "function", "getStreams", "(", "$", "channelId", "=", "null", ")", "{", "if", "(", "!", "$", "channelId", ")", "{", "$", "channelId", "=", "$", "this", "->", "channelId", ";", "}", "if", "(", "!", "$", "channelId", ")", "{", "throw", "new", "MissingChannelIdException", "(", "\"You must specify the channel id\"", ")", ";", "}", "if", "(", "$", "this", "->", "cache", ")", "{", "$", "data", "=", "$", "this", "->", "cache", "->", "fetch", "(", "$", "this", "->", "getCacheKey", "(", "$", "channelId", ")", ")", ";", "if", "(", "$", "data", "!==", "false", ")", "{", "return", "$", "data", ";", "}", "}", "$", "searchResponse", "=", "$", "this", "->", "client", "->", "get", "(", "'search'", ",", "[", "'query'", "=>", "[", "'part'", "=>", "'id'", ",", "'channelId'", "=>", "$", "channelId", ",", "'eventType'", "=>", "'live'", ",", "'type'", "=>", "'video'", ",", "'maxResults'", "=>", "50", "]", "]", ")", ";", "$", "searchData", "=", "json_decode", "(", "$", "searchResponse", "->", "getBody", "(", ")", "->", "getContents", "(", ")", ",", "true", ")", ";", "$", "videosResponse", "=", "$", "this", "->", "client", "->", "get", "(", "'videos'", ",", "[", "'query'", "=>", "[", "'part'", "=>", "'id,snippet,liveStreamingDetails'", ",", "'id'", "=>", "implode", "(", "','", ",", "array_map", "(", "function", "(", "$", "video", ")", "{", "return", "$", "video", "[", "'id'", "]", "[", "'videoId'", "]", ";", "}", ",", "$", "searchData", "[", "'items'", "]", ")", ")", "]", "]", ")", ";", "$", "videosData", "=", "json_decode", "(", "$", "videosResponse", "->", "getBody", "(", ")", "->", "getContents", "(", ")", ",", "true", ")", ";", "$", "streams", "=", "array_map", "(", "function", "(", "$", "video", ")", "{", "return", "[", "'name'", "=>", "$", "video", "[", "'snippet'", "]", "[", "'title'", "]", ",", "'thumb'", "=>", "$", "video", "[", "'snippet'", "]", "[", "'thumbnails'", "]", "[", "'high'", "]", "[", "'url'", "]", ",", "'videoId'", "=>", "$", "video", "[", "'id'", "]", "]", ";", "}", ",", "array_values", "(", "array_filter", "(", "$", "videosData", "[", "'items'", "]", ",", "function", "(", "$", "video", ")", "{", "return", "!", "isset", "(", "$", "video", "[", "'liveStreamingDetails'", "]", "[", "'actualEndTime'", "]", ")", ";", "}", ")", ")", ")", ";", "if", "(", "$", "this", "->", "cache", "&&", "$", "this", "->", "cacheTimeout", ">", "0", ")", "{", "$", "this", "->", "cache", "->", "save", "(", "$", "this", "->", "getCacheKey", "(", "$", "channelId", ")", ",", "$", "streams", ",", "$", "this", "->", "cacheTimeout", ")", ";", "}", "return", "$", "streams", ";", "}" ]
Get the list of videos from YouTube @param string $channelId @throws \Mcfedr\YouTube\LiveStreamsBundle\Exception\MissingChannelIdException @return array
[ "Get", "the", "list", "of", "videos", "from", "YouTube" ]
4a82d3b4e2722a629654c6c2a0aeaa178bb4a6cb
https://github.com/mcfedr/youtubelivestreamsbundle/blob/4a82d3b4e2722a629654c6c2a0aeaa178bb4a6cb/src/Mcfedr/YouTube/LiveStreamsBundle/Streams/YouTubeStreamsLoader.php#L55-L130
239,984
jakecleary/ultrapress-library
src/Ultra/Config/Config.php
Config.get
public static function get($file, $key = false, $force = false) { $item = self::read($file, $force); if($item === false) { return false; } if($key != false && isset($item[$key])) { return $item[$key]; } return $item; }
php
public static function get($file, $key = false, $force = false) { $item = self::read($file, $force); if($item === false) { return false; } if($key != false && isset($item[$key])) { return $item[$key]; } return $item; }
[ "public", "static", "function", "get", "(", "$", "file", ",", "$", "key", "=", "false", ",", "$", "force", "=", "false", ")", "{", "$", "item", "=", "self", "::", "read", "(", "$", "file", ",", "$", "force", ")", ";", "if", "(", "$", "item", "===", "false", ")", "{", "return", "false", ";", "}", "if", "(", "$", "key", "!=", "false", "&&", "isset", "(", "$", "item", "[", "$", "key", "]", ")", ")", "{", "return", "$", "item", "[", "$", "key", "]", ";", "}", "return", "$", "item", ";", "}" ]
Get the key from a config file. @param string $file The name of the config file @param string $key The name of the array key @param boolean $force = false Force read the config from file @return * $data The data stored in that key
[ "Get", "the", "key", "from", "a", "config", "file", "." ]
84ca5d1dae8eb16de8c886787575ea41f9332ae2
https://github.com/jakecleary/ultrapress-library/blob/84ca5d1dae8eb16de8c886787575ea41f9332ae2/src/Ultra/Config/Config.php#L72-L87
239,985
AlcyZ/Alcys-ORM
src/Core/Db/Facade/JoinFacade.php
JoinFacade.inner
public function inner($table, array $optionalTables = array()) { $preparedTablesArray = $this->_getPreparedTableObjects($table, $optionalTables); $this->join->inner($preparedTablesArray['table'], $preparedTablesArray['optionalTables']); return $this; }
php
public function inner($table, array $optionalTables = array()) { $preparedTablesArray = $this->_getPreparedTableObjects($table, $optionalTables); $this->join->inner($preparedTablesArray['table'], $preparedTablesArray['optionalTables']); return $this; }
[ "public", "function", "inner", "(", "$", "table", ",", "array", "$", "optionalTables", "=", "array", "(", ")", ")", "{", "$", "preparedTablesArray", "=", "$", "this", "->", "_getPreparedTableObjects", "(", "$", "table", ",", "$", "optionalTables", ")", ";", "$", "this", "->", "join", "->", "inner", "(", "$", "preparedTablesArray", "[", "'table'", "]", ",", "$", "preparedTablesArray", "[", "'optionalTables'", "]", ")", ";", "return", "$", "this", ";", "}" ]
Join the expected table with an inner join. In the second argument can pass optional tables for the join operation. @param string $table Name of the table for the join. @param array $optionalTables (Optional) Array with table names as elements @return $this The same instance to concatenate methods.
[ "Join", "the", "expected", "table", "with", "an", "inner", "join", ".", "In", "the", "second", "argument", "can", "pass", "optional", "tables", "for", "the", "join", "operation", "." ]
dd30946ad35ab06cba2167cf6dfa02b733614720
https://github.com/AlcyZ/Alcys-ORM/blob/dd30946ad35ab06cba2167cf6dfa02b733614720/src/Core/Db/Facade/JoinFacade.php#L77-L83
239,986
AlcyZ/Alcys-ORM
src/Core/Db/Facade/JoinFacade.php
JoinFacade.left
public function left($table, array $optionalTables = array()) { $preparedTablesArray = $this->_getPreparedTableObjects($table, $optionalTables); $this->join->left($preparedTablesArray['table'], $preparedTablesArray['optionalTables']); return $this; }
php
public function left($table, array $optionalTables = array()) { $preparedTablesArray = $this->_getPreparedTableObjects($table, $optionalTables); $this->join->left($preparedTablesArray['table'], $preparedTablesArray['optionalTables']); return $this; }
[ "public", "function", "left", "(", "$", "table", ",", "array", "$", "optionalTables", "=", "array", "(", ")", ")", "{", "$", "preparedTablesArray", "=", "$", "this", "->", "_getPreparedTableObjects", "(", "$", "table", ",", "$", "optionalTables", ")", ";", "$", "this", "->", "join", "->", "left", "(", "$", "preparedTablesArray", "[", "'table'", "]", ",", "$", "preparedTablesArray", "[", "'optionalTables'", "]", ")", ";", "return", "$", "this", ";", "}" ]
Join the expected table with a left join. In the second argument can pass optional tables for the join operation. @param string $table Name of the table for the join. @param array $optionalTables (Optional) Array with table names as elements @return $this The same instance to concatenate methods.
[ "Join", "the", "expected", "table", "with", "a", "left", "join", ".", "In", "the", "second", "argument", "can", "pass", "optional", "tables", "for", "the", "join", "operation", "." ]
dd30946ad35ab06cba2167cf6dfa02b733614720
https://github.com/AlcyZ/Alcys-ORM/blob/dd30946ad35ab06cba2167cf6dfa02b733614720/src/Core/Db/Facade/JoinFacade.php#L95-L101
239,987
AlcyZ/Alcys-ORM
src/Core/Db/Facade/JoinFacade.php
JoinFacade.right
public function right($table, array $optionalTables = array()) { $preparedTablesArray = $this->_getPreparedTableObjects($table, $optionalTables); $this->join->right($preparedTablesArray['table'], $preparedTablesArray['optionalTables']); return $this; }
php
public function right($table, array $optionalTables = array()) { $preparedTablesArray = $this->_getPreparedTableObjects($table, $optionalTables); $this->join->right($preparedTablesArray['table'], $preparedTablesArray['optionalTables']); return $this; }
[ "public", "function", "right", "(", "$", "table", ",", "array", "$", "optionalTables", "=", "array", "(", ")", ")", "{", "$", "preparedTablesArray", "=", "$", "this", "->", "_getPreparedTableObjects", "(", "$", "table", ",", "$", "optionalTables", ")", ";", "$", "this", "->", "join", "->", "right", "(", "$", "preparedTablesArray", "[", "'table'", "]", ",", "$", "preparedTablesArray", "[", "'optionalTables'", "]", ")", ";", "return", "$", "this", ";", "}" ]
Join the expected table with a right join. In the second argument can pass optional tables for the join operation. @param string $table Name of the table for the join. @param array $optionalTables (Optional) Array with table names as elements @return $this The same instance to concatenate methods.
[ "Join", "the", "expected", "table", "with", "a", "right", "join", ".", "In", "the", "second", "argument", "can", "pass", "optional", "tables", "for", "the", "join", "operation", "." ]
dd30946ad35ab06cba2167cf6dfa02b733614720
https://github.com/AlcyZ/Alcys-ORM/blob/dd30946ad35ab06cba2167cf6dfa02b733614720/src/Core/Db/Facade/JoinFacade.php#L113-L119
239,988
AlcyZ/Alcys-ORM
src/Core/Db/Facade/JoinFacade.php
JoinFacade.leftOuter
public function leftOuter($table, array $optionalTables = array()) { $preparedTablesArray = $this->_getPreparedTableObjects($table, $optionalTables); $this->join->leftOuter($preparedTablesArray['table'], $preparedTablesArray['optionalTables']); return $this; }
php
public function leftOuter($table, array $optionalTables = array()) { $preparedTablesArray = $this->_getPreparedTableObjects($table, $optionalTables); $this->join->leftOuter($preparedTablesArray['table'], $preparedTablesArray['optionalTables']); return $this; }
[ "public", "function", "leftOuter", "(", "$", "table", ",", "array", "$", "optionalTables", "=", "array", "(", ")", ")", "{", "$", "preparedTablesArray", "=", "$", "this", "->", "_getPreparedTableObjects", "(", "$", "table", ",", "$", "optionalTables", ")", ";", "$", "this", "->", "join", "->", "leftOuter", "(", "$", "preparedTablesArray", "[", "'table'", "]", ",", "$", "preparedTablesArray", "[", "'optionalTables'", "]", ")", ";", "return", "$", "this", ";", "}" ]
Join the expected table with a left outer join. In the second argument can pass optional tables for the join operation. @param string $table Name of the table for the join. @param array $optionalTables (Optional) Array with table names as elements @return $this The same instance to concatenate methods.
[ "Join", "the", "expected", "table", "with", "a", "left", "outer", "join", ".", "In", "the", "second", "argument", "can", "pass", "optional", "tables", "for", "the", "join", "operation", "." ]
dd30946ad35ab06cba2167cf6dfa02b733614720
https://github.com/AlcyZ/Alcys-ORM/blob/dd30946ad35ab06cba2167cf6dfa02b733614720/src/Core/Db/Facade/JoinFacade.php#L131-L137
239,989
AlcyZ/Alcys-ORM
src/Core/Db/Facade/JoinFacade.php
JoinFacade.rightOuter
public function rightOuter($table, array $optionalTables = array()) { $preparedTablesArray = $this->_getPreparedTableObjects($table, $optionalTables); $this->join->rightOuter($preparedTablesArray['table'], $preparedTablesArray['optionalTables']); return $this; }
php
public function rightOuter($table, array $optionalTables = array()) { $preparedTablesArray = $this->_getPreparedTableObjects($table, $optionalTables); $this->join->rightOuter($preparedTablesArray['table'], $preparedTablesArray['optionalTables']); return $this; }
[ "public", "function", "rightOuter", "(", "$", "table", ",", "array", "$", "optionalTables", "=", "array", "(", ")", ")", "{", "$", "preparedTablesArray", "=", "$", "this", "->", "_getPreparedTableObjects", "(", "$", "table", ",", "$", "optionalTables", ")", ";", "$", "this", "->", "join", "->", "rightOuter", "(", "$", "preparedTablesArray", "[", "'table'", "]", ",", "$", "preparedTablesArray", "[", "'optionalTables'", "]", ")", ";", "return", "$", "this", ";", "}" ]
Join the expected table with a right outer join. In the second argument can pass optional tables for the join operation. @param string $table Name of the table for the join. @param array $optionalTables (Optional) Array with table names as elements @return $this The same instance to concatenate methods.
[ "Join", "the", "expected", "table", "with", "a", "right", "outer", "join", ".", "In", "the", "second", "argument", "can", "pass", "optional", "tables", "for", "the", "join", "operation", "." ]
dd30946ad35ab06cba2167cf6dfa02b733614720
https://github.com/AlcyZ/Alcys-ORM/blob/dd30946ad35ab06cba2167cf6dfa02b733614720/src/Core/Db/Facade/JoinFacade.php#L149-L155
239,990
AlcyZ/Alcys-ORM
src/Core/Db/Facade/JoinFacade.php
JoinFacade._getPreparedTableObjects
private function _getPreparedTableObjects($table, array $optionalTables) { $tableObj = $this->factory->references('Table', $table); $optionalTablesObj = array(); foreach($optionalTables as $tbl) { $optionalTablesObj[] = $this->factory->references('Table', $tbl); } return array('table' => $tableObj, 'optionalTables' => $optionalTablesObj); }
php
private function _getPreparedTableObjects($table, array $optionalTables) { $tableObj = $this->factory->references('Table', $table); $optionalTablesObj = array(); foreach($optionalTables as $tbl) { $optionalTablesObj[] = $this->factory->references('Table', $tbl); } return array('table' => $tableObj, 'optionalTables' => $optionalTablesObj); }
[ "private", "function", "_getPreparedTableObjects", "(", "$", "table", ",", "array", "$", "optionalTables", ")", "{", "$", "tableObj", "=", "$", "this", "->", "factory", "->", "references", "(", "'Table'", ",", "$", "table", ")", ";", "$", "optionalTablesObj", "=", "array", "(", ")", ";", "foreach", "(", "$", "optionalTables", "as", "$", "tbl", ")", "{", "$", "optionalTablesObj", "[", "]", "=", "$", "this", "->", "factory", "->", "references", "(", "'Table'", ",", "$", "tbl", ")", ";", "}", "return", "array", "(", "'table'", "=>", "$", "tableObj", ",", "'optionalTables'", "=>", "$", "optionalTablesObj", ")", ";", "}" ]
Create table objects from the passed arguments. An array will return with the key 'table' for the main table and 'optionalTables' for optional tables. When no optional tables are passed, the key 'optionalTables' return an empty array. @param string $table Name of the main table. @param array $optionalTables Optional table names, hold in an array. @return array Array with prepared table objects, format: ['table' => $tbl, 'optionalTables' => array].
[ "Create", "table", "objects", "from", "the", "passed", "arguments", ".", "An", "array", "will", "return", "with", "the", "key", "table", "for", "the", "main", "table", "and", "optionalTables", "for", "optional", "tables", ".", "When", "no", "optional", "tables", "are", "passed", "the", "key", "optionalTables", "return", "an", "empty", "array", "." ]
dd30946ad35ab06cba2167cf6dfa02b733614720
https://github.com/AlcyZ/Alcys-ORM/blob/dd30946ad35ab06cba2167cf6dfa02b733614720/src/Core/Db/Facade/JoinFacade.php#L237-L247
239,991
AlcyZ/Alcys-ORM
src/Core/Db/Facade/JoinFacade.php
JoinFacade._checkOnArguments
private function _checkOnArguments(array $firstColumn, array $secondColumn) { if(!array_key_exists('column', $firstColumn) || !array_key_exists('table', $firstColumn) || !array_key_exists('column', $secondColumn) || !array_key_exists('table', $secondColumn) ) { throw new \InvalidArgumentException('Both arguments of on method require "column" and "table" as key'); } }
php
private function _checkOnArguments(array $firstColumn, array $secondColumn) { if(!array_key_exists('column', $firstColumn) || !array_key_exists('table', $firstColumn) || !array_key_exists('column', $secondColumn) || !array_key_exists('table', $secondColumn) ) { throw new \InvalidArgumentException('Both arguments of on method require "column" and "table" as key'); } }
[ "private", "function", "_checkOnArguments", "(", "array", "$", "firstColumn", ",", "array", "$", "secondColumn", ")", "{", "if", "(", "!", "array_key_exists", "(", "'column'", ",", "$", "firstColumn", ")", "||", "!", "array_key_exists", "(", "'table'", ",", "$", "firstColumn", ")", "||", "!", "array_key_exists", "(", "'column'", ",", "$", "secondColumn", ")", "||", "!", "array_key_exists", "(", "'table'", ",", "$", "secondColumn", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Both arguments of on method require \"column\" and \"table\" as key'", ")", ";", "}", "}" ]
Check the passed arguments of the on method. If they don't have keys equivalent to column and table, an invalid argument exception will thrown. @param array $firstColumn First argument of on method. @param array $secondColumn Second argument of on method.
[ "Check", "the", "passed", "arguments", "of", "the", "on", "method", ".", "If", "they", "don", "t", "have", "keys", "equivalent", "to", "column", "and", "table", "an", "invalid", "argument", "exception", "will", "thrown", "." ]
dd30946ad35ab06cba2167cf6dfa02b733614720
https://github.com/AlcyZ/Alcys-ORM/blob/dd30946ad35ab06cba2167cf6dfa02b733614720/src/Core/Db/Facade/JoinFacade.php#L257-L265
239,992
weew/kernel
src/Weew/Kernel/Kernel.php
Kernel.createEach
protected function createEach() { foreach ($this->providers as $class => &$data) { if ( ! array_get($data, 'instance')) { $instance = $this->getProviderInvoker() ->create($class, $this->getSharedArguments()); array_set($data, 'instance', $instance); $this->create(); break; } } }
php
protected function createEach() { foreach ($this->providers as $class => &$data) { if ( ! array_get($data, 'instance')) { $instance = $this->getProviderInvoker() ->create($class, $this->getSharedArguments()); array_set($data, 'instance', $instance); $this->create(); break; } } }
[ "protected", "function", "createEach", "(", ")", "{", "foreach", "(", "$", "this", "->", "providers", "as", "$", "class", "=>", "&", "$", "data", ")", "{", "if", "(", "!", "array_get", "(", "$", "data", ",", "'instance'", ")", ")", "{", "$", "instance", "=", "$", "this", "->", "getProviderInvoker", "(", ")", "->", "create", "(", "$", "class", ",", "$", "this", "->", "getSharedArguments", "(", ")", ")", ";", "array_set", "(", "$", "data", ",", "'instance'", ",", "$", "instance", ")", ";", "$", "this", "->", "create", "(", ")", ";", "break", ";", "}", "}", "}" ]
Instantiate all providers.
[ "Instantiate", "all", "providers", "." ]
4dada4aa36ed1f5bebad2a2864941c68fa568a58
https://github.com/weew/kernel/blob/4dada4aa36ed1f5bebad2a2864941c68fa568a58/src/Weew/Kernel/Kernel.php#L49-L60
239,993
weew/kernel
src/Weew/Kernel/Kernel.php
Kernel.configureEach
protected function configureEach() { foreach ($this->providers as $class => &$data) { if ( ! array_contains(array_get($data, 'tags'), ProviderTag::CONFIGURED)) { $this->create(); array_add($data, 'tags', ProviderTag::CONFIGURED); $instance = array_get($data, 'instance'); if (method_exists($instance, 'configure')) { $this->getProviderInvoker() ->configure($instance, $this->getSharedArguments()); } $this->configureEach(); break; } } }
php
protected function configureEach() { foreach ($this->providers as $class => &$data) { if ( ! array_contains(array_get($data, 'tags'), ProviderTag::CONFIGURED)) { $this->create(); array_add($data, 'tags', ProviderTag::CONFIGURED); $instance = array_get($data, 'instance'); if (method_exists($instance, 'configure')) { $this->getProviderInvoker() ->configure($instance, $this->getSharedArguments()); } $this->configureEach(); break; } } }
[ "protected", "function", "configureEach", "(", ")", "{", "foreach", "(", "$", "this", "->", "providers", "as", "$", "class", "=>", "&", "$", "data", ")", "{", "if", "(", "!", "array_contains", "(", "array_get", "(", "$", "data", ",", "'tags'", ")", ",", "ProviderTag", "::", "CONFIGURED", ")", ")", "{", "$", "this", "->", "create", "(", ")", ";", "array_add", "(", "$", "data", ",", "'tags'", ",", "ProviderTag", "::", "CONFIGURED", ")", ";", "$", "instance", "=", "array_get", "(", "$", "data", ",", "'instance'", ")", ";", "if", "(", "method_exists", "(", "$", "instance", ",", "'configure'", ")", ")", "{", "$", "this", "->", "getProviderInvoker", "(", ")", "->", "configure", "(", "$", "instance", ",", "$", "this", "->", "getSharedArguments", "(", ")", ")", ";", "}", "$", "this", "->", "configureEach", "(", ")", ";", "break", ";", "}", "}", "}" ]
Configure all providers. @return void
[ "Configure", "all", "providers", "." ]
4dada4aa36ed1f5bebad2a2864941c68fa568a58
https://github.com/weew/kernel/blob/4dada4aa36ed1f5bebad2a2864941c68fa568a58/src/Weew/Kernel/Kernel.php#L76-L93
239,994
weew/kernel
src/Weew/Kernel/Kernel.php
Kernel.initializeEach
protected function initializeEach() { foreach ($this->providers as $class => &$data) { if ( ! array_contains(array_get($data, 'tags'), ProviderTag::INITIALIZED)) { $this->configure(); array_add($data, 'tags', ProviderTag::INITIALIZED); $instance = array_get($data, 'instance'); if (method_exists($instance, 'initialize')) { $this->getProviderInvoker() ->initialize($instance, $this->getSharedArguments()); } $this->initializeEach(); break; } } }
php
protected function initializeEach() { foreach ($this->providers as $class => &$data) { if ( ! array_contains(array_get($data, 'tags'), ProviderTag::INITIALIZED)) { $this->configure(); array_add($data, 'tags', ProviderTag::INITIALIZED); $instance = array_get($data, 'instance'); if (method_exists($instance, 'initialize')) { $this->getProviderInvoker() ->initialize($instance, $this->getSharedArguments()); } $this->initializeEach(); break; } } }
[ "protected", "function", "initializeEach", "(", ")", "{", "foreach", "(", "$", "this", "->", "providers", "as", "$", "class", "=>", "&", "$", "data", ")", "{", "if", "(", "!", "array_contains", "(", "array_get", "(", "$", "data", ",", "'tags'", ")", ",", "ProviderTag", "::", "INITIALIZED", ")", ")", "{", "$", "this", "->", "configure", "(", ")", ";", "array_add", "(", "$", "data", ",", "'tags'", ",", "ProviderTag", "::", "INITIALIZED", ")", ";", "$", "instance", "=", "array_get", "(", "$", "data", ",", "'instance'", ")", ";", "if", "(", "method_exists", "(", "$", "instance", ",", "'initialize'", ")", ")", "{", "$", "this", "->", "getProviderInvoker", "(", ")", "->", "initialize", "(", "$", "instance", ",", "$", "this", "->", "getSharedArguments", "(", ")", ")", ";", "}", "$", "this", "->", "initializeEach", "(", ")", ";", "break", ";", "}", "}", "}" ]
Initialize all providers. @return void
[ "Initialize", "all", "providers", "." ]
4dada4aa36ed1f5bebad2a2864941c68fa568a58
https://github.com/weew/kernel/blob/4dada4aa36ed1f5bebad2a2864941c68fa568a58/src/Weew/Kernel/Kernel.php#L109-L126
239,995
weew/kernel
src/Weew/Kernel/Kernel.php
Kernel.bootEach
protected function bootEach() { foreach ($this->providers as $class => &$data) { if ( ! array_contains(array_get($data, 'tags'), ProviderTag::BOOTED)) { $this->initialize(); array_add($data, 'tags', ProviderTag::BOOTED); $instance = array_get($data, 'instance'); if (method_exists($instance, 'boot')) { $this->getProviderInvoker() ->boot($instance, $this->getSharedArguments()); } $this->bootEach(); break; } } }
php
protected function bootEach() { foreach ($this->providers as $class => &$data) { if ( ! array_contains(array_get($data, 'tags'), ProviderTag::BOOTED)) { $this->initialize(); array_add($data, 'tags', ProviderTag::BOOTED); $instance = array_get($data, 'instance'); if (method_exists($instance, 'boot')) { $this->getProviderInvoker() ->boot($instance, $this->getSharedArguments()); } $this->bootEach(); break; } } }
[ "protected", "function", "bootEach", "(", ")", "{", "foreach", "(", "$", "this", "->", "providers", "as", "$", "class", "=>", "&", "$", "data", ")", "{", "if", "(", "!", "array_contains", "(", "array_get", "(", "$", "data", ",", "'tags'", ")", ",", "ProviderTag", "::", "BOOTED", ")", ")", "{", "$", "this", "->", "initialize", "(", ")", ";", "array_add", "(", "$", "data", ",", "'tags'", ",", "ProviderTag", "::", "BOOTED", ")", ";", "$", "instance", "=", "array_get", "(", "$", "data", ",", "'instance'", ")", ";", "if", "(", "method_exists", "(", "$", "instance", ",", "'boot'", ")", ")", "{", "$", "this", "->", "getProviderInvoker", "(", ")", "->", "boot", "(", "$", "instance", ",", "$", "this", "->", "getSharedArguments", "(", ")", ")", ";", "}", "$", "this", "->", "bootEach", "(", ")", ";", "break", ";", "}", "}", "}" ]
Boot all providers. @return void
[ "Boot", "all", "providers", "." ]
4dada4aa36ed1f5bebad2a2864941c68fa568a58
https://github.com/weew/kernel/blob/4dada4aa36ed1f5bebad2a2864941c68fa568a58/src/Weew/Kernel/Kernel.php#L142-L159
239,996
weew/kernel
src/Weew/Kernel/Kernel.php
Kernel.shutdownEach
protected function shutdownEach() { foreach ($this->providers as $class => &$data) { if ( ! array_contains(array_get($data, 'tags'), ProviderTag::SHUTDOWN)) { $this->boot(); array_add($data, 'tags', ProviderTag::SHUTDOWN); $instance = array_get($data, 'instance'); if (method_exists($instance, 'shutdown')) { $this->getProviderInvoker() ->boot($instance, $this->getSharedArguments()); } $this->shutdownEach(); break; } } }
php
protected function shutdownEach() { foreach ($this->providers as $class => &$data) { if ( ! array_contains(array_get($data, 'tags'), ProviderTag::SHUTDOWN)) { $this->boot(); array_add($data, 'tags', ProviderTag::SHUTDOWN); $instance = array_get($data, 'instance'); if (method_exists($instance, 'shutdown')) { $this->getProviderInvoker() ->boot($instance, $this->getSharedArguments()); } $this->shutdownEach(); break; } } }
[ "protected", "function", "shutdownEach", "(", ")", "{", "foreach", "(", "$", "this", "->", "providers", "as", "$", "class", "=>", "&", "$", "data", ")", "{", "if", "(", "!", "array_contains", "(", "array_get", "(", "$", "data", ",", "'tags'", ")", ",", "ProviderTag", "::", "SHUTDOWN", ")", ")", "{", "$", "this", "->", "boot", "(", ")", ";", "array_add", "(", "$", "data", ",", "'tags'", ",", "ProviderTag", "::", "SHUTDOWN", ")", ";", "$", "instance", "=", "array_get", "(", "$", "data", ",", "'instance'", ")", ";", "if", "(", "method_exists", "(", "$", "instance", ",", "'shutdown'", ")", ")", "{", "$", "this", "->", "getProviderInvoker", "(", ")", "->", "boot", "(", "$", "instance", ",", "$", "this", "->", "getSharedArguments", "(", ")", ")", ";", "}", "$", "this", "->", "shutdownEach", "(", ")", ";", "break", ";", "}", "}", "}" ]
Shutdown all providers.
[ "Shutdown", "all", "providers", "." ]
4dada4aa36ed1f5bebad2a2864941c68fa568a58
https://github.com/weew/kernel/blob/4dada4aa36ed1f5bebad2a2864941c68fa568a58/src/Weew/Kernel/Kernel.php#L177-L194
239,997
antaresproject/tester
src/Adapter/MessageAdapter.php
MessageAdapter.add
public function add($message, $code, $type) { $default = ['message' => $message, 'code' => $code, 'type' => $type]; if ($type == 'error' && is_numeric($code) && $code >= 0) { $default['descriptor'] = array_search($code, $this->codes['codes']); } if ($this->domain !== self::DEFAULT_DOMAIN) { $default['domain'] = $this->domain; } array_push($this->messages, $default); return $this; }
php
public function add($message, $code, $type) { $default = ['message' => $message, 'code' => $code, 'type' => $type]; if ($type == 'error' && is_numeric($code) && $code >= 0) { $default['descriptor'] = array_search($code, $this->codes['codes']); } if ($this->domain !== self::DEFAULT_DOMAIN) { $default['domain'] = $this->domain; } array_push($this->messages, $default); return $this; }
[ "public", "function", "add", "(", "$", "message", ",", "$", "code", ",", "$", "type", ")", "{", "$", "default", "=", "[", "'message'", "=>", "$", "message", ",", "'code'", "=>", "$", "code", ",", "'type'", "=>", "$", "type", "]", ";", "if", "(", "$", "type", "==", "'error'", "&&", "is_numeric", "(", "$", "code", ")", "&&", "$", "code", ">=", "0", ")", "{", "$", "default", "[", "'descriptor'", "]", "=", "array_search", "(", "$", "code", ",", "$", "this", "->", "codes", "[", "'codes'", "]", ")", ";", "}", "if", "(", "$", "this", "->", "domain", "!==", "self", "::", "DEFAULT_DOMAIN", ")", "{", "$", "default", "[", "'domain'", "]", "=", "$", "this", "->", "domain", ";", "}", "array_push", "(", "$", "this", "->", "messages", ",", "$", "default", ")", ";", "return", "$", "this", ";", "}" ]
add message to container; @param String $message @param numeric $code @param String $type @return \Antares\Tester\Adapter\ResponseAdapter
[ "add", "message", "to", "container", ";" ]
23e9b4dd7880475769486a8c8f979ab6530c99df
https://github.com/antaresproject/tester/blob/23e9b4dd7880475769486a8c8f979ab6530c99df/src/Adapter/MessageAdapter.php#L91-L102
239,998
20centcroak/DBManagement
src/DbManagementTable.php
DbManagementTable.populate
public function populate(DbManagement $db, DbManagementObject $DbManagementObject, $query) { $keys = array_values($DbManagementObject->getKeys()); $db->add($query, $keys); $array = array_values($DbManagementObject->getValues()); $db->query($query, $array); return $db->lastInsertId(); }
php
public function populate(DbManagement $db, DbManagementObject $DbManagementObject, $query) { $keys = array_values($DbManagementObject->getKeys()); $db->add($query, $keys); $array = array_values($DbManagementObject->getValues()); $db->query($query, $array); return $db->lastInsertId(); }
[ "public", "function", "populate", "(", "DbManagement", "$", "db", ",", "DbManagementObject", "$", "DbManagementObject", ",", "$", "query", ")", "{", "$", "keys", "=", "array_values", "(", "$", "DbManagementObject", "->", "getKeys", "(", ")", ")", ";", "$", "db", "->", "add", "(", "$", "query", ",", "$", "keys", ")", ";", "$", "array", "=", "array_values", "(", "$", "DbManagementObject", "->", "getValues", "(", ")", ")", ";", "$", "db", "->", "query", "(", "$", "query", ",", "$", "array", ")", ";", "return", "$", "db", "->", "lastInsertId", "(", ")", ";", "}" ]
add an Object to the table in the database @param DbManagement $db the database connector @param DbManagementObject $DbManagementObject the DbManagementObject containing all needed data to populate database @param String $query the query to populate database @throws DataBaseException error in connecting to the database @return id of the record
[ "add", "an", "Object", "to", "the", "table", "in", "the", "database" ]
1c137bb284712c2830e8cf792237adcc1d86d6f4
https://github.com/20centcroak/DBManagement/blob/1c137bb284712c2830e8cf792237adcc1d86d6f4/src/DbManagementTable.php#L23-L30
239,999
20centcroak/DBManagement
src/DbManagementTable.php
DbManagementTable.getData
public function getData(DbManagement $db, $query, $params, DbManagementObject $DbManagementObject) { $keys = $DbManagementObject->getKeys(); //parse params to check their validity and //use the conventions to sort and filter results $parsed = $this->parseParams($params, $keys, $DbManagementObject->getTypes()); $array=[]; //if valid params have been detected //query is filled in with arguments if(isset($parsed)){ foreach ($parsed as $type => $values) { switch($type){ case "min": foreach ($values as $key => $val) { $min = $keys[$key]."-min"; $db->sortMin($query,$keys[$key],$min); $array[]=$val; } break; case "max": foreach ($values as $key => $val) { $max = $keys[$key]."-max"; $db->sortMax($query,$keys[$key],$max); $array[]=$val; } break; case "up": foreach ($values as $val) { $db->orderUp($query,$keys[$val]); } break; case "down": foreach ($values as $val) { $db->orderDown($query,$keys[$val]); } break; case "equals": foreach ($values as $key => $val) { $db->sort($query,$keys[$key], $keys[$key]); $array[]=$val; } break; } } } //close query $db->closeQuery($query); $answer = $db->query($query, $array); $args=[]; while ($row = $answer->fetch(\PDO::FETCH_ASSOC)) { foreach ($keys as $key => $val) { $argsDbManagementObject[$val]=$row[$val]; } $args[] = $argsDbManagementObject; } return $args; }
php
public function getData(DbManagement $db, $query, $params, DbManagementObject $DbManagementObject) { $keys = $DbManagementObject->getKeys(); //parse params to check their validity and //use the conventions to sort and filter results $parsed = $this->parseParams($params, $keys, $DbManagementObject->getTypes()); $array=[]; //if valid params have been detected //query is filled in with arguments if(isset($parsed)){ foreach ($parsed as $type => $values) { switch($type){ case "min": foreach ($values as $key => $val) { $min = $keys[$key]."-min"; $db->sortMin($query,$keys[$key],$min); $array[]=$val; } break; case "max": foreach ($values as $key => $val) { $max = $keys[$key]."-max"; $db->sortMax($query,$keys[$key],$max); $array[]=$val; } break; case "up": foreach ($values as $val) { $db->orderUp($query,$keys[$val]); } break; case "down": foreach ($values as $val) { $db->orderDown($query,$keys[$val]); } break; case "equals": foreach ($values as $key => $val) { $db->sort($query,$keys[$key], $keys[$key]); $array[]=$val; } break; } } } //close query $db->closeQuery($query); $answer = $db->query($query, $array); $args=[]; while ($row = $answer->fetch(\PDO::FETCH_ASSOC)) { foreach ($keys as $key => $val) { $argsDbManagementObject[$val]=$row[$val]; } $args[] = $argsDbManagementObject; } return $args; }
[ "public", "function", "getData", "(", "DbManagement", "$", "db", ",", "$", "query", ",", "$", "params", ",", "DbManagementObject", "$", "DbManagementObject", ")", "{", "$", "keys", "=", "$", "DbManagementObject", "->", "getKeys", "(", ")", ";", "//parse params to check their validity and ", "//use the conventions to sort and filter results", "$", "parsed", "=", "$", "this", "->", "parseParams", "(", "$", "params", ",", "$", "keys", ",", "$", "DbManagementObject", "->", "getTypes", "(", ")", ")", ";", "$", "array", "=", "[", "]", ";", "//if valid params have been detected", "//query is filled in with arguments", "if", "(", "isset", "(", "$", "parsed", ")", ")", "{", "foreach", "(", "$", "parsed", "as", "$", "type", "=>", "$", "values", ")", "{", "switch", "(", "$", "type", ")", "{", "case", "\"min\"", ":", "foreach", "(", "$", "values", "as", "$", "key", "=>", "$", "val", ")", "{", "$", "min", "=", "$", "keys", "[", "$", "key", "]", ".", "\"-min\"", ";", "$", "db", "->", "sortMin", "(", "$", "query", ",", "$", "keys", "[", "$", "key", "]", ",", "$", "min", ")", ";", "$", "array", "[", "]", "=", "$", "val", ";", "}", "break", ";", "case", "\"max\"", ":", "foreach", "(", "$", "values", "as", "$", "key", "=>", "$", "val", ")", "{", "$", "max", "=", "$", "keys", "[", "$", "key", "]", ".", "\"-max\"", ";", "$", "db", "->", "sortMax", "(", "$", "query", ",", "$", "keys", "[", "$", "key", "]", ",", "$", "max", ")", ";", "$", "array", "[", "]", "=", "$", "val", ";", "}", "break", ";", "case", "\"up\"", ":", "foreach", "(", "$", "values", "as", "$", "val", ")", "{", "$", "db", "->", "orderUp", "(", "$", "query", ",", "$", "keys", "[", "$", "val", "]", ")", ";", "}", "break", ";", "case", "\"down\"", ":", "foreach", "(", "$", "values", "as", "$", "val", ")", "{", "$", "db", "->", "orderDown", "(", "$", "query", ",", "$", "keys", "[", "$", "val", "]", ")", ";", "}", "break", ";", "case", "\"equals\"", ":", "foreach", "(", "$", "values", "as", "$", "key", "=>", "$", "val", ")", "{", "$", "db", "->", "sort", "(", "$", "query", ",", "$", "keys", "[", "$", "key", "]", ",", "$", "keys", "[", "$", "key", "]", ")", ";", "$", "array", "[", "]", "=", "$", "val", ";", "}", "break", ";", "}", "}", "}", "//close query", "$", "db", "->", "closeQuery", "(", "$", "query", ")", ";", "$", "answer", "=", "$", "db", "->", "query", "(", "$", "query", ",", "$", "array", ")", ";", "$", "args", "=", "[", "]", ";", "while", "(", "$", "row", "=", "$", "answer", "->", "fetch", "(", "\\", "PDO", "::", "FETCH_ASSOC", ")", ")", "{", "foreach", "(", "$", "keys", "as", "$", "key", "=>", "$", "val", ")", "{", "$", "argsDbManagementObject", "[", "$", "val", "]", "=", "$", "row", "[", "$", "val", "]", ";", "}", "$", "args", "[", "]", "=", "$", "argsDbManagementObject", ";", "}", "return", "$", "args", ";", "}" ]
get data from the table in the database according to the params and the expected DbManagementObject @param DbManagement $db the database connector @param String $query the query to select data in database @param array $params parameters for the query to indicate filters or sorting @param DbManagementObject $DbManagementObject the DbManagementObject for which data are expected @throws DataBaseException error in connecting to the database @return mixed array containing key/value pair defining a DbManagementObject
[ "get", "data", "from", "the", "table", "in", "the", "database", "according", "to", "the", "params", "and", "the", "expected", "DbManagementObject" ]
1c137bb284712c2830e8cf792237adcc1d86d6f4
https://github.com/20centcroak/DBManagement/blob/1c137bb284712c2830e8cf792237adcc1d86d6f4/src/DbManagementTable.php#L41-L104