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
partition
stringclasses
1 value
gliverphp/helpers
src/StringHelper/StringHelper.php
StringHelper.plural
public static function plural($string) { //assign the input string to a result variable $result = $string; //loop through the array of plural patterns, getting the regular exppression friendly pattern foreach (self::$plurals as $rule => $replacement) { //get the regular axpression friendlt pattern $result = $string; //check if there is a match for this pattern in the input string if ( preg_match($rule, $string) ) { //if match found, replace rule with the replacement string $result = preg_replace($rule, $replacement, $string); //break out of loop once match is found break; } } //return the new string contained in result return $result; }
php
public static function plural($string) { //assign the input string to a result variable $result = $string; //loop through the array of plural patterns, getting the regular exppression friendly pattern foreach (self::$plurals as $rule => $replacement) { //get the regular axpression friendlt pattern $result = $string; //check if there is a match for this pattern in the input string if ( preg_match($rule, $string) ) { //if match found, replace rule with the replacement string $result = preg_replace($rule, $replacement, $string); //break out of loop once match is found break; } } //return the new string contained in result return $result; }
[ "public", "static", "function", "plural", "(", "$", "string", ")", "{", "//assign the input string to a result variable", "$", "result", "=", "$", "string", ";", "//loop through the array of plural patterns, getting the regular exppression friendly pattern", "foreach", "(", "se...
This method gets the plural form of an input string @param string $string Input string for which to find plural @return string The output string after chaning to plural
[ "This", "method", "gets", "the", "plural", "form", "of", "an", "input", "string" ]
c5204df8169fad55f5b273422e45f56164373ab8
https://github.com/gliverphp/helpers/blob/c5204df8169fad55f5b273422e45f56164373ab8/src/StringHelper/StringHelper.php#L363-L390
train
kaecyra/app-common
src/ConfigCollection.php
ConfigCollection.addConfig
public function addConfig(ConfigInterface $config) { // Add to config list $this->configs->attach($config); // If collection is in merge mode, add config data to common store $this->store->merge($config->dump()); return $this; }
php
public function addConfig(ConfigInterface $config) { // Add to config list $this->configs->attach($config); // If collection is in merge mode, add config data to common store $this->store->merge($config->dump()); return $this; }
[ "public", "function", "addConfig", "(", "ConfigInterface", "$", "config", ")", "{", "// Add to config list", "$", "this", "->", "configs", "->", "attach", "(", "$", "config", ")", ";", "// If collection is in merge mode, add config data to common store", "$", "this", ...
Add a ConfigInterface object to collection @param \Kaecyra\AppCommon\ConfigInterface $config @return ConfigCollection
[ "Add", "a", "ConfigInterface", "object", "to", "collection" ]
8dbcf70c575fb587614b45da8ec02d098e3e843b
https://github.com/kaecyra/app-common/blob/8dbcf70c575fb587614b45da8ec02d098e3e843b/src/ConfigCollection.php#L38-L45
train
kaecyra/app-common
src/ConfigCollection.php
ConfigCollection.removeConfig
public function removeConfig(ConfigInterface $config) { // If collection is in merge mode, don't permit removing configs (cannot unmerge) if ($this->merge) { throw new Exception("Cannot remove configs from merged collection."); } $this->configs->detach($config); return $this; }
php
public function removeConfig(ConfigInterface $config) { // If collection is in merge mode, don't permit removing configs (cannot unmerge) if ($this->merge) { throw new Exception("Cannot remove configs from merged collection."); } $this->configs->detach($config); return $this; }
[ "public", "function", "removeConfig", "(", "ConfigInterface", "$", "config", ")", "{", "// If collection is in merge mode, don't permit removing configs (cannot unmerge)", "if", "(", "$", "this", "->", "merge", ")", "{", "throw", "new", "Exception", "(", "\"Cannot remove ...
Remove ConfigInterface object from collection @param \Kaecyra\AppCommon\ConfigInterface $config @return ConfigCollection
[ "Remove", "ConfigInterface", "object", "from", "collection" ]
8dbcf70c575fb587614b45da8ec02d098e3e843b
https://github.com/kaecyra/app-common/blob/8dbcf70c575fb587614b45da8ec02d098e3e843b/src/ConfigCollection.php#L53-L63
train
kaecyra/app-common
src/ConfigCollection.php
ConfigCollection.addFile
public function addFile($file, $writeable = false): ConfigCollection { $config = FileConfig::load($file, $writeable); if ($config) { $this->addConfig($config); } return $this; }
php
public function addFile($file, $writeable = false): ConfigCollection { $config = FileConfig::load($file, $writeable); if ($config) { $this->addConfig($config); } return $this; }
[ "public", "function", "addFile", "(", "$", "file", ",", "$", "writeable", "=", "false", ")", ":", "ConfigCollection", "{", "$", "config", "=", "FileConfig", "::", "load", "(", "$", "file", ",", "$", "writeable", ")", ";", "if", "(", "$", "config", ")...
Add a physical config file @param string $file @param bool $writeable @return ConfigCollection
[ "Add", "a", "physical", "config", "file" ]
8dbcf70c575fb587614b45da8ec02d098e3e843b
https://github.com/kaecyra/app-common/blob/8dbcf70c575fb587614b45da8ec02d098e3e843b/src/ConfigCollection.php#L72-L78
train
kaecyra/app-common
src/ConfigCollection.php
ConfigCollection.addVirtual
public function addVirtual($data): ConfigCollection { $config = VirtualConfig::load($data); if ($config) { $this->addConfig($config); } return $this; }
php
public function addVirtual($data): ConfigCollection { $config = VirtualConfig::load($data); if ($config) { $this->addConfig($config); } return $this; }
[ "public", "function", "addVirtual", "(", "$", "data", ")", ":", "ConfigCollection", "{", "$", "config", "=", "VirtualConfig", "::", "load", "(", "$", "data", ")", ";", "if", "(", "$", "config", ")", "{", "$", "this", "->", "addConfig", "(", "$", "con...
Add a virtual config @param string|array $data @return ConfigCollection
[ "Add", "a", "virtual", "config" ]
8dbcf70c575fb587614b45da8ec02d098e3e843b
https://github.com/kaecyra/app-common/blob/8dbcf70c575fb587614b45da8ec02d098e3e843b/src/ConfigCollection.php#L86-L92
train
kaecyra/app-common
src/ConfigCollection.php
ConfigCollection.addFolder
public function addFolder($folder, $extension): ConfigCollection { $extLen = strlen($extension); $files = scandir($folder, SCANDIR_SORT_ASCENDING); foreach ($files as $file) { if (in_array($file, ['.','..'])) { continue; } if (substr($file, -$extLen) != $extension) { continue; } $config = FileConfig::load(paths($folder, $file), false); if ($config) { $this->addConfig($config); } } return $this; }
php
public function addFolder($folder, $extension): ConfigCollection { $extLen = strlen($extension); $files = scandir($folder, SCANDIR_SORT_ASCENDING); foreach ($files as $file) { if (in_array($file, ['.','..'])) { continue; } if (substr($file, -$extLen) != $extension) { continue; } $config = FileConfig::load(paths($folder, $file), false); if ($config) { $this->addConfig($config); } } return $this; }
[ "public", "function", "addFolder", "(", "$", "folder", ",", "$", "extension", ")", ":", "ConfigCollection", "{", "$", "extLen", "=", "strlen", "(", "$", "extension", ")", ";", "$", "files", "=", "scandir", "(", "$", "folder", ",", "SCANDIR_SORT_ASCENDING",...
Add a folder of config files @param string $folder @param string $extension @return ConfigCollection
[ "Add", "a", "folder", "of", "config", "files" ]
8dbcf70c575fb587614b45da8ec02d098e3e843b
https://github.com/kaecyra/app-common/blob/8dbcf70c575fb587614b45da8ec02d098e3e843b/src/ConfigCollection.php#L101-L117
train
arvici/framework
src/Arvici/Heart/Cache/Cache.php
Cache.getPool
public function getPool ($name = 'default') { if (isset($this->pools[$name])) { return $this->pools[$name]; } throw new NotFoundException('Caching Pool not found with given name \''.$name.'\''); }
php
public function getPool ($name = 'default') { if (isset($this->pools[$name])) { return $this->pools[$name]; } throw new NotFoundException('Caching Pool not found with given name \''.$name.'\''); }
[ "public", "function", "getPool", "(", "$", "name", "=", "'default'", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "pools", "[", "$", "name", "]", ")", ")", "{", "return", "$", "this", "->", "pools", "[", "$", "name", "]", ";", "}", "th...
Get pool instance. @param string $name @return Pool @throws NotFoundException
[ "Get", "pool", "instance", "." ]
4d0933912fef8f9edc756ef1ace009e96d9fc4b1
https://github.com/arvici/framework/blob/4d0933912fef8f9edc756ef1ace009e96d9fc4b1/src/Arvici/Heart/Cache/Cache.php#L70-L76
train
arvici/framework
src/Arvici/Heart/Cache/Cache.php
Cache.initiatePools
protected function initiatePools () { foreach ($this->configuration['pools'] as $name => $poolConfiguration) { // Try to get the driver class. Will throw an exception if not exists. new \ReflectionClass($poolConfiguration['driver']); $options = $poolConfiguration['options']; /** @var DriverInterface $driverInstance */ $driverInstance = new $poolConfiguration['driver']($options); $poolInstance = new Pool($driverInstance, $name); // Register in the local instance holding variable. $this->pools[$name] = $poolInstance; } }
php
protected function initiatePools () { foreach ($this->configuration['pools'] as $name => $poolConfiguration) { // Try to get the driver class. Will throw an exception if not exists. new \ReflectionClass($poolConfiguration['driver']); $options = $poolConfiguration['options']; /** @var DriverInterface $driverInstance */ $driverInstance = new $poolConfiguration['driver']($options); $poolInstance = new Pool($driverInstance, $name); // Register in the local instance holding variable. $this->pools[$name] = $poolInstance; } }
[ "protected", "function", "initiatePools", "(", ")", "{", "foreach", "(", "$", "this", "->", "configuration", "[", "'pools'", "]", "as", "$", "name", "=>", "$", "poolConfiguration", ")", "{", "// Try to get the driver class. Will throw an exception if not exists.", "ne...
Initiate Pools.
[ "Initiate", "Pools", "." ]
4d0933912fef8f9edc756ef1ace009e96d9fc4b1
https://github.com/arvici/framework/blob/4d0933912fef8f9edc756ef1ace009e96d9fc4b1/src/Arvici/Heart/Cache/Cache.php#L92-L108
train
Bulveyz/Bulveyz
src/Bulveyz/Middleware/Middleware.php
Middleware.fatalAccess
public static function fatalAccess(string $userGroup, string $error) { if (!isset($_SESSION[$userGroup])) { exit($error); } }
php
public static function fatalAccess(string $userGroup, string $error) { if (!isset($_SESSION[$userGroup])) { exit($error); } }
[ "public", "static", "function", "fatalAccess", "(", "string", "$", "userGroup", ",", "string", "$", "error", ")", "{", "if", "(", "!", "isset", "(", "$", "_SESSION", "[", "$", "userGroup", "]", ")", ")", "{", "exit", "(", "$", "error", ")", ";", "}...
Return Fatal Error
[ "Return", "Fatal", "Error" ]
62fffe8ffe1b2b02844e4ed0c49b8f181ae21e15
https://github.com/Bulveyz/Bulveyz/blob/62fffe8ffe1b2b02844e4ed0c49b8f181ae21e15/src/Bulveyz/Middleware/Middleware.php#L22-L27
train
Bulveyz/Bulveyz
src/Bulveyz/Middleware/Middleware.php
Middleware.fatalElseAccess
public static function fatalElseAccess(string $userGroup, string $error) { if (isset($_SESSION[$userGroup])) { exit($error); } }
php
public static function fatalElseAccess(string $userGroup, string $error) { if (isset($_SESSION[$userGroup])) { exit($error); } }
[ "public", "static", "function", "fatalElseAccess", "(", "string", "$", "userGroup", ",", "string", "$", "error", ")", "{", "if", "(", "isset", "(", "$", "_SESSION", "[", "$", "userGroup", "]", ")", ")", "{", "exit", "(", "$", "error", ")", ";", "}", ...
Return Fatal Error for one users group
[ "Return", "Fatal", "Error", "for", "one", "users", "group" ]
62fffe8ffe1b2b02844e4ed0c49b8f181ae21e15
https://github.com/Bulveyz/Bulveyz/blob/62fffe8ffe1b2b02844e4ed0c49b8f181ae21e15/src/Bulveyz/Middleware/Middleware.php#L38-L43
train
PandaPlatform/helpers
ArrayHelper.php
ArrayHelper.set
public static function set($array, $key, $value = null, $useDotSyntax = false) { // Normalize array $array = $array ?: []; // Check if key is empty if (StringHelper::emptyString($key, true)) { throw new InvalidArgumentException(__METHOD__ . ': Key cannot be empty'); } /** * Split name using dots. * * Just checking whether the key doesn't have any dots * but $useDotSyntax is true by default. */ $keyParts = explode('.', $key); $useDotSyntax = $useDotSyntax && count($keyParts) > 1; // Set simple value, without dot syntax if (!$useDotSyntax) { if (is_null($value) && isset($array[$key])) { unset($array[$key]); } elseif (!is_null($value)) { $array[$key] = $value; } } else { // Recursive call $base = $keyParts[0]; unset($keyParts[0]); // Check if the base array exists if (!isset($array[$base])) { $array[$base] = []; } // Get key, base array and continue $key = implode('.', $keyParts); $innerArray = $array[$base]; $array[$base] = static::set($innerArray, $key, $value, $useDotSyntax); } return $array; }
php
public static function set($array, $key, $value = null, $useDotSyntax = false) { // Normalize array $array = $array ?: []; // Check if key is empty if (StringHelper::emptyString($key, true)) { throw new InvalidArgumentException(__METHOD__ . ': Key cannot be empty'); } /** * Split name using dots. * * Just checking whether the key doesn't have any dots * but $useDotSyntax is true by default. */ $keyParts = explode('.', $key); $useDotSyntax = $useDotSyntax && count($keyParts) > 1; // Set simple value, without dot syntax if (!$useDotSyntax) { if (is_null($value) && isset($array[$key])) { unset($array[$key]); } elseif (!is_null($value)) { $array[$key] = $value; } } else { // Recursive call $base = $keyParts[0]; unset($keyParts[0]); // Check if the base array exists if (!isset($array[$base])) { $array[$base] = []; } // Get key, base array and continue $key = implode('.', $keyParts); $innerArray = $array[$base]; $array[$base] = static::set($innerArray, $key, $value, $useDotSyntax); } return $array; }
[ "public", "static", "function", "set", "(", "$", "array", ",", "$", "key", ",", "$", "value", "=", "null", ",", "$", "useDotSyntax", "=", "false", ")", "{", "// Normalize array", "$", "array", "=", "$", "array", "?", ":", "[", "]", ";", "// Check if ...
Set an item in the given array. @param array $array @param string $key @param mixed $value @param bool $useDotSyntax @return array @throws InvalidArgumentException
[ "Set", "an", "item", "in", "the", "given", "array", "." ]
a319d861d5e34e24a68a8e6db0c14cba888bc8a2
https://github.com/PandaPlatform/helpers/blob/a319d861d5e34e24a68a8e6db0c14cba888bc8a2/ArrayHelper.php#L87-L131
train
EmanueleMinotto/Gravatar
Client.php
Client.getProfile
public function getProfile($email) { $url = $this->getProfileUrl($email); $httpClient = &$this->httpClient; $response = $httpClient->get($url); $data = $response->json(); return $data['entry'][0]; }
php
public function getProfile($email) { $url = $this->getProfileUrl($email); $httpClient = &$this->httpClient; $response = $httpClient->get($url); $data = $response->json(); return $data['entry'][0]; }
[ "public", "function", "getProfile", "(", "$", "email", ")", "{", "$", "url", "=", "$", "this", "->", "getProfileUrl", "(", "$", "email", ")", ";", "$", "httpClient", "=", "&", "$", "this", "->", "httpClient", ";", "$", "response", "=", "$", "httpClie...
Get user profile data. @param string $email User email. @return array
[ "Get", "user", "profile", "data", "." ]
661da058c2348a605393653a72543b7b384ca903
https://github.com/EmanueleMinotto/Gravatar/blob/661da058c2348a605393653a72543b7b384ca903/Client.php#L89-L99
train
EmanueleMinotto/Gravatar
Client.php
Client.getAvatarUrl
public function getAvatarUrl($email, $size = 80, $extension = 'jpg', $default = 404, $rating = 'g') { $url = 'https://www.gravatar.com/avatar/'; $url .= md5(strtolower(trim($email))).'.'.$extension; $url .= '?'.http_build_query([ 'd' => $default, 'r' => $rating, 's' => $size, ]); return $url; }
php
public function getAvatarUrl($email, $size = 80, $extension = 'jpg', $default = 404, $rating = 'g') { $url = 'https://www.gravatar.com/avatar/'; $url .= md5(strtolower(trim($email))).'.'.$extension; $url .= '?'.http_build_query([ 'd' => $default, 'r' => $rating, 's' => $size, ]); return $url; }
[ "public", "function", "getAvatarUrl", "(", "$", "email", ",", "$", "size", "=", "80", ",", "$", "extension", "=", "'jpg'", ",", "$", "default", "=", "404", ",", "$", "rating", "=", "'g'", ")", "{", "$", "url", "=", "'https://www.gravatar.com/avatar/'", ...
Get user avatar image URL. @param string $email User email. @param int $size Image size (default 80). @param string $extension Image extension (default jpg). @param int $default Error response (default 404). @param string $rating Image rating (default G). @return string
[ "Get", "user", "avatar", "image", "URL", "." ]
661da058c2348a605393653a72543b7b384ca903
https://github.com/EmanueleMinotto/Gravatar/blob/661da058c2348a605393653a72543b7b384ca903/Client.php#L112-L125
train
Opifer/Revisions
src/Opifer/Revisions/Mapping/AnnotationReader.php
AnnotationReader.get
public function get($entity, $annotation) { $properties = $this->getProperties($entity); $return = array(); foreach ($properties as $reflectionProperty) { $propertyAnnotation = $this->reader->getPropertyAnnotation($reflectionProperty, $annotation); if (!is_null($propertyAnnotation) && get_class($propertyAnnotation) == $annotation) { $return[$reflectionProperty->name] = $reflectionProperty; } } return $return; }
php
public function get($entity, $annotation) { $properties = $this->getProperties($entity); $return = array(); foreach ($properties as $reflectionProperty) { $propertyAnnotation = $this->reader->getPropertyAnnotation($reflectionProperty, $annotation); if (!is_null($propertyAnnotation) && get_class($propertyAnnotation) == $annotation) { $return[$reflectionProperty->name] = $reflectionProperty; } } return $return; }
[ "public", "function", "get", "(", "$", "entity", ",", "$", "annotation", ")", "{", "$", "properties", "=", "$", "this", "->", "getProperties", "(", "$", "entity", ")", ";", "$", "return", "=", "array", "(", ")", ";", "foreach", "(", "$", "properties"...
Get annotations by entity and annotation @param Object $entity @param string $annotation @return array
[ "Get", "annotations", "by", "entity", "and", "annotation" ]
da1f15a9abcc083c9db7f8459f1af661937454ea
https://github.com/Opifer/Revisions/blob/da1f15a9abcc083c9db7f8459f1af661937454ea/src/Opifer/Revisions/Mapping/AnnotationReader.php#L32-L45
train
Opifer/Revisions
src/Opifer/Revisions/Mapping/AnnotationReader.php
AnnotationReader.all
public function all($entity) { $reflectionClass = new \ReflectionClass($entity); $properties = $reflectionClass->getProperties(); $class = new \ReflectionClass($entity); while ($parent = $class->getParentClass()) { $parentProperties = $parent->getProperties(); $properties = array_merge($parentProperties, $properties); $class = $parent; } $return = array(); foreach ($properties as $reflectionProperty) { $propertyAnnotation = $this->reader->getPropertyAnnotation($reflectionProperty, $this->annotationClass); if (!is_null($propertyAnnotation) && $propertyAnnotation->listable) { $return[] = array( 'property' => $reflectionProperty->name, 'type' => $propertyAnnotation->type ); } } return $return; }
php
public function all($entity) { $reflectionClass = new \ReflectionClass($entity); $properties = $reflectionClass->getProperties(); $class = new \ReflectionClass($entity); while ($parent = $class->getParentClass()) { $parentProperties = $parent->getProperties(); $properties = array_merge($parentProperties, $properties); $class = $parent; } $return = array(); foreach ($properties as $reflectionProperty) { $propertyAnnotation = $this->reader->getPropertyAnnotation($reflectionProperty, $this->annotationClass); if (!is_null($propertyAnnotation) && $propertyAnnotation->listable) { $return[] = array( 'property' => $reflectionProperty->name, 'type' => $propertyAnnotation->type ); } } return $return; }
[ "public", "function", "all", "(", "$", "entity", ")", "{", "$", "reflectionClass", "=", "new", "\\", "ReflectionClass", "(", "$", "entity", ")", ";", "$", "properties", "=", "$", "reflectionClass", "->", "getProperties", "(", ")", ";", "$", "class", "=",...
Gets all annotations @param [type] $entity [description] @return [type] [description]
[ "Gets", "all", "annotations" ]
da1f15a9abcc083c9db7f8459f1af661937454ea
https://github.com/Opifer/Revisions/blob/da1f15a9abcc083c9db7f8459f1af661937454ea/src/Opifer/Revisions/Mapping/AnnotationReader.php#L131-L156
train
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...
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
train
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'", ",", ...
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
train
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", ")", ")", "{", "...
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
train
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", "(", ")", ...
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
train
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", "[...
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
train
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", ...
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
train
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", ",", "$", "_...
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
train
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", "!=", "...
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
train
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", "[", "$...
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
train
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", "(", ")", ")", ";", "/...
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
train
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...
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
train
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", ")", ")", "{", "$", "condi...
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
train
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", ",", "...
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
train
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", ",", ...
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
train
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", ",", "$...
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
train
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", "\\...
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
train
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", ")", "{", "ret...
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
train
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", "(", "$"...
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
train
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", "(", "$"...
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
train
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", "\\", "InvalidArgumentExce...
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
train
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__", ")", "...
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
train
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",...
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
train
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", "(", "$", "optClas...
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
train
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", "["...
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
train
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 no...
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
train
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", ...
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
train
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
train
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", "(", "$", "respo...
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
train
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'", "]", ")", ")", "{", "$...
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
train
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", "(", "$", ...
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
train
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", ...
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
train
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", "(", ...
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
train
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", "(", ...
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
train
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'", ")", ";", "$", "...
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
train
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'",...
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
train
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.conf...
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
train
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", "[", "$", "k...
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
train
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!", ...
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
train
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", ",", "''...
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
train
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", ")", ";", "ses...
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
train
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", "(", "i...
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
train
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", ...
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
train
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...
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
train
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();",...
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
train
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", ";", "//update...
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
train
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
train
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"...
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
train
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", ...
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
train
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", "...
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
train
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", "=", "...
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
train
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"...
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
train
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", "(", "!",...
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
train
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", "...
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
train
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", "(", ")", ...
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
train
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", ")", ",...
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
train
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'", "=>", "$",...
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
train
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...
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
train
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", ",...
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
train
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", "=", "'...
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
train
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", "(", ...
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
train
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\"", "]", ...
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
train
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", "[", "$", "ke...
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
train
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....
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
train
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", "$", "t...
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
train
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", "(", "$", "...
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
train
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'"...
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
train
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. Funct...
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
train
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", ...
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
train
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", "...
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
train
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", "=", "...
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
train
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", "(", "'...
Protected Custom Request
[ "Protected", "Custom", "Request" ]
d603667191e2e386cbc2119836c5bed9e3ade141
https://github.com/znframework/package-services/blob/d603667191e2e386cbc2119836c5bed9e3ade141/Restful.php#L288-L298
train
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", ...
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
train
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'",...
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
train
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/use...
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
train
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", "(", ...
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
train
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",...
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
train
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", ")", ";", "i...
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
train
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", "(", "$", "d...
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
train
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"...
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
train
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", "{", "...
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
train
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",...
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
train
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", "=", "$", "fileSy...
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
train
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...
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
train
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...
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
train
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", ...
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
train