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
|
---|---|---|---|---|---|---|---|---|---|---|---|
20,300 |
ezsystems/ezcomments-ls-extension
|
classes/ezcomnotifcationmanager.php
|
ezcomNotificationManager.sendNotificationInMany
|
public function sendNotificationInMany( $subscriber, $contentObject, $comment, $tpl = null )
{
if ( is_null( $tpl ) )
{
$tpl = eZTemplate::factory();
}
$tpl->setVariable( 'subscriber', $subscriber );
$tpl->setVariable( 'contentobject', $contentObject );
$tpl->setVariable( 'comment', $comment );
$subject = $tpl->fetch( $this->subjectTemplatePath );
$body = $tpl->fetch( $this->bodyTemplatePath );
$this->executeSending( $subject, $body, $subscriber );
}
|
php
|
public function sendNotificationInMany( $subscriber, $contentObject, $comment, $tpl = null )
{
if ( is_null( $tpl ) )
{
$tpl = eZTemplate::factory();
}
$tpl->setVariable( 'subscriber', $subscriber );
$tpl->setVariable( 'contentobject', $contentObject );
$tpl->setVariable( 'comment', $comment );
$subject = $tpl->fetch( $this->subjectTemplatePath );
$body = $tpl->fetch( $this->bodyTemplatePath );
$this->executeSending( $subject, $body, $subscriber );
}
|
[
"public",
"function",
"sendNotificationInMany",
"(",
"$",
"subscriber",
",",
"$",
"contentObject",
",",
"$",
"comment",
",",
"$",
"tpl",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"tpl",
")",
")",
"{",
"$",
"tpl",
"=",
"eZTemplate",
"::",
"factory",
"(",
")",
";",
"}",
"$",
"tpl",
"->",
"setVariable",
"(",
"'subscriber'",
",",
"$",
"subscriber",
")",
";",
"$",
"tpl",
"->",
"setVariable",
"(",
"'contentobject'",
",",
"$",
"contentObject",
")",
";",
"$",
"tpl",
"->",
"setVariable",
"(",
"'comment'",
",",
"$",
"comment",
")",
";",
"$",
"subject",
"=",
"$",
"tpl",
"->",
"fetch",
"(",
"$",
"this",
"->",
"subjectTemplatePath",
")",
";",
"$",
"body",
"=",
"$",
"tpl",
"->",
"fetch",
"(",
"$",
"this",
"->",
"bodyTemplatePath",
")",
";",
"$",
"this",
"->",
"executeSending",
"(",
"$",
"subject",
",",
"$",
"body",
",",
"$",
"subscriber",
")",
";",
"}"
] |
send one notification with one comment by one comment
Exception if error happens
@param $subscriber
@param $contentObject
@param $comment
@param $tpl
@return void
|
[
"send",
"one",
"notification",
"with",
"one",
"comment",
"by",
"one",
"comment",
"Exception",
"if",
"error",
"happens"
] |
2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5
|
https://github.com/ezsystems/ezcomments-ls-extension/blob/2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5/classes/ezcomnotifcationmanager.php#L41-L54
|
20,301 |
ezsystems/ezcomments-ls-extension
|
classes/ezcomnotifcationmanager.php
|
ezcomNotificationManager.sendNotificationInOne
|
public function sendNotificationInOne( $subscriber, $contentObject, $commentList = null, $tpl = null )
{
if ( is_null( $tpl ) )
{
$tpl = eZTemplate::factory();
}
$tpl->setVariable( 'subscriber', $subscriber );
$tpl->setVariable( 'contentobject', $contentObject );
if ( !is_null( $commentList ) )
{
$tpl->setVariable( 'comment_list', $commentList );
}
$subject = $tpl->fetch( $this->multiSubjectTemplatePath );
$body = $tpl->fetch( $this->multiBodyTemplatePath );
$this->executeSending( $subject, $body, $subscriber );
}
|
php
|
public function sendNotificationInOne( $subscriber, $contentObject, $commentList = null, $tpl = null )
{
if ( is_null( $tpl ) )
{
$tpl = eZTemplate::factory();
}
$tpl->setVariable( 'subscriber', $subscriber );
$tpl->setVariable( 'contentobject', $contentObject );
if ( !is_null( $commentList ) )
{
$tpl->setVariable( 'comment_list', $commentList );
}
$subject = $tpl->fetch( $this->multiSubjectTemplatePath );
$body = $tpl->fetch( $this->multiBodyTemplatePath );
$this->executeSending( $subject, $body, $subscriber );
}
|
[
"public",
"function",
"sendNotificationInOne",
"(",
"$",
"subscriber",
",",
"$",
"contentObject",
",",
"$",
"commentList",
"=",
"null",
",",
"$",
"tpl",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"tpl",
")",
")",
"{",
"$",
"tpl",
"=",
"eZTemplate",
"::",
"factory",
"(",
")",
";",
"}",
"$",
"tpl",
"->",
"setVariable",
"(",
"'subscriber'",
",",
"$",
"subscriber",
")",
";",
"$",
"tpl",
"->",
"setVariable",
"(",
"'contentobject'",
",",
"$",
"contentObject",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"commentList",
")",
")",
"{",
"$",
"tpl",
"->",
"setVariable",
"(",
"'comment_list'",
",",
"$",
"commentList",
")",
";",
"}",
"$",
"subject",
"=",
"$",
"tpl",
"->",
"fetch",
"(",
"$",
"this",
"->",
"multiSubjectTemplatePath",
")",
";",
"$",
"body",
"=",
"$",
"tpl",
"->",
"fetch",
"(",
"$",
"this",
"->",
"multiBodyTemplatePath",
")",
";",
"$",
"this",
"->",
"executeSending",
"(",
"$",
"subject",
",",
"$",
"body",
",",
"$",
"subscriber",
")",
";",
"}"
] |
send notification with all comment in one notification
Exception if error happens
@param $subscriber
@param $contentObject
@param $commentList comment list to the subscriber, which can be null.
@param $tpl
@return void
|
[
"send",
"notification",
"with",
"all",
"comment",
"in",
"one",
"notification",
"Exception",
"if",
"error",
"happens"
] |
2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5
|
https://github.com/ezsystems/ezcomments-ls-extension/blob/2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5/classes/ezcomnotifcationmanager.php#L65-L80
|
20,302 |
ezsystems/ezcomments-ls-extension
|
classes/ezcomnotifcationmanager.php
|
ezcomNotificationManager.instance
|
public static function instance( $className = null )
{
if ( is_null( $className ) )
{
$ini = eZINI::instance( 'ezcomments.ini' );
$className = $ini->variable( 'NotificationSettings', 'NotificationManagerClass' );
}
if ( !isset( self::$instance ) )
{
self::$instance = new $className();
}
return self::$instance;
}
|
php
|
public static function instance( $className = null )
{
if ( is_null( $className ) )
{
$ini = eZINI::instance( 'ezcomments.ini' );
$className = $ini->variable( 'NotificationSettings', 'NotificationManagerClass' );
}
if ( !isset( self::$instance ) )
{
self::$instance = new $className();
}
return self::$instance;
}
|
[
"public",
"static",
"function",
"instance",
"(",
"$",
"className",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"className",
")",
")",
"{",
"$",
"ini",
"=",
"eZINI",
"::",
"instance",
"(",
"'ezcomments.ini'",
")",
";",
"$",
"className",
"=",
"$",
"ini",
"->",
"variable",
"(",
"'NotificationSettings'",
",",
"'NotificationManagerClass'",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"instance",
")",
")",
"{",
"self",
"::",
"$",
"instance",
"=",
"new",
"$",
"className",
"(",
")",
";",
"}",
"return",
"self",
"::",
"$",
"instance",
";",
"}"
] |
create instance of the object
@param string $className
@return ezcomNotificationManager
|
[
"create",
"instance",
"of",
"the",
"object"
] |
2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5
|
https://github.com/ezsystems/ezcomments-ls-extension/blob/2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5/classes/ezcomnotifcationmanager.php#L87-L99
|
20,303 |
ezsystems/ezcomments-ls-extension
|
classes/ezcomnotifcationmanager.php
|
ezcomNotificationManager.create
|
public static function create( $className = null )
{
if ( is_null( $className ) )
{
$ini = eZINI::instance( 'ezcomments.ini' );
$className = $ini->variable( 'NotificationSettings', 'NotificationManagerClass' );
}
return new $className();
}
|
php
|
public static function create( $className = null )
{
if ( is_null( $className ) )
{
$ini = eZINI::instance( 'ezcomments.ini' );
$className = $ini->variable( 'NotificationSettings', 'NotificationManagerClass' );
}
return new $className();
}
|
[
"public",
"static",
"function",
"create",
"(",
"$",
"className",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"className",
")",
")",
"{",
"$",
"ini",
"=",
"eZINI",
"::",
"instance",
"(",
"'ezcomments.ini'",
")",
";",
"$",
"className",
"=",
"$",
"ini",
"->",
"variable",
"(",
"'NotificationSettings'",
",",
"'NotificationManagerClass'",
")",
";",
"}",
"return",
"new",
"$",
"className",
"(",
")",
";",
"}"
] |
create instance of the object without using singleton
@param string $className
@return ezcomNotificationManager
|
[
"create",
"instance",
"of",
"the",
"object",
"without",
"using",
"singleton"
] |
2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5
|
https://github.com/ezsystems/ezcomments-ls-extension/blob/2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5/classes/ezcomnotifcationmanager.php#L106-L114
|
20,304 |
DomAndTom/dnt_laravel-swagger-alpha_framework
|
src/controllers/BaseController.php
|
BaseController.resources
|
public function resources()
{
$options = Config::get('laravel-swagger::getResourceListOptions');
$excludedPath = Config::get('laravel-swagger::excludedPath');
$swagger = new Swagger($this->getPaths(), $excludedPath);
if (Config::get('laravel-swagger::cache')) {
$resourceList = Cache::remember('resourceList', $this->getExpireAt(), function() use ($swagger, $options)
{
return $swagger->getResourceList($options);
});
} else {
$resourceList = $swagger->getResourceList($options);
}
return $resourceList;
}
|
php
|
public function resources()
{
$options = Config::get('laravel-swagger::getResourceListOptions');
$excludedPath = Config::get('laravel-swagger::excludedPath');
$swagger = new Swagger($this->getPaths(), $excludedPath);
if (Config::get('laravel-swagger::cache')) {
$resourceList = Cache::remember('resourceList', $this->getExpireAt(), function() use ($swagger, $options)
{
return $swagger->getResourceList($options);
});
} else {
$resourceList = $swagger->getResourceList($options);
}
return $resourceList;
}
|
[
"public",
"function",
"resources",
"(",
")",
"{",
"$",
"options",
"=",
"Config",
"::",
"get",
"(",
"'laravel-swagger::getResourceListOptions'",
")",
";",
"$",
"excludedPath",
"=",
"Config",
"::",
"get",
"(",
"'laravel-swagger::excludedPath'",
")",
";",
"$",
"swagger",
"=",
"new",
"Swagger",
"(",
"$",
"this",
"->",
"getPaths",
"(",
")",
",",
"$",
"excludedPath",
")",
";",
"if",
"(",
"Config",
"::",
"get",
"(",
"'laravel-swagger::cache'",
")",
")",
"{",
"$",
"resourceList",
"=",
"Cache",
"::",
"remember",
"(",
"'resourceList'",
",",
"$",
"this",
"->",
"getExpireAt",
"(",
")",
",",
"function",
"(",
")",
"use",
"(",
"$",
"swagger",
",",
"$",
"options",
")",
"{",
"return",
"$",
"swagger",
"->",
"getResourceList",
"(",
"$",
"options",
")",
";",
"}",
")",
";",
"}",
"else",
"{",
"$",
"resourceList",
"=",
"$",
"swagger",
"->",
"getResourceList",
"(",
"$",
"options",
")",
";",
"}",
"return",
"$",
"resourceList",
";",
"}"
] |
Show all available Resources
|
[
"Show",
"all",
"available",
"Resources"
] |
489fc5398583682b8372bdadd6631a4cbff6099f
|
https://github.com/DomAndTom/dnt_laravel-swagger-alpha_framework/blob/489fc5398583682b8372bdadd6631a4cbff6099f/src/controllers/BaseController.php#L29-L46
|
20,305 |
DomAndTom/dnt_laravel-swagger-alpha_framework
|
src/controllers/BaseController.php
|
BaseController.showResource
|
public function showResource($name)
{
$options = Config::get('laravel-swagger::getResourceOptions');
$resourceName = "/" . str_replace("-", "/", $name);
$excludedPath = Config::get('laravel-swagger::excludedPath');
$swagger = new Swagger($this->getPaths(), $excludedPath);
if (Config::get('laravel-swagger::cache') && Cache::has('resource_'.$resourceName)) {
$resource = Cache::get('resource_'.$resourceName);
} else {
if (!in_array($resourceName, $swagger->getResourceNames())) {
App::abort(404, 'Resource not found');
}
// Pet demo uses the main laravel-swagger route.
if ($resourceName == '/petdemo') {
$options['defaultBasePath'] = route('swagger-index');
}
$resource = $swagger->getResource($resourceName, $options);
}
if (Config::get('laravel-swagger::cache') && !Cache::has('resource_'.$resourceName)) {
Cache::put('resource_'.$resourceName, $resource, $this->getExpireAt());
}
return $resource;
}
|
php
|
public function showResource($name)
{
$options = Config::get('laravel-swagger::getResourceOptions');
$resourceName = "/" . str_replace("-", "/", $name);
$excludedPath = Config::get('laravel-swagger::excludedPath');
$swagger = new Swagger($this->getPaths(), $excludedPath);
if (Config::get('laravel-swagger::cache') && Cache::has('resource_'.$resourceName)) {
$resource = Cache::get('resource_'.$resourceName);
} else {
if (!in_array($resourceName, $swagger->getResourceNames())) {
App::abort(404, 'Resource not found');
}
// Pet demo uses the main laravel-swagger route.
if ($resourceName == '/petdemo') {
$options['defaultBasePath'] = route('swagger-index');
}
$resource = $swagger->getResource($resourceName, $options);
}
if (Config::get('laravel-swagger::cache') && !Cache::has('resource_'.$resourceName)) {
Cache::put('resource_'.$resourceName, $resource, $this->getExpireAt());
}
return $resource;
}
|
[
"public",
"function",
"showResource",
"(",
"$",
"name",
")",
"{",
"$",
"options",
"=",
"Config",
"::",
"get",
"(",
"'laravel-swagger::getResourceOptions'",
")",
";",
"$",
"resourceName",
"=",
"\"/\"",
".",
"str_replace",
"(",
"\"-\"",
",",
"\"/\"",
",",
"$",
"name",
")",
";",
"$",
"excludedPath",
"=",
"Config",
"::",
"get",
"(",
"'laravel-swagger::excludedPath'",
")",
";",
"$",
"swagger",
"=",
"new",
"Swagger",
"(",
"$",
"this",
"->",
"getPaths",
"(",
")",
",",
"$",
"excludedPath",
")",
";",
"if",
"(",
"Config",
"::",
"get",
"(",
"'laravel-swagger::cache'",
")",
"&&",
"Cache",
"::",
"has",
"(",
"'resource_'",
".",
"$",
"resourceName",
")",
")",
"{",
"$",
"resource",
"=",
"Cache",
"::",
"get",
"(",
"'resource_'",
".",
"$",
"resourceName",
")",
";",
"}",
"else",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"resourceName",
",",
"$",
"swagger",
"->",
"getResourceNames",
"(",
")",
")",
")",
"{",
"App",
"::",
"abort",
"(",
"404",
",",
"'Resource not found'",
")",
";",
"}",
"// Pet demo uses the main laravel-swagger route.",
"if",
"(",
"$",
"resourceName",
"==",
"'/petdemo'",
")",
"{",
"$",
"options",
"[",
"'defaultBasePath'",
"]",
"=",
"route",
"(",
"'swagger-index'",
")",
";",
"}",
"$",
"resource",
"=",
"$",
"swagger",
"->",
"getResource",
"(",
"$",
"resourceName",
",",
"$",
"options",
")",
";",
"}",
"if",
"(",
"Config",
"::",
"get",
"(",
"'laravel-swagger::cache'",
")",
"&&",
"!",
"Cache",
"::",
"has",
"(",
"'resource_'",
".",
"$",
"resourceName",
")",
")",
"{",
"Cache",
"::",
"put",
"(",
"'resource_'",
".",
"$",
"resourceName",
",",
"$",
"resource",
",",
"$",
"this",
"->",
"getExpireAt",
"(",
")",
")",
";",
"}",
"return",
"$",
"resource",
";",
"}"
] |
Show an specific Resource
|
[
"Show",
"an",
"specific",
"Resource"
] |
489fc5398583682b8372bdadd6631a4cbff6099f
|
https://github.com/DomAndTom/dnt_laravel-swagger-alpha_framework/blob/489fc5398583682b8372bdadd6631a4cbff6099f/src/controllers/BaseController.php#L51-L79
|
20,306 |
eghojansu/moe
|
src/tools/Image.php
|
Image.save
|
function save() {
$fw=Base::instance();
if ($this->flag) {
if (!is_dir($dir=$fw->get('TEMP')))
mkdir($dir,Base::MODE,TRUE);
$this->count++;
$fw->write($dir.'/'.
$fw->hash($fw->get('ROOT').$fw->get('BASE')).'.'.
$fw->hash($this->file).'-'.$this->count.'.png',
$this->dump());
}
return $this;
}
|
php
|
function save() {
$fw=Base::instance();
if ($this->flag) {
if (!is_dir($dir=$fw->get('TEMP')))
mkdir($dir,Base::MODE,TRUE);
$this->count++;
$fw->write($dir.'/'.
$fw->hash($fw->get('ROOT').$fw->get('BASE')).'.'.
$fw->hash($this->file).'-'.$this->count.'.png',
$this->dump());
}
return $this;
}
|
[
"function",
"save",
"(",
")",
"{",
"$",
"fw",
"=",
"Base",
"::",
"instance",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"flag",
")",
"{",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"dir",
"=",
"$",
"fw",
"->",
"get",
"(",
"'TEMP'",
")",
")",
")",
"mkdir",
"(",
"$",
"dir",
",",
"Base",
"::",
"MODE",
",",
"TRUE",
")",
";",
"$",
"this",
"->",
"count",
"++",
";",
"$",
"fw",
"->",
"write",
"(",
"$",
"dir",
".",
"'/'",
".",
"$",
"fw",
"->",
"hash",
"(",
"$",
"fw",
"->",
"get",
"(",
"'ROOT'",
")",
".",
"$",
"fw",
"->",
"get",
"(",
"'BASE'",
")",
")",
".",
"'.'",
".",
"$",
"fw",
"->",
"hash",
"(",
"$",
"this",
"->",
"file",
")",
".",
"'-'",
".",
"$",
"this",
"->",
"count",
".",
"'.png'",
",",
"$",
"this",
"->",
"dump",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Save current state
@return object
|
[
"Save",
"current",
"state"
] |
f58ec75a3116d1a572782256e2b38bb9aab95e3c
|
https://github.com/eghojansu/moe/blob/f58ec75a3116d1a572782256e2b38bb9aab95e3c/src/tools/Image.php#L480-L492
|
20,307 |
eghojansu/moe
|
src/tools/Image.php
|
Image.restore
|
function restore($state=1) {
$fw=Base::instance();
if ($this->flag && is_file($file=($path=$fw->get('TEMP').
$fw->hash($fw->get('ROOT').$fw->get('BASE')).'.'.
$fw->hash($this->file).'-').$state.'.png')) {
if (is_resource($this->data))
imagedestroy($this->data);
$this->data=imagecreatefromstring($fw->read($file));
imagesavealpha($this->data,TRUE);
foreach (glob($path.'*.png',GLOB_NOSORT) as $match)
if (preg_match('/-(\d+)\.png/',$match,$parts) &&
$parts[1]>$state)
@unlink($match);
$this->count=$state;
}
return $this;
}
|
php
|
function restore($state=1) {
$fw=Base::instance();
if ($this->flag && is_file($file=($path=$fw->get('TEMP').
$fw->hash($fw->get('ROOT').$fw->get('BASE')).'.'.
$fw->hash($this->file).'-').$state.'.png')) {
if (is_resource($this->data))
imagedestroy($this->data);
$this->data=imagecreatefromstring($fw->read($file));
imagesavealpha($this->data,TRUE);
foreach (glob($path.'*.png',GLOB_NOSORT) as $match)
if (preg_match('/-(\d+)\.png/',$match,$parts) &&
$parts[1]>$state)
@unlink($match);
$this->count=$state;
}
return $this;
}
|
[
"function",
"restore",
"(",
"$",
"state",
"=",
"1",
")",
"{",
"$",
"fw",
"=",
"Base",
"::",
"instance",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"flag",
"&&",
"is_file",
"(",
"$",
"file",
"=",
"(",
"$",
"path",
"=",
"$",
"fw",
"->",
"get",
"(",
"'TEMP'",
")",
".",
"$",
"fw",
"->",
"hash",
"(",
"$",
"fw",
"->",
"get",
"(",
"'ROOT'",
")",
".",
"$",
"fw",
"->",
"get",
"(",
"'BASE'",
")",
")",
".",
"'.'",
".",
"$",
"fw",
"->",
"hash",
"(",
"$",
"this",
"->",
"file",
")",
".",
"'-'",
")",
".",
"$",
"state",
".",
"'.png'",
")",
")",
"{",
"if",
"(",
"is_resource",
"(",
"$",
"this",
"->",
"data",
")",
")",
"imagedestroy",
"(",
"$",
"this",
"->",
"data",
")",
";",
"$",
"this",
"->",
"data",
"=",
"imagecreatefromstring",
"(",
"$",
"fw",
"->",
"read",
"(",
"$",
"file",
")",
")",
";",
"imagesavealpha",
"(",
"$",
"this",
"->",
"data",
",",
"TRUE",
")",
";",
"foreach",
"(",
"glob",
"(",
"$",
"path",
".",
"'*.png'",
",",
"GLOB_NOSORT",
")",
"as",
"$",
"match",
")",
"if",
"(",
"preg_match",
"(",
"'/-(\\d+)\\.png/'",
",",
"$",
"match",
",",
"$",
"parts",
")",
"&&",
"$",
"parts",
"[",
"1",
"]",
">",
"$",
"state",
")",
"@",
"unlink",
"(",
"$",
"match",
")",
";",
"$",
"this",
"->",
"count",
"=",
"$",
"state",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Revert to specified state
@return object
@param $state int
|
[
"Revert",
"to",
"specified",
"state"
] |
f58ec75a3116d1a572782256e2b38bb9aab95e3c
|
https://github.com/eghojansu/moe/blob/f58ec75a3116d1a572782256e2b38bb9aab95e3c/src/tools/Image.php#L499-L515
|
20,308 |
alevilar/ristorantino-vendor
|
Mesa/Model/Mesa.php
|
Mesa.calcular_valor_cubierto
|
function calcular_valor_cubierto ( $mesaId = null ) {
if (!empty($mesaId)) {
$this->id = $mesaId;
}
$cant_comensales = $this->field('cant_comensales');
$precioCubierto = Configure::read('Restaurante.valorCubierto');
$valor_cubierto = 0;
if ($precioCubierto > 0) {
$valor_cubierto = $precioCubierto * $cant_comensales;
}
return $valor_cubierto;
}
|
php
|
function calcular_valor_cubierto ( $mesaId = null ) {
if (!empty($mesaId)) {
$this->id = $mesaId;
}
$cant_comensales = $this->field('cant_comensales');
$precioCubierto = Configure::read('Restaurante.valorCubierto');
$valor_cubierto = 0;
if ($precioCubierto > 0) {
$valor_cubierto = $precioCubierto * $cant_comensales;
}
return $valor_cubierto;
}
|
[
"function",
"calcular_valor_cubierto",
"(",
"$",
"mesaId",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"mesaId",
")",
")",
"{",
"$",
"this",
"->",
"id",
"=",
"$",
"mesaId",
";",
"}",
"$",
"cant_comensales",
"=",
"$",
"this",
"->",
"field",
"(",
"'cant_comensales'",
")",
";",
"$",
"precioCubierto",
"=",
"Configure",
"::",
"read",
"(",
"'Restaurante.valorCubierto'",
")",
";",
"$",
"valor_cubierto",
"=",
"0",
";",
"if",
"(",
"$",
"precioCubierto",
">",
"0",
")",
"{",
"$",
"valor_cubierto",
"=",
"$",
"precioCubierto",
"*",
"$",
"cant_comensales",
";",
"}",
"return",
"$",
"valor_cubierto",
";",
"}"
] |
Funcion que calcula el precio del cubierto
@param Integer $mesaId default NULL
@return Float precio del cubierto
|
[
"Funcion",
"que",
"calcula",
"el",
"precio",
"del",
"cubierto"
] |
6b91a1e20cc0ba09a1968d77e3de6512cfa2d966
|
https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Mesa/Model/Mesa.php#L559-L572
|
20,309 |
alevilar/ristorantino-vendor
|
Mesa/Model/Mesa.php
|
Mesa.estaCobrada
|
function estaCobrada($id = null, $force_db = false){
$ret = false;
if (!empty($id)){
$this->id = $id;
}
if ( !empty($this->data[$this->name]['estado_id']) ){
$ret = $this->data[$this->name]['estado_id'] == MESA_COBRADA;
}
if ( $force_db) {
// lo busco en BBDD
$ret = $this->find('count', array(
'conditions' => array(
'Mesa.estado_id' => MESA_COBRADA,
'Mesa.id' => $this->id,
)
));
}
return $ret;
}
|
php
|
function estaCobrada($id = null, $force_db = false){
$ret = false;
if (!empty($id)){
$this->id = $id;
}
if ( !empty($this->data[$this->name]['estado_id']) ){
$ret = $this->data[$this->name]['estado_id'] == MESA_COBRADA;
}
if ( $force_db) {
// lo busco en BBDD
$ret = $this->find('count', array(
'conditions' => array(
'Mesa.estado_id' => MESA_COBRADA,
'Mesa.id' => $this->id,
)
));
}
return $ret;
}
|
[
"function",
"estaCobrada",
"(",
"$",
"id",
"=",
"null",
",",
"$",
"force_db",
"=",
"false",
")",
"{",
"$",
"ret",
"=",
"false",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"id",
")",
")",
"{",
"$",
"this",
"->",
"id",
"=",
"$",
"id",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"data",
"[",
"$",
"this",
"->",
"name",
"]",
"[",
"'estado_id'",
"]",
")",
")",
"{",
"$",
"ret",
"=",
"$",
"this",
"->",
"data",
"[",
"$",
"this",
"->",
"name",
"]",
"[",
"'estado_id'",
"]",
"==",
"MESA_COBRADA",
";",
"}",
"if",
"(",
"$",
"force_db",
")",
"{",
"// lo busco en BBDD ",
"$",
"ret",
"=",
"$",
"this",
"->",
"find",
"(",
"'count'",
",",
"array",
"(",
"'conditions'",
"=>",
"array",
"(",
"'Mesa.estado_id'",
"=>",
"MESA_COBRADA",
",",
"'Mesa.id'",
"=>",
"$",
"this",
"->",
"id",
",",
")",
")",
")",
";",
"}",
"return",
"$",
"ret",
";",
"}"
] |
Dice si una mesa esta cobrada o no
@param integer $id
@param boolean $force_db indica si quiero forzar para que busque en la BBDD
@return boolean
|
[
"Dice",
"si",
"una",
"mesa",
"esta",
"cobrada",
"o",
"no"
] |
6b91a1e20cc0ba09a1968d77e3de6512cfa2d966
|
https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Mesa/Model/Mesa.php#L746-L768
|
20,310 |
alevilar/ristorantino-vendor
|
Mesa/Model/Mesa.php
|
Mesa.estaAbierta
|
function estaAbierta($id = null){
if (!empty($id)){
$this->id = $id;
}
// lo busco en BBDD
$ret = $this->find('count', array(
'conditions' => array(
'Mesa.estado_id' => MESA_ABIERTA,
'Mesa.id' => $this->id,
)
));
return ($ret > 0);
}
|
php
|
function estaAbierta($id = null){
if (!empty($id)){
$this->id = $id;
}
// lo busco en BBDD
$ret = $this->find('count', array(
'conditions' => array(
'Mesa.estado_id' => MESA_ABIERTA,
'Mesa.id' => $this->id,
)
));
return ($ret > 0);
}
|
[
"function",
"estaAbierta",
"(",
"$",
"id",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"id",
")",
")",
"{",
"$",
"this",
"->",
"id",
"=",
"$",
"id",
";",
"}",
"// lo busco en BBDD ",
"$",
"ret",
"=",
"$",
"this",
"->",
"find",
"(",
"'count'",
",",
"array",
"(",
"'conditions'",
"=>",
"array",
"(",
"'Mesa.estado_id'",
"=>",
"MESA_ABIERTA",
",",
"'Mesa.id'",
"=>",
"$",
"this",
"->",
"id",
",",
")",
")",
")",
";",
"return",
"(",
"$",
"ret",
">",
"0",
")",
";",
"}"
] |
Dice si una mesa esta abierta o no
@param integer $id
@return boolean
|
[
"Dice",
"si",
"una",
"mesa",
"esta",
"abierta",
"o",
"no"
] |
6b91a1e20cc0ba09a1968d77e3de6512cfa2d966
|
https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Mesa/Model/Mesa.php#L780-L793
|
20,311 |
alevilar/ristorantino-vendor
|
Mesa/Model/Mesa.php
|
Mesa.totalesDeMesasEntre
|
function totalesDeMesasEntre($fechaDesde = '', $fechaHasta = '', $conds = array()){
$horarioCorte = Configure::read('Horario.corte_del_dia');
if ( $horarioCorte < 10 ) {
$horarioCorte = "0$horarioCorte";
}
$sqlHorarioDeCorte = "DATE(SUBTIME(Mesa.checkin, '$horarioCorte:00:00'))";
$desde = empty($fechaDesde) ? date('Y-m-d', strtotime('now')) : $fechaDesde;
$hasta = empty($fechaHasta) ? date('Y-m-d', strtotime('now')) : $fechaHasta;
$defaultOrder = array();
$defaultFields = array(
'count(*) as "cant_mesas"',
'sum(Mesa.cant_comensales) as "cant_cubiertos"',
'sum(Mesa.subtotal) as "subtotal"',
'sum(Mesa.total) as "total"',
'sum(Mesa.total)/sum(Mesa.cant_comensales) as "promedio_cubiertos"',
"$sqlHorarioDeCorte as fecha",
);
$defaultGroup = array(
"$sqlHorarioDeCorte" ,
);
if ( empty($conds['order'])) {
$defaultOrder = array(
"Mesa.checkin DESC"
);
}
$defaultConditions = array(
'Mesa.deleted' => '0', // mesas no borradas
"$sqlHorarioDeCorte BETWEEN '$desde' AND '$hasta'"
);
$ops = array(
'fields' => $defaultFields,
'conditions' => $defaultConditions,
'group' => $defaultGroup,
'order' => $defaultOrder,
);
$ops = array_merge_recursive($ops, $conds);
$mesas = $this->find('all', $ops);
return $mesas;
}
|
php
|
function totalesDeMesasEntre($fechaDesde = '', $fechaHasta = '', $conds = array()){
$horarioCorte = Configure::read('Horario.corte_del_dia');
if ( $horarioCorte < 10 ) {
$horarioCorte = "0$horarioCorte";
}
$sqlHorarioDeCorte = "DATE(SUBTIME(Mesa.checkin, '$horarioCorte:00:00'))";
$desde = empty($fechaDesde) ? date('Y-m-d', strtotime('now')) : $fechaDesde;
$hasta = empty($fechaHasta) ? date('Y-m-d', strtotime('now')) : $fechaHasta;
$defaultOrder = array();
$defaultFields = array(
'count(*) as "cant_mesas"',
'sum(Mesa.cant_comensales) as "cant_cubiertos"',
'sum(Mesa.subtotal) as "subtotal"',
'sum(Mesa.total) as "total"',
'sum(Mesa.total)/sum(Mesa.cant_comensales) as "promedio_cubiertos"',
"$sqlHorarioDeCorte as fecha",
);
$defaultGroup = array(
"$sqlHorarioDeCorte" ,
);
if ( empty($conds['order'])) {
$defaultOrder = array(
"Mesa.checkin DESC"
);
}
$defaultConditions = array(
'Mesa.deleted' => '0', // mesas no borradas
"$sqlHorarioDeCorte BETWEEN '$desde' AND '$hasta'"
);
$ops = array(
'fields' => $defaultFields,
'conditions' => $defaultConditions,
'group' => $defaultGroup,
'order' => $defaultOrder,
);
$ops = array_merge_recursive($ops, $conds);
$mesas = $this->find('all', $ops);
return $mesas;
}
|
[
"function",
"totalesDeMesasEntre",
"(",
"$",
"fechaDesde",
"=",
"''",
",",
"$",
"fechaHasta",
"=",
"''",
",",
"$",
"conds",
"=",
"array",
"(",
")",
")",
"{",
"$",
"horarioCorte",
"=",
"Configure",
"::",
"read",
"(",
"'Horario.corte_del_dia'",
")",
";",
"if",
"(",
"$",
"horarioCorte",
"<",
"10",
")",
"{",
"$",
"horarioCorte",
"=",
"\"0$horarioCorte\"",
";",
"}",
"$",
"sqlHorarioDeCorte",
"=",
"\"DATE(SUBTIME(Mesa.checkin, '$horarioCorte:00:00'))\"",
";",
"$",
"desde",
"=",
"empty",
"(",
"$",
"fechaDesde",
")",
"?",
"date",
"(",
"'Y-m-d'",
",",
"strtotime",
"(",
"'now'",
")",
")",
":",
"$",
"fechaDesde",
";",
"$",
"hasta",
"=",
"empty",
"(",
"$",
"fechaHasta",
")",
"?",
"date",
"(",
"'Y-m-d'",
",",
"strtotime",
"(",
"'now'",
")",
")",
":",
"$",
"fechaHasta",
";",
"$",
"defaultOrder",
"=",
"array",
"(",
")",
";",
"$",
"defaultFields",
"=",
"array",
"(",
"'count(*) as \"cant_mesas\"'",
",",
"'sum(Mesa.cant_comensales) as \"cant_cubiertos\"'",
",",
"'sum(Mesa.subtotal) as \"subtotal\"'",
",",
"'sum(Mesa.total) as \"total\"'",
",",
"'sum(Mesa.total)/sum(Mesa.cant_comensales) as \"promedio_cubiertos\"'",
",",
"\"$sqlHorarioDeCorte as fecha\"",
",",
")",
";",
"$",
"defaultGroup",
"=",
"array",
"(",
"\"$sqlHorarioDeCorte\"",
",",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"conds",
"[",
"'order'",
"]",
")",
")",
"{",
"$",
"defaultOrder",
"=",
"array",
"(",
"\"Mesa.checkin DESC\"",
")",
";",
"}",
"$",
"defaultConditions",
"=",
"array",
"(",
"'Mesa.deleted'",
"=>",
"'0'",
",",
"// mesas no borradas",
"\"$sqlHorarioDeCorte BETWEEN '$desde' AND '$hasta'\"",
")",
";",
"$",
"ops",
"=",
"array",
"(",
"'fields'",
"=>",
"$",
"defaultFields",
",",
"'conditions'",
"=>",
"$",
"defaultConditions",
",",
"'group'",
"=>",
"$",
"defaultGroup",
",",
"'order'",
"=>",
"$",
"defaultOrder",
",",
")",
";",
"$",
"ops",
"=",
"array_merge_recursive",
"(",
"$",
"ops",
",",
"$",
"conds",
")",
";",
"$",
"mesas",
"=",
"$",
"this",
"->",
"find",
"(",
"'all'",
",",
"$",
"ops",
")",
";",
"return",
"$",
"mesas",
";",
"}"
] |
Me devuelve un listado agrupado por dia de mesas. Util para estadistica y contabilidad
@param type $fechaDesde string formato de fecha debe ser del tip AÑO-mes-dia Y-m-d
@param type $fechaHasta string formato de fecha debe ser del tip AÑO-mes-dia Y-m-d
@param type $conds array de condiciones extra
|
[
"Me",
"devuelve",
"un",
"listado",
"agrupado",
"por",
"dia",
"de",
"mesas",
".",
"Util",
"para",
"estadistica",
"y",
"contabilidad"
] |
6b91a1e20cc0ba09a1968d77e3de6512cfa2d966
|
https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Mesa/Model/Mesa.php#L826-L868
|
20,312 |
alevilar/ristorantino-vendor
|
Mesa/Model/Mesa.php
|
Mesa.changeRoomStateIfTodayInPeriod
|
public function changeRoomStateIfTodayInPeriod($room, $checkin, $checkout) {
if (!is_array($room) && (is_string($room) || is_int($room))) {
$room = $this->Room->findById($room);
}
$today = date('Y-m-d');
if ($this->hasRoomMesaInDate($room, $today)) {
return $this->Room->changeRoomState($room, 2); // 2 = Ocupada
} else {
if ($room['Room']['room_state_id'] != 4) {
return $this->Room->changeRoomState($room, 1);
}
}
}
|
php
|
public function changeRoomStateIfTodayInPeriod($room, $checkin, $checkout) {
if (!is_array($room) && (is_string($room) || is_int($room))) {
$room = $this->Room->findById($room);
}
$today = date('Y-m-d');
if ($this->hasRoomMesaInDate($room, $today)) {
return $this->Room->changeRoomState($room, 2); // 2 = Ocupada
} else {
if ($room['Room']['room_state_id'] != 4) {
return $this->Room->changeRoomState($room, 1);
}
}
}
|
[
"public",
"function",
"changeRoomStateIfTodayInPeriod",
"(",
"$",
"room",
",",
"$",
"checkin",
",",
"$",
"checkout",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"room",
")",
"&&",
"(",
"is_string",
"(",
"$",
"room",
")",
"||",
"is_int",
"(",
"$",
"room",
")",
")",
")",
"{",
"$",
"room",
"=",
"$",
"this",
"->",
"Room",
"->",
"findById",
"(",
"$",
"room",
")",
";",
"}",
"$",
"today",
"=",
"date",
"(",
"'Y-m-d'",
")",
";",
"if",
"(",
"$",
"this",
"->",
"hasRoomMesaInDate",
"(",
"$",
"room",
",",
"$",
"today",
")",
")",
"{",
"return",
"$",
"this",
"->",
"Room",
"->",
"changeRoomState",
"(",
"$",
"room",
",",
"2",
")",
";",
"// 2 = Ocupada",
"}",
"else",
"{",
"if",
"(",
"$",
"room",
"[",
"'Room'",
"]",
"[",
"'room_state_id'",
"]",
"!=",
"4",
")",
"{",
"return",
"$",
"this",
"->",
"Room",
"->",
"changeRoomState",
"(",
"$",
"room",
",",
"1",
")",
";",
"}",
"}",
"}"
] |
change the room state if today is between period of Mesa for a given nombre_mesa_id or room object
@param int|array $room
@param string $checkin
@param string $checkout
@return void
|
[
"change",
"the",
"room",
"state",
"if",
"today",
"is",
"between",
"period",
"of",
"Mesa",
"for",
"a",
"given",
"nombre_mesa_id",
"or",
"room",
"object"
] |
6b91a1e20cc0ba09a1968d77e3de6512cfa2d966
|
https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Mesa/Model/Mesa.php#L945-L957
|
20,313 |
ouropencode/dachi
|
src/Console/Application.php
|
Application.create
|
public static function create() {
$app = new CLIApplication('Dachi', Kernel::getVersion(true));
$commands = array(
new \Dachi\Core\Console\Command\TestCommand(),
new \Dachi\Core\Console\Command\CreateCommand(),
new \Dachi\Core\Console\Command\DocumentCommand(),
/** run under 'dachi:all' **/
new \Dachi\Core\Console\Command\RouteCommand(),
new \Dachi\Core\Console\Command\ModulesCommand(),
new \Dachi\Core\Console\Command\ConfigCommand(),
new \Dachi\Core\Console\Command\AllCommand()
/** end run under 'dachi:all' **/
);
foreach($commands as $commandClass) {
$app->add($commandClass);
}
$app->run();
}
|
php
|
public static function create() {
$app = new CLIApplication('Dachi', Kernel::getVersion(true));
$commands = array(
new \Dachi\Core\Console\Command\TestCommand(),
new \Dachi\Core\Console\Command\CreateCommand(),
new \Dachi\Core\Console\Command\DocumentCommand(),
/** run under 'dachi:all' **/
new \Dachi\Core\Console\Command\RouteCommand(),
new \Dachi\Core\Console\Command\ModulesCommand(),
new \Dachi\Core\Console\Command\ConfigCommand(),
new \Dachi\Core\Console\Command\AllCommand()
/** end run under 'dachi:all' **/
);
foreach($commands as $commandClass) {
$app->add($commandClass);
}
$app->run();
}
|
[
"public",
"static",
"function",
"create",
"(",
")",
"{",
"$",
"app",
"=",
"new",
"CLIApplication",
"(",
"'Dachi'",
",",
"Kernel",
"::",
"getVersion",
"(",
"true",
")",
")",
";",
"$",
"commands",
"=",
"array",
"(",
"new",
"\\",
"Dachi",
"\\",
"Core",
"\\",
"Console",
"\\",
"Command",
"\\",
"TestCommand",
"(",
")",
",",
"new",
"\\",
"Dachi",
"\\",
"Core",
"\\",
"Console",
"\\",
"Command",
"\\",
"CreateCommand",
"(",
")",
",",
"new",
"\\",
"Dachi",
"\\",
"Core",
"\\",
"Console",
"\\",
"Command",
"\\",
"DocumentCommand",
"(",
")",
",",
"/** run under 'dachi:all' **/",
"new",
"\\",
"Dachi",
"\\",
"Core",
"\\",
"Console",
"\\",
"Command",
"\\",
"RouteCommand",
"(",
")",
",",
"new",
"\\",
"Dachi",
"\\",
"Core",
"\\",
"Console",
"\\",
"Command",
"\\",
"ModulesCommand",
"(",
")",
",",
"new",
"\\",
"Dachi",
"\\",
"Core",
"\\",
"Console",
"\\",
"Command",
"\\",
"ConfigCommand",
"(",
")",
",",
"new",
"\\",
"Dachi",
"\\",
"Core",
"\\",
"Console",
"\\",
"Command",
"\\",
"AllCommand",
"(",
")",
"/** end run under 'dachi:all' **/",
")",
";",
"foreach",
"(",
"$",
"commands",
"as",
"$",
"commandClass",
")",
"{",
"$",
"app",
"->",
"add",
"(",
"$",
"commandClass",
")",
";",
"}",
"$",
"app",
"->",
"run",
"(",
")",
";",
"}"
] |
Create the CLI application
@return null
|
[
"Create",
"the",
"CLI",
"application"
] |
a0e1daf269d0345afbb859ce20ef9da6decd7efe
|
https://github.com/ouropencode/dachi/blob/a0e1daf269d0345afbb859ce20ef9da6decd7efe/src/Console/Application.php#L21-L43
|
20,314 |
heidelpay/PhpDoc
|
src/phpDocumentor/Parser/ServiceProvider.php
|
ServiceProvider.validateDocBlocks
|
public function validateDocBlocks($data)
{
/** @var \phpDocumentor\Reflection\BaseReflector $element */
$element = $data->getSubject();
/** @var \phpDocumentor\Reflection\DocBlock $docblock */
$docblock = $data->getDocblock();
// get the type of element
$type = substr(
get_class($element),
strrpos(get_class($element), '\\') + 1,
-9 // Reflector
);
// no docblock, or docblock should be ignored, so no reason to validate
if ($docblock && $docblock->hasTag('ignore')) {
return;
}
$validatorOptions = $this->loadConfiguration();
foreach (array('Deprecated', 'Required', $type) as $validator) {
// todo: move to a factory or builder class
$class = 'phpDocumentor\Plugin\Core\Parser\DocBlock\Validator\\' . $validator . 'Validator';
if (class_exists($class)) {
/** @var ValidatorAbstract $val */
$val = new $class($element->getName(), $docblock, $element);
$val->setOptions($validatorOptions);
$val->isValid($element);
}
}
}
|
php
|
public function validateDocBlocks($data)
{
/** @var \phpDocumentor\Reflection\BaseReflector $element */
$element = $data->getSubject();
/** @var \phpDocumentor\Reflection\DocBlock $docblock */
$docblock = $data->getDocblock();
// get the type of element
$type = substr(
get_class($element),
strrpos(get_class($element), '\\') + 1,
-9 // Reflector
);
// no docblock, or docblock should be ignored, so no reason to validate
if ($docblock && $docblock->hasTag('ignore')) {
return;
}
$validatorOptions = $this->loadConfiguration();
foreach (array('Deprecated', 'Required', $type) as $validator) {
// todo: move to a factory or builder class
$class = 'phpDocumentor\Plugin\Core\Parser\DocBlock\Validator\\' . $validator . 'Validator';
if (class_exists($class)) {
/** @var ValidatorAbstract $val */
$val = new $class($element->getName(), $docblock, $element);
$val->setOptions($validatorOptions);
$val->isValid($element);
}
}
}
|
[
"public",
"function",
"validateDocBlocks",
"(",
"$",
"data",
")",
"{",
"/** @var \\phpDocumentor\\Reflection\\BaseReflector $element */",
"$",
"element",
"=",
"$",
"data",
"->",
"getSubject",
"(",
")",
";",
"/** @var \\phpDocumentor\\Reflection\\DocBlock $docblock */",
"$",
"docblock",
"=",
"$",
"data",
"->",
"getDocblock",
"(",
")",
";",
"// get the type of element",
"$",
"type",
"=",
"substr",
"(",
"get_class",
"(",
"$",
"element",
")",
",",
"strrpos",
"(",
"get_class",
"(",
"$",
"element",
")",
",",
"'\\\\'",
")",
"+",
"1",
",",
"-",
"9",
"// Reflector",
")",
";",
"// no docblock, or docblock should be ignored, so no reason to validate",
"if",
"(",
"$",
"docblock",
"&&",
"$",
"docblock",
"->",
"hasTag",
"(",
"'ignore'",
")",
")",
"{",
"return",
";",
"}",
"$",
"validatorOptions",
"=",
"$",
"this",
"->",
"loadConfiguration",
"(",
")",
";",
"foreach",
"(",
"array",
"(",
"'Deprecated'",
",",
"'Required'",
",",
"$",
"type",
")",
"as",
"$",
"validator",
")",
"{",
"// todo: move to a factory or builder class",
"$",
"class",
"=",
"'phpDocumentor\\Plugin\\Core\\Parser\\DocBlock\\Validator\\\\'",
".",
"$",
"validator",
".",
"'Validator'",
";",
"if",
"(",
"class_exists",
"(",
"$",
"class",
")",
")",
"{",
"/** @var ValidatorAbstract $val */",
"$",
"val",
"=",
"new",
"$",
"class",
"(",
"$",
"element",
"->",
"getName",
"(",
")",
",",
"$",
"docblock",
",",
"$",
"element",
")",
";",
"$",
"val",
"->",
"setOptions",
"(",
"$",
"validatorOptions",
")",
";",
"$",
"val",
"->",
"isValid",
"(",
"$",
"element",
")",
";",
"}",
"}",
"}"
] |
Checks all phpDocumentor whether they match the given rules.
@param PostDocBlockExtractionEvent $data Event object containing the parameters.
@todo convert this method to the new style validators; this method is not invoked anymore
@return void
|
[
"Checks",
"all",
"phpDocumentor",
"whether",
"they",
"match",
"the",
"given",
"rules",
"."
] |
5ac9e842cbd4cbb70900533b240c131f3515ee02
|
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Parser/ServiceProvider.php#L77-L110
|
20,315 |
neat-php/database
|
classes/Connection.php
|
Connection.pdo
|
public function pdo(PDO $pdo = null)
{
if ($pdo) {
$this->pdo = $pdo;
}
return $this->pdo;
}
|
php
|
public function pdo(PDO $pdo = null)
{
if ($pdo) {
$this->pdo = $pdo;
}
return $this->pdo;
}
|
[
"public",
"function",
"pdo",
"(",
"PDO",
"$",
"pdo",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"pdo",
")",
"{",
"$",
"this",
"->",
"pdo",
"=",
"$",
"pdo",
";",
"}",
"return",
"$",
"this",
"->",
"pdo",
";",
"}"
] |
Get or set PDO instance
@param PDO $pdo (optional)
@return PDO
|
[
"Get",
"or",
"set",
"PDO",
"instance"
] |
7b4b66c8f1bc63e50925f12712b9eedcfb2a98ff
|
https://github.com/neat-php/database/blob/7b4b66c8f1bc63e50925f12712b9eedcfb2a98ff/classes/Connection.php#L64-L71
|
20,316 |
neat-php/database
|
classes/Connection.php
|
Connection.quoteIdentifier
|
public function quoteIdentifier($identifier)
{
$parts = explode(".", $identifier);
if (count($parts) > 1) {
return $this->quoteIdentifier($parts[0]) . '.' . $this->quoteIdentifier($parts[1]);
}
return '`' . str_replace('`', '``', $identifier) . '`';
}
|
php
|
public function quoteIdentifier($identifier)
{
$parts = explode(".", $identifier);
if (count($parts) > 1) {
return $this->quoteIdentifier($parts[0]) . '.' . $this->quoteIdentifier($parts[1]);
}
return '`' . str_replace('`', '``', $identifier) . '`';
}
|
[
"public",
"function",
"quoteIdentifier",
"(",
"$",
"identifier",
")",
"{",
"$",
"parts",
"=",
"explode",
"(",
"\".\"",
",",
"$",
"identifier",
")",
";",
"if",
"(",
"count",
"(",
"$",
"parts",
")",
">",
"1",
")",
"{",
"return",
"$",
"this",
"->",
"quoteIdentifier",
"(",
"$",
"parts",
"[",
"0",
"]",
")",
".",
"'.'",
".",
"$",
"this",
"->",
"quoteIdentifier",
"(",
"$",
"parts",
"[",
"1",
"]",
")",
";",
"}",
"return",
"'`'",
".",
"str_replace",
"(",
"'`'",
",",
"'``'",
",",
"$",
"identifier",
")",
".",
"'`'",
";",
"}"
] |
Quote an identifier for MySQL query usage
@param string $identifier
@return string
|
[
"Quote",
"an",
"identifier",
"for",
"MySQL",
"query",
"usage"
] |
7b4b66c8f1bc63e50925f12712b9eedcfb2a98ff
|
https://github.com/neat-php/database/blob/7b4b66c8f1bc63e50925f12712b9eedcfb2a98ff/classes/Connection.php#L103-L111
|
20,317 |
neat-php/database
|
classes/Connection.php
|
Connection.merge
|
public function merge($query, array $data)
{
$expression = "/(\\?)(?=(?:[^']|'[^']*')*$)/";
$callback = function () use (&$data) {
if (!$data) {
return '?';
}
return $this->quote(array_shift($data));
};
return preg_replace_callback($expression, $callback, $query);
}
|
php
|
public function merge($query, array $data)
{
$expression = "/(\\?)(?=(?:[^']|'[^']*')*$)/";
$callback = function () use (&$data) {
if (!$data) {
return '?';
}
return $this->quote(array_shift($data));
};
return preg_replace_callback($expression, $callback, $query);
}
|
[
"public",
"function",
"merge",
"(",
"$",
"query",
",",
"array",
"$",
"data",
")",
"{",
"$",
"expression",
"=",
"\"/(\\\\?)(?=(?:[^']|'[^']*')*$)/\"",
";",
"$",
"callback",
"=",
"function",
"(",
")",
"use",
"(",
"&",
"$",
"data",
")",
"{",
"if",
"(",
"!",
"$",
"data",
")",
"{",
"return",
"'?'",
";",
"}",
"return",
"$",
"this",
"->",
"quote",
"(",
"array_shift",
"(",
"$",
"data",
")",
")",
";",
"}",
";",
"return",
"preg_replace_callback",
"(",
"$",
"expression",
",",
"$",
"callback",
",",
"$",
"query",
")",
";",
"}"
] |
Merge data into an SQL query with placeholders
@param string $query
@param array $data
@return string
|
[
"Merge",
"data",
"into",
"an",
"SQL",
"query",
"with",
"placeholders"
] |
7b4b66c8f1bc63e50925f12712b9eedcfb2a98ff
|
https://github.com/neat-php/database/blob/7b4b66c8f1bc63e50925f12712b9eedcfb2a98ff/classes/Connection.php#L120-L132
|
20,318 |
neat-php/database
|
classes/Connection.php
|
Connection.query
|
public function query($query, ...$data)
{
if ($data) {
$query = $this->merge($query, $data);
}
try {
$statement = $this->pdo->query($query);
return new Result($statement);
} catch (PDOException $exception) {
throw new QueryException($exception, $query);
}
}
|
php
|
public function query($query, ...$data)
{
if ($data) {
$query = $this->merge($query, $data);
}
try {
$statement = $this->pdo->query($query);
return new Result($statement);
} catch (PDOException $exception) {
throw new QueryException($exception, $query);
}
}
|
[
"public",
"function",
"query",
"(",
"$",
"query",
",",
"...",
"$",
"data",
")",
"{",
"if",
"(",
"$",
"data",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"merge",
"(",
"$",
"query",
",",
"$",
"data",
")",
";",
"}",
"try",
"{",
"$",
"statement",
"=",
"$",
"this",
"->",
"pdo",
"->",
"query",
"(",
"$",
"query",
")",
";",
"return",
"new",
"Result",
"(",
"$",
"statement",
")",
";",
"}",
"catch",
"(",
"PDOException",
"$",
"exception",
")",
"{",
"throw",
"new",
"QueryException",
"(",
"$",
"exception",
",",
"$",
"query",
")",
";",
"}",
"}"
] |
Run a query and return the result
The result can be interactively fetched, but only once due to the
forward-only cursor being used to fetch the results.
@param string $query
@param mixed ...$data
@return Result
@throws QueryException
|
[
"Run",
"a",
"query",
"and",
"return",
"the",
"result"
] |
7b4b66c8f1bc63e50925f12712b9eedcfb2a98ff
|
https://github.com/neat-php/database/blob/7b4b66c8f1bc63e50925f12712b9eedcfb2a98ff/classes/Connection.php#L145-L158
|
20,319 |
neat-php/database
|
classes/Connection.php
|
Connection.fetch
|
public function fetch($query, ...$data)
{
if ($data) {
$query = $this->merge($query, $data);
}
try {
$statement = $this->pdo->query($query);
return new FetchedResult($statement->fetchAll(PDO::FETCH_ASSOC));
} catch (PDOException $exception) {
throw new QueryException($exception, $query);
}
}
|
php
|
public function fetch($query, ...$data)
{
if ($data) {
$query = $this->merge($query, $data);
}
try {
$statement = $this->pdo->query($query);
return new FetchedResult($statement->fetchAll(PDO::FETCH_ASSOC));
} catch (PDOException $exception) {
throw new QueryException($exception, $query);
}
}
|
[
"public",
"function",
"fetch",
"(",
"$",
"query",
",",
"...",
"$",
"data",
")",
"{",
"if",
"(",
"$",
"data",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"merge",
"(",
"$",
"query",
",",
"$",
"data",
")",
";",
"}",
"try",
"{",
"$",
"statement",
"=",
"$",
"this",
"->",
"pdo",
"->",
"query",
"(",
"$",
"query",
")",
";",
"return",
"new",
"FetchedResult",
"(",
"$",
"statement",
"->",
"fetchAll",
"(",
"PDO",
"::",
"FETCH_ASSOC",
")",
")",
";",
"}",
"catch",
"(",
"PDOException",
"$",
"exception",
")",
"{",
"throw",
"new",
"QueryException",
"(",
"$",
"exception",
",",
"$",
"query",
")",
";",
"}",
"}"
] |
Run a query and eagerly fetch the result into memory
Allows the result to be used more than once, for example when you
want to count the result and then iterate over it. Normally the
result would be entirely consumed after counting its rows.
@param string $query
@param mixed ...$data
@return FetchedResult
@throws QueryException
|
[
"Run",
"a",
"query",
"and",
"eagerly",
"fetch",
"the",
"result",
"into",
"memory"
] |
7b4b66c8f1bc63e50925f12712b9eedcfb2a98ff
|
https://github.com/neat-php/database/blob/7b4b66c8f1bc63e50925f12712b9eedcfb2a98ff/classes/Connection.php#L172-L185
|
20,320 |
neat-php/database
|
classes/Connection.php
|
Connection.execute
|
public function execute($query, ...$data)
{
if ($data) {
$query = $this->merge($query, $data);
}
try {
return $this->pdo->exec($query);
} catch (PDOException $exception) {
throw new QueryException($exception, $query);
}
}
|
php
|
public function execute($query, ...$data)
{
if ($data) {
$query = $this->merge($query, $data);
}
try {
return $this->pdo->exec($query);
} catch (PDOException $exception) {
throw new QueryException($exception, $query);
}
}
|
[
"public",
"function",
"execute",
"(",
"$",
"query",
",",
"...",
"$",
"data",
")",
"{",
"if",
"(",
"$",
"data",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"merge",
"(",
"$",
"query",
",",
"$",
"data",
")",
";",
"}",
"try",
"{",
"return",
"$",
"this",
"->",
"pdo",
"->",
"exec",
"(",
"$",
"query",
")",
";",
"}",
"catch",
"(",
"PDOException",
"$",
"exception",
")",
"{",
"throw",
"new",
"QueryException",
"(",
"$",
"exception",
",",
"$",
"query",
")",
";",
"}",
"}"
] |
Execute a query and return the number of rows affected
@param string $query
@param mixed ...$data
@return int
@throws QueryException
|
[
"Execute",
"a",
"query",
"and",
"return",
"the",
"number",
"of",
"rows",
"affected"
] |
7b4b66c8f1bc63e50925f12712b9eedcfb2a98ff
|
https://github.com/neat-php/database/blob/7b4b66c8f1bc63e50925f12712b9eedcfb2a98ff/classes/Connection.php#L195-L206
|
20,321 |
neat-php/database
|
classes/Connection.php
|
Connection.insert
|
public function insert($table, array $data = null)
{
$insert = $this->build()->insert($table);
if ($data) {
return $insert->values($data)->execute();
}
return $insert;
}
|
php
|
public function insert($table, array $data = null)
{
$insert = $this->build()->insert($table);
if ($data) {
return $insert->values($data)->execute();
}
return $insert;
}
|
[
"public",
"function",
"insert",
"(",
"$",
"table",
",",
"array",
"$",
"data",
"=",
"null",
")",
"{",
"$",
"insert",
"=",
"$",
"this",
"->",
"build",
"(",
")",
"->",
"insert",
"(",
"$",
"table",
")",
";",
"if",
"(",
"$",
"data",
")",
"{",
"return",
"$",
"insert",
"->",
"values",
"(",
"$",
"data",
")",
"->",
"execute",
"(",
")",
";",
"}",
"return",
"$",
"insert",
";",
"}"
] |
Insert data into a table
When all parameters are specified, the insert query is immediately
executed and the number of rows affected will be returned. Otherwise
the query builder is returned so you can extend the query further.
@param string $table
@param array $data (optional)
@return Query|int
@throws QueryException
|
[
"Insert",
"data",
"into",
"a",
"table"
] |
7b4b66c8f1bc63e50925f12712b9eedcfb2a98ff
|
https://github.com/neat-php/database/blob/7b4b66c8f1bc63e50925f12712b9eedcfb2a98ff/classes/Connection.php#L251-L259
|
20,322 |
neat-php/database
|
classes/Connection.php
|
Connection.update
|
public function update($table, array $data = null, $where = null)
{
$update = $this->build()->update($table);
if ($data) {
$update->set($data);
}
if ($where) {
$update->where($where);
}
if ($data && $where) {
return $update->execute();
}
return $update;
}
|
php
|
public function update($table, array $data = null, $where = null)
{
$update = $this->build()->update($table);
if ($data) {
$update->set($data);
}
if ($where) {
$update->where($where);
}
if ($data && $where) {
return $update->execute();
}
return $update;
}
|
[
"public",
"function",
"update",
"(",
"$",
"table",
",",
"array",
"$",
"data",
"=",
"null",
",",
"$",
"where",
"=",
"null",
")",
"{",
"$",
"update",
"=",
"$",
"this",
"->",
"build",
"(",
")",
"->",
"update",
"(",
"$",
"table",
")",
";",
"if",
"(",
"$",
"data",
")",
"{",
"$",
"update",
"->",
"set",
"(",
"$",
"data",
")",
";",
"}",
"if",
"(",
"$",
"where",
")",
"{",
"$",
"update",
"->",
"where",
"(",
"$",
"where",
")",
";",
"}",
"if",
"(",
"$",
"data",
"&&",
"$",
"where",
")",
"{",
"return",
"$",
"update",
"->",
"execute",
"(",
")",
";",
"}",
"return",
"$",
"update",
";",
"}"
] |
Update data in a table
When all parameters are specified, the update query is immediately
executed and the number of rows affected will be returned. Otherwise
the query builder is returned so you can extend the query further.
@param string $table
@param array $data (optional)
@param array|string $where (optional)
@return Query|int
@throws QueryException
|
[
"Update",
"data",
"in",
"a",
"table"
] |
7b4b66c8f1bc63e50925f12712b9eedcfb2a98ff
|
https://github.com/neat-php/database/blob/7b4b66c8f1bc63e50925f12712b9eedcfb2a98ff/classes/Connection.php#L274-L288
|
20,323 |
neat-php/database
|
classes/Connection.php
|
Connection.delete
|
public function delete($table, $where = null)
{
$delete = $this->build()->delete($table);
if ($where) {
return $delete->where($where)->execute();
}
return $delete;
}
|
php
|
public function delete($table, $where = null)
{
$delete = $this->build()->delete($table);
if ($where) {
return $delete->where($where)->execute();
}
return $delete;
}
|
[
"public",
"function",
"delete",
"(",
"$",
"table",
",",
"$",
"where",
"=",
"null",
")",
"{",
"$",
"delete",
"=",
"$",
"this",
"->",
"build",
"(",
")",
"->",
"delete",
"(",
"$",
"table",
")",
";",
"if",
"(",
"$",
"where",
")",
"{",
"return",
"$",
"delete",
"->",
"where",
"(",
"$",
"where",
")",
"->",
"execute",
"(",
")",
";",
"}",
"return",
"$",
"delete",
";",
"}"
] |
Delete from a table
When all parameters are specified, the delete query is immediately
executed and the number of rows affected will be returned. Otherwise
the query builder is returned so you can extend the query further.
@param string $table
@param array|string $where (optional)
@return Query|int
@throws QueryException
|
[
"Delete",
"from",
"a",
"table"
] |
7b4b66c8f1bc63e50925f12712b9eedcfb2a98ff
|
https://github.com/neat-php/database/blob/7b4b66c8f1bc63e50925f12712b9eedcfb2a98ff/classes/Connection.php#L302-L310
|
20,324 |
neat-php/database
|
classes/Connection.php
|
Connection.transaction
|
public function transaction(callable $closure)
{
$this->start();
try {
$result = $closure();
} catch (\Throwable $e) {
$this->rollback();
throw $e;
}
$this->commit();
return $result;
}
|
php
|
public function transaction(callable $closure)
{
$this->start();
try {
$result = $closure();
} catch (\Throwable $e) {
$this->rollback();
throw $e;
}
$this->commit();
return $result;
}
|
[
"public",
"function",
"transaction",
"(",
"callable",
"$",
"closure",
")",
"{",
"$",
"this",
"->",
"start",
"(",
")",
";",
"try",
"{",
"$",
"result",
"=",
"$",
"closure",
"(",
")",
";",
"}",
"catch",
"(",
"\\",
"Throwable",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"rollback",
"(",
")",
";",
"throw",
"$",
"e",
";",
"}",
"$",
"this",
"->",
"commit",
"(",
")",
";",
"return",
"$",
"result",
";",
"}"
] |
Run a closure inside a transaction
Begins a transaction before running the closure and commits the
transaction afterwards. When the closure emits an exception or
throwable error, the transaction will be rolled back.
@param callable $closure Closure without required parameters
@return mixed Closure return value
@throws \Throwable Exceptions thrown by the closure
|
[
"Run",
"a",
"closure",
"inside",
"a",
"transaction"
] |
7b4b66c8f1bc63e50925f12712b9eedcfb2a98ff
|
https://github.com/neat-php/database/blob/7b4b66c8f1bc63e50925f12712b9eedcfb2a98ff/classes/Connection.php#L368-L380
|
20,325 |
surebert/surebert-framework
|
src/sb/Encryption/ForTransmission.php
|
ForTransmission.encrypt
|
public function encrypt($string)
{
$td = mcrypt_module_open($this->cypher, '', $this->mode, '');
$iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($td), mcrypt_RAND);
mcrypt_generic_init($td, $this->key, $iv);
$encrypted = mcrypt_generic($td, $string);
mcrypt_generic_deinit($td);
return $iv.$encrypted;
}
|
php
|
public function encrypt($string)
{
$td = mcrypt_module_open($this->cypher, '', $this->mode, '');
$iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($td), mcrypt_RAND);
mcrypt_generic_init($td, $this->key, $iv);
$encrypted = mcrypt_generic($td, $string);
mcrypt_generic_deinit($td);
return $iv.$encrypted;
}
|
[
"public",
"function",
"encrypt",
"(",
"$",
"string",
")",
"{",
"$",
"td",
"=",
"mcrypt_module_open",
"(",
"$",
"this",
"->",
"cypher",
",",
"''",
",",
"$",
"this",
"->",
"mode",
",",
"''",
")",
";",
"$",
"iv",
"=",
"mcrypt_create_iv",
"(",
"mcrypt_enc_get_iv_size",
"(",
"$",
"td",
")",
",",
"mcrypt_RAND",
")",
";",
"mcrypt_generic_init",
"(",
"$",
"td",
",",
"$",
"this",
"->",
"key",
",",
"$",
"iv",
")",
";",
"$",
"encrypted",
"=",
"mcrypt_generic",
"(",
"$",
"td",
",",
"$",
"string",
")",
";",
"mcrypt_generic_deinit",
"(",
"$",
"td",
")",
";",
"return",
"$",
"iv",
".",
"$",
"encrypted",
";",
"}"
] |
Encrypts a string
@param $string The string of data to encrypt
|
[
"Encrypts",
"a",
"string"
] |
f2f32eb693bd39385ceb93355efb5b2a429f27ce
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Encryption/ForTransmission.php#L43-L52
|
20,326 |
surebert/surebert-framework
|
src/sb/Encryption/ForTransmission.php
|
ForTransmission.decrypt
|
public function decrypt($string)
{
$decrypted = "";
$td = mcrypt_module_open($this->cypher, '', $this->mode, '');
$ivsize = mcrypt_enc_get_iv_size($td);
$iv = substr($string, 0, $ivsize);
$string = substr($string, $ivsize);
if ($iv) {
mcrypt_generic_init($td, $this->key, $iv);
$decrypted = mdecrypt_generic($td, $string);
}
return rtrim($decrypted);
}
|
php
|
public function decrypt($string)
{
$decrypted = "";
$td = mcrypt_module_open($this->cypher, '', $this->mode, '');
$ivsize = mcrypt_enc_get_iv_size($td);
$iv = substr($string, 0, $ivsize);
$string = substr($string, $ivsize);
if ($iv) {
mcrypt_generic_init($td, $this->key, $iv);
$decrypted = mdecrypt_generic($td, $string);
}
return rtrim($decrypted);
}
|
[
"public",
"function",
"decrypt",
"(",
"$",
"string",
")",
"{",
"$",
"decrypted",
"=",
"\"\"",
";",
"$",
"td",
"=",
"mcrypt_module_open",
"(",
"$",
"this",
"->",
"cypher",
",",
"''",
",",
"$",
"this",
"->",
"mode",
",",
"''",
")",
";",
"$",
"ivsize",
"=",
"mcrypt_enc_get_iv_size",
"(",
"$",
"td",
")",
";",
"$",
"iv",
"=",
"substr",
"(",
"$",
"string",
",",
"0",
",",
"$",
"ivsize",
")",
";",
"$",
"string",
"=",
"substr",
"(",
"$",
"string",
",",
"$",
"ivsize",
")",
";",
"if",
"(",
"$",
"iv",
")",
"{",
"mcrypt_generic_init",
"(",
"$",
"td",
",",
"$",
"this",
"->",
"key",
",",
"$",
"iv",
")",
";",
"$",
"decrypted",
"=",
"mdecrypt_generic",
"(",
"$",
"td",
",",
"$",
"string",
")",
";",
"}",
"return",
"rtrim",
"(",
"$",
"decrypted",
")",
";",
"}"
] |
Decrypts a string
@param $string The data to decrypt
|
[
"Decrypts",
"a",
"string"
] |
f2f32eb693bd39385ceb93355efb5b2a429f27ce
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Encryption/ForTransmission.php#L58-L72
|
20,327 |
sinri/Ark-Core
|
src/ArkLogger.php
|
ArkLogger.getCurrentLogFilePath
|
public function getCurrentLogFilePath()
{
$rotateTimeMark = "";
if ($this->rotateTimeFormat !== null) {
$rotateTimeMark .= "-" . date($this->rotateTimeFormat);
}
if (is_callable($this->prefix)) {
$prefix = call_user_func_array($this->prefix, []);
// not check prefix here, let user ensure this correctness
} else {
$prefix = $this->prefix;
}
return $this->targetLogDir . '/log' . (empty($this->prefix) ? '' : "-" . $prefix) . $rotateTimeMark . '.log';
}
|
php
|
public function getCurrentLogFilePath()
{
$rotateTimeMark = "";
if ($this->rotateTimeFormat !== null) {
$rotateTimeMark .= "-" . date($this->rotateTimeFormat);
}
if (is_callable($this->prefix)) {
$prefix = call_user_func_array($this->prefix, []);
// not check prefix here, let user ensure this correctness
} else {
$prefix = $this->prefix;
}
return $this->targetLogDir . '/log' . (empty($this->prefix) ? '' : "-" . $prefix) . $rotateTimeMark . '.log';
}
|
[
"public",
"function",
"getCurrentLogFilePath",
"(",
")",
"{",
"$",
"rotateTimeMark",
"=",
"\"\"",
";",
"if",
"(",
"$",
"this",
"->",
"rotateTimeFormat",
"!==",
"null",
")",
"{",
"$",
"rotateTimeMark",
".=",
"\"-\"",
".",
"date",
"(",
"$",
"this",
"->",
"rotateTimeFormat",
")",
";",
"}",
"if",
"(",
"is_callable",
"(",
"$",
"this",
"->",
"prefix",
")",
")",
"{",
"$",
"prefix",
"=",
"call_user_func_array",
"(",
"$",
"this",
"->",
"prefix",
",",
"[",
"]",
")",
";",
"// not check prefix here, let user ensure this correctness",
"}",
"else",
"{",
"$",
"prefix",
"=",
"$",
"this",
"->",
"prefix",
";",
"}",
"return",
"$",
"this",
"->",
"targetLogDir",
".",
"'/log'",
".",
"(",
"empty",
"(",
"$",
"this",
"->",
"prefix",
")",
"?",
"''",
":",
"\"-\"",
".",
"$",
"prefix",
")",
".",
"$",
"rotateTimeMark",
".",
"'.log'",
";",
"}"
] |
Sometime you may need to know where the log file is
@return string
@since 2.2
|
[
"Sometime",
"you",
"may",
"need",
"to",
"know",
"where",
"the",
"log",
"file",
"is"
] |
fb5715e72b500ddc08dd52d9701d713fe49f48c6
|
https://github.com/sinri/Ark-Core/blob/fb5715e72b500ddc08dd52d9701d713fe49f48c6/src/ArkLogger.php#L194-L208
|
20,328 |
sinri/Ark-Core
|
src/ArkLogger.php
|
ArkLogger.print
|
public function print($level, $message, array $context = array(), $enforceEndOfLine = true)
{
if ($this->shouldIgnoreThisLog($level)) {
return;
}
$msg = $this->generateLog($level, $message, $context, $enforceEndOfLine);
echo $msg;
}
|
php
|
public function print($level, $message, array $context = array(), $enforceEndOfLine = true)
{
if ($this->shouldIgnoreThisLog($level)) {
return;
}
$msg = $this->generateLog($level, $message, $context, $enforceEndOfLine);
echo $msg;
}
|
[
"public",
"function",
"print",
"(",
"$",
"level",
",",
"$",
"message",
",",
"array",
"$",
"context",
"=",
"array",
"(",
")",
",",
"$",
"enforceEndOfLine",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"shouldIgnoreThisLog",
"(",
"$",
"level",
")",
")",
"{",
"return",
";",
"}",
"$",
"msg",
"=",
"$",
"this",
"->",
"generateLog",
"(",
"$",
"level",
",",
"$",
"message",
",",
"$",
"context",
",",
"$",
"enforceEndOfLine",
")",
";",
"echo",
"$",
"msg",
";",
"}"
] |
If you want to output log directly to STDOUT, use this.
@since 2.0 renamed from echo to print
@param $level
@param $message
@param array $context
@param bool $enforceEndOfLine @since 2.1
|
[
"If",
"you",
"want",
"to",
"output",
"log",
"directly",
"to",
"STDOUT",
"use",
"this",
"."
] |
fb5715e72b500ddc08dd52d9701d713fe49f48c6
|
https://github.com/sinri/Ark-Core/blob/fb5715e72b500ddc08dd52d9701d713fe49f48c6/src/ArkLogger.php#L234-L241
|
20,329 |
nabab/bbn
|
src/bbn/appui/history.php
|
history._get_db
|
private static function _get_db(): ?bbn\db
{
if ( self::$db && self::$db->check() ){
return self::$db;
}
return null;
}
|
php
|
private static function _get_db(): ?bbn\db
{
if ( self::$db && self::$db->check() ){
return self::$db;
}
return null;
}
|
[
"private",
"static",
"function",
"_get_db",
"(",
")",
":",
"?",
"bbn",
"\\",
"db",
"{",
"if",
"(",
"self",
"::",
"$",
"db",
"&&",
"self",
"::",
"$",
"db",
"->",
"check",
"(",
")",
")",
"{",
"return",
"self",
"::",
"$",
"db",
";",
"}",
"return",
"null",
";",
"}"
] |
Returns the database connection object.
@return bbn\db
|
[
"Returns",
"the",
"database",
"connection",
"object",
"."
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/history.php#L49-L55
|
20,330 |
nabab/bbn
|
src/bbn/appui/history.php
|
history._get_databases
|
private static function _get_databases(): ?databases
{
if ( self::check() ){
if ( !self::$databases_obj && ($db = self::_get_db()) ){
self::$databases_obj = new databases($db);
}
return self::$databases_obj;
}
return null;
}
|
php
|
private static function _get_databases(): ?databases
{
if ( self::check() ){
if ( !self::$databases_obj && ($db = self::_get_db()) ){
self::$databases_obj = new databases($db);
}
return self::$databases_obj;
}
return null;
}
|
[
"private",
"static",
"function",
"_get_databases",
"(",
")",
":",
"?",
"databases",
"{",
"if",
"(",
"self",
"::",
"check",
"(",
")",
")",
"{",
"if",
"(",
"!",
"self",
"::",
"$",
"databases_obj",
"&&",
"(",
"$",
"db",
"=",
"self",
"::",
"_get_db",
"(",
")",
")",
")",
"{",
"self",
"::",
"$",
"databases_obj",
"=",
"new",
"databases",
"(",
"$",
"db",
")",
";",
"}",
"return",
"self",
"::",
"$",
"databases_obj",
";",
"}",
"return",
"null",
";",
"}"
] |
Returns an instance of the appui\database class.
@return databases
|
[
"Returns",
"an",
"instance",
"of",
"the",
"appui",
"\\",
"database",
"class",
"."
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/history.php#L62-L71
|
20,331 |
nabab/bbn
|
src/bbn/appui/history.php
|
history._insert
|
private static function _insert(array $cfg): int
{
if (
isset($cfg['column'], $cfg['line'], $cfg['chrono']) &&
self::check() &&
($db = self::_get_db())
){
// Recording the last ID
$id = $db->last_id();
$last = self::$db->last();
$last_params = self::$db->last_params;
self::disable();
if ( !array_key_exists('old', $cfg) ){
$cfg['ref'] = null;
$cfg['val'] = null;
}
else if (
bbn\str::is_uid($cfg['old']) &&
self::$db->count(self::$table_uids, ['bbn_uid' => $cfg['old']])
){
$cfg['ref'] = $cfg['old'];
$cfg['val'] = null;
}
else{
$cfg['ref'] = null;
$cfg['val'] = $cfg['old'];
}
// New row in the history table
if ( $res = $db->insert(self::$table, [
'opr' => $cfg['operation'],
'uid' => $cfg['line'],
'col' => $cfg['column'],
'val' => $cfg['val'],
'ref' => $cfg['ref'],
'tst' => self::$date ?: $cfg['chrono'],
'usr' => self::$user
]) ){
// Set back the original last ID
$db->set_last_insert_id($id);
}
self::$db->last_query = $last;
self::$db->last_params = $last_params;
self::enable();
return $res;
}
return 0;
}
|
php
|
private static function _insert(array $cfg): int
{
if (
isset($cfg['column'], $cfg['line'], $cfg['chrono']) &&
self::check() &&
($db = self::_get_db())
){
// Recording the last ID
$id = $db->last_id();
$last = self::$db->last();
$last_params = self::$db->last_params;
self::disable();
if ( !array_key_exists('old', $cfg) ){
$cfg['ref'] = null;
$cfg['val'] = null;
}
else if (
bbn\str::is_uid($cfg['old']) &&
self::$db->count(self::$table_uids, ['bbn_uid' => $cfg['old']])
){
$cfg['ref'] = $cfg['old'];
$cfg['val'] = null;
}
else{
$cfg['ref'] = null;
$cfg['val'] = $cfg['old'];
}
// New row in the history table
if ( $res = $db->insert(self::$table, [
'opr' => $cfg['operation'],
'uid' => $cfg['line'],
'col' => $cfg['column'],
'val' => $cfg['val'],
'ref' => $cfg['ref'],
'tst' => self::$date ?: $cfg['chrono'],
'usr' => self::$user
]) ){
// Set back the original last ID
$db->set_last_insert_id($id);
}
self::$db->last_query = $last;
self::$db->last_params = $last_params;
self::enable();
return $res;
}
return 0;
}
|
[
"private",
"static",
"function",
"_insert",
"(",
"array",
"$",
"cfg",
")",
":",
"int",
"{",
"if",
"(",
"isset",
"(",
"$",
"cfg",
"[",
"'column'",
"]",
",",
"$",
"cfg",
"[",
"'line'",
"]",
",",
"$",
"cfg",
"[",
"'chrono'",
"]",
")",
"&&",
"self",
"::",
"check",
"(",
")",
"&&",
"(",
"$",
"db",
"=",
"self",
"::",
"_get_db",
"(",
")",
")",
")",
"{",
"// Recording the last ID",
"$",
"id",
"=",
"$",
"db",
"->",
"last_id",
"(",
")",
";",
"$",
"last",
"=",
"self",
"::",
"$",
"db",
"->",
"last",
"(",
")",
";",
"$",
"last_params",
"=",
"self",
"::",
"$",
"db",
"->",
"last_params",
";",
"self",
"::",
"disable",
"(",
")",
";",
"if",
"(",
"!",
"array_key_exists",
"(",
"'old'",
",",
"$",
"cfg",
")",
")",
"{",
"$",
"cfg",
"[",
"'ref'",
"]",
"=",
"null",
";",
"$",
"cfg",
"[",
"'val'",
"]",
"=",
"null",
";",
"}",
"else",
"if",
"(",
"bbn",
"\\",
"str",
"::",
"is_uid",
"(",
"$",
"cfg",
"[",
"'old'",
"]",
")",
"&&",
"self",
"::",
"$",
"db",
"->",
"count",
"(",
"self",
"::",
"$",
"table_uids",
",",
"[",
"'bbn_uid'",
"=>",
"$",
"cfg",
"[",
"'old'",
"]",
"]",
")",
")",
"{",
"$",
"cfg",
"[",
"'ref'",
"]",
"=",
"$",
"cfg",
"[",
"'old'",
"]",
";",
"$",
"cfg",
"[",
"'val'",
"]",
"=",
"null",
";",
"}",
"else",
"{",
"$",
"cfg",
"[",
"'ref'",
"]",
"=",
"null",
";",
"$",
"cfg",
"[",
"'val'",
"]",
"=",
"$",
"cfg",
"[",
"'old'",
"]",
";",
"}",
"// New row in the history table",
"if",
"(",
"$",
"res",
"=",
"$",
"db",
"->",
"insert",
"(",
"self",
"::",
"$",
"table",
",",
"[",
"'opr'",
"=>",
"$",
"cfg",
"[",
"'operation'",
"]",
",",
"'uid'",
"=>",
"$",
"cfg",
"[",
"'line'",
"]",
",",
"'col'",
"=>",
"$",
"cfg",
"[",
"'column'",
"]",
",",
"'val'",
"=>",
"$",
"cfg",
"[",
"'val'",
"]",
",",
"'ref'",
"=>",
"$",
"cfg",
"[",
"'ref'",
"]",
",",
"'tst'",
"=>",
"self",
"::",
"$",
"date",
"?",
":",
"$",
"cfg",
"[",
"'chrono'",
"]",
",",
"'usr'",
"=>",
"self",
"::",
"$",
"user",
"]",
")",
")",
"{",
"// Set back the original last ID",
"$",
"db",
"->",
"set_last_insert_id",
"(",
"$",
"id",
")",
";",
"}",
"self",
"::",
"$",
"db",
"->",
"last_query",
"=",
"$",
"last",
";",
"self",
"::",
"$",
"db",
"->",
"last_params",
"=",
"$",
"last_params",
";",
"self",
"::",
"enable",
"(",
")",
";",
"return",
"$",
"res",
";",
"}",
"return",
"0",
";",
"}"
] |
Adds a row in the history table
@param array $cfg
@return int
|
[
"Adds",
"a",
"row",
"in",
"the",
"history",
"table"
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/history.php#L79-L125
|
20,332 |
nabab/bbn
|
src/bbn/appui/history.php
|
history._get_table_where
|
private static function _get_table_where(string $table): ?string
{
if (
bbn\str::check_name($table) &&
($db = self::_get_db()) &&
($databases_obj = self::_get_databases()) &&
($model = $databases_obj->modelize($table))
){
$col = $db->escape('col');
$where_ar = [];
foreach ( $model['fields'] as $k => $f ){
if ( !empty($f['id_option']) ){
$where_ar[] = $col.' = UNHEX("'.$db->escape_value($f['id_option']).'")';
}
}
if ( \count($where_ar) ){
return implode(' OR ', $where_ar);
}
}
return null;
}
|
php
|
private static function _get_table_where(string $table): ?string
{
if (
bbn\str::check_name($table) &&
($db = self::_get_db()) &&
($databases_obj = self::_get_databases()) &&
($model = $databases_obj->modelize($table))
){
$col = $db->escape('col');
$where_ar = [];
foreach ( $model['fields'] as $k => $f ){
if ( !empty($f['id_option']) ){
$where_ar[] = $col.' = UNHEX("'.$db->escape_value($f['id_option']).'")';
}
}
if ( \count($where_ar) ){
return implode(' OR ', $where_ar);
}
}
return null;
}
|
[
"private",
"static",
"function",
"_get_table_where",
"(",
"string",
"$",
"table",
")",
":",
"?",
"string",
"{",
"if",
"(",
"bbn",
"\\",
"str",
"::",
"check_name",
"(",
"$",
"table",
")",
"&&",
"(",
"$",
"db",
"=",
"self",
"::",
"_get_db",
"(",
")",
")",
"&&",
"(",
"$",
"databases_obj",
"=",
"self",
"::",
"_get_databases",
"(",
")",
")",
"&&",
"(",
"$",
"model",
"=",
"$",
"databases_obj",
"->",
"modelize",
"(",
"$",
"table",
")",
")",
")",
"{",
"$",
"col",
"=",
"$",
"db",
"->",
"escape",
"(",
"'col'",
")",
";",
"$",
"where_ar",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"model",
"[",
"'fields'",
"]",
"as",
"$",
"k",
"=>",
"$",
"f",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"f",
"[",
"'id_option'",
"]",
")",
")",
"{",
"$",
"where_ar",
"[",
"]",
"=",
"$",
"col",
".",
"' = UNHEX(\"'",
".",
"$",
"db",
"->",
"escape_value",
"(",
"$",
"f",
"[",
"'id_option'",
"]",
")",
".",
"'\")'",
";",
"}",
"}",
"if",
"(",
"\\",
"count",
"(",
"$",
"where_ar",
")",
")",
"{",
"return",
"implode",
"(",
"' OR '",
",",
"$",
"where_ar",
")",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
Get a string for the WHERE in the query with all the columns selection
@param string $table
@return string|null
|
[
"Get",
"a",
"string",
"for",
"the",
"WHERE",
"in",
"the",
"query",
"with",
"all",
"the",
"columns",
"selection"
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/history.php#L132-L152
|
20,333 |
nabab/bbn
|
src/bbn/appui/history.php
|
history.get_id_column
|
public static function get_id_column(string $column, string $table): ?string
{
if (
($db = self::_get_db()) &&
($full_table = $db->tfn($table)) &&
($databases_obj = self::_get_databases())
){
[$database, $table] = explode('.', $full_table);
return $databases_obj->column_id($column, $table, $database, self::$db->host);
}
return false;
}
|
php
|
public static function get_id_column(string $column, string $table): ?string
{
if (
($db = self::_get_db()) &&
($full_table = $db->tfn($table)) &&
($databases_obj = self::_get_databases())
){
[$database, $table] = explode('.', $full_table);
return $databases_obj->column_id($column, $table, $database, self::$db->host);
}
return false;
}
|
[
"public",
"static",
"function",
"get_id_column",
"(",
"string",
"$",
"column",
",",
"string",
"$",
"table",
")",
":",
"?",
"string",
"{",
"if",
"(",
"(",
"$",
"db",
"=",
"self",
"::",
"_get_db",
"(",
")",
")",
"&&",
"(",
"$",
"full_table",
"=",
"$",
"db",
"->",
"tfn",
"(",
"$",
"table",
")",
")",
"&&",
"(",
"$",
"databases_obj",
"=",
"self",
"::",
"_get_databases",
"(",
")",
")",
")",
"{",
"[",
"$",
"database",
",",
"$",
"table",
"]",
"=",
"explode",
"(",
"'.'",
",",
"$",
"full_table",
")",
";",
"return",
"$",
"databases_obj",
"->",
"column_id",
"(",
"$",
"column",
",",
"$",
"table",
",",
"$",
"database",
",",
"self",
"::",
"$",
"db",
"->",
"host",
")",
";",
"}",
"return",
"false",
";",
"}"
] |
Returns the column's corresponding option's ID
@param $column string
@param $table string
@return null|string
|
[
"Returns",
"the",
"column",
"s",
"corresponding",
"option",
"s",
"ID"
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/history.php#L160-L171
|
20,334 |
nabab/bbn
|
src/bbn/appui/history.php
|
history.check
|
public static function check(): bool
{
return
isset(self::$user, self::$table, self::$db) &&
self::is_init() &&
self::_get_db();
}
|
php
|
public static function check(): bool
{
return
isset(self::$user, self::$table, self::$db) &&
self::is_init() &&
self::_get_db();
}
|
[
"public",
"static",
"function",
"check",
"(",
")",
":",
"bool",
"{",
"return",
"isset",
"(",
"self",
"::",
"$",
"user",
",",
"self",
"::",
"$",
"table",
",",
"self",
"::",
"$",
"db",
")",
"&&",
"self",
"::",
"is_init",
"(",
")",
"&&",
"self",
"::",
"_get_db",
"(",
")",
";",
"}"
] |
Checks if all history parameters are set in order to read and write into history
@return bool
|
[
"Checks",
"if",
"all",
"history",
"parameters",
"are",
"set",
"in",
"order",
"to",
"read",
"and",
"write",
"into",
"history"
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/history.php#L257-L263
|
20,335 |
nabab/bbn
|
src/bbn/appui/history.php
|
history.has_history
|
public static function has_history(bbn\db $db): bool
{
$hash = $db->get_hash();
return \in_array($hash, self::$dbs, true);
}
|
php
|
public static function has_history(bbn\db $db): bool
{
$hash = $db->get_hash();
return \in_array($hash, self::$dbs, true);
}
|
[
"public",
"static",
"function",
"has_history",
"(",
"bbn",
"\\",
"db",
"$",
"db",
")",
":",
"bool",
"{",
"$",
"hash",
"=",
"$",
"db",
"->",
"get_hash",
"(",
")",
";",
"return",
"\\",
"in_array",
"(",
"$",
"hash",
",",
"self",
"::",
"$",
"dbs",
",",
"true",
")",
";",
"}"
] |
Returns true if the given DB connection is configured for history
@param bbn\db $db
@return bool
|
[
"Returns",
"true",
"if",
"the",
"given",
"DB",
"connection",
"is",
"configured",
"for",
"history"
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/history.php#L271-L275
|
20,336 |
nabab/bbn
|
src/bbn/appui/history.php
|
history.set_column
|
public static function set_column(string $column): void
{
if ( bbn\str::check_name($column) ){
self::$column = $column;
}
}
|
php
|
public static function set_column(string $column): void
{
if ( bbn\str::check_name($column) ){
self::$column = $column;
}
}
|
[
"public",
"static",
"function",
"set_column",
"(",
"string",
"$",
"column",
")",
":",
"void",
"{",
"if",
"(",
"bbn",
"\\",
"str",
"::",
"check_name",
"(",
"$",
"column",
")",
")",
"{",
"self",
"::",
"$",
"column",
"=",
"$",
"column",
";",
"}",
"}"
] |
Sets the "active" column name
@param string $column
@return void
|
[
"Sets",
"the",
"active",
"column",
"name"
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/history.php#L297-L302
|
20,337 |
nabab/bbn
|
src/bbn/appui/history.php
|
history.set_admin_db
|
public static function set_admin_db(string $db_name): void
{
// Sets the history table name
if ( bbn\str::check_name($db_name) ){
self::$admin_db = $db_name;
self::$table = self::$admin_db.'.'.self::$prefix.'history';
}
}
|
php
|
public static function set_admin_db(string $db_name): void
{
// Sets the history table name
if ( bbn\str::check_name($db_name) ){
self::$admin_db = $db_name;
self::$table = self::$admin_db.'.'.self::$prefix.'history';
}
}
|
[
"public",
"static",
"function",
"set_admin_db",
"(",
"string",
"$",
"db_name",
")",
":",
"void",
"{",
"// Sets the history table name",
"if",
"(",
"bbn",
"\\",
"str",
"::",
"check_name",
"(",
"$",
"db_name",
")",
")",
"{",
"self",
"::",
"$",
"admin_db",
"=",
"$",
"db_name",
";",
"self",
"::",
"$",
"table",
"=",
"self",
"::",
"$",
"admin_db",
".",
"'.'",
".",
"self",
"::",
"$",
"prefix",
".",
"'history'",
";",
"}",
"}"
] |
Sets the history table name
@param string $db_name
@return void
|
[
"Sets",
"the",
"history",
"table",
"name"
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/history.php#L353-L360
|
20,338 |
nabab/bbn
|
src/bbn/appui/history.php
|
history.set_user
|
public static function set_user($user): void
{
// Sets the history table name
if ( bbn\str::is_uid($user) ){
self::$user = $user;
}
}
|
php
|
public static function set_user($user): void
{
// Sets the history table name
if ( bbn\str::is_uid($user) ){
self::$user = $user;
}
}
|
[
"public",
"static",
"function",
"set_user",
"(",
"$",
"user",
")",
":",
"void",
"{",
"// Sets the history table name",
"if",
"(",
"bbn",
"\\",
"str",
"::",
"is_uid",
"(",
"$",
"user",
")",
")",
"{",
"self",
"::",
"$",
"user",
"=",
"$",
"user",
";",
"}",
"}"
] |
Sets the user ID that will be used to fill the user_id field
@param $user
@return void
|
[
"Sets",
"the",
"user",
"ID",
"that",
"will",
"be",
"used",
"to",
"fill",
"the",
"user_id",
"field"
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/history.php#L367-L373
|
20,339 |
hametuha/wpametu
|
src/WPametu/File/Mime.php
|
Mime.is_image
|
public function is_image($path){
if( !file_exists($path) || !($info = getimagesize($path)) ){
return false;
}
return (bool) preg_match("/^image\/(jpeg|png|gif)$/", $info['mime']);
}
|
php
|
public function is_image($path){
if( !file_exists($path) || !($info = getimagesize($path)) ){
return false;
}
return (bool) preg_match("/^image\/(jpeg|png|gif)$/", $info['mime']);
}
|
[
"public",
"function",
"is_image",
"(",
"$",
"path",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"path",
")",
"||",
"!",
"(",
"$",
"info",
"=",
"getimagesize",
"(",
"$",
"path",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"(",
"bool",
")",
"preg_match",
"(",
"\"/^image\\/(jpeg|png|gif)$/\"",
",",
"$",
"info",
"[",
"'mime'",
"]",
")",
";",
"}"
] |
Detect if specified file is image
@param string $path
@return bool
|
[
"Detect",
"if",
"specified",
"file",
"is",
"image"
] |
0939373800815a8396291143d2a57967340da5aa
|
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/File/Mime.php#L22-L27
|
20,340 |
hametuha/wpametu
|
src/WPametu/File/Mime.php
|
Mime.get_mime
|
public function get_mime($file){
$type = $this->get_content_type($file);
if( $type ){
$type = array_map('trim', explode(';', $type));
return $type[0];
}else{
return '';
}
}
|
php
|
public function get_mime($file){
$type = $this->get_content_type($file);
if( $type ){
$type = array_map('trim', explode(';', $type));
return $type[0];
}else{
return '';
}
}
|
[
"public",
"function",
"get_mime",
"(",
"$",
"file",
")",
"{",
"$",
"type",
"=",
"$",
"this",
"->",
"get_content_type",
"(",
"$",
"file",
")",
";",
"if",
"(",
"$",
"type",
")",
"{",
"$",
"type",
"=",
"array_map",
"(",
"'trim'",
",",
"explode",
"(",
"';'",
",",
"$",
"type",
")",
")",
";",
"return",
"$",
"type",
"[",
"0",
"]",
";",
"}",
"else",
"{",
"return",
"''",
";",
"}",
"}"
] |
Return mime type
@param string $file
@return string
|
[
"Return",
"mime",
"type"
] |
0939373800815a8396291143d2a57967340da5aa
|
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/File/Mime.php#L35-L43
|
20,341 |
hametuha/wpametu
|
src/WPametu/File/Mime.php
|
Mime.get_content_type
|
public function get_content_type($path){
if( file_exists($path) ){
$info = finfo_open(FILEINFO_MIME);
$type = finfo_file($info, $path) ;
finfo_close($info);
return $type ?: '' ;
}else{
return '';
}
}
|
php
|
public function get_content_type($path){
if( file_exists($path) ){
$info = finfo_open(FILEINFO_MIME);
$type = finfo_file($info, $path) ;
finfo_close($info);
return $type ?: '' ;
}else{
return '';
}
}
|
[
"public",
"function",
"get_content_type",
"(",
"$",
"path",
")",
"{",
"if",
"(",
"file_exists",
"(",
"$",
"path",
")",
")",
"{",
"$",
"info",
"=",
"finfo_open",
"(",
"FILEINFO_MIME",
")",
";",
"$",
"type",
"=",
"finfo_file",
"(",
"$",
"info",
",",
"$",
"path",
")",
";",
"finfo_close",
"(",
"$",
"info",
")",
";",
"return",
"$",
"type",
"?",
":",
"''",
";",
"}",
"else",
"{",
"return",
"''",
";",
"}",
"}"
] |
Get content type
@param string $path
@return string
|
[
"Get",
"content",
"type"
] |
0939373800815a8396291143d2a57967340da5aa
|
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/File/Mime.php#L51-L60
|
20,342 |
andromeda-framework/doctrine
|
src/Doctrine/Console/Commands/MetadataMerger.php
|
MetadataMerger.merge
|
public function merge(array $metadata): array
{
$tables = [];
foreach ($metadata as $entity) {
$tables[$entity->getTableName()][] = $entity;
}
$merged = [];
foreach ($tables as $table => $metadata) {
if (count($metadata) === 1) {
$merged[] = array_shift($metadata);
continue;
}
$primary = $this->resolvePrimaryMetadata($metadata);
foreach ($metadata as $secondary) {
$primary = $this->mergeMetadata($primary, $secondary);
}
$primary->fieldMappings = $this->mappingCleanup($primary->fieldMappings);
$primary->associationMappings = $this->mappingCleanup($primary->associationMappings);
$merged[] = $primary;
}
return $merged;
}
|
php
|
public function merge(array $metadata): array
{
$tables = [];
foreach ($metadata as $entity) {
$tables[$entity->getTableName()][] = $entity;
}
$merged = [];
foreach ($tables as $table => $metadata) {
if (count($metadata) === 1) {
$merged[] = array_shift($metadata);
continue;
}
$primary = $this->resolvePrimaryMetadata($metadata);
foreach ($metadata as $secondary) {
$primary = $this->mergeMetadata($primary, $secondary);
}
$primary->fieldMappings = $this->mappingCleanup($primary->fieldMappings);
$primary->associationMappings = $this->mappingCleanup($primary->associationMappings);
$merged[] = $primary;
}
return $merged;
}
|
[
"public",
"function",
"merge",
"(",
"array",
"$",
"metadata",
")",
":",
"array",
"{",
"$",
"tables",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"metadata",
"as",
"$",
"entity",
")",
"{",
"$",
"tables",
"[",
"$",
"entity",
"->",
"getTableName",
"(",
")",
"]",
"[",
"]",
"=",
"$",
"entity",
";",
"}",
"$",
"merged",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"tables",
"as",
"$",
"table",
"=>",
"$",
"metadata",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"metadata",
")",
"===",
"1",
")",
"{",
"$",
"merged",
"[",
"]",
"=",
"array_shift",
"(",
"$",
"metadata",
")",
";",
"continue",
";",
"}",
"$",
"primary",
"=",
"$",
"this",
"->",
"resolvePrimaryMetadata",
"(",
"$",
"metadata",
")",
";",
"foreach",
"(",
"$",
"metadata",
"as",
"$",
"secondary",
")",
"{",
"$",
"primary",
"=",
"$",
"this",
"->",
"mergeMetadata",
"(",
"$",
"primary",
",",
"$",
"secondary",
")",
";",
"}",
"$",
"primary",
"->",
"fieldMappings",
"=",
"$",
"this",
"->",
"mappingCleanup",
"(",
"$",
"primary",
"->",
"fieldMappings",
")",
";",
"$",
"primary",
"->",
"associationMappings",
"=",
"$",
"this",
"->",
"mappingCleanup",
"(",
"$",
"primary",
"->",
"associationMappings",
")",
";",
"$",
"merged",
"[",
"]",
"=",
"$",
"primary",
";",
"}",
"return",
"$",
"merged",
";",
"}"
] |
Merges metadata of multiple doctrine entities.
Input metadata can contain duplicit tables. If so, metadata for
the same table will be merged into one.
@param ClassMetadata[] $metadata
@return ClassMetadata[]
|
[
"Merges",
"metadata",
"of",
"multiple",
"doctrine",
"entities",
"."
] |
46924d91c09e0b9fbe5764518cbad70e467ffad4
|
https://github.com/andromeda-framework/doctrine/blob/46924d91c09e0b9fbe5764518cbad70e467ffad4/src/Doctrine/Console/Commands/MetadataMerger.php#L40-L66
|
20,343 |
comodojo/daemon
|
src/Comodojo/Daemon/Daemon.php
|
Daemon.init
|
public function init() {
$args = $this->console->arguments;
$args->parse();
if ( $args->defined('hardstart') ) {
$this->hardstart();
}
if ( $args->defined('daemon') ) {
$this->daemonize();
} else if ( $args->defined('foreground') ) {
if ( $args->defined('verbose') ) {
$this->logger->pushHandler(new LogHandler());
}
$this->start();
} else {
$this->console->pad()->green()->usage();
$this->end(0);
}
}
|
php
|
public function init() {
$args = $this->console->arguments;
$args->parse();
if ( $args->defined('hardstart') ) {
$this->hardstart();
}
if ( $args->defined('daemon') ) {
$this->daemonize();
} else if ( $args->defined('foreground') ) {
if ( $args->defined('verbose') ) {
$this->logger->pushHandler(new LogHandler());
}
$this->start();
} else {
$this->console->pad()->green()->usage();
$this->end(0);
}
}
|
[
"public",
"function",
"init",
"(",
")",
"{",
"$",
"args",
"=",
"$",
"this",
"->",
"console",
"->",
"arguments",
";",
"$",
"args",
"->",
"parse",
"(",
")",
";",
"if",
"(",
"$",
"args",
"->",
"defined",
"(",
"'hardstart'",
")",
")",
"{",
"$",
"this",
"->",
"hardstart",
"(",
")",
";",
"}",
"if",
"(",
"$",
"args",
"->",
"defined",
"(",
"'daemon'",
")",
")",
"{",
"$",
"this",
"->",
"daemonize",
"(",
")",
";",
"}",
"else",
"if",
"(",
"$",
"args",
"->",
"defined",
"(",
"'foreground'",
")",
")",
"{",
"if",
"(",
"$",
"args",
"->",
"defined",
"(",
"'verbose'",
")",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"pushHandler",
"(",
"new",
"LogHandler",
"(",
")",
")",
";",
"}",
"$",
"this",
"->",
"start",
"(",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"console",
"->",
"pad",
"(",
")",
"->",
"green",
"(",
")",
"->",
"usage",
"(",
")",
";",
"$",
"this",
"->",
"end",
"(",
"0",
")",
";",
"}",
"}"
] |
Parse console arguments and init the daemon
|
[
"Parse",
"console",
"arguments",
"and",
"init",
"the",
"daemon"
] |
361b0a3a91dc7720dd3bec448bb4ca47d0ef0292
|
https://github.com/comodojo/daemon/blob/361b0a3a91dc7720dd3bec448bb4ca47d0ef0292/src/Comodojo/Daemon/Daemon.php#L133-L164
|
20,344 |
comodojo/daemon
|
src/Comodojo/Daemon/Daemon.php
|
Daemon.daemonize
|
public function daemonize() {
// fork script
$pid = $this->fork();
// detach from current terminal (if any)
$this->detach();
// update pid reference (we have a new daemon)
$this->pid = $pid;
// start process daemon
$this->start();
}
|
php
|
public function daemonize() {
// fork script
$pid = $this->fork();
// detach from current terminal (if any)
$this->detach();
// update pid reference (we have a new daemon)
$this->pid = $pid;
// start process daemon
$this->start();
}
|
[
"public",
"function",
"daemonize",
"(",
")",
"{",
"// fork script",
"$",
"pid",
"=",
"$",
"this",
"->",
"fork",
"(",
")",
";",
"// detach from current terminal (if any)",
"$",
"this",
"->",
"detach",
"(",
")",
";",
"// update pid reference (we have a new daemon)",
"$",
"this",
"->",
"pid",
"=",
"$",
"pid",
";",
"// start process daemon",
"$",
"this",
"->",
"start",
"(",
")",
";",
"}"
] |
Start as a daemon, forking main process and detaching it from terminal
|
[
"Start",
"as",
"a",
"daemon",
"forking",
"main",
"process",
"and",
"detaching",
"it",
"from",
"terminal"
] |
361b0a3a91dc7720dd3bec448bb4ca47d0ef0292
|
https://github.com/comodojo/daemon/blob/361b0a3a91dc7720dd3bec448bb4ca47d0ef0292/src/Comodojo/Daemon/Daemon.php#L170-L184
|
20,345 |
zhouyl/mellivora
|
Mellivora/Pagination/AbstractPaginator.php
|
AbstractPaginator.url
|
public function url($page)
{
if ($page <= 0) {
$page = 1;
}
// If we have any extra query string key / value pairs that need to be added
// onto the URL, we will put them in query string form and then attach it
// to the URL. This allows for extra information like sortings storage.
$parameters = [$this->pageName => $page];
if (count($this->query) > 0) {
$parameters = array_merge($this->query, $parameters);
}
$uri = Uri::createFromString($this->path);
parse_str($uri->getQuery(), $queryParts);
return $uri->withQuery(http_build_query($parameters + $queryParts))
->withFragment($this->buildFragment())
->__toString();
}
|
php
|
public function url($page)
{
if ($page <= 0) {
$page = 1;
}
// If we have any extra query string key / value pairs that need to be added
// onto the URL, we will put them in query string form and then attach it
// to the URL. This allows for extra information like sortings storage.
$parameters = [$this->pageName => $page];
if (count($this->query) > 0) {
$parameters = array_merge($this->query, $parameters);
}
$uri = Uri::createFromString($this->path);
parse_str($uri->getQuery(), $queryParts);
return $uri->withQuery(http_build_query($parameters + $queryParts))
->withFragment($this->buildFragment())
->__toString();
}
|
[
"public",
"function",
"url",
"(",
"$",
"page",
")",
"{",
"if",
"(",
"$",
"page",
"<=",
"0",
")",
"{",
"$",
"page",
"=",
"1",
";",
"}",
"// If we have any extra query string key / value pairs that need to be added",
"// onto the URL, we will put them in query string form and then attach it",
"// to the URL. This allows for extra information like sortings storage.",
"$",
"parameters",
"=",
"[",
"$",
"this",
"->",
"pageName",
"=>",
"$",
"page",
"]",
";",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"query",
")",
">",
"0",
")",
"{",
"$",
"parameters",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"query",
",",
"$",
"parameters",
")",
";",
"}",
"$",
"uri",
"=",
"Uri",
"::",
"createFromString",
"(",
"$",
"this",
"->",
"path",
")",
";",
"parse_str",
"(",
"$",
"uri",
"->",
"getQuery",
"(",
")",
",",
"$",
"queryParts",
")",
";",
"return",
"$",
"uri",
"->",
"withQuery",
"(",
"http_build_query",
"(",
"$",
"parameters",
"+",
"$",
"queryParts",
")",
")",
"->",
"withFragment",
"(",
"$",
"this",
"->",
"buildFragment",
"(",
")",
")",
"->",
"__toString",
"(",
")",
";",
"}"
] |
Get the URL for a given page number.
@param int $page
@return string
|
[
"Get",
"the",
"URL",
"for",
"a",
"given",
"page",
"number",
"."
] |
79f844c5c9c25ffbe18d142062e9bc3df00b36a1
|
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Pagination/AbstractPaginator.php#L143-L165
|
20,346 |
gpupo/common-schema
|
src/ORM/Entity/Application/API/OAuth/Provider.php
|
Provider.addClient
|
public function addClient(\Gpupo\CommonSchema\ORM\Entity\Application\API\OAuth\Client\Client $client)
{
$this->clients[] = $client;
return $this;
}
|
php
|
public function addClient(\Gpupo\CommonSchema\ORM\Entity\Application\API\OAuth\Client\Client $client)
{
$this->clients[] = $client;
return $this;
}
|
[
"public",
"function",
"addClient",
"(",
"\\",
"Gpupo",
"\\",
"CommonSchema",
"\\",
"ORM",
"\\",
"Entity",
"\\",
"Application",
"\\",
"API",
"\\",
"OAuth",
"\\",
"Client",
"\\",
"Client",
"$",
"client",
")",
"{",
"$",
"this",
"->",
"clients",
"[",
"]",
"=",
"$",
"client",
";",
"return",
"$",
"this",
";",
"}"
] |
Add client.
@param \Gpupo\CommonSchema\ORM\Entity\Application\API\OAuth\Client\Client $client
@return Provider
|
[
"Add",
"client",
"."
] |
a762d2eb3063b7317c72c69cbb463b1f95b86b0a
|
https://github.com/gpupo/common-schema/blob/a762d2eb3063b7317c72c69cbb463b1f95b86b0a/src/ORM/Entity/Application/API/OAuth/Provider.php#L279-L284
|
20,347 |
gpupo/common-schema
|
src/ORM/Entity/Application/API/OAuth/Provider.php
|
Provider.removeClient
|
public function removeClient(\Gpupo\CommonSchema\ORM\Entity\Application\API\OAuth\Client\Client $client)
{
return $this->clients->removeElement($client);
}
|
php
|
public function removeClient(\Gpupo\CommonSchema\ORM\Entity\Application\API\OAuth\Client\Client $client)
{
return $this->clients->removeElement($client);
}
|
[
"public",
"function",
"removeClient",
"(",
"\\",
"Gpupo",
"\\",
"CommonSchema",
"\\",
"ORM",
"\\",
"Entity",
"\\",
"Application",
"\\",
"API",
"\\",
"OAuth",
"\\",
"Client",
"\\",
"Client",
"$",
"client",
")",
"{",
"return",
"$",
"this",
"->",
"clients",
"->",
"removeElement",
"(",
"$",
"client",
")",
";",
"}"
] |
Remove client.
@param \Gpupo\CommonSchema\ORM\Entity\Application\API\OAuth\Client\Client $client
@return bool TRUE if this collection contained the specified element, FALSE otherwise
|
[
"Remove",
"client",
"."
] |
a762d2eb3063b7317c72c69cbb463b1f95b86b0a
|
https://github.com/gpupo/common-schema/blob/a762d2eb3063b7317c72c69cbb463b1f95b86b0a/src/ORM/Entity/Application/API/OAuth/Provider.php#L293-L296
|
20,348 |
bytic/framework
|
src/Paginator.php
|
Paginator.getLimits
|
public function getLimits()
{
$totalPages = $this->getTotalPages();
$this->currentPage = ($this->currentPage > $totalPages) ? $totalPages : $this->currentPage;
$dLimit = ($this->currentPage - 1) * $this->itemsPerPage;
return array($dLimit, $this->itemsPerPage);
}
|
php
|
public function getLimits()
{
$totalPages = $this->getTotalPages();
$this->currentPage = ($this->currentPage > $totalPages) ? $totalPages : $this->currentPage;
$dLimit = ($this->currentPage - 1) * $this->itemsPerPage;
return array($dLimit, $this->itemsPerPage);
}
|
[
"public",
"function",
"getLimits",
"(",
")",
"{",
"$",
"totalPages",
"=",
"$",
"this",
"->",
"getTotalPages",
"(",
")",
";",
"$",
"this",
"->",
"currentPage",
"=",
"(",
"$",
"this",
"->",
"currentPage",
">",
"$",
"totalPages",
")",
"?",
"$",
"totalPages",
":",
"$",
"this",
"->",
"currentPage",
";",
"$",
"dLimit",
"=",
"(",
"$",
"this",
"->",
"currentPage",
"-",
"1",
")",
"*",
"$",
"this",
"->",
"itemsPerPage",
";",
"return",
"array",
"(",
"$",
"dLimit",
",",
"$",
"this",
"->",
"itemsPerPage",
")",
";",
"}"
] |
Returns the offset ant length for limiting results to current page
@return array
|
[
"Returns",
"the",
"offset",
"ant",
"length",
"for",
"limiting",
"results",
"to",
"current",
"page"
] |
36b4a761f4b64899f3841b0f6c8eb92887e91677
|
https://github.com/bytic/framework/blob/36b4a761f4b64899f3841b0f6c8eb92887e91677/src/Paginator.php#L17-L26
|
20,349 |
colorium/web
|
src/Colorium/Web/Context.php
|
Context.post
|
public function post(...$keys)
{
if(!$keys) {
return $this->request->values;
}
elseif(count($keys) === 1) {
return $this->request->value($keys[0]);
}
$values = [];
foreach($keys as $key) {
$values[] = $this->request->value($key);
}
return $values;
}
|
php
|
public function post(...$keys)
{
if(!$keys) {
return $this->request->values;
}
elseif(count($keys) === 1) {
return $this->request->value($keys[0]);
}
$values = [];
foreach($keys as $key) {
$values[] = $this->request->value($key);
}
return $values;
}
|
[
"public",
"function",
"post",
"(",
"...",
"$",
"keys",
")",
"{",
"if",
"(",
"!",
"$",
"keys",
")",
"{",
"return",
"$",
"this",
"->",
"request",
"->",
"values",
";",
"}",
"elseif",
"(",
"count",
"(",
"$",
"keys",
")",
"===",
"1",
")",
"{",
"return",
"$",
"this",
"->",
"request",
"->",
"value",
"(",
"$",
"keys",
"[",
"0",
"]",
")",
";",
"}",
"$",
"values",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"keys",
"as",
"$",
"key",
")",
"{",
"$",
"values",
"[",
"]",
"=",
"$",
"this",
"->",
"request",
"->",
"value",
"(",
"$",
"key",
")",
";",
"}",
"return",
"$",
"values",
";",
"}"
] |
Get post value
@param array $keys
@return string
|
[
"Get",
"post",
"value"
] |
2a767658b8737022939b0cc4505b5f652c1683d2
|
https://github.com/colorium/web/blob/2a767658b8737022939b0cc4505b5f652c1683d2/src/Colorium/Web/Context.php#L76-L90
|
20,350 |
oroinc/OroLayoutComponent
|
Extension/Theme/Model/DependencyInitializer.php
|
DependencyInitializer.initialize
|
public function initialize($object)
{
if (!is_object($object)) {
return;
}
foreach ($this->knownDependencies as $interface => $dependencyInfo) {
list($setterMethod, $serviceId) = $dependencyInfo;
if (is_a($object, $interface)) {
$object->$setterMethod($this->container->get($serviceId));
}
}
}
|
php
|
public function initialize($object)
{
if (!is_object($object)) {
return;
}
foreach ($this->knownDependencies as $interface => $dependencyInfo) {
list($setterMethod, $serviceId) = $dependencyInfo;
if (is_a($object, $interface)) {
$object->$setterMethod($this->container->get($serviceId));
}
}
}
|
[
"public",
"function",
"initialize",
"(",
"$",
"object",
")",
"{",
"if",
"(",
"!",
"is_object",
"(",
"$",
"object",
")",
")",
"{",
"return",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"knownDependencies",
"as",
"$",
"interface",
"=>",
"$",
"dependencyInfo",
")",
"{",
"list",
"(",
"$",
"setterMethod",
",",
"$",
"serviceId",
")",
"=",
"$",
"dependencyInfo",
";",
"if",
"(",
"is_a",
"(",
"$",
"object",
",",
"$",
"interface",
")",
")",
"{",
"$",
"object",
"->",
"$",
"setterMethod",
"(",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"$",
"serviceId",
")",
")",
";",
"}",
"}",
"}"
] |
Initializes object dependencies
@param object $object
|
[
"Initializes",
"object",
"dependencies"
] |
682a96672393d81c63728e47c4a4c3618c515be0
|
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/Extension/Theme/Model/DependencyInitializer.php#L42-L55
|
20,351 |
mekras/atompub
|
src/Document/ServiceDocument.php
|
ServiceDocument.getWorkspaces
|
public function getWorkspaces()
{
return $this->getCachedProperty(
'workspaces',
function () {
$workspaces = [];
$items = $this->getDomElement()->getElementsByTagNameNS($this->ns(), 'workspace');
foreach ($items as $item) {
$workspaces[] = $this->getExtensions()->parseElement($this, $item);
}
return $workspaces;
}
);
}
|
php
|
public function getWorkspaces()
{
return $this->getCachedProperty(
'workspaces',
function () {
$workspaces = [];
$items = $this->getDomElement()->getElementsByTagNameNS($this->ns(), 'workspace');
foreach ($items as $item) {
$workspaces[] = $this->getExtensions()->parseElement($this, $item);
}
return $workspaces;
}
);
}
|
[
"public",
"function",
"getWorkspaces",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"getCachedProperty",
"(",
"'workspaces'",
",",
"function",
"(",
")",
"{",
"$",
"workspaces",
"=",
"[",
"]",
";",
"$",
"items",
"=",
"$",
"this",
"->",
"getDomElement",
"(",
")",
"->",
"getElementsByTagNameNS",
"(",
"$",
"this",
"->",
"ns",
"(",
")",
",",
"'workspace'",
")",
";",
"foreach",
"(",
"$",
"items",
"as",
"$",
"item",
")",
"{",
"$",
"workspaces",
"[",
"]",
"=",
"$",
"this",
"->",
"getExtensions",
"(",
")",
"->",
"parseElement",
"(",
"$",
"this",
",",
"$",
"item",
")",
";",
"}",
"return",
"$",
"workspaces",
";",
"}",
")",
";",
"}"
] |
Return workspaces.
@return Workspace[]
@since 1.0
|
[
"Return",
"workspaces",
"."
] |
cfc9aab97cff7a822b720e1dd84ef16733183dbb
|
https://github.com/mekras/atompub/blob/cfc9aab97cff7a822b720e1dd84ef16733183dbb/src/Document/ServiceDocument.php#L28-L42
|
20,352 |
mekras/atompub
|
src/Document/ServiceDocument.php
|
ServiceDocument.addWorkspace
|
public function addWorkspace($title)
{
$workspaces = $this->getWorkspaces();
/** @var Workspace $workspace */
$workspace = $this->getExtensions()->createElement($this, 'app:workspace');
$workspace->addTitle($title);
$workspaces[] = $workspace;
$this->setCachedProperty('workspaces', $workspaces);
return $workspace;
}
|
php
|
public function addWorkspace($title)
{
$workspaces = $this->getWorkspaces();
/** @var Workspace $workspace */
$workspace = $this->getExtensions()->createElement($this, 'app:workspace');
$workspace->addTitle($title);
$workspaces[] = $workspace;
$this->setCachedProperty('workspaces', $workspaces);
return $workspace;
}
|
[
"public",
"function",
"addWorkspace",
"(",
"$",
"title",
")",
"{",
"$",
"workspaces",
"=",
"$",
"this",
"->",
"getWorkspaces",
"(",
")",
";",
"/** @var Workspace $workspace */",
"$",
"workspace",
"=",
"$",
"this",
"->",
"getExtensions",
"(",
")",
"->",
"createElement",
"(",
"$",
"this",
",",
"'app:workspace'",
")",
";",
"$",
"workspace",
"->",
"addTitle",
"(",
"$",
"title",
")",
";",
"$",
"workspaces",
"[",
"]",
"=",
"$",
"workspace",
";",
"$",
"this",
"->",
"setCachedProperty",
"(",
"'workspaces'",
",",
"$",
"workspaces",
")",
";",
"return",
"$",
"workspace",
";",
"}"
] |
Add workspace to document.
@param string $title
@return Workspace
@since 1.0
|
[
"Add",
"workspace",
"to",
"document",
"."
] |
cfc9aab97cff7a822b720e1dd84ef16733183dbb
|
https://github.com/mekras/atompub/blob/cfc9aab97cff7a822b720e1dd84ef16733183dbb/src/Document/ServiceDocument.php#L53-L65
|
20,353 |
Speicher210/monsum-api
|
src/Service/Article/ArticleService.php
|
ArticleService.getArticles
|
public function getArticles($articleNumber = null)
{
$requestData = new Get\RequestData();
$requestData->setArticleNumber($articleNumber);
$request = new Get\Request($requestData);
return $this->sendRequest($request, Get\ApiResponse::class);
}
|
php
|
public function getArticles($articleNumber = null)
{
$requestData = new Get\RequestData();
$requestData->setArticleNumber($articleNumber);
$request = new Get\Request($requestData);
return $this->sendRequest($request, Get\ApiResponse::class);
}
|
[
"public",
"function",
"getArticles",
"(",
"$",
"articleNumber",
"=",
"null",
")",
"{",
"$",
"requestData",
"=",
"new",
"Get",
"\\",
"RequestData",
"(",
")",
";",
"$",
"requestData",
"->",
"setArticleNumber",
"(",
"$",
"articleNumber",
")",
";",
"$",
"request",
"=",
"new",
"Get",
"\\",
"Request",
"(",
"$",
"requestData",
")",
";",
"return",
"$",
"this",
"->",
"sendRequest",
"(",
"$",
"request",
",",
"Get",
"\\",
"ApiResponse",
"::",
"class",
")",
";",
"}"
] |
Get the articles.
@param string $articleNumber Article number to filter on.
@return Get\ApiResponse
|
[
"Get",
"the",
"articles",
"."
] |
4611a048097de5d2b0efe9d4426779c783c0af4d
|
https://github.com/Speicher210/monsum-api/blob/4611a048097de5d2b0efe9d4426779c783c0af4d/src/Service/Article/ArticleService.php#L23-L31
|
20,354 |
Speicher210/monsum-api
|
src/Service/Article/ArticleService.php
|
ArticleService.getArticle
|
public function getArticle($articleNumber)
{
$requestData = new Get\RequestData();
$requestData->setArticleNumber($articleNumber);
$request = new Get\Request($requestData);
$request->setLimit(1);
/** @var Get\ApiResponse $apiResponse */
$apiResponse = $this->sendRequest($request, Get\ApiResponse::class);
$articles = $apiResponse->getResponse()->getArticles();
return isset($articles[0]) ? $articles[0] : null;
}
|
php
|
public function getArticle($articleNumber)
{
$requestData = new Get\RequestData();
$requestData->setArticleNumber($articleNumber);
$request = new Get\Request($requestData);
$request->setLimit(1);
/** @var Get\ApiResponse $apiResponse */
$apiResponse = $this->sendRequest($request, Get\ApiResponse::class);
$articles = $apiResponse->getResponse()->getArticles();
return isset($articles[0]) ? $articles[0] : null;
}
|
[
"public",
"function",
"getArticle",
"(",
"$",
"articleNumber",
")",
"{",
"$",
"requestData",
"=",
"new",
"Get",
"\\",
"RequestData",
"(",
")",
";",
"$",
"requestData",
"->",
"setArticleNumber",
"(",
"$",
"articleNumber",
")",
";",
"$",
"request",
"=",
"new",
"Get",
"\\",
"Request",
"(",
"$",
"requestData",
")",
";",
"$",
"request",
"->",
"setLimit",
"(",
"1",
")",
";",
"/** @var Get\\ApiResponse $apiResponse */",
"$",
"apiResponse",
"=",
"$",
"this",
"->",
"sendRequest",
"(",
"$",
"request",
",",
"Get",
"\\",
"ApiResponse",
"::",
"class",
")",
";",
"$",
"articles",
"=",
"$",
"apiResponse",
"->",
"getResponse",
"(",
")",
"->",
"getArticles",
"(",
")",
";",
"return",
"isset",
"(",
"$",
"articles",
"[",
"0",
"]",
")",
"?",
"$",
"articles",
"[",
"0",
"]",
":",
"null",
";",
"}"
] |
Get one article by article number.
@param string $articleNumber Article number of the article to get.
@return Article|null
|
[
"Get",
"one",
"article",
"by",
"article",
"number",
"."
] |
4611a048097de5d2b0efe9d4426779c783c0af4d
|
https://github.com/Speicher210/monsum-api/blob/4611a048097de5d2b0efe9d4426779c783c0af4d/src/Service/Article/ArticleService.php#L39-L52
|
20,355 |
Speicher210/monsum-api
|
src/Service/Article/ArticleService.php
|
ArticleService.getArticleNumberCheckoutURL
|
public function getArticleNumberCheckoutURL($articleNumber, Customer $customer = null)
{
$article = $this->getArticle($articleNumber);
if ($article === null) {
throw new \OutOfBoundsException('Article not found.');
}
return $this->getArticleCheckoutURL($article, $customer);
}
|
php
|
public function getArticleNumberCheckoutURL($articleNumber, Customer $customer = null)
{
$article = $this->getArticle($articleNumber);
if ($article === null) {
throw new \OutOfBoundsException('Article not found.');
}
return $this->getArticleCheckoutURL($article, $customer);
}
|
[
"public",
"function",
"getArticleNumberCheckoutURL",
"(",
"$",
"articleNumber",
",",
"Customer",
"$",
"customer",
"=",
"null",
")",
"{",
"$",
"article",
"=",
"$",
"this",
"->",
"getArticle",
"(",
"$",
"articleNumber",
")",
";",
"if",
"(",
"$",
"article",
"===",
"null",
")",
"{",
"throw",
"new",
"\\",
"OutOfBoundsException",
"(",
"'Article not found.'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"getArticleCheckoutURL",
"(",
"$",
"article",
",",
"$",
"customer",
")",
";",
"}"
] |
Get the checkout URL for an article.
@param string $articleNumber Article number of the article to get the checkout URL.
@param Customer $customer The customer for which the checkout URL should be created.
@return string
@throws \OutOfBoundsException If the article is not found.
|
[
"Get",
"the",
"checkout",
"URL",
"for",
"an",
"article",
"."
] |
4611a048097de5d2b0efe9d4426779c783c0af4d
|
https://github.com/Speicher210/monsum-api/blob/4611a048097de5d2b0efe9d4426779c783c0af4d/src/Service/Article/ArticleService.php#L85-L93
|
20,356 |
Speicher210/monsum-api
|
src/Service/Article/ArticleService.php
|
ArticleService.generateCheckoutURLForCustomer
|
protected function generateCheckoutURLForCustomer($customerHash, $articleNumber)
{
return sprintf(
'https://app.monsum.com/checkout/0/%s/%s/%s',
$this->transport->getCredentials()->getAccountHash(),
$customerHash,
$articleNumber
);
}
|
php
|
protected function generateCheckoutURLForCustomer($customerHash, $articleNumber)
{
return sprintf(
'https://app.monsum.com/checkout/0/%s/%s/%s',
$this->transport->getCredentials()->getAccountHash(),
$customerHash,
$articleNumber
);
}
|
[
"protected",
"function",
"generateCheckoutURLForCustomer",
"(",
"$",
"customerHash",
",",
"$",
"articleNumber",
")",
"{",
"return",
"sprintf",
"(",
"'https://app.monsum.com/checkout/0/%s/%s/%s'",
",",
"$",
"this",
"->",
"transport",
"->",
"getCredentials",
"(",
")",
"->",
"getAccountHash",
"(",
")",
",",
"$",
"customerHash",
",",
"$",
"articleNumber",
")",
";",
"}"
] |
Get the checkout URL of an article for a customer.
@param string $customerHash The customer hash.
@param string $articleNumber The article number.
@return string
|
[
"Get",
"the",
"checkout",
"URL",
"of",
"an",
"article",
"for",
"a",
"customer",
"."
] |
4611a048097de5d2b0efe9d4426779c783c0af4d
|
https://github.com/Speicher210/monsum-api/blob/4611a048097de5d2b0efe9d4426779c783c0af4d/src/Service/Article/ArticleService.php#L116-L124
|
20,357 |
superjimpupcake/Pupcake
|
src/Pupcake/Route.php
|
Route.execute
|
public function execute($params = array())
{
$app = $this->router->getAppInstance();
return $app->trigger("system.routing.route.execute", function($event) {
$app = $event->props('app');
$route = $event->props('route');
$params = $event->props('params');
if (count($params) == 0) {
$params = $route->getParams();
}
//enhancement, detect the type of the callback
$callback = $route->getCallback();
if (is_string($callback)) {
$callback_comps = explode("#", $callback);
$callback_object_class = $callback_comps[0]; //starting from root namespace
$callback_object_class = str_replace(".", "\\", $callback_object_class);
$callback_object = new $callback_object_class($app);
$callback_object_method = $callback_comps[1];
$callback = array($callback_object, $callback_object_method);
}
return call_user_func_array($callback, $params);
}, array('app' => $app, 'route' => $this, 'params' => $params));
}
|
php
|
public function execute($params = array())
{
$app = $this->router->getAppInstance();
return $app->trigger("system.routing.route.execute", function($event) {
$app = $event->props('app');
$route = $event->props('route');
$params = $event->props('params');
if (count($params) == 0) {
$params = $route->getParams();
}
//enhancement, detect the type of the callback
$callback = $route->getCallback();
if (is_string($callback)) {
$callback_comps = explode("#", $callback);
$callback_object_class = $callback_comps[0]; //starting from root namespace
$callback_object_class = str_replace(".", "\\", $callback_object_class);
$callback_object = new $callback_object_class($app);
$callback_object_method = $callback_comps[1];
$callback = array($callback_object, $callback_object_method);
}
return call_user_func_array($callback, $params);
}, array('app' => $app, 'route' => $this, 'params' => $params));
}
|
[
"public",
"function",
"execute",
"(",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"$",
"app",
"=",
"$",
"this",
"->",
"router",
"->",
"getAppInstance",
"(",
")",
";",
"return",
"$",
"app",
"->",
"trigger",
"(",
"\"system.routing.route.execute\"",
",",
"function",
"(",
"$",
"event",
")",
"{",
"$",
"app",
"=",
"$",
"event",
"->",
"props",
"(",
"'app'",
")",
";",
"$",
"route",
"=",
"$",
"event",
"->",
"props",
"(",
"'route'",
")",
";",
"$",
"params",
"=",
"$",
"event",
"->",
"props",
"(",
"'params'",
")",
";",
"if",
"(",
"count",
"(",
"$",
"params",
")",
"==",
"0",
")",
"{",
"$",
"params",
"=",
"$",
"route",
"->",
"getParams",
"(",
")",
";",
"}",
"//enhancement, detect the type of the callback",
"$",
"callback",
"=",
"$",
"route",
"->",
"getCallback",
"(",
")",
";",
"if",
"(",
"is_string",
"(",
"$",
"callback",
")",
")",
"{",
"$",
"callback_comps",
"=",
"explode",
"(",
"\"#\"",
",",
"$",
"callback",
")",
";",
"$",
"callback_object_class",
"=",
"$",
"callback_comps",
"[",
"0",
"]",
";",
"//starting from root namespace",
"$",
"callback_object_class",
"=",
"str_replace",
"(",
"\".\"",
",",
"\"\\\\\"",
",",
"$",
"callback_object_class",
")",
";",
"$",
"callback_object",
"=",
"new",
"$",
"callback_object_class",
"(",
"$",
"app",
")",
";",
"$",
"callback_object_method",
"=",
"$",
"callback_comps",
"[",
"1",
"]",
";",
"$",
"callback",
"=",
"array",
"(",
"$",
"callback_object",
",",
"$",
"callback_object_method",
")",
";",
"}",
"return",
"call_user_func_array",
"(",
"$",
"callback",
",",
"$",
"params",
")",
";",
"}",
",",
"array",
"(",
"'app'",
"=>",
"$",
"app",
",",
"'route'",
"=>",
"$",
"this",
",",
"'params'",
"=>",
"$",
"params",
")",
")",
";",
"}"
] |
Execute this route
|
[
"Execute",
"this",
"route"
] |
2f962818646e4e1d65f5d008eeb953cb41ebb3e0
|
https://github.com/superjimpupcake/Pupcake/blob/2f962818646e4e1d65f5d008eeb953cb41ebb3e0/src/Pupcake/Route.php#L88-L110
|
20,358 |
mustardandrew/muan-laravel-acl
|
src/Traits/HasRolesTrait.php
|
HasRolesTrait.eachRole
|
public function eachRole(array $roles, callable $callback)
{
$roles = array_flatten($roles);
foreach ($roles as $role) {
if ($role = $this->prepareRole($role)) {
$callback($role);
}
}
}
|
php
|
public function eachRole(array $roles, callable $callback)
{
$roles = array_flatten($roles);
foreach ($roles as $role) {
if ($role = $this->prepareRole($role)) {
$callback($role);
}
}
}
|
[
"public",
"function",
"eachRole",
"(",
"array",
"$",
"roles",
",",
"callable",
"$",
"callback",
")",
"{",
"$",
"roles",
"=",
"array_flatten",
"(",
"$",
"roles",
")",
";",
"foreach",
"(",
"$",
"roles",
"as",
"$",
"role",
")",
"{",
"if",
"(",
"$",
"role",
"=",
"$",
"this",
"->",
"prepareRole",
"(",
"$",
"role",
")",
")",
"{",
"$",
"callback",
"(",
"$",
"role",
")",
";",
"}",
"}",
"}"
] |
Calc each rote
@param array $roles
@param callable $callback
|
[
"Calc",
"each",
"rote"
] |
b5f23340b5536babb98d9fd0d727a7a3371c97d5
|
https://github.com/mustardandrew/muan-laravel-acl/blob/b5f23340b5536babb98d9fd0d727a7a3371c97d5/src/Traits/HasRolesTrait.php#L117-L126
|
20,359 |
heidelpay/PhpDoc
|
src/phpDocumentor/Console/Output/Output.php
|
Output.writeTimedLog
|
public function writeTimedLog($message, $operation, array $arguments = array())
{
$this->write(sprintf('%-66.66s .. ', $message));
$timerStart = microtime(true);
call_user_func_array($operation, $arguments);
$this->writeln(sprintf('%8.3fs', microtime(true) - $timerStart));
}
|
php
|
public function writeTimedLog($message, $operation, array $arguments = array())
{
$this->write(sprintf('%-66.66s .. ', $message));
$timerStart = microtime(true);
call_user_func_array($operation, $arguments);
$this->writeln(sprintf('%8.3fs', microtime(true) - $timerStart));
}
|
[
"public",
"function",
"writeTimedLog",
"(",
"$",
"message",
",",
"$",
"operation",
",",
"array",
"$",
"arguments",
"=",
"array",
"(",
")",
")",
"{",
"$",
"this",
"->",
"write",
"(",
"sprintf",
"(",
"'%-66.66s .. '",
",",
"$",
"message",
")",
")",
";",
"$",
"timerStart",
"=",
"microtime",
"(",
"true",
")",
";",
"call_user_func_array",
"(",
"$",
"operation",
",",
"$",
"arguments",
")",
";",
"$",
"this",
"->",
"writeln",
"(",
"sprintf",
"(",
"'%8.3fs'",
",",
"microtime",
"(",
"true",
")",
"-",
"$",
"timerStart",
")",
")",
";",
"}"
] |
Executes a callable piece of code and writes an entry to the log detailing how long it took.
@param string $message
@param callable $operation
@param array $arguments
@return void
|
[
"Executes",
"a",
"callable",
"piece",
"of",
"code",
"and",
"writes",
"an",
"entry",
"to",
"the",
"log",
"detailing",
"how",
"long",
"it",
"took",
"."
] |
5ac9e842cbd4cbb70900533b240c131f3515ee02
|
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Console/Output/Output.php#L54-L62
|
20,360 |
heidelpay/PhpDoc
|
src/phpDocumentor/Console/Output/Output.php
|
Output.write
|
public function write($message, $newline = false, $type = 0)
{
$messages = (array) $message;
if ($this->getLogger()) {
foreach ($messages as $message) {
$this->getLogger()->info($this->getFormatter()->format(strip_tags($message)));
}
}
parent::write($messages, $newline, $type);
}
|
php
|
public function write($message, $newline = false, $type = 0)
{
$messages = (array) $message;
if ($this->getLogger()) {
foreach ($messages as $message) {
$this->getLogger()->info($this->getFormatter()->format(strip_tags($message)));
}
}
parent::write($messages, $newline, $type);
}
|
[
"public",
"function",
"write",
"(",
"$",
"message",
",",
"$",
"newline",
"=",
"false",
",",
"$",
"type",
"=",
"0",
")",
"{",
"$",
"messages",
"=",
"(",
"array",
")",
"$",
"message",
";",
"if",
"(",
"$",
"this",
"->",
"getLogger",
"(",
")",
")",
"{",
"foreach",
"(",
"$",
"messages",
"as",
"$",
"message",
")",
"{",
"$",
"this",
"->",
"getLogger",
"(",
")",
"->",
"info",
"(",
"$",
"this",
"->",
"getFormatter",
"(",
")",
"->",
"format",
"(",
"strip_tags",
"(",
"$",
"message",
")",
")",
")",
";",
"}",
"}",
"parent",
"::",
"write",
"(",
"$",
"messages",
",",
"$",
"newline",
",",
"$",
"type",
")",
";",
"}"
] |
Write an entry to the console and to the provided logger.
@param array|string $message
@param bool $newline
@param int $type
@return void
|
[
"Write",
"an",
"entry",
"to",
"the",
"console",
"and",
"to",
"the",
"provided",
"logger",
"."
] |
5ac9e842cbd4cbb70900533b240c131f3515ee02
|
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Console/Output/Output.php#L73-L84
|
20,361 |
interactivesolutions/honeycomb-core
|
src/http/controllers/HCCoreFormValidator.php
|
HCCoreFormValidator.formatErrors
|
protected function formatErrors(string $errors)
{
$errors = json_decode($errors);
$output = '';
foreach ($errors as $error)
foreach ($error as $message)
$output .= $message . "\r\n";
return $output;
}
|
php
|
protected function formatErrors(string $errors)
{
$errors = json_decode($errors);
$output = '';
foreach ($errors as $error)
foreach ($error as $message)
$output .= $message . "\r\n";
return $output;
}
|
[
"protected",
"function",
"formatErrors",
"(",
"string",
"$",
"errors",
")",
"{",
"$",
"errors",
"=",
"json_decode",
"(",
"$",
"errors",
")",
";",
"$",
"output",
"=",
"''",
";",
"foreach",
"(",
"$",
"errors",
"as",
"$",
"error",
")",
"foreach",
"(",
"$",
"error",
"as",
"$",
"message",
")",
"$",
"output",
".=",
"$",
"message",
".",
"\"\\r\\n\"",
";",
"return",
"$",
"output",
";",
"}"
] |
Must return string!!
@param string $errors
@return mixed
|
[
"Must",
"return",
"string!!"
] |
06b8d88bb285e73a1a286e60411ca5f41863f39f
|
https://github.com/interactivesolutions/honeycomb-core/blob/06b8d88bb285e73a1a286e60411ca5f41863f39f/src/http/controllers/HCCoreFormValidator.php#L95-L105
|
20,362 |
ezsystems/ezcomments-ls-extension
|
classes/ezcompermission.php
|
ezcomPermission.hasFunctionAccess
|
public function hasFunctionAccess( $user, $functionName, $contentObject, $languageCode, $comment = null, $scope = null, $node = null )
{
$result = $user->hasAccessTo( self::$moduleName, $functionName );
if ( $result['accessWord'] !== 'limited' )
{
$return = ( $result['accessWord'] === 'yes' ) and ( $scope !== 'personal' );
}
else
{
foreach( $result['policies'] as $limitationArray )
{
// eZDebug::writeDebug( $limitationArray, "limitationArray for function $functionName" );
$return = true;
foreach( $limitationArray as $limitationKey => $limitation )
{
// deal with limitation checking
$resultItem = $this->checkPermission( $user, $limitationKey, $limitation,
$contentObject, $languageCode, $comment, $scope, $node );
ezDebugSetting::writeNotice( 'extension-ezcomments',
"Permission check result for function '$functionName' with limitation '$limitationKey': " . ( $resultItem === true ? 'true' : 'false' ), __METHOD__ );
$return = ( $return and $resultItem );
}
if ( $return === true )
break;
}
}
return $return;
}
|
php
|
public function hasFunctionAccess( $user, $functionName, $contentObject, $languageCode, $comment = null, $scope = null, $node = null )
{
$result = $user->hasAccessTo( self::$moduleName, $functionName );
if ( $result['accessWord'] !== 'limited' )
{
$return = ( $result['accessWord'] === 'yes' ) and ( $scope !== 'personal' );
}
else
{
foreach( $result['policies'] as $limitationArray )
{
// eZDebug::writeDebug( $limitationArray, "limitationArray for function $functionName" );
$return = true;
foreach( $limitationArray as $limitationKey => $limitation )
{
// deal with limitation checking
$resultItem = $this->checkPermission( $user, $limitationKey, $limitation,
$contentObject, $languageCode, $comment, $scope, $node );
ezDebugSetting::writeNotice( 'extension-ezcomments',
"Permission check result for function '$functionName' with limitation '$limitationKey': " . ( $resultItem === true ? 'true' : 'false' ), __METHOD__ );
$return = ( $return and $resultItem );
}
if ( $return === true )
break;
}
}
return $return;
}
|
[
"public",
"function",
"hasFunctionAccess",
"(",
"$",
"user",
",",
"$",
"functionName",
",",
"$",
"contentObject",
",",
"$",
"languageCode",
",",
"$",
"comment",
"=",
"null",
",",
"$",
"scope",
"=",
"null",
",",
"$",
"node",
"=",
"null",
")",
"{",
"$",
"result",
"=",
"$",
"user",
"->",
"hasAccessTo",
"(",
"self",
"::",
"$",
"moduleName",
",",
"$",
"functionName",
")",
";",
"if",
"(",
"$",
"result",
"[",
"'accessWord'",
"]",
"!==",
"'limited'",
")",
"{",
"$",
"return",
"=",
"(",
"$",
"result",
"[",
"'accessWord'",
"]",
"===",
"'yes'",
")",
"and",
"(",
"$",
"scope",
"!==",
"'personal'",
")",
";",
"}",
"else",
"{",
"foreach",
"(",
"$",
"result",
"[",
"'policies'",
"]",
"as",
"$",
"limitationArray",
")",
"{",
"// eZDebug::writeDebug( $limitationArray, \"limitationArray for function $functionName\" );",
"$",
"return",
"=",
"true",
";",
"foreach",
"(",
"$",
"limitationArray",
"as",
"$",
"limitationKey",
"=>",
"$",
"limitation",
")",
"{",
"// deal with limitation checking",
"$",
"resultItem",
"=",
"$",
"this",
"->",
"checkPermission",
"(",
"$",
"user",
",",
"$",
"limitationKey",
",",
"$",
"limitation",
",",
"$",
"contentObject",
",",
"$",
"languageCode",
",",
"$",
"comment",
",",
"$",
"scope",
",",
"$",
"node",
")",
";",
"ezDebugSetting",
"::",
"writeNotice",
"(",
"'extension-ezcomments'",
",",
"\"Permission check result for function '$functionName' with limitation '$limitationKey': \"",
".",
"(",
"$",
"resultItem",
"===",
"true",
"?",
"'true'",
":",
"'false'",
")",
",",
"__METHOD__",
")",
";",
"$",
"return",
"=",
"(",
"$",
"return",
"and",
"$",
"resultItem",
")",
";",
"}",
"if",
"(",
"$",
"return",
"===",
"true",
")",
"break",
";",
"}",
"}",
"return",
"$",
"return",
";",
"}"
] |
check if the user has Acceess to the object with limitation of class, section, owner, language, nodes, subtrees
return true if has, false if not
|
[
"check",
"if",
"the",
"user",
"has",
"Acceess",
"to",
"the",
"object",
"with",
"limitation",
"of",
"class",
"section",
"owner",
"language",
"nodes",
"subtrees"
] |
2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5
|
https://github.com/ezsystems/ezcomments-ls-extension/blob/2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5/classes/ezcompermission.php#L28-L58
|
20,363 |
alevilar/ristorantino-vendor
|
Stats/Controller/QueriesController.php
|
QueriesController.contruye_excel
|
function contruye_excel($id){
$this->layout = 'excel';
Configure::write('debug',0);
$this->RequestHandler->setContent('xls', 'application/vnd.ms-excel');
$res = $this->Query->findById($id);
$sql = $res['Query']['query'];
$this->Query->recursive = -1;
$consulta_ejecutada = $this->Query->query($sql);
$precols = array_keys($consulta_ejecutada[0]);
$quitar_columnas = $consulta_ejecutada[0][0];
while(list($key,$value) = each($quitar_columnas)):
$columnas[] = $key;
endwhile;
$this->set('nombre',$res['Query']['name']);
$this->set('columnas',$columnas);
$this->set('filas',$consulta_ejecutada);
}
|
php
|
function contruye_excel($id){
$this->layout = 'excel';
Configure::write('debug',0);
$this->RequestHandler->setContent('xls', 'application/vnd.ms-excel');
$res = $this->Query->findById($id);
$sql = $res['Query']['query'];
$this->Query->recursive = -1;
$consulta_ejecutada = $this->Query->query($sql);
$precols = array_keys($consulta_ejecutada[0]);
$quitar_columnas = $consulta_ejecutada[0][0];
while(list($key,$value) = each($quitar_columnas)):
$columnas[] = $key;
endwhile;
$this->set('nombre',$res['Query']['name']);
$this->set('columnas',$columnas);
$this->set('filas',$consulta_ejecutada);
}
|
[
"function",
"contruye_excel",
"(",
"$",
"id",
")",
"{",
"$",
"this",
"->",
"layout",
"=",
"'excel'",
";",
"Configure",
"::",
"write",
"(",
"'debug'",
",",
"0",
")",
";",
"$",
"this",
"->",
"RequestHandler",
"->",
"setContent",
"(",
"'xls'",
",",
"'application/vnd.ms-excel'",
")",
";",
"$",
"res",
"=",
"$",
"this",
"->",
"Query",
"->",
"findById",
"(",
"$",
"id",
")",
";",
"$",
"sql",
"=",
"$",
"res",
"[",
"'Query'",
"]",
"[",
"'query'",
"]",
";",
"$",
"this",
"->",
"Query",
"->",
"recursive",
"=",
"-",
"1",
";",
"$",
"consulta_ejecutada",
"=",
"$",
"this",
"->",
"Query",
"->",
"query",
"(",
"$",
"sql",
")",
";",
"$",
"precols",
"=",
"array_keys",
"(",
"$",
"consulta_ejecutada",
"[",
"0",
"]",
")",
";",
"$",
"quitar_columnas",
"=",
"$",
"consulta_ejecutada",
"[",
"0",
"]",
"[",
"0",
"]",
";",
"while",
"(",
"list",
"(",
"$",
"key",
",",
"$",
"value",
")",
"=",
"each",
"(",
"$",
"quitar_columnas",
")",
")",
":",
"$",
"columnas",
"[",
"]",
"=",
"$",
"key",
";",
"endwhile",
";",
"$",
"this",
"->",
"set",
"(",
"'nombre'",
",",
"$",
"res",
"[",
"'Query'",
"]",
"[",
"'name'",
"]",
")",
";",
"$",
"this",
"->",
"set",
"(",
"'columnas'",
",",
"$",
"columnas",
")",
";",
"$",
"this",
"->",
"set",
"(",
"'filas'",
",",
"$",
"consulta_ejecutada",
")",
";",
"}"
] |
esto me construye un excel en la vista con el id de la query
@param $id
|
[
"esto",
"me",
"construye",
"un",
"excel",
"en",
"la",
"vista",
"con",
"el",
"id",
"de",
"la",
"query"
] |
6b91a1e20cc0ba09a1968d77e3de6512cfa2d966
|
https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Stats/Controller/QueriesController.php#L94-L114
|
20,364 |
hametuha/wpametu
|
src/WPametu/DB/TableBuilder.php
|
TableBuilder.db_update
|
private function db_update( $file ){
require $file;
if( isset($table) ){
// Test required members
$config = wp_parse_args($table, [
'name' => str_replace('.php', '', basename($file)),
'version' => false,
'engine' => Engine::INNODB,
'columns' => false,
'primary_key' => [],
'indexes' => [],
'unique' => [],
'fulltext' => [],
]);
$table_name = $config['name'];
if( $config['name'] && $config['version'] && $config['indexes'] ){
if( $this->need_update($table_name, $config['version']) ){
// Add prefix
$config['name'] = $this->db->prefix.$config['name'];
// Need update. Let's make query!
$query = $this->make_query($config);
if( !function_exists('dbDelta') ){
require_once ABSPATH . "wp-admin/includes/upgrade.php";
}
// Do dbDelta
$result = dbDelta($query);
// Return message
if( isset( $result[$config['name']] ) ){
$message = sprintf('<code>%s</code> created.', $config['name']);
}else{
$message = sprintf('<code>%s</code> updated.', $config['name']);
}
if( !empty($this->db->last_error) ){
$message .= sprintf(' <small>(Error: %s)</small>', $this->db->last_error);
}
// Check table existence
if( $this->table_exists($config['name']) ){
update_option($this->option_key, array_merge($this->option, [
$table_name => $config['version'],
]));
}else{
$message = sprintf('Failed to create or update <code>%s</code>', $config['name']);
}
return $message;
}
}else{
throw new \Exception(sprintf('Config file %s is wrong.', $file));
}
}else{
throw new \Exception(sprintf('Config file %s must be PHP Array format.', $file));
}
return '';
}
|
php
|
private function db_update( $file ){
require $file;
if( isset($table) ){
// Test required members
$config = wp_parse_args($table, [
'name' => str_replace('.php', '', basename($file)),
'version' => false,
'engine' => Engine::INNODB,
'columns' => false,
'primary_key' => [],
'indexes' => [],
'unique' => [],
'fulltext' => [],
]);
$table_name = $config['name'];
if( $config['name'] && $config['version'] && $config['indexes'] ){
if( $this->need_update($table_name, $config['version']) ){
// Add prefix
$config['name'] = $this->db->prefix.$config['name'];
// Need update. Let's make query!
$query = $this->make_query($config);
if( !function_exists('dbDelta') ){
require_once ABSPATH . "wp-admin/includes/upgrade.php";
}
// Do dbDelta
$result = dbDelta($query);
// Return message
if( isset( $result[$config['name']] ) ){
$message = sprintf('<code>%s</code> created.', $config['name']);
}else{
$message = sprintf('<code>%s</code> updated.', $config['name']);
}
if( !empty($this->db->last_error) ){
$message .= sprintf(' <small>(Error: %s)</small>', $this->db->last_error);
}
// Check table existence
if( $this->table_exists($config['name']) ){
update_option($this->option_key, array_merge($this->option, [
$table_name => $config['version'],
]));
}else{
$message = sprintf('Failed to create or update <code>%s</code>', $config['name']);
}
return $message;
}
}else{
throw new \Exception(sprintf('Config file %s is wrong.', $file));
}
}else{
throw new \Exception(sprintf('Config file %s must be PHP Array format.', $file));
}
return '';
}
|
[
"private",
"function",
"db_update",
"(",
"$",
"file",
")",
"{",
"require",
"$",
"file",
";",
"if",
"(",
"isset",
"(",
"$",
"table",
")",
")",
"{",
"// Test required members",
"$",
"config",
"=",
"wp_parse_args",
"(",
"$",
"table",
",",
"[",
"'name'",
"=>",
"str_replace",
"(",
"'.php'",
",",
"''",
",",
"basename",
"(",
"$",
"file",
")",
")",
",",
"'version'",
"=>",
"false",
",",
"'engine'",
"=>",
"Engine",
"::",
"INNODB",
",",
"'columns'",
"=>",
"false",
",",
"'primary_key'",
"=>",
"[",
"]",
",",
"'indexes'",
"=>",
"[",
"]",
",",
"'unique'",
"=>",
"[",
"]",
",",
"'fulltext'",
"=>",
"[",
"]",
",",
"]",
")",
";",
"$",
"table_name",
"=",
"$",
"config",
"[",
"'name'",
"]",
";",
"if",
"(",
"$",
"config",
"[",
"'name'",
"]",
"&&",
"$",
"config",
"[",
"'version'",
"]",
"&&",
"$",
"config",
"[",
"'indexes'",
"]",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"need_update",
"(",
"$",
"table_name",
",",
"$",
"config",
"[",
"'version'",
"]",
")",
")",
"{",
"// Add prefix",
"$",
"config",
"[",
"'name'",
"]",
"=",
"$",
"this",
"->",
"db",
"->",
"prefix",
".",
"$",
"config",
"[",
"'name'",
"]",
";",
"// Need update. Let's make query!",
"$",
"query",
"=",
"$",
"this",
"->",
"make_query",
"(",
"$",
"config",
")",
";",
"if",
"(",
"!",
"function_exists",
"(",
"'dbDelta'",
")",
")",
"{",
"require_once",
"ABSPATH",
".",
"\"wp-admin/includes/upgrade.php\"",
";",
"}",
"// Do dbDelta",
"$",
"result",
"=",
"dbDelta",
"(",
"$",
"query",
")",
";",
"// Return message",
"if",
"(",
"isset",
"(",
"$",
"result",
"[",
"$",
"config",
"[",
"'name'",
"]",
"]",
")",
")",
"{",
"$",
"message",
"=",
"sprintf",
"(",
"'<code>%s</code> created.'",
",",
"$",
"config",
"[",
"'name'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"message",
"=",
"sprintf",
"(",
"'<code>%s</code> updated.'",
",",
"$",
"config",
"[",
"'name'",
"]",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"db",
"->",
"last_error",
")",
")",
"{",
"$",
"message",
".=",
"sprintf",
"(",
"' <small>(Error: %s)</small>'",
",",
"$",
"this",
"->",
"db",
"->",
"last_error",
")",
";",
"}",
"// Check table existence",
"if",
"(",
"$",
"this",
"->",
"table_exists",
"(",
"$",
"config",
"[",
"'name'",
"]",
")",
")",
"{",
"update_option",
"(",
"$",
"this",
"->",
"option_key",
",",
"array_merge",
"(",
"$",
"this",
"->",
"option",
",",
"[",
"$",
"table_name",
"=>",
"$",
"config",
"[",
"'version'",
"]",
",",
"]",
")",
")",
";",
"}",
"else",
"{",
"$",
"message",
"=",
"sprintf",
"(",
"'Failed to create or update <code>%s</code>'",
",",
"$",
"config",
"[",
"'name'",
"]",
")",
";",
"}",
"return",
"$",
"message",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"sprintf",
"(",
"'Config file %s is wrong.'",
",",
"$",
"file",
")",
")",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"sprintf",
"(",
"'Config file %s must be PHP Array format.'",
",",
"$",
"file",
")",
")",
";",
"}",
"return",
"''",
";",
"}"
] |
Update db if possible
@param string $file path to config
@return string
@throws \Exception
|
[
"Update",
"db",
"if",
"possible"
] |
0939373800815a8396291143d2a57967340da5aa
|
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/DB/TableBuilder.php#L80-L132
|
20,365 |
hametuha/wpametu
|
src/WPametu/DB/TableBuilder.php
|
TableBuilder.make_query
|
private function make_query($config){
/** @var $name string */
/** @var $version string */
/** @var $engine string */
/** @var $columns array */
/** @var $primary_key array */
/** @var $indexes array */
/** @var $unique array */
/** @var $fulltext array */
/** @var $charset string */
extract($config);
if( empty($columns) ){
throw new \Exception(sprintf('Columns of %s shouldn\'t be empty.', $name), 500);
}
$column_query = [];
foreach( $columns as $name => $column ){
$column_query[] = Column::build_query($name, $column);
}
// Is primary key is specified.
if( !empty($primary_key) ){
$column_query[] = sprintf('PRIMARY KEY (%s)', implode(', ', $primary_key));
}
// Is index exists?
if( !empty($indexes) ){
foreach( $indexes as $name => $index ){
$keys = (array)$index;
$column_query[] = sprintf('KEY %s (%s)', $name, implode(', ', $index));
}
}
// Is unique?
if( !empty($unique) ){
foreach ( $unique as $name => $index ) {
$keys = (array)$index;
$column_query[] = sprintf('UNIQUE (%s)', implode(', ', $index));
}
}
// has full text index?
if( !empty($fulltext) ){
foreach( $fulltext as $name => $index ){
$keys = (array) $index;
$column_query[] = sprintf('FULLTEXT %s (%s)', $name, implode(', ', $index));
}
}
if( !isset($charset) ){
$charset = 'utf8';
}
// Normalize charset
$sql = <<<SQL
CREATE TABLE %s (
%s
) ENGINE = %s CHARACTER SET %s
SQL;
$sql = sprintf($sql, $config['name'], implode(','.PHP_EOL.' ', $column_query), $engine, $charset);
return $sql;
}
|
php
|
private function make_query($config){
/** @var $name string */
/** @var $version string */
/** @var $engine string */
/** @var $columns array */
/** @var $primary_key array */
/** @var $indexes array */
/** @var $unique array */
/** @var $fulltext array */
/** @var $charset string */
extract($config);
if( empty($columns) ){
throw new \Exception(sprintf('Columns of %s shouldn\'t be empty.', $name), 500);
}
$column_query = [];
foreach( $columns as $name => $column ){
$column_query[] = Column::build_query($name, $column);
}
// Is primary key is specified.
if( !empty($primary_key) ){
$column_query[] = sprintf('PRIMARY KEY (%s)', implode(', ', $primary_key));
}
// Is index exists?
if( !empty($indexes) ){
foreach( $indexes as $name => $index ){
$keys = (array)$index;
$column_query[] = sprintf('KEY %s (%s)', $name, implode(', ', $index));
}
}
// Is unique?
if( !empty($unique) ){
foreach ( $unique as $name => $index ) {
$keys = (array)$index;
$column_query[] = sprintf('UNIQUE (%s)', implode(', ', $index));
}
}
// has full text index?
if( !empty($fulltext) ){
foreach( $fulltext as $name => $index ){
$keys = (array) $index;
$column_query[] = sprintf('FULLTEXT %s (%s)', $name, implode(', ', $index));
}
}
if( !isset($charset) ){
$charset = 'utf8';
}
// Normalize charset
$sql = <<<SQL
CREATE TABLE %s (
%s
) ENGINE = %s CHARACTER SET %s
SQL;
$sql = sprintf($sql, $config['name'], implode(','.PHP_EOL.' ', $column_query), $engine, $charset);
return $sql;
}
|
[
"private",
"function",
"make_query",
"(",
"$",
"config",
")",
"{",
"/** @var $name string */",
"/** @var $version string */",
"/** @var $engine string */",
"/** @var $columns array */",
"/** @var $primary_key array */",
"/** @var $indexes array */",
"/** @var $unique array */",
"/** @var $fulltext array */",
"/** @var $charset string */",
"extract",
"(",
"$",
"config",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"columns",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"sprintf",
"(",
"'Columns of %s shouldn\\'t be empty.'",
",",
"$",
"name",
")",
",",
"500",
")",
";",
"}",
"$",
"column_query",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"columns",
"as",
"$",
"name",
"=>",
"$",
"column",
")",
"{",
"$",
"column_query",
"[",
"]",
"=",
"Column",
"::",
"build_query",
"(",
"$",
"name",
",",
"$",
"column",
")",
";",
"}",
"// Is primary key is specified.",
"if",
"(",
"!",
"empty",
"(",
"$",
"primary_key",
")",
")",
"{",
"$",
"column_query",
"[",
"]",
"=",
"sprintf",
"(",
"'PRIMARY KEY (%s)'",
",",
"implode",
"(",
"', '",
",",
"$",
"primary_key",
")",
")",
";",
"}",
"// Is index exists?",
"if",
"(",
"!",
"empty",
"(",
"$",
"indexes",
")",
")",
"{",
"foreach",
"(",
"$",
"indexes",
"as",
"$",
"name",
"=>",
"$",
"index",
")",
"{",
"$",
"keys",
"=",
"(",
"array",
")",
"$",
"index",
";",
"$",
"column_query",
"[",
"]",
"=",
"sprintf",
"(",
"'KEY %s (%s)'",
",",
"$",
"name",
",",
"implode",
"(",
"', '",
",",
"$",
"index",
")",
")",
";",
"}",
"}",
"// Is unique?",
"if",
"(",
"!",
"empty",
"(",
"$",
"unique",
")",
")",
"{",
"foreach",
"(",
"$",
"unique",
"as",
"$",
"name",
"=>",
"$",
"index",
")",
"{",
"$",
"keys",
"=",
"(",
"array",
")",
"$",
"index",
";",
"$",
"column_query",
"[",
"]",
"=",
"sprintf",
"(",
"'UNIQUE (%s)'",
",",
"implode",
"(",
"', '",
",",
"$",
"index",
")",
")",
";",
"}",
"}",
"// has full text index?",
"if",
"(",
"!",
"empty",
"(",
"$",
"fulltext",
")",
")",
"{",
"foreach",
"(",
"$",
"fulltext",
"as",
"$",
"name",
"=>",
"$",
"index",
")",
"{",
"$",
"keys",
"=",
"(",
"array",
")",
"$",
"index",
";",
"$",
"column_query",
"[",
"]",
"=",
"sprintf",
"(",
"'FULLTEXT %s (%s)'",
",",
"$",
"name",
",",
"implode",
"(",
"', '",
",",
"$",
"index",
")",
")",
";",
"}",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"charset",
")",
")",
"{",
"$",
"charset",
"=",
"'utf8'",
";",
"}",
"// Normalize charset",
"$",
"sql",
"=",
" <<<SQL\nCREATE TABLE %s (\n %s\n) ENGINE = %s CHARACTER SET %s\nSQL",
";",
"$",
"sql",
"=",
"sprintf",
"(",
"$",
"sql",
",",
"$",
"config",
"[",
"'name'",
"]",
",",
"implode",
"(",
"','",
".",
"PHP_EOL",
".",
"' '",
",",
"$",
"column_query",
")",
",",
"$",
"engine",
",",
"$",
"charset",
")",
";",
"return",
"$",
"sql",
";",
"}"
] |
Build create query
@param array $config
@return string
@throws \Exception
|
[
"Build",
"create",
"query"
] |
0939373800815a8396291143d2a57967340da5aa
|
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/DB/TableBuilder.php#L151-L205
|
20,366 |
hametuha/wpametu
|
src/WPametu/DB/TableBuilder.php
|
TableBuilder.need_update
|
protected function need_update($name, $version){
return !isset($this->option[$name]) || !$this->option[$name] || version_compare($this->option[$name], $version, '<');
}
|
php
|
protected function need_update($name, $version){
return !isset($this->option[$name]) || !$this->option[$name] || version_compare($this->option[$name], $version, '<');
}
|
[
"protected",
"function",
"need_update",
"(",
"$",
"name",
",",
"$",
"version",
")",
"{",
"return",
"!",
"isset",
"(",
"$",
"this",
"->",
"option",
"[",
"$",
"name",
"]",
")",
"||",
"!",
"$",
"this",
"->",
"option",
"[",
"$",
"name",
"]",
"||",
"version_compare",
"(",
"$",
"this",
"->",
"option",
"[",
"$",
"name",
"]",
",",
"$",
"version",
",",
"'<'",
")",
";",
"}"
] |
Detect if source version is greater than existing db
@param string $name
@param string $version
@return bool
|
[
"Detect",
"if",
"source",
"version",
"is",
"greater",
"than",
"existing",
"db"
] |
0939373800815a8396291143d2a57967340da5aa
|
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/DB/TableBuilder.php#L229-L231
|
20,367 |
Erdiko/core
|
src/Controller.php
|
Controller.setTheme
|
public function setTheme($name)
{
$this->getResponse()->setThemeName($name);
$this->getResponse()->getTheme()->setName($name);
}
|
php
|
public function setTheme($name)
{
$this->getResponse()->setThemeName($name);
$this->getResponse()->getTheme()->setName($name);
}
|
[
"public",
"function",
"setTheme",
"(",
"$",
"name",
")",
"{",
"$",
"this",
"->",
"getResponse",
"(",
")",
"->",
"setThemeName",
"(",
"$",
"name",
")",
";",
"$",
"this",
"->",
"getResponse",
"(",
")",
"->",
"getTheme",
"(",
")",
"->",
"setName",
"(",
"$",
"name",
")",
";",
"}"
] |
Set the theme name in both the response and the theme objects
@param string $name, the name/id of the theme
|
[
"Set",
"the",
"theme",
"name",
"in",
"both",
"the",
"response",
"and",
"the",
"theme",
"objects"
] |
c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6
|
https://github.com/Erdiko/core/blob/c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6/src/Controller.php#L158-L162
|
20,368 |
Erdiko/core
|
src/Controller.php
|
Controller.setBodyTitle
|
public function setBodyTitle($title)
{
$this->getResponse()->getTheme()->setBodyTitle($title);
$this->_title = $title;
}
|
php
|
public function setBodyTitle($title)
{
$this->getResponse()->getTheme()->setBodyTitle($title);
$this->_title = $title;
}
|
[
"public",
"function",
"setBodyTitle",
"(",
"$",
"title",
")",
"{",
"$",
"this",
"->",
"getResponse",
"(",
")",
"->",
"getTheme",
"(",
")",
"->",
"setBodyTitle",
"(",
"$",
"title",
")",
";",
"$",
"this",
"->",
"_title",
"=",
"$",
"title",
";",
"}"
] |
Set page content title to be themed in the view
@param string $title
|
[
"Set",
"page",
"content",
"title",
"to",
"be",
"themed",
"in",
"the",
"view"
] |
c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6
|
https://github.com/Erdiko/core/blob/c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6/src/Controller.php#L238-L242
|
20,369 |
Erdiko/core
|
src/Controller.php
|
Controller.addView
|
public function addView($view, $data = null)
{
if(!is_object($view))
$view = new \erdiko\core\View($view, $data);
if($data != null)
$view->setData($data);
$this->appendContent($view->toHtml());
}
|
php
|
public function addView($view, $data = null)
{
if(!is_object($view))
$view = new \erdiko\core\View($view, $data);
if($data != null)
$view->setData($data);
$this->appendContent($view->toHtml());
}
|
[
"public",
"function",
"addView",
"(",
"$",
"view",
",",
"$",
"data",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_object",
"(",
"$",
"view",
")",
")",
"$",
"view",
"=",
"new",
"\\",
"erdiko",
"\\",
"core",
"\\",
"View",
"(",
"$",
"view",
",",
"$",
"data",
")",
";",
"if",
"(",
"$",
"data",
"!=",
"null",
")",
"$",
"view",
"->",
"setData",
"(",
"$",
"data",
")",
";",
"$",
"this",
"->",
"appendContent",
"(",
"$",
"view",
"->",
"toHtml",
"(",
")",
")",
";",
"}"
] |
Add a view from the current theme with the given data
@param mixed $view, can be a string (view name) or object (view object)
@param array $data
@return string $html, view contents
|
[
"Add",
"a",
"view",
"from",
"the",
"current",
"theme",
"with",
"the",
"given",
"data"
] |
c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6
|
https://github.com/Erdiko/core/blob/c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6/src/Controller.php#L357-L365
|
20,370 |
Erdiko/core
|
src/Controller.php
|
Controller.getLayout
|
public function getLayout($layoutName, $data = null, $templateRootFolder = null)
{
$layout = new \erdiko\core\Layout($layoutName, $data, $this->getThemeName());
$layout->setTitle($this->getBodyTitle());
if ($templateRootFolder != null) {
$layout->setViewRootFolder($templateRootFolder);
$layout->setTemplateRootFolder($templateRootFolder);
}
return $layout->toHtml();
}
|
php
|
public function getLayout($layoutName, $data = null, $templateRootFolder = null)
{
$layout = new \erdiko\core\Layout($layoutName, $data, $this->getThemeName());
$layout->setTitle($this->getBodyTitle());
if ($templateRootFolder != null) {
$layout->setViewRootFolder($templateRootFolder);
$layout->setTemplateRootFolder($templateRootFolder);
}
return $layout->toHtml();
}
|
[
"public",
"function",
"getLayout",
"(",
"$",
"layoutName",
",",
"$",
"data",
"=",
"null",
",",
"$",
"templateRootFolder",
"=",
"null",
")",
"{",
"$",
"layout",
"=",
"new",
"\\",
"erdiko",
"\\",
"core",
"\\",
"Layout",
"(",
"$",
"layoutName",
",",
"$",
"data",
",",
"$",
"this",
"->",
"getThemeName",
"(",
")",
")",
";",
"$",
"layout",
"->",
"setTitle",
"(",
"$",
"this",
"->",
"getBodyTitle",
"(",
")",
")",
";",
"if",
"(",
"$",
"templateRootFolder",
"!=",
"null",
")",
"{",
"$",
"layout",
"->",
"setViewRootFolder",
"(",
"$",
"templateRootFolder",
")",
";",
"$",
"layout",
"->",
"setTemplateRootFolder",
"(",
"$",
"templateRootFolder",
")",
";",
"}",
"return",
"$",
"layout",
"->",
"toHtml",
"(",
")",
";",
"}"
] |
Load a layout with the given data
@param string $layoutName
@param array $data
@return string $html, layout contents
|
[
"Load",
"a",
"layout",
"with",
"the",
"given",
"data"
] |
c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6
|
https://github.com/Erdiko/core/blob/c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6/src/Controller.php#L374-L385
|
20,371 |
Erdiko/core
|
src/Controller.php
|
Controller.setMeta
|
public function setMeta($meta)
{
foreach($meta as $name => $content)
$this->getResponse()->getTheme()->addMeta($name, $content);
}
|
php
|
public function setMeta($meta)
{
foreach($meta as $name => $content)
$this->getResponse()->getTheme()->addMeta($name, $content);
}
|
[
"public",
"function",
"setMeta",
"(",
"$",
"meta",
")",
"{",
"foreach",
"(",
"$",
"meta",
"as",
"$",
"name",
"=>",
"$",
"content",
")",
"$",
"this",
"->",
"getResponse",
"(",
")",
"->",
"getTheme",
"(",
")",
"->",
"addMeta",
"(",
"$",
"name",
",",
"$",
"content",
")",
";",
"}"
] |
Set multiple meta fields at once
@param array $meta
|
[
"Set",
"multiple",
"meta",
"fields",
"at",
"once"
] |
c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6
|
https://github.com/Erdiko/core/blob/c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6/src/Controller.php#L412-L416
|
20,372 |
Erdiko/core
|
src/Controller.php
|
Controller.addPhpToJs
|
public function addPhpToJs($key, $value)
{
if (is_bool($value)) {
$value = $value ? "true" : "false";
} elseif (is_string($value)) {
$value = "\"$value\"";
} elseif (is_array($value)) {
$value = json_encode($value);
} elseif (is_object($value) && method_exists($value, "toArray")) {
$value = json_encode($value->toArray());
} else {
throw new \Exception("Can not translate a parameter from PHP to JS\n".print_r($value, true));
}
$this->_themeExtras['phpToJs'][$key] = $value;
}
|
php
|
public function addPhpToJs($key, $value)
{
if (is_bool($value)) {
$value = $value ? "true" : "false";
} elseif (is_string($value)) {
$value = "\"$value\"";
} elseif (is_array($value)) {
$value = json_encode($value);
} elseif (is_object($value) && method_exists($value, "toArray")) {
$value = json_encode($value->toArray());
} else {
throw new \Exception("Can not translate a parameter from PHP to JS\n".print_r($value, true));
}
$this->_themeExtras['phpToJs'][$key] = $value;
}
|
[
"public",
"function",
"addPhpToJs",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"if",
"(",
"is_bool",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"$",
"value",
"?",
"\"true\"",
":",
"\"false\"",
";",
"}",
"elseif",
"(",
"is_string",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"\"\\\"$value\\\"\"",
";",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"json_encode",
"(",
"$",
"value",
")",
";",
"}",
"elseif",
"(",
"is_object",
"(",
"$",
"value",
")",
"&&",
"method_exists",
"(",
"$",
"value",
",",
"\"toArray\"",
")",
")",
"{",
"$",
"value",
"=",
"json_encode",
"(",
"$",
"value",
"->",
"toArray",
"(",
")",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Can not translate a parameter from PHP to JS\\n\"",
".",
"print_r",
"(",
"$",
"value",
",",
"true",
")",
")",
";",
"}",
"$",
"this",
"->",
"_themeExtras",
"[",
"'phpToJs'",
"]",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}"
] |
Add phpToJs variable to be set on the current page
@param mixed $key
@param mixed $value
|
[
"Add",
"phpToJs",
"variable",
"to",
"be",
"set",
"on",
"the",
"current",
"page"
] |
c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6
|
https://github.com/Erdiko/core/blob/c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6/src/Controller.php#L485-L500
|
20,373 |
gpupo/common-schema
|
src/ORM/Entity/Trading/Order/Shipping/Seller.php
|
Seller.setShipping
|
public function setShipping(\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Shipping\Shipping $shipping = null)
{
$this->shipping = $shipping;
return $this;
}
|
php
|
public function setShipping(\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Shipping\Shipping $shipping = null)
{
$this->shipping = $shipping;
return $this;
}
|
[
"public",
"function",
"setShipping",
"(",
"\\",
"Gpupo",
"\\",
"CommonSchema",
"\\",
"ORM",
"\\",
"Entity",
"\\",
"Trading",
"\\",
"Order",
"\\",
"Shipping",
"\\",
"Shipping",
"$",
"shipping",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"shipping",
"=",
"$",
"shipping",
";",
"return",
"$",
"this",
";",
"}"
] |
Set shipping.
@param null|\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Shipping\Shipping $shipping
@return Seller
|
[
"Set",
"shipping",
"."
] |
a762d2eb3063b7317c72c69cbb463b1f95b86b0a
|
https://github.com/gpupo/common-schema/blob/a762d2eb3063b7317c72c69cbb463b1f95b86b0a/src/ORM/Entity/Trading/Order/Shipping/Seller.php#L345-L350
|
20,374 |
nabab/bbn
|
src/bbn/user/manager.php
|
manager.groups
|
public function groups(){
$a =& $this->class_cfg['arch'];
$t =& $this->class_cfg['tables'];
$id = $this->db->cfn($a['groups']['id'], $t['groups'], 1);
$group = $this->db->cfn($a['groups']['group'], $t['groups'], 1);
$id_group = $this->db->cfn($a['users']['id_group'], $t['users'], 1);
$active = $this->db->cfn($a['users']['active'], $t['users'], 1);
$users_id = $this->db->cfn($a['users']['id'], $t['users'], 1);
$groups = $this->db->escape($t['groups']);
$users = $this->db->escape($t['users']);
return $this->db->get_rows("
SELECT $id, $group,
COUNT($users_id) AS `num`
FROM $groups
LEFT JOIN $users
ON $id_group = $id
GROUP BY $id");
}
|
php
|
public function groups(){
$a =& $this->class_cfg['arch'];
$t =& $this->class_cfg['tables'];
$id = $this->db->cfn($a['groups']['id'], $t['groups'], 1);
$group = $this->db->cfn($a['groups']['group'], $t['groups'], 1);
$id_group = $this->db->cfn($a['users']['id_group'], $t['users'], 1);
$active = $this->db->cfn($a['users']['active'], $t['users'], 1);
$users_id = $this->db->cfn($a['users']['id'], $t['users'], 1);
$groups = $this->db->escape($t['groups']);
$users = $this->db->escape($t['users']);
return $this->db->get_rows("
SELECT $id, $group,
COUNT($users_id) AS `num`
FROM $groups
LEFT JOIN $users
ON $id_group = $id
GROUP BY $id");
}
|
[
"public",
"function",
"groups",
"(",
")",
"{",
"$",
"a",
"=",
"&",
"$",
"this",
"->",
"class_cfg",
"[",
"'arch'",
"]",
";",
"$",
"t",
"=",
"&",
"$",
"this",
"->",
"class_cfg",
"[",
"'tables'",
"]",
";",
"$",
"id",
"=",
"$",
"this",
"->",
"db",
"->",
"cfn",
"(",
"$",
"a",
"[",
"'groups'",
"]",
"[",
"'id'",
"]",
",",
"$",
"t",
"[",
"'groups'",
"]",
",",
"1",
")",
";",
"$",
"group",
"=",
"$",
"this",
"->",
"db",
"->",
"cfn",
"(",
"$",
"a",
"[",
"'groups'",
"]",
"[",
"'group'",
"]",
",",
"$",
"t",
"[",
"'groups'",
"]",
",",
"1",
")",
";",
"$",
"id_group",
"=",
"$",
"this",
"->",
"db",
"->",
"cfn",
"(",
"$",
"a",
"[",
"'users'",
"]",
"[",
"'id_group'",
"]",
",",
"$",
"t",
"[",
"'users'",
"]",
",",
"1",
")",
";",
"$",
"active",
"=",
"$",
"this",
"->",
"db",
"->",
"cfn",
"(",
"$",
"a",
"[",
"'users'",
"]",
"[",
"'active'",
"]",
",",
"$",
"t",
"[",
"'users'",
"]",
",",
"1",
")",
";",
"$",
"users_id",
"=",
"$",
"this",
"->",
"db",
"->",
"cfn",
"(",
"$",
"a",
"[",
"'users'",
"]",
"[",
"'id'",
"]",
",",
"$",
"t",
"[",
"'users'",
"]",
",",
"1",
")",
";",
"$",
"groups",
"=",
"$",
"this",
"->",
"db",
"->",
"escape",
"(",
"$",
"t",
"[",
"'groups'",
"]",
")",
";",
"$",
"users",
"=",
"$",
"this",
"->",
"db",
"->",
"escape",
"(",
"$",
"t",
"[",
"'users'",
"]",
")",
";",
"return",
"$",
"this",
"->",
"db",
"->",
"get_rows",
"(",
"\"\n SELECT $id, $group,\n COUNT($users_id) AS `num`\n FROM $groups\n LEFT JOIN $users\n ON $id_group = $id\n GROUP BY $id\"",
")",
";",
"}"
] |
Returns all the users' groups - with or without admin
@param bool $adm
@return array|false
|
[
"Returns",
"all",
"the",
"users",
"groups",
"-",
"with",
"or",
"without",
"admin"
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user/manager.php#L124-L141
|
20,375 |
m4grio/bangkok-insurance-php
|
src/Client.php
|
Client.call
|
public function call($method, Array $params = [])
{
$params = $this->mergeParams($method, $params);
try {
$result = $this->soapClient->__soapCall($method, $params);
} catch (SoapFault $fault) {
// @todo log
throw $fault;
}
return $result;
}
|
php
|
public function call($method, Array $params = [])
{
$params = $this->mergeParams($method, $params);
try {
$result = $this->soapClient->__soapCall($method, $params);
} catch (SoapFault $fault) {
// @todo log
throw $fault;
}
return $result;
}
|
[
"public",
"function",
"call",
"(",
"$",
"method",
",",
"Array",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"$",
"params",
"=",
"$",
"this",
"->",
"mergeParams",
"(",
"$",
"method",
",",
"$",
"params",
")",
";",
"try",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"soapClient",
"->",
"__soapCall",
"(",
"$",
"method",
",",
"$",
"params",
")",
";",
"}",
"catch",
"(",
"SoapFault",
"$",
"fault",
")",
"{",
"// @todo log",
"throw",
"$",
"fault",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Prepare and issue a call
@param $method
@param array $params
@return AbstractResult
@throws SoapFault
@throws \Exception
|
[
"Prepare",
"and",
"issue",
"a",
"call"
] |
400266d043abe6b7cacb9da36064cbb169149c2a
|
https://github.com/m4grio/bangkok-insurance-php/blob/400266d043abe6b7cacb9da36064cbb169149c2a/src/Client.php#L54-L65
|
20,376 |
m4grio/bangkok-insurance-php
|
src/Client.php
|
Client.mergeParams
|
protected function mergeParams($method, Array $params = [])
{
$mergedParams = array_merge($this->defaultParams, $params);
$newParams = [$method => $mergedParams];
return $newParams;
}
|
php
|
protected function mergeParams($method, Array $params = [])
{
$mergedParams = array_merge($this->defaultParams, $params);
$newParams = [$method => $mergedParams];
return $newParams;
}
|
[
"protected",
"function",
"mergeParams",
"(",
"$",
"method",
",",
"Array",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"$",
"mergedParams",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"defaultParams",
",",
"$",
"params",
")",
";",
"$",
"newParams",
"=",
"[",
"$",
"method",
"=>",
"$",
"mergedParams",
"]",
";",
"return",
"$",
"newParams",
";",
"}"
] |
Default way to merge params
@param $method
@param array $params
@return array
|
[
"Default",
"way",
"to",
"merge",
"params"
] |
400266d043abe6b7cacb9da36064cbb169149c2a
|
https://github.com/m4grio/bangkok-insurance-php/blob/400266d043abe6b7cacb9da36064cbb169149c2a/src/Client.php#L75-L81
|
20,377 |
rhosocial/yii2-user
|
models/log/Login.php
|
Login.deleteExtraRecords
|
protected function deleteExtraRecords()
{
try {
$limit = (int)($this->limitMax);
} catch (\Exception $ex) {
Yii::error($ex->getMessage(), __METHOD__);
return 0;
}
$host = $this->host;
/* @var $host \rhosocial\user\User */
$count = static::find()->createdBy($host)->count();
Yii::info($host->getReadableGUID() . " has $count login logs.", __METHOD__);
if ($count > $limit) {
foreach (static::find()->createdBy($host)->orderByCreatedAt()->limit($count - $limit)->all() as $login) {
/* @var $login static */
$result = $login->delete();
if (YII_ENV_DEV) {
Yii::info($host->getReadableGUID() . ": ($result) login record created at (" . $login->getCreatedAt() . ") was just deleted.", __METHOD__);
}
}
}
return $count - $limit;
}
|
php
|
protected function deleteExtraRecords()
{
try {
$limit = (int)($this->limitMax);
} catch (\Exception $ex) {
Yii::error($ex->getMessage(), __METHOD__);
return 0;
}
$host = $this->host;
/* @var $host \rhosocial\user\User */
$count = static::find()->createdBy($host)->count();
Yii::info($host->getReadableGUID() . " has $count login logs.", __METHOD__);
if ($count > $limit) {
foreach (static::find()->createdBy($host)->orderByCreatedAt()->limit($count - $limit)->all() as $login) {
/* @var $login static */
$result = $login->delete();
if (YII_ENV_DEV) {
Yii::info($host->getReadableGUID() . ": ($result) login record created at (" . $login->getCreatedAt() . ") was just deleted.", __METHOD__);
}
}
}
return $count - $limit;
}
|
[
"protected",
"function",
"deleteExtraRecords",
"(",
")",
"{",
"try",
"{",
"$",
"limit",
"=",
"(",
"int",
")",
"(",
"$",
"this",
"->",
"limitMax",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"ex",
")",
"{",
"Yii",
"::",
"error",
"(",
"$",
"ex",
"->",
"getMessage",
"(",
")",
",",
"__METHOD__",
")",
";",
"return",
"0",
";",
"}",
"$",
"host",
"=",
"$",
"this",
"->",
"host",
";",
"/* @var $host \\rhosocial\\user\\User */",
"$",
"count",
"=",
"static",
"::",
"find",
"(",
")",
"->",
"createdBy",
"(",
"$",
"host",
")",
"->",
"count",
"(",
")",
";",
"Yii",
"::",
"info",
"(",
"$",
"host",
"->",
"getReadableGUID",
"(",
")",
".",
"\" has $count login logs.\"",
",",
"__METHOD__",
")",
";",
"if",
"(",
"$",
"count",
">",
"$",
"limit",
")",
"{",
"foreach",
"(",
"static",
"::",
"find",
"(",
")",
"->",
"createdBy",
"(",
"$",
"host",
")",
"->",
"orderByCreatedAt",
"(",
")",
"->",
"limit",
"(",
"$",
"count",
"-",
"$",
"limit",
")",
"->",
"all",
"(",
")",
"as",
"$",
"login",
")",
"{",
"/* @var $login static */",
"$",
"result",
"=",
"$",
"login",
"->",
"delete",
"(",
")",
";",
"if",
"(",
"YII_ENV_DEV",
")",
"{",
"Yii",
"::",
"info",
"(",
"$",
"host",
"->",
"getReadableGUID",
"(",
")",
".",
"\": ($result) login record created at (\"",
".",
"$",
"login",
"->",
"getCreatedAt",
"(",
")",
".",
"\") was just deleted.\"",
",",
"__METHOD__",
")",
";",
"}",
"}",
"}",
"return",
"$",
"count",
"-",
"$",
"limit",
";",
"}"
] |
Delete extra records.
@return integer The total of rows deleted.
|
[
"Delete",
"extra",
"records",
"."
] |
96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc
|
https://github.com/rhosocial/yii2-user/blob/96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc/models/log/Login.php#L102-L124
|
20,378 |
rhosocial/yii2-user
|
models/log/Login.php
|
Login.deleteExpiredRecords
|
protected function deleteExpiredRecords()
{
try {
$limit = (int)($this->limitDuration);
} catch (\Exception $ex) {
Yii::error($ex->getMessage(), __METHOD__);
return 0;
}
$count = 0;
$host = $this->host;
/* @var $host \rhosocial\user\User */
foreach (static::find()
->createdBy($host)
->andWhere(['<=', $this->createdAtAttribute, $this->offsetDatetime($this->currentUtcDatetime(), -$limit)])
->all() as $login) {
/* @var $login static */
$result = $login->delete();
$count += $result;
if (YII_ENV_DEV) {
Yii::info($host->getReadableGUID() . ": ($result) login record created at (" . $login->getCreatedAt() . ") was just deleted.", __METHOD__);
}
}
return $count;
}
|
php
|
protected function deleteExpiredRecords()
{
try {
$limit = (int)($this->limitDuration);
} catch (\Exception $ex) {
Yii::error($ex->getMessage(), __METHOD__);
return 0;
}
$count = 0;
$host = $this->host;
/* @var $host \rhosocial\user\User */
foreach (static::find()
->createdBy($host)
->andWhere(['<=', $this->createdAtAttribute, $this->offsetDatetime($this->currentUtcDatetime(), -$limit)])
->all() as $login) {
/* @var $login static */
$result = $login->delete();
$count += $result;
if (YII_ENV_DEV) {
Yii::info($host->getReadableGUID() . ": ($result) login record created at (" . $login->getCreatedAt() . ") was just deleted.", __METHOD__);
}
}
return $count;
}
|
[
"protected",
"function",
"deleteExpiredRecords",
"(",
")",
"{",
"try",
"{",
"$",
"limit",
"=",
"(",
"int",
")",
"(",
"$",
"this",
"->",
"limitDuration",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"ex",
")",
"{",
"Yii",
"::",
"error",
"(",
"$",
"ex",
"->",
"getMessage",
"(",
")",
",",
"__METHOD__",
")",
";",
"return",
"0",
";",
"}",
"$",
"count",
"=",
"0",
";",
"$",
"host",
"=",
"$",
"this",
"->",
"host",
";",
"/* @var $host \\rhosocial\\user\\User */",
"foreach",
"(",
"static",
"::",
"find",
"(",
")",
"->",
"createdBy",
"(",
"$",
"host",
")",
"->",
"andWhere",
"(",
"[",
"'<='",
",",
"$",
"this",
"->",
"createdAtAttribute",
",",
"$",
"this",
"->",
"offsetDatetime",
"(",
"$",
"this",
"->",
"currentUtcDatetime",
"(",
")",
",",
"-",
"$",
"limit",
")",
"]",
")",
"->",
"all",
"(",
")",
"as",
"$",
"login",
")",
"{",
"/* @var $login static */",
"$",
"result",
"=",
"$",
"login",
"->",
"delete",
"(",
")",
";",
"$",
"count",
"+=",
"$",
"result",
";",
"if",
"(",
"YII_ENV_DEV",
")",
"{",
"Yii",
"::",
"info",
"(",
"$",
"host",
"->",
"getReadableGUID",
"(",
")",
".",
"\": ($result) login record created at (\"",
".",
"$",
"login",
"->",
"getCreatedAt",
"(",
")",
".",
"\") was just deleted.\"",
",",
"__METHOD__",
")",
";",
"}",
"}",
"return",
"$",
"count",
";",
"}"
] |
Delete expired records.
@return integer The total of rows deleted.
|
[
"Delete",
"expired",
"records",
"."
] |
96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc
|
https://github.com/rhosocial/yii2-user/blob/96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc/models/log/Login.php#L130-L153
|
20,379 |
nabab/bbn
|
src/bbn/mvc/model.php
|
model.has_data
|
public function has_data($idx=null)
{
if ( !\is_array($this->data) ){
return false;
}
if ( \is_null($idx) ){
return !empty($this->data);
}
$args = \func_get_args();
foreach ( $args as $arg ){
if ( !isset($this->data[$idx]) ){
return false;
}
}
return true;
}
|
php
|
public function has_data($idx=null)
{
if ( !\is_array($this->data) ){
return false;
}
if ( \is_null($idx) ){
return !empty($this->data);
}
$args = \func_get_args();
foreach ( $args as $arg ){
if ( !isset($this->data[$idx]) ){
return false;
}
}
return true;
}
|
[
"public",
"function",
"has_data",
"(",
"$",
"idx",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"\\",
"is_array",
"(",
"$",
"this",
"->",
"data",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"\\",
"is_null",
"(",
"$",
"idx",
")",
")",
"{",
"return",
"!",
"empty",
"(",
"$",
"this",
"->",
"data",
")",
";",
"}",
"$",
"args",
"=",
"\\",
"func_get_args",
"(",
")",
";",
"foreach",
"(",
"$",
"args",
"as",
"$",
"arg",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"data",
"[",
"$",
"idx",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] |
Checks if data exists or if a specific index exists in the data
@return bool
|
[
"Checks",
"if",
"data",
"exists",
"or",
"if",
"a",
"specific",
"index",
"exists",
"in",
"the",
"data"
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/mvc/model.php#L145-L160
|
20,380 |
JBZoo/Assets
|
src/Asset/File.php
|
File._findSource
|
protected function _findSource()
{
$path = $this->_manager->getPath();
if ($path->isVirtual($this->_source)) {
$path = $path->get($this->_source);
$isStrictMode = $this->_manager->getParams()->get('strict_mode', false, 'bool');
if ($isStrictMode && !$path) {
throw new Exception("Asset file not found: {$this->_source}");
}
return $path;
}
if (Url::isAbsolute($this->_source)) {
return $this->_source;
}
$fullPath = $path->get('root:' . $this->_source);
return $fullPath;
}
|
php
|
protected function _findSource()
{
$path = $this->_manager->getPath();
if ($path->isVirtual($this->_source)) {
$path = $path->get($this->_source);
$isStrictMode = $this->_manager->getParams()->get('strict_mode', false, 'bool');
if ($isStrictMode && !$path) {
throw new Exception("Asset file not found: {$this->_source}");
}
return $path;
}
if (Url::isAbsolute($this->_source)) {
return $this->_source;
}
$fullPath = $path->get('root:' . $this->_source);
return $fullPath;
}
|
[
"protected",
"function",
"_findSource",
"(",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"_manager",
"->",
"getPath",
"(",
")",
";",
"if",
"(",
"$",
"path",
"->",
"isVirtual",
"(",
"$",
"this",
"->",
"_source",
")",
")",
"{",
"$",
"path",
"=",
"$",
"path",
"->",
"get",
"(",
"$",
"this",
"->",
"_source",
")",
";",
"$",
"isStrictMode",
"=",
"$",
"this",
"->",
"_manager",
"->",
"getParams",
"(",
")",
"->",
"get",
"(",
"'strict_mode'",
",",
"false",
",",
"'bool'",
")",
";",
"if",
"(",
"$",
"isStrictMode",
"&&",
"!",
"$",
"path",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Asset file not found: {$this->_source}\"",
")",
";",
"}",
"return",
"$",
"path",
";",
"}",
"if",
"(",
"Url",
"::",
"isAbsolute",
"(",
"$",
"this",
"->",
"_source",
")",
")",
"{",
"return",
"$",
"this",
"->",
"_source",
";",
"}",
"$",
"fullPath",
"=",
"$",
"path",
"->",
"get",
"(",
"'root:'",
".",
"$",
"this",
"->",
"_source",
")",
";",
"return",
"$",
"fullPath",
";",
"}"
] |
Find source in variants.
@return string|array
@throws Exception
|
[
"Find",
"source",
"in",
"variants",
"."
] |
134a109378f5b5e955dfb15e6ed2821581564991
|
https://github.com/JBZoo/Assets/blob/134a109378f5b5e955dfb15e6ed2821581564991/src/Asset/File.php#L46-L68
|
20,381 |
SporkCode/Spork
|
src/View/Helper/Date.php
|
Date.createService
|
public function createService(ServiceLocatorInterface $serviceLocator)
{
$appConfig = $serviceLocator;
$config = array_key_exists($appConfig['view_helper_date']) ? $appConfig['view_helper_date'] : array();
if (array_key_exists('formats', $config)) {
$this->addFormats($config['formats']);
}
}
|
php
|
public function createService(ServiceLocatorInterface $serviceLocator)
{
$appConfig = $serviceLocator;
$config = array_key_exists($appConfig['view_helper_date']) ? $appConfig['view_helper_date'] : array();
if (array_key_exists('formats', $config)) {
$this->addFormats($config['formats']);
}
}
|
[
"public",
"function",
"createService",
"(",
"ServiceLocatorInterface",
"$",
"serviceLocator",
")",
"{",
"$",
"appConfig",
"=",
"$",
"serviceLocator",
";",
"$",
"config",
"=",
"array_key_exists",
"(",
"$",
"appConfig",
"[",
"'view_helper_date'",
"]",
")",
"?",
"$",
"appConfig",
"[",
"'view_helper_date'",
"]",
":",
"array",
"(",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"'formats'",
",",
"$",
"config",
")",
")",
"{",
"$",
"this",
"->",
"addFormats",
"(",
"$",
"config",
"[",
"'formats'",
"]",
")",
";",
"}",
"}"
] |
Create and configure instance
@see \Zend\ServiceManager\FactoryInterface::createService()
@param ServiceLocatorInterface $serviceLocator
|
[
"Create",
"and",
"configure",
"instance"
] |
7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a
|
https://github.com/SporkCode/Spork/blob/7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a/src/View/Helper/Date.php#L57-L64
|
20,382 |
SporkCode/Spork
|
src/View/Helper/Date.php
|
Date.addFormats
|
public function addFormats(array $formats)
{
foreach ($formats as $name => $format) {
$this->formats[$name] = $format;
}
}
|
php
|
public function addFormats(array $formats)
{
foreach ($formats as $name => $format) {
$this->formats[$name] = $format;
}
}
|
[
"public",
"function",
"addFormats",
"(",
"array",
"$",
"formats",
")",
"{",
"foreach",
"(",
"$",
"formats",
"as",
"$",
"name",
"=>",
"$",
"format",
")",
"{",
"$",
"this",
"->",
"formats",
"[",
"$",
"name",
"]",
"=",
"$",
"format",
";",
"}",
"}"
] |
Add datetime formats
@param array $formats
|
[
"Add",
"datetime",
"formats"
] |
7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a
|
https://github.com/SporkCode/Spork/blob/7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a/src/View/Helper/Date.php#L101-L106
|
20,383 |
antaresproject/notifications
|
src/Http/Filter/NotificationAreaFilter.php
|
NotificationAreaFilter.options
|
protected function options()
{
$areas = app(AreaManager::class)->getAreas();
$options = [];
foreach ($areas as $area) {
array_set($options, $area->getId(), $area->getLabel());
}
return $options;
}
|
php
|
protected function options()
{
$areas = app(AreaManager::class)->getAreas();
$options = [];
foreach ($areas as $area) {
array_set($options, $area->getId(), $area->getLabel());
}
return $options;
}
|
[
"protected",
"function",
"options",
"(",
")",
"{",
"$",
"areas",
"=",
"app",
"(",
"AreaManager",
"::",
"class",
")",
"->",
"getAreas",
"(",
")",
";",
"$",
"options",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"areas",
"as",
"$",
"area",
")",
"{",
"array_set",
"(",
"$",
"options",
",",
"$",
"area",
"->",
"getId",
"(",
")",
",",
"$",
"area",
"->",
"getLabel",
"(",
")",
")",
";",
"}",
"return",
"$",
"options",
";",
"}"
] |
Filter instance dataprovider
@return Collection
|
[
"Filter",
"instance",
"dataprovider"
] |
60de743477b7e9cbb51de66da5fd9461adc9dd8a
|
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Http/Filter/NotificationAreaFilter.php#L61-L69
|
20,384 |
ekuiter/feature-php
|
FeaturePhp/Helper/_Array.php
|
_Array.findByKey
|
public static function findByKey($array, $key, $value) {
foreach ($array as $element)
if (call_user_func(array($element, $key)) === $value)
return $element;
return null;
}
|
php
|
public static function findByKey($array, $key, $value) {
foreach ($array as $element)
if (call_user_func(array($element, $key)) === $value)
return $element;
return null;
}
|
[
"public",
"static",
"function",
"findByKey",
"(",
"$",
"array",
",",
"$",
"key",
",",
"$",
"value",
")",
"{",
"foreach",
"(",
"$",
"array",
"as",
"$",
"element",
")",
"if",
"(",
"call_user_func",
"(",
"array",
"(",
"$",
"element",
",",
"$",
"key",
")",
")",
"===",
"$",
"value",
")",
"return",
"$",
"element",
";",
"return",
"null",
";",
"}"
] |
Finds an array element by comparing a member with the given value.
@param array $array
@param callable $key
@param mixed $value
@return object
|
[
"Finds",
"an",
"array",
"element",
"by",
"comparing",
"a",
"member",
"with",
"the",
"given",
"value",
"."
] |
daf4a59098802fedcfd1f1a1d07847fcf2fea7bf
|
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Helper/_Array.php#L26-L31
|
20,385 |
ekuiter/feature-php
|
FeaturePhp/Helper/_Array.php
|
_Array.sortByKey
|
public static function sortByKey($_array, $key) {
$array = $_array;
$result = usort($array, function($a, $b) use ($key) {
return strcmp(call_user_func(array($a, $key)),
call_user_func(array($b, $key)));
});
if (!$result)
throw new ArrayException("sorting by \"$key\" failed");
return $array;
}
|
php
|
public static function sortByKey($_array, $key) {
$array = $_array;
$result = usort($array, function($a, $b) use ($key) {
return strcmp(call_user_func(array($a, $key)),
call_user_func(array($b, $key)));
});
if (!$result)
throw new ArrayException("sorting by \"$key\" failed");
return $array;
}
|
[
"public",
"static",
"function",
"sortByKey",
"(",
"$",
"_array",
",",
"$",
"key",
")",
"{",
"$",
"array",
"=",
"$",
"_array",
";",
"$",
"result",
"=",
"usort",
"(",
"$",
"array",
",",
"function",
"(",
"$",
"a",
",",
"$",
"b",
")",
"use",
"(",
"$",
"key",
")",
"{",
"return",
"strcmp",
"(",
"call_user_func",
"(",
"array",
"(",
"$",
"a",
",",
"$",
"key",
")",
")",
",",
"call_user_func",
"(",
"array",
"(",
"$",
"b",
",",
"$",
"key",
")",
")",
")",
";",
"}",
")",
";",
"if",
"(",
"!",
"$",
"result",
")",
"throw",
"new",
"ArrayException",
"(",
"\"sorting by \\\"$key\\\" failed\"",
")",
";",
"return",
"$",
"array",
";",
"}"
] |
Sorts an array in ascending order regarding a member.
@param array $_array
@param callable $key
@return array
|
[
"Sorts",
"an",
"array",
"in",
"ascending",
"order",
"regarding",
"a",
"member",
"."
] |
daf4a59098802fedcfd1f1a1d07847fcf2fea7bf
|
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Helper/_Array.php#L58-L67
|
20,386 |
j-d/draggy
|
src/Draggy/Utils/Indenter/AbstractIndenter.php
|
AbstractIndenter.prepareToIndent
|
protected function prepareToIndent()
{
foreach ($this->lines as $lineNumber => $line) {
$this->lines[$lineNumber] = trim($line);
}
$this->outputLines = $this->lines;
}
|
php
|
protected function prepareToIndent()
{
foreach ($this->lines as $lineNumber => $line) {
$this->lines[$lineNumber] = trim($line);
}
$this->outputLines = $this->lines;
}
|
[
"protected",
"function",
"prepareToIndent",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"lines",
"as",
"$",
"lineNumber",
"=>",
"$",
"line",
")",
"{",
"$",
"this",
"->",
"lines",
"[",
"$",
"lineNumber",
"]",
"=",
"trim",
"(",
"$",
"line",
")",
";",
"}",
"$",
"this",
"->",
"outputLines",
"=",
"$",
"this",
"->",
"lines",
";",
"}"
] |
Pre-process all the lines so they are ready to be indented
|
[
"Pre",
"-",
"process",
"all",
"the",
"lines",
"so",
"they",
"are",
"ready",
"to",
"be",
"indented"
] |
97ffc66e1aacb5f685d7aac5251c4abb8888d4bb
|
https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Utils/Indenter/AbstractIndenter.php#L181-L188
|
20,387 |
Danack/GithubArtaxService
|
lib/GithubService/Operation/searchRepos.php
|
searchRepos.createAndExecute
|
public function createAndExecute() {
$request = $this->createRequest();
$response = $this->api->execute($request, $this);
$this->response = $response;
return $response;
}
|
php
|
public function createAndExecute() {
$request = $this->createRequest();
$response = $this->api->execute($request, $this);
$this->response = $response;
return $response;
}
|
[
"public",
"function",
"createAndExecute",
"(",
")",
"{",
"$",
"request",
"=",
"$",
"this",
"->",
"createRequest",
"(",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"api",
"->",
"execute",
"(",
"$",
"request",
",",
"$",
"this",
")",
";",
"$",
"this",
"->",
"response",
"=",
"$",
"response",
";",
"return",
"$",
"response",
";",
"}"
] |
Create and execute the operation, returning the raw response from the server.
@return \Amp\Artax\Response
|
[
"Create",
"and",
"execute",
"the",
"operation",
"returning",
"the",
"raw",
"response",
"from",
"the",
"server",
"."
] |
9f62b5be4f413207d4012e7fa084d0ae505680eb
|
https://github.com/Danack/GithubArtaxService/blob/9f62b5be4f413207d4012e7fa084d0ae505680eb/lib/GithubService/Operation/searchRepos.php#L289-L295
|
20,388 |
Danack/GithubArtaxService
|
lib/GithubService/Operation/searchRepos.php
|
searchRepos.dispatchAsync
|
public function dispatchAsync(\Amp\Artax\Request $request, callable $callable) {
return $this->api->executeAsync($request, $this, $callable);
}
|
php
|
public function dispatchAsync(\Amp\Artax\Request $request, callable $callable) {
return $this->api->executeAsync($request, $this, $callable);
}
|
[
"public",
"function",
"dispatchAsync",
"(",
"\\",
"Amp",
"\\",
"Artax",
"\\",
"Request",
"$",
"request",
",",
"callable",
"$",
"callable",
")",
"{",
"return",
"$",
"this",
"->",
"api",
"->",
"executeAsync",
"(",
"$",
"request",
",",
"$",
"this",
",",
"$",
"callable",
")",
";",
"}"
] |
Dispatch the request for this operation and process the response asynchronously.
Allows you to modify the request before it is sent.
@return \GithubService\Model\SearchRepos
@param \Amp\Artax\Request $request The request to be processed
@param callable $callable The callable that processes the response
|
[
"Dispatch",
"the",
"request",
"for",
"this",
"operation",
"and",
"process",
"the",
"response",
"asynchronously",
".",
"Allows",
"you",
"to",
"modify",
"the",
"request",
"before",
"it",
"is",
"sent",
"."
] |
9f62b5be4f413207d4012e7fa084d0ae505680eb
|
https://github.com/Danack/GithubArtaxService/blob/9f62b5be4f413207d4012e7fa084d0ae505680eb/lib/GithubService/Operation/searchRepos.php#L359-L361
|
20,389 |
ekuiter/feature-php
|
FeaturePhp/Generator/Generator.php
|
Generator.getGeneratorMap
|
public static function getGeneratorMap() {
$generatorMap = array();
foreach (self::getGenerators() as $generator)
$generatorMap[call_user_func(array($generator, "getKey"))] = $generator;
return $generatorMap;
}
|
php
|
public static function getGeneratorMap() {
$generatorMap = array();
foreach (self::getGenerators() as $generator)
$generatorMap[call_user_func(array($generator, "getKey"))] = $generator;
return $generatorMap;
}
|
[
"public",
"static",
"function",
"getGeneratorMap",
"(",
")",
"{",
"$",
"generatorMap",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"self",
"::",
"getGenerators",
"(",
")",
"as",
"$",
"generator",
")",
"$",
"generatorMap",
"[",
"call_user_func",
"(",
"array",
"(",
"$",
"generator",
",",
"\"getKey\"",
")",
")",
"]",
"=",
"$",
"generator",
";",
"return",
"$",
"generatorMap",
";",
"}"
] |
Returns a map from all generator keys to class names.
@return string[]
|
[
"Returns",
"a",
"map",
"from",
"all",
"generator",
"keys",
"to",
"class",
"names",
"."
] |
daf4a59098802fedcfd1f1a1d07847fcf2fea7bf
|
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Generator/Generator.php#L68-L73
|
20,390 |
ekuiter/feature-php
|
FeaturePhp/Generator/Generator.php
|
Generator.generateFiles
|
public function generateFiles() {
if ($this->files === null) {
$this->files = array();
$this->tracingLinks = array();
$this->_generateFiles();
}
if ($this->settings->getOptional("logFile", false))
return array_merge(array($this->logFile), $this->files);
else
return $this->files;
}
|
php
|
public function generateFiles() {
if ($this->files === null) {
$this->files = array();
$this->tracingLinks = array();
$this->_generateFiles();
}
if ($this->settings->getOptional("logFile", false))
return array_merge(array($this->logFile), $this->files);
else
return $this->files;
}
|
[
"public",
"function",
"generateFiles",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"files",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"files",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"tracingLinks",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"_generateFiles",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"settings",
"->",
"getOptional",
"(",
"\"logFile\"",
",",
"false",
")",
")",
"return",
"array_merge",
"(",
"array",
"(",
"$",
"this",
"->",
"logFile",
")",
",",
"$",
"this",
"->",
"files",
")",
";",
"else",
"return",
"$",
"this",
"->",
"files",
";",
"}"
] |
Generates the files for all registered artifacts.
If the files have already been generated, returns the cached files.
The generator's log file is included.
@return \FeaturePhp\File\File[]
|
[
"Generates",
"the",
"files",
"for",
"all",
"registered",
"artifacts",
".",
"If",
"the",
"files",
"have",
"already",
"been",
"generated",
"returns",
"the",
"cached",
"files",
".",
"The",
"generator",
"s",
"log",
"file",
"is",
"included",
"."
] |
daf4a59098802fedcfd1f1a1d07847fcf2fea7bf
|
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Generator/Generator.php#L134-L144
|
20,391 |
ekuiter/feature-php
|
FeaturePhp/Generator/Generator.php
|
Generator.isSelectedFeature
|
protected function isSelectedFeature($featureName) {
$isSelected = false;
foreach ($this->selectedArtifacts as $selectedArtifact)
if ($featureName === $selectedArtifact->getFeature()->getName())
$isSelected = true;
return $isSelected;
}
|
php
|
protected function isSelectedFeature($featureName) {
$isSelected = false;
foreach ($this->selectedArtifacts as $selectedArtifact)
if ($featureName === $selectedArtifact->getFeature()->getName())
$isSelected = true;
return $isSelected;
}
|
[
"protected",
"function",
"isSelectedFeature",
"(",
"$",
"featureName",
")",
"{",
"$",
"isSelected",
"=",
"false",
";",
"foreach",
"(",
"$",
"this",
"->",
"selectedArtifacts",
"as",
"$",
"selectedArtifact",
")",
"if",
"(",
"$",
"featureName",
"===",
"$",
"selectedArtifact",
"->",
"getFeature",
"(",
")",
"->",
"getName",
"(",
")",
")",
"$",
"isSelected",
"=",
"true",
";",
"return",
"$",
"isSelected",
";",
"}"
] |
Returns whether a feature's artifact is selected.
@param string $featureName
@return bool
|
[
"Returns",
"whether",
"a",
"feature",
"s",
"artifact",
"is",
"selected",
"."
] |
daf4a59098802fedcfd1f1a1d07847fcf2fea7bf
|
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Generator/Generator.php#L160-L166
|
20,392 |
kenphp/ken
|
src/Http/MiddlewareFactory.php
|
MiddlewareFactory.createObject
|
public function createObject($builder, $parameters = array()) {
if (is_string($builder)) {
if (class_exists($builder)) {
$response = $parameters['response'];
$nextMiddleware = $parameters['next'];
if ($response == null) {
throw new InvalidArgumentException("'response' parameters must be 'Psr\Http\Message\ResponseInterface' instance.");
}
if ($nextMiddleware != null) {
if (($nextMiddleware instanceof BaseMiddleware) == false) {
throw new InvalidArgumentException("'next' parameters must be 'Ken\Http\BaseMiddleware' instance.");
}
}
return new $builder($response, $nextMiddleware);
}
throw new InvalidArgumentException("Class '{$builder}' not found.");
}
throw new InvalidArgumentException("'builder' must be a fully qualified namespace of middleware class.");
}
|
php
|
public function createObject($builder, $parameters = array()) {
if (is_string($builder)) {
if (class_exists($builder)) {
$response = $parameters['response'];
$nextMiddleware = $parameters['next'];
if ($response == null) {
throw new InvalidArgumentException("'response' parameters must be 'Psr\Http\Message\ResponseInterface' instance.");
}
if ($nextMiddleware != null) {
if (($nextMiddleware instanceof BaseMiddleware) == false) {
throw new InvalidArgumentException("'next' parameters must be 'Ken\Http\BaseMiddleware' instance.");
}
}
return new $builder($response, $nextMiddleware);
}
throw new InvalidArgumentException("Class '{$builder}' not found.");
}
throw new InvalidArgumentException("'builder' must be a fully qualified namespace of middleware class.");
}
|
[
"public",
"function",
"createObject",
"(",
"$",
"builder",
",",
"$",
"parameters",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"builder",
")",
")",
"{",
"if",
"(",
"class_exists",
"(",
"$",
"builder",
")",
")",
"{",
"$",
"response",
"=",
"$",
"parameters",
"[",
"'response'",
"]",
";",
"$",
"nextMiddleware",
"=",
"$",
"parameters",
"[",
"'next'",
"]",
";",
"if",
"(",
"$",
"response",
"==",
"null",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"'response' parameters must be 'Psr\\Http\\Message\\ResponseInterface' instance.\"",
")",
";",
"}",
"if",
"(",
"$",
"nextMiddleware",
"!=",
"null",
")",
"{",
"if",
"(",
"(",
"$",
"nextMiddleware",
"instanceof",
"BaseMiddleware",
")",
"==",
"false",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"'next' parameters must be 'Ken\\Http\\BaseMiddleware' instance.\"",
")",
";",
"}",
"}",
"return",
"new",
"$",
"builder",
"(",
"$",
"response",
",",
"$",
"nextMiddleware",
")",
";",
"}",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Class '{$builder}' not found.\"",
")",
";",
"}",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"'builder' must be a fully qualified namespace of middleware class.\"",
")",
";",
"}"
] |
Creates a middleware instance
@param string $builder A fully qualified namespace of middleware class.
The middleware class must extend **Ken\Http\BaseMiddleware** class.
@param array $parameters An array containing :
'response' : an instance of **Psr\Http\Message\ResponseInterface**
'next' : null or an instance of **Ken\Http\BaseMiddleware**
@return \Ken\Http\BaseMiddleware
@throws InvalidArgumentException
|
[
"Creates",
"a",
"middleware",
"instance"
] |
c454a86f0ab55c52c88e9bff5bc6fb4e7bd9e0eb
|
https://github.com/kenphp/ken/blob/c454a86f0ab55c52c88e9bff5bc6fb4e7bd9e0eb/src/Http/MiddlewareFactory.php#L23-L46
|
20,393 |
nabab/bbn
|
src/bbn/file/dir.php
|
dir.get_files
|
public static function get_files($dir, $including_dirs = false, $hidden = false, $extension = null)
{
$dir = self::clean($dir);
clearstatcache();
if ( $dir === './' ){
$dir = '.';
}
if ( is_dir($dir) && (($dir === '.') || ((strpos(basename($dir), '.') !== 0) || $hidden)) ){
$files = [];
$fs = scandir($dir, SCANDIR_SORT_ASCENDING );
//$encodings = ['UTF-8', 'WINDOWS-1252', 'ISO-8859-1', 'ISO-8859-15'];
foreach ( $fs as $f ){
if ( $f !== '.' && $f !== '..' ){
/*
$enc = mb_detect_encoding($f, $encodings);
if ( $enc !== 'UTF-8' ){
$f = html_entity_decode(htmlentities($f, ENT_QUOTES, $enc), ENT_QUOTES , 'UTF-8');
}
*/
if ( $hidden || (strpos(basename($f), '.') !== 0) ){
if ( $including_dirs ){
$files[] = self::cur($dir.'/').$f;
}
else if ( is_file($dir.'/'.$f) ){
if ( !$extension || (strtolower($extension) === strtolower(bbn\str::file_ext($f))) ){
$files[] = self::cur($dir.'/').$f;
}
}
}
}
}
if ( \count($files) > 0 ){
bbn\x::sort($files);
}
return $files;
}
return false;
}
|
php
|
public static function get_files($dir, $including_dirs = false, $hidden = false, $extension = null)
{
$dir = self::clean($dir);
clearstatcache();
if ( $dir === './' ){
$dir = '.';
}
if ( is_dir($dir) && (($dir === '.') || ((strpos(basename($dir), '.') !== 0) || $hidden)) ){
$files = [];
$fs = scandir($dir, SCANDIR_SORT_ASCENDING );
//$encodings = ['UTF-8', 'WINDOWS-1252', 'ISO-8859-1', 'ISO-8859-15'];
foreach ( $fs as $f ){
if ( $f !== '.' && $f !== '..' ){
/*
$enc = mb_detect_encoding($f, $encodings);
if ( $enc !== 'UTF-8' ){
$f = html_entity_decode(htmlentities($f, ENT_QUOTES, $enc), ENT_QUOTES , 'UTF-8');
}
*/
if ( $hidden || (strpos(basename($f), '.') !== 0) ){
if ( $including_dirs ){
$files[] = self::cur($dir.'/').$f;
}
else if ( is_file($dir.'/'.$f) ){
if ( !$extension || (strtolower($extension) === strtolower(bbn\str::file_ext($f))) ){
$files[] = self::cur($dir.'/').$f;
}
}
}
}
}
if ( \count($files) > 0 ){
bbn\x::sort($files);
}
return $files;
}
return false;
}
|
[
"public",
"static",
"function",
"get_files",
"(",
"$",
"dir",
",",
"$",
"including_dirs",
"=",
"false",
",",
"$",
"hidden",
"=",
"false",
",",
"$",
"extension",
"=",
"null",
")",
"{",
"$",
"dir",
"=",
"self",
"::",
"clean",
"(",
"$",
"dir",
")",
";",
"clearstatcache",
"(",
")",
";",
"if",
"(",
"$",
"dir",
"===",
"'./'",
")",
"{",
"$",
"dir",
"=",
"'.'",
";",
"}",
"if",
"(",
"is_dir",
"(",
"$",
"dir",
")",
"&&",
"(",
"(",
"$",
"dir",
"===",
"'.'",
")",
"||",
"(",
"(",
"strpos",
"(",
"basename",
"(",
"$",
"dir",
")",
",",
"'.'",
")",
"!==",
"0",
")",
"||",
"$",
"hidden",
")",
")",
")",
"{",
"$",
"files",
"=",
"[",
"]",
";",
"$",
"fs",
"=",
"scandir",
"(",
"$",
"dir",
",",
"SCANDIR_SORT_ASCENDING",
")",
";",
"//$encodings = ['UTF-8', 'WINDOWS-1252', 'ISO-8859-1', 'ISO-8859-15'];",
"foreach",
"(",
"$",
"fs",
"as",
"$",
"f",
")",
"{",
"if",
"(",
"$",
"f",
"!==",
"'.'",
"&&",
"$",
"f",
"!==",
"'..'",
")",
"{",
"/*\n $enc = mb_detect_encoding($f, $encodings);\n if ( $enc !== 'UTF-8' ){\n $f = html_entity_decode(htmlentities($f, ENT_QUOTES, $enc), ENT_QUOTES , 'UTF-8');\n }\n */",
"if",
"(",
"$",
"hidden",
"||",
"(",
"strpos",
"(",
"basename",
"(",
"$",
"f",
")",
",",
"'.'",
")",
"!==",
"0",
")",
")",
"{",
"if",
"(",
"$",
"including_dirs",
")",
"{",
"$",
"files",
"[",
"]",
"=",
"self",
"::",
"cur",
"(",
"$",
"dir",
".",
"'/'",
")",
".",
"$",
"f",
";",
"}",
"else",
"if",
"(",
"is_file",
"(",
"$",
"dir",
".",
"'/'",
".",
"$",
"f",
")",
")",
"{",
"if",
"(",
"!",
"$",
"extension",
"||",
"(",
"strtolower",
"(",
"$",
"extension",
")",
"===",
"strtolower",
"(",
"bbn",
"\\",
"str",
"::",
"file_ext",
"(",
"$",
"f",
")",
")",
")",
")",
"{",
"$",
"files",
"[",
"]",
"=",
"self",
"::",
"cur",
"(",
"$",
"dir",
".",
"'/'",
")",
".",
"$",
"f",
";",
"}",
"}",
"}",
"}",
"}",
"if",
"(",
"\\",
"count",
"(",
"$",
"files",
")",
">",
"0",
")",
"{",
"bbn",
"\\",
"x",
"::",
"sort",
"(",
"$",
"files",
")",
";",
"}",
"return",
"$",
"files",
";",
"}",
"return",
"false",
";",
"}"
] |
Returns an array of files contained in the given directory.
Returns the full path of files.
```php
\bbn\x::dump(\bbn\file\dir::get_files("/home/Docs/Test"));
// (array) ['/home/Docs/Test/file.txt']
\bbn\x::dump(\bbn\file\dir::get_files("/home/Docs/Test",0,1));
// (array) ['/home/Docs/Test/file.txt', '/home/Docs/Test/.doc.pdf']
\bbn\x::dump(\bbn\file\dir::get_files("/home/Docs/Test", 1));
// (array) ['/home/Docs/Test/folder', '/home/Docs/Test/file.txt']
\bbn\x::dump(\bbn\file\dir::get_files("/home/Docs/Test", 1,1));
// (array) ['/home/Docs/Test/folder', '/home/Docs/Test/.folder_test','/home/Docs/Test/file.txt', '/home/Docs/Test/.doc.pdf']
```
@param string $dir The directory's path.
@param bool $including_dirs If set to true it will also returns the folders contained in the given directory.
@param bool $hidden If set to true will also returns the hidden files contained the directory
@return array|false
|
[
"Returns",
"an",
"array",
"of",
"files",
"contained",
"in",
"the",
"given",
"directory",
".",
"Returns",
"the",
"full",
"path",
"of",
"files",
"."
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/file/dir.php#L142-L179
|
20,394 |
nabab/bbn
|
src/bbn/file/dir.php
|
dir.delete
|
public static function delete(string $dir, bool $full = true): bool
{
$dir = self::clean($dir);
if ( is_dir($dir) ){
$files = self::get_files($dir, 1, 1);
foreach ( $files as $file ){
self::delete($file);
}
if ( $full ){
return rmdir($dir);
}
return true;
}
if ( is_file($dir) ){
return unlink($dir);
}
return false;
}
|
php
|
public static function delete(string $dir, bool $full = true): bool
{
$dir = self::clean($dir);
if ( is_dir($dir) ){
$files = self::get_files($dir, 1, 1);
foreach ( $files as $file ){
self::delete($file);
}
if ( $full ){
return rmdir($dir);
}
return true;
}
if ( is_file($dir) ){
return unlink($dir);
}
return false;
}
|
[
"public",
"static",
"function",
"delete",
"(",
"string",
"$",
"dir",
",",
"bool",
"$",
"full",
"=",
"true",
")",
":",
"bool",
"{",
"$",
"dir",
"=",
"self",
"::",
"clean",
"(",
"$",
"dir",
")",
";",
"if",
"(",
"is_dir",
"(",
"$",
"dir",
")",
")",
"{",
"$",
"files",
"=",
"self",
"::",
"get_files",
"(",
"$",
"dir",
",",
"1",
",",
"1",
")",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"file",
")",
"{",
"self",
"::",
"delete",
"(",
"$",
"file",
")",
";",
"}",
"if",
"(",
"$",
"full",
")",
"{",
"return",
"rmdir",
"(",
"$",
"dir",
")",
";",
"}",
"return",
"true",
";",
"}",
"if",
"(",
"is_file",
"(",
"$",
"dir",
")",
")",
"{",
"return",
"unlink",
"(",
"$",
"dir",
")",
";",
"}",
"return",
"false",
";",
"}"
] |
Deletes the given directory and all its content.
```php
\bbn\x::dump(\bbn\file\dir::delete('/home/Docs/Test/')
// (bool) true
\bbn\x::dump(\bbn\file\dir::delete('/home/Docs/Test', 0);
// (bool) false
\bbn\x::dump(\bbn\file\dir::delete('/home/Docs/Test/file.txt');
// (bool) false
```
@param string $dir The directory path's.
@param bool $full If set to '0' will delete only the content of the directory. Default: "1".
@return bool
|
[
"Deletes",
"the",
"given",
"directory",
"and",
"all",
"its",
"content",
"."
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/file/dir.php#L197-L214
|
20,395 |
nabab/bbn
|
src/bbn/file/dir.php
|
dir.scan
|
public static function scan(string $dir, string $type = null, bool $hidden = false): array
{
$all = [];
$dir = self::clean($dir);
$dirs = self::get_dirs($dir);
if ( \is_array($dirs) ){
if ( $type && (strpos($type, 'file') === 0) ){
$all = self::get_files($dir, false, $hidden);
}
else if ( $type && ((strpos($type, 'dir') === 0) || (strpos($type, 'fold') === 0)) ){
$all = $dirs;
}
else if ( $type ){
$all = array_filter(self::get_files($dir, false, $hidden), function($a)use($type){
$ext = bbn\str::file_ext($a);
return strtolower($ext) === strtolower($type);
});
}
else{
$files = self::get_files($dir, false, $hidden);
if ( \is_array($files) ){
$all = array_merge($dirs, $files);
}
}
foreach ( $dirs as $d ){
$all = array_merge(\is_array($all) ? $all : [], self::scan($d, $type, $hidden));
}
}
return $all;
}
|
php
|
public static function scan(string $dir, string $type = null, bool $hidden = false): array
{
$all = [];
$dir = self::clean($dir);
$dirs = self::get_dirs($dir);
if ( \is_array($dirs) ){
if ( $type && (strpos($type, 'file') === 0) ){
$all = self::get_files($dir, false, $hidden);
}
else if ( $type && ((strpos($type, 'dir') === 0) || (strpos($type, 'fold') === 0)) ){
$all = $dirs;
}
else if ( $type ){
$all = array_filter(self::get_files($dir, false, $hidden), function($a)use($type){
$ext = bbn\str::file_ext($a);
return strtolower($ext) === strtolower($type);
});
}
else{
$files = self::get_files($dir, false, $hidden);
if ( \is_array($files) ){
$all = array_merge($dirs, $files);
}
}
foreach ( $dirs as $d ){
$all = array_merge(\is_array($all) ? $all : [], self::scan($d, $type, $hidden));
}
}
return $all;
}
|
[
"public",
"static",
"function",
"scan",
"(",
"string",
"$",
"dir",
",",
"string",
"$",
"type",
"=",
"null",
",",
"bool",
"$",
"hidden",
"=",
"false",
")",
":",
"array",
"{",
"$",
"all",
"=",
"[",
"]",
";",
"$",
"dir",
"=",
"self",
"::",
"clean",
"(",
"$",
"dir",
")",
";",
"$",
"dirs",
"=",
"self",
"::",
"get_dirs",
"(",
"$",
"dir",
")",
";",
"if",
"(",
"\\",
"is_array",
"(",
"$",
"dirs",
")",
")",
"{",
"if",
"(",
"$",
"type",
"&&",
"(",
"strpos",
"(",
"$",
"type",
",",
"'file'",
")",
"===",
"0",
")",
")",
"{",
"$",
"all",
"=",
"self",
"::",
"get_files",
"(",
"$",
"dir",
",",
"false",
",",
"$",
"hidden",
")",
";",
"}",
"else",
"if",
"(",
"$",
"type",
"&&",
"(",
"(",
"strpos",
"(",
"$",
"type",
",",
"'dir'",
")",
"===",
"0",
")",
"||",
"(",
"strpos",
"(",
"$",
"type",
",",
"'fold'",
")",
"===",
"0",
")",
")",
")",
"{",
"$",
"all",
"=",
"$",
"dirs",
";",
"}",
"else",
"if",
"(",
"$",
"type",
")",
"{",
"$",
"all",
"=",
"array_filter",
"(",
"self",
"::",
"get_files",
"(",
"$",
"dir",
",",
"false",
",",
"$",
"hidden",
")",
",",
"function",
"(",
"$",
"a",
")",
"use",
"(",
"$",
"type",
")",
"{",
"$",
"ext",
"=",
"bbn",
"\\",
"str",
"::",
"file_ext",
"(",
"$",
"a",
")",
";",
"return",
"strtolower",
"(",
"$",
"ext",
")",
"===",
"strtolower",
"(",
"$",
"type",
")",
";",
"}",
")",
";",
"}",
"else",
"{",
"$",
"files",
"=",
"self",
"::",
"get_files",
"(",
"$",
"dir",
",",
"false",
",",
"$",
"hidden",
")",
";",
"if",
"(",
"\\",
"is_array",
"(",
"$",
"files",
")",
")",
"{",
"$",
"all",
"=",
"array_merge",
"(",
"$",
"dirs",
",",
"$",
"files",
")",
";",
"}",
"}",
"foreach",
"(",
"$",
"dirs",
"as",
"$",
"d",
")",
"{",
"$",
"all",
"=",
"array_merge",
"(",
"\\",
"is_array",
"(",
"$",
"all",
")",
"?",
"$",
"all",
":",
"[",
"]",
",",
"self",
"::",
"scan",
"(",
"$",
"d",
",",
"$",
"type",
",",
"$",
"hidden",
")",
")",
";",
"}",
"}",
"return",
"$",
"all",
";",
"}"
] |
Returns an array with all the content of the given directory.
@todo check the default value for $hidden
```php
\bbn\x::dump(\bbn\file\dir::scan("/home/data/test"));
// (array) ["/home/data/test/Folder", "/home/data/test/Folder_test/image.png"]
\bbn\x::dump(\bbn\file\dir::scan("/home/data/test", "", true));
// (array) ["/home/data/test/Folder", "/home/data/test/Folder_test/image.png", "/home/data/test/.doc.pdf"]
\bbn\x::dump(\bbn\file\dir::scan("/home/data/test", "dir"));
// (array) ["/home/data/test/Folder", "/home/data/test/Folder_test"]
\bbn\x::dump(\bbn\file\dir::scan("/home/data/test", "file"));
// (array) ["/home/data/test/Folder_test/image.png"]
\bbn\x::dump(\bbn\file\dir::scan("/home/data/test", "file", true));
// (array) ["/home/data/test/Folder_test/image.png", "/home/data/test/Folder/.doc.pdf"]
```
@param string $dir The directory's path.
@param string $type The type or the extension of item to return ('file', 'dir', 'php', default is both)
@param bool $hidden If set to true will include the hidden files/directories in the result
@return array
|
[
"Returns",
"an",
"array",
"with",
"all",
"the",
"content",
"of",
"the",
"given",
"directory",
"."
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/file/dir.php#L238-L267
|
20,396 |
nabab/bbn
|
src/bbn/file/dir.php
|
dir.get_tree
|
public static function get_tree(string $dir, bool $only_dir = false, callable $filter = null, bool $hidden = false): array
{
$r = [];
$dir = self::clean($dir);
$dirs = self::get_dirs($dir, $hidden);
if ( \is_array($dirs) ){
foreach ( $dirs as $d ){
$x = [
'name' => $d,
'type' => 'dir',
'num_children' => 0,
'items' => self::get_tree($d, $only_dir, $filter, $hidden)
];
$x['num_children'] = \count($x['items']);
if ( $filter ){
if ( $filter($x) ){
$r[] = $x;
}
}
else{
$r[] = $x;
}
}
if ( !$only_dir ){
$files = self::get_files($dir, false, $hidden);
foreach ( $files as $f ){
$x = [
'name' => $f,
'type' => 'file',
'ext' => bbn\str::file_ext($f)
];
if ( $filter ){
if ( $filter($x) ){
$r[] = $x;
}
}
else{
$r[] = $x;
}
}
}
}
return $r;
}
|
php
|
public static function get_tree(string $dir, bool $only_dir = false, callable $filter = null, bool $hidden = false): array
{
$r = [];
$dir = self::clean($dir);
$dirs = self::get_dirs($dir, $hidden);
if ( \is_array($dirs) ){
foreach ( $dirs as $d ){
$x = [
'name' => $d,
'type' => 'dir',
'num_children' => 0,
'items' => self::get_tree($d, $only_dir, $filter, $hidden)
];
$x['num_children'] = \count($x['items']);
if ( $filter ){
if ( $filter($x) ){
$r[] = $x;
}
}
else{
$r[] = $x;
}
}
if ( !$only_dir ){
$files = self::get_files($dir, false, $hidden);
foreach ( $files as $f ){
$x = [
'name' => $f,
'type' => 'file',
'ext' => bbn\str::file_ext($f)
];
if ( $filter ){
if ( $filter($x) ){
$r[] = $x;
}
}
else{
$r[] = $x;
}
}
}
}
return $r;
}
|
[
"public",
"static",
"function",
"get_tree",
"(",
"string",
"$",
"dir",
",",
"bool",
"$",
"only_dir",
"=",
"false",
",",
"callable",
"$",
"filter",
"=",
"null",
",",
"bool",
"$",
"hidden",
"=",
"false",
")",
":",
"array",
"{",
"$",
"r",
"=",
"[",
"]",
";",
"$",
"dir",
"=",
"self",
"::",
"clean",
"(",
"$",
"dir",
")",
";",
"$",
"dirs",
"=",
"self",
"::",
"get_dirs",
"(",
"$",
"dir",
",",
"$",
"hidden",
")",
";",
"if",
"(",
"\\",
"is_array",
"(",
"$",
"dirs",
")",
")",
"{",
"foreach",
"(",
"$",
"dirs",
"as",
"$",
"d",
")",
"{",
"$",
"x",
"=",
"[",
"'name'",
"=>",
"$",
"d",
",",
"'type'",
"=>",
"'dir'",
",",
"'num_children'",
"=>",
"0",
",",
"'items'",
"=>",
"self",
"::",
"get_tree",
"(",
"$",
"d",
",",
"$",
"only_dir",
",",
"$",
"filter",
",",
"$",
"hidden",
")",
"]",
";",
"$",
"x",
"[",
"'num_children'",
"]",
"=",
"\\",
"count",
"(",
"$",
"x",
"[",
"'items'",
"]",
")",
";",
"if",
"(",
"$",
"filter",
")",
"{",
"if",
"(",
"$",
"filter",
"(",
"$",
"x",
")",
")",
"{",
"$",
"r",
"[",
"]",
"=",
"$",
"x",
";",
"}",
"}",
"else",
"{",
"$",
"r",
"[",
"]",
"=",
"$",
"x",
";",
"}",
"}",
"if",
"(",
"!",
"$",
"only_dir",
")",
"{",
"$",
"files",
"=",
"self",
"::",
"get_files",
"(",
"$",
"dir",
",",
"false",
",",
"$",
"hidden",
")",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"f",
")",
"{",
"$",
"x",
"=",
"[",
"'name'",
"=>",
"$",
"f",
",",
"'type'",
"=>",
"'file'",
",",
"'ext'",
"=>",
"bbn",
"\\",
"str",
"::",
"file_ext",
"(",
"$",
"f",
")",
"]",
";",
"if",
"(",
"$",
"filter",
")",
"{",
"if",
"(",
"$",
"filter",
"(",
"$",
"x",
")",
")",
"{",
"$",
"r",
"[",
"]",
"=",
"$",
"x",
";",
"}",
"}",
"else",
"{",
"$",
"r",
"[",
"]",
"=",
"$",
"x",
";",
"}",
"}",
"}",
"}",
"return",
"$",
"r",
";",
"}"
] |
Return an array with the tree of the folder's content.
```php
\bbn\x::dump(\bbn\file\dir::get_tree("/home/data/test"));
/* (array)
[
[
"name" => "/home/data/test/Folder",
"type" => "dir",
"num_children" => 0,
"items" => [],
],
[
"name" => "/home/data/test/Folder_test",
"type" => "dir",
"num_children" => 1,
"items" => [
[
"name" => "/home/data/test/Folder_test/image.png",
"type" => "file",
"ext" => "png",
],
],
],
]
\bbn\x::dump(\bbn\file\dir::get_tree("/home/data/test", true) );
/* (array)
[
[
"name" => "/home/data/test/Folder",
"type" => "dir",
"num_children" => 0,
"items" => [],
],
[
"name" => "/home/data/test/Folder_test",
"type" => "dir",
"num_children" => 0,
"items" => [],
],
]
\bbn\x::dump(\bbn\file\dir::get_tree("/home/data/test", false, false, true) );
/* (array)
[
[
"name" => "/home/data/test/Folder",
"type" => "dir",
"num_children" => 1,
"items" => [
[
"name" => "/home/data/test/Folder/.doc.pdf",
"type" => "file",
"ext" => "pdf",
],
],
],
[
"name" => "/home/data/test/Folder_test",
"type" => "dir",
"num_children" => 1,
"items" => [
[
"name" => "/home/data/test/Folder_test/image.png",
"type" => "file",
"ext" => "png",
],
],
],
]
```
@param string $dir The directory's path.
@param bool $only_dir If set to true will just return the folder(s), if false will include in the resulr also the file(s). Default = false.
@param callable $filter Filter function
@param bool $hidden If set to true will also return the hidden file(s)/folder(s)
@return array
|
[
"Return",
"an",
"array",
"with",
"the",
"tree",
"of",
"the",
"folder",
"s",
"content",
"."
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/file/dir.php#L425-L468
|
20,397 |
nabab/bbn
|
src/bbn/file/dir.php
|
dir.create_path
|
public static function create_path(string $dir, $chmod=false){
if ( !$dir || !\is_string($dir) ){
return false;
}
clearstatcache();
if ( !is_dir($dir) ){
$bits = explode('/', $dir);
$path = empty($bits[0]) ? '/' : '';
foreach ( $bits as $i => $b ){
if ( !empty($b) ){
$path .= $b;
if ( !is_dir($path) ){
if ( !mkdir($path) || !is_dir($path) ){
return false;
}
if ( $chmod ){
@chmod($path, $chmod);
}
}
$path .= '/';
}
}
}
return $dir;
}
|
php
|
public static function create_path(string $dir, $chmod=false){
if ( !$dir || !\is_string($dir) ){
return false;
}
clearstatcache();
if ( !is_dir($dir) ){
$bits = explode('/', $dir);
$path = empty($bits[0]) ? '/' : '';
foreach ( $bits as $i => $b ){
if ( !empty($b) ){
$path .= $b;
if ( !is_dir($path) ){
if ( !mkdir($path) || !is_dir($path) ){
return false;
}
if ( $chmod ){
@chmod($path, $chmod);
}
}
$path .= '/';
}
}
}
return $dir;
}
|
[
"public",
"static",
"function",
"create_path",
"(",
"string",
"$",
"dir",
",",
"$",
"chmod",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"dir",
"||",
"!",
"\\",
"is_string",
"(",
"$",
"dir",
")",
")",
"{",
"return",
"false",
";",
"}",
"clearstatcache",
"(",
")",
";",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"dir",
")",
")",
"{",
"$",
"bits",
"=",
"explode",
"(",
"'/'",
",",
"$",
"dir",
")",
";",
"$",
"path",
"=",
"empty",
"(",
"$",
"bits",
"[",
"0",
"]",
")",
"?",
"'/'",
":",
"''",
";",
"foreach",
"(",
"$",
"bits",
"as",
"$",
"i",
"=>",
"$",
"b",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"b",
")",
")",
"{",
"$",
"path",
".=",
"$",
"b",
";",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"path",
")",
")",
"{",
"if",
"(",
"!",
"mkdir",
"(",
"$",
"path",
")",
"||",
"!",
"is_dir",
"(",
"$",
"path",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"chmod",
")",
"{",
"@",
"chmod",
"(",
"$",
"path",
",",
"$",
"chmod",
")",
";",
"}",
"}",
"$",
"path",
".=",
"'/'",
";",
"}",
"}",
"}",
"return",
"$",
"dir",
";",
"}"
] |
Creates a folder with the given path.
```php
\bbn\x::dump(\bbn\file\dir::create_path("/home/data/test/New"));
\\ (string) "/home/data/test/New"
```
@param string $dir The new directory's path.
@param bool $chmod If set to true the user won't have the permissions to view the content of the folder created
@return string|false
|
[
"Creates",
"a",
"folder",
"with",
"the",
"given",
"path",
"."
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/file/dir.php#L482-L506
|
20,398 |
nabab/bbn
|
src/bbn/file/dir.php
|
dir.move
|
public static function move($orig, $dest, $st = '_v', $length = 0): bool
{
if ( file_exists($orig) && self::create_path(\dirname($dest)) ){
if ( file_exists($dest) ){
if ( $st === true ){
self::delete($dest);
}
else{
$i = 1;
while ( $i ){
$dir = \dirname($dest).'/';
$file_name = bbn\str::file_ext($dest, 1);
$file = $file_name[0].$st;
if ( $length > 0 ){
$len = \strlen(bbn\str::cast($i));
if ( $len > $length ){
return false;
}
$file .= str_repeat('0', $length - $len);
}
$file .= bbn\str::cast($i);
if ( !empty($file_name[1]) ){
$file .= '.'.$file_name[1];
}
$i++;
if ( !file_exists($dir.$file) ){
$dest = $dir.$file;
$i = false;
}
}
}
}
if ( rename($orig, $dest) ){
return true;
}
}
return false;
}
|
php
|
public static function move($orig, $dest, $st = '_v', $length = 0): bool
{
if ( file_exists($orig) && self::create_path(\dirname($dest)) ){
if ( file_exists($dest) ){
if ( $st === true ){
self::delete($dest);
}
else{
$i = 1;
while ( $i ){
$dir = \dirname($dest).'/';
$file_name = bbn\str::file_ext($dest, 1);
$file = $file_name[0].$st;
if ( $length > 0 ){
$len = \strlen(bbn\str::cast($i));
if ( $len > $length ){
return false;
}
$file .= str_repeat('0', $length - $len);
}
$file .= bbn\str::cast($i);
if ( !empty($file_name[1]) ){
$file .= '.'.$file_name[1];
}
$i++;
if ( !file_exists($dir.$file) ){
$dest = $dir.$file;
$i = false;
}
}
}
}
if ( rename($orig, $dest) ){
return true;
}
}
return false;
}
|
[
"public",
"static",
"function",
"move",
"(",
"$",
"orig",
",",
"$",
"dest",
",",
"$",
"st",
"=",
"'_v'",
",",
"$",
"length",
"=",
"0",
")",
":",
"bool",
"{",
"if",
"(",
"file_exists",
"(",
"$",
"orig",
")",
"&&",
"self",
"::",
"create_path",
"(",
"\\",
"dirname",
"(",
"$",
"dest",
")",
")",
")",
"{",
"if",
"(",
"file_exists",
"(",
"$",
"dest",
")",
")",
"{",
"if",
"(",
"$",
"st",
"===",
"true",
")",
"{",
"self",
"::",
"delete",
"(",
"$",
"dest",
")",
";",
"}",
"else",
"{",
"$",
"i",
"=",
"1",
";",
"while",
"(",
"$",
"i",
")",
"{",
"$",
"dir",
"=",
"\\",
"dirname",
"(",
"$",
"dest",
")",
".",
"'/'",
";",
"$",
"file_name",
"=",
"bbn",
"\\",
"str",
"::",
"file_ext",
"(",
"$",
"dest",
",",
"1",
")",
";",
"$",
"file",
"=",
"$",
"file_name",
"[",
"0",
"]",
".",
"$",
"st",
";",
"if",
"(",
"$",
"length",
">",
"0",
")",
"{",
"$",
"len",
"=",
"\\",
"strlen",
"(",
"bbn",
"\\",
"str",
"::",
"cast",
"(",
"$",
"i",
")",
")",
";",
"if",
"(",
"$",
"len",
">",
"$",
"length",
")",
"{",
"return",
"false",
";",
"}",
"$",
"file",
".=",
"str_repeat",
"(",
"'0'",
",",
"$",
"length",
"-",
"$",
"len",
")",
";",
"}",
"$",
"file",
".=",
"bbn",
"\\",
"str",
"::",
"cast",
"(",
"$",
"i",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"file_name",
"[",
"1",
"]",
")",
")",
"{",
"$",
"file",
".=",
"'.'",
".",
"$",
"file_name",
"[",
"1",
"]",
";",
"}",
"$",
"i",
"++",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"dir",
".",
"$",
"file",
")",
")",
"{",
"$",
"dest",
"=",
"$",
"dir",
".",
"$",
"file",
";",
"$",
"i",
"=",
"false",
";",
"}",
"}",
"}",
"}",
"if",
"(",
"rename",
"(",
"$",
"orig",
",",
"$",
"dest",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Moves a file or directory to a new location
```php
\bbn\x::dump(\bbn\file\dir::move("/home/data/test/Folder/image.png","/home/data/test/Folder_test/image.png"));
\\ (string) "image.png"
\bbn\x::dump(\bbn\file\dir::move("/home/data/test/Folder/image.png","/home/data/test/Folder_test/Intro/image.png"));
\\ (string) "image.png"
\bbn\x::dump(\bbn\file\dir::move("/home/data/test/Folder","/home/data/test/Folder_test", true));
\\ (string) "Folder_test"
\bbn\x::dump(\bbn\file\dir::move("/home/data/test/Folder","/home/data/test/Folder_test", "_n", 3));
\\ (string) "Folder_test_n001"
```
@param string $orig The path of the file to move
@param string $dest The full name of the destination (including basename)
@param string | true $st If in the destination folder alredy exists a file with the same name of the file to move it will rename the file adding '_v' (default). If 'string' will change the file name with the given string. If $st=true it will overwrite the file/folder.
@param int $length The number of characters to use for the revision number; will be zerofilled
@return bool Success
|
[
"Moves",
"a",
"file",
"or",
"directory",
"to",
"a",
"new",
"location"
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/file/dir.php#L528-L565
|
20,399 |
nabab/bbn
|
src/bbn/file/dir.php
|
dir.copy
|
public static function copy($src, $dst): bool
{
if ( is_file($src) ){
return copy($src, $dst);
}
if ( is_dir($src) && self::create_path($dst) ){
$files = self::get_files($src);
$dirs = self::get_dirs($src);
foreach ( $files as $f ){
copy($f, $dst.'/'.basename($f));
}
foreach ( $dirs as $f ){
self::copy($f, $dst.'/'.basename($f));
}
return true;
}
else{
return false;
}
}
|
php
|
public static function copy($src, $dst): bool
{
if ( is_file($src) ){
return copy($src, $dst);
}
if ( is_dir($src) && self::create_path($dst) ){
$files = self::get_files($src);
$dirs = self::get_dirs($src);
foreach ( $files as $f ){
copy($f, $dst.'/'.basename($f));
}
foreach ( $dirs as $f ){
self::copy($f, $dst.'/'.basename($f));
}
return true;
}
else{
return false;
}
}
|
[
"public",
"static",
"function",
"copy",
"(",
"$",
"src",
",",
"$",
"dst",
")",
":",
"bool",
"{",
"if",
"(",
"is_file",
"(",
"$",
"src",
")",
")",
"{",
"return",
"copy",
"(",
"$",
"src",
",",
"$",
"dst",
")",
";",
"}",
"if",
"(",
"is_dir",
"(",
"$",
"src",
")",
"&&",
"self",
"::",
"create_path",
"(",
"$",
"dst",
")",
")",
"{",
"$",
"files",
"=",
"self",
"::",
"get_files",
"(",
"$",
"src",
")",
";",
"$",
"dirs",
"=",
"self",
"::",
"get_dirs",
"(",
"$",
"src",
")",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"f",
")",
"{",
"copy",
"(",
"$",
"f",
",",
"$",
"dst",
".",
"'/'",
".",
"basename",
"(",
"$",
"f",
")",
")",
";",
"}",
"foreach",
"(",
"$",
"dirs",
"as",
"$",
"f",
")",
"{",
"self",
"::",
"copy",
"(",
"$",
"f",
",",
"$",
"dst",
".",
"'/'",
".",
"basename",
"(",
"$",
"f",
")",
")",
";",
"}",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] |
Will move the content of the given folder to a new destination. Doesn't move the hidden files.
```php
\bbn\x::dump(\bbn\file\dir::copy("/home/data/test/Folder","/home/data/test/Folder_test"));
\\ (bool) 1
```
@param string $src The path of the files to move
@param string $dst The new destination of files
@return bool
|
[
"Will",
"move",
"the",
"content",
"of",
"the",
"given",
"folder",
"to",
"a",
"new",
"destination",
".",
"Doesn",
"t",
"move",
"the",
"hidden",
"files",
"."
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/file/dir.php#L578-L597
|
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.