id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
list | docstring
stringlengths 3
47.2k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 91
247
|
|---|---|---|---|---|---|---|---|---|---|---|---|
26,000
|
SagittariusX/Beluga.Translation
|
src/Beluga/Translation/Locale.php
|
Locale.TryParseArray
|
public static function TryParseArray(
&$refLocale, array $requestData, array $acceptedKeys = [ 'locale', 'language', 'lang', 'loc', 'lc', 'lng' ] )
: bool
{
if ( \count( $requestData ) < 1 )
{
return false;
}
$requestData = \array_change_key_case( $requestData , \CASE_LOWER );
$acceptedKeys = \array_change_key_case( $acceptedKeys, \CASE_LOWER );
$language = null;
foreach ( $acceptedKeys as $key )
{
if ( ! isset( $requestData[ $key ] ) )
{
continue;
}
$language = \trim( $requestData[ 'language' ] );
break;
}
if ( empty( $language ) ) { return false; }
if ( ! \preg_match( '~^([a-zA-Z]{2})([_-]([a-zA-Z]{2}))?~', $language, $matches ) )
{
return false;
}
// Getting the LID + CID
$lid = \strtolower( $matches[ 1 ] );
$cid = empty( $matches[ 2 ] )
? null
: \strtoupper( $matches[ 3 ] );
// Everything is OK. Init the new instance and return TRUE
$refLocale = new Locale( $lid, $cid );
return true;
}
|
php
|
public static function TryParseArray(
&$refLocale, array $requestData, array $acceptedKeys = [ 'locale', 'language', 'lang', 'loc', 'lc', 'lng' ] )
: bool
{
if ( \count( $requestData ) < 1 )
{
return false;
}
$requestData = \array_change_key_case( $requestData , \CASE_LOWER );
$acceptedKeys = \array_change_key_case( $acceptedKeys, \CASE_LOWER );
$language = null;
foreach ( $acceptedKeys as $key )
{
if ( ! isset( $requestData[ $key ] ) )
{
continue;
}
$language = \trim( $requestData[ 'language' ] );
break;
}
if ( empty( $language ) ) { return false; }
if ( ! \preg_match( '~^([a-zA-Z]{2})([_-]([a-zA-Z]{2}))?~', $language, $matches ) )
{
return false;
}
// Getting the LID + CID
$lid = \strtolower( $matches[ 1 ] );
$cid = empty( $matches[ 2 ] )
? null
: \strtoupper( $matches[ 3 ] );
// Everything is OK. Init the new instance and return TRUE
$refLocale = new Locale( $lid, $cid );
return true;
}
|
[
"public",
"static",
"function",
"TryParseArray",
"(",
"&",
"$",
"refLocale",
",",
"array",
"$",
"requestData",
",",
"array",
"$",
"acceptedKeys",
"=",
"[",
"'locale'",
",",
"'language'",
",",
"'lang'",
",",
"'loc'",
",",
"'lc'",
",",
"'lng'",
"]",
")",
":",
"bool",
"{",
"if",
"(",
"\\",
"count",
"(",
"$",
"requestData",
")",
"<",
"1",
")",
"{",
"return",
"false",
";",
"}",
"$",
"requestData",
"=",
"\\",
"array_change_key_case",
"(",
"$",
"requestData",
",",
"\\",
"CASE_LOWER",
")",
";",
"$",
"acceptedKeys",
"=",
"\\",
"array_change_key_case",
"(",
"$",
"acceptedKeys",
",",
"\\",
"CASE_LOWER",
")",
";",
"$",
"language",
"=",
"null",
";",
"foreach",
"(",
"$",
"acceptedKeys",
"as",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"requestData",
"[",
"$",
"key",
"]",
")",
")",
"{",
"continue",
";",
"}",
"$",
"language",
"=",
"\\",
"trim",
"(",
"$",
"requestData",
"[",
"'language'",
"]",
")",
";",
"break",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"language",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"\\",
"preg_match",
"(",
"'~^([a-zA-Z]{2})([_-]([a-zA-Z]{2}))?~'",
",",
"$",
"language",
",",
"$",
"matches",
")",
")",
"{",
"return",
"false",
";",
"}",
"// Getting the LID + CID",
"$",
"lid",
"=",
"\\",
"strtolower",
"(",
"$",
"matches",
"[",
"1",
"]",
")",
";",
"$",
"cid",
"=",
"empty",
"(",
"$",
"matches",
"[",
"2",
"]",
")",
"?",
"null",
":",
"\\",
"strtoupper",
"(",
"$",
"matches",
"[",
"3",
"]",
")",
";",
"// Everything is OK. Init the new instance and return TRUE",
"$",
"refLocale",
"=",
"new",
"Locale",
"(",
"$",
"lid",
",",
"$",
"cid",
")",
";",
"return",
"true",
";",
"}"
] |
Tries to create a new Locale instance from defined array. It accepts one of the following array keys
to declare an
@param \Beluga\Translation\Locale $refLocale Returns the Locale instance if the method return TRUE.
@param array $requestData The array with the data that should be used for getting local info from.
@return bool
|
[
"Tries",
"to",
"create",
"a",
"new",
"Locale",
"instance",
"from",
"defined",
"array",
".",
"It",
"accepts",
"one",
"of",
"the",
"following",
"array",
"keys",
"to",
"declare",
"an"
] |
8f66c4fef6fa4494413972ca56bd8e13f5a7e444
|
https://github.com/SagittariusX/Beluga.Translation/blob/8f66c4fef6fa4494413972ca56bd8e13f5a7e444/src/Beluga/Translation/Locale.php#L389-L431
|
26,001
|
itkg/core
|
src/Itkg/Core/Cache/Adapter/Chain/UseFirstWorkingStrategy.php
|
UseFirstWorkingStrategy.get
|
public function get(array $adapters, CacheableInterface $item)
{
foreach ($adapters as $adapter) {
try {
return $adapter->get($item);
} catch (\Exception $e) {
continue;
}
}
throw new UnhandledCacheException('No cache system is available');
}
|
php
|
public function get(array $adapters, CacheableInterface $item)
{
foreach ($adapters as $adapter) {
try {
return $adapter->get($item);
} catch (\Exception $e) {
continue;
}
}
throw new UnhandledCacheException('No cache system is available');
}
|
[
"public",
"function",
"get",
"(",
"array",
"$",
"adapters",
",",
"CacheableInterface",
"$",
"item",
")",
"{",
"foreach",
"(",
"$",
"adapters",
"as",
"$",
"adapter",
")",
"{",
"try",
"{",
"return",
"$",
"adapter",
"->",
"get",
"(",
"$",
"item",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"continue",
";",
"}",
"}",
"throw",
"new",
"UnhandledCacheException",
"(",
"'No cache system is available'",
")",
";",
"}"
] |
Get cache from first up adapter
@param array $adapters
@param CacheableInterface $item
@throws UnhandledCacheException
@return mixed
|
[
"Get",
"cache",
"from",
"first",
"up",
"adapter"
] |
e5e4efb05feb4d23b0df41f2b21fd095103e593b
|
https://github.com/itkg/core/blob/e5e4efb05feb4d23b0df41f2b21fd095103e593b/src/Itkg/Core/Cache/Adapter/Chain/UseFirstWorkingStrategy.php#L38-L49
|
26,002
|
itkg/core
|
src/Itkg/Core/Cache/Adapter/Chain/UseFirstWorkingStrategy.php
|
UseFirstWorkingStrategy.remove
|
public function remove(array $adapters, CacheableInterface $item)
{
foreach ($adapters as $adapter) {
$adapter->remove($item);
}
}
|
php
|
public function remove(array $adapters, CacheableInterface $item)
{
foreach ($adapters as $adapter) {
$adapter->remove($item);
}
}
|
[
"public",
"function",
"remove",
"(",
"array",
"$",
"adapters",
",",
"CacheableInterface",
"$",
"item",
")",
"{",
"foreach",
"(",
"$",
"adapters",
"as",
"$",
"adapter",
")",
"{",
"$",
"adapter",
"->",
"remove",
"(",
"$",
"item",
")",
";",
"}",
"}"
] |
Remove cache from all adapters
@param array $adapters
@param CacheableInterface $item
@return void
|
[
"Remove",
"cache",
"from",
"all",
"adapters"
] |
e5e4efb05feb4d23b0df41f2b21fd095103e593b
|
https://github.com/itkg/core/blob/e5e4efb05feb4d23b0df41f2b21fd095103e593b/src/Itkg/Core/Cache/Adapter/Chain/UseFirstWorkingStrategy.php#L80-L85
|
26,003
|
congraphcms/core
|
Repositories/RelationLoader.php
|
RelationLoader.queueUnresolvedObjects
|
public function queueUnresolvedObjects($data, $relations)
{
if( is_object($data) )
{
if( $data instanceof Model )
{
$data = $data->getData();
}
if( !$this->resolved($data) )
{
$this->addToQueue($data, $relations);
return;
}
$data = get_object_vars($data);
}
if( is_array($data) )
{
foreach ($data as $key => $value)
{
if(is_int($key))
{
$this->queueUnresolvedObjects($value, $relations);
}
if($this->hasRelation($key, $relations))
{
$nestedRelations = $this->getNestedRelations($key, $relations);
$this->queueUnresolvedObjects($value, $nestedRelations);
}
}
}
}
|
php
|
public function queueUnresolvedObjects($data, $relations)
{
if( is_object($data) )
{
if( $data instanceof Model )
{
$data = $data->getData();
}
if( !$this->resolved($data) )
{
$this->addToQueue($data, $relations);
return;
}
$data = get_object_vars($data);
}
if( is_array($data) )
{
foreach ($data as $key => $value)
{
if(is_int($key))
{
$this->queueUnresolvedObjects($value, $relations);
}
if($this->hasRelation($key, $relations))
{
$nestedRelations = $this->getNestedRelations($key, $relations);
$this->queueUnresolvedObjects($value, $nestedRelations);
}
}
}
}
|
[
"public",
"function",
"queueUnresolvedObjects",
"(",
"$",
"data",
",",
"$",
"relations",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"data",
")",
")",
"{",
"if",
"(",
"$",
"data",
"instanceof",
"Model",
")",
"{",
"$",
"data",
"=",
"$",
"data",
"->",
"getData",
"(",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"resolved",
"(",
"$",
"data",
")",
")",
"{",
"$",
"this",
"->",
"addToQueue",
"(",
"$",
"data",
",",
"$",
"relations",
")",
";",
"return",
";",
"}",
"$",
"data",
"=",
"get_object_vars",
"(",
"$",
"data",
")",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"data",
")",
")",
"{",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"is_int",
"(",
"$",
"key",
")",
")",
"{",
"$",
"this",
"->",
"queueUnresolvedObjects",
"(",
"$",
"value",
",",
"$",
"relations",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"hasRelation",
"(",
"$",
"key",
",",
"$",
"relations",
")",
")",
"{",
"$",
"nestedRelations",
"=",
"$",
"this",
"->",
"getNestedRelations",
"(",
"$",
"key",
",",
"$",
"relations",
")",
";",
"$",
"this",
"->",
"queueUnresolvedObjects",
"(",
"$",
"value",
",",
"$",
"nestedRelations",
")",
";",
"}",
"}",
"}",
"}"
] |
Add unresovled objects to load queue
@param mixed $data data to be parsed
@param array | integer $relations relations to be loaded
@return void
|
[
"Add",
"unresovled",
"objects",
"to",
"load",
"queue"
] |
d017d3951b446fb2ac93b8fcee120549bb125b17
|
https://github.com/congraphcms/core/blob/d017d3951b446fb2ac93b8fcee120549bb125b17/Repositories/RelationLoader.php#L92-L127
|
26,004
|
congraphcms/core
|
Repositories/RelationLoader.php
|
RelationLoader.resolved
|
protected function resolved($obj)
{
if( ! is_object($obj) )
{
return true;
}
$data = get_object_vars($obj);
if( count($data) == 2
&& array_key_exists('id', $data)
&& array_key_exists('type', $data)
)
{
return false;
}
return true;
}
|
php
|
protected function resolved($obj)
{
if( ! is_object($obj) )
{
return true;
}
$data = get_object_vars($obj);
if( count($data) == 2
&& array_key_exists('id', $data)
&& array_key_exists('type', $data)
)
{
return false;
}
return true;
}
|
[
"protected",
"function",
"resolved",
"(",
"$",
"obj",
")",
"{",
"if",
"(",
"!",
"is_object",
"(",
"$",
"obj",
")",
")",
"{",
"return",
"true",
";",
"}",
"$",
"data",
"=",
"get_object_vars",
"(",
"$",
"obj",
")",
";",
"if",
"(",
"count",
"(",
"$",
"data",
")",
"==",
"2",
"&&",
"array_key_exists",
"(",
"'id'",
",",
"$",
"data",
")",
"&&",
"array_key_exists",
"(",
"'type'",
",",
"$",
"data",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Check if object is resolved
@param stdClass $obj object to check
@return boolean
|
[
"Check",
"if",
"object",
"is",
"resolved"
] |
d017d3951b446fb2ac93b8fcee120549bb125b17
|
https://github.com/congraphcms/core/blob/d017d3951b446fb2ac93b8fcee120549bb125b17/Repositories/RelationLoader.php#L136-L153
|
26,005
|
congraphcms/core
|
Repositories/RelationLoader.php
|
RelationLoader.addToQueue
|
protected function addToQueue($object, $relations)
{
if( ! array_key_exists($object->type, self::$loadQueue) )
{
self::$loadQueue[$object->type] = [];
}
$relationsKey = base64_encode(json_encode($relations));
if( ! array_key_exists($relationsKey, self::$loadQueue[$object->type]) )
{
self::$loadQueue[$object->type][$relationsKey] = [ 'type' => $object->type, 'ids' => [], 'relations' => $relations ];
}
self::$loadQueue[$object->type][$relationsKey]['ids'][] = $object->id;
}
|
php
|
protected function addToQueue($object, $relations)
{
if( ! array_key_exists($object->type, self::$loadQueue) )
{
self::$loadQueue[$object->type] = [];
}
$relationsKey = base64_encode(json_encode($relations));
if( ! array_key_exists($relationsKey, self::$loadQueue[$object->type]) )
{
self::$loadQueue[$object->type][$relationsKey] = [ 'type' => $object->type, 'ids' => [], 'relations' => $relations ];
}
self::$loadQueue[$object->type][$relationsKey]['ids'][] = $object->id;
}
|
[
"protected",
"function",
"addToQueue",
"(",
"$",
"object",
",",
"$",
"relations",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"object",
"->",
"type",
",",
"self",
"::",
"$",
"loadQueue",
")",
")",
"{",
"self",
"::",
"$",
"loadQueue",
"[",
"$",
"object",
"->",
"type",
"]",
"=",
"[",
"]",
";",
"}",
"$",
"relationsKey",
"=",
"base64_encode",
"(",
"json_encode",
"(",
"$",
"relations",
")",
")",
";",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"relationsKey",
",",
"self",
"::",
"$",
"loadQueue",
"[",
"$",
"object",
"->",
"type",
"]",
")",
")",
"{",
"self",
"::",
"$",
"loadQueue",
"[",
"$",
"object",
"->",
"type",
"]",
"[",
"$",
"relationsKey",
"]",
"=",
"[",
"'type'",
"=>",
"$",
"object",
"->",
"type",
",",
"'ids'",
"=>",
"[",
"]",
",",
"'relations'",
"=>",
"$",
"relations",
"]",
";",
"}",
"self",
"::",
"$",
"loadQueue",
"[",
"$",
"object",
"->",
"type",
"]",
"[",
"$",
"relationsKey",
"]",
"[",
"'ids'",
"]",
"[",
"]",
"=",
"$",
"object",
"->",
"id",
";",
"}"
] |
Add object to loadQueue if it's specified in relations
@param stdClass $object object to add
@param array | int $relations relations to check
@return void
|
[
"Add",
"object",
"to",
"loadQueue",
"if",
"it",
"s",
"specified",
"in",
"relations"
] |
d017d3951b446fb2ac93b8fcee120549bb125b17
|
https://github.com/congraphcms/core/blob/d017d3951b446fb2ac93b8fcee120549bb125b17/Repositories/RelationLoader.php#L163-L176
|
26,006
|
imsamurai/CakePHP-AdvancedShell
|
Console/Command/Task/AdvancedTask.php
|
AdvancedTask._scheduleVars
|
protected function _scheduleVars() {
global $argv;
$path = $argv[2] . DS;
$shellName = $argv[3];
$taskName = $argv[4];
if (isset($this->args[0]) && $this->hasMethod($this->args[0])) {
$methodName = $this->args[0];
array_shift($this->args);
} else {
$methodName = null;
}
$command = implode(' ', array_filter(array(
'Console/cake',
$shellName,
$taskName,
$methodName
)));
$arguments = $this->args;
foreach ($this->params as $name => $value) {
if (in_array($name, array(
'scheduled',
'scheduled-depends-on',
'scheduled-wait-prev',
'skip-unlogged',
'scheduled-process-timeout'
), true)) {
continue;
}
if (is_bool($value) && $value) {
$arguments[] = '--' . $name;
} elseif (!is_bool($value)) {
$arguments['--' . $name] = $value;
}
}
$options = array(
'timeout' => $this->params['scheduled-process-timeout'],
'dependsOn' => empty($this->params['scheduled-depends-on']) ? array() : explode(',', $this->params['scheduled-depends-on'])
);
return array($command, $path, $arguments, $options);
}
|
php
|
protected function _scheduleVars() {
global $argv;
$path = $argv[2] . DS;
$shellName = $argv[3];
$taskName = $argv[4];
if (isset($this->args[0]) && $this->hasMethod($this->args[0])) {
$methodName = $this->args[0];
array_shift($this->args);
} else {
$methodName = null;
}
$command = implode(' ', array_filter(array(
'Console/cake',
$shellName,
$taskName,
$methodName
)));
$arguments = $this->args;
foreach ($this->params as $name => $value) {
if (in_array($name, array(
'scheduled',
'scheduled-depends-on',
'scheduled-wait-prev',
'skip-unlogged',
'scheduled-process-timeout'
), true)) {
continue;
}
if (is_bool($value) && $value) {
$arguments[] = '--' . $name;
} elseif (!is_bool($value)) {
$arguments['--' . $name] = $value;
}
}
$options = array(
'timeout' => $this->params['scheduled-process-timeout'],
'dependsOn' => empty($this->params['scheduled-depends-on']) ? array() : explode(',', $this->params['scheduled-depends-on'])
);
return array($command, $path, $arguments, $options);
}
|
[
"protected",
"function",
"_scheduleVars",
"(",
")",
"{",
"global",
"$",
"argv",
";",
"$",
"path",
"=",
"$",
"argv",
"[",
"2",
"]",
".",
"DS",
";",
"$",
"shellName",
"=",
"$",
"argv",
"[",
"3",
"]",
";",
"$",
"taskName",
"=",
"$",
"argv",
"[",
"4",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"args",
"[",
"0",
"]",
")",
"&&",
"$",
"this",
"->",
"hasMethod",
"(",
"$",
"this",
"->",
"args",
"[",
"0",
"]",
")",
")",
"{",
"$",
"methodName",
"=",
"$",
"this",
"->",
"args",
"[",
"0",
"]",
";",
"array_shift",
"(",
"$",
"this",
"->",
"args",
")",
";",
"}",
"else",
"{",
"$",
"methodName",
"=",
"null",
";",
"}",
"$",
"command",
"=",
"implode",
"(",
"' '",
",",
"array_filter",
"(",
"array",
"(",
"'Console/cake'",
",",
"$",
"shellName",
",",
"$",
"taskName",
",",
"$",
"methodName",
")",
")",
")",
";",
"$",
"arguments",
"=",
"$",
"this",
"->",
"args",
";",
"foreach",
"(",
"$",
"this",
"->",
"params",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"name",
",",
"array",
"(",
"'scheduled'",
",",
"'scheduled-depends-on'",
",",
"'scheduled-wait-prev'",
",",
"'skip-unlogged'",
",",
"'scheduled-process-timeout'",
")",
",",
"true",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"is_bool",
"(",
"$",
"value",
")",
"&&",
"$",
"value",
")",
"{",
"$",
"arguments",
"[",
"]",
"=",
"'--'",
".",
"$",
"name",
";",
"}",
"elseif",
"(",
"!",
"is_bool",
"(",
"$",
"value",
")",
")",
"{",
"$",
"arguments",
"[",
"'--'",
".",
"$",
"name",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"$",
"options",
"=",
"array",
"(",
"'timeout'",
"=>",
"$",
"this",
"->",
"params",
"[",
"'scheduled-process-timeout'",
"]",
",",
"'dependsOn'",
"=>",
"empty",
"(",
"$",
"this",
"->",
"params",
"[",
"'scheduled-depends-on'",
"]",
")",
"?",
"array",
"(",
")",
":",
"explode",
"(",
"','",
",",
"$",
"this",
"->",
"params",
"[",
"'scheduled-depends-on'",
"]",
")",
")",
";",
"return",
"array",
"(",
"$",
"command",
",",
"$",
"path",
",",
"$",
"arguments",
",",
"$",
"options",
")",
";",
"}"
] |
Returns variables for schedule
@global array $argv
@return array
|
[
"Returns",
"variables",
"for",
"schedule"
] |
087d483742e2a76bee45e35b8d94957b0d20f857
|
https://github.com/imsamurai/CakePHP-AdvancedShell/blob/087d483742e2a76bee45e35b8d94957b0d20f857/Console/Command/Task/AdvancedTask.php#L181-L225
|
26,007
|
imsamurai/CakePHP-AdvancedShell
|
Console/Command/Task/AdvancedTask.php
|
AdvancedTask._schedule
|
protected function _schedule($command, $path, array $arguments, array $options) {
$TaskClient = ClassRegistry::init('Task.TaskClient');
$task = $TaskClient->add($command, $path, $arguments, $options);
if ($task) {
$waitFor = empty($options['dependsOn']) ? 'none' : implode(', ', $options['dependsOn']) . ' task(s)';
$this->out("Task #{$TaskClient->id} successfuly added, wait for $waitFor");
} else {
$this->err('Error! Task not added!');
}
return $task;
}
|
php
|
protected function _schedule($command, $path, array $arguments, array $options) {
$TaskClient = ClassRegistry::init('Task.TaskClient');
$task = $TaskClient->add($command, $path, $arguments, $options);
if ($task) {
$waitFor = empty($options['dependsOn']) ? 'none' : implode(', ', $options['dependsOn']) . ' task(s)';
$this->out("Task #{$TaskClient->id} successfuly added, wait for $waitFor");
} else {
$this->err('Error! Task not added!');
}
return $task;
}
|
[
"protected",
"function",
"_schedule",
"(",
"$",
"command",
",",
"$",
"path",
",",
"array",
"$",
"arguments",
",",
"array",
"$",
"options",
")",
"{",
"$",
"TaskClient",
"=",
"ClassRegistry",
"::",
"init",
"(",
"'Task.TaskClient'",
")",
";",
"$",
"task",
"=",
"$",
"TaskClient",
"->",
"add",
"(",
"$",
"command",
",",
"$",
"path",
",",
"$",
"arguments",
",",
"$",
"options",
")",
";",
"if",
"(",
"$",
"task",
")",
"{",
"$",
"waitFor",
"=",
"empty",
"(",
"$",
"options",
"[",
"'dependsOn'",
"]",
")",
"?",
"'none'",
":",
"implode",
"(",
"', '",
",",
"$",
"options",
"[",
"'dependsOn'",
"]",
")",
".",
"' task(s)'",
";",
"$",
"this",
"->",
"out",
"(",
"\"Task #{$TaskClient->id} successfuly added, wait for $waitFor\"",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"err",
"(",
"'Error! Task not added!'",
")",
";",
"}",
"return",
"$",
"task",
";",
"}"
] |
Adds script to sceduler
@param string $command
@param string $path
@param array $arguments
@param array $options
|
[
"Adds",
"script",
"to",
"sceduler"
] |
087d483742e2a76bee45e35b8d94957b0d20f857
|
https://github.com/imsamurai/CakePHP-AdvancedShell/blob/087d483742e2a76bee45e35b8d94957b0d20f857/Console/Command/Task/AdvancedTask.php#L235-L245
|
26,008
|
imsamurai/CakePHP-AdvancedShell
|
Console/Command/Task/AdvancedTask.php
|
AdvancedTask._getInterval
|
protected function _getInterval($interval) {
if ($interval !== null) {
return $interval;
} elseif (!empty($this->params['interval'])) {
return $this->params['interval'];
} else {
return '1 day';
}
}
|
php
|
protected function _getInterval($interval) {
if ($interval !== null) {
return $interval;
} elseif (!empty($this->params['interval'])) {
return $this->params['interval'];
} else {
return '1 day';
}
}
|
[
"protected",
"function",
"_getInterval",
"(",
"$",
"interval",
")",
"{",
"if",
"(",
"$",
"interval",
"!==",
"null",
")",
"{",
"return",
"$",
"interval",
";",
"}",
"elseif",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"params",
"[",
"'interval'",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"params",
"[",
"'interval'",
"]",
";",
"}",
"else",
"{",
"return",
"'1 day'",
";",
"}",
"}"
] |
Returns interval value specified by parameter or default value
@param string $interval If not null method return this value
@return string
|
[
"Returns",
"interval",
"value",
"specified",
"by",
"parameter",
"or",
"default",
"value"
] |
087d483742e2a76bee45e35b8d94957b0d20f857
|
https://github.com/imsamurai/CakePHP-AdvancedShell/blob/087d483742e2a76bee45e35b8d94957b0d20f857/Console/Command/Task/AdvancedTask.php#L302-L310
|
26,009
|
ekyna/Sale
|
PriceableTrait.php
|
PriceableTrait.getTaxesAmounts
|
public function getTaxesAmounts()
{
$amounts = new TaxesAmounts();
$amounts->addTaxAmount(new TaxAmount($this->tax, $this->getTaxAmount()));
return $amounts;
}
|
php
|
public function getTaxesAmounts()
{
$amounts = new TaxesAmounts();
$amounts->addTaxAmount(new TaxAmount($this->tax, $this->getTaxAmount()));
return $amounts;
}
|
[
"public",
"function",
"getTaxesAmounts",
"(",
")",
"{",
"$",
"amounts",
"=",
"new",
"TaxesAmounts",
"(",
")",
";",
"$",
"amounts",
"->",
"addTaxAmount",
"(",
"new",
"TaxAmount",
"(",
"$",
"this",
"->",
"tax",
",",
"$",
"this",
"->",
"getTaxAmount",
"(",
")",
")",
")",
";",
"return",
"$",
"amounts",
";",
"}"
] |
Returns the taxes amounts.
@return TaxesAmounts
|
[
"Returns",
"the",
"taxes",
"amounts",
"."
] |
434093b658628e88b59a156e21239df0b1855e89
|
https://github.com/ekyna/Sale/blob/434093b658628e88b59a156e21239df0b1855e89/PriceableTrait.php#L89-L94
|
26,010
|
975L/ConfigBundle
|
Twig/Config.php
|
Config.config
|
public function config($parameter)
{
$value = $this->configService->getParameter($parameter);
return is_array($value) ? json_encode($value) : $value;
}
|
php
|
public function config($parameter)
{
$value = $this->configService->getParameter($parameter);
return is_array($value) ? json_encode($value) : $value;
}
|
[
"public",
"function",
"config",
"(",
"$",
"parameter",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"configService",
"->",
"getParameter",
"(",
"$",
"parameter",
")",
";",
"return",
"is_array",
"(",
"$",
"value",
")",
"?",
"json_encode",
"(",
"$",
"value",
")",
":",
"$",
"value",
";",
"}"
] |
Returns the specified parameter
@return string
|
[
"Returns",
"the",
"specified",
"parameter"
] |
1f9a9e937dbb79ad06fe5d456e7536d58bd56e19
|
https://github.com/975L/ConfigBundle/blob/1f9a9e937dbb79ad06fe5d456e7536d58bd56e19/Twig/Config.php#L48-L53
|
26,011
|
black-lamp/blcms-payment
|
frontend/controllers/DefaultController.php
|
DefaultController.actionGetPaymentMethodInfo
|
public function actionGetPaymentMethodInfo($id) {
if (\Yii::$app->request->isAjax) {
if (!empty($id)) {
$method = PaymentMethod::findOne($id);
$methodTranslation = $method->translation;
$method = ArrayHelper::toArray($method);
$method['translation'] = ArrayHelper::toArray($methodTranslation);
$method['image'] = '/images/payment/' .
FileHelper::getFullName(
\Yii::$app->shop_imagable->get('payment', 'small', $method['image']
));
return json_encode([
'paymentMethod' => $method,
]);
}
}
throw new NotFoundHttpException();
}
|
php
|
public function actionGetPaymentMethodInfo($id) {
if (\Yii::$app->request->isAjax) {
if (!empty($id)) {
$method = PaymentMethod::findOne($id);
$methodTranslation = $method->translation;
$method = ArrayHelper::toArray($method);
$method['translation'] = ArrayHelper::toArray($methodTranslation);
$method['image'] = '/images/payment/' .
FileHelper::getFullName(
\Yii::$app->shop_imagable->get('payment', 'small', $method['image']
));
return json_encode([
'paymentMethod' => $method,
]);
}
}
throw new NotFoundHttpException();
}
|
[
"public",
"function",
"actionGetPaymentMethodInfo",
"(",
"$",
"id",
")",
"{",
"if",
"(",
"\\",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"isAjax",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"id",
")",
")",
"{",
"$",
"method",
"=",
"PaymentMethod",
"::",
"findOne",
"(",
"$",
"id",
")",
";",
"$",
"methodTranslation",
"=",
"$",
"method",
"->",
"translation",
";",
"$",
"method",
"=",
"ArrayHelper",
"::",
"toArray",
"(",
"$",
"method",
")",
";",
"$",
"method",
"[",
"'translation'",
"]",
"=",
"ArrayHelper",
"::",
"toArray",
"(",
"$",
"methodTranslation",
")",
";",
"$",
"method",
"[",
"'image'",
"]",
"=",
"'/images/payment/'",
".",
"FileHelper",
"::",
"getFullName",
"(",
"\\",
"Yii",
"::",
"$",
"app",
"->",
"shop_imagable",
"->",
"get",
"(",
"'payment'",
",",
"'small'",
",",
"$",
"method",
"[",
"'image'",
"]",
")",
")",
";",
"return",
"json_encode",
"(",
"[",
"'paymentMethod'",
"=>",
"$",
"method",
",",
"]",
")",
";",
"}",
"}",
"throw",
"new",
"NotFoundHttpException",
"(",
")",
";",
"}"
] |
Returns payment method model if request is Ajax.
@param integer $id
@return PaymentMethod
@throws NotFoundHttpException
|
[
"Returns",
"payment",
"method",
"model",
"if",
"request",
"is",
"Ajax",
"."
] |
6d139e0bb5a4e7733382cc6fe083173551905b92
|
https://github.com/black-lamp/blcms-payment/blob/6d139e0bb5a4e7733382cc6fe083173551905b92/frontend/controllers/DefaultController.php#L25-L45
|
26,012
|
MichaelJ2324/PHP-REST-Client
|
src/Storage/StaticStorage.php
|
StaticStorage.getItem
|
public static function getItem($namespace,$key){
if (isset(static::$_STORAGE[$namespace])){
if (isset(static::$_STORAGE[$namespace][$key])){
return static::$_STORAGE[$namespace][$key];
}
}
return NULL;
}
|
php
|
public static function getItem($namespace,$key){
if (isset(static::$_STORAGE[$namespace])){
if (isset(static::$_STORAGE[$namespace][$key])){
return static::$_STORAGE[$namespace][$key];
}
}
return NULL;
}
|
[
"public",
"static",
"function",
"getItem",
"(",
"$",
"namespace",
",",
"$",
"key",
")",
"{",
"if",
"(",
"isset",
"(",
"static",
"::",
"$",
"_STORAGE",
"[",
"$",
"namespace",
"]",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"static",
"::",
"$",
"_STORAGE",
"[",
"$",
"namespace",
"]",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"static",
"::",
"$",
"_STORAGE",
"[",
"$",
"namespace",
"]",
"[",
"$",
"key",
"]",
";",
"}",
"}",
"return",
"NULL",
";",
"}"
] |
Get an Item from the Static Storage array
@param $namespace
@param $key
@return mixed|null
|
[
"Get",
"an",
"Item",
"from",
"the",
"Static",
"Storage",
"array"
] |
b8a2caaf6456eccaa845ba5c5098608aa9645c92
|
https://github.com/MichaelJ2324/PHP-REST-Client/blob/b8a2caaf6456eccaa845ba5c5098608aa9645c92/src/Storage/StaticStorage.php#L46-L53
|
26,013
|
MichaelJ2324/PHP-REST-Client
|
src/Storage/StaticStorage.php
|
StaticStorage.setItem
|
public static function setItem($namespace,$key,$value){
if (!isset(static::$_STORAGE[$namespace])){
static::$_STORAGE[$namespace] = array();
}
static::$_STORAGE[$namespace][$key] = $value;
return TRUE;
}
|
php
|
public static function setItem($namespace,$key,$value){
if (!isset(static::$_STORAGE[$namespace])){
static::$_STORAGE[$namespace] = array();
}
static::$_STORAGE[$namespace][$key] = $value;
return TRUE;
}
|
[
"public",
"static",
"function",
"setItem",
"(",
"$",
"namespace",
",",
"$",
"key",
",",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"static",
"::",
"$",
"_STORAGE",
"[",
"$",
"namespace",
"]",
")",
")",
"{",
"static",
"::",
"$",
"_STORAGE",
"[",
"$",
"namespace",
"]",
"=",
"array",
"(",
")",
";",
"}",
"static",
"::",
"$",
"_STORAGE",
"[",
"$",
"namespace",
"]",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"return",
"TRUE",
";",
"}"
] |
Set an Item in the Static Storage array for a particular Namespace
@param $namespace
@param $key
@return bool
|
[
"Set",
"an",
"Item",
"in",
"the",
"Static",
"Storage",
"array",
"for",
"a",
"particular",
"Namespace"
] |
b8a2caaf6456eccaa845ba5c5098608aa9645c92
|
https://github.com/MichaelJ2324/PHP-REST-Client/blob/b8a2caaf6456eccaa845ba5c5098608aa9645c92/src/Storage/StaticStorage.php#L61-L67
|
26,014
|
railken/lem
|
src/Result.php
|
Result.addErrors
|
public function addErrors(Collection $errors)
{
$this->errors = $this->getErrors()->merge($errors);
return $this;
}
|
php
|
public function addErrors(Collection $errors)
{
$this->errors = $this->getErrors()->merge($errors);
return $this;
}
|
[
"public",
"function",
"addErrors",
"(",
"Collection",
"$",
"errors",
")",
"{",
"$",
"this",
"->",
"errors",
"=",
"$",
"this",
"->",
"getErrors",
"(",
")",
"->",
"merge",
"(",
"$",
"errors",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Add errors.
@param Collection $errors
@return $this
|
[
"Add",
"errors",
"."
] |
cff1efcd090a9504b2faf5594121885786dea67a
|
https://github.com/railken/lem/blob/cff1efcd090a9504b2faf5594121885786dea67a/src/Result.php#L104-L109
|
26,015
|
phossa/phossa-cache
|
src/Phossa/Cache/CachePool.php
|
CachePool.createItem
|
protected function createItem(/*# string */ $key)/*# : CacheItemInterface */
{
// validate key first
$this->validateKey($key);
// use item factory
if (is_callable($this->item_factory)) {
$func = $this->item_factory;
$item = $func($key, $this, $this->item_config);
// default CacheItem class
} else {
$item = new CacheItem($key, $this, $this->item_config);
}
return $item;
}
|
php
|
protected function createItem(/*# string */ $key)/*# : CacheItemInterface */
{
// validate key first
$this->validateKey($key);
// use item factory
if (is_callable($this->item_factory)) {
$func = $this->item_factory;
$item = $func($key, $this, $this->item_config);
// default CacheItem class
} else {
$item = new CacheItem($key, $this, $this->item_config);
}
return $item;
}
|
[
"protected",
"function",
"createItem",
"(",
"/*# string */",
"$",
"key",
")",
"/*# : CacheItemInterface */",
"{",
"// validate key first",
"$",
"this",
"->",
"validateKey",
"(",
"$",
"key",
")",
";",
"// use item factory",
"if",
"(",
"is_callable",
"(",
"$",
"this",
"->",
"item_factory",
")",
")",
"{",
"$",
"func",
"=",
"$",
"this",
"->",
"item_factory",
";",
"$",
"item",
"=",
"$",
"func",
"(",
"$",
"key",
",",
"$",
"this",
",",
"$",
"this",
"->",
"item_config",
")",
";",
"// default CacheItem class",
"}",
"else",
"{",
"$",
"item",
"=",
"new",
"CacheItem",
"(",
"$",
"key",
",",
"$",
"this",
",",
"$",
"this",
"->",
"item_config",
")",
";",
"}",
"return",
"$",
"item",
";",
"}"
] |
Create item object
@param string $key item key
@return CacheItemInterface
@throws Exception\InvalidArgumentException
@access protected
|
[
"Create",
"item",
"object"
] |
ad86bee9c5c646fbae09f6f58a346b379d16276e
|
https://github.com/phossa/phossa-cache/blob/ad86bee9c5c646fbae09f6f58a346b379d16276e/src/Phossa/Cache/CachePool.php#L306-L322
|
26,016
|
picturae/php-composition-utils
|
src/WithArrayTransform.php
|
WithArrayTransform.toArray
|
public function toArray()
{
$classData = [];
foreach ($this->getReflector()->getProperties(\ReflectionProperty::IS_PROTECTED) as $reflectionProperty) {
if (!$reflectionProperty->isStatic()) {
$reflectionProperty->setAccessible(true);
$classData[$reflectionProperty->getName()] = $reflectionProperty->getValue($this);
}
}
return $classData;
}
|
php
|
public function toArray()
{
$classData = [];
foreach ($this->getReflector()->getProperties(\ReflectionProperty::IS_PROTECTED) as $reflectionProperty) {
if (!$reflectionProperty->isStatic()) {
$reflectionProperty->setAccessible(true);
$classData[$reflectionProperty->getName()] = $reflectionProperty->getValue($this);
}
}
return $classData;
}
|
[
"public",
"function",
"toArray",
"(",
")",
"{",
"$",
"classData",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"getReflector",
"(",
")",
"->",
"getProperties",
"(",
"\\",
"ReflectionProperty",
"::",
"IS_PROTECTED",
")",
"as",
"$",
"reflectionProperty",
")",
"{",
"if",
"(",
"!",
"$",
"reflectionProperty",
"->",
"isStatic",
"(",
")",
")",
"{",
"$",
"reflectionProperty",
"->",
"setAccessible",
"(",
"true",
")",
";",
"$",
"classData",
"[",
"$",
"reflectionProperty",
"->",
"getName",
"(",
")",
"]",
"=",
"$",
"reflectionProperty",
"->",
"getValue",
"(",
"$",
"this",
")",
";",
"}",
"}",
"return",
"$",
"classData",
";",
"}"
] |
Fetch the array representation of the protected properties of an object.
@return array
|
[
"Fetch",
"the",
"array",
"representation",
"of",
"the",
"protected",
"properties",
"of",
"an",
"object",
"."
] |
59a8191066c27687daabc8c5b33addb3599826ab
|
https://github.com/picturae/php-composition-utils/blob/59a8191066c27687daabc8c5b33addb3599826ab/src/WithArrayTransform.php#L30-L40
|
26,017
|
picturae/php-composition-utils
|
src/WithArrayTransform.php
|
WithArrayTransform.fromArray
|
public function fromArray(array $source)
{
foreach ($this->getReflector()->getProperties(\ReflectionProperty::IS_PROTECTED) as $reflectionProperty) {
if (!$reflectionProperty->isStatic() && isset($source[$reflectionProperty->getName()])) {
$reflectionProperty->setAccessible(true);
$reflectionProperty->setValue($this, $source[$reflectionProperty->getName()]);
}
}
return $this;
}
|
php
|
public function fromArray(array $source)
{
foreach ($this->getReflector()->getProperties(\ReflectionProperty::IS_PROTECTED) as $reflectionProperty) {
if (!$reflectionProperty->isStatic() && isset($source[$reflectionProperty->getName()])) {
$reflectionProperty->setAccessible(true);
$reflectionProperty->setValue($this, $source[$reflectionProperty->getName()]);
}
}
return $this;
}
|
[
"public",
"function",
"fromArray",
"(",
"array",
"$",
"source",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getReflector",
"(",
")",
"->",
"getProperties",
"(",
"\\",
"ReflectionProperty",
"::",
"IS_PROTECTED",
")",
"as",
"$",
"reflectionProperty",
")",
"{",
"if",
"(",
"!",
"$",
"reflectionProperty",
"->",
"isStatic",
"(",
")",
"&&",
"isset",
"(",
"$",
"source",
"[",
"$",
"reflectionProperty",
"->",
"getName",
"(",
")",
"]",
")",
")",
"{",
"$",
"reflectionProperty",
"->",
"setAccessible",
"(",
"true",
")",
";",
"$",
"reflectionProperty",
"->",
"setValue",
"(",
"$",
"this",
",",
"$",
"source",
"[",
"$",
"reflectionProperty",
"->",
"getName",
"(",
")",
"]",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] |
Set protected propertie according to provided source.
@param array source data.
@return $this
|
[
"Set",
"protected",
"propertie",
"according",
"to",
"provided",
"source",
"."
] |
59a8191066c27687daabc8c5b33addb3599826ab
|
https://github.com/picturae/php-composition-utils/blob/59a8191066c27687daabc8c5b33addb3599826ab/src/WithArrayTransform.php#L47-L56
|
26,018
|
picturae/php-composition-utils
|
src/WithArrayTransform.php
|
WithArrayTransform.getFieldsConfig
|
public function getFieldsConfig()
{
if (null === $this->fieldsConfigList) {
$this->fieldsConfigList = [];
foreach ($this->getFields() as $field) {
$reflectionProperty = $this->getReflector()->getProperty($field);
$docBlock = $reflectionProperty->getDocComment();
preg_match('/@var\s([a-z]*).*/', $docBlock, $matches);
$this->fieldsConfigList[$field] = [
'type' => isset($matches[1]) ? $matches[1] : null
];
}
}
return $this->fieldsConfigList;
}
|
php
|
public function getFieldsConfig()
{
if (null === $this->fieldsConfigList) {
$this->fieldsConfigList = [];
foreach ($this->getFields() as $field) {
$reflectionProperty = $this->getReflector()->getProperty($field);
$docBlock = $reflectionProperty->getDocComment();
preg_match('/@var\s([a-z]*).*/', $docBlock, $matches);
$this->fieldsConfigList[$field] = [
'type' => isset($matches[1]) ? $matches[1] : null
];
}
}
return $this->fieldsConfigList;
}
|
[
"public",
"function",
"getFieldsConfig",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"fieldsConfigList",
")",
"{",
"$",
"this",
"->",
"fieldsConfigList",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"getFields",
"(",
")",
"as",
"$",
"field",
")",
"{",
"$",
"reflectionProperty",
"=",
"$",
"this",
"->",
"getReflector",
"(",
")",
"->",
"getProperty",
"(",
"$",
"field",
")",
";",
"$",
"docBlock",
"=",
"$",
"reflectionProperty",
"->",
"getDocComment",
"(",
")",
";",
"preg_match",
"(",
"'/@var\\s([a-z]*).*/'",
",",
"$",
"docBlock",
",",
"$",
"matches",
")",
";",
"$",
"this",
"->",
"fieldsConfigList",
"[",
"$",
"field",
"]",
"=",
"[",
"'type'",
"=>",
"isset",
"(",
"$",
"matches",
"[",
"1",
"]",
")",
"?",
"$",
"matches",
"[",
"1",
"]",
":",
"null",
"]",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"fieldsConfigList",
";",
"}"
] |
Fetch the var metadata for a field and store it in the config.
@return array
|
[
"Fetch",
"the",
"var",
"metadata",
"for",
"a",
"field",
"and",
"store",
"it",
"in",
"the",
"config",
"."
] |
59a8191066c27687daabc8c5b33addb3599826ab
|
https://github.com/picturae/php-composition-utils/blob/59a8191066c27687daabc8c5b33addb3599826ab/src/WithArrayTransform.php#L80-L98
|
26,019
|
picturae/php-composition-utils
|
src/WithArrayTransform.php
|
WithArrayTransform.getFieldType
|
public function getFieldType($field)
{
return isset($this->getFieldsConfig()[$field]) ? $this->getFieldsConfig()[$field]['type'] : null;
}
|
php
|
public function getFieldType($field)
{
return isset($this->getFieldsConfig()[$field]) ? $this->getFieldsConfig()[$field]['type'] : null;
}
|
[
"public",
"function",
"getFieldType",
"(",
"$",
"field",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"getFieldsConfig",
"(",
")",
"[",
"$",
"field",
"]",
")",
"?",
"$",
"this",
"->",
"getFieldsConfig",
"(",
")",
"[",
"$",
"field",
"]",
"[",
"'type'",
"]",
":",
"null",
";",
"}"
] |
Fetch a field type according to var metadata.
@param string $field
@return string
|
[
"Fetch",
"a",
"field",
"type",
"according",
"to",
"var",
"metadata",
"."
] |
59a8191066c27687daabc8c5b33addb3599826ab
|
https://github.com/picturae/php-composition-utils/blob/59a8191066c27687daabc8c5b33addb3599826ab/src/WithArrayTransform.php#L105-L108
|
26,020
|
hamjoint/mustard-media
|
src/lib/Photo.php
|
Photo.getUrlAttribute
|
public function getUrlAttribute($suffix = '')
{
if (!$this->exists) {
return Cache::rememberForever('missing_photo', function () {
return static::placeholder('No photo provided');
});
}
if (!$this->processed) {
return Cache::rememberForever('processing_photo', function () {
return static::placeholder(
"This photo is\nbeing processed\nand will appear\nshortly"
);
});
}
return "/photo/{$this->photoId}$suffix.jpg";
}
|
php
|
public function getUrlAttribute($suffix = '')
{
if (!$this->exists) {
return Cache::rememberForever('missing_photo', function () {
return static::placeholder('No photo provided');
});
}
if (!$this->processed) {
return Cache::rememberForever('processing_photo', function () {
return static::placeholder(
"This photo is\nbeing processed\nand will appear\nshortly"
);
});
}
return "/photo/{$this->photoId}$suffix.jpg";
}
|
[
"public",
"function",
"getUrlAttribute",
"(",
"$",
"suffix",
"=",
"''",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"exists",
")",
"{",
"return",
"Cache",
"::",
"rememberForever",
"(",
"'missing_photo'",
",",
"function",
"(",
")",
"{",
"return",
"static",
"::",
"placeholder",
"(",
"'No photo provided'",
")",
";",
"}",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"processed",
")",
"{",
"return",
"Cache",
"::",
"rememberForever",
"(",
"'processing_photo'",
",",
"function",
"(",
")",
"{",
"return",
"static",
"::",
"placeholder",
"(",
"\"This photo is\\nbeing processed\\nand will appear\\nshortly\"",
")",
";",
"}",
")",
";",
"}",
"return",
"\"/photo/{$this->photoId}$suffix.jpg\"",
";",
"}"
] |
Return the public URL for the photo.
@param string $suffix
@return string
|
[
"Return",
"the",
"public",
"URL",
"for",
"the",
"photo",
"."
] |
d3c799dbc3578e1e1022bb4eccae7a20e285ba06
|
https://github.com/hamjoint/mustard-media/blob/d3c799dbc3578e1e1022bb4eccae7a20e285ba06/src/lib/Photo.php#L94-L111
|
26,021
|
hamjoint/mustard-media
|
src/lib/Photo.php
|
Photo.delete
|
public function delete()
{
$disk = Storage::disk(config('mustard.storage.disk', 'local'));
$disk->delete($this->getPath());
$disk->delete($this->getSmallPath());
$disk->delete($this->getLargePath());
parent::delete();
}
|
php
|
public function delete()
{
$disk = Storage::disk(config('mustard.storage.disk', 'local'));
$disk->delete($this->getPath());
$disk->delete($this->getSmallPath());
$disk->delete($this->getLargePath());
parent::delete();
}
|
[
"public",
"function",
"delete",
"(",
")",
"{",
"$",
"disk",
"=",
"Storage",
"::",
"disk",
"(",
"config",
"(",
"'mustard.storage.disk'",
",",
"'local'",
")",
")",
";",
"$",
"disk",
"->",
"delete",
"(",
"$",
"this",
"->",
"getPath",
"(",
")",
")",
";",
"$",
"disk",
"->",
"delete",
"(",
"$",
"this",
"->",
"getSmallPath",
"(",
")",
")",
";",
"$",
"disk",
"->",
"delete",
"(",
"$",
"this",
"->",
"getLargePath",
"(",
")",
")",
";",
"parent",
"::",
"delete",
"(",
")",
";",
"}"
] |
Delete the record and data from the filesystem.
@return void
|
[
"Delete",
"the",
"record",
"and",
"data",
"from",
"the",
"filesystem",
"."
] |
d3c799dbc3578e1e1022bb4eccae7a20e285ba06
|
https://github.com/hamjoint/mustard-media/blob/d3c799dbc3578e1e1022bb4eccae7a20e285ba06/src/lib/Photo.php#L138-L147
|
26,022
|
hamjoint/mustard-media
|
src/lib/Photo.php
|
Photo.placeholder
|
private static function placeholder($text)
{
$image_manager = new ImageManager(['driver' => 'imagick']);
$image = $image_manager->canvas(640, 480, '#efefef');
$image->text($text, 320, 240 - (70 * substr_count($text, "\n")), function ($font) {
$font->file(base_path('vendor/webfontkit/open-sans/fonts/opensans-regular.woff'));
$font->size(60);
$font->color('#cbcbcb');
$font->align('center');
$font->valign('center');
});
$image_data = (string) $image->encode('gif');
return 'data:image/gif;base64,'.base64_encode($image_data);
}
|
php
|
private static function placeholder($text)
{
$image_manager = new ImageManager(['driver' => 'imagick']);
$image = $image_manager->canvas(640, 480, '#efefef');
$image->text($text, 320, 240 - (70 * substr_count($text, "\n")), function ($font) {
$font->file(base_path('vendor/webfontkit/open-sans/fonts/opensans-regular.woff'));
$font->size(60);
$font->color('#cbcbcb');
$font->align('center');
$font->valign('center');
});
$image_data = (string) $image->encode('gif');
return 'data:image/gif;base64,'.base64_encode($image_data);
}
|
[
"private",
"static",
"function",
"placeholder",
"(",
"$",
"text",
")",
"{",
"$",
"image_manager",
"=",
"new",
"ImageManager",
"(",
"[",
"'driver'",
"=>",
"'imagick'",
"]",
")",
";",
"$",
"image",
"=",
"$",
"image_manager",
"->",
"canvas",
"(",
"640",
",",
"480",
",",
"'#efefef'",
")",
";",
"$",
"image",
"->",
"text",
"(",
"$",
"text",
",",
"320",
",",
"240",
"-",
"(",
"70",
"*",
"substr_count",
"(",
"$",
"text",
",",
"\"\\n\"",
")",
")",
",",
"function",
"(",
"$",
"font",
")",
"{",
"$",
"font",
"->",
"file",
"(",
"base_path",
"(",
"'vendor/webfontkit/open-sans/fonts/opensans-regular.woff'",
")",
")",
";",
"$",
"font",
"->",
"size",
"(",
"60",
")",
";",
"$",
"font",
"->",
"color",
"(",
"'#cbcbcb'",
")",
";",
"$",
"font",
"->",
"align",
"(",
"'center'",
")",
";",
"$",
"font",
"->",
"valign",
"(",
"'center'",
")",
";",
"}",
")",
";",
"$",
"image_data",
"=",
"(",
"string",
")",
"$",
"image",
"->",
"encode",
"(",
"'gif'",
")",
";",
"return",
"'data:image/gif;base64,'",
".",
"base64_encode",
"(",
"$",
"image_data",
")",
";",
"}"
] |
Return a placeholder image containing the provided text.
@param string $text
@return string
|
[
"Return",
"a",
"placeholder",
"image",
"containing",
"the",
"provided",
"text",
"."
] |
d3c799dbc3578e1e1022bb4eccae7a20e285ba06
|
https://github.com/hamjoint/mustard-media/blob/d3c799dbc3578e1e1022bb4eccae7a20e285ba06/src/lib/Photo.php#L166-L183
|
26,023
|
hamjoint/mustard-media
|
src/lib/Photo.php
|
Photo.upload
|
public static function upload($file)
{
$photo = self::create();
$image_manager = new ImageManager(['driver' => 'imagick']);
$disk = Storage::disk(config('mustard.storage.disk', 'local'));
if (!file_exists($file)) {
RuntimeException("File $file does not exist");
}
$dest_dir = config('mustard.storage.photo.dir', 'mustard/photos');
$quality = config('mustard.storage.photo.quality', 90);
$disk->makeDirectory($dest_dir);
$photo_id = $photo->getKey();
Queue::push(function ($job) use ($file, $quality, $dest_dir, $photo_id) {
if (!file_exists($file)) {
RuntimeException("File $file no longer exists");
}
$image_manager = new ImageManager(['driver' => 'imagick']);
$disk = Storage::disk(config('mustard.storage.disk', 'local'));
if ($file != "$dest_dir/$photo_id.jpg") {
$image = $image_manager->make($file);
$disk->put("$dest_dir/$photo_id.jpg", (string) $image->encode('jpg', $quality));
$image->destroy();
}
$image = $image_manager->make($file)->heighten(83);
$disk->put("$dest_dir/{$photo_id}_s.jpg", (string) $image->encode('jpg', $quality));
$image->destroy();
$image = $image_manager->make($file)->widen(500);
$disk->put("$dest_dir/{$photo_id}_l.jpg", (string) $image->encode('jpg', $quality));
$image->destroy();
$photo = Photo::find($photo_id);
$photo->processed = true;
$photo->save();
$job->delete();
});
return $photo;
}
|
php
|
public static function upload($file)
{
$photo = self::create();
$image_manager = new ImageManager(['driver' => 'imagick']);
$disk = Storage::disk(config('mustard.storage.disk', 'local'));
if (!file_exists($file)) {
RuntimeException("File $file does not exist");
}
$dest_dir = config('mustard.storage.photo.dir', 'mustard/photos');
$quality = config('mustard.storage.photo.quality', 90);
$disk->makeDirectory($dest_dir);
$photo_id = $photo->getKey();
Queue::push(function ($job) use ($file, $quality, $dest_dir, $photo_id) {
if (!file_exists($file)) {
RuntimeException("File $file no longer exists");
}
$image_manager = new ImageManager(['driver' => 'imagick']);
$disk = Storage::disk(config('mustard.storage.disk', 'local'));
if ($file != "$dest_dir/$photo_id.jpg") {
$image = $image_manager->make($file);
$disk->put("$dest_dir/$photo_id.jpg", (string) $image->encode('jpg', $quality));
$image->destroy();
}
$image = $image_manager->make($file)->heighten(83);
$disk->put("$dest_dir/{$photo_id}_s.jpg", (string) $image->encode('jpg', $quality));
$image->destroy();
$image = $image_manager->make($file)->widen(500);
$disk->put("$dest_dir/{$photo_id}_l.jpg", (string) $image->encode('jpg', $quality));
$image->destroy();
$photo = Photo::find($photo_id);
$photo->processed = true;
$photo->save();
$job->delete();
});
return $photo;
}
|
[
"public",
"static",
"function",
"upload",
"(",
"$",
"file",
")",
"{",
"$",
"photo",
"=",
"self",
"::",
"create",
"(",
")",
";",
"$",
"image_manager",
"=",
"new",
"ImageManager",
"(",
"[",
"'driver'",
"=>",
"'imagick'",
"]",
")",
";",
"$",
"disk",
"=",
"Storage",
"::",
"disk",
"(",
"config",
"(",
"'mustard.storage.disk'",
",",
"'local'",
")",
")",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"file",
")",
")",
"{",
"RuntimeException",
"(",
"\"File $file does not exist\"",
")",
";",
"}",
"$",
"dest_dir",
"=",
"config",
"(",
"'mustard.storage.photo.dir'",
",",
"'mustard/photos'",
")",
";",
"$",
"quality",
"=",
"config",
"(",
"'mustard.storage.photo.quality'",
",",
"90",
")",
";",
"$",
"disk",
"->",
"makeDirectory",
"(",
"$",
"dest_dir",
")",
";",
"$",
"photo_id",
"=",
"$",
"photo",
"->",
"getKey",
"(",
")",
";",
"Queue",
"::",
"push",
"(",
"function",
"(",
"$",
"job",
")",
"use",
"(",
"$",
"file",
",",
"$",
"quality",
",",
"$",
"dest_dir",
",",
"$",
"photo_id",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"file",
")",
")",
"{",
"RuntimeException",
"(",
"\"File $file no longer exists\"",
")",
";",
"}",
"$",
"image_manager",
"=",
"new",
"ImageManager",
"(",
"[",
"'driver'",
"=>",
"'imagick'",
"]",
")",
";",
"$",
"disk",
"=",
"Storage",
"::",
"disk",
"(",
"config",
"(",
"'mustard.storage.disk'",
",",
"'local'",
")",
")",
";",
"if",
"(",
"$",
"file",
"!=",
"\"$dest_dir/$photo_id.jpg\"",
")",
"{",
"$",
"image",
"=",
"$",
"image_manager",
"->",
"make",
"(",
"$",
"file",
")",
";",
"$",
"disk",
"->",
"put",
"(",
"\"$dest_dir/$photo_id.jpg\"",
",",
"(",
"string",
")",
"$",
"image",
"->",
"encode",
"(",
"'jpg'",
",",
"$",
"quality",
")",
")",
";",
"$",
"image",
"->",
"destroy",
"(",
")",
";",
"}",
"$",
"image",
"=",
"$",
"image_manager",
"->",
"make",
"(",
"$",
"file",
")",
"->",
"heighten",
"(",
"83",
")",
";",
"$",
"disk",
"->",
"put",
"(",
"\"$dest_dir/{$photo_id}_s.jpg\"",
",",
"(",
"string",
")",
"$",
"image",
"->",
"encode",
"(",
"'jpg'",
",",
"$",
"quality",
")",
")",
";",
"$",
"image",
"->",
"destroy",
"(",
")",
";",
"$",
"image",
"=",
"$",
"image_manager",
"->",
"make",
"(",
"$",
"file",
")",
"->",
"widen",
"(",
"500",
")",
";",
"$",
"disk",
"->",
"put",
"(",
"\"$dest_dir/{$photo_id}_l.jpg\"",
",",
"(",
"string",
")",
"$",
"image",
"->",
"encode",
"(",
"'jpg'",
",",
"$",
"quality",
")",
")",
";",
"$",
"image",
"->",
"destroy",
"(",
")",
";",
"$",
"photo",
"=",
"Photo",
"::",
"find",
"(",
"$",
"photo_id",
")",
";",
"$",
"photo",
"->",
"processed",
"=",
"true",
";",
"$",
"photo",
"->",
"save",
"(",
")",
";",
"$",
"job",
"->",
"delete",
"(",
")",
";",
"}",
")",
";",
"return",
"$",
"photo",
";",
"}"
] |
Process a photo and create a record.
@param string $file
@return self
|
[
"Process",
"a",
"photo",
"and",
"create",
"a",
"record",
"."
] |
d3c799dbc3578e1e1022bb4eccae7a20e285ba06
|
https://github.com/hamjoint/mustard-media/blob/d3c799dbc3578e1e1022bb4eccae7a20e285ba06/src/lib/Photo.php#L192-L250
|
26,024
|
fivesqrd/mutex
|
src/Laravel/MutexServiceProvider.php
|
MutexServiceProvider.boot
|
public function boot()
{
$source = realpath($raw = __DIR__ . '/Config.php') ?: $raw;
if ($this->app instanceof LaravelApplication && $this->app->runningInConsole()) {
$this->publishes([$source => config_path('mutex.php')]);
} elseif ($this->app instanceof LumenApplication) {
$this->app->configure('mutex');
}
$this->mergeConfigFrom($source, 'mutex');
}
|
php
|
public function boot()
{
$source = realpath($raw = __DIR__ . '/Config.php') ?: $raw;
if ($this->app instanceof LaravelApplication && $this->app->runningInConsole()) {
$this->publishes([$source => config_path('mutex.php')]);
} elseif ($this->app instanceof LumenApplication) {
$this->app->configure('mutex');
}
$this->mergeConfigFrom($source, 'mutex');
}
|
[
"public",
"function",
"boot",
"(",
")",
"{",
"$",
"source",
"=",
"realpath",
"(",
"$",
"raw",
"=",
"__DIR__",
".",
"'/Config.php'",
")",
"?",
":",
"$",
"raw",
";",
"if",
"(",
"$",
"this",
"->",
"app",
"instanceof",
"LaravelApplication",
"&&",
"$",
"this",
"->",
"app",
"->",
"runningInConsole",
"(",
")",
")",
"{",
"$",
"this",
"->",
"publishes",
"(",
"[",
"$",
"source",
"=>",
"config_path",
"(",
"'mutex.php'",
")",
"]",
")",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"app",
"instanceof",
"LumenApplication",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"configure",
"(",
"'mutex'",
")",
";",
"}",
"$",
"this",
"->",
"mergeConfigFrom",
"(",
"$",
"source",
",",
"'mutex'",
")",
";",
"}"
] |
Bootstrap the configuration
@return void
|
[
"Bootstrap",
"the",
"configuration"
] |
46ec93b5503e5c142da97379e744e4006a717643
|
https://github.com/fivesqrd/mutex/blob/46ec93b5503e5c142da97379e744e4006a717643/src/Laravel/MutexServiceProvider.php#L22-L33
|
26,025
|
dsv-su/daisy-api-client-php
|
src/Employee.php
|
Employee.find
|
public static function find(array $query)
{
$employees = Client::get("employee", $query);
return array_map(function ($data) { return new self($data); }, $employees);
}
|
php
|
public static function find(array $query)
{
$employees = Client::get("employee", $query);
return array_map(function ($data) { return new self($data); }, $employees);
}
|
[
"public",
"static",
"function",
"find",
"(",
"array",
"$",
"query",
")",
"{",
"$",
"employees",
"=",
"Client",
"::",
"get",
"(",
"\"employee\"",
",",
"$",
"query",
")",
";",
"return",
"array_map",
"(",
"function",
"(",
"$",
"data",
")",
"{",
"return",
"new",
"self",
"(",
"$",
"data",
")",
";",
"}",
",",
"$",
"employees",
")",
";",
"}"
] |
Retrieve an array of Employee objects according to a search query.
@param array $query The query.
@return Employee[]
|
[
"Retrieve",
"an",
"array",
"of",
"Employee",
"objects",
"according",
"to",
"a",
"search",
"query",
"."
] |
aa6817ed45fdf3629c9683ea8a8e70a80f59b441
|
https://github.com/dsv-su/daisy-api-client-php/blob/aa6817ed45fdf3629c9683ea8a8e70a80f59b441/src/Employee.php#L62-L66
|
26,026
|
dsv-su/daisy-api-client-php
|
src/Employee.php
|
Employee.getWorkPhone
|
public function getWorkPhone()
{
if (!isset($this->workPhone)) {
$wp = trim($this->getRawWorkPhone());
if (empty($wp)) {
$this->workPhone = null;
} else {
if (preg_match('/^\+?[-\d\s()]+/', $wp, $matches)) {
$wp = $matches[0];
$wp = trim(str_replace(['(', ')'], '', $wp));
if (strlen(str_replace(' ', '', $wp)) === 4) {
$wp = self::phonePrefixForExt($wp) . $wp;
}
if ($wp[0] !== '0' && $wp[0] !== '+') {
$wp = '08' . $wp;
}
$phoneUtil = \libphonenumber\PhoneNumberUtil::getInstance();
try {
$this->workPhone = $phoneUtil->parse($wp, 'SE');
} catch (\libphonenumber\NumberParseException $e) {
$this->workPhone = $this->getRawWorkPhone();
}
} else {
$this->workPhone = $this->getRawWorkPhone();
}
}
}
return $this->workPhone;
}
|
php
|
public function getWorkPhone()
{
if (!isset($this->workPhone)) {
$wp = trim($this->getRawWorkPhone());
if (empty($wp)) {
$this->workPhone = null;
} else {
if (preg_match('/^\+?[-\d\s()]+/', $wp, $matches)) {
$wp = $matches[0];
$wp = trim(str_replace(['(', ')'], '', $wp));
if (strlen(str_replace(' ', '', $wp)) === 4) {
$wp = self::phonePrefixForExt($wp) . $wp;
}
if ($wp[0] !== '0' && $wp[0] !== '+') {
$wp = '08' . $wp;
}
$phoneUtil = \libphonenumber\PhoneNumberUtil::getInstance();
try {
$this->workPhone = $phoneUtil->parse($wp, 'SE');
} catch (\libphonenumber\NumberParseException $e) {
$this->workPhone = $this->getRawWorkPhone();
}
} else {
$this->workPhone = $this->getRawWorkPhone();
}
}
}
return $this->workPhone;
}
|
[
"public",
"function",
"getWorkPhone",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"workPhone",
")",
")",
"{",
"$",
"wp",
"=",
"trim",
"(",
"$",
"this",
"->",
"getRawWorkPhone",
"(",
")",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"wp",
")",
")",
"{",
"$",
"this",
"->",
"workPhone",
"=",
"null",
";",
"}",
"else",
"{",
"if",
"(",
"preg_match",
"(",
"'/^\\+?[-\\d\\s()]+/'",
",",
"$",
"wp",
",",
"$",
"matches",
")",
")",
"{",
"$",
"wp",
"=",
"$",
"matches",
"[",
"0",
"]",
";",
"$",
"wp",
"=",
"trim",
"(",
"str_replace",
"(",
"[",
"'('",
",",
"')'",
"]",
",",
"''",
",",
"$",
"wp",
")",
")",
";",
"if",
"(",
"strlen",
"(",
"str_replace",
"(",
"' '",
",",
"''",
",",
"$",
"wp",
")",
")",
"===",
"4",
")",
"{",
"$",
"wp",
"=",
"self",
"::",
"phonePrefixForExt",
"(",
"$",
"wp",
")",
".",
"$",
"wp",
";",
"}",
"if",
"(",
"$",
"wp",
"[",
"0",
"]",
"!==",
"'0'",
"&&",
"$",
"wp",
"[",
"0",
"]",
"!==",
"'+'",
")",
"{",
"$",
"wp",
"=",
"'08'",
".",
"$",
"wp",
";",
"}",
"$",
"phoneUtil",
"=",
"\\",
"libphonenumber",
"\\",
"PhoneNumberUtil",
"::",
"getInstance",
"(",
")",
";",
"try",
"{",
"$",
"this",
"->",
"workPhone",
"=",
"$",
"phoneUtil",
"->",
"parse",
"(",
"$",
"wp",
",",
"'SE'",
")",
";",
"}",
"catch",
"(",
"\\",
"libphonenumber",
"\\",
"NumberParseException",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"workPhone",
"=",
"$",
"this",
"->",
"getRawWorkPhone",
"(",
")",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"workPhone",
"=",
"$",
"this",
"->",
"getRawWorkPhone",
"(",
")",
";",
"}",
"}",
"}",
"return",
"$",
"this",
"->",
"workPhone",
";",
"}"
] |
Get work phone number of this employee. Try to parse it to a
PhoneNumber, otherwise return the raw string.
@return PhoneNumber|string|null The work phone number, or null if missing.
|
[
"Get",
"work",
"phone",
"number",
"of",
"this",
"employee",
".",
"Try",
"to",
"parse",
"it",
"to",
"a",
"PhoneNumber",
"otherwise",
"return",
"the",
"raw",
"string",
"."
] |
aa6817ed45fdf3629c9683ea8a8e70a80f59b441
|
https://github.com/dsv-su/daisy-api-client-php/blob/aa6817ed45fdf3629c9683ea8a8e70a80f59b441/src/Employee.php#L105-L133
|
26,027
|
PatrolServer/patrolsdk-php
|
lib/Software.php
|
Software.find
|
public function find($id, $scopes = []) {
return $this->_get('servers/' . $this->server_id . '/software/' . $id, null, $scopes);
}
|
php
|
public function find($id, $scopes = []) {
return $this->_get('servers/' . $this->server_id . '/software/' . $id, null, $scopes);
}
|
[
"public",
"function",
"find",
"(",
"$",
"id",
",",
"$",
"scopes",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"_get",
"(",
"'servers/'",
".",
"$",
"this",
"->",
"server_id",
".",
"'/software/'",
".",
"$",
"id",
",",
"null",
",",
"$",
"scopes",
")",
";",
"}"
] |
Gets a single software object on the server
@param integer $id
@param array $scopes optional
@return Software
|
[
"Gets",
"a",
"single",
"software",
"object",
"on",
"the",
"server"
] |
2451f0d2ba2bb5bc3d7e47cfc110f7f272620db2
|
https://github.com/PatrolServer/patrolsdk-php/blob/2451f0d2ba2bb5bc3d7e47cfc110f7f272620db2/lib/Software.php#L38-L40
|
26,028
|
PatrolServer/patrolsdk-php
|
lib/Software.php
|
Software.exploits
|
public function exploits($scopes = []) {
if (!$this->id) {
throw new Exception("The software has no ID, can\'t get exploits");
}
if (!$this->server_id) {
throw new Exception("The software has no server ID, can\'t get exploits");
}
$exploit = new Exploit($this->patrol);
$exploit->defaults([
'software_id' => $this->id,
'server_id' => $this->server_id
]);
return $exploit->all();
}
|
php
|
public function exploits($scopes = []) {
if (!$this->id) {
throw new Exception("The software has no ID, can\'t get exploits");
}
if (!$this->server_id) {
throw new Exception("The software has no server ID, can\'t get exploits");
}
$exploit = new Exploit($this->patrol);
$exploit->defaults([
'software_id' => $this->id,
'server_id' => $this->server_id
]);
return $exploit->all();
}
|
[
"public",
"function",
"exploits",
"(",
"$",
"scopes",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"id",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"The software has no ID, can\\'t get exploits\"",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"server_id",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"The software has no server ID, can\\'t get exploits\"",
")",
";",
"}",
"$",
"exploit",
"=",
"new",
"Exploit",
"(",
"$",
"this",
"->",
"patrol",
")",
";",
"$",
"exploit",
"->",
"defaults",
"(",
"[",
"'software_id'",
"=>",
"$",
"this",
"->",
"id",
",",
"'server_id'",
"=>",
"$",
"this",
"->",
"server_id",
"]",
")",
";",
"return",
"$",
"exploit",
"->",
"all",
"(",
")",
";",
"}"
] |
Gets a list of exploits from this software
@param array $scopes optional
@return array List of PatrolSdk\Exploit
|
[
"Gets",
"a",
"list",
"of",
"exploits",
"from",
"this",
"software"
] |
2451f0d2ba2bb5bc3d7e47cfc110f7f272620db2
|
https://github.com/PatrolServer/patrolsdk-php/blob/2451f0d2ba2bb5bc3d7e47cfc110f7f272620db2/lib/Software.php#L49-L66
|
26,029
|
PatrolServer/patrolsdk-php
|
lib/Software.php
|
Software.__valueSet
|
protected function __valueSet($key, $value) {
if ($key === "exploits") {
$casted = [];
foreach ($value as $exploit) {
$casted[] = new Exploit($this->patrol, $exploit);
}
return $casted;
}
return $value;
}
|
php
|
protected function __valueSet($key, $value) {
if ($key === "exploits") {
$casted = [];
foreach ($value as $exploit) {
$casted[] = new Exploit($this->patrol, $exploit);
}
return $casted;
}
return $value;
}
|
[
"protected",
"function",
"__valueSet",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"key",
"===",
"\"exploits\"",
")",
"{",
"$",
"casted",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"value",
"as",
"$",
"exploit",
")",
"{",
"$",
"casted",
"[",
"]",
"=",
"new",
"Exploit",
"(",
"$",
"this",
"->",
"patrol",
",",
"$",
"exploit",
")",
";",
"}",
"return",
"$",
"casted",
";",
"}",
"return",
"$",
"value",
";",
"}"
] |
This is a casting hook, when a new value is set in PatrolModel, this hook will be called,
in this case, when "exploits" are set in the model, cast them to a PatrolSdk\Exploit object
@param string $key
@param object $value
@return object $value Can be casted
|
[
"This",
"is",
"a",
"casting",
"hook",
"when",
"a",
"new",
"value",
"is",
"set",
"in",
"PatrolModel",
"this",
"hook",
"will",
"be",
"called",
"in",
"this",
"case",
"when",
"exploits",
"are",
"set",
"in",
"the",
"model",
"cast",
"them",
"to",
"a",
"PatrolSdk",
"\\",
"Exploit",
"object"
] |
2451f0d2ba2bb5bc3d7e47cfc110f7f272620db2
|
https://github.com/PatrolServer/patrolsdk-php/blob/2451f0d2ba2bb5bc3d7e47cfc110f7f272620db2/lib/Software.php#L77-L87
|
26,030
|
DaemonAlchemist/atp-core
|
src/ATPCore/Lessc.php
|
Lessc.deduplicate
|
protected function deduplicate($lines) {
$unique = array();
$comments = array();
foreach($lines as $line) {
if (strpos($line, '/*') === 0) {
$comments[] = $line;
continue;
}
if (!in_array($line, $unique)) {
$unique[] = $line;
}
array_splice($unique, array_search($line, $unique), 0, $comments);
$comments = array();
}
return array_merge($unique, $comments);
}
|
php
|
protected function deduplicate($lines) {
$unique = array();
$comments = array();
foreach($lines as $line) {
if (strpos($line, '/*') === 0) {
$comments[] = $line;
continue;
}
if (!in_array($line, $unique)) {
$unique[] = $line;
}
array_splice($unique, array_search($line, $unique), 0, $comments);
$comments = array();
}
return array_merge($unique, $comments);
}
|
[
"protected",
"function",
"deduplicate",
"(",
"$",
"lines",
")",
"{",
"$",
"unique",
"=",
"array",
"(",
")",
";",
"$",
"comments",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"lines",
"as",
"$",
"line",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"line",
",",
"'/*'",
")",
"===",
"0",
")",
"{",
"$",
"comments",
"[",
"]",
"=",
"$",
"line",
";",
"continue",
";",
"}",
"if",
"(",
"!",
"in_array",
"(",
"$",
"line",
",",
"$",
"unique",
")",
")",
"{",
"$",
"unique",
"[",
"]",
"=",
"$",
"line",
";",
"}",
"array_splice",
"(",
"$",
"unique",
",",
"array_search",
"(",
"$",
"line",
",",
"$",
"unique",
")",
",",
"0",
",",
"$",
"comments",
")",
";",
"$",
"comments",
"=",
"array",
"(",
")",
";",
"}",
"return",
"array_merge",
"(",
"$",
"unique",
",",
"$",
"comments",
")",
";",
"}"
] |
Deduplicate lines in a block. Comments are not deduplicated. If a
duplicate rule is detected, the comments immediately preceding each
occurence are consolidated.
|
[
"Deduplicate",
"lines",
"in",
"a",
"block",
".",
"Comments",
"are",
"not",
"deduplicated",
".",
"If",
"a",
"duplicate",
"rule",
"is",
"detected",
"the",
"comments",
"immediately",
"preceding",
"each",
"occurence",
"are",
"consolidated",
"."
] |
47efa734b882c27aa2a59fbcba34653b4d2125c7
|
https://github.com/DaemonAlchemist/atp-core/blob/47efa734b882c27aa2a59fbcba34653b4d2125c7/src/ATPCore/Lessc.php#L295-L311
|
26,031
|
DaemonAlchemist/atp-core
|
src/ATPCore/Lessc.php
|
Lessc.findBlocks
|
protected function findBlocks($searchIn, $path, $orderedArgs, $keywordArgs, $seen=array()) {
if ($searchIn == null) return null;
if (isset($seen[$searchIn->id])) return null;
$seen[$searchIn->id] = true;
$name = $path[0];
if (isset($searchIn->children[$name])) {
$blocks = $searchIn->children[$name];
if (count($path) == 1) {
$matches = $this->patternMatchAll($blocks, $orderedArgs, $keywordArgs, $seen);
if (!empty($matches)) {
// This will return all blocks that match in the closest
// scope that has any matching block, like lessjs
return $matches;
}
} else {
$matches = array();
foreach ($blocks as $subBlock) {
$subMatches = $this->findBlocks($subBlock,
array_slice($path, 1), $orderedArgs, $keywordArgs, $seen);
if (!is_null($subMatches)) {
foreach ($subMatches as $sm) {
$matches[] = $sm;
}
}
}
return count($matches) > 0 ? $matches : null;
}
}
if ($searchIn->parent === $searchIn) return null;
return $this->findBlocks($searchIn->parent, $path, $orderedArgs, $keywordArgs, $seen);
}
|
php
|
protected function findBlocks($searchIn, $path, $orderedArgs, $keywordArgs, $seen=array()) {
if ($searchIn == null) return null;
if (isset($seen[$searchIn->id])) return null;
$seen[$searchIn->id] = true;
$name = $path[0];
if (isset($searchIn->children[$name])) {
$blocks = $searchIn->children[$name];
if (count($path) == 1) {
$matches = $this->patternMatchAll($blocks, $orderedArgs, $keywordArgs, $seen);
if (!empty($matches)) {
// This will return all blocks that match in the closest
// scope that has any matching block, like lessjs
return $matches;
}
} else {
$matches = array();
foreach ($blocks as $subBlock) {
$subMatches = $this->findBlocks($subBlock,
array_slice($path, 1), $orderedArgs, $keywordArgs, $seen);
if (!is_null($subMatches)) {
foreach ($subMatches as $sm) {
$matches[] = $sm;
}
}
}
return count($matches) > 0 ? $matches : null;
}
}
if ($searchIn->parent === $searchIn) return null;
return $this->findBlocks($searchIn->parent, $path, $orderedArgs, $keywordArgs, $seen);
}
|
[
"protected",
"function",
"findBlocks",
"(",
"$",
"searchIn",
",",
"$",
"path",
",",
"$",
"orderedArgs",
",",
"$",
"keywordArgs",
",",
"$",
"seen",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"$",
"searchIn",
"==",
"null",
")",
"return",
"null",
";",
"if",
"(",
"isset",
"(",
"$",
"seen",
"[",
"$",
"searchIn",
"->",
"id",
"]",
")",
")",
"return",
"null",
";",
"$",
"seen",
"[",
"$",
"searchIn",
"->",
"id",
"]",
"=",
"true",
";",
"$",
"name",
"=",
"$",
"path",
"[",
"0",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"searchIn",
"->",
"children",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"blocks",
"=",
"$",
"searchIn",
"->",
"children",
"[",
"$",
"name",
"]",
";",
"if",
"(",
"count",
"(",
"$",
"path",
")",
"==",
"1",
")",
"{",
"$",
"matches",
"=",
"$",
"this",
"->",
"patternMatchAll",
"(",
"$",
"blocks",
",",
"$",
"orderedArgs",
",",
"$",
"keywordArgs",
",",
"$",
"seen",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"matches",
")",
")",
"{",
"// This will return all blocks that match in the closest\r",
"// scope that has any matching block, like lessjs\r",
"return",
"$",
"matches",
";",
"}",
"}",
"else",
"{",
"$",
"matches",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"blocks",
"as",
"$",
"subBlock",
")",
"{",
"$",
"subMatches",
"=",
"$",
"this",
"->",
"findBlocks",
"(",
"$",
"subBlock",
",",
"array_slice",
"(",
"$",
"path",
",",
"1",
")",
",",
"$",
"orderedArgs",
",",
"$",
"keywordArgs",
",",
"$",
"seen",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"subMatches",
")",
")",
"{",
"foreach",
"(",
"$",
"subMatches",
"as",
"$",
"sm",
")",
"{",
"$",
"matches",
"[",
"]",
"=",
"$",
"sm",
";",
"}",
"}",
"}",
"return",
"count",
"(",
"$",
"matches",
")",
">",
"0",
"?",
"$",
"matches",
":",
"null",
";",
"}",
"}",
"if",
"(",
"$",
"searchIn",
"->",
"parent",
"===",
"$",
"searchIn",
")",
"return",
"null",
";",
"return",
"$",
"this",
"->",
"findBlocks",
"(",
"$",
"searchIn",
"->",
"parent",
",",
"$",
"path",
",",
"$",
"orderedArgs",
",",
"$",
"keywordArgs",
",",
"$",
"seen",
")",
";",
"}"
] |
attempt to find blocks matched by path and args
|
[
"attempt",
"to",
"find",
"blocks",
"matched",
"by",
"path",
"and",
"args"
] |
47efa734b882c27aa2a59fbcba34653b4d2125c7
|
https://github.com/DaemonAlchemist/atp-core/blob/47efa734b882c27aa2a59fbcba34653b4d2125c7/src/ATPCore/Lessc.php#L597-L631
|
26,032
|
DaemonAlchemist/atp-core
|
src/ATPCore/Lessc.php
|
Lessc.lib_data_uri
|
protected function lib_data_uri($value) {
$mime = ($value[0] === 'list') ? $value[2][0][2] : null;
$url = ($value[0] === 'list') ? $value[2][1][2][0] : $value[2][0];
$fullpath = $this->findImport($url);
if($fullpath && ($fsize = filesize($fullpath)) !== false) {
// IE8 can't handle data uris larger than 32KB
if($fsize/1024 < 32) {
if(is_null($mime)) {
if(class_exists('finfo')) { // php 5.3+
$finfo = new finfo(FILEINFO_MIME);
$mime = explode('; ', $finfo->file($fullpath));
$mime = $mime[0];
} elseif(function_exists('mime_content_type')) { // PHP 5.2
$mime = mime_content_type($fullpath);
}
}
if(!is_null($mime)) // fallback if the mime type is still unknown
$url = sprintf('data:%s;base64,%s', $mime, base64_encode(file_get_contents($fullpath)));
}
}
return 'url("'.$url.'")';
}
|
php
|
protected function lib_data_uri($value) {
$mime = ($value[0] === 'list') ? $value[2][0][2] : null;
$url = ($value[0] === 'list') ? $value[2][1][2][0] : $value[2][0];
$fullpath = $this->findImport($url);
if($fullpath && ($fsize = filesize($fullpath)) !== false) {
// IE8 can't handle data uris larger than 32KB
if($fsize/1024 < 32) {
if(is_null($mime)) {
if(class_exists('finfo')) { // php 5.3+
$finfo = new finfo(FILEINFO_MIME);
$mime = explode('; ', $finfo->file($fullpath));
$mime = $mime[0];
} elseif(function_exists('mime_content_type')) { // PHP 5.2
$mime = mime_content_type($fullpath);
}
}
if(!is_null($mime)) // fallback if the mime type is still unknown
$url = sprintf('data:%s;base64,%s', $mime, base64_encode(file_get_contents($fullpath)));
}
}
return 'url("'.$url.'")';
}
|
[
"protected",
"function",
"lib_data_uri",
"(",
"$",
"value",
")",
"{",
"$",
"mime",
"=",
"(",
"$",
"value",
"[",
"0",
"]",
"===",
"'list'",
")",
"?",
"$",
"value",
"[",
"2",
"]",
"[",
"0",
"]",
"[",
"2",
"]",
":",
"null",
";",
"$",
"url",
"=",
"(",
"$",
"value",
"[",
"0",
"]",
"===",
"'list'",
")",
"?",
"$",
"value",
"[",
"2",
"]",
"[",
"1",
"]",
"[",
"2",
"]",
"[",
"0",
"]",
":",
"$",
"value",
"[",
"2",
"]",
"[",
"0",
"]",
";",
"$",
"fullpath",
"=",
"$",
"this",
"->",
"findImport",
"(",
"$",
"url",
")",
";",
"if",
"(",
"$",
"fullpath",
"&&",
"(",
"$",
"fsize",
"=",
"filesize",
"(",
"$",
"fullpath",
")",
")",
"!==",
"false",
")",
"{",
"// IE8 can't handle data uris larger than 32KB\r",
"if",
"(",
"$",
"fsize",
"/",
"1024",
"<",
"32",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"mime",
")",
")",
"{",
"if",
"(",
"class_exists",
"(",
"'finfo'",
")",
")",
"{",
"// php 5.3+\r",
"$",
"finfo",
"=",
"new",
"finfo",
"(",
"FILEINFO_MIME",
")",
";",
"$",
"mime",
"=",
"explode",
"(",
"'; '",
",",
"$",
"finfo",
"->",
"file",
"(",
"$",
"fullpath",
")",
")",
";",
"$",
"mime",
"=",
"$",
"mime",
"[",
"0",
"]",
";",
"}",
"elseif",
"(",
"function_exists",
"(",
"'mime_content_type'",
")",
")",
"{",
"// PHP 5.2\r",
"$",
"mime",
"=",
"mime_content_type",
"(",
"$",
"fullpath",
")",
";",
"}",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"mime",
")",
")",
"// fallback if the mime type is still unknown\r",
"$",
"url",
"=",
"sprintf",
"(",
"'data:%s;base64,%s'",
",",
"$",
"mime",
",",
"base64_encode",
"(",
"file_get_contents",
"(",
"$",
"fullpath",
")",
")",
")",
";",
"}",
"}",
"return",
"'url(\"'",
".",
"$",
"url",
".",
"'\")'",
";",
"}"
] |
Given an url, decide whether to output a regular link or the base64-encoded contents of the file
@param array $value either an argument list (two strings) or a single string
@return string formatted url(), either as a link or base64-encoded
|
[
"Given",
"an",
"url",
"decide",
"whether",
"to",
"output",
"a",
"regular",
"link",
"or",
"the",
"base64",
"-",
"encoded",
"contents",
"of",
"the",
"file"
] |
47efa734b882c27aa2a59fbcba34653b4d2125c7
|
https://github.com/DaemonAlchemist/atp-core/blob/47efa734b882c27aa2a59fbcba34653b4d2125c7/src/ATPCore/Lessc.php#L994-L1019
|
26,033
|
DaemonAlchemist/atp-core
|
src/ATPCore/Lessc.php
|
Lessc.toRGB
|
protected function toRGB($color) {
if ($color[0] == 'color') return $color;
$H = $color[1] / 360;
$S = $color[2] / 100;
$L = $color[3] / 100;
if ($S == 0) {
$r = $g = $b = $L;
} else {
$temp2 = $L < 0.5 ?
$L*(1.0 + $S) :
$L + $S - $L * $S;
$temp1 = 2.0 * $L - $temp2;
$r = $this->toRGB_helper($H + 1/3, $temp1, $temp2);
$g = $this->toRGB_helper($H, $temp1, $temp2);
$b = $this->toRGB_helper($H - 1/3, $temp1, $temp2);
}
// $out = array('color', round($r*255), round($g*255), round($b*255));
$out = array('color', $r*255, $g*255, $b*255);
if (count($color) > 4) $out[] = $color[4]; // copy alpha
return $out;
}
|
php
|
protected function toRGB($color) {
if ($color[0] == 'color') return $color;
$H = $color[1] / 360;
$S = $color[2] / 100;
$L = $color[3] / 100;
if ($S == 0) {
$r = $g = $b = $L;
} else {
$temp2 = $L < 0.5 ?
$L*(1.0 + $S) :
$L + $S - $L * $S;
$temp1 = 2.0 * $L - $temp2;
$r = $this->toRGB_helper($H + 1/3, $temp1, $temp2);
$g = $this->toRGB_helper($H, $temp1, $temp2);
$b = $this->toRGB_helper($H - 1/3, $temp1, $temp2);
}
// $out = array('color', round($r*255), round($g*255), round($b*255));
$out = array('color', $r*255, $g*255, $b*255);
if (count($color) > 4) $out[] = $color[4]; // copy alpha
return $out;
}
|
[
"protected",
"function",
"toRGB",
"(",
"$",
"color",
")",
"{",
"if",
"(",
"$",
"color",
"[",
"0",
"]",
"==",
"'color'",
")",
"return",
"$",
"color",
";",
"$",
"H",
"=",
"$",
"color",
"[",
"1",
"]",
"/",
"360",
";",
"$",
"S",
"=",
"$",
"color",
"[",
"2",
"]",
"/",
"100",
";",
"$",
"L",
"=",
"$",
"color",
"[",
"3",
"]",
"/",
"100",
";",
"if",
"(",
"$",
"S",
"==",
"0",
")",
"{",
"$",
"r",
"=",
"$",
"g",
"=",
"$",
"b",
"=",
"$",
"L",
";",
"}",
"else",
"{",
"$",
"temp2",
"=",
"$",
"L",
"<",
"0.5",
"?",
"$",
"L",
"*",
"(",
"1.0",
"+",
"$",
"S",
")",
":",
"$",
"L",
"+",
"$",
"S",
"-",
"$",
"L",
"*",
"$",
"S",
";",
"$",
"temp1",
"=",
"2.0",
"*",
"$",
"L",
"-",
"$",
"temp2",
";",
"$",
"r",
"=",
"$",
"this",
"->",
"toRGB_helper",
"(",
"$",
"H",
"+",
"1",
"/",
"3",
",",
"$",
"temp1",
",",
"$",
"temp2",
")",
";",
"$",
"g",
"=",
"$",
"this",
"->",
"toRGB_helper",
"(",
"$",
"H",
",",
"$",
"temp1",
",",
"$",
"temp2",
")",
";",
"$",
"b",
"=",
"$",
"this",
"->",
"toRGB_helper",
"(",
"$",
"H",
"-",
"1",
"/",
"3",
",",
"$",
"temp1",
",",
"$",
"temp2",
")",
";",
"}",
"// $out = array('color', round($r*255), round($g*255), round($b*255));\r",
"$",
"out",
"=",
"array",
"(",
"'color'",
",",
"$",
"r",
"*",
"255",
",",
"$",
"g",
"*",
"255",
",",
"$",
"b",
"*",
"255",
")",
";",
"if",
"(",
"count",
"(",
"$",
"color",
")",
">",
"4",
")",
"$",
"out",
"[",
"]",
"=",
"$",
"color",
"[",
"4",
"]",
";",
"// copy alpha\r",
"return",
"$",
"out",
";",
"}"
] |
Converts a hsl array into a color value in rgb.
Expects H to be in range of 0 to 360, S and L in 0 to 100
|
[
"Converts",
"a",
"hsl",
"array",
"into",
"a",
"color",
"value",
"in",
"rgb",
".",
"Expects",
"H",
"to",
"be",
"in",
"range",
"of",
"0",
"to",
"360",
"S",
"and",
"L",
"in",
"0",
"to",
"100"
] |
47efa734b882c27aa2a59fbcba34653b4d2125c7
|
https://github.com/DaemonAlchemist/atp-core/blob/47efa734b882c27aa2a59fbcba34653b4d2125c7/src/ATPCore/Lessc.php#L1362-L1387
|
26,034
|
DaemonAlchemist/atp-core
|
src/ATPCore/Lessc.php
|
Lessc.funcToColor
|
protected function funcToColor($func) {
$fname = $func[1];
if ($func[2][0] != 'list') return false; // need a list of arguments
$rawComponents = $func[2][2];
if ($fname == 'hsl' || $fname == 'hsla') {
$hsl = array('hsl');
$i = 0;
foreach ($rawComponents as $c) {
$val = $this->reduce($c);
$val = isset($val[1]) ? floatval($val[1]) : 0;
if ($i == 0) $clamp = 360;
elseif ($i < 3) $clamp = 100;
else $clamp = 1;
$hsl[] = $this->clamp($val, $clamp);
$i++;
}
while (count($hsl) < 4) $hsl[] = 0;
return $this->toRGB($hsl);
} elseif ($fname == 'rgb' || $fname == 'rgba') {
$components = array();
$i = 1;
foreach ($rawComponents as $c) {
$c = $this->reduce($c);
if ($i < 4) {
if ($c[0] == "number" && $c[2] == "%") {
$components[] = 255 * ($c[1] / 100);
} else {
$components[] = floatval($c[1]);
}
} elseif ($i == 4) {
if ($c[0] == "number" && $c[2] == "%") {
$components[] = 1.0 * ($c[1] / 100);
} else {
$components[] = floatval($c[1]);
}
} else break;
$i++;
}
while (count($components) < 3) $components[] = 0;
array_unshift($components, 'color');
return $this->fixColor($components);
}
return false;
}
|
php
|
protected function funcToColor($func) {
$fname = $func[1];
if ($func[2][0] != 'list') return false; // need a list of arguments
$rawComponents = $func[2][2];
if ($fname == 'hsl' || $fname == 'hsla') {
$hsl = array('hsl');
$i = 0;
foreach ($rawComponents as $c) {
$val = $this->reduce($c);
$val = isset($val[1]) ? floatval($val[1]) : 0;
if ($i == 0) $clamp = 360;
elseif ($i < 3) $clamp = 100;
else $clamp = 1;
$hsl[] = $this->clamp($val, $clamp);
$i++;
}
while (count($hsl) < 4) $hsl[] = 0;
return $this->toRGB($hsl);
} elseif ($fname == 'rgb' || $fname == 'rgba') {
$components = array();
$i = 1;
foreach ($rawComponents as $c) {
$c = $this->reduce($c);
if ($i < 4) {
if ($c[0] == "number" && $c[2] == "%") {
$components[] = 255 * ($c[1] / 100);
} else {
$components[] = floatval($c[1]);
}
} elseif ($i == 4) {
if ($c[0] == "number" && $c[2] == "%") {
$components[] = 1.0 * ($c[1] / 100);
} else {
$components[] = floatval($c[1]);
}
} else break;
$i++;
}
while (count($components) < 3) $components[] = 0;
array_unshift($components, 'color');
return $this->fixColor($components);
}
return false;
}
|
[
"protected",
"function",
"funcToColor",
"(",
"$",
"func",
")",
"{",
"$",
"fname",
"=",
"$",
"func",
"[",
"1",
"]",
";",
"if",
"(",
"$",
"func",
"[",
"2",
"]",
"[",
"0",
"]",
"!=",
"'list'",
")",
"return",
"false",
";",
"// need a list of arguments\r",
"$",
"rawComponents",
"=",
"$",
"func",
"[",
"2",
"]",
"[",
"2",
"]",
";",
"if",
"(",
"$",
"fname",
"==",
"'hsl'",
"||",
"$",
"fname",
"==",
"'hsla'",
")",
"{",
"$",
"hsl",
"=",
"array",
"(",
"'hsl'",
")",
";",
"$",
"i",
"=",
"0",
";",
"foreach",
"(",
"$",
"rawComponents",
"as",
"$",
"c",
")",
"{",
"$",
"val",
"=",
"$",
"this",
"->",
"reduce",
"(",
"$",
"c",
")",
";",
"$",
"val",
"=",
"isset",
"(",
"$",
"val",
"[",
"1",
"]",
")",
"?",
"floatval",
"(",
"$",
"val",
"[",
"1",
"]",
")",
":",
"0",
";",
"if",
"(",
"$",
"i",
"==",
"0",
")",
"$",
"clamp",
"=",
"360",
";",
"elseif",
"(",
"$",
"i",
"<",
"3",
")",
"$",
"clamp",
"=",
"100",
";",
"else",
"$",
"clamp",
"=",
"1",
";",
"$",
"hsl",
"[",
"]",
"=",
"$",
"this",
"->",
"clamp",
"(",
"$",
"val",
",",
"$",
"clamp",
")",
";",
"$",
"i",
"++",
";",
"}",
"while",
"(",
"count",
"(",
"$",
"hsl",
")",
"<",
"4",
")",
"$",
"hsl",
"[",
"]",
"=",
"0",
";",
"return",
"$",
"this",
"->",
"toRGB",
"(",
"$",
"hsl",
")",
";",
"}",
"elseif",
"(",
"$",
"fname",
"==",
"'rgb'",
"||",
"$",
"fname",
"==",
"'rgba'",
")",
"{",
"$",
"components",
"=",
"array",
"(",
")",
";",
"$",
"i",
"=",
"1",
";",
"foreach",
"(",
"$",
"rawComponents",
"as",
"$",
"c",
")",
"{",
"$",
"c",
"=",
"$",
"this",
"->",
"reduce",
"(",
"$",
"c",
")",
";",
"if",
"(",
"$",
"i",
"<",
"4",
")",
"{",
"if",
"(",
"$",
"c",
"[",
"0",
"]",
"==",
"\"number\"",
"&&",
"$",
"c",
"[",
"2",
"]",
"==",
"\"%\"",
")",
"{",
"$",
"components",
"[",
"]",
"=",
"255",
"*",
"(",
"$",
"c",
"[",
"1",
"]",
"/",
"100",
")",
";",
"}",
"else",
"{",
"$",
"components",
"[",
"]",
"=",
"floatval",
"(",
"$",
"c",
"[",
"1",
"]",
")",
";",
"}",
"}",
"elseif",
"(",
"$",
"i",
"==",
"4",
")",
"{",
"if",
"(",
"$",
"c",
"[",
"0",
"]",
"==",
"\"number\"",
"&&",
"$",
"c",
"[",
"2",
"]",
"==",
"\"%\"",
")",
"{",
"$",
"components",
"[",
"]",
"=",
"1.0",
"*",
"(",
"$",
"c",
"[",
"1",
"]",
"/",
"100",
")",
";",
"}",
"else",
"{",
"$",
"components",
"[",
"]",
"=",
"floatval",
"(",
"$",
"c",
"[",
"1",
"]",
")",
";",
"}",
"}",
"else",
"break",
";",
"$",
"i",
"++",
";",
"}",
"while",
"(",
"count",
"(",
"$",
"components",
")",
"<",
"3",
")",
"$",
"components",
"[",
"]",
"=",
"0",
";",
"array_unshift",
"(",
"$",
"components",
",",
"'color'",
")",
";",
"return",
"$",
"this",
"->",
"fixColor",
"(",
"$",
"components",
")",
";",
"}",
"return",
"false",
";",
"}"
] |
Convert the rgb, rgba, hsl color literals of function type
as returned by the parser into values of color type.
|
[
"Convert",
"the",
"rgb",
"rgba",
"hsl",
"color",
"literals",
"of",
"function",
"type",
"as",
"returned",
"by",
"the",
"parser",
"into",
"values",
"of",
"color",
"type",
"."
] |
47efa734b882c27aa2a59fbcba34653b4d2125c7
|
https://github.com/DaemonAlchemist/atp-core/blob/47efa734b882c27aa2a59fbcba34653b4d2125c7/src/ATPCore/Lessc.php#L1397-L1447
|
26,035
|
DaemonAlchemist/atp-core
|
src/ATPCore/Lessc.php
|
Lessc.get
|
protected function get($name) {
$current = $this->env;
$isArguments = $name == $this->vPrefix . 'arguments';
while ($current) {
if ($isArguments && isset($current->arguments)) {
return array('list', ' ', $current->arguments);
}
if (isset($current->store[$name]))
return $current->store[$name];
else {
$current = isset($current->storeParent) ?
$current->storeParent : $current->parent;
}
}
$this->throwError("variable $name is undefined");
}
|
php
|
protected function get($name) {
$current = $this->env;
$isArguments = $name == $this->vPrefix . 'arguments';
while ($current) {
if ($isArguments && isset($current->arguments)) {
return array('list', ' ', $current->arguments);
}
if (isset($current->store[$name]))
return $current->store[$name];
else {
$current = isset($current->storeParent) ?
$current->storeParent : $current->parent;
}
}
$this->throwError("variable $name is undefined");
}
|
[
"protected",
"function",
"get",
"(",
"$",
"name",
")",
"{",
"$",
"current",
"=",
"$",
"this",
"->",
"env",
";",
"$",
"isArguments",
"=",
"$",
"name",
"==",
"$",
"this",
"->",
"vPrefix",
".",
"'arguments'",
";",
"while",
"(",
"$",
"current",
")",
"{",
"if",
"(",
"$",
"isArguments",
"&&",
"isset",
"(",
"$",
"current",
"->",
"arguments",
")",
")",
"{",
"return",
"array",
"(",
"'list'",
",",
"' '",
",",
"$",
"current",
"->",
"arguments",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"current",
"->",
"store",
"[",
"$",
"name",
"]",
")",
")",
"return",
"$",
"current",
"->",
"store",
"[",
"$",
"name",
"]",
";",
"else",
"{",
"$",
"current",
"=",
"isset",
"(",
"$",
"current",
"->",
"storeParent",
")",
"?",
"$",
"current",
"->",
"storeParent",
":",
"$",
"current",
"->",
"parent",
";",
"}",
"}",
"$",
"this",
"->",
"throwError",
"(",
"\"variable $name is undefined\"",
")",
";",
"}"
] |
get the highest occurrence entry for a name
|
[
"get",
"the",
"highest",
"occurrence",
"entry",
"for",
"a",
"name"
] |
47efa734b882c27aa2a59fbcba34653b4d2125c7
|
https://github.com/DaemonAlchemist/atp-core/blob/47efa734b882c27aa2a59fbcba34653b4d2125c7/src/ATPCore/Lessc.php#L1837-L1855
|
26,036
|
DaemonAlchemist/atp-core
|
src/ATPCore/Lessc.php
|
lessc_parser.propertyValue
|
public function propertyValue(&$value, $keyName = null) {
$values = array();
if ($keyName !== null) $this->env->currentProperty = $keyName;
$s = null;
while ($this->expressionList($v)) {
$values[] = $v;
$s = $this->seek();
if (!$this->literal(',')) break;
}
if ($s) $this->seek($s);
if ($keyName !== null) unset($this->env->currentProperty);
if (count($values) == 0) return false;
$value = \ATPCore\Lessc::compressList($values, ', ');
return true;
}
|
php
|
public function propertyValue(&$value, $keyName = null) {
$values = array();
if ($keyName !== null) $this->env->currentProperty = $keyName;
$s = null;
while ($this->expressionList($v)) {
$values[] = $v;
$s = $this->seek();
if (!$this->literal(',')) break;
}
if ($s) $this->seek($s);
if ($keyName !== null) unset($this->env->currentProperty);
if (count($values) == 0) return false;
$value = \ATPCore\Lessc::compressList($values, ', ');
return true;
}
|
[
"public",
"function",
"propertyValue",
"(",
"&",
"$",
"value",
",",
"$",
"keyName",
"=",
"null",
")",
"{",
"$",
"values",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"keyName",
"!==",
"null",
")",
"$",
"this",
"->",
"env",
"->",
"currentProperty",
"=",
"$",
"keyName",
";",
"$",
"s",
"=",
"null",
";",
"while",
"(",
"$",
"this",
"->",
"expressionList",
"(",
"$",
"v",
")",
")",
"{",
"$",
"values",
"[",
"]",
"=",
"$",
"v",
";",
"$",
"s",
"=",
"$",
"this",
"->",
"seek",
"(",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"literal",
"(",
"','",
")",
")",
"break",
";",
"}",
"if",
"(",
"$",
"s",
")",
"$",
"this",
"->",
"seek",
"(",
"$",
"s",
")",
";",
"if",
"(",
"$",
"keyName",
"!==",
"null",
")",
"unset",
"(",
"$",
"this",
"->",
"env",
"->",
"currentProperty",
")",
";",
"if",
"(",
"count",
"(",
"$",
"values",
")",
"==",
"0",
")",
"return",
"false",
";",
"$",
"value",
"=",
"\\",
"ATPCore",
"\\",
"Lessc",
"::",
"compressList",
"(",
"$",
"values",
",",
"', '",
")",
";",
"return",
"true",
";",
"}"
] |
consume a list of values for a property
|
[
"consume",
"a",
"list",
"of",
"values",
"for",
"a",
"property"
] |
47efa734b882c27aa2a59fbcba34653b4d2125c7
|
https://github.com/DaemonAlchemist/atp-core/blob/47efa734b882c27aa2a59fbcba34653b4d2125c7/src/ATPCore/Lessc.php#L2671-L2691
|
26,037
|
DaemonAlchemist/atp-core
|
src/ATPCore/Lessc.php
|
lessc_parser.tag
|
protected function tag(&$tag, $simple = false) {
if ($simple)
$chars = '^@,:;{}\][>\(\) "\'';
else
$chars = '^@,;{}["\'';
$s = $this->seek();
$hasExpression = false;
$parts = array();
while ($this->tagBracket($parts, $hasExpression));
$oldWhite = $this->eatWhiteDefault;
$this->eatWhiteDefault = false;
while (true) {
if ($this->match('(['.$chars.'0-9]['.$chars.']*)', $m)) {
$parts[] = $m[1];
if ($simple) break;
while ($this->tagBracket($parts, $hasExpression));
continue;
}
if (isset($this->buffer[$this->count]) && $this->buffer[$this->count] == "@") {
if ($this->interpolation($interp)) {
$hasExpression = true;
$interp[2] = true; // don't unescape
$parts[] = $interp;
continue;
}
if ($this->literal("@")) {
$parts[] = "@";
continue;
}
}
if ($this->unit($unit)) { // for keyframes
$parts[] = $unit[1];
$parts[] = $unit[2];
continue;
}
break;
}
$this->eatWhiteDefault = $oldWhite;
if (!$parts) {
$this->seek($s);
return false;
}
if ($hasExpression) {
$tag = array("exp", array("string", "", $parts));
} else {
$tag = trim(implode($parts));
}
$this->whitespace();
return true;
}
|
php
|
protected function tag(&$tag, $simple = false) {
if ($simple)
$chars = '^@,:;{}\][>\(\) "\'';
else
$chars = '^@,;{}["\'';
$s = $this->seek();
$hasExpression = false;
$parts = array();
while ($this->tagBracket($parts, $hasExpression));
$oldWhite = $this->eatWhiteDefault;
$this->eatWhiteDefault = false;
while (true) {
if ($this->match('(['.$chars.'0-9]['.$chars.']*)', $m)) {
$parts[] = $m[1];
if ($simple) break;
while ($this->tagBracket($parts, $hasExpression));
continue;
}
if (isset($this->buffer[$this->count]) && $this->buffer[$this->count] == "@") {
if ($this->interpolation($interp)) {
$hasExpression = true;
$interp[2] = true; // don't unescape
$parts[] = $interp;
continue;
}
if ($this->literal("@")) {
$parts[] = "@";
continue;
}
}
if ($this->unit($unit)) { // for keyframes
$parts[] = $unit[1];
$parts[] = $unit[2];
continue;
}
break;
}
$this->eatWhiteDefault = $oldWhite;
if (!$parts) {
$this->seek($s);
return false;
}
if ($hasExpression) {
$tag = array("exp", array("string", "", $parts));
} else {
$tag = trim(implode($parts));
}
$this->whitespace();
return true;
}
|
[
"protected",
"function",
"tag",
"(",
"&",
"$",
"tag",
",",
"$",
"simple",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"simple",
")",
"$",
"chars",
"=",
"'^@,:;{}\\][>\\(\\) \"\\''",
";",
"else",
"$",
"chars",
"=",
"'^@,;{}[\"\\''",
";",
"$",
"s",
"=",
"$",
"this",
"->",
"seek",
"(",
")",
";",
"$",
"hasExpression",
"=",
"false",
";",
"$",
"parts",
"=",
"array",
"(",
")",
";",
"while",
"(",
"$",
"this",
"->",
"tagBracket",
"(",
"$",
"parts",
",",
"$",
"hasExpression",
")",
")",
";",
"$",
"oldWhite",
"=",
"$",
"this",
"->",
"eatWhiteDefault",
";",
"$",
"this",
"->",
"eatWhiteDefault",
"=",
"false",
";",
"while",
"(",
"true",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"match",
"(",
"'(['",
".",
"$",
"chars",
".",
"'0-9]['",
".",
"$",
"chars",
".",
"']*)'",
",",
"$",
"m",
")",
")",
"{",
"$",
"parts",
"[",
"]",
"=",
"$",
"m",
"[",
"1",
"]",
";",
"if",
"(",
"$",
"simple",
")",
"break",
";",
"while",
"(",
"$",
"this",
"->",
"tagBracket",
"(",
"$",
"parts",
",",
"$",
"hasExpression",
")",
")",
";",
"continue",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"buffer",
"[",
"$",
"this",
"->",
"count",
"]",
")",
"&&",
"$",
"this",
"->",
"buffer",
"[",
"$",
"this",
"->",
"count",
"]",
"==",
"\"@\"",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"interpolation",
"(",
"$",
"interp",
")",
")",
"{",
"$",
"hasExpression",
"=",
"true",
";",
"$",
"interp",
"[",
"2",
"]",
"=",
"true",
";",
"// don't unescape\r",
"$",
"parts",
"[",
"]",
"=",
"$",
"interp",
";",
"continue",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"literal",
"(",
"\"@\"",
")",
")",
"{",
"$",
"parts",
"[",
"]",
"=",
"\"@\"",
";",
"continue",
";",
"}",
"}",
"if",
"(",
"$",
"this",
"->",
"unit",
"(",
"$",
"unit",
")",
")",
"{",
"// for keyframes\r",
"$",
"parts",
"[",
"]",
"=",
"$",
"unit",
"[",
"1",
"]",
";",
"$",
"parts",
"[",
"]",
"=",
"$",
"unit",
"[",
"2",
"]",
";",
"continue",
";",
"}",
"break",
";",
"}",
"$",
"this",
"->",
"eatWhiteDefault",
"=",
"$",
"oldWhite",
";",
"if",
"(",
"!",
"$",
"parts",
")",
"{",
"$",
"this",
"->",
"seek",
"(",
"$",
"s",
")",
";",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"hasExpression",
")",
"{",
"$",
"tag",
"=",
"array",
"(",
"\"exp\"",
",",
"array",
"(",
"\"string\"",
",",
"\"\"",
",",
"$",
"parts",
")",
")",
";",
"}",
"else",
"{",
"$",
"tag",
"=",
"trim",
"(",
"implode",
"(",
"$",
"parts",
")",
")",
";",
"}",
"$",
"this",
"->",
"whitespace",
"(",
")",
";",
"return",
"true",
";",
"}"
] |
a space separated list of selectors
|
[
"a",
"space",
"separated",
"list",
"of",
"selectors"
] |
47efa734b882c27aa2a59fbcba34653b4d2125c7
|
https://github.com/DaemonAlchemist/atp-core/blob/47efa734b882c27aa2a59fbcba34653b4d2125c7/src/ATPCore/Lessc.php#L3215-L3276
|
26,038
|
DaemonAlchemist/atp-core
|
src/ATPCore/Lessc.php
|
lessc_parser.func
|
protected function func(&$func) {
$s = $this->seek();
if ($this->match('(%|[\w\-_][\w\-_:\.]+|[\w_])', $m) && $this->literal('(')) {
$fname = $m[1];
$sPreArgs = $this->seek();
$args = array();
while (true) {
$ss = $this->seek();
// this ugly nonsense is for ie filter properties
if ($this->keyword($name) && $this->literal('=') && $this->expressionList($value)) {
$args[] = array("string", "", array($name, "=", $value));
} else {
$this->seek($ss);
if ($this->expressionList($value)) {
$args[] = $value;
}
}
if (!$this->literal(',')) break;
}
$args = array('list', ',', $args);
if ($this->literal(')')) {
$func = array('function', $fname, $args);
return true;
} elseif ($fname == 'url') {
// couldn't parse and in url? treat as string
$this->seek($sPreArgs);
if ($this->openString(")", $string) && $this->literal(")")) {
$func = array('function', $fname, $string);
return true;
}
}
}
$this->seek($s);
return false;
}
|
php
|
protected function func(&$func) {
$s = $this->seek();
if ($this->match('(%|[\w\-_][\w\-_:\.]+|[\w_])', $m) && $this->literal('(')) {
$fname = $m[1];
$sPreArgs = $this->seek();
$args = array();
while (true) {
$ss = $this->seek();
// this ugly nonsense is for ie filter properties
if ($this->keyword($name) && $this->literal('=') && $this->expressionList($value)) {
$args[] = array("string", "", array($name, "=", $value));
} else {
$this->seek($ss);
if ($this->expressionList($value)) {
$args[] = $value;
}
}
if (!$this->literal(',')) break;
}
$args = array('list', ',', $args);
if ($this->literal(')')) {
$func = array('function', $fname, $args);
return true;
} elseif ($fname == 'url') {
// couldn't parse and in url? treat as string
$this->seek($sPreArgs);
if ($this->openString(")", $string) && $this->literal(")")) {
$func = array('function', $fname, $string);
return true;
}
}
}
$this->seek($s);
return false;
}
|
[
"protected",
"function",
"func",
"(",
"&",
"$",
"func",
")",
"{",
"$",
"s",
"=",
"$",
"this",
"->",
"seek",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"match",
"(",
"'(%|[\\w\\-_][\\w\\-_:\\.]+|[\\w_])'",
",",
"$",
"m",
")",
"&&",
"$",
"this",
"->",
"literal",
"(",
"'('",
")",
")",
"{",
"$",
"fname",
"=",
"$",
"m",
"[",
"1",
"]",
";",
"$",
"sPreArgs",
"=",
"$",
"this",
"->",
"seek",
"(",
")",
";",
"$",
"args",
"=",
"array",
"(",
")",
";",
"while",
"(",
"true",
")",
"{",
"$",
"ss",
"=",
"$",
"this",
"->",
"seek",
"(",
")",
";",
"// this ugly nonsense is for ie filter properties\r",
"if",
"(",
"$",
"this",
"->",
"keyword",
"(",
"$",
"name",
")",
"&&",
"$",
"this",
"->",
"literal",
"(",
"'='",
")",
"&&",
"$",
"this",
"->",
"expressionList",
"(",
"$",
"value",
")",
")",
"{",
"$",
"args",
"[",
"]",
"=",
"array",
"(",
"\"string\"",
",",
"\"\"",
",",
"array",
"(",
"$",
"name",
",",
"\"=\"",
",",
"$",
"value",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"seek",
"(",
"$",
"ss",
")",
";",
"if",
"(",
"$",
"this",
"->",
"expressionList",
"(",
"$",
"value",
")",
")",
"{",
"$",
"args",
"[",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"literal",
"(",
"','",
")",
")",
"break",
";",
"}",
"$",
"args",
"=",
"array",
"(",
"'list'",
",",
"','",
",",
"$",
"args",
")",
";",
"if",
"(",
"$",
"this",
"->",
"literal",
"(",
"')'",
")",
")",
"{",
"$",
"func",
"=",
"array",
"(",
"'function'",
",",
"$",
"fname",
",",
"$",
"args",
")",
";",
"return",
"true",
";",
"}",
"elseif",
"(",
"$",
"fname",
"==",
"'url'",
")",
"{",
"// couldn't parse and in url? treat as string\r",
"$",
"this",
"->",
"seek",
"(",
"$",
"sPreArgs",
")",
";",
"if",
"(",
"$",
"this",
"->",
"openString",
"(",
"\")\"",
",",
"$",
"string",
")",
"&&",
"$",
"this",
"->",
"literal",
"(",
"\")\"",
")",
")",
"{",
"$",
"func",
"=",
"array",
"(",
"'function'",
",",
"$",
"fname",
",",
"$",
"string",
")",
";",
"return",
"true",
";",
"}",
"}",
"}",
"$",
"this",
"->",
"seek",
"(",
"$",
"s",
")",
";",
"return",
"false",
";",
"}"
] |
a css function
|
[
"a",
"css",
"function"
] |
47efa734b882c27aa2a59fbcba34653b4d2125c7
|
https://github.com/DaemonAlchemist/atp-core/blob/47efa734b882c27aa2a59fbcba34653b4d2125c7/src/ATPCore/Lessc.php#L3279-L3319
|
26,039
|
DaemonAlchemist/atp-core
|
src/ATPCore/Lessc.php
|
lessc_parser.assign
|
protected function assign($name = null) {
if ($name) $this->currentProperty = $name;
return $this->literal(':') || $this->literal('=');
}
|
php
|
protected function assign($name = null) {
if ($name) $this->currentProperty = $name;
return $this->literal(':') || $this->literal('=');
}
|
[
"protected",
"function",
"assign",
"(",
"$",
"name",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"name",
")",
"$",
"this",
"->",
"currentProperty",
"=",
"$",
"name",
";",
"return",
"$",
"this",
"->",
"literal",
"(",
"':'",
")",
"||",
"$",
"this",
"->",
"literal",
"(",
"'='",
")",
";",
"}"
] |
Consume an assignment operator
Can optionally take a name that will be set to the current property name
|
[
"Consume",
"an",
"assignment",
"operator",
"Can",
"optionally",
"take",
"a",
"name",
"that",
"will",
"be",
"set",
"to",
"the",
"current",
"property",
"name"
] |
47efa734b882c27aa2a59fbcba34653b4d2125c7
|
https://github.com/DaemonAlchemist/atp-core/blob/47efa734b882c27aa2a59fbcba34653b4d2125c7/src/ATPCore/Lessc.php#L3344-L3347
|
26,040
|
DaemonAlchemist/atp-core
|
src/ATPCore/Lessc.php
|
lessc_parser.append
|
protected function append($prop, $pos = null) {
if ($pos !== null) $prop[-1] = $pos;
$this->env->props[] = $prop;
}
|
php
|
protected function append($prop, $pos = null) {
if ($pos !== null) $prop[-1] = $pos;
$this->env->props[] = $prop;
}
|
[
"protected",
"function",
"append",
"(",
"$",
"prop",
",",
"$",
"pos",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"pos",
"!==",
"null",
")",
"$",
"prop",
"[",
"-",
"1",
"]",
"=",
"$",
"pos",
";",
"$",
"this",
"->",
"env",
"->",
"props",
"[",
"]",
"=",
"$",
"prop",
";",
"}"
] |
append a property to the current block
|
[
"append",
"a",
"property",
"to",
"the",
"current",
"block"
] |
47efa734b882c27aa2a59fbcba34653b4d2125c7
|
https://github.com/DaemonAlchemist/atp-core/blob/47efa734b882c27aa2a59fbcba34653b4d2125c7/src/ATPCore/Lessc.php#L3584-L3587
|
26,041
|
pdyn/httpclient
|
HttpClientResponse.php
|
HttpClientResponse.instance_from_curl
|
public static function instance_from_curl($ch, $body) {
$transfer_info = curl_getinfo($ch);
$statuscode = (!empty($transfer_info['http_code'])) ? (int)$transfer_info['http_code'] : 404;
$errors = [];
$err = static::decode_error_code(curl_errno($ch));
if ($err !== 'SUCCESS') {
$errors[] = $err;
}
$mime = (!empty($transfer_info['content_type'])) ? $transfer_info['content_type'] : 'text/plain';
return new HttpClientResponse($statuscode, $mime, $body, $errors);
}
|
php
|
public static function instance_from_curl($ch, $body) {
$transfer_info = curl_getinfo($ch);
$statuscode = (!empty($transfer_info['http_code'])) ? (int)$transfer_info['http_code'] : 404;
$errors = [];
$err = static::decode_error_code(curl_errno($ch));
if ($err !== 'SUCCESS') {
$errors[] = $err;
}
$mime = (!empty($transfer_info['content_type'])) ? $transfer_info['content_type'] : 'text/plain';
return new HttpClientResponse($statuscode, $mime, $body, $errors);
}
|
[
"public",
"static",
"function",
"instance_from_curl",
"(",
"$",
"ch",
",",
"$",
"body",
")",
"{",
"$",
"transfer_info",
"=",
"curl_getinfo",
"(",
"$",
"ch",
")",
";",
"$",
"statuscode",
"=",
"(",
"!",
"empty",
"(",
"$",
"transfer_info",
"[",
"'http_code'",
"]",
")",
")",
"?",
"(",
"int",
")",
"$",
"transfer_info",
"[",
"'http_code'",
"]",
":",
"404",
";",
"$",
"errors",
"=",
"[",
"]",
";",
"$",
"err",
"=",
"static",
"::",
"decode_error_code",
"(",
"curl_errno",
"(",
"$",
"ch",
")",
")",
";",
"if",
"(",
"$",
"err",
"!==",
"'SUCCESS'",
")",
"{",
"$",
"errors",
"[",
"]",
"=",
"$",
"err",
";",
"}",
"$",
"mime",
"=",
"(",
"!",
"empty",
"(",
"$",
"transfer_info",
"[",
"'content_type'",
"]",
")",
")",
"?",
"$",
"transfer_info",
"[",
"'content_type'",
"]",
":",
"'text/plain'",
";",
"return",
"new",
"HttpClientResponse",
"(",
"$",
"statuscode",
",",
"$",
"mime",
",",
"$",
"body",
",",
"$",
"errors",
")",
";",
"}"
] |
Create an instance from a curl handle and body.
@param resource $ch An active curl handle.
@param string $body The returned body.
@return HttpClientResponse A response object.
|
[
"Create",
"an",
"instance",
"from",
"a",
"curl",
"handle",
"and",
"body",
"."
] |
9714796945db4908605be6f19c31ded1ee813c70
|
https://github.com/pdyn/httpclient/blob/9714796945db4908605be6f19c31ded1ee813c70/HttpClientResponse.php#L77-L90
|
26,042
|
pdyn/httpclient
|
HttpClientResponse.php
|
HttpClientResponse.get_debug_string
|
public function get_debug_string() {
return 'status: '.$this->statuscode.' body:'.htmlentities($this->body).' errors: '.print_r($this->errors, true);
}
|
php
|
public function get_debug_string() {
return 'status: '.$this->statuscode.' body:'.htmlentities($this->body).' errors: '.print_r($this->errors, true);
}
|
[
"public",
"function",
"get_debug_string",
"(",
")",
"{",
"return",
"'status: '",
".",
"$",
"this",
"->",
"statuscode",
".",
"' body:'",
".",
"htmlentities",
"(",
"$",
"this",
"->",
"body",
")",
".",
"' errors: '",
".",
"print_r",
"(",
"$",
"this",
"->",
"errors",
",",
"true",
")",
";",
"}"
] |
Get a string with some basic information about the request. Usually put into the logs.
@return string A string containing debug information.
|
[
"Get",
"a",
"string",
"with",
"some",
"basic",
"information",
"about",
"the",
"request",
".",
"Usually",
"put",
"into",
"the",
"logs",
"."
] |
9714796945db4908605be6f19c31ded1ee813c70
|
https://github.com/pdyn/httpclient/blob/9714796945db4908605be6f19c31ded1ee813c70/HttpClientResponse.php#L106-L108
|
26,043
|
pdyn/httpclient
|
HttpClientResponse.php
|
HttpClientResponse.status_type
|
public function status_type() {
$status_code_type = (!empty($this->statuscode))
? (int)mb_substr($this->statuscode, 0, 1)
: 0;
if ($status_code_type === 1) {
$status_type = 'informational';
} elseif ($status_code_type === 2) {
$status_type = 'success';
} elseif ($status_code_type === 3) {
$status_type = 'redirect';
} elseif ($status_code_type === 4) {
$status_type = 'client_err';
} elseif ($status_code_type === 5) {
$status_type = 'server_err';
} else {
$status_type = 'bad';
}
return $status_type;
}
|
php
|
public function status_type() {
$status_code_type = (!empty($this->statuscode))
? (int)mb_substr($this->statuscode, 0, 1)
: 0;
if ($status_code_type === 1) {
$status_type = 'informational';
} elseif ($status_code_type === 2) {
$status_type = 'success';
} elseif ($status_code_type === 3) {
$status_type = 'redirect';
} elseif ($status_code_type === 4) {
$status_type = 'client_err';
} elseif ($status_code_type === 5) {
$status_type = 'server_err';
} else {
$status_type = 'bad';
}
return $status_type;
}
|
[
"public",
"function",
"status_type",
"(",
")",
"{",
"$",
"status_code_type",
"=",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"statuscode",
")",
")",
"?",
"(",
"int",
")",
"mb_substr",
"(",
"$",
"this",
"->",
"statuscode",
",",
"0",
",",
"1",
")",
":",
"0",
";",
"if",
"(",
"$",
"status_code_type",
"===",
"1",
")",
"{",
"$",
"status_type",
"=",
"'informational'",
";",
"}",
"elseif",
"(",
"$",
"status_code_type",
"===",
"2",
")",
"{",
"$",
"status_type",
"=",
"'success'",
";",
"}",
"elseif",
"(",
"$",
"status_code_type",
"===",
"3",
")",
"{",
"$",
"status_type",
"=",
"'redirect'",
";",
"}",
"elseif",
"(",
"$",
"status_code_type",
"===",
"4",
")",
"{",
"$",
"status_type",
"=",
"'client_err'",
";",
"}",
"elseif",
"(",
"$",
"status_code_type",
"===",
"5",
")",
"{",
"$",
"status_type",
"=",
"'server_err'",
";",
"}",
"else",
"{",
"$",
"status_type",
"=",
"'bad'",
";",
"}",
"return",
"$",
"status_type",
";",
"}"
] |
Get the status type.
@return string The status type.
|
[
"Get",
"the",
"status",
"type",
"."
] |
9714796945db4908605be6f19c31ded1ee813c70
|
https://github.com/pdyn/httpclient/blob/9714796945db4908605be6f19c31ded1ee813c70/HttpClientResponse.php#L115-L134
|
26,044
|
DavidePastore/paris-model-generator
|
src/DavidePastore/ParisModelGenerator/ParisGeneratorCommand.php
|
ParisGeneratorCommand.generateCode
|
private function generateCode($className, $primaryKey){
$tags = $this->config->getTags();
$class = new ClassGenerator();
$docblock = DocBlockGenerator::fromArray(array(
'shortDescription' => ucfirst($className) .' model class',
'longDescription' => 'This is a model class generated with DavidePastore\ParisModelGenerator.',
'tags' => $tags
));
$idColumn = new PropertyGenerator('_id_column');
$idColumn
->setStatic(true)
->setDefaultValue($primaryKey);
$table = new PropertyGenerator('_table');
$table
->setStatic(true)
->setDefaultValue($className);
$tableUseShortName = new PropertyGenerator('_table_use_short_name');
$tableUseShortName
->setStatic(true)
->setDefaultValue(true);
$namespace = $this->config->getNamespace();
$extendedClass = '\Model';
if(isset($namespace) && !empty($namespace)){
$class->setNamespaceName($this->config->getNamespace());
}
$class
->setName(ucfirst($className))
->setDocblock($docblock)
->setExtendedClass($extendedClass)
->addProperties(array(
$idColumn,
$table,
$tableUseShortName
));
$file = FileGenerator::fromArray(array(
'classes' => array($class),
'docblock' => DocBlockGenerator::fromArray(array(
'shortDescription' => ucfirst($className) . ' class file',
'longDescription' => null,
'tags' => $tags
))
));
$generatedCode = $file->generate();
$directory = $this->config->getDestinationFolder() . $namespace;
if(!file_exists($directory)){
mkdir($directory, 0777, true);
}
$filePath = $directory . "/" . $class->getName() . ".php";
if(file_exists($filePath) && !$this->force){
$helper = $this->getHelper('question');
$realPath = realpath($filePath);
$this->output->writeln("\n");
$question = new ConfirmationQuestion('Do you want to overwrite the file "' . $realPath . '"?', false);
if ($helper->ask($this->input, $this->output, $question)) {
$this->writeInFile($filePath, $generatedCode);
}
}
else {
$this->writeInFile($filePath, $generatedCode);
}
}
|
php
|
private function generateCode($className, $primaryKey){
$tags = $this->config->getTags();
$class = new ClassGenerator();
$docblock = DocBlockGenerator::fromArray(array(
'shortDescription' => ucfirst($className) .' model class',
'longDescription' => 'This is a model class generated with DavidePastore\ParisModelGenerator.',
'tags' => $tags
));
$idColumn = new PropertyGenerator('_id_column');
$idColumn
->setStatic(true)
->setDefaultValue($primaryKey);
$table = new PropertyGenerator('_table');
$table
->setStatic(true)
->setDefaultValue($className);
$tableUseShortName = new PropertyGenerator('_table_use_short_name');
$tableUseShortName
->setStatic(true)
->setDefaultValue(true);
$namespace = $this->config->getNamespace();
$extendedClass = '\Model';
if(isset($namespace) && !empty($namespace)){
$class->setNamespaceName($this->config->getNamespace());
}
$class
->setName(ucfirst($className))
->setDocblock($docblock)
->setExtendedClass($extendedClass)
->addProperties(array(
$idColumn,
$table,
$tableUseShortName
));
$file = FileGenerator::fromArray(array(
'classes' => array($class),
'docblock' => DocBlockGenerator::fromArray(array(
'shortDescription' => ucfirst($className) . ' class file',
'longDescription' => null,
'tags' => $tags
))
));
$generatedCode = $file->generate();
$directory = $this->config->getDestinationFolder() . $namespace;
if(!file_exists($directory)){
mkdir($directory, 0777, true);
}
$filePath = $directory . "/" . $class->getName() . ".php";
if(file_exists($filePath) && !$this->force){
$helper = $this->getHelper('question');
$realPath = realpath($filePath);
$this->output->writeln("\n");
$question = new ConfirmationQuestion('Do you want to overwrite the file "' . $realPath . '"?', false);
if ($helper->ask($this->input, $this->output, $question)) {
$this->writeInFile($filePath, $generatedCode);
}
}
else {
$this->writeInFile($filePath, $generatedCode);
}
}
|
[
"private",
"function",
"generateCode",
"(",
"$",
"className",
",",
"$",
"primaryKey",
")",
"{",
"$",
"tags",
"=",
"$",
"this",
"->",
"config",
"->",
"getTags",
"(",
")",
";",
"$",
"class",
"=",
"new",
"ClassGenerator",
"(",
")",
";",
"$",
"docblock",
"=",
"DocBlockGenerator",
"::",
"fromArray",
"(",
"array",
"(",
"'shortDescription'",
"=>",
"ucfirst",
"(",
"$",
"className",
")",
".",
"' model class'",
",",
"'longDescription'",
"=>",
"'This is a model class generated with DavidePastore\\ParisModelGenerator.'",
",",
"'tags'",
"=>",
"$",
"tags",
")",
")",
";",
"$",
"idColumn",
"=",
"new",
"PropertyGenerator",
"(",
"'_id_column'",
")",
";",
"$",
"idColumn",
"->",
"setStatic",
"(",
"true",
")",
"->",
"setDefaultValue",
"(",
"$",
"primaryKey",
")",
";",
"$",
"table",
"=",
"new",
"PropertyGenerator",
"(",
"'_table'",
")",
";",
"$",
"table",
"->",
"setStatic",
"(",
"true",
")",
"->",
"setDefaultValue",
"(",
"$",
"className",
")",
";",
"$",
"tableUseShortName",
"=",
"new",
"PropertyGenerator",
"(",
"'_table_use_short_name'",
")",
";",
"$",
"tableUseShortName",
"->",
"setStatic",
"(",
"true",
")",
"->",
"setDefaultValue",
"(",
"true",
")",
";",
"$",
"namespace",
"=",
"$",
"this",
"->",
"config",
"->",
"getNamespace",
"(",
")",
";",
"$",
"extendedClass",
"=",
"'\\Model'",
";",
"if",
"(",
"isset",
"(",
"$",
"namespace",
")",
"&&",
"!",
"empty",
"(",
"$",
"namespace",
")",
")",
"{",
"$",
"class",
"->",
"setNamespaceName",
"(",
"$",
"this",
"->",
"config",
"->",
"getNamespace",
"(",
")",
")",
";",
"}",
"$",
"class",
"->",
"setName",
"(",
"ucfirst",
"(",
"$",
"className",
")",
")",
"->",
"setDocblock",
"(",
"$",
"docblock",
")",
"->",
"setExtendedClass",
"(",
"$",
"extendedClass",
")",
"->",
"addProperties",
"(",
"array",
"(",
"$",
"idColumn",
",",
"$",
"table",
",",
"$",
"tableUseShortName",
")",
")",
";",
"$",
"file",
"=",
"FileGenerator",
"::",
"fromArray",
"(",
"array",
"(",
"'classes'",
"=>",
"array",
"(",
"$",
"class",
")",
",",
"'docblock'",
"=>",
"DocBlockGenerator",
"::",
"fromArray",
"(",
"array",
"(",
"'shortDescription'",
"=>",
"ucfirst",
"(",
"$",
"className",
")",
".",
"' class file'",
",",
"'longDescription'",
"=>",
"null",
",",
"'tags'",
"=>",
"$",
"tags",
")",
")",
")",
")",
";",
"$",
"generatedCode",
"=",
"$",
"file",
"->",
"generate",
"(",
")",
";",
"$",
"directory",
"=",
"$",
"this",
"->",
"config",
"->",
"getDestinationFolder",
"(",
")",
".",
"$",
"namespace",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"directory",
")",
")",
"{",
"mkdir",
"(",
"$",
"directory",
",",
"0777",
",",
"true",
")",
";",
"}",
"$",
"filePath",
"=",
"$",
"directory",
".",
"\"/\"",
".",
"$",
"class",
"->",
"getName",
"(",
")",
".",
"\".php\"",
";",
"if",
"(",
"file_exists",
"(",
"$",
"filePath",
")",
"&&",
"!",
"$",
"this",
"->",
"force",
")",
"{",
"$",
"helper",
"=",
"$",
"this",
"->",
"getHelper",
"(",
"'question'",
")",
";",
"$",
"realPath",
"=",
"realpath",
"(",
"$",
"filePath",
")",
";",
"$",
"this",
"->",
"output",
"->",
"writeln",
"(",
"\"\\n\"",
")",
";",
"$",
"question",
"=",
"new",
"ConfirmationQuestion",
"(",
"'Do you want to overwrite the file \"'",
".",
"$",
"realPath",
".",
"'\"?'",
",",
"false",
")",
";",
"if",
"(",
"$",
"helper",
"->",
"ask",
"(",
"$",
"this",
"->",
"input",
",",
"$",
"this",
"->",
"output",
",",
"$",
"question",
")",
")",
"{",
"$",
"this",
"->",
"writeInFile",
"(",
"$",
"filePath",
",",
"$",
"generatedCode",
")",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"writeInFile",
"(",
"$",
"filePath",
",",
"$",
"generatedCode",
")",
";",
"}",
"}"
] |
Generate the code for the given className and primaryKey and write it in a file.
@param string $className The class name.
@param string $primaryKey The primary key.
|
[
"Generate",
"the",
"code",
"for",
"the",
"given",
"className",
"and",
"primaryKey",
"and",
"write",
"it",
"in",
"a",
"file",
"."
] |
cd056dd7a2218b1c56fa17dcc6311e01a2570030
|
https://github.com/DavidePastore/paris-model-generator/blob/cd056dd7a2218b1c56fa17dcc6311e01a2570030/src/DavidePastore/ParisModelGenerator/ParisGeneratorCommand.php#L204-L282
|
26,045
|
ScaraMVC/Framework
|
src/Scara/Session/Cookie.php
|
Cookie.set
|
public function set($key, $value, $expire = 3600, $path = '/')
{
if ($expire == false) {
setcookie($key, serialize($value), false, $path);
} else {
setcookie($key, serialize($value), time() + $expire, $path);
}
}
|
php
|
public function set($key, $value, $expire = 3600, $path = '/')
{
if ($expire == false) {
setcookie($key, serialize($value), false, $path);
} else {
setcookie($key, serialize($value), time() + $expire, $path);
}
}
|
[
"public",
"function",
"set",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"expire",
"=",
"3600",
",",
"$",
"path",
"=",
"'/'",
")",
"{",
"if",
"(",
"$",
"expire",
"==",
"false",
")",
"{",
"setcookie",
"(",
"$",
"key",
",",
"serialize",
"(",
"$",
"value",
")",
",",
"false",
",",
"$",
"path",
")",
";",
"}",
"else",
"{",
"setcookie",
"(",
"$",
"key",
",",
"serialize",
"(",
"$",
"value",
")",
",",
"time",
"(",
")",
"+",
"$",
"expire",
",",
"$",
"path",
")",
";",
"}",
"}"
] |
Adds to the session.
@param string $key - Key given to session
@param string $value - Value given to session's $key
@param mixed $expire - Sets expiration of cookie
@param stirng $path - The path the cookie should be set to
@return mixed
|
[
"Adds",
"to",
"the",
"session",
"."
] |
199b08b45fadf5dae14ac4732af03b36e15bbef2
|
https://github.com/ScaraMVC/Framework/blob/199b08b45fadf5dae14ac4732af03b36e15bbef2/src/Scara/Session/Cookie.php#L32-L39
|
26,046
|
graze/data-node
|
src/NodeCollection.php
|
NodeCollection.first
|
public function first(callable $fn = null, $default = null)
{
if (is_null($fn)) {
return count($this->items) > 0 ? reset($this->items) : $default;
}
foreach ($this->getIterator() as $value) {
if (call_user_func($fn, $value)) {
return $value;
}
}
return $default;
}
|
php
|
public function first(callable $fn = null, $default = null)
{
if (is_null($fn)) {
return count($this->items) > 0 ? reset($this->items) : $default;
}
foreach ($this->getIterator() as $value) {
if (call_user_func($fn, $value)) {
return $value;
}
}
return $default;
}
|
[
"public",
"function",
"first",
"(",
"callable",
"$",
"fn",
"=",
"null",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"fn",
")",
")",
"{",
"return",
"count",
"(",
"$",
"this",
"->",
"items",
")",
">",
"0",
"?",
"reset",
"(",
"$",
"this",
"->",
"items",
")",
":",
"$",
"default",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"getIterator",
"(",
")",
"as",
"$",
"value",
")",
"{",
"if",
"(",
"call_user_func",
"(",
"$",
"fn",
",",
"$",
"value",
")",
")",
"{",
"return",
"$",
"value",
";",
"}",
"}",
"return",
"$",
"default",
";",
"}"
] |
Retrieve the first element that matches the optional callback
@param callable|null $fn
@param mixed|null $default
@return mixed|null
|
[
"Retrieve",
"the",
"first",
"element",
"that",
"matches",
"the",
"optional",
"callback"
] |
e604d8062b1e18046f23c6dc20341b368e88697e
|
https://github.com/graze/data-node/blob/e604d8062b1e18046f23c6dc20341b368e88697e/src/NodeCollection.php#L92-L105
|
26,047
|
graze/data-node
|
src/NodeCollection.php
|
NodeCollection.last
|
public function last(callable $fn = null, $default = null)
{
if (is_null($fn)) {
return count($this->items) > 0 ? end($this->items) : $default;
}
foreach (array_reverse($this->items) as $value) {
if (call_user_func($fn, $value)) {
return $value;
}
}
return $default;
}
|
php
|
public function last(callable $fn = null, $default = null)
{
if (is_null($fn)) {
return count($this->items) > 0 ? end($this->items) : $default;
}
foreach (array_reverse($this->items) as $value) {
if (call_user_func($fn, $value)) {
return $value;
}
}
return $default;
}
|
[
"public",
"function",
"last",
"(",
"callable",
"$",
"fn",
"=",
"null",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"fn",
")",
")",
"{",
"return",
"count",
"(",
"$",
"this",
"->",
"items",
")",
">",
"0",
"?",
"end",
"(",
"$",
"this",
"->",
"items",
")",
":",
"$",
"default",
";",
"}",
"foreach",
"(",
"array_reverse",
"(",
"$",
"this",
"->",
"items",
")",
"as",
"$",
"value",
")",
"{",
"if",
"(",
"call_user_func",
"(",
"$",
"fn",
",",
"$",
"value",
")",
")",
"{",
"return",
"$",
"value",
";",
"}",
"}",
"return",
"$",
"default",
";",
"}"
] |
Receive the last element that matches the optional callback
@param callable|null $fn
@param mixed|null $default
@return mixed|null
|
[
"Receive",
"the",
"last",
"element",
"that",
"matches",
"the",
"optional",
"callback"
] |
e604d8062b1e18046f23c6dc20341b368e88697e
|
https://github.com/graze/data-node/blob/e604d8062b1e18046f23c6dc20341b368e88697e/src/NodeCollection.php#L115-L128
|
26,048
|
tdebatty/php-noorm
|
src/noorm/Persistent.php
|
Persistent.One
|
public static function One($id) {
$class = get_called_class();
if (! isset(self::$refs[$class][$id])) {
$file = self::File($id);
$obj = unserialize(file_get_contents($file));
self::$refs[$class][$id] = $obj;
}
return self::$refs[$class][$id];
}
|
php
|
public static function One($id) {
$class = get_called_class();
if (! isset(self::$refs[$class][$id])) {
$file = self::File($id);
$obj = unserialize(file_get_contents($file));
self::$refs[$class][$id] = $obj;
}
return self::$refs[$class][$id];
}
|
[
"public",
"static",
"function",
"One",
"(",
"$",
"id",
")",
"{",
"$",
"class",
"=",
"get_called_class",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"refs",
"[",
"$",
"class",
"]",
"[",
"$",
"id",
"]",
")",
")",
"{",
"$",
"file",
"=",
"self",
"::",
"File",
"(",
"$",
"id",
")",
";",
"$",
"obj",
"=",
"unserialize",
"(",
"file_get_contents",
"(",
"$",
"file",
")",
")",
";",
"self",
"::",
"$",
"refs",
"[",
"$",
"class",
"]",
"[",
"$",
"id",
"]",
"=",
"$",
"obj",
";",
"}",
"return",
"self",
"::",
"$",
"refs",
"[",
"$",
"class",
"]",
"[",
"$",
"id",
"]",
";",
"}"
] |
Fetch one saved object by id
@param int $id
@return Persistent
|
[
"Fetch",
"one",
"saved",
"object",
"by",
"id"
] |
ba33e2f0efaed71693c3013e73315d3c019d7f05
|
https://github.com/tdebatty/php-noorm/blob/ba33e2f0efaed71693c3013e73315d3c019d7f05/src/noorm/Persistent.php#L59-L69
|
26,049
|
tdebatty/php-noorm
|
src/noorm/Persistent.php
|
Persistent.SetDirectory
|
public static function SetDirectory($dir) {
if (!is_dir($dir)) {
if (!@\mkdir($dir, 0700, TRUE)) {
throw new \InvalidArgumentException("dir $dir does not exist and could not be created");
}
}
self::$DIR = realpath($dir);
}
|
php
|
public static function SetDirectory($dir) {
if (!is_dir($dir)) {
if (!@\mkdir($dir, 0700, TRUE)) {
throw new \InvalidArgumentException("dir $dir does not exist and could not be created");
}
}
self::$DIR = realpath($dir);
}
|
[
"public",
"static",
"function",
"SetDirectory",
"(",
"$",
"dir",
")",
"{",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"dir",
")",
")",
"{",
"if",
"(",
"!",
"@",
"\\",
"mkdir",
"(",
"$",
"dir",
",",
"0700",
",",
"TRUE",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"dir $dir does not exist and could not be created\"",
")",
";",
"}",
"}",
"self",
"::",
"$",
"DIR",
"=",
"realpath",
"(",
"$",
"dir",
")",
";",
"}"
] |
Set directory where all persistent objects and relations will be saved.
@param String $dir
@throws \InvalidArgumentException
|
[
"Set",
"directory",
"where",
"all",
"persistent",
"objects",
"and",
"relations",
"will",
"be",
"saved",
"."
] |
ba33e2f0efaed71693c3013e73315d3c019d7f05
|
https://github.com/tdebatty/php-noorm/blob/ba33e2f0efaed71693c3013e73315d3c019d7f05/src/noorm/Persistent.php#L95-L103
|
26,050
|
tdebatty/php-noorm
|
src/noorm/Persistent.php
|
Persistent.Save
|
public function Save() {
if (!$this->Validate()) {
throw new \Exception("Validation failed");
}
$file = self::File($this->id);
if (!is_dir(dirname($file))) {
mkdir(dirname($file), 0755, true);
}
file_put_contents($file, serialize($this), LOCK_EX);
return $this;
}
|
php
|
public function Save() {
if (!$this->Validate()) {
throw new \Exception("Validation failed");
}
$file = self::File($this->id);
if (!is_dir(dirname($file))) {
mkdir(dirname($file), 0755, true);
}
file_put_contents($file, serialize($this), LOCK_EX);
return $this;
}
|
[
"public",
"function",
"Save",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"Validate",
"(",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Validation failed\"",
")",
";",
"}",
"$",
"file",
"=",
"self",
"::",
"File",
"(",
"$",
"this",
"->",
"id",
")",
";",
"if",
"(",
"!",
"is_dir",
"(",
"dirname",
"(",
"$",
"file",
")",
")",
")",
"{",
"mkdir",
"(",
"dirname",
"(",
"$",
"file",
")",
",",
"0755",
",",
"true",
")",
";",
"}",
"file_put_contents",
"(",
"$",
"file",
",",
"serialize",
"(",
"$",
"this",
")",
",",
"LOCK_EX",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Save this object.
@return boolean true on success
|
[
"Save",
"this",
"object",
"."
] |
ba33e2f0efaed71693c3013e73315d3c019d7f05
|
https://github.com/tdebatty/php-noorm/blob/ba33e2f0efaed71693c3013e73315d3c019d7f05/src/noorm/Persistent.php#L187-L199
|
26,051
|
t3v/t3v_core
|
Classes/Utility/ExtensionUtility.php
|
ExtensionUtility.extensionIdentifier
|
public static function extensionIdentifier(string $extensionKey): string {
$extensionIdentifier = GeneralUtility::underscoredToUpperCamelCase($extensionKey);
$extensionIdentifier = mb_strtolower($extensionIdentifier);
return $extensionIdentifier;
}
|
php
|
public static function extensionIdentifier(string $extensionKey): string {
$extensionIdentifier = GeneralUtility::underscoredToUpperCamelCase($extensionKey);
$extensionIdentifier = mb_strtolower($extensionIdentifier);
return $extensionIdentifier;
}
|
[
"public",
"static",
"function",
"extensionIdentifier",
"(",
"string",
"$",
"extensionKey",
")",
":",
"string",
"{",
"$",
"extensionIdentifier",
"=",
"GeneralUtility",
"::",
"underscoredToUpperCamelCase",
"(",
"$",
"extensionKey",
")",
";",
"$",
"extensionIdentifier",
"=",
"mb_strtolower",
"(",
"$",
"extensionIdentifier",
")",
";",
"return",
"$",
"extensionIdentifier",
";",
"}"
] |
Gets an extension identifier from an extension key.
@param string $extensionKey The extension key
@return string The extension identifier
|
[
"Gets",
"an",
"extension",
"identifier",
"from",
"an",
"extension",
"key",
"."
] |
8c04b7688cc2773f11fcc87fda3f7cd53d80a980
|
https://github.com/t3v/t3v_core/blob/8c04b7688cc2773f11fcc87fda3f7cd53d80a980/Classes/Utility/ExtensionUtility.php#L18-L23
|
26,052
|
t3v/t3v_core
|
Classes/Utility/ExtensionUtility.php
|
ExtensionUtility.extensionSignature
|
public static function extensionSignature(string $namespace, string $extensionKey, string $separator = '.'): string {
$namespace = GeneralUtility::underscoredToUpperCamelCase($namespace);
$extensionKey = GeneralUtility::underscoredToUpperCamelCase($extensionKey);
return "${namespace}${separator}${extensionKey}";
}
|
php
|
public static function extensionSignature(string $namespace, string $extensionKey, string $separator = '.'): string {
$namespace = GeneralUtility::underscoredToUpperCamelCase($namespace);
$extensionKey = GeneralUtility::underscoredToUpperCamelCase($extensionKey);
return "${namespace}${separator}${extensionKey}";
}
|
[
"public",
"static",
"function",
"extensionSignature",
"(",
"string",
"$",
"namespace",
",",
"string",
"$",
"extensionKey",
",",
"string",
"$",
"separator",
"=",
"'.'",
")",
":",
"string",
"{",
"$",
"namespace",
"=",
"GeneralUtility",
"::",
"underscoredToUpperCamelCase",
"(",
"$",
"namespace",
")",
";",
"$",
"extensionKey",
"=",
"GeneralUtility",
"::",
"underscoredToUpperCamelCase",
"(",
"$",
"extensionKey",
")",
";",
"return",
"\"${namespace}${separator}${extensionKey}\"",
";",
"}"
] |
Gets an extension signature from a namespace and extension key.
@param string $namespace The namespace
@param string $extensionKey The extension key
@param string $separator The optional separator, defaults to `.`
@return string The extension signature
|
[
"Gets",
"an",
"extension",
"signature",
"from",
"a",
"namespace",
"and",
"extension",
"key",
"."
] |
8c04b7688cc2773f11fcc87fda3f7cd53d80a980
|
https://github.com/t3v/t3v_core/blob/8c04b7688cc2773f11fcc87fda3f7cd53d80a980/Classes/Utility/ExtensionUtility.php#L43-L48
|
26,053
|
t3v/t3v_core
|
Classes/Utility/ExtensionUtility.php
|
ExtensionUtility.getExtensionSignature
|
public static function getExtensionSignature(string $namespace, string $extensionKey, string $separator = '.'): string {
return self::extensionSignature($namespace, $extensionKey, $separator);
}
|
php
|
public static function getExtensionSignature(string $namespace, string $extensionKey, string $separator = '.'): string {
return self::extensionSignature($namespace, $extensionKey, $separator);
}
|
[
"public",
"static",
"function",
"getExtensionSignature",
"(",
"string",
"$",
"namespace",
",",
"string",
"$",
"extensionKey",
",",
"string",
"$",
"separator",
"=",
"'.'",
")",
":",
"string",
"{",
"return",
"self",
"::",
"extensionSignature",
"(",
"$",
"namespace",
",",
"$",
"extensionKey",
",",
"$",
"separator",
")",
";",
"}"
] |
Alias for the `extensionSignature` function.
@param string $namespace The namespace
@param string $extensionKey The extension key
@param string $separator The optional separator, defaults to `.`
@return string The extension signature
|
[
"Alias",
"for",
"the",
"extensionSignature",
"function",
"."
] |
8c04b7688cc2773f11fcc87fda3f7cd53d80a980
|
https://github.com/t3v/t3v_core/blob/8c04b7688cc2773f11fcc87fda3f7cd53d80a980/Classes/Utility/ExtensionUtility.php#L58-L60
|
26,054
|
t3v/t3v_core
|
Classes/Utility/ExtensionUtility.php
|
ExtensionUtility.locallang
|
public static function locallang(string $extensionKey, string $fileName = 'locallang.xlf', string $prefix = 'LLL:EXT:', string $separator = ':'): string {
$languageFolder = self::languageFolder($extensionKey, $prefix);
return "${languageFolder}/${fileName}${separator}";
}
|
php
|
public static function locallang(string $extensionKey, string $fileName = 'locallang.xlf', string $prefix = 'LLL:EXT:', string $separator = ':'): string {
$languageFolder = self::languageFolder($extensionKey, $prefix);
return "${languageFolder}/${fileName}${separator}";
}
|
[
"public",
"static",
"function",
"locallang",
"(",
"string",
"$",
"extensionKey",
",",
"string",
"$",
"fileName",
"=",
"'locallang.xlf'",
",",
"string",
"$",
"prefix",
"=",
"'LLL:EXT:'",
",",
"string",
"$",
"separator",
"=",
"':'",
")",
":",
"string",
"{",
"$",
"languageFolder",
"=",
"self",
"::",
"languageFolder",
"(",
"$",
"extensionKey",
",",
"$",
"prefix",
")",
";",
"return",
"\"${languageFolder}/${fileName}${separator}\"",
";",
"}"
] |
Gets the locallang file from an extension key.
@param string $extensionKey The extension key
@param string $prefix The optional file name of the locallang file, defaults to `locallang.xlf`
@param string $prefix The optional prefix, defaults to `LLL:EXT:`
@param string $separator The optional separator, defaults to `:`
@return string The locallang file
|
[
"Gets",
"the",
"locallang",
"file",
"from",
"an",
"extension",
"key",
"."
] |
8c04b7688cc2773f11fcc87fda3f7cd53d80a980
|
https://github.com/t3v/t3v_core/blob/8c04b7688cc2773f11fcc87fda3f7cd53d80a980/Classes/Utility/ExtensionUtility.php#L71-L75
|
26,055
|
t3v/t3v_core
|
Classes/Utility/ExtensionUtility.php
|
ExtensionUtility.getConfigurationFolder
|
public static function getConfigurationFolder(string $extensionKey, string $prefix = 'FILE:EXT:'): string {
return self::configurationFolder($extensionKey, $prefix);
}
|
php
|
public static function getConfigurationFolder(string $extensionKey, string $prefix = 'FILE:EXT:'): string {
return self::configurationFolder($extensionKey, $prefix);
}
|
[
"public",
"static",
"function",
"getConfigurationFolder",
"(",
"string",
"$",
"extensionKey",
",",
"string",
"$",
"prefix",
"=",
"'FILE:EXT:'",
")",
":",
"string",
"{",
"return",
"self",
"::",
"configurationFolder",
"(",
"$",
"extensionKey",
",",
"$",
"prefix",
")",
";",
"}"
] |
Alias for the `configurationFolder` function.
@param string $extensionKey The extension key
@param string $prefix The optional prefix, defaults to `FILE:EXT:`
@return string The configuration folder
|
[
"Alias",
"for",
"the",
"configurationFolder",
"function",
"."
] |
8c04b7688cc2773f11fcc87fda3f7cd53d80a980
|
https://github.com/t3v/t3v_core/blob/8c04b7688cc2773f11fcc87fda3f7cd53d80a980/Classes/Utility/ExtensionUtility.php#L121-L123
|
26,056
|
t3v/t3v_core
|
Classes/Utility/ExtensionUtility.php
|
ExtensionUtility.flexFormsFolder
|
public static function flexFormsFolder(string $extensionKey, string $prefix = 'FILE:EXT:'): string {
$configurationFolder = self::configurationFolder($extensionKey, $prefix);
return "${configurationFolder}/FlexForms";
}
|
php
|
public static function flexFormsFolder(string $extensionKey, string $prefix = 'FILE:EXT:'): string {
$configurationFolder = self::configurationFolder($extensionKey, $prefix);
return "${configurationFolder}/FlexForms";
}
|
[
"public",
"static",
"function",
"flexFormsFolder",
"(",
"string",
"$",
"extensionKey",
",",
"string",
"$",
"prefix",
"=",
"'FILE:EXT:'",
")",
":",
"string",
"{",
"$",
"configurationFolder",
"=",
"self",
"::",
"configurationFolder",
"(",
"$",
"extensionKey",
",",
"$",
"prefix",
")",
";",
"return",
"\"${configurationFolder}/FlexForms\"",
";",
"}"
] |
Gets the FlexForms folder from an extension key.
@param string $extensionKey The extension key
@param string $prefix The optional prefix, defaults to `FILE:EXT:`
@return string The FlexForms folder
|
[
"Gets",
"the",
"FlexForms",
"folder",
"from",
"an",
"extension",
"key",
"."
] |
8c04b7688cc2773f11fcc87fda3f7cd53d80a980
|
https://github.com/t3v/t3v_core/blob/8c04b7688cc2773f11fcc87fda3f7cd53d80a980/Classes/Utility/ExtensionUtility.php#L132-L136
|
26,057
|
t3v/t3v_core
|
Classes/Utility/ExtensionUtility.php
|
ExtensionUtility.getFlexFormsFolder
|
public static function getFlexFormsFolder(string $extensionKey, string $prefix = 'FILE:EXT:'): string {
return self::flexFormsFolder($extensionKey, $prefix);
}
|
php
|
public static function getFlexFormsFolder(string $extensionKey, string $prefix = 'FILE:EXT:'): string {
return self::flexFormsFolder($extensionKey, $prefix);
}
|
[
"public",
"static",
"function",
"getFlexFormsFolder",
"(",
"string",
"$",
"extensionKey",
",",
"string",
"$",
"prefix",
"=",
"'FILE:EXT:'",
")",
":",
"string",
"{",
"return",
"self",
"::",
"flexFormsFolder",
"(",
"$",
"extensionKey",
",",
"$",
"prefix",
")",
";",
"}"
] |
Alias for the `flexFormsFolder` function.
@param string $extensionKey The extension key
@param string $prefix The optional prefix, defaults to `FILE:EXT:`
@return string The FlexForms folder
|
[
"Alias",
"for",
"the",
"flexFormsFolder",
"function",
"."
] |
8c04b7688cc2773f11fcc87fda3f7cd53d80a980
|
https://github.com/t3v/t3v_core/blob/8c04b7688cc2773f11fcc87fda3f7cd53d80a980/Classes/Utility/ExtensionUtility.php#L145-L147
|
26,058
|
t3v/t3v_core
|
Classes/Utility/ExtensionUtility.php
|
ExtensionUtility.getResourcesFolder
|
public static function getResourcesFolder(string $extensionKey, string $prefix = 'EXT:'): string {
return self::resourcesFolder($extensionKey, $prefix);
}
|
php
|
public static function getResourcesFolder(string $extensionKey, string $prefix = 'EXT:'): string {
return self::resourcesFolder($extensionKey, $prefix);
}
|
[
"public",
"static",
"function",
"getResourcesFolder",
"(",
"string",
"$",
"extensionKey",
",",
"string",
"$",
"prefix",
"=",
"'EXT:'",
")",
":",
"string",
"{",
"return",
"self",
"::",
"resourcesFolder",
"(",
"$",
"extensionKey",
",",
"$",
"prefix",
")",
";",
"}"
] |
Alias for the `resourcesFolder` function.
@param string $extensionKey The extension key
@param string $prefix The optional prefix, defaults to `EXT:`
@return string The resources folder
|
[
"Alias",
"for",
"the",
"resourcesFolder",
"function",
"."
] |
8c04b7688cc2773f11fcc87fda3f7cd53d80a980
|
https://github.com/t3v/t3v_core/blob/8c04b7688cc2773f11fcc87fda3f7cd53d80a980/Classes/Utility/ExtensionUtility.php#L167-L169
|
26,059
|
t3v/t3v_core
|
Classes/Utility/ExtensionUtility.php
|
ExtensionUtility.privateFolder
|
public static function privateFolder(string $extensionKey, string $prefix = 'EXT:'): string {
$resourcesFolder = self::resourcesFolder($extensionKey, $prefix);
return "${resourcesFolder}/Private";
}
|
php
|
public static function privateFolder(string $extensionKey, string $prefix = 'EXT:'): string {
$resourcesFolder = self::resourcesFolder($extensionKey, $prefix);
return "${resourcesFolder}/Private";
}
|
[
"public",
"static",
"function",
"privateFolder",
"(",
"string",
"$",
"extensionKey",
",",
"string",
"$",
"prefix",
"=",
"'EXT:'",
")",
":",
"string",
"{",
"$",
"resourcesFolder",
"=",
"self",
"::",
"resourcesFolder",
"(",
"$",
"extensionKey",
",",
"$",
"prefix",
")",
";",
"return",
"\"${resourcesFolder}/Private\"",
";",
"}"
] |
Gets the private folder from an extension key.
@param string $extensionKey The extension key
@param string $prefix The optional prefix, defaults to `EXT:`
@return string The private folder
|
[
"Gets",
"the",
"private",
"folder",
"from",
"an",
"extension",
"key",
"."
] |
8c04b7688cc2773f11fcc87fda3f7cd53d80a980
|
https://github.com/t3v/t3v_core/blob/8c04b7688cc2773f11fcc87fda3f7cd53d80a980/Classes/Utility/ExtensionUtility.php#L178-L182
|
26,060
|
t3v/t3v_core
|
Classes/Utility/ExtensionUtility.php
|
ExtensionUtility.getPrivateFolder
|
public static function getPrivateFolder(string $extensionKey, string $prefix = 'EXT:'): string {
return self::privateFolder($extensionKey, $prefix);
}
|
php
|
public static function getPrivateFolder(string $extensionKey, string $prefix = 'EXT:'): string {
return self::privateFolder($extensionKey, $prefix);
}
|
[
"public",
"static",
"function",
"getPrivateFolder",
"(",
"string",
"$",
"extensionKey",
",",
"string",
"$",
"prefix",
"=",
"'EXT:'",
")",
":",
"string",
"{",
"return",
"self",
"::",
"privateFolder",
"(",
"$",
"extensionKey",
",",
"$",
"prefix",
")",
";",
"}"
] |
Alias for the `privateFolder` function.
@param string $extensionKey The extension key
@param string $prefix The optional prefix, defaults to `EXT:`
@return string The private folder
|
[
"Alias",
"for",
"the",
"privateFolder",
"function",
"."
] |
8c04b7688cc2773f11fcc87fda3f7cd53d80a980
|
https://github.com/t3v/t3v_core/blob/8c04b7688cc2773f11fcc87fda3f7cd53d80a980/Classes/Utility/ExtensionUtility.php#L191-L193
|
26,061
|
t3v/t3v_core
|
Classes/Utility/ExtensionUtility.php
|
ExtensionUtility.languageFolder
|
public static function languageFolder(string $extensionKey, string $prefix = 'EXT:'): string {
$privateFolder = self::privateFolder($extensionKey, $prefix);
return "${privateFolder}/Language";
}
|
php
|
public static function languageFolder(string $extensionKey, string $prefix = 'EXT:'): string {
$privateFolder = self::privateFolder($extensionKey, $prefix);
return "${privateFolder}/Language";
}
|
[
"public",
"static",
"function",
"languageFolder",
"(",
"string",
"$",
"extensionKey",
",",
"string",
"$",
"prefix",
"=",
"'EXT:'",
")",
":",
"string",
"{",
"$",
"privateFolder",
"=",
"self",
"::",
"privateFolder",
"(",
"$",
"extensionKey",
",",
"$",
"prefix",
")",
";",
"return",
"\"${privateFolder}/Language\"",
";",
"}"
] |
Gets the language folder from an extension key.
@param string $extensionKey The extension key
@param string $prefix The optional prefix, defaults to `EXT:`
@return string The language folder
|
[
"Gets",
"the",
"language",
"folder",
"from",
"an",
"extension",
"key",
"."
] |
8c04b7688cc2773f11fcc87fda3f7cd53d80a980
|
https://github.com/t3v/t3v_core/blob/8c04b7688cc2773f11fcc87fda3f7cd53d80a980/Classes/Utility/ExtensionUtility.php#L202-L206
|
26,062
|
t3v/t3v_core
|
Classes/Utility/ExtensionUtility.php
|
ExtensionUtility.getLanguageFolder
|
public static function getLanguageFolder(string $extensionKey, string $prefix = 'EXT:'): string {
return self::languageFolder($extensionKey, $prefix);
}
|
php
|
public static function getLanguageFolder(string $extensionKey, string $prefix = 'EXT:'): string {
return self::languageFolder($extensionKey, $prefix);
}
|
[
"public",
"static",
"function",
"getLanguageFolder",
"(",
"string",
"$",
"extensionKey",
",",
"string",
"$",
"prefix",
"=",
"'EXT:'",
")",
":",
"string",
"{",
"return",
"self",
"::",
"languageFolder",
"(",
"$",
"extensionKey",
",",
"$",
"prefix",
")",
";",
"}"
] |
Alias for the `languageFolder` function.
@param string $extensionKey The extension key
@param string $prefix The optional prefix, defaults to `EXT:`
@return string The language folder
|
[
"Alias",
"for",
"the",
"languageFolder",
"function",
"."
] |
8c04b7688cc2773f11fcc87fda3f7cd53d80a980
|
https://github.com/t3v/t3v_core/blob/8c04b7688cc2773f11fcc87fda3f7cd53d80a980/Classes/Utility/ExtensionUtility.php#L215-L217
|
26,063
|
t3v/t3v_core
|
Classes/Utility/ExtensionUtility.php
|
ExtensionUtility.locallangFolder
|
public static function locallangFolder(string $extensionKey, string $prefix = 'LLL:EXT:'): string {
return self::languageFolder($extensionKey, $prefix);
}
|
php
|
public static function locallangFolder(string $extensionKey, string $prefix = 'LLL:EXT:'): string {
return self::languageFolder($extensionKey, $prefix);
}
|
[
"public",
"static",
"function",
"locallangFolder",
"(",
"string",
"$",
"extensionKey",
",",
"string",
"$",
"prefix",
"=",
"'LLL:EXT:'",
")",
":",
"string",
"{",
"return",
"self",
"::",
"languageFolder",
"(",
"$",
"extensionKey",
",",
"$",
"prefix",
")",
";",
"}"
] |
Gets the locallang folder from an extension key.
Alias for the `languageFolder` function with `LLL:EXT:` as prefix.
@param string $extensionKey The extension key
@param string $prefix The optional prefix, defaults to `LLL:EXT:`
@return string The locallang folder
|
[
"Gets",
"the",
"locallang",
"folder",
"from",
"an",
"extension",
"key",
"."
] |
8c04b7688cc2773f11fcc87fda3f7cd53d80a980
|
https://github.com/t3v/t3v_core/blob/8c04b7688cc2773f11fcc87fda3f7cd53d80a980/Classes/Utility/ExtensionUtility.php#L228-L230
|
26,064
|
t3v/t3v_core
|
Classes/Utility/ExtensionUtility.php
|
ExtensionUtility.publicFolder
|
public static function publicFolder(string $extensionKey, string $prefix = 'EXT:'): string {
$resourcesFolder = self::resourcesFolder($extensionKey, $prefix);
return "${resourcesFolder}/Public";
}
|
php
|
public static function publicFolder(string $extensionKey, string $prefix = 'EXT:'): string {
$resourcesFolder = self::resourcesFolder($extensionKey, $prefix);
return "${resourcesFolder}/Public";
}
|
[
"public",
"static",
"function",
"publicFolder",
"(",
"string",
"$",
"extensionKey",
",",
"string",
"$",
"prefix",
"=",
"'EXT:'",
")",
":",
"string",
"{",
"$",
"resourcesFolder",
"=",
"self",
"::",
"resourcesFolder",
"(",
"$",
"extensionKey",
",",
"$",
"prefix",
")",
";",
"return",
"\"${resourcesFolder}/Public\"",
";",
"}"
] |
Gets the public folder from an extension key.
@param string $extensionKey The extension key
@param string $prefix The optional prefix, defaults to `EXT:`
@return string The public folder
|
[
"Gets",
"the",
"public",
"folder",
"from",
"an",
"extension",
"key",
"."
] |
8c04b7688cc2773f11fcc87fda3f7cd53d80a980
|
https://github.com/t3v/t3v_core/blob/8c04b7688cc2773f11fcc87fda3f7cd53d80a980/Classes/Utility/ExtensionUtility.php#L261-L265
|
26,065
|
t3v/t3v_core
|
Classes/Utility/ExtensionUtility.php
|
ExtensionUtility.getPublicFolder
|
public static function getPublicFolder(string $extensionKey, string $prefix = 'EXT:'): string {
return self::publicFolder($extensionKey, $prefix);
}
|
php
|
public static function getPublicFolder(string $extensionKey, string $prefix = 'EXT:'): string {
return self::publicFolder($extensionKey, $prefix);
}
|
[
"public",
"static",
"function",
"getPublicFolder",
"(",
"string",
"$",
"extensionKey",
",",
"string",
"$",
"prefix",
"=",
"'EXT:'",
")",
":",
"string",
"{",
"return",
"self",
"::",
"publicFolder",
"(",
"$",
"extensionKey",
",",
"$",
"prefix",
")",
";",
"}"
] |
Alias for the `publicFolder` function.
@param string $extensionKey The extension key
@param string $prefix The optional prefix, defaults to `EXT:`
@return string The public folder
|
[
"Alias",
"for",
"the",
"publicFolder",
"function",
"."
] |
8c04b7688cc2773f11fcc87fda3f7cd53d80a980
|
https://github.com/t3v/t3v_core/blob/8c04b7688cc2773f11fcc87fda3f7cd53d80a980/Classes/Utility/ExtensionUtility.php#L274-L276
|
26,066
|
t3v/t3v_core
|
Classes/Utility/ExtensionUtility.php
|
ExtensionUtility.assetsFolder
|
public static function assetsFolder(string $extensionKey, string $prefix = 'EXT:'): string {
$publicFolder = self::publicFolder($extensionKey, $prefix);
return "${publicFolder}/Assets";
}
|
php
|
public static function assetsFolder(string $extensionKey, string $prefix = 'EXT:'): string {
$publicFolder = self::publicFolder($extensionKey, $prefix);
return "${publicFolder}/Assets";
}
|
[
"public",
"static",
"function",
"assetsFolder",
"(",
"string",
"$",
"extensionKey",
",",
"string",
"$",
"prefix",
"=",
"'EXT:'",
")",
":",
"string",
"{",
"$",
"publicFolder",
"=",
"self",
"::",
"publicFolder",
"(",
"$",
"extensionKey",
",",
"$",
"prefix",
")",
";",
"return",
"\"${publicFolder}/Assets\"",
";",
"}"
] |
Gets the assets folder from an extension key.
@param string $extensionKey The extension key
@param string $prefix The optional prefix, defaults to `EXT:`
@return string The assets folder
|
[
"Gets",
"the",
"assets",
"folder",
"from",
"an",
"extension",
"key",
"."
] |
8c04b7688cc2773f11fcc87fda3f7cd53d80a980
|
https://github.com/t3v/t3v_core/blob/8c04b7688cc2773f11fcc87fda3f7cd53d80a980/Classes/Utility/ExtensionUtility.php#L285-L289
|
26,067
|
t3v/t3v_core
|
Classes/Utility/ExtensionUtility.php
|
ExtensionUtility.getAssetsFolder
|
public static function getAssetsFolder(string $extensionKey, string $prefix = 'EXT:'): string {
return self::assetsFolder($extensionKey, $prefix);
}
|
php
|
public static function getAssetsFolder(string $extensionKey, string $prefix = 'EXT:'): string {
return self::assetsFolder($extensionKey, $prefix);
}
|
[
"public",
"static",
"function",
"getAssetsFolder",
"(",
"string",
"$",
"extensionKey",
",",
"string",
"$",
"prefix",
"=",
"'EXT:'",
")",
":",
"string",
"{",
"return",
"self",
"::",
"assetsFolder",
"(",
"$",
"extensionKey",
",",
"$",
"prefix",
")",
";",
"}"
] |
Alias for the `assetsFolder` function.
@param string $extensionKey The extension key
@param string $prefix The optional prefix, defaults to `EXT:`
@return string The assets folder
|
[
"Alias",
"for",
"the",
"assetsFolder",
"function",
"."
] |
8c04b7688cc2773f11fcc87fda3f7cd53d80a980
|
https://github.com/t3v/t3v_core/blob/8c04b7688cc2773f11fcc87fda3f7cd53d80a980/Classes/Utility/ExtensionUtility.php#L298-L300
|
26,068
|
t3v/t3v_core
|
Classes/Utility/ExtensionUtility.php
|
ExtensionUtility.iconsFolder
|
public static function iconsFolder(string $extensionKey, string $prefix = 'EXT:'): string {
$publicFolder = self::publicFolder($extensionKey, $prefix);
return "${publicFolder}/Icons";
}
|
php
|
public static function iconsFolder(string $extensionKey, string $prefix = 'EXT:'): string {
$publicFolder = self::publicFolder($extensionKey, $prefix);
return "${publicFolder}/Icons";
}
|
[
"public",
"static",
"function",
"iconsFolder",
"(",
"string",
"$",
"extensionKey",
",",
"string",
"$",
"prefix",
"=",
"'EXT:'",
")",
":",
"string",
"{",
"$",
"publicFolder",
"=",
"self",
"::",
"publicFolder",
"(",
"$",
"extensionKey",
",",
"$",
"prefix",
")",
";",
"return",
"\"${publicFolder}/Icons\"",
";",
"}"
] |
Gets the icons folder from an extension key.
@param string $extensionKey The extension key
@param string $prefix The optional prefix, defaults to `EXT:`
@return string The icons folder
|
[
"Gets",
"the",
"icons",
"folder",
"from",
"an",
"extension",
"key",
"."
] |
8c04b7688cc2773f11fcc87fda3f7cd53d80a980
|
https://github.com/t3v/t3v_core/blob/8c04b7688cc2773f11fcc87fda3f7cd53d80a980/Classes/Utility/ExtensionUtility.php#L309-L313
|
26,069
|
t3v/t3v_core
|
Classes/Utility/ExtensionUtility.php
|
ExtensionUtility.getIconsFolder
|
public static function getIconsFolder(string $extensionKey, string $prefix = 'EXT:'): string {
return self::iconsFolder($extensionKey, $prefix);
}
|
php
|
public static function getIconsFolder(string $extensionKey, string $prefix = 'EXT:'): string {
return self::iconsFolder($extensionKey, $prefix);
}
|
[
"public",
"static",
"function",
"getIconsFolder",
"(",
"string",
"$",
"extensionKey",
",",
"string",
"$",
"prefix",
"=",
"'EXT:'",
")",
":",
"string",
"{",
"return",
"self",
"::",
"iconsFolder",
"(",
"$",
"extensionKey",
",",
"$",
"prefix",
")",
";",
"}"
] |
Alias for the `iconsFolder` function.
@param string $extensionKey The extension key
@param string $prefix The optional prefix, defaults to `EXT:`
@return string The icons folder
|
[
"Alias",
"for",
"the",
"iconsFolder",
"function",
"."
] |
8c04b7688cc2773f11fcc87fda3f7cd53d80a980
|
https://github.com/t3v/t3v_core/blob/8c04b7688cc2773f11fcc87fda3f7cd53d80a980/Classes/Utility/ExtensionUtility.php#L322-L324
|
26,070
|
t3v/t3v_core
|
Classes/Utility/ExtensionUtility.php
|
ExtensionUtility.placeholdersFolder
|
public static function placeholdersFolder(string $extensionKey, string $prefix = 'EXT:'): string {
$publicFolder = self::publicFolder($extensionKey, $prefix);
return "${publicFolder}/Placeholders";
}
|
php
|
public static function placeholdersFolder(string $extensionKey, string $prefix = 'EXT:'): string {
$publicFolder = self::publicFolder($extensionKey, $prefix);
return "${publicFolder}/Placeholders";
}
|
[
"public",
"static",
"function",
"placeholdersFolder",
"(",
"string",
"$",
"extensionKey",
",",
"string",
"$",
"prefix",
"=",
"'EXT:'",
")",
":",
"string",
"{",
"$",
"publicFolder",
"=",
"self",
"::",
"publicFolder",
"(",
"$",
"extensionKey",
",",
"$",
"prefix",
")",
";",
"return",
"\"${publicFolder}/Placeholders\"",
";",
"}"
] |
Gets the placeholders folder from an extension key.
@param string $extensionKey The extension key
@param string $prefix The optional prefix, defaults to `EXT:`
@return string The placeholders folder
|
[
"Gets",
"the",
"placeholders",
"folder",
"from",
"an",
"extension",
"key",
"."
] |
8c04b7688cc2773f11fcc87fda3f7cd53d80a980
|
https://github.com/t3v/t3v_core/blob/8c04b7688cc2773f11fcc87fda3f7cd53d80a980/Classes/Utility/ExtensionUtility.php#L333-L337
|
26,071
|
t3v/t3v_core
|
Classes/Utility/ExtensionUtility.php
|
ExtensionUtility.getPlaceholdersFolder
|
public static function getPlaceholdersFolder(string $extensionKey, string $prefix = 'EXT:'): string {
return self::placeholdersFolder($extensionKey, $prefix);
}
|
php
|
public static function getPlaceholdersFolder(string $extensionKey, string $prefix = 'EXT:'): string {
return self::placeholdersFolder($extensionKey, $prefix);
}
|
[
"public",
"static",
"function",
"getPlaceholdersFolder",
"(",
"string",
"$",
"extensionKey",
",",
"string",
"$",
"prefix",
"=",
"'EXT:'",
")",
":",
"string",
"{",
"return",
"self",
"::",
"placeholdersFolder",
"(",
"$",
"extensionKey",
",",
"$",
"prefix",
")",
";",
"}"
] |
Alias for the `placeholdersFolder` function.
@param string $extensionKey The extension key
@param string $prefix The optional prefix, defaults to `EXT:`
@return string The placeholders folder
|
[
"Alias",
"for",
"the",
"placeholdersFolder",
"function",
"."
] |
8c04b7688cc2773f11fcc87fda3f7cd53d80a980
|
https://github.com/t3v/t3v_core/blob/8c04b7688cc2773f11fcc87fda3f7cd53d80a980/Classes/Utility/ExtensionUtility.php#L346-L348
|
26,072
|
t3v/t3v_core
|
Classes/Utility/ExtensionUtility.php
|
ExtensionUtility.samplesFolder
|
public static function samplesFolder(string $extensionKey, string $prefix = 'EXT:'): string {
$publicFolder = self::publicFolder($extensionKey, $prefix);
return "${publicFolder}/Samples";
}
|
php
|
public static function samplesFolder(string $extensionKey, string $prefix = 'EXT:'): string {
$publicFolder = self::publicFolder($extensionKey, $prefix);
return "${publicFolder}/Samples";
}
|
[
"public",
"static",
"function",
"samplesFolder",
"(",
"string",
"$",
"extensionKey",
",",
"string",
"$",
"prefix",
"=",
"'EXT:'",
")",
":",
"string",
"{",
"$",
"publicFolder",
"=",
"self",
"::",
"publicFolder",
"(",
"$",
"extensionKey",
",",
"$",
"prefix",
")",
";",
"return",
"\"${publicFolder}/Samples\"",
";",
"}"
] |
Gets the samples folder from an extension key.
@param string $extensionKey The extension key
@param string $prefix The optional prefix, defaults to `EXT:`
@return string The samples folder
|
[
"Gets",
"the",
"samples",
"folder",
"from",
"an",
"extension",
"key",
"."
] |
8c04b7688cc2773f11fcc87fda3f7cd53d80a980
|
https://github.com/t3v/t3v_core/blob/8c04b7688cc2773f11fcc87fda3f7cd53d80a980/Classes/Utility/ExtensionUtility.php#L357-L361
|
26,073
|
t3v/t3v_core
|
Classes/Utility/ExtensionUtility.php
|
ExtensionUtility.getSamplesFolder
|
public static function getSamplesFolder(string $extensionKey, string $prefix = 'EXT:'): string {
return self::samplesFolder($extensionKey, $prefix);
}
|
php
|
public static function getSamplesFolder(string $extensionKey, string $prefix = 'EXT:'): string {
return self::samplesFolder($extensionKey, $prefix);
}
|
[
"public",
"static",
"function",
"getSamplesFolder",
"(",
"string",
"$",
"extensionKey",
",",
"string",
"$",
"prefix",
"=",
"'EXT:'",
")",
":",
"string",
"{",
"return",
"self",
"::",
"samplesFolder",
"(",
"$",
"extensionKey",
",",
"$",
"prefix",
")",
";",
"}"
] |
Alias for the `samplesFolder` function.
@param string $extensionKey The extension key
@param string $prefix The optional prefix, defaults to `EXT:`
@return string The samples folder
|
[
"Alias",
"for",
"the",
"samplesFolder",
"function",
"."
] |
8c04b7688cc2773f11fcc87fda3f7cd53d80a980
|
https://github.com/t3v/t3v_core/blob/8c04b7688cc2773f11fcc87fda3f7cd53d80a980/Classes/Utility/ExtensionUtility.php#L370-L372
|
26,074
|
ciims/ciims-modules-dashboard
|
components/CiiDashboardController.php
|
CiiDashboardController.getAsset
|
public function getAsset($dist=false)
{
return Yii::app()->assetManager->publish(YiiBase::getPathOfAlias('application.modules.dashboard.assets'), true, -1, YII_DEBUG);
}
|
php
|
public function getAsset($dist=false)
{
return Yii::app()->assetManager->publish(YiiBase::getPathOfAlias('application.modules.dashboard.assets'), true, -1, YII_DEBUG);
}
|
[
"public",
"function",
"getAsset",
"(",
"$",
"dist",
"=",
"false",
")",
"{",
"return",
"Yii",
"::",
"app",
"(",
")",
"->",
"assetManager",
"->",
"publish",
"(",
"YiiBase",
"::",
"getPathOfAlias",
"(",
"'application.modules.dashboard.assets'",
")",
",",
"true",
",",
"-",
"1",
",",
"YII_DEBUG",
")",
";",
"}"
] |
Retrieve assetManager from anywhere without having to instatiate this code
@return CAssetManager
|
[
"Retrieve",
"assetManager",
"from",
"anywhere",
"without",
"having",
"to",
"instatiate",
"this",
"code"
] |
94b89239e9ee34ac3b9c398e8d1ba67a08c68c11
|
https://github.com/ciims/ciims-modules-dashboard/blob/94b89239e9ee34ac3b9c398e8d1ba67a08c68c11/components/CiiDashboardController.php#L12-L15
|
26,075
|
ciims/ciims-modules-dashboard
|
components/CiiDashboardController.php
|
CiiDashboardController.beforeAction
|
public function beforeAction($action)
{
// Redirect to SSL if this is set in the dashboard
if (!Yii::app()->getRequest()->isSecureConnection && Cii::getConfig('forceSecureSSL', false))
$this->redirect('https://' . Yii::app()->getRequest()->serverName . Yii::app()->getRequest()->requestUri);
Yii::app()->setTheme(NULL);
return parent::beforeAction($action);
}
|
php
|
public function beforeAction($action)
{
// Redirect to SSL if this is set in the dashboard
if (!Yii::app()->getRequest()->isSecureConnection && Cii::getConfig('forceSecureSSL', false))
$this->redirect('https://' . Yii::app()->getRequest()->serverName . Yii::app()->getRequest()->requestUri);
Yii::app()->setTheme(NULL);
return parent::beforeAction($action);
}
|
[
"public",
"function",
"beforeAction",
"(",
"$",
"action",
")",
"{",
"// Redirect to SSL if this is set in the dashboard",
"if",
"(",
"!",
"Yii",
"::",
"app",
"(",
")",
"->",
"getRequest",
"(",
")",
"->",
"isSecureConnection",
"&&",
"Cii",
"::",
"getConfig",
"(",
"'forceSecureSSL'",
",",
"false",
")",
")",
"$",
"this",
"->",
"redirect",
"(",
"'https://'",
".",
"Yii",
"::",
"app",
"(",
")",
"->",
"getRequest",
"(",
")",
"->",
"serverName",
".",
"Yii",
"::",
"app",
"(",
")",
"->",
"getRequest",
"(",
")",
"->",
"requestUri",
")",
";",
"Yii",
"::",
"app",
"(",
")",
"->",
"setTheme",
"(",
"NULL",
")",
";",
"return",
"parent",
"::",
"beforeAction",
"(",
"$",
"action",
")",
";",
"}"
] |
Before action method
@param CAction $action The aciton
@return boolean
|
[
"Before",
"action",
"method"
] |
94b89239e9ee34ac3b9c398e8d1ba67a08c68c11
|
https://github.com/ciims/ciims-modules-dashboard/blob/94b89239e9ee34ac3b9c398e8d1ba67a08c68c11/components/CiiDashboardController.php#L22-L30
|
26,076
|
pluf/discount
|
src/Discount/Engine/SpecialPercent.php
|
Discount_Engine_SpecialPercent.getPrice
|
public function getPrice($price, $discount, $request)
{
if(!$this->isValid($discount, $request))
throw new Discount_Exception_InvalidDiscount();
$newPrice = $price - ($price * $discount->off_value / 100);
return $newPrice;
}
|
php
|
public function getPrice($price, $discount, $request)
{
if(!$this->isValid($discount, $request))
throw new Discount_Exception_InvalidDiscount();
$newPrice = $price - ($price * $discount->off_value / 100);
return $newPrice;
}
|
[
"public",
"function",
"getPrice",
"(",
"$",
"price",
",",
"$",
"discount",
",",
"$",
"request",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isValid",
"(",
"$",
"discount",
",",
"$",
"request",
")",
")",
"throw",
"new",
"Discount_Exception_InvalidDiscount",
"(",
")",
";",
"$",
"newPrice",
"=",
"$",
"price",
"-",
"(",
"$",
"price",
"*",
"$",
"discount",
"->",
"off_value",
"/",
"100",
")",
";",
"return",
"$",
"newPrice",
";",
"}"
] |
Compute new price after use given discount.
@param int $price
@param Discount_Discount $discount
@param Pluf_HTTP_Request $request
|
[
"Compute",
"new",
"price",
"after",
"use",
"given",
"discount",
"."
] |
b0006d6b25dd61241f51b5b098d7d546b470de26
|
https://github.com/pluf/discount/blob/b0006d6b25dd61241f51b5b098d7d546b470de26/src/Discount/Engine/SpecialPercent.php#L13-L19
|
26,077
|
SysControllers/Admin
|
src/app/Http/Controllers/Admin/FormularioContactoController.php
|
FormularioContactoController.index
|
public function index(Request $request)
{
$mensajes = $this->contactoMensajeRepo->findMessageAndPaginate($request);
return view('admin.formularios.contacto.list', compact('mensajes'));
}
|
php
|
public function index(Request $request)
{
$mensajes = $this->contactoMensajeRepo->findMessageAndPaginate($request);
return view('admin.formularios.contacto.list', compact('mensajes'));
}
|
[
"public",
"function",
"index",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"mensajes",
"=",
"$",
"this",
"->",
"contactoMensajeRepo",
"->",
"findMessageAndPaginate",
"(",
"$",
"request",
")",
";",
"return",
"view",
"(",
"'admin.formularios.contacto.list'",
",",
"compact",
"(",
"'mensajes'",
")",
")",
";",
"}"
] |
Show the form for editing the specified adminconfig.
@param Request $request
@return Response
@internal param int $id
|
[
"Show",
"the",
"form",
"for",
"editing",
"the",
"specified",
"adminconfig",
"."
] |
8f1df46aca422b87f2f522fbba610dcfa0c5f7f3
|
https://github.com/SysControllers/Admin/blob/8f1df46aca422b87f2f522fbba610dcfa0c5f7f3/src/app/Http/Controllers/Admin/FormularioContactoController.php#L26-L31
|
26,078
|
itkg/core
|
src/Itkg/Core/KernelAbstract.php
|
KernelAbstract.loadConfig
|
protected function loadConfig()
{
$this->container['app']->getConfig()->load($this->getConfigFiles());
$this->dispatchEvent(KernelEvents::CONFIG_LOADED, new KernelEvent($this->container));
}
|
php
|
protected function loadConfig()
{
$this->container['app']->getConfig()->load($this->getConfigFiles());
$this->dispatchEvent(KernelEvents::CONFIG_LOADED, new KernelEvent($this->container));
}
|
[
"protected",
"function",
"loadConfig",
"(",
")",
"{",
"$",
"this",
"->",
"container",
"[",
"'app'",
"]",
"->",
"getConfig",
"(",
")",
"->",
"load",
"(",
"$",
"this",
"->",
"getConfigFiles",
"(",
")",
")",
";",
"$",
"this",
"->",
"dispatchEvent",
"(",
"KernelEvents",
"::",
"CONFIG_LOADED",
",",
"new",
"KernelEvent",
"(",
"$",
"this",
"->",
"container",
")",
")",
";",
"}"
] |
Load Config from config files
@return $this
|
[
"Load",
"Config",
"from",
"config",
"files"
] |
e5e4efb05feb4d23b0df41f2b21fd095103e593b
|
https://github.com/itkg/core/blob/e5e4efb05feb4d23b0df41f2b21fd095103e593b/src/Itkg/Core/KernelAbstract.php#L75-L80
|
26,079
|
rollerworks/search-doctrine-orm
|
DoctrineOrmFactory.php
|
DoctrineOrmFactory.createConditionGenerator
|
public function createConditionGenerator($query, SearchCondition $searchCondition)
{
if ($query instanceof NativeQuery) {
return new NativeQueryConditionGenerator($query, $searchCondition);
}
if ($query instanceof Query || $query instanceof QueryBuilder) {
return new DqlConditionGenerator($query, $searchCondition);
}
throw new \InvalidArgumentException(
sprintf('Query "%s" is not supported by the DoctrineOrmFactory.', \get_class($query))
);
}
|
php
|
public function createConditionGenerator($query, SearchCondition $searchCondition)
{
if ($query instanceof NativeQuery) {
return new NativeQueryConditionGenerator($query, $searchCondition);
}
if ($query instanceof Query || $query instanceof QueryBuilder) {
return new DqlConditionGenerator($query, $searchCondition);
}
throw new \InvalidArgumentException(
sprintf('Query "%s" is not supported by the DoctrineOrmFactory.', \get_class($query))
);
}
|
[
"public",
"function",
"createConditionGenerator",
"(",
"$",
"query",
",",
"SearchCondition",
"$",
"searchCondition",
")",
"{",
"if",
"(",
"$",
"query",
"instanceof",
"NativeQuery",
")",
"{",
"return",
"new",
"NativeQueryConditionGenerator",
"(",
"$",
"query",
",",
"$",
"searchCondition",
")",
";",
"}",
"if",
"(",
"$",
"query",
"instanceof",
"Query",
"||",
"$",
"query",
"instanceof",
"QueryBuilder",
")",
"{",
"return",
"new",
"DqlConditionGenerator",
"(",
"$",
"query",
",",
"$",
"searchCondition",
")",
";",
"}",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Query \"%s\" is not supported by the DoctrineOrmFactory.'",
",",
"\\",
"get_class",
"(",
"$",
"query",
")",
")",
")",
";",
"}"
] |
Creates a new ConditionGenerator for the SearchCondition.
Conversions are applied using the 'doctrine_dbal_conversion' option (when present).
@param NativeQuery|Query|QueryBuilder $query Doctrine ORM (Native)Query object
@param SearchCondition $searchCondition SearchCondition object
@return NativeQueryConditionGenerator|DqlConditionGenerator
|
[
"Creates",
"a",
"new",
"ConditionGenerator",
"for",
"the",
"SearchCondition",
"."
] |
d4d7e9cfc6591d34e9d00f084c35f109f971ac4f
|
https://github.com/rollerworks/search-doctrine-orm/blob/d4d7e9cfc6591d34e9d00f084c35f109f971ac4f/DoctrineOrmFactory.php#L52-L65
|
26,080
|
rollerworks/search-doctrine-orm
|
DoctrineOrmFactory.php
|
DoctrineOrmFactory.createCachedConditionGenerator
|
public function createCachedConditionGenerator($conditionGenerator, $ttl = null): ConditionGenerator
{
if (null === $this->cacheDriver) {
return $conditionGenerator;
}
if ($conditionGenerator instanceof DqlConditionGenerator) {
return new CachedDqlConditionGenerator($conditionGenerator, $this->cacheDriver, $ttl);
} elseif ($conditionGenerator instanceof NativeQueryConditionGenerator) {
return new CachedNativeQueryConditionGenerator($conditionGenerator, $this->cacheDriver, $ttl);
}
throw new \InvalidArgumentException(
sprintf('ConditionGenerator "%s" is not supported by the DoctrineOrmFactory.', \get_class($conditionGenerator))
);
}
|
php
|
public function createCachedConditionGenerator($conditionGenerator, $ttl = null): ConditionGenerator
{
if (null === $this->cacheDriver) {
return $conditionGenerator;
}
if ($conditionGenerator instanceof DqlConditionGenerator) {
return new CachedDqlConditionGenerator($conditionGenerator, $this->cacheDriver, $ttl);
} elseif ($conditionGenerator instanceof NativeQueryConditionGenerator) {
return new CachedNativeQueryConditionGenerator($conditionGenerator, $this->cacheDriver, $ttl);
}
throw new \InvalidArgumentException(
sprintf('ConditionGenerator "%s" is not supported by the DoctrineOrmFactory.', \get_class($conditionGenerator))
);
}
|
[
"public",
"function",
"createCachedConditionGenerator",
"(",
"$",
"conditionGenerator",
",",
"$",
"ttl",
"=",
"null",
")",
":",
"ConditionGenerator",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"cacheDriver",
")",
"{",
"return",
"$",
"conditionGenerator",
";",
"}",
"if",
"(",
"$",
"conditionGenerator",
"instanceof",
"DqlConditionGenerator",
")",
"{",
"return",
"new",
"CachedDqlConditionGenerator",
"(",
"$",
"conditionGenerator",
",",
"$",
"this",
"->",
"cacheDriver",
",",
"$",
"ttl",
")",
";",
"}",
"elseif",
"(",
"$",
"conditionGenerator",
"instanceof",
"NativeQueryConditionGenerator",
")",
"{",
"return",
"new",
"CachedNativeQueryConditionGenerator",
"(",
"$",
"conditionGenerator",
",",
"$",
"this",
"->",
"cacheDriver",
",",
"$",
"ttl",
")",
";",
"}",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'ConditionGenerator \"%s\" is not supported by the DoctrineOrmFactory.'",
",",
"\\",
"get_class",
"(",
"$",
"conditionGenerator",
")",
")",
")",
";",
"}"
] |
Creates a new CachedConditionGenerator instance for the ConditionGenerator.
@param DqlConditionGenerator|NativeQueryConditionGenerator $conditionGenerator
@param int|\DateInterval|null $ttl Optional. The TTL value of this item. If no value is sent and
the driver supports TTL then the library may set a default value
for it or let the driver take care of that.
|
[
"Creates",
"a",
"new",
"CachedConditionGenerator",
"instance",
"for",
"the",
"ConditionGenerator",
"."
] |
d4d7e9cfc6591d34e9d00f084c35f109f971ac4f
|
https://github.com/rollerworks/search-doctrine-orm/blob/d4d7e9cfc6591d34e9d00f084c35f109f971ac4f/DoctrineOrmFactory.php#L75-L90
|
26,081
|
dmj/PicaRecord
|
src/HAB/Pica/Record/Helper.php
|
Helper.mapMethod
|
public static function mapMethod (array $sequence, $method, array $arguments = array())
{
if (empty($arguments)) {
$f = function ($element) use ($method) {
return $element->$method();
};
} else {
$f = function ($element) use ($method, $arguments) {
return call_user_func_array(array($element, $method), $arguments);
};
}
return array_map($f, $sequence);
}
|
php
|
public static function mapMethod (array $sequence, $method, array $arguments = array())
{
if (empty($arguments)) {
$f = function ($element) use ($method) {
return $element->$method();
};
} else {
$f = function ($element) use ($method, $arguments) {
return call_user_func_array(array($element, $method), $arguments);
};
}
return array_map($f, $sequence);
}
|
[
"public",
"static",
"function",
"mapMethod",
"(",
"array",
"$",
"sequence",
",",
"$",
"method",
",",
"array",
"$",
"arguments",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"arguments",
")",
")",
"{",
"$",
"f",
"=",
"function",
"(",
"$",
"element",
")",
"use",
"(",
"$",
"method",
")",
"{",
"return",
"$",
"element",
"->",
"$",
"method",
"(",
")",
";",
"}",
";",
"}",
"else",
"{",
"$",
"f",
"=",
"function",
"(",
"$",
"element",
")",
"use",
"(",
"$",
"method",
",",
"$",
"arguments",
")",
"{",
"return",
"call_user_func_array",
"(",
"array",
"(",
"$",
"element",
",",
"$",
"method",
")",
",",
"$",
"arguments",
")",
";",
"}",
";",
"}",
"return",
"array_map",
"(",
"$",
"f",
",",
"$",
"sequence",
")",
";",
"}"
] |
Return an array of the results of calling a method for each element of a
sequence.
@param array $sequence Sequence of objects
@param string $method Name of the method
@param array $arguments Optional array of method arguments
@return array Result of calling method on each element of sequence
|
[
"Return",
"an",
"array",
"of",
"the",
"results",
"of",
"calling",
"a",
"method",
"for",
"each",
"element",
"of",
"a",
"sequence",
"."
] |
bd5577b9a4333aa6156398b94cc870a9377061b8
|
https://github.com/dmj/PicaRecord/blob/bd5577b9a4333aa6156398b94cc870a9377061b8/src/HAB/Pica/Record/Helper.php#L56-L68
|
26,082
|
dmj/PicaRecord
|
src/HAB/Pica/Record/Helper.php
|
Helper.some
|
public static function some (array $sequence, $predicate)
{
foreach ($sequence as $element) {
if (call_user_func($predicate, $element)) {
return true;
}
}
return false;
}
|
php
|
public static function some (array $sequence, $predicate)
{
foreach ($sequence as $element) {
if (call_user_func($predicate, $element)) {
return true;
}
}
return false;
}
|
[
"public",
"static",
"function",
"some",
"(",
"array",
"$",
"sequence",
",",
"$",
"predicate",
")",
"{",
"foreach",
"(",
"$",
"sequence",
"as",
"$",
"element",
")",
"{",
"if",
"(",
"call_user_func",
"(",
"$",
"predicate",
",",
"$",
"element",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Return TRUE if at leat one element of sequence matches predicate.
@todo Make FALSE and TRUE self-evaluating, maybe
@param array $sequence Sequence
@param callback $predicate Predicate
@return boolean TRUE if at least one element matches predicate
|
[
"Return",
"TRUE",
"if",
"at",
"leat",
"one",
"element",
"of",
"sequence",
"matches",
"predicate",
"."
] |
bd5577b9a4333aa6156398b94cc870a9377061b8
|
https://github.com/dmj/PicaRecord/blob/bd5577b9a4333aa6156398b94cc870a9377061b8/src/HAB/Pica/Record/Helper.php#L90-L98
|
26,083
|
dmj/PicaRecord
|
src/HAB/Pica/Record/Helper.php
|
Helper.every
|
public static function every (array $sequence, $predicate)
{
foreach ($sequence as $element) {
if (!call_user_func($predicate, $element)) {
return false;
}
}
return true;
}
|
php
|
public static function every (array $sequence, $predicate)
{
foreach ($sequence as $element) {
if (!call_user_func($predicate, $element)) {
return false;
}
}
return true;
}
|
[
"public",
"static",
"function",
"every",
"(",
"array",
"$",
"sequence",
",",
"$",
"predicate",
")",
"{",
"foreach",
"(",
"$",
"sequence",
"as",
"$",
"element",
")",
"{",
"if",
"(",
"!",
"call_user_func",
"(",
"$",
"predicate",
",",
"$",
"element",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] |
Return TRUE if every element of sequence fullfills predicate.
@todo Make FALSE and TRUE self-evaluating, maybe
@param array $sequence Sequence
@param callback $predicate Predicate
@return boolean TRUE if every element fullfills predicate
|
[
"Return",
"TRUE",
"if",
"every",
"element",
"of",
"sequence",
"fullfills",
"predicate",
"."
] |
bd5577b9a4333aa6156398b94cc870a9377061b8
|
https://github.com/dmj/PicaRecord/blob/bd5577b9a4333aa6156398b94cc870a9377061b8/src/HAB/Pica/Record/Helper.php#L109-L117
|
26,084
|
dmj/PicaRecord
|
src/HAB/Pica/Record/Helper.php
|
Helper.flatten
|
public static function flatten (array $sequence)
{
$flat = array();
array_walk_recursive($sequence, function ($element) use (&$flat) { $flat []= $element; });
return $flat;
}
|
php
|
public static function flatten (array $sequence)
{
$flat = array();
array_walk_recursive($sequence, function ($element) use (&$flat) { $flat []= $element; });
return $flat;
}
|
[
"public",
"static",
"function",
"flatten",
"(",
"array",
"$",
"sequence",
")",
"{",
"$",
"flat",
"=",
"array",
"(",
")",
";",
"array_walk_recursive",
"(",
"$",
"sequence",
",",
"function",
"(",
"$",
"element",
")",
"use",
"(",
"&",
"$",
"flat",
")",
"{",
"$",
"flat",
"[",
"]",
"=",
"$",
"element",
";",
"}",
")",
";",
"return",
"$",
"flat",
";",
"}"
] |
Flatten sequence.
@param array $sequence Sequence
@return array Flattend sequence
|
[
"Flatten",
"sequence",
"."
] |
bd5577b9a4333aa6156398b94cc870a9377061b8
|
https://github.com/dmj/PicaRecord/blob/bd5577b9a4333aa6156398b94cc870a9377061b8/src/HAB/Pica/Record/Helper.php#L125-L130
|
26,085
|
zodream/database
|
src/Command.php
|
Command.addPrefix
|
public function addPrefix($table) {
if (strpos($table, '`') !== false) {
return $table;
}
preg_match('/([\w_\.]+)( (as )?[\w_]+)?/i', $table, $match);
$table = count($match) == 2 ? $table : $match[1];
$alias = '';
if (count($match) > 2) {
$alias = $match[2];
}
if (strpos($table, '.') !== false) {
list($schema, $table) = explode('.', $table);
return sprintf('`%s`.`%s`%s', $schema, $table, $alias);
}
if (strpos($table, '!') === 0) {
return sprintf('`%s`%s', substr($table, 1), $alias);
}
$prefix = $this->getEngine()->getConfig('prefix');
if (empty($prefix)) {
return sprintf('`%s`%s', $table, $alias);
}
return sprintf('`%s`%s', $prefix.
Str::firstReplace($table, $prefix), $alias);
}
|
php
|
public function addPrefix($table) {
if (strpos($table, '`') !== false) {
return $table;
}
preg_match('/([\w_\.]+)( (as )?[\w_]+)?/i', $table, $match);
$table = count($match) == 2 ? $table : $match[1];
$alias = '';
if (count($match) > 2) {
$alias = $match[2];
}
if (strpos($table, '.') !== false) {
list($schema, $table) = explode('.', $table);
return sprintf('`%s`.`%s`%s', $schema, $table, $alias);
}
if (strpos($table, '!') === 0) {
return sprintf('`%s`%s', substr($table, 1), $alias);
}
$prefix = $this->getEngine()->getConfig('prefix');
if (empty($prefix)) {
return sprintf('`%s`%s', $table, $alias);
}
return sprintf('`%s`%s', $prefix.
Str::firstReplace($table, $prefix), $alias);
}
|
[
"public",
"function",
"addPrefix",
"(",
"$",
"table",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"table",
",",
"'`'",
")",
"!==",
"false",
")",
"{",
"return",
"$",
"table",
";",
"}",
"preg_match",
"(",
"'/([\\w_\\.]+)( (as )?[\\w_]+)?/i'",
",",
"$",
"table",
",",
"$",
"match",
")",
";",
"$",
"table",
"=",
"count",
"(",
"$",
"match",
")",
"==",
"2",
"?",
"$",
"table",
":",
"$",
"match",
"[",
"1",
"]",
";",
"$",
"alias",
"=",
"''",
";",
"if",
"(",
"count",
"(",
"$",
"match",
")",
">",
"2",
")",
"{",
"$",
"alias",
"=",
"$",
"match",
"[",
"2",
"]",
";",
"}",
"if",
"(",
"strpos",
"(",
"$",
"table",
",",
"'.'",
")",
"!==",
"false",
")",
"{",
"list",
"(",
"$",
"schema",
",",
"$",
"table",
")",
"=",
"explode",
"(",
"'.'",
",",
"$",
"table",
")",
";",
"return",
"sprintf",
"(",
"'`%s`.`%s`%s'",
",",
"$",
"schema",
",",
"$",
"table",
",",
"$",
"alias",
")",
";",
"}",
"if",
"(",
"strpos",
"(",
"$",
"table",
",",
"'!'",
")",
"===",
"0",
")",
"{",
"return",
"sprintf",
"(",
"'`%s`%s'",
",",
"substr",
"(",
"$",
"table",
",",
"1",
")",
",",
"$",
"alias",
")",
";",
"}",
"$",
"prefix",
"=",
"$",
"this",
"->",
"getEngine",
"(",
")",
"->",
"getConfig",
"(",
"'prefix'",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"prefix",
")",
")",
"{",
"return",
"sprintf",
"(",
"'`%s`%s'",
",",
"$",
"table",
",",
"$",
"alias",
")",
";",
"}",
"return",
"sprintf",
"(",
"'`%s`%s'",
",",
"$",
"prefix",
".",
"Str",
"::",
"firstReplace",
"(",
"$",
"table",
",",
"$",
"prefix",
")",
",",
"$",
"alias",
")",
";",
"}"
] |
ADD TABLE PREFIX
@param string $table
@return string
@throws \Exception
|
[
"ADD",
"TABLE",
"PREFIX"
] |
03712219c057799d07350a3a2650c55bcc92c28e
|
https://github.com/zodream/database/blob/03712219c057799d07350a3a2650c55bcc92c28e/src/Command.php#L63-L86
|
26,086
|
KDF5000/EasyThink
|
src/ThinkPHP/Library/Vendor/SmartTemplate/class.smarttemplatedebugger.php
|
SmartTemplateDebugger.vardump
|
function vardump($var, $depth = 0)
{
if (is_array($var))
{
$result = "Array (" . count($var) . ")<BR>";
foreach(array_keys($var) as $key)
{
$result .= $this->tab[$depth] . "<B>$key</B>: " . $this->vardump($var[$key], $depth+1);
}
return $result;
}
else
{
$ret = htmlentities($var) . "<BR>";
return $ret;
}
}
|
php
|
function vardump($var, $depth = 0)
{
if (is_array($var))
{
$result = "Array (" . count($var) . ")<BR>";
foreach(array_keys($var) as $key)
{
$result .= $this->tab[$depth] . "<B>$key</B>: " . $this->vardump($var[$key], $depth+1);
}
return $result;
}
else
{
$ret = htmlentities($var) . "<BR>";
return $ret;
}
}
|
[
"function",
"vardump",
"(",
"$",
"var",
",",
"$",
"depth",
"=",
"0",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"var",
")",
")",
"{",
"$",
"result",
"=",
"\"Array (\"",
".",
"count",
"(",
"$",
"var",
")",
".",
"\")<BR>\"",
";",
"foreach",
"(",
"array_keys",
"(",
"$",
"var",
")",
"as",
"$",
"key",
")",
"{",
"$",
"result",
".=",
"$",
"this",
"->",
"tab",
"[",
"$",
"depth",
"]",
".",
"\"<B>$key</B>: \"",
".",
"$",
"this",
"->",
"vardump",
"(",
"$",
"var",
"[",
"$",
"key",
"]",
",",
"$",
"depth",
"+",
"1",
")",
";",
"}",
"return",
"$",
"result",
";",
"}",
"else",
"{",
"$",
"ret",
"=",
"htmlentities",
"(",
"$",
"var",
")",
".",
"\"<BR>\"",
";",
"return",
"$",
"ret",
";",
"}",
"}"
] |
Recursive Variable Display Output
@param mixed $var Content
@param int $depth Incremented Indent Counter for Recursive Calls
@return string Variable Content
@access private
@desc Recursive Variable Display Output
|
[
"Recursive",
"Variable",
"Display",
"Output"
] |
86efc9c8a0d504e01e2fea55868227fdc8928841
|
https://github.com/KDF5000/EasyThink/blob/86efc9c8a0d504e01e2fea55868227fdc8928841/src/ThinkPHP/Library/Vendor/SmartTemplate/class.smarttemplatedebugger.php#L384-L400
|
26,087
|
KDF5000/EasyThink
|
src/ThinkPHP/Library/Vendor/SmartTemplate/class.smarttemplatedebugger.php
|
SmartTemplateDebugger.highlight_html
|
function highlight_html ( $code )
{
$code = htmlentities($code);
$code = preg_replace('/([a-zA-Z_]+)=/', '<font color="#FF0000">$1=</font>', $code);
$code = preg_replace('/(<[\/a-zA-Z0-9&;]+)/', '<font color="#0000FF">$1</font>', $code);
$code = str_replace('<!--', '<font color="#008080"><!--', $code);
$code = str_replace('-->', '--></font>', $code);
$code = preg_replace('/[\r\n]+/', "\n", $code);
return $code;
}
|
php
|
function highlight_html ( $code )
{
$code = htmlentities($code);
$code = preg_replace('/([a-zA-Z_]+)=/', '<font color="#FF0000">$1=</font>', $code);
$code = preg_replace('/(<[\/a-zA-Z0-9&;]+)/', '<font color="#0000FF">$1</font>', $code);
$code = str_replace('<!--', '<font color="#008080"><!--', $code);
$code = str_replace('-->', '--></font>', $code);
$code = preg_replace('/[\r\n]+/', "\n", $code);
return $code;
}
|
[
"function",
"highlight_html",
"(",
"$",
"code",
")",
"{",
"$",
"code",
"=",
"htmlentities",
"(",
"$",
"code",
")",
";",
"$",
"code",
"=",
"preg_replace",
"(",
"'/([a-zA-Z_]+)=/'",
",",
"'<font color=\"#FF0000\">$1=</font>'",
",",
"$",
"code",
")",
";",
"$",
"code",
"=",
"preg_replace",
"(",
"'/(<[\\/a-zA-Z0-9&;]+)/'",
",",
"'<font color=\"#0000FF\">$1</font>'",
",",
"$",
"code",
")",
";",
"$",
"code",
"=",
"str_replace",
"(",
"'<!--'",
",",
"'<font color=\"#008080\"><!--'",
",",
"$",
"code",
")",
";",
"$",
"code",
"=",
"str_replace",
"(",
"'-->'",
",",
"'--></font>'",
",",
"$",
"code",
")",
";",
"$",
"code",
"=",
"preg_replace",
"(",
"'/[\\r\\n]+/'",
",",
"\"\\n\"",
",",
"$",
"code",
")",
";",
"return",
"$",
"code",
";",
"}"
] |
Highlight HTML Source
@param string $code HTML Source
@return string Hightlighte HTML Source
@access private
@desc Highlight HTML Source
|
[
"Highlight",
"HTML",
"Source"
] |
86efc9c8a0d504e01e2fea55868227fdc8928841
|
https://github.com/KDF5000/EasyThink/blob/86efc9c8a0d504e01e2fea55868227fdc8928841/src/ThinkPHP/Library/Vendor/SmartTemplate/class.smarttemplatedebugger.php#L445-L454
|
26,088
|
ndavison/groundwork-framework
|
src/Groundwork/Classes/Response.php
|
Response.send
|
public function send($code, $body = '')
{
if (!isset($this->codes[$code])) {
$statusCode = 500;
$body = 'API attempted to return an unknown HTTP status.';
}
// if the body wasn't defined, default to the inbuilt response
if (!$body) $body = $this->codes[$code];
header('HTTP/1.1 ' . $code . ' ' . $this->codes[$code]);
header('Content-type: application/json');
echo json_encode($body);
exit;
}
|
php
|
public function send($code, $body = '')
{
if (!isset($this->codes[$code])) {
$statusCode = 500;
$body = 'API attempted to return an unknown HTTP status.';
}
// if the body wasn't defined, default to the inbuilt response
if (!$body) $body = $this->codes[$code];
header('HTTP/1.1 ' . $code . ' ' . $this->codes[$code]);
header('Content-type: application/json');
echo json_encode($body);
exit;
}
|
[
"public",
"function",
"send",
"(",
"$",
"code",
",",
"$",
"body",
"=",
"''",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"codes",
"[",
"$",
"code",
"]",
")",
")",
"{",
"$",
"statusCode",
"=",
"500",
";",
"$",
"body",
"=",
"'API attempted to return an unknown HTTP status.'",
";",
"}",
"// if the body wasn't defined, default to the inbuilt response",
"if",
"(",
"!",
"$",
"body",
")",
"$",
"body",
"=",
"$",
"this",
"->",
"codes",
"[",
"$",
"code",
"]",
";",
"header",
"(",
"'HTTP/1.1 '",
".",
"$",
"code",
".",
"' '",
".",
"$",
"this",
"->",
"codes",
"[",
"$",
"code",
"]",
")",
";",
"header",
"(",
"'Content-type: application/json'",
")",
";",
"echo",
"json_encode",
"(",
"$",
"body",
")",
";",
"exit",
";",
"}"
] |
Output a JSON formatted response of the supplied body param, along with
the supplied code param as the HTTP status code.
@param int $code
@param mixed $body
|
[
"Output",
"a",
"JSON",
"formatted",
"response",
"of",
"the",
"supplied",
"body",
"param",
"along",
"with",
"the",
"supplied",
"code",
"param",
"as",
"the",
"HTTP",
"status",
"code",
"."
] |
c3d22a1410c8d8a07b4ca1f99a35a1181516cd6c
|
https://github.com/ndavison/groundwork-framework/blob/c3d22a1410c8d8a07b4ca1f99a35a1181516cd6c/src/Groundwork/Classes/Response.php#L46-L58
|
26,089
|
deesoft/yii2-rest
|
BasicController.php
|
BasicController.viewDetail
|
protected function viewDetail($id, $field)
{
$model = $this->findModel($id);
$definition = array_merge($model->fields(), $model->extraFields());
if (isset($definition[$field])) {
return is_string($definition[$field]) ? $model->{$definition[$field]} : call_user_func($definition[$field], $model, $field);
} elseif (in_array($field, $definition)) {
return $model->$field;
}
throw new NotFoundHttpException("Object not found: $id/$field");
}
|
php
|
protected function viewDetail($id, $field)
{
$model = $this->findModel($id);
$definition = array_merge($model->fields(), $model->extraFields());
if (isset($definition[$field])) {
return is_string($definition[$field]) ? $model->{$definition[$field]} : call_user_func($definition[$field], $model, $field);
} elseif (in_array($field, $definition)) {
return $model->$field;
}
throw new NotFoundHttpException("Object not found: $id/$field");
}
|
[
"protected",
"function",
"viewDetail",
"(",
"$",
"id",
",",
"$",
"field",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"findModel",
"(",
"$",
"id",
")",
";",
"$",
"definition",
"=",
"array_merge",
"(",
"$",
"model",
"->",
"fields",
"(",
")",
",",
"$",
"model",
"->",
"extraFields",
"(",
")",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"definition",
"[",
"$",
"field",
"]",
")",
")",
"{",
"return",
"is_string",
"(",
"$",
"definition",
"[",
"$",
"field",
"]",
")",
"?",
"$",
"model",
"->",
"{",
"$",
"definition",
"[",
"$",
"field",
"]",
"}",
":",
"call_user_func",
"(",
"$",
"definition",
"[",
"$",
"field",
"]",
",",
"$",
"model",
",",
"$",
"field",
")",
";",
"}",
"elseif",
"(",
"in_array",
"(",
"$",
"field",
",",
"$",
"definition",
")",
")",
"{",
"return",
"$",
"model",
"->",
"$",
"field",
";",
"}",
"throw",
"new",
"NotFoundHttpException",
"(",
"\"Object not found: $id/$field\"",
")",
";",
"}"
] |
Displays a single filed of model.
@param integer $id
@return mixed
|
[
"Displays",
"a",
"single",
"filed",
"of",
"model",
"."
] |
c33f145fbfa2bc138dffdd2f9408a2a461153128
|
https://github.com/deesoft/yii2-rest/blob/c33f145fbfa2bc138dffdd2f9408a2a461153128/BasicController.php#L72-L82
|
26,090
|
Danack/Jig
|
src/Jig/JigBase.php
|
JigBase.callFunction
|
protected function callFunction($functionName)
{
$functionArgs = func_get_args();
$params = array_splice($functionArgs, 1);
foreach ($this->plugins as $plugin) {
$functionList = $plugin->getFunctionList();
if (in_array($functionName, $functionList) === true) {
return $plugin->callFunction($functionName, $params);
}
}
throw new JigException("Function $functionName not known in plugins.");
}
|
php
|
protected function callFunction($functionName)
{
$functionArgs = func_get_args();
$params = array_splice($functionArgs, 1);
foreach ($this->plugins as $plugin) {
$functionList = $plugin->getFunctionList();
if (in_array($functionName, $functionList) === true) {
return $plugin->callFunction($functionName, $params);
}
}
throw new JigException("Function $functionName not known in plugins.");
}
|
[
"protected",
"function",
"callFunction",
"(",
"$",
"functionName",
")",
"{",
"$",
"functionArgs",
"=",
"func_get_args",
"(",
")",
";",
"$",
"params",
"=",
"array_splice",
"(",
"$",
"functionArgs",
",",
"1",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"plugins",
"as",
"$",
"plugin",
")",
"{",
"$",
"functionList",
"=",
"$",
"plugin",
"->",
"getFunctionList",
"(",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"functionName",
",",
"$",
"functionList",
")",
"===",
"true",
")",
"{",
"return",
"$",
"plugin",
"->",
"callFunction",
"(",
"$",
"functionName",
",",
"$",
"params",
")",
";",
"}",
"}",
"throw",
"new",
"JigException",
"(",
"\"Function $functionName not known in plugins.\"",
")",
";",
"}"
] |
Used to call a function in a template
@param $functionName
@return mixed
@throws JigException
|
[
"Used",
"to",
"call",
"a",
"function",
"in",
"a",
"template"
] |
b11106bc7d634add9873bf246eda1dadb059ed7a
|
https://github.com/Danack/Jig/blob/b11106bc7d634add9873bf246eda1dadb059ed7a/src/Jig/JigBase.php#L59-L72
|
26,091
|
Danack/Jig
|
src/Jig/JigBase.php
|
JigBase.startRenderBlock
|
protected function startRenderBlock($blockName, $segmentText)
{
foreach ($this->plugins as $plugin) {
$blockRenderList = $plugin->getBlockRenderList();
if (in_array($blockName, $blockRenderList) === true) {
echo $plugin->callBlockRenderStart($blockName, $segmentText);
ob_start();
return;
}
}
throw new JigException("Block $blockName not known for starting block in plugins.");
}
|
php
|
protected function startRenderBlock($blockName, $segmentText)
{
foreach ($this->plugins as $plugin) {
$blockRenderList = $plugin->getBlockRenderList();
if (in_array($blockName, $blockRenderList) === true) {
echo $plugin->callBlockRenderStart($blockName, $segmentText);
ob_start();
return;
}
}
throw new JigException("Block $blockName not known for starting block in plugins.");
}
|
[
"protected",
"function",
"startRenderBlock",
"(",
"$",
"blockName",
",",
"$",
"segmentText",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"plugins",
"as",
"$",
"plugin",
")",
"{",
"$",
"blockRenderList",
"=",
"$",
"plugin",
"->",
"getBlockRenderList",
"(",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"blockName",
",",
"$",
"blockRenderList",
")",
"===",
"true",
")",
"{",
"echo",
"$",
"plugin",
"->",
"callBlockRenderStart",
"(",
"$",
"blockName",
",",
"$",
"segmentText",
")",
";",
"ob_start",
"(",
")",
";",
"return",
";",
"}",
"}",
"throw",
"new",
"JigException",
"(",
"\"Block $blockName not known for starting block in plugins.\"",
")",
";",
"}"
] |
Called when a block is started in a template.
@param $blockName
@param $segmentText
@throws JigException
|
[
"Called",
"when",
"a",
"block",
"is",
"started",
"in",
"a",
"template",
"."
] |
b11106bc7d634add9873bf246eda1dadb059ed7a
|
https://github.com/Danack/Jig/blob/b11106bc7d634add9873bf246eda1dadb059ed7a/src/Jig/JigBase.php#L81-L92
|
26,092
|
Danack/Jig
|
src/Jig/JigBase.php
|
JigBase.endRenderBlock
|
protected function endRenderBlock($blockName)
{
$contents = ob_get_contents();
ob_end_clean();
foreach ($this->plugins as $plugin) {
$blockRenderList = $plugin->getBlockRenderList();
if (in_array($blockName, $blockRenderList) === true) {
echo $plugin->callBlockRenderEnd($blockName, $contents);
return;
}
}
echo $contents;
throw new JigException("Block $blockName not known for ending block in plugins.");
}
|
php
|
protected function endRenderBlock($blockName)
{
$contents = ob_get_contents();
ob_end_clean();
foreach ($this->plugins as $plugin) {
$blockRenderList = $plugin->getBlockRenderList();
if (in_array($blockName, $blockRenderList) === true) {
echo $plugin->callBlockRenderEnd($blockName, $contents);
return;
}
}
echo $contents;
throw new JigException("Block $blockName not known for ending block in plugins.");
}
|
[
"protected",
"function",
"endRenderBlock",
"(",
"$",
"blockName",
")",
"{",
"$",
"contents",
"=",
"ob_get_contents",
"(",
")",
";",
"ob_end_clean",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"plugins",
"as",
"$",
"plugin",
")",
"{",
"$",
"blockRenderList",
"=",
"$",
"plugin",
"->",
"getBlockRenderList",
"(",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"blockName",
",",
"$",
"blockRenderList",
")",
"===",
"true",
")",
"{",
"echo",
"$",
"plugin",
"->",
"callBlockRenderEnd",
"(",
"$",
"blockName",
",",
"$",
"contents",
")",
";",
"return",
";",
"}",
"}",
"echo",
"$",
"contents",
";",
"throw",
"new",
"JigException",
"(",
"\"Block $blockName not known for ending block in plugins.\"",
")",
";",
"}"
] |
Called when a block is ended in a template.
@param $blockName
@throws JigException
|
[
"Called",
"when",
"a",
"block",
"is",
"ended",
"in",
"a",
"template",
"."
] |
b11106bc7d634add9873bf246eda1dadb059ed7a
|
https://github.com/Danack/Jig/blob/b11106bc7d634add9873bf246eda1dadb059ed7a/src/Jig/JigBase.php#L99-L112
|
26,093
|
oliverde8/MPDedicatedServerBundle
|
Service/DedicatedServer.php
|
DedicatedServer.getServerInfo
|
public function getServerInfo($login)
{
static $lockAcquired = false;
if (isset($this->servers[$login])) {
$cacheKey = $this->_getServerInfoCacheKey($login);
$cacheResult = $this->serverInfoCache->fetch($cacheKey);
if ($cacheResult) {
return $cacheResult;
} else if (!$lockAcquired) {
// We don't have the lock, we need to get it before asking the dedicated.
// Start Protected code.
$this->semaphore->aquire($cacheKey);
$lockAcquired = true;
// Ask for data again, if cache filled from other instance then data from cache, if not wil do a call.
$data = $this->getServerInfo($login);
// End protected code.
$lockAcquired = false;
$this->semaphore->release($cacheKey);
return $data;
} else {
// We have the lock, data not in cache get data from the server.
$data = $this->_getServerInfo($login);
$this->serverInfoCache->save($cacheKey, $data, $this->cacheTimeOutInfo);
return $data;
}
}
return null;
}
|
php
|
public function getServerInfo($login)
{
static $lockAcquired = false;
if (isset($this->servers[$login])) {
$cacheKey = $this->_getServerInfoCacheKey($login);
$cacheResult = $this->serverInfoCache->fetch($cacheKey);
if ($cacheResult) {
return $cacheResult;
} else if (!$lockAcquired) {
// We don't have the lock, we need to get it before asking the dedicated.
// Start Protected code.
$this->semaphore->aquire($cacheKey);
$lockAcquired = true;
// Ask for data again, if cache filled from other instance then data from cache, if not wil do a call.
$data = $this->getServerInfo($login);
// End protected code.
$lockAcquired = false;
$this->semaphore->release($cacheKey);
return $data;
} else {
// We have the lock, data not in cache get data from the server.
$data = $this->_getServerInfo($login);
$this->serverInfoCache->save($cacheKey, $data, $this->cacheTimeOutInfo);
return $data;
}
}
return null;
}
|
[
"public",
"function",
"getServerInfo",
"(",
"$",
"login",
")",
"{",
"static",
"$",
"lockAcquired",
"=",
"false",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"servers",
"[",
"$",
"login",
"]",
")",
")",
"{",
"$",
"cacheKey",
"=",
"$",
"this",
"->",
"_getServerInfoCacheKey",
"(",
"$",
"login",
")",
";",
"$",
"cacheResult",
"=",
"$",
"this",
"->",
"serverInfoCache",
"->",
"fetch",
"(",
"$",
"cacheKey",
")",
";",
"if",
"(",
"$",
"cacheResult",
")",
"{",
"return",
"$",
"cacheResult",
";",
"}",
"else",
"if",
"(",
"!",
"$",
"lockAcquired",
")",
"{",
"// We don't have the lock, we need to get it before asking the dedicated.",
"// Start Protected code.",
"$",
"this",
"->",
"semaphore",
"->",
"aquire",
"(",
"$",
"cacheKey",
")",
";",
"$",
"lockAcquired",
"=",
"true",
";",
"// Ask for data again, if cache filled from other instance then data from cache, if not wil do a call.",
"$",
"data",
"=",
"$",
"this",
"->",
"getServerInfo",
"(",
"$",
"login",
")",
";",
"// End protected code.",
"$",
"lockAcquired",
"=",
"false",
";",
"$",
"this",
"->",
"semaphore",
"->",
"release",
"(",
"$",
"cacheKey",
")",
";",
"return",
"$",
"data",
";",
"}",
"else",
"{",
"// We have the lock, data not in cache get data from the server.",
"$",
"data",
"=",
"$",
"this",
"->",
"_getServerInfo",
"(",
"$",
"login",
")",
";",
"$",
"this",
"->",
"serverInfoCache",
"->",
"save",
"(",
"$",
"cacheKey",
",",
"$",
"data",
",",
"$",
"this",
"->",
"cacheTimeOutInfo",
")",
";",
"return",
"$",
"data",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
Returns server information. If server information not in cache will make call to the dedicated server.
Try to use this with ajax calls in order to have a faster website.
@param string $login Login of the server
@return ServerInfo|null
|
[
"Returns",
"server",
"information",
".",
"If",
"server",
"information",
"not",
"in",
"cache",
"will",
"make",
"call",
"to",
"the",
"dedicated",
"server",
".",
"Try",
"to",
"use",
"this",
"with",
"ajax",
"calls",
"in",
"order",
"to",
"have",
"a",
"faster",
"website",
"."
] |
c0cab0b0089a1273032ddf4bbf0287e7aee8fceb
|
https://github.com/oliverde8/MPDedicatedServerBundle/blob/c0cab0b0089a1273032ddf4bbf0287e7aee8fceb/Service/DedicatedServer.php#L73-L107
|
26,094
|
oliverde8/MPDedicatedServerBundle
|
Service/DedicatedServer.php
|
DedicatedServer.getServerChatLines
|
public function getServerChatLines($login)
{
static $lockAcquired = false;
if (isset($this->servers[$login])) {
$cacheKey = $this->_getServerChatCacheKey($login);
$cacheResult = $this->serverInfoCache->fetch($cacheKey);
if ($cacheResult) {
return $cacheResult;
} else if (!$lockAcquired) {
// We don't have the lock, we need to get it before asking the dedicated.
// Start Protected code.
$this->semaphore->aquire($cacheKey);
$lockAcquired = true;
// Ask for data again, if cache filled from other instance then data from cache, if not wil do a call.
$data = $this->getServerChatLines($login);
// End protected code.
$lockAcquired = false;
$this->semaphore->release($cacheKey);
return $data;
} else {
$data = array();
try {
$connection = $this->getConnection($login);
if ($connection) {
$data = $connection->getChatLines();
}
} catch (\Exception $e) {
}
$this->serverInfoCache->save($cacheKey, $data, $this->cacheTimeOutChat);
return $data;
}
}
return null;
}
|
php
|
public function getServerChatLines($login)
{
static $lockAcquired = false;
if (isset($this->servers[$login])) {
$cacheKey = $this->_getServerChatCacheKey($login);
$cacheResult = $this->serverInfoCache->fetch($cacheKey);
if ($cacheResult) {
return $cacheResult;
} else if (!$lockAcquired) {
// We don't have the lock, we need to get it before asking the dedicated.
// Start Protected code.
$this->semaphore->aquire($cacheKey);
$lockAcquired = true;
// Ask for data again, if cache filled from other instance then data from cache, if not wil do a call.
$data = $this->getServerChatLines($login);
// End protected code.
$lockAcquired = false;
$this->semaphore->release($cacheKey);
return $data;
} else {
$data = array();
try {
$connection = $this->getConnection($login);
if ($connection) {
$data = $connection->getChatLines();
}
} catch (\Exception $e) {
}
$this->serverInfoCache->save($cacheKey, $data, $this->cacheTimeOutChat);
return $data;
}
}
return null;
}
|
[
"public",
"function",
"getServerChatLines",
"(",
"$",
"login",
")",
"{",
"static",
"$",
"lockAcquired",
"=",
"false",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"servers",
"[",
"$",
"login",
"]",
")",
")",
"{",
"$",
"cacheKey",
"=",
"$",
"this",
"->",
"_getServerChatCacheKey",
"(",
"$",
"login",
")",
";",
"$",
"cacheResult",
"=",
"$",
"this",
"->",
"serverInfoCache",
"->",
"fetch",
"(",
"$",
"cacheKey",
")",
";",
"if",
"(",
"$",
"cacheResult",
")",
"{",
"return",
"$",
"cacheResult",
";",
"}",
"else",
"if",
"(",
"!",
"$",
"lockAcquired",
")",
"{",
"// We don't have the lock, we need to get it before asking the dedicated.",
"// Start Protected code.",
"$",
"this",
"->",
"semaphore",
"->",
"aquire",
"(",
"$",
"cacheKey",
")",
";",
"$",
"lockAcquired",
"=",
"true",
";",
"// Ask for data again, if cache filled from other instance then data from cache, if not wil do a call.",
"$",
"data",
"=",
"$",
"this",
"->",
"getServerChatLines",
"(",
"$",
"login",
")",
";",
"// End protected code.",
"$",
"lockAcquired",
"=",
"false",
";",
"$",
"this",
"->",
"semaphore",
"->",
"release",
"(",
"$",
"cacheKey",
")",
";",
"return",
"$",
"data",
";",
"}",
"else",
"{",
"$",
"data",
"=",
"array",
"(",
")",
";",
"try",
"{",
"$",
"connection",
"=",
"$",
"this",
"->",
"getConnection",
"(",
"$",
"login",
")",
";",
"if",
"(",
"$",
"connection",
")",
"{",
"$",
"data",
"=",
"$",
"connection",
"->",
"getChatLines",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"}",
"$",
"this",
"->",
"serverInfoCache",
"->",
"save",
"(",
"$",
"cacheKey",
",",
"$",
"data",
",",
"$",
"this",
"->",
"cacheTimeOutChat",
")",
";",
"return",
"$",
"data",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
Returns chat lines.
Try to use this with ajax calls in order to have a faster website.
@param string $login Login of the server
@return ServerInfo|null
|
[
"Returns",
"chat",
"lines",
".",
"Try",
"to",
"use",
"this",
"with",
"ajax",
"calls",
"in",
"order",
"to",
"have",
"a",
"faster",
"website",
"."
] |
c0cab0b0089a1273032ddf4bbf0287e7aee8fceb
|
https://github.com/oliverde8/MPDedicatedServerBundle/blob/c0cab0b0089a1273032ddf4bbf0287e7aee8fceb/Service/DedicatedServer.php#L117-L158
|
26,095
|
oliverde8/MPDedicatedServerBundle
|
Service/DedicatedServer.php
|
DedicatedServer.getMapList
|
public function getMapList($login) {
static $lockAcquired = false;
if (isset($this->servers[$login])) {
$cacheKey = $this->_getServerMapsCacheKey($login);
$cacheResult = $this->serverInfoCache->fetch($cacheKey);
if ($cacheResult) {
return $cacheResult;
} else if (!$lockAcquired) {
// We don't have the lock, we need to get it before asking the dedicated.
// Start Protected code.
$this->semaphore->aquire($cacheKey);
$lockAcquired = true;
// Ask for data again, if cache filled from other instance then data from cache, if not wil do a call.
$data = $this->getMapList($login);
// End protected code.
$lockAcquired = false;
$this->semaphore->release($cacheKey);
return $data;
} else {
$data = array();
try {
$connection = $this->getConnection($login);
if ($connection) {
$data = $connection->getMapList(-1, 0);
$this->serverInfoCache->save($cacheKey, $data, $this->cacheTimeOutMap);
}
} catch (\Exception $e) {
//If can't connect keep shorter in cache
$this->serverInfoCache->save($cacheKey, array(), $this->cacheTimeOutMapRetry);
}
return $data;
}
}
}
|
php
|
public function getMapList($login) {
static $lockAcquired = false;
if (isset($this->servers[$login])) {
$cacheKey = $this->_getServerMapsCacheKey($login);
$cacheResult = $this->serverInfoCache->fetch($cacheKey);
if ($cacheResult) {
return $cacheResult;
} else if (!$lockAcquired) {
// We don't have the lock, we need to get it before asking the dedicated.
// Start Protected code.
$this->semaphore->aquire($cacheKey);
$lockAcquired = true;
// Ask for data again, if cache filled from other instance then data from cache, if not wil do a call.
$data = $this->getMapList($login);
// End protected code.
$lockAcquired = false;
$this->semaphore->release($cacheKey);
return $data;
} else {
$data = array();
try {
$connection = $this->getConnection($login);
if ($connection) {
$data = $connection->getMapList(-1, 0);
$this->serverInfoCache->save($cacheKey, $data, $this->cacheTimeOutMap);
}
} catch (\Exception $e) {
//If can't connect keep shorter in cache
$this->serverInfoCache->save($cacheKey, array(), $this->cacheTimeOutMapRetry);
}
return $data;
}
}
}
|
[
"public",
"function",
"getMapList",
"(",
"$",
"login",
")",
"{",
"static",
"$",
"lockAcquired",
"=",
"false",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"servers",
"[",
"$",
"login",
"]",
")",
")",
"{",
"$",
"cacheKey",
"=",
"$",
"this",
"->",
"_getServerMapsCacheKey",
"(",
"$",
"login",
")",
";",
"$",
"cacheResult",
"=",
"$",
"this",
"->",
"serverInfoCache",
"->",
"fetch",
"(",
"$",
"cacheKey",
")",
";",
"if",
"(",
"$",
"cacheResult",
")",
"{",
"return",
"$",
"cacheResult",
";",
"}",
"else",
"if",
"(",
"!",
"$",
"lockAcquired",
")",
"{",
"// We don't have the lock, we need to get it before asking the dedicated.",
"// Start Protected code.",
"$",
"this",
"->",
"semaphore",
"->",
"aquire",
"(",
"$",
"cacheKey",
")",
";",
"$",
"lockAcquired",
"=",
"true",
";",
"// Ask for data again, if cache filled from other instance then data from cache, if not wil do a call.",
"$",
"data",
"=",
"$",
"this",
"->",
"getMapList",
"(",
"$",
"login",
")",
";",
"// End protected code.",
"$",
"lockAcquired",
"=",
"false",
";",
"$",
"this",
"->",
"semaphore",
"->",
"release",
"(",
"$",
"cacheKey",
")",
";",
"return",
"$",
"data",
";",
"}",
"else",
"{",
"$",
"data",
"=",
"array",
"(",
")",
";",
"try",
"{",
"$",
"connection",
"=",
"$",
"this",
"->",
"getConnection",
"(",
"$",
"login",
")",
";",
"if",
"(",
"$",
"connection",
")",
"{",
"$",
"data",
"=",
"$",
"connection",
"->",
"getMapList",
"(",
"-",
"1",
",",
"0",
")",
";",
"$",
"this",
"->",
"serverInfoCache",
"->",
"save",
"(",
"$",
"cacheKey",
",",
"$",
"data",
",",
"$",
"this",
"->",
"cacheTimeOutMap",
")",
";",
"}",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"//If can't connect keep shorter in cache",
"$",
"this",
"->",
"serverInfoCache",
"->",
"save",
"(",
"$",
"cacheKey",
",",
"array",
"(",
")",
",",
"$",
"this",
"->",
"cacheTimeOutMapRetry",
")",
";",
"}",
"return",
"$",
"data",
";",
"}",
"}",
"}"
] |
Returns list of maps on the server. If list of map not in cache will make a call to the dedicatd server.
Try to use this with ajax calls in order to have a faster website.
@param string $login Login of the server
@return \Maniaplanet\DedicatedServer\Structures\Map[]
|
[
"Returns",
"list",
"of",
"maps",
"on",
"the",
"server",
".",
"If",
"list",
"of",
"map",
"not",
"in",
"cache",
"will",
"make",
"a",
"call",
"to",
"the",
"dedicatd",
"server",
".",
"Try",
"to",
"use",
"this",
"with",
"ajax",
"calls",
"in",
"order",
"to",
"have",
"a",
"faster",
"website",
"."
] |
c0cab0b0089a1273032ddf4bbf0287e7aee8fceb
|
https://github.com/oliverde8/MPDedicatedServerBundle/blob/c0cab0b0089a1273032ddf4bbf0287e7aee8fceb/Service/DedicatedServer.php#L168-L207
|
26,096
|
oliverde8/MPDedicatedServerBundle
|
Service/DedicatedServer.php
|
DedicatedServer.getServerNames
|
public function getServerNames() {
$serverNames = array();
foreach($this->servers as $login => $data) {
$serverNames[$login] = $data['name'];
}
return $serverNames;
}
|
php
|
public function getServerNames() {
$serverNames = array();
foreach($this->servers as $login => $data) {
$serverNames[$login] = $data['name'];
}
return $serverNames;
}
|
[
"public",
"function",
"getServerNames",
"(",
")",
"{",
"$",
"serverNames",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"servers",
"as",
"$",
"login",
"=>",
"$",
"data",
")",
"{",
"$",
"serverNames",
"[",
"$",
"login",
"]",
"=",
"$",
"data",
"[",
"'name'",
"]",
";",
"}",
"return",
"$",
"serverNames",
";",
"}"
] |
Returns login, server name association.
This is the name you defined in the config and therfore won't make any dedicated calls.
@return String[]
|
[
"Returns",
"login",
"server",
"name",
"association",
".",
"This",
"is",
"the",
"name",
"you",
"defined",
"in",
"the",
"config",
"and",
"therfore",
"won",
"t",
"make",
"any",
"dedicated",
"calls",
"."
] |
c0cab0b0089a1273032ddf4bbf0287e7aee8fceb
|
https://github.com/oliverde8/MPDedicatedServerBundle/blob/c0cab0b0089a1273032ddf4bbf0287e7aee8fceb/Service/DedicatedServer.php#L215-L221
|
26,097
|
oliverde8/MPDedicatedServerBundle
|
Service/DedicatedServer.php
|
DedicatedServer.getConnection
|
public function getConnection($login) {
if (isset($this->servers[$login])) {
if (!isset($this->connections[$login])) {
$conf = $this->servers[$login];
$this->connections[$login] = Connection::factory($conf['host'], $conf['port'], 1, $conf['user'], $conf['password']);
}
return $this->connections[$login];
}
return null;
}
|
php
|
public function getConnection($login) {
if (isset($this->servers[$login])) {
if (!isset($this->connections[$login])) {
$conf = $this->servers[$login];
$this->connections[$login] = Connection::factory($conf['host'], $conf['port'], 1, $conf['user'], $conf['password']);
}
return $this->connections[$login];
}
return null;
}
|
[
"public",
"function",
"getConnection",
"(",
"$",
"login",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"servers",
"[",
"$",
"login",
"]",
")",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"connections",
"[",
"$",
"login",
"]",
")",
")",
"{",
"$",
"conf",
"=",
"$",
"this",
"->",
"servers",
"[",
"$",
"login",
"]",
";",
"$",
"this",
"->",
"connections",
"[",
"$",
"login",
"]",
"=",
"Connection",
"::",
"factory",
"(",
"$",
"conf",
"[",
"'host'",
"]",
",",
"$",
"conf",
"[",
"'port'",
"]",
",",
"1",
",",
"$",
"conf",
"[",
"'user'",
"]",
",",
"$",
"conf",
"[",
"'password'",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"connections",
"[",
"$",
"login",
"]",
";",
"}",
"return",
"null",
";",
"}"
] |
Connects to the dedicated server API, if connection already established will send existing connextion
@param string $login Server to connect to
@return Connection
|
[
"Connects",
"to",
"the",
"dedicated",
"server",
"API",
"if",
"connection",
"already",
"established",
"will",
"send",
"existing",
"connextion"
] |
c0cab0b0089a1273032ddf4bbf0287e7aee8fceb
|
https://github.com/oliverde8/MPDedicatedServerBundle/blob/c0cab0b0089a1273032ddf4bbf0287e7aee8fceb/Service/DedicatedServer.php#L301-L312
|
26,098
|
balintsera/evista-perform
|
src/FormMarkupTranspiler.php
|
FormMarkupTranspiler.findFormClassName
|
public function findFormClassName()
{
$this->runIfNotCached(
'formClassName',
function () {
return $this->findFormTag()->attr(self:: FORM_CLASS_NAME_ATTR_NAME);
}
);
return $this->formClassName;
}
|
php
|
public function findFormClassName()
{
$this->runIfNotCached(
'formClassName',
function () {
return $this->findFormTag()->attr(self:: FORM_CLASS_NAME_ATTR_NAME);
}
);
return $this->formClassName;
}
|
[
"public",
"function",
"findFormClassName",
"(",
")",
"{",
"$",
"this",
"->",
"runIfNotCached",
"(",
"'formClassName'",
",",
"function",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"findFormTag",
"(",
")",
"->",
"attr",
"(",
"self",
"::",
"FORM_CLASS_NAME_ATTR_NAME",
")",
";",
"}",
")",
";",
"return",
"$",
"this",
"->",
"formClassName",
";",
"}"
] |
Get class-name for the form
|
[
"Get",
"class",
"-",
"name",
"for",
"the",
"form"
] |
2b8723852ebe824ed721f30293e1e0d2c14f4b21
|
https://github.com/balintsera/evista-perform/blob/2b8723852ebe824ed721f30293e1e0d2c14f4b21/src/FormMarkupTranspiler.php#L70-L80
|
26,099
|
balintsera/evista-perform
|
src/FormMarkupTranspiler.php
|
FormMarkupTranspiler.transpileFields
|
private function transpileFields()
{
$formElements = 'input, select, textarea, button';
$this->findFormTag()->filter($formElements)->each(
function (Crawler $node, $i) {
// If it has a type attr, use as type
if (null !== $node->attr('type')) {
$type = $node->attr('type');
} else {
$type = $node->nodeName();
}
// Node name cames back with apostrophs on some servers
$type = str_replace('\"', '', $type);
// Create a FormField and get default attributes (name, value, validation, required)
$field = $this->fieldFactory($type, $node);
// complex form elements 1: select -> options
if ($type === 'select') {
$options = $node->filter('option');
// FormField
$options->each(
function ($option) use ($field) {
$optionField = $this->fieldFactory('option', $option);
$field->addOption($optionField);
}
);
}
// complex form elements: handle file uploads
if ($type === 'file') {
try {
$field->compactFiles($_FILES, $this->uploadDir);
} catch (NoFileUploadedException $noFileEx) {
// throw validation error?
}
}
// Add to all fields
$this->fields[$field->getName()] = $field;
}
);
return $this->fields;
}
|
php
|
private function transpileFields()
{
$formElements = 'input, select, textarea, button';
$this->findFormTag()->filter($formElements)->each(
function (Crawler $node, $i) {
// If it has a type attr, use as type
if (null !== $node->attr('type')) {
$type = $node->attr('type');
} else {
$type = $node->nodeName();
}
// Node name cames back with apostrophs on some servers
$type = str_replace('\"', '', $type);
// Create a FormField and get default attributes (name, value, validation, required)
$field = $this->fieldFactory($type, $node);
// complex form elements 1: select -> options
if ($type === 'select') {
$options = $node->filter('option');
// FormField
$options->each(
function ($option) use ($field) {
$optionField = $this->fieldFactory('option', $option);
$field->addOption($optionField);
}
);
}
// complex form elements: handle file uploads
if ($type === 'file') {
try {
$field->compactFiles($_FILES, $this->uploadDir);
} catch (NoFileUploadedException $noFileEx) {
// throw validation error?
}
}
// Add to all fields
$this->fields[$field->getName()] = $field;
}
);
return $this->fields;
}
|
[
"private",
"function",
"transpileFields",
"(",
")",
"{",
"$",
"formElements",
"=",
"'input, select, textarea, button'",
";",
"$",
"this",
"->",
"findFormTag",
"(",
")",
"->",
"filter",
"(",
"$",
"formElements",
")",
"->",
"each",
"(",
"function",
"(",
"Crawler",
"$",
"node",
",",
"$",
"i",
")",
"{",
"// If it has a type attr, use as type",
"if",
"(",
"null",
"!==",
"$",
"node",
"->",
"attr",
"(",
"'type'",
")",
")",
"{",
"$",
"type",
"=",
"$",
"node",
"->",
"attr",
"(",
"'type'",
")",
";",
"}",
"else",
"{",
"$",
"type",
"=",
"$",
"node",
"->",
"nodeName",
"(",
")",
";",
"}",
"// Node name cames back with apostrophs on some servers",
"$",
"type",
"=",
"str_replace",
"(",
"'\\\"'",
",",
"''",
",",
"$",
"type",
")",
";",
"// Create a FormField and get default attributes (name, value, validation, required)",
"$",
"field",
"=",
"$",
"this",
"->",
"fieldFactory",
"(",
"$",
"type",
",",
"$",
"node",
")",
";",
"// complex form elements 1: select -> options",
"if",
"(",
"$",
"type",
"===",
"'select'",
")",
"{",
"$",
"options",
"=",
"$",
"node",
"->",
"filter",
"(",
"'option'",
")",
";",
"// FormField",
"$",
"options",
"->",
"each",
"(",
"function",
"(",
"$",
"option",
")",
"use",
"(",
"$",
"field",
")",
"{",
"$",
"optionField",
"=",
"$",
"this",
"->",
"fieldFactory",
"(",
"'option'",
",",
"$",
"option",
")",
";",
"$",
"field",
"->",
"addOption",
"(",
"$",
"optionField",
")",
";",
"}",
")",
";",
"}",
"// complex form elements: handle file uploads",
"if",
"(",
"$",
"type",
"===",
"'file'",
")",
"{",
"try",
"{",
"$",
"field",
"->",
"compactFiles",
"(",
"$",
"_FILES",
",",
"$",
"this",
"->",
"uploadDir",
")",
";",
"}",
"catch",
"(",
"NoFileUploadedException",
"$",
"noFileEx",
")",
"{",
"// throw validation error?",
"}",
"}",
"// Add to all fields",
"$",
"this",
"->",
"fields",
"[",
"$",
"field",
"->",
"getName",
"(",
")",
"]",
"=",
"$",
"field",
";",
"}",
")",
";",
"return",
"$",
"this",
"->",
"fields",
";",
"}"
] |
Find fields in markup
|
[
"Find",
"fields",
"in",
"markup"
] |
2b8723852ebe824ed721f30293e1e0d2c14f4b21
|
https://github.com/balintsera/evista-perform/blob/2b8723852ebe824ed721f30293e1e0d2c14f4b21/src/FormMarkupTranspiler.php#L112-L161
|
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.