id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
sequence | docstring
stringlengths 3
47.2k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 91
247
|
---|---|---|---|---|---|---|---|---|---|---|---|
8,800 | lucifurious/kisma | src/Kisma/Core/Utility/Scalar.php | Scalar.arraySort | public static function arraySort( &$arrayToSort, $columnsToSort = array() )
{
// Convert to an array
if ( !empty( $columnsToSort ) && !is_array( $columnsToSort ) )
{
$columnsToSort = array($columnsToSort);
}
// Any fields?
if ( !empty( $columnsToSort ) )
{
return usort(
$arrayToSort,
function ( $a, $b ) use ( $columnsToSort )
{
$_result = null;
foreach ( $columnsToSort as $_column => $_order )
{
$_order = trim( strtolower( $_order ) );
if ( is_numeric( $_column ) && !static::in( $_order, 'asc', 'desc' ) )
{
$_column = $_order;
$_order = null;
}
if ( 'desc' == strtolower( $_order ) )
{
return strnatcmp( $b[$_column], $a[$_column] );
}
return strnatcmp( $a[$_column], $b[$_column] );
}
}
);
}
return false;
} | php | public static function arraySort( &$arrayToSort, $columnsToSort = array() )
{
// Convert to an array
if ( !empty( $columnsToSort ) && !is_array( $columnsToSort ) )
{
$columnsToSort = array($columnsToSort);
}
// Any fields?
if ( !empty( $columnsToSort ) )
{
return usort(
$arrayToSort,
function ( $a, $b ) use ( $columnsToSort )
{
$_result = null;
foreach ( $columnsToSort as $_column => $_order )
{
$_order = trim( strtolower( $_order ) );
if ( is_numeric( $_column ) && !static::in( $_order, 'asc', 'desc' ) )
{
$_column = $_order;
$_order = null;
}
if ( 'desc' == strtolower( $_order ) )
{
return strnatcmp( $b[$_column], $a[$_column] );
}
return strnatcmp( $a[$_column], $b[$_column] );
}
}
);
}
return false;
} | [
"public",
"static",
"function",
"arraySort",
"(",
"&",
"$",
"arrayToSort",
",",
"$",
"columnsToSort",
"=",
"array",
"(",
")",
")",
"{",
"//\tConvert to an array",
"if",
"(",
"!",
"empty",
"(",
"$",
"columnsToSort",
")",
"&&",
"!",
"is_array",
"(",
"$",
"columnsToSort",
")",
")",
"{",
"$",
"columnsToSort",
"=",
"array",
"(",
"$",
"columnsToSort",
")",
";",
"}",
"//\tAny fields?",
"if",
"(",
"!",
"empty",
"(",
"$",
"columnsToSort",
")",
")",
"{",
"return",
"usort",
"(",
"$",
"arrayToSort",
",",
"function",
"(",
"$",
"a",
",",
"$",
"b",
")",
"use",
"(",
"$",
"columnsToSort",
")",
"{",
"$",
"_result",
"=",
"null",
";",
"foreach",
"(",
"$",
"columnsToSort",
"as",
"$",
"_column",
"=>",
"$",
"_order",
")",
"{",
"$",
"_order",
"=",
"trim",
"(",
"strtolower",
"(",
"$",
"_order",
")",
")",
";",
"if",
"(",
"is_numeric",
"(",
"$",
"_column",
")",
"&&",
"!",
"static",
"::",
"in",
"(",
"$",
"_order",
",",
"'asc'",
",",
"'desc'",
")",
")",
"{",
"$",
"_column",
"=",
"$",
"_order",
";",
"$",
"_order",
"=",
"null",
";",
"}",
"if",
"(",
"'desc'",
"==",
"strtolower",
"(",
"$",
"_order",
")",
")",
"{",
"return",
"strnatcmp",
"(",
"$",
"b",
"[",
"$",
"_column",
"]",
",",
"$",
"a",
"[",
"$",
"_column",
"]",
")",
";",
"}",
"return",
"strnatcmp",
"(",
"$",
"a",
"[",
"$",
"_column",
"]",
",",
"$",
"b",
"[",
"$",
"_column",
"]",
")",
";",
"}",
"}",
")",
";",
"}",
"return",
"false",
";",
"}"
] | Generic array sorter
To sort a column in descending order, assign 'desc' to the column's value in the defining array:
$_columnsToSort = array(
'date' => 'desc',
'lastName' => 'asc',
'firstName' => 'asc',
);
@param array $arrayToSort
@param array $columnsToSort Array of columns in $arrayToSort to sort.
@return boolean | [
"Generic",
"array",
"sorter"
] | 4cc9954249da4e535b52f154e728935f07e648ae | https://github.com/lucifurious/kisma/blob/4cc9954249da4e535b52f154e728935f07e648ae/src/Kisma/Core/Utility/Scalar.php#L323-L362 |
8,801 | lucifurious/kisma | src/Kisma/Core/Utility/Scalar.php | Scalar.array_multisort_column | public static function array_multisort_column( &$sourceArray, $column, $sortDirection = SORT_ASC )
{
$_sortColumn = array();
foreach ( $sourceArray as $_key => $_row )
{
$_sortColumn[$_key] = ( isset( $_row[$column] ) ? $_row[$column] : null );
}
return \array_multisort( $_sortColumn, $sortDirection, $sourceArray );
} | php | public static function array_multisort_column( &$sourceArray, $column, $sortDirection = SORT_ASC )
{
$_sortColumn = array();
foreach ( $sourceArray as $_key => $_row )
{
$_sortColumn[$_key] = ( isset( $_row[$column] ) ? $_row[$column] : null );
}
return \array_multisort( $_sortColumn, $sortDirection, $sourceArray );
} | [
"public",
"static",
"function",
"array_multisort_column",
"(",
"&",
"$",
"sourceArray",
",",
"$",
"column",
",",
"$",
"sortDirection",
"=",
"SORT_ASC",
")",
"{",
"$",
"_sortColumn",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"sourceArray",
"as",
"$",
"_key",
"=>",
"$",
"_row",
")",
"{",
"$",
"_sortColumn",
"[",
"$",
"_key",
"]",
"=",
"(",
"isset",
"(",
"$",
"_row",
"[",
"$",
"column",
"]",
")",
"?",
"$",
"_row",
"[",
"$",
"column",
"]",
":",
"null",
")",
";",
"}",
"return",
"\\",
"array_multisort",
"(",
"$",
"_sortColumn",
",",
"$",
"sortDirection",
",",
"$",
"sourceArray",
")",
";",
"}"
] | Sorts an array by a single column
@param array $sourceArray
@param string $column
@param int $sortDirection
@return bool | [
"Sorts",
"an",
"array",
"by",
"a",
"single",
"column"
] | 4cc9954249da4e535b52f154e728935f07e648ae | https://github.com/lucifurious/kisma/blob/4cc9954249da4e535b52f154e728935f07e648ae/src/Kisma/Core/Utility/Scalar.php#L373-L383 |
8,802 | lucifurious/kisma | src/Kisma/Core/Utility/Scalar.php | Scalar.strlen | public static function strlen( $string )
{
if ( false === ( $_encoding = static::mbSupported( $string ) ) )
{
return strlen( $string );
}
return mb_strwidth( $string, $_encoding );
} | php | public static function strlen( $string )
{
if ( false === ( $_encoding = static::mbSupported( $string ) ) )
{
return strlen( $string );
}
return mb_strwidth( $string, $_encoding );
} | [
"public",
"static",
"function",
"strlen",
"(",
"$",
"string",
")",
"{",
"if",
"(",
"false",
"===",
"(",
"$",
"_encoding",
"=",
"static",
"::",
"mbSupported",
"(",
"$",
"string",
")",
")",
")",
"{",
"return",
"strlen",
"(",
"$",
"string",
")",
";",
"}",
"return",
"mb_strwidth",
"(",
"$",
"string",
",",
"$",
"_encoding",
")",
";",
"}"
] | Multibyte-aware strlen
Originally swiped from Symfony2 Console Application class private functions. Modified for Kisma use.
@param string $string
@return int | [
"Multibyte",
"-",
"aware",
"strlen",
"Originally",
"swiped",
"from",
"Symfony2",
"Console",
"Application",
"class",
"private",
"functions",
".",
"Modified",
"for",
"Kisma",
"use",
"."
] | 4cc9954249da4e535b52f154e728935f07e648ae | https://github.com/lucifurious/kisma/blob/4cc9954249da4e535b52f154e728935f07e648ae/src/Kisma/Core/Utility/Scalar.php#L393-L401 |
8,803 | lucifurious/kisma | src/Kisma/Core/Utility/Scalar.php | Scalar.mbSupported | public static function mbSupported( $string = null )
{
$_encoding = false;
if ( !function_exists( 'mb_strwidth' ) || ( $string && false === ( $_encoding = mb_detect_encoding( $string ) ) ) )
{
return false;
}
return $_encoding;
} | php | public static function mbSupported( $string = null )
{
$_encoding = false;
if ( !function_exists( 'mb_strwidth' ) || ( $string && false === ( $_encoding = mb_detect_encoding( $string ) ) ) )
{
return false;
}
return $_encoding;
} | [
"public",
"static",
"function",
"mbSupported",
"(",
"$",
"string",
"=",
"null",
")",
"{",
"$",
"_encoding",
"=",
"false",
";",
"if",
"(",
"!",
"function_exists",
"(",
"'mb_strwidth'",
")",
"||",
"(",
"$",
"string",
"&&",
"false",
"===",
"(",
"$",
"_encoding",
"=",
"mb_detect_encoding",
"(",
"$",
"string",
")",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"$",
"_encoding",
";",
"}"
] | Checks if multi-byte is available and returns encoding of optional string. False otherwise.
@param string $string
@return bool|string | [
"Checks",
"if",
"multi",
"-",
"byte",
"is",
"available",
"and",
"returns",
"encoding",
"of",
"optional",
"string",
".",
"False",
"otherwise",
"."
] | 4cc9954249da4e535b52f154e728935f07e648ae | https://github.com/lucifurious/kisma/blob/4cc9954249da4e535b52f154e728935f07e648ae/src/Kisma/Core/Utility/Scalar.php#L459-L469 |
8,804 | synga-nl/inheritance-finder | src/Parser/PhpClassParser.php | PhpClassParser.parse | public function parse(PhpClass $phpClass, SplFileInfo $fileInfo) {
try {
$this->nodeVisitor->setPhpClass($phpClass);
$this->traverse($fileInfo->getContents(), [$this->nodeVisitor]);
$phpClass->setFile($fileInfo);
$phpClass->setLastModified((new \DateTime())->setTimestamp($fileInfo->getMTime()));
} catch (\Exception $e) {
return false;
}
if($phpClass->isValid()){
return $phpClass;
}
return false;
} | php | public function parse(PhpClass $phpClass, SplFileInfo $fileInfo) {
try {
$this->nodeVisitor->setPhpClass($phpClass);
$this->traverse($fileInfo->getContents(), [$this->nodeVisitor]);
$phpClass->setFile($fileInfo);
$phpClass->setLastModified((new \DateTime())->setTimestamp($fileInfo->getMTime()));
} catch (\Exception $e) {
return false;
}
if($phpClass->isValid()){
return $phpClass;
}
return false;
} | [
"public",
"function",
"parse",
"(",
"PhpClass",
"$",
"phpClass",
",",
"SplFileInfo",
"$",
"fileInfo",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"nodeVisitor",
"->",
"setPhpClass",
"(",
"$",
"phpClass",
")",
";",
"$",
"this",
"->",
"traverse",
"(",
"$",
"fileInfo",
"->",
"getContents",
"(",
")",
",",
"[",
"$",
"this",
"->",
"nodeVisitor",
"]",
")",
";",
"$",
"phpClass",
"->",
"setFile",
"(",
"$",
"fileInfo",
")",
";",
"$",
"phpClass",
"->",
"setLastModified",
"(",
"(",
"new",
"\\",
"DateTime",
"(",
")",
")",
"->",
"setTimestamp",
"(",
"$",
"fileInfo",
"->",
"getMTime",
"(",
")",
")",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"phpClass",
"->",
"isValid",
"(",
")",
")",
"{",
"return",
"$",
"phpClass",
";",
"}",
"return",
"false",
";",
"}"
] | Builds the cache
@param PhpClass $phpClass
@param SplFileInfo $fileInfo
@return \Synga\InheritanceFinder\PhpClass[] | [
"Builds",
"the",
"cache"
] | 52669ac662b58dfeb6142b2e1bffbfba6f17d4b0 | https://github.com/synga-nl/inheritance-finder/blob/52669ac662b58dfeb6142b2e1bffbfba6f17d4b0/src/Parser/PhpClassParser.php#L43-L61 |
8,805 | synga-nl/inheritance-finder | src/Parser/PhpClassParser.php | PhpClassParser.traverse | protected function traverse($content, array $nodeVisitors = []) {
$nodes = $this->phpParser->parse($content);
$traverser = new NodeTraverser;
$traverser->addVisitor(new NameResolver());
foreach ($nodeVisitors as $nodeVisitor) {
$traverser->addVisitor($nodeVisitor);
}
$traverser->traverse($nodes);
} | php | protected function traverse($content, array $nodeVisitors = []) {
$nodes = $this->phpParser->parse($content);
$traverser = new NodeTraverser;
$traverser->addVisitor(new NameResolver());
foreach ($nodeVisitors as $nodeVisitor) {
$traverser->addVisitor($nodeVisitor);
}
$traverser->traverse($nodes);
} | [
"protected",
"function",
"traverse",
"(",
"$",
"content",
",",
"array",
"$",
"nodeVisitors",
"=",
"[",
"]",
")",
"{",
"$",
"nodes",
"=",
"$",
"this",
"->",
"phpParser",
"->",
"parse",
"(",
"$",
"content",
")",
";",
"$",
"traverser",
"=",
"new",
"NodeTraverser",
";",
"$",
"traverser",
"->",
"addVisitor",
"(",
"new",
"NameResolver",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"nodeVisitors",
"as",
"$",
"nodeVisitor",
")",
"{",
"$",
"traverser",
"->",
"addVisitor",
"(",
"$",
"nodeVisitor",
")",
";",
"}",
"$",
"traverser",
"->",
"traverse",
"(",
"$",
"nodes",
")",
";",
"}"
] | Traverse the parser nodes so we can extract the information
@param $content
@param array $nodeVisitors
@internal param bool $addInterface | [
"Traverse",
"the",
"parser",
"nodes",
"so",
"we",
"can",
"extract",
"the",
"information"
] | 52669ac662b58dfeb6142b2e1bffbfba6f17d4b0 | https://github.com/synga-nl/inheritance-finder/blob/52669ac662b58dfeb6142b2e1bffbfba6f17d4b0/src/Parser/PhpClassParser.php#L70-L81 |
8,806 | asbsoft/yii2module-news_1b_160430 | models/News.php | News.correctSavedData | protected function correctSavedData($insert)
{
if ($insert) {
$tzShiftSec = intval(date('Z')); // server time zone shift in seconds: west UTC <0, east UTC >0
if (!empty($tzShiftSec)) {//var_dump($tzShiftSec);exit;
$now = new Expression("DATE_SUB(NOW(), INTERVAL {$tzShiftSec} SECOND)"); // UTC time
} else {
$now = new Expression('NOW()'); // server time
}
$this->create_time = $now;
if (empty($this->show_from_time)) $this->show_from_time = $now;
$this->owner_id = Yii::$app->user->identity->id;
} else {
/*
// this corrections move to controller to POST preprocessing
if (!empty($this->timezoneshift)) {//var_dump($this->attributes);var_dump($this->timezoneshift);
$tz = intval($this->timezoneshift);
$this->show_from_time = new Expression("DATE_ADD('{$this->show_from_time}', INTERVAL {$tz} MINUTE)");
$this->show_to_time = new Expression("DATE_ADD('{$this->show_to_time}', INTERVAL {$tz} MINUTE)");
}//var_dump($this->attributes);exit;
*/
}
} | php | protected function correctSavedData($insert)
{
if ($insert) {
$tzShiftSec = intval(date('Z')); // server time zone shift in seconds: west UTC <0, east UTC >0
if (!empty($tzShiftSec)) {//var_dump($tzShiftSec);exit;
$now = new Expression("DATE_SUB(NOW(), INTERVAL {$tzShiftSec} SECOND)"); // UTC time
} else {
$now = new Expression('NOW()'); // server time
}
$this->create_time = $now;
if (empty($this->show_from_time)) $this->show_from_time = $now;
$this->owner_id = Yii::$app->user->identity->id;
} else {
/*
// this corrections move to controller to POST preprocessing
if (!empty($this->timezoneshift)) {//var_dump($this->attributes);var_dump($this->timezoneshift);
$tz = intval($this->timezoneshift);
$this->show_from_time = new Expression("DATE_ADD('{$this->show_from_time}', INTERVAL {$tz} MINUTE)");
$this->show_to_time = new Expression("DATE_ADD('{$this->show_to_time}', INTERVAL {$tz} MINUTE)");
}//var_dump($this->attributes);exit;
*/
}
} | [
"protected",
"function",
"correctSavedData",
"(",
"$",
"insert",
")",
"{",
"if",
"(",
"$",
"insert",
")",
"{",
"$",
"tzShiftSec",
"=",
"intval",
"(",
"date",
"(",
"'Z'",
")",
")",
";",
"// server time zone shift in seconds: west UTC <0, east UTC >0",
"if",
"(",
"!",
"empty",
"(",
"$",
"tzShiftSec",
")",
")",
"{",
"//var_dump($tzShiftSec);exit;",
"$",
"now",
"=",
"new",
"Expression",
"(",
"\"DATE_SUB(NOW(), INTERVAL {$tzShiftSec} SECOND)\"",
")",
";",
"// UTC time",
"}",
"else",
"{",
"$",
"now",
"=",
"new",
"Expression",
"(",
"'NOW()'",
")",
";",
"// server time",
"}",
"$",
"this",
"->",
"create_time",
"=",
"$",
"now",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"show_from_time",
")",
")",
"$",
"this",
"->",
"show_from_time",
"=",
"$",
"now",
";",
"$",
"this",
"->",
"owner_id",
"=",
"Yii",
"::",
"$",
"app",
"->",
"user",
"->",
"identity",
"->",
"id",
";",
"}",
"else",
"{",
"/*\n // this corrections move to controller to POST preprocessing\n if (!empty($this->timezoneshift)) {//var_dump($this->attributes);var_dump($this->timezoneshift);\n $tz = intval($this->timezoneshift);\n $this->show_from_time = new Expression(\"DATE_ADD('{$this->show_from_time}', INTERVAL {$tz} MINUTE)\");\n $this->show_to_time = new Expression(\"DATE_ADD('{$this->show_to_time}', INTERVAL {$tz} MINUTE)\");\n }//var_dump($this->attributes);exit;\n*/",
"}",
"}"
] | Data correction immediatly before save.
Datetime fields will convert into Expression-class. | [
"Data",
"correction",
"immediatly",
"before",
"save",
".",
"Datetime",
"fields",
"will",
"convert",
"into",
"Expression",
"-",
"class",
"."
] | ce64b1e70c5a57b572921945cc51384087905461 | https://github.com/asbsoft/yii2module-news_1b_160430/blob/ce64b1e70c5a57b572921945cc51384087905461/models/News.php#L147-L170 |
8,807 | asbsoft/yii2module-news_1b_160430 | models/News.php | News.prepareI18nModels | public static function prepareI18nModels($model)
{//echo __METHOD__;var_dump($model->attributes);
//$languages = LangHelper::activeLanguages();//var_dump($languages);
//$config = Module::getModuleConfigByClassname(Module::className());//var_dump($config);
//$langHelper = $config['params']['langHelper'];
$moduleClass = static::moduleClass();//var_dump($module);exit;
if (!$moduleClass) $moduleClass = Module::className(); //?? or better throw new \Exception("Can't found module for " . static::className());
$module = UniModule::getModuleByClassname($moduleClass);
$langHelper = $module->langHelper;
//$languages = $langHelper::activeLanguages();//var_dump($languages);
$editAllLanguages = empty($module->params['editAllLanguages']) ? false : $module->params['editAllLanguages'];
$languages = $langHelper::activeLanguages($editAllLanguages);//var_dump($languages);exit;
$mI18n = $model->i18n;//var_dump($mI18n);exit;
//$conf = Module::getModuleConfigByClassname(Module::className());//var_dump($conf);
//$contentHelperClass = $conf['params']['contentHelper'];
//$module = Module::getModuleByClassname(Module::className());
//$contentHelperClass = $module->contentHelper;
//$contentHelper = new $contentHelperClass;
$modelsI18n = [];
foreach ($mI18n as $modelI18n) {//var_dump($modelI18n->attributes);
//$modelI18n->body = $contentHelper::afterSelectBody($modelI18n->body); //!! move to self::correctI18nBodies()
$modelsI18n[$modelI18n->lang_code] = $modelI18n;
}
$modelsI18n = static::correctI18nBodies($modelsI18n);//var_dump($modelsI18n);exit;
foreach ($languages as $langCode => $lang) {
if (empty($modelsI18n[$langCode])) {
//$modelsI18n[$langCode] = (new NewsI18n())->loadDefaultValues();
$newNewsI18n = $module::model('NewsI18n');//var_dump($newNewsI18n);exit;
$modelsI18n[$langCode] = $newNewsI18n->loadDefaultValues();
$modelsI18n[$langCode]->lang_code = $langCode;
}
}//var_dump($modelsI18n);exit;
return $modelsI18n;
} | php | public static function prepareI18nModels($model)
{//echo __METHOD__;var_dump($model->attributes);
//$languages = LangHelper::activeLanguages();//var_dump($languages);
//$config = Module::getModuleConfigByClassname(Module::className());//var_dump($config);
//$langHelper = $config['params']['langHelper'];
$moduleClass = static::moduleClass();//var_dump($module);exit;
if (!$moduleClass) $moduleClass = Module::className(); //?? or better throw new \Exception("Can't found module for " . static::className());
$module = UniModule::getModuleByClassname($moduleClass);
$langHelper = $module->langHelper;
//$languages = $langHelper::activeLanguages();//var_dump($languages);
$editAllLanguages = empty($module->params['editAllLanguages']) ? false : $module->params['editAllLanguages'];
$languages = $langHelper::activeLanguages($editAllLanguages);//var_dump($languages);exit;
$mI18n = $model->i18n;//var_dump($mI18n);exit;
//$conf = Module::getModuleConfigByClassname(Module::className());//var_dump($conf);
//$contentHelperClass = $conf['params']['contentHelper'];
//$module = Module::getModuleByClassname(Module::className());
//$contentHelperClass = $module->contentHelper;
//$contentHelper = new $contentHelperClass;
$modelsI18n = [];
foreach ($mI18n as $modelI18n) {//var_dump($modelI18n->attributes);
//$modelI18n->body = $contentHelper::afterSelectBody($modelI18n->body); //!! move to self::correctI18nBodies()
$modelsI18n[$modelI18n->lang_code] = $modelI18n;
}
$modelsI18n = static::correctI18nBodies($modelsI18n);//var_dump($modelsI18n);exit;
foreach ($languages as $langCode => $lang) {
if (empty($modelsI18n[$langCode])) {
//$modelsI18n[$langCode] = (new NewsI18n())->loadDefaultValues();
$newNewsI18n = $module::model('NewsI18n');//var_dump($newNewsI18n);exit;
$modelsI18n[$langCode] = $newNewsI18n->loadDefaultValues();
$modelsI18n[$langCode]->lang_code = $langCode;
}
}//var_dump($modelsI18n);exit;
return $modelsI18n;
} | [
"public",
"static",
"function",
"prepareI18nModels",
"(",
"$",
"model",
")",
"{",
"//echo __METHOD__;var_dump($model->attributes);",
"//$languages = LangHelper::activeLanguages();//var_dump($languages);",
"//$config = Module::getModuleConfigByClassname(Module::className());//var_dump($config);",
"//$langHelper = $config['params']['langHelper'];",
"$",
"moduleClass",
"=",
"static",
"::",
"moduleClass",
"(",
")",
";",
"//var_dump($module);exit;",
"if",
"(",
"!",
"$",
"moduleClass",
")",
"$",
"moduleClass",
"=",
"Module",
"::",
"className",
"(",
")",
";",
"//?? or better throw new \\Exception(\"Can't found module for \" . static::className());",
"$",
"module",
"=",
"UniModule",
"::",
"getModuleByClassname",
"(",
"$",
"moduleClass",
")",
";",
"$",
"langHelper",
"=",
"$",
"module",
"->",
"langHelper",
";",
"//$languages = $langHelper::activeLanguages();//var_dump($languages);",
"$",
"editAllLanguages",
"=",
"empty",
"(",
"$",
"module",
"->",
"params",
"[",
"'editAllLanguages'",
"]",
")",
"?",
"false",
":",
"$",
"module",
"->",
"params",
"[",
"'editAllLanguages'",
"]",
";",
"$",
"languages",
"=",
"$",
"langHelper",
"::",
"activeLanguages",
"(",
"$",
"editAllLanguages",
")",
";",
"//var_dump($languages);exit;",
"$",
"mI18n",
"=",
"$",
"model",
"->",
"i18n",
";",
"//var_dump($mI18n);exit;",
"//$conf = Module::getModuleConfigByClassname(Module::className());//var_dump($conf);",
"//$contentHelperClass = $conf['params']['contentHelper'];",
"//$module = Module::getModuleByClassname(Module::className());",
"//$contentHelperClass = $module->contentHelper;",
"//$contentHelper = new $contentHelperClass;",
"$",
"modelsI18n",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"mI18n",
"as",
"$",
"modelI18n",
")",
"{",
"//var_dump($modelI18n->attributes);",
"//$modelI18n->body = $contentHelper::afterSelectBody($modelI18n->body); //!! move to self::correctI18nBodies()",
"$",
"modelsI18n",
"[",
"$",
"modelI18n",
"->",
"lang_code",
"]",
"=",
"$",
"modelI18n",
";",
"}",
"$",
"modelsI18n",
"=",
"static",
"::",
"correctI18nBodies",
"(",
"$",
"modelsI18n",
")",
";",
"//var_dump($modelsI18n);exit;",
"foreach",
"(",
"$",
"languages",
"as",
"$",
"langCode",
"=>",
"$",
"lang",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"modelsI18n",
"[",
"$",
"langCode",
"]",
")",
")",
"{",
"//$modelsI18n[$langCode] = (new NewsI18n())->loadDefaultValues();",
"$",
"newNewsI18n",
"=",
"$",
"module",
"::",
"model",
"(",
"'NewsI18n'",
")",
";",
"//var_dump($newNewsI18n);exit;",
"$",
"modelsI18n",
"[",
"$",
"langCode",
"]",
"=",
"$",
"newNewsI18n",
"->",
"loadDefaultValues",
"(",
")",
";",
"$",
"modelsI18n",
"[",
"$",
"langCode",
"]",
"->",
"lang_code",
"=",
"$",
"langCode",
";",
"}",
"}",
"//var_dump($modelsI18n);exit;",
"return",
"$",
"modelsI18n",
";",
"}"
] | Prepare multilang models array.
@return array of NewsI18n | [
"Prepare",
"multilang",
"models",
"array",
"."
] | ce64b1e70c5a57b572921945cc51384087905461 | https://github.com/asbsoft/yii2module-news_1b_160430/blob/ce64b1e70c5a57b572921945cc51384087905461/models/News.php#L291-L330 |
8,808 | asbsoft/yii2module-news_1b_160430 | models/News.php | News.correctI18nBodies | public static function correctI18nBodies($modelsI18n)
{
$module = Module::getModuleByClassname(Module::className());
$contentHelperClass = $module->contentHelper;
foreach ($modelsI18n as $modelI18n) {//var_dump($modelI18n->attributes);exit;
$modelI18n->body = $contentHelperClass::afterSelectBody($modelI18n->body);
}
return $modelsI18n;
} | php | public static function correctI18nBodies($modelsI18n)
{
$module = Module::getModuleByClassname(Module::className());
$contentHelperClass = $module->contentHelper;
foreach ($modelsI18n as $modelI18n) {//var_dump($modelI18n->attributes);exit;
$modelI18n->body = $contentHelperClass::afterSelectBody($modelI18n->body);
}
return $modelsI18n;
} | [
"public",
"static",
"function",
"correctI18nBodies",
"(",
"$",
"modelsI18n",
")",
"{",
"$",
"module",
"=",
"Module",
"::",
"getModuleByClassname",
"(",
"Module",
"::",
"className",
"(",
")",
")",
";",
"$",
"contentHelperClass",
"=",
"$",
"module",
"->",
"contentHelper",
";",
"foreach",
"(",
"$",
"modelsI18n",
"as",
"$",
"modelI18n",
")",
"{",
"//var_dump($modelI18n->attributes);exit;",
"$",
"modelI18n",
"->",
"body",
"=",
"$",
"contentHelperClass",
"::",
"afterSelectBody",
"(",
"$",
"modelI18n",
"->",
"body",
")",
";",
"}",
"return",
"$",
"modelsI18n",
";",
"}"
] | Use ContentHelper to correct texts after visual editor.
Need as independent method to repeat run after unsuccessful validation. | [
"Use",
"ContentHelper",
"to",
"correct",
"texts",
"after",
"visual",
"editor",
".",
"Need",
"as",
"independent",
"method",
"to",
"repeat",
"run",
"after",
"unsuccessful",
"validation",
"."
] | ce64b1e70c5a57b572921945cc51384087905461 | https://github.com/asbsoft/yii2module-news_1b_160430/blob/ce64b1e70c5a57b572921945cc51384087905461/models/News.php#L336-L345 |
8,809 | asbsoft/yii2module-news_1b_160430 | models/News.php | News.deleteFiles | protected function deleteFiles($id)
{//echo __METHOD__."($id)";
$subdir = static::getImageSubdir($id);
if (!empty($this->module->params['uploadsNewsDir'])) {
$uploadsDir = Yii::getAlias($this->module->params['uploadsNewsDir']) . '/' . $subdir;//var_dump($uploadsDir);
//@FileHelper::removeDirectory($uploadsDir);
rename($uploadsDir, $uploadsDir . '~remove~' . date('ymd~His') . '~');
}
if (array_key_exists('@webfilespath', Yii::$aliases) && !empty($this->module->params['filesSubpath'])) {
$webfilesDir = Yii::getAlias('@webfilespath') . '/' . $this->module->params['filesSubpath'] . '/' . $subdir;//var_dump($webfilesDir);
@FileHelper::removeDirectory($webfilesDir);
}
//?! Yii2-advanced temblate has 2 web roots. Here delete only one.
} | php | protected function deleteFiles($id)
{//echo __METHOD__."($id)";
$subdir = static::getImageSubdir($id);
if (!empty($this->module->params['uploadsNewsDir'])) {
$uploadsDir = Yii::getAlias($this->module->params['uploadsNewsDir']) . '/' . $subdir;//var_dump($uploadsDir);
//@FileHelper::removeDirectory($uploadsDir);
rename($uploadsDir, $uploadsDir . '~remove~' . date('ymd~His') . '~');
}
if (array_key_exists('@webfilespath', Yii::$aliases) && !empty($this->module->params['filesSubpath'])) {
$webfilesDir = Yii::getAlias('@webfilespath') . '/' . $this->module->params['filesSubpath'] . '/' . $subdir;//var_dump($webfilesDir);
@FileHelper::removeDirectory($webfilesDir);
}
//?! Yii2-advanced temblate has 2 web roots. Here delete only one.
} | [
"protected",
"function",
"deleteFiles",
"(",
"$",
"id",
")",
"{",
"//echo __METHOD__.\"($id)\";",
"$",
"subdir",
"=",
"static",
"::",
"getImageSubdir",
"(",
"$",
"id",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"module",
"->",
"params",
"[",
"'uploadsNewsDir'",
"]",
")",
")",
"{",
"$",
"uploadsDir",
"=",
"Yii",
"::",
"getAlias",
"(",
"$",
"this",
"->",
"module",
"->",
"params",
"[",
"'uploadsNewsDir'",
"]",
")",
".",
"'/'",
".",
"$",
"subdir",
";",
"//var_dump($uploadsDir);",
"//@FileHelper::removeDirectory($uploadsDir);",
"rename",
"(",
"$",
"uploadsDir",
",",
"$",
"uploadsDir",
".",
"'~remove~'",
".",
"date",
"(",
"'ymd~His'",
")",
".",
"'~'",
")",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"'@webfilespath'",
",",
"Yii",
"::",
"$",
"aliases",
")",
"&&",
"!",
"empty",
"(",
"$",
"this",
"->",
"module",
"->",
"params",
"[",
"'filesSubpath'",
"]",
")",
")",
"{",
"$",
"webfilesDir",
"=",
"Yii",
"::",
"getAlias",
"(",
"'@webfilespath'",
")",
".",
"'/'",
".",
"$",
"this",
"->",
"module",
"->",
"params",
"[",
"'filesSubpath'",
"]",
".",
"'/'",
".",
"$",
"subdir",
";",
"//var_dump($webfilesDir);",
"@",
"FileHelper",
"::",
"removeDirectory",
"(",
"$",
"webfilesDir",
")",
";",
"}",
"//?! Yii2-advanced temblate has 2 web roots. Here delete only one.",
"}"
] | Delete uploaded files connected with the model.
@param integet $id model id | [
"Delete",
"uploaded",
"files",
"connected",
"with",
"the",
"model",
"."
] | ce64b1e70c5a57b572921945cc51384087905461 | https://github.com/asbsoft/yii2module-news_1b_160430/blob/ce64b1e70c5a57b572921945cc51384087905461/models/News.php#L381-L394 |
8,810 | indigophp-archive/codeception-fuel-module | fuel/fuel/core/classes/session/redis.php | Session_Redis._write_redis | protected function _write_redis($session_id, $payload)
{
// write it to the redis server
$this->redis->set($session_id, $payload);
$this->redis->expire($session_id, $this->config['expiration_time']);
} | php | protected function _write_redis($session_id, $payload)
{
// write it to the redis server
$this->redis->set($session_id, $payload);
$this->redis->expire($session_id, $this->config['expiration_time']);
} | [
"protected",
"function",
"_write_redis",
"(",
"$",
"session_id",
",",
"$",
"payload",
")",
"{",
"// write it to the redis server",
"$",
"this",
"->",
"redis",
"->",
"set",
"(",
"$",
"session_id",
",",
"$",
"payload",
")",
";",
"$",
"this",
"->",
"redis",
"->",
"expire",
"(",
"$",
"session_id",
",",
"$",
"this",
"->",
"config",
"[",
"'expiration_time'",
"]",
")",
";",
"}"
] | Writes the redis entry
@access private
@return boolean, true if it was an existing session, false if not | [
"Writes",
"the",
"redis",
"entry"
] | 0973b7cbd540a0e89cc5bb7af94627f77f09bf49 | https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/session/redis.php#L233-L238 |
8,811 | kirkbowers/sphec | src/Context.php | Context.describe | public function describe($label, $block) {
return $this->_tests[] = new Context($label, $block, $this->_indent . ' ', $this);
} | php | public function describe($label, $block) {
return $this->_tests[] = new Context($label, $block, $this->_indent . ' ', $this);
} | [
"public",
"function",
"describe",
"(",
"$",
"label",
",",
"$",
"block",
")",
"{",
"return",
"$",
"this",
"->",
"_tests",
"[",
"]",
"=",
"new",
"Context",
"(",
"$",
"label",
",",
"$",
"block",
",",
"$",
"this",
"->",
"_indent",
".",
"' '",
",",
"$",
"this",
")",
";",
"}"
] | Creates a new subcontext.
Usually this is used to group together tests on a sub-feature such as a method of
a class.
@param $label A string label of what is being described.
@param $block An anonymous function that performs all the specifying and testing
for this subcontext. It should take one parameter, which will be this Context
instance that can perform all
the mojo that a Context does (describe, it, etc.). | [
"Creates",
"a",
"new",
"subcontext",
"."
] | e1b849aac683fd07eae2e344faad0a00f559e1eb | https://github.com/kirkbowers/sphec/blob/e1b849aac683fd07eae2e344faad0a00f559e1eb/src/Context.php#L38-L40 |
8,812 | kirkbowers/sphec | src/Context.php | Context.it | public function it($label, $block) {
return $this->_tests[] = new Example($label, $block, $this->_indent . ' ', $this);
} | php | public function it($label, $block) {
return $this->_tests[] = new Example($label, $block, $this->_indent . ' ', $this);
} | [
"public",
"function",
"it",
"(",
"$",
"label",
",",
"$",
"block",
")",
"{",
"return",
"$",
"this",
"->",
"_tests",
"[",
"]",
"=",
"new",
"Example",
"(",
"$",
"label",
",",
"$",
"block",
",",
"$",
"this",
"->",
"_indent",
".",
"' '",
",",
"$",
"this",
")",
";",
"}"
] | Creates a new example.
This is where individual tests are performed. The label should describe
what is to be expected in this test in a sentence that follows "it".
(Eg. "It" "should evaluate to true in this situation.")
@param $label A string label of what is being expected.
@param $block An anonymous function that performs all the testing
for this example. It should take one parameter, which will be the Example
instance that can perform `expect` methods. | [
"Creates",
"a",
"new",
"example",
"."
] | e1b849aac683fd07eae2e344faad0a00f559e1eb | https://github.com/kirkbowers/sphec/blob/e1b849aac683fd07eae2e344faad0a00f559e1eb/src/Context.php#L95-L97 |
8,813 | kirkbowers/sphec | src/Context.php | Context.run | public function run() {
if ($this->_expector->output && $this->_expector->output->isVerbose()) {
$this->_expector->output->writeln($this->_indent . $this->_label);
}
foreach ($this->_tests as $test) {
$test->run();
}
} | php | public function run() {
if ($this->_expector->output && $this->_expector->output->isVerbose()) {
$this->_expector->output->writeln($this->_indent . $this->_label);
}
foreach ($this->_tests as $test) {
$test->run();
}
} | [
"public",
"function",
"run",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_expector",
"->",
"output",
"&&",
"$",
"this",
"->",
"_expector",
"->",
"output",
"->",
"isVerbose",
"(",
")",
")",
"{",
"$",
"this",
"->",
"_expector",
"->",
"output",
"->",
"writeln",
"(",
"$",
"this",
"->",
"_indent",
".",
"$",
"this",
"->",
"_label",
")",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"_tests",
"as",
"$",
"test",
")",
"{",
"$",
"test",
"->",
"run",
"(",
")",
";",
"}",
"}"
] | Runs all the tests in this scope. | [
"Runs",
"all",
"the",
"tests",
"in",
"this",
"scope",
"."
] | e1b849aac683fd07eae2e344faad0a00f559e1eb | https://github.com/kirkbowers/sphec/blob/e1b849aac683fd07eae2e344faad0a00f559e1eb/src/Context.php#L136-L144 |
8,814 | marando/phpSOFA | src/Marando/IAU/iauC2ixys.php | iauC2ixys.C2ixys | public static function C2ixys($x, $y, $s, array &$rc2i) {
$r2;
$e;
$d;
/* Obtain the spherical angles E and d. */
$r2 = $x * $x + $y * $y;
$e = ($r2 > 0.0) ? atan2($y, $x) : 0.0;
$d = atan(sqrt($r2 / (1.0 - $r2)));
/* Form the matrix. */
IAU::Ir($rc2i);
IAU::Rz($e, $rc2i);
IAU::Ry($d, $rc2i);
IAU::Rz(-($e + $s), $rc2i);
return;
} | php | public static function C2ixys($x, $y, $s, array &$rc2i) {
$r2;
$e;
$d;
/* Obtain the spherical angles E and d. */
$r2 = $x * $x + $y * $y;
$e = ($r2 > 0.0) ? atan2($y, $x) : 0.0;
$d = atan(sqrt($r2 / (1.0 - $r2)));
/* Form the matrix. */
IAU::Ir($rc2i);
IAU::Rz($e, $rc2i);
IAU::Ry($d, $rc2i);
IAU::Rz(-($e + $s), $rc2i);
return;
} | [
"public",
"static",
"function",
"C2ixys",
"(",
"$",
"x",
",",
"$",
"y",
",",
"$",
"s",
",",
"array",
"&",
"$",
"rc2i",
")",
"{",
"$",
"r2",
";",
"$",
"e",
";",
"$",
"d",
";",
"/* Obtain the spherical angles E and d. */",
"$",
"r2",
"=",
"$",
"x",
"*",
"$",
"x",
"+",
"$",
"y",
"*",
"$",
"y",
";",
"$",
"e",
"=",
"(",
"$",
"r2",
">",
"0.0",
")",
"?",
"atan2",
"(",
"$",
"y",
",",
"$",
"x",
")",
":",
"0.0",
";",
"$",
"d",
"=",
"atan",
"(",
"sqrt",
"(",
"$",
"r2",
"/",
"(",
"1.0",
"-",
"$",
"r2",
")",
")",
")",
";",
"/* Form the matrix. */",
"IAU",
"::",
"Ir",
"(",
"$",
"rc2i",
")",
";",
"IAU",
"::",
"Rz",
"(",
"$",
"e",
",",
"$",
"rc2i",
")",
";",
"IAU",
"::",
"Ry",
"(",
"$",
"d",
",",
"$",
"rc2i",
")",
";",
"IAU",
"::",
"Rz",
"(",
"-",
"(",
"$",
"e",
"+",
"$",
"s",
")",
",",
"$",
"rc2i",
")",
";",
"return",
";",
"}"
] | - - - - - - - - - -
i a u C 2 i x y s
- - - - - - - - - -
Form the celestial to intermediate-frame-of-date matrix given the CIP
X,Y and the CIO locator s.
This function is part of the International Astronomical Union's
SOFA (Standards Of Fundamental Astronomy) software collection.
Status: support function.
Given:
x,y double Celestial Intermediate Pole (Note 1)
s double the CIO locator s (Note 2)
Returned:
rc2i double[3][3] celestial-to-intermediate matrix (Note 3)
Notes:
1) The Celestial Intermediate Pole coordinates are the x,y
components of the unit vector in the Geocentric Celestial
Reference System.
2) The CIO locator s (in radians) positions the Celestial
Intermediate Origin on the equator of the CIP.
3) The matrix rc2i is the first stage in the transformation from
celestial to terrestrial coordinates:
[TRS] = RPOM * R_3(ERA) * rc2i * [CRS]
= RC2T * [CRS]
where [CRS] is a vector in the Geocentric Celestial Reference
System and [TRS] is a vector in the International Terrestrial
Reference System (see IERS Conventions 2003), ERA is the Earth
Rotation Angle and RPOM is the polar motion matrix.
Called:
iauIr initialize r-matrix to identity
iauRz rotate around Z-axis
iauRy rotate around Y-axis
Reference:
McCarthy, D. D., Petit, G. (eds.), IERS Conventions (2003),
IERS Technical Note No. 32, BKG (2004)
This revision: 2014 November 7
SOFA release 2015-02-09
Copyright (C) 2015 IAU SOFA Board. See notes at end. | [
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"i",
"a",
"u",
"C",
"2",
"i",
"x",
"y",
"s",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-"
] | 757fa49fe335ae1210eaa7735473fd4388b13f07 | https://github.com/marando/phpSOFA/blob/757fa49fe335ae1210eaa7735473fd4388b13f07/src/Marando/IAU/iauC2ixys.php#L64-L81 |
8,815 | hametuha/hametwoo | src/Hametuha/HametWoo/Utility/UniqueId.php | UniqueId.generate | public static function generate( $length = 16 ) {
if ( function_exists( 'random_bytes' ) ) {
return bin2hex( random_bytes( $length ) );
} elseif ( function_exists( 'openssl_random_pseudo_bytes' ) ) {
return bin2hex( openssl_random_pseudo_bytes( $length ) );
} else {
$id = uniqid();
$hash = '';
$str_len = strlen( $id );
$limit = floor( $length * 2 / $str_len );
for ( $i = 0; $i < $limit; $i++ ) {
$hash .= $id;
}
$remainder = strlen( $id ) / ( $length * 2 );
if ( $remainder ) {
$hash .= substr( $id, 0, $remainder );
}
return $hash;
}
} | php | public static function generate( $length = 16 ) {
if ( function_exists( 'random_bytes' ) ) {
return bin2hex( random_bytes( $length ) );
} elseif ( function_exists( 'openssl_random_pseudo_bytes' ) ) {
return bin2hex( openssl_random_pseudo_bytes( $length ) );
} else {
$id = uniqid();
$hash = '';
$str_len = strlen( $id );
$limit = floor( $length * 2 / $str_len );
for ( $i = 0; $i < $limit; $i++ ) {
$hash .= $id;
}
$remainder = strlen( $id ) / ( $length * 2 );
if ( $remainder ) {
$hash .= substr( $id, 0, $remainder );
}
return $hash;
}
} | [
"public",
"static",
"function",
"generate",
"(",
"$",
"length",
"=",
"16",
")",
"{",
"if",
"(",
"function_exists",
"(",
"'random_bytes'",
")",
")",
"{",
"return",
"bin2hex",
"(",
"random_bytes",
"(",
"$",
"length",
")",
")",
";",
"}",
"elseif",
"(",
"function_exists",
"(",
"'openssl_random_pseudo_bytes'",
")",
")",
"{",
"return",
"bin2hex",
"(",
"openssl_random_pseudo_bytes",
"(",
"$",
"length",
")",
")",
";",
"}",
"else",
"{",
"$",
"id",
"=",
"uniqid",
"(",
")",
";",
"$",
"hash",
"=",
"''",
";",
"$",
"str_len",
"=",
"strlen",
"(",
"$",
"id",
")",
";",
"$",
"limit",
"=",
"floor",
"(",
"$",
"length",
"*",
"2",
"/",
"$",
"str_len",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"limit",
";",
"$",
"i",
"++",
")",
"{",
"$",
"hash",
".=",
"$",
"id",
";",
"}",
"$",
"remainder",
"=",
"strlen",
"(",
"$",
"id",
")",
"/",
"(",
"$",
"length",
"*",
"2",
")",
";",
"if",
"(",
"$",
"remainder",
")",
"{",
"$",
"hash",
".=",
"substr",
"(",
"$",
"id",
",",
"0",
",",
"$",
"remainder",
")",
";",
"}",
"return",
"$",
"hash",
";",
"}",
"}"
] | Generate unique ID
@param int $length Length of id. Default 16.
@return string | [
"Generate",
"unique",
"ID"
] | bcd5948ea53d6ca2181873a9f9d0d221c346592e | https://github.com/hametuha/hametwoo/blob/bcd5948ea53d6ca2181873a9f9d0d221c346592e/src/Hametuha/HametWoo/Utility/UniqueId.php#L27-L46 |
8,816 | cawaphp/module-swagger-server | src/ExamplesService/Type.php | Type.string | public function string(int $length = 8)
{
$list = 'abcdefghijklmnopqrstuvwxyz';
$return = '';
for ($i = 0; $i < $length; $i++) {
$return .= $list[rand(0, strlen($list) - 1)];
}
return $return;
} | php | public function string(int $length = 8)
{
$list = 'abcdefghijklmnopqrstuvwxyz';
$return = '';
for ($i = 0; $i < $length; $i++) {
$return .= $list[rand(0, strlen($list) - 1)];
}
return $return;
} | [
"public",
"function",
"string",
"(",
"int",
"$",
"length",
"=",
"8",
")",
"{",
"$",
"list",
"=",
"'abcdefghijklmnopqrstuvwxyz'",
";",
"$",
"return",
"=",
"''",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"length",
";",
"$",
"i",
"++",
")",
"{",
"$",
"return",
".=",
"$",
"list",
"[",
"rand",
"(",
"0",
",",
"strlen",
"(",
"$",
"list",
")",
"-",
"1",
")",
"]",
";",
"}",
"return",
"$",
"return",
";",
"}"
] | Return a simple random string.
taken from character list : 0123456789abcdefghijklmnopqrstuvwxyz
@httpmethod GET
@auth None
@param int $length the length of generated string
@return string the generated random string | [
"Return",
"a",
"simple",
"random",
"string",
"."
] | 809d541254e8a839938bb49bcc9e91d61d0879a8 | https://github.com/cawaphp/module-swagger-server/blob/809d541254e8a839938bb49bcc9e91d61d0879a8/src/ExamplesService/Type.php#L34-L43 |
8,817 | cawaphp/module-swagger-server | src/ExamplesService/Type.php | Type.integer | public function integer(int $min, int $max)
{
if ($max < $min) {
throw new ResponseCode('max must be greater than min', 422);
}
return rand($min, $max);
} | php | public function integer(int $min, int $max)
{
if ($max < $min) {
throw new ResponseCode('max must be greater than min', 422);
}
return rand($min, $max);
} | [
"public",
"function",
"integer",
"(",
"int",
"$",
"min",
",",
"int",
"$",
"max",
")",
"{",
"if",
"(",
"$",
"max",
"<",
"$",
"min",
")",
"{",
"throw",
"new",
"ResponseCode",
"(",
"'max must be greater than min'",
",",
"422",
")",
";",
"}",
"return",
"rand",
"(",
"$",
"min",
",",
"$",
"max",
")",
";",
"}"
] | Return a random integer.
taken between $min and $max value
@httpmethod GET
@auth None
@param int $min the min value @validation(gte:0|lte:20)
@param int $max the max value @validation(gte:0|lt:20)
@throws ResponseCode 422 max must be greater than min
@return int | [
"Return",
"a",
"random",
"integer",
"."
] | 809d541254e8a839938bb49bcc9e91d61d0879a8 | https://github.com/cawaphp/module-swagger-server/blob/809d541254e8a839938bb49bcc9e91d61d0879a8/src/ExamplesService/Type.php#L60-L67 |
8,818 | cawaphp/module-swagger-server | src/ExamplesService/Type.php | Type.float | public function float(float $min, float $max)
{
if ($max < $min) {
throw new ResponseCode('max must be greater than min', 422);
}
return rand((int) $min * 100, (int) $max * 100) / 100;
} | php | public function float(float $min, float $max)
{
if ($max < $min) {
throw new ResponseCode('max must be greater than min', 422);
}
return rand((int) $min * 100, (int) $max * 100) / 100;
} | [
"public",
"function",
"float",
"(",
"float",
"$",
"min",
",",
"float",
"$",
"max",
")",
"{",
"if",
"(",
"$",
"max",
"<",
"$",
"min",
")",
"{",
"throw",
"new",
"ResponseCode",
"(",
"'max must be greater than min'",
",",
"422",
")",
";",
"}",
"return",
"rand",
"(",
"(",
"int",
")",
"$",
"min",
"*",
"100",
",",
"(",
"int",
")",
"$",
"max",
"*",
"100",
")",
"/",
"100",
";",
"}"
] | Return a random float.
with 2 decimal taken between $min and $max value
@httpmethod GET
@auth None
@param float $min the min value @validation(gte:0|lte:20)
@param float $max the max value @validation(gte:0|lt:20)
@throws ResponseCode 422 max must be greater than min
@return float the generated value | [
"Return",
"a",
"random",
"float",
"."
] | 809d541254e8a839938bb49bcc9e91d61d0879a8 | https://github.com/cawaphp/module-swagger-server/blob/809d541254e8a839938bb49bcc9e91d61d0879a8/src/ExamplesService/Type.php#L84-L91 |
8,819 | cawaphp/module-swagger-server | src/ExamplesService/Type.php | Type.object | public function object(float $min, float $max)
{
$populate = function (bool $extended = false) use ($min, $max) {
$class = 'Cawa\\SwaggerServer\\ExamplesService\\' . ($extended ? 'ObjectExtended' : 'Object');
$object = new $class();
$object->string = $this->String((int) $max);
if ($extended) {
$object->extendString = $this->String((int) $max);
}
$object->integer = $this->Integer((int) $min, (int) $max);
$object->float = $this->Float((int) $min, (int) $max);
$object->boolean = $this->Boolean();
$object->integerMap = [
$this->String((int) $max) => $this->Integer((int) $min, (int) $max),
$this->String((int) $max) => $this->Integer((int) $min, (int) $max),
$this->String((int) $max) => $this->Integer((int) $min, (int) $max),
];
$object->stringMap = [
$this->String((int) $max) => $this->String((int) $max),
$this->String((int) $max) => $this->String((int) $max),
$this->String((int) $max) => $this->String((int) $max),
];
$object->datetime = $this->Date(new DateTime());
return $object;
};
$return = $populate();
for ($i = 0; $i < 3; $i++) {
$object = $populate(true);
$return->objects[] = $object;
}
return $return;
} | php | public function object(float $min, float $max)
{
$populate = function (bool $extended = false) use ($min, $max) {
$class = 'Cawa\\SwaggerServer\\ExamplesService\\' . ($extended ? 'ObjectExtended' : 'Object');
$object = new $class();
$object->string = $this->String((int) $max);
if ($extended) {
$object->extendString = $this->String((int) $max);
}
$object->integer = $this->Integer((int) $min, (int) $max);
$object->float = $this->Float((int) $min, (int) $max);
$object->boolean = $this->Boolean();
$object->integerMap = [
$this->String((int) $max) => $this->Integer((int) $min, (int) $max),
$this->String((int) $max) => $this->Integer((int) $min, (int) $max),
$this->String((int) $max) => $this->Integer((int) $min, (int) $max),
];
$object->stringMap = [
$this->String((int) $max) => $this->String((int) $max),
$this->String((int) $max) => $this->String((int) $max),
$this->String((int) $max) => $this->String((int) $max),
];
$object->datetime = $this->Date(new DateTime());
return $object;
};
$return = $populate();
for ($i = 0; $i < 3; $i++) {
$object = $populate(true);
$return->objects[] = $object;
}
return $return;
} | [
"public",
"function",
"object",
"(",
"float",
"$",
"min",
",",
"float",
"$",
"max",
")",
"{",
"$",
"populate",
"=",
"function",
"(",
"bool",
"$",
"extended",
"=",
"false",
")",
"use",
"(",
"$",
"min",
",",
"$",
"max",
")",
"{",
"$",
"class",
"=",
"'Cawa\\\\SwaggerServer\\\\ExamplesService\\\\'",
".",
"(",
"$",
"extended",
"?",
"'ObjectExtended'",
":",
"'Object'",
")",
";",
"$",
"object",
"=",
"new",
"$",
"class",
"(",
")",
";",
"$",
"object",
"->",
"string",
"=",
"$",
"this",
"->",
"String",
"(",
"(",
"int",
")",
"$",
"max",
")",
";",
"if",
"(",
"$",
"extended",
")",
"{",
"$",
"object",
"->",
"extendString",
"=",
"$",
"this",
"->",
"String",
"(",
"(",
"int",
")",
"$",
"max",
")",
";",
"}",
"$",
"object",
"->",
"integer",
"=",
"$",
"this",
"->",
"Integer",
"(",
"(",
"int",
")",
"$",
"min",
",",
"(",
"int",
")",
"$",
"max",
")",
";",
"$",
"object",
"->",
"float",
"=",
"$",
"this",
"->",
"Float",
"(",
"(",
"int",
")",
"$",
"min",
",",
"(",
"int",
")",
"$",
"max",
")",
";",
"$",
"object",
"->",
"boolean",
"=",
"$",
"this",
"->",
"Boolean",
"(",
")",
";",
"$",
"object",
"->",
"integerMap",
"=",
"[",
"$",
"this",
"->",
"String",
"(",
"(",
"int",
")",
"$",
"max",
")",
"=>",
"$",
"this",
"->",
"Integer",
"(",
"(",
"int",
")",
"$",
"min",
",",
"(",
"int",
")",
"$",
"max",
")",
",",
"$",
"this",
"->",
"String",
"(",
"(",
"int",
")",
"$",
"max",
")",
"=>",
"$",
"this",
"->",
"Integer",
"(",
"(",
"int",
")",
"$",
"min",
",",
"(",
"int",
")",
"$",
"max",
")",
",",
"$",
"this",
"->",
"String",
"(",
"(",
"int",
")",
"$",
"max",
")",
"=>",
"$",
"this",
"->",
"Integer",
"(",
"(",
"int",
")",
"$",
"min",
",",
"(",
"int",
")",
"$",
"max",
")",
",",
"]",
";",
"$",
"object",
"->",
"stringMap",
"=",
"[",
"$",
"this",
"->",
"String",
"(",
"(",
"int",
")",
"$",
"max",
")",
"=>",
"$",
"this",
"->",
"String",
"(",
"(",
"int",
")",
"$",
"max",
")",
",",
"$",
"this",
"->",
"String",
"(",
"(",
"int",
")",
"$",
"max",
")",
"=>",
"$",
"this",
"->",
"String",
"(",
"(",
"int",
")",
"$",
"max",
")",
",",
"$",
"this",
"->",
"String",
"(",
"(",
"int",
")",
"$",
"max",
")",
"=>",
"$",
"this",
"->",
"String",
"(",
"(",
"int",
")",
"$",
"max",
")",
",",
"]",
";",
"$",
"object",
"->",
"datetime",
"=",
"$",
"this",
"->",
"Date",
"(",
"new",
"DateTime",
"(",
")",
")",
";",
"return",
"$",
"object",
";",
"}",
";",
"$",
"return",
"=",
"$",
"populate",
"(",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"3",
";",
"$",
"i",
"++",
")",
"{",
"$",
"object",
"=",
"$",
"populate",
"(",
"true",
")",
";",
"$",
"return",
"->",
"objects",
"[",
"]",
"=",
"$",
"object",
";",
"}",
"return",
"$",
"return",
";",
"}"
] | Return a random object.
with all possible primitive type
@httpmethod GET
@auth None
@param float $min the min value @validation(gte:0|lte:20)
@param float $max the max value @validation(gte:0|lt:20)
@throws ResponseCode 422 max must be greater than min
@return \Cawa\SwaggerServer\ExamplesService\Object | [
"Return",
"a",
"random",
"object",
"."
] | 809d541254e8a839938bb49bcc9e91d61d0879a8 | https://github.com/cawaphp/module-swagger-server/blob/809d541254e8a839938bb49bcc9e91d61d0879a8/src/ExamplesService/Type.php#L136-L172 |
8,820 | nowzoo/wp-utils | src/NowZoo/WPUtils/WPUtils.php | WPUtils.trim_stripslashes_deep | public static function trim_stripslashes_deep($value){
if ( is_array($value) ) {
$value = array_map(array(get_called_class(), 'trim_stripslashes_deep'), $value);
} elseif ( is_object($value) ) {
$vars = get_object_vars( $value );
foreach ($vars as $key=>$data) {
$value->{$key} = self::trim_stripslashes_deep( $data );
}
} elseif ( is_string( $value ) ) {
$value = trim(stripslashes($value));
}
return $value;
} | php | public static function trim_stripslashes_deep($value){
if ( is_array($value) ) {
$value = array_map(array(get_called_class(), 'trim_stripslashes_deep'), $value);
} elseif ( is_object($value) ) {
$vars = get_object_vars( $value );
foreach ($vars as $key=>$data) {
$value->{$key} = self::trim_stripslashes_deep( $data );
}
} elseif ( is_string( $value ) ) {
$value = trim(stripslashes($value));
}
return $value;
} | [
"public",
"static",
"function",
"trim_stripslashes_deep",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"array_map",
"(",
"array",
"(",
"get_called_class",
"(",
")",
",",
"'trim_stripslashes_deep'",
")",
",",
"$",
"value",
")",
";",
"}",
"elseif",
"(",
"is_object",
"(",
"$",
"value",
")",
")",
"{",
"$",
"vars",
"=",
"get_object_vars",
"(",
"$",
"value",
")",
";",
"foreach",
"(",
"$",
"vars",
"as",
"$",
"key",
"=>",
"$",
"data",
")",
"{",
"$",
"value",
"->",
"{",
"$",
"key",
"}",
"=",
"self",
"::",
"trim_stripslashes_deep",
"(",
"$",
"data",
")",
";",
"}",
"}",
"elseif",
"(",
"is_string",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"trim",
"(",
"stripslashes",
"(",
"$",
"value",
")",
")",
";",
"}",
"return",
"$",
"value",
";",
"}"
] | Provides a replacement for WP's native stripslashes_deep
function, which, frustratingly, doesn't trim
@param $value
@return array|object|string | [
"Provides",
"a",
"replacement",
"for",
"WP",
"s",
"native",
"stripslashes_deep",
"function",
"which",
"frustratingly",
"doesn",
"t",
"trim"
] | 4d0bba292cc86958374da4ddff0956200f154b85 | https://github.com/nowzoo/wp-utils/blob/4d0bba292cc86958374da4ddff0956200f154b85/src/NowZoo/WPUtils/WPUtils.php#L22-L34 |
8,821 | DerekMarcinyshyn/monashee-backup | src/Monashee/Backup/Database.php | Database.checkMysqlConnection | private function checkMysqlConnection() {
$this->connection = new \mysqli(
$this->config->get('backup::config')['BACKUP_MYSQL_HOST'],
$this->config->get('backup::config')['BACKUP_MYSQL_USER'],
$this->config->get('backup::config')['BACKUP_MYSQL_PASSWORD']);
if ($this->connection->connect_errno) {
$this->event->fire('MonasheeBackupError', 'No database connection');
throw new \Exception('Error connecting to MySQL');
}
echo 'Connected: '.$this->connection->host_info."\n";
echo 'Server info: '.$this->connection->get_server_info()."\n";
return true;
} | php | private function checkMysqlConnection() {
$this->connection = new \mysqli(
$this->config->get('backup::config')['BACKUP_MYSQL_HOST'],
$this->config->get('backup::config')['BACKUP_MYSQL_USER'],
$this->config->get('backup::config')['BACKUP_MYSQL_PASSWORD']);
if ($this->connection->connect_errno) {
$this->event->fire('MonasheeBackupError', 'No database connection');
throw new \Exception('Error connecting to MySQL');
}
echo 'Connected: '.$this->connection->host_info."\n";
echo 'Server info: '.$this->connection->get_server_info()."\n";
return true;
} | [
"private",
"function",
"checkMysqlConnection",
"(",
")",
"{",
"$",
"this",
"->",
"connection",
"=",
"new",
"\\",
"mysqli",
"(",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'backup::config'",
")",
"[",
"'BACKUP_MYSQL_HOST'",
"]",
",",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'backup::config'",
")",
"[",
"'BACKUP_MYSQL_USER'",
"]",
",",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'backup::config'",
")",
"[",
"'BACKUP_MYSQL_PASSWORD'",
"]",
")",
";",
"if",
"(",
"$",
"this",
"->",
"connection",
"->",
"connect_errno",
")",
"{",
"$",
"this",
"->",
"event",
"->",
"fire",
"(",
"'MonasheeBackupError'",
",",
"'No database connection'",
")",
";",
"throw",
"new",
"\\",
"Exception",
"(",
"'Error connecting to MySQL'",
")",
";",
"}",
"echo",
"'Connected: '",
".",
"$",
"this",
"->",
"connection",
"->",
"host_info",
".",
"\"\\n\"",
";",
"echo",
"'Server info: '",
".",
"$",
"this",
"->",
"connection",
"->",
"get_server_info",
"(",
")",
".",
"\"\\n\"",
";",
"return",
"true",
";",
"}"
] | Check MySQL Connection
@return bool
@throws \Exception | [
"Check",
"MySQL",
"Connection"
] | 2f96f3ddbbdd1c672e0064bf3b66951f94975158 | https://github.com/DerekMarcinyshyn/monashee-backup/blob/2f96f3ddbbdd1c672e0064bf3b66951f94975158/src/Monashee/Backup/Database.php#L75-L91 |
8,822 | indigophp-archive/fuel-core | classes/Controller/TemplateController.php | TemplateController.view | protected function view($view, $data = [], $auto_filter = null)
{
return \View::forge($view, $data, $auto_filter);
} | php | protected function view($view, $data = [], $auto_filter = null)
{
return \View::forge($view, $data, $auto_filter);
} | [
"protected",
"function",
"view",
"(",
"$",
"view",
",",
"$",
"data",
"=",
"[",
"]",
",",
"$",
"auto_filter",
"=",
"null",
")",
"{",
"return",
"\\",
"View",
"::",
"forge",
"(",
"$",
"view",
",",
"$",
"data",
",",
"$",
"auto_filter",
")",
";",
"}"
] | Creates a new View object
@see View::forge
@return View | [
"Creates",
"a",
"new",
"View",
"object"
] | 275462154fb7937f8e1c2c541b31d8e7c5760e39 | https://github.com/indigophp-archive/fuel-core/blob/275462154fb7937f8e1c2c541b31d8e7c5760e39/classes/Controller/TemplateController.php#L56-L59 |
8,823 | webriq/core | module/Customize/src/Grid/Customize/Controller/CssAdminController.php | CssAdminController.editAction | public function editAction()
{
/* @var $form \Zork\Form\Form */
/* @var $model \Grid\Customize\Model\Sheet\Model */
$params = $this->params();
$request = $this->getRequest();
$locator = $this->getServiceLocator();
$id = $params->fromRoute( 'id' );
$rootId = is_numeric( $id ) ? (int) $id : null;
$model = $locator->get( 'Grid\Customize\Model\Sheet\Model' );
$form = $locator->get( 'Form' )
->get( 'Grid\Customize\Css' );
$sheet = $model->find( $rootId );
$form->setHydrator( $model->getMapper() )
->bind( $sheet );
if ( $request->isPost() )
{
$form->setData( $request->getPost() );
if ( $form->isValid() && $sheet->save() )
{
$this->messenger()
->add( 'customize.form.success',
'customize', Message::LEVEL_INFO );
$cssPreview = $locator->get( 'Grid\Customize\Service\CssPreview' );
if ( $cssPreview->hasPreviewById( $rootId ) )
{
@ unlink( 'public' . $cssPreview->getPreviewById( $rootId ) );
$cssPreview->unsetPreviewById( $rootId );
}
return $this->redirect()
->toRoute( 'Grid\Customize\CssAdmin\List', array(
'locale' => (string) $this->locale(),
) );
}
else
{
$this->messenger()
->add( 'customize.form.failed',
'customize', Message::LEVEL_ERROR );
}
}
return array(
'form' => $form,
'sheet' => $sheet,
);
} | php | public function editAction()
{
/* @var $form \Zork\Form\Form */
/* @var $model \Grid\Customize\Model\Sheet\Model */
$params = $this->params();
$request = $this->getRequest();
$locator = $this->getServiceLocator();
$id = $params->fromRoute( 'id' );
$rootId = is_numeric( $id ) ? (int) $id : null;
$model = $locator->get( 'Grid\Customize\Model\Sheet\Model' );
$form = $locator->get( 'Form' )
->get( 'Grid\Customize\Css' );
$sheet = $model->find( $rootId );
$form->setHydrator( $model->getMapper() )
->bind( $sheet );
if ( $request->isPost() )
{
$form->setData( $request->getPost() );
if ( $form->isValid() && $sheet->save() )
{
$this->messenger()
->add( 'customize.form.success',
'customize', Message::LEVEL_INFO );
$cssPreview = $locator->get( 'Grid\Customize\Service\CssPreview' );
if ( $cssPreview->hasPreviewById( $rootId ) )
{
@ unlink( 'public' . $cssPreview->getPreviewById( $rootId ) );
$cssPreview->unsetPreviewById( $rootId );
}
return $this->redirect()
->toRoute( 'Grid\Customize\CssAdmin\List', array(
'locale' => (string) $this->locale(),
) );
}
else
{
$this->messenger()
->add( 'customize.form.failed',
'customize', Message::LEVEL_ERROR );
}
}
return array(
'form' => $form,
'sheet' => $sheet,
);
} | [
"public",
"function",
"editAction",
"(",
")",
"{",
"/* @var $form \\Zork\\Form\\Form */",
"/* @var $model \\Grid\\Customize\\Model\\Sheet\\Model */",
"$",
"params",
"=",
"$",
"this",
"->",
"params",
"(",
")",
";",
"$",
"request",
"=",
"$",
"this",
"->",
"getRequest",
"(",
")",
";",
"$",
"locator",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
";",
"$",
"id",
"=",
"$",
"params",
"->",
"fromRoute",
"(",
"'id'",
")",
";",
"$",
"rootId",
"=",
"is_numeric",
"(",
"$",
"id",
")",
"?",
"(",
"int",
")",
"$",
"id",
":",
"null",
";",
"$",
"model",
"=",
"$",
"locator",
"->",
"get",
"(",
"'Grid\\Customize\\Model\\Sheet\\Model'",
")",
";",
"$",
"form",
"=",
"$",
"locator",
"->",
"get",
"(",
"'Form'",
")",
"->",
"get",
"(",
"'Grid\\Customize\\Css'",
")",
";",
"$",
"sheet",
"=",
"$",
"model",
"->",
"find",
"(",
"$",
"rootId",
")",
";",
"$",
"form",
"->",
"setHydrator",
"(",
"$",
"model",
"->",
"getMapper",
"(",
")",
")",
"->",
"bind",
"(",
"$",
"sheet",
")",
";",
"if",
"(",
"$",
"request",
"->",
"isPost",
"(",
")",
")",
"{",
"$",
"form",
"->",
"setData",
"(",
"$",
"request",
"->",
"getPost",
"(",
")",
")",
";",
"if",
"(",
"$",
"form",
"->",
"isValid",
"(",
")",
"&&",
"$",
"sheet",
"->",
"save",
"(",
")",
")",
"{",
"$",
"this",
"->",
"messenger",
"(",
")",
"->",
"add",
"(",
"'customize.form.success'",
",",
"'customize'",
",",
"Message",
"::",
"LEVEL_INFO",
")",
";",
"$",
"cssPreview",
"=",
"$",
"locator",
"->",
"get",
"(",
"'Grid\\Customize\\Service\\CssPreview'",
")",
";",
"if",
"(",
"$",
"cssPreview",
"->",
"hasPreviewById",
"(",
"$",
"rootId",
")",
")",
"{",
"@",
"unlink",
"(",
"'public'",
".",
"$",
"cssPreview",
"->",
"getPreviewById",
"(",
"$",
"rootId",
")",
")",
";",
"$",
"cssPreview",
"->",
"unsetPreviewById",
"(",
"$",
"rootId",
")",
";",
"}",
"return",
"$",
"this",
"->",
"redirect",
"(",
")",
"->",
"toRoute",
"(",
"'Grid\\Customize\\CssAdmin\\List'",
",",
"array",
"(",
"'locale'",
"=>",
"(",
"string",
")",
"$",
"this",
"->",
"locale",
"(",
")",
",",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"messenger",
"(",
")",
"->",
"add",
"(",
"'customize.form.failed'",
",",
"'customize'",
",",
"Message",
"::",
"LEVEL_ERROR",
")",
";",
"}",
"}",
"return",
"array",
"(",
"'form'",
"=>",
"$",
"form",
",",
"'sheet'",
"=>",
"$",
"sheet",
",",
")",
";",
"}"
] | Edit a css | [
"Edit",
"a",
"css"
] | cfeb6e8a4732561c2215ec94e736c07f9b8bc990 | https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Customize/src/Grid/Customize/Controller/CssAdminController.php#L53-L105 |
8,824 | webriq/core | module/Customize/src/Grid/Customize/Controller/CssAdminController.php | CssAdminController.previewAction | public function previewAction()
{
/* @var $form \Zork\Form\Form */
/* @var $model \Grid\Customize\Model\Sheet\Model */
$params = $this->params();
$request = $this->getRequest();
$locator = $this->getServiceLocator();
$id = $params->fromRoute( 'id' );
$rootId = is_numeric( $id ) ? (int) $id : null;
$model = $locator->get( 'Grid\Customize\Model\Sheet\Model' );
$form = $locator->get( 'Form' )
->get( 'Grid\Customize\Css' );
$sheet = $model->createEmpty( $rootId );
$form->setHydrator( $model->getMapper() )
->bind( $sheet );
if ( $request->isPost() )
{
$form->setData( $request->getPost() );
if ( $form->isValid() )
{
$this->messenger()
->add( 'customize.preview.success',
'customize', Message::LEVEL_INFO );
$id = $rootId === null ? 'global' : $rootId;
$prefix = 'public';
$file = sprintf( static::PREVIEW_FILE, $id ) . '.';
do
{
$suffix = new DateTime;
}
while ( file_exists( $prefix . $file . $suffix->toHash() .
static::PREVIEW_EXTENSION ) );
$url = $file . $suffix->toHash() . static::PREVIEW_EXTENSION;
$path = $prefix . $url;
$sheet->render( $path );
$locator->get( 'Grid\Customize\Service\CssPreview' )
->setPreviewById( $rootId, $url );
if ( null === $rootId )
{
return $this->redirect()
->toUrl( '/' );
}
else
{
return $this->redirect()
->toRoute( 'Grid\Paragraph\Render\Paragraph', array(
'locale' => (string) $this->locale(),
'paragraphId' => $rootId,
) );
}
}
else
{
$this->messenger()
->add( 'customize.preview.failed',
'customize', Message::LEVEL_ERROR );
return $this->redirect()
->toRoute( 'Grid\Customize\CssAdmin\List', array(
'locale' => (string) $this->locale(),
) );
}
}
} | php | public function previewAction()
{
/* @var $form \Zork\Form\Form */
/* @var $model \Grid\Customize\Model\Sheet\Model */
$params = $this->params();
$request = $this->getRequest();
$locator = $this->getServiceLocator();
$id = $params->fromRoute( 'id' );
$rootId = is_numeric( $id ) ? (int) $id : null;
$model = $locator->get( 'Grid\Customize\Model\Sheet\Model' );
$form = $locator->get( 'Form' )
->get( 'Grid\Customize\Css' );
$sheet = $model->createEmpty( $rootId );
$form->setHydrator( $model->getMapper() )
->bind( $sheet );
if ( $request->isPost() )
{
$form->setData( $request->getPost() );
if ( $form->isValid() )
{
$this->messenger()
->add( 'customize.preview.success',
'customize', Message::LEVEL_INFO );
$id = $rootId === null ? 'global' : $rootId;
$prefix = 'public';
$file = sprintf( static::PREVIEW_FILE, $id ) . '.';
do
{
$suffix = new DateTime;
}
while ( file_exists( $prefix . $file . $suffix->toHash() .
static::PREVIEW_EXTENSION ) );
$url = $file . $suffix->toHash() . static::PREVIEW_EXTENSION;
$path = $prefix . $url;
$sheet->render( $path );
$locator->get( 'Grid\Customize\Service\CssPreview' )
->setPreviewById( $rootId, $url );
if ( null === $rootId )
{
return $this->redirect()
->toUrl( '/' );
}
else
{
return $this->redirect()
->toRoute( 'Grid\Paragraph\Render\Paragraph', array(
'locale' => (string) $this->locale(),
'paragraphId' => $rootId,
) );
}
}
else
{
$this->messenger()
->add( 'customize.preview.failed',
'customize', Message::LEVEL_ERROR );
return $this->redirect()
->toRoute( 'Grid\Customize\CssAdmin\List', array(
'locale' => (string) $this->locale(),
) );
}
}
} | [
"public",
"function",
"previewAction",
"(",
")",
"{",
"/* @var $form \\Zork\\Form\\Form */",
"/* @var $model \\Grid\\Customize\\Model\\Sheet\\Model */",
"$",
"params",
"=",
"$",
"this",
"->",
"params",
"(",
")",
";",
"$",
"request",
"=",
"$",
"this",
"->",
"getRequest",
"(",
")",
";",
"$",
"locator",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
";",
"$",
"id",
"=",
"$",
"params",
"->",
"fromRoute",
"(",
"'id'",
")",
";",
"$",
"rootId",
"=",
"is_numeric",
"(",
"$",
"id",
")",
"?",
"(",
"int",
")",
"$",
"id",
":",
"null",
";",
"$",
"model",
"=",
"$",
"locator",
"->",
"get",
"(",
"'Grid\\Customize\\Model\\Sheet\\Model'",
")",
";",
"$",
"form",
"=",
"$",
"locator",
"->",
"get",
"(",
"'Form'",
")",
"->",
"get",
"(",
"'Grid\\Customize\\Css'",
")",
";",
"$",
"sheet",
"=",
"$",
"model",
"->",
"createEmpty",
"(",
"$",
"rootId",
")",
";",
"$",
"form",
"->",
"setHydrator",
"(",
"$",
"model",
"->",
"getMapper",
"(",
")",
")",
"->",
"bind",
"(",
"$",
"sheet",
")",
";",
"if",
"(",
"$",
"request",
"->",
"isPost",
"(",
")",
")",
"{",
"$",
"form",
"->",
"setData",
"(",
"$",
"request",
"->",
"getPost",
"(",
")",
")",
";",
"if",
"(",
"$",
"form",
"->",
"isValid",
"(",
")",
")",
"{",
"$",
"this",
"->",
"messenger",
"(",
")",
"->",
"add",
"(",
"'customize.preview.success'",
",",
"'customize'",
",",
"Message",
"::",
"LEVEL_INFO",
")",
";",
"$",
"id",
"=",
"$",
"rootId",
"===",
"null",
"?",
"'global'",
":",
"$",
"rootId",
";",
"$",
"prefix",
"=",
"'public'",
";",
"$",
"file",
"=",
"sprintf",
"(",
"static",
"::",
"PREVIEW_FILE",
",",
"$",
"id",
")",
".",
"'.'",
";",
"do",
"{",
"$",
"suffix",
"=",
"new",
"DateTime",
";",
"}",
"while",
"(",
"file_exists",
"(",
"$",
"prefix",
".",
"$",
"file",
".",
"$",
"suffix",
"->",
"toHash",
"(",
")",
".",
"static",
"::",
"PREVIEW_EXTENSION",
")",
")",
";",
"$",
"url",
"=",
"$",
"file",
".",
"$",
"suffix",
"->",
"toHash",
"(",
")",
".",
"static",
"::",
"PREVIEW_EXTENSION",
";",
"$",
"path",
"=",
"$",
"prefix",
".",
"$",
"url",
";",
"$",
"sheet",
"->",
"render",
"(",
"$",
"path",
")",
";",
"$",
"locator",
"->",
"get",
"(",
"'Grid\\Customize\\Service\\CssPreview'",
")",
"->",
"setPreviewById",
"(",
"$",
"rootId",
",",
"$",
"url",
")",
";",
"if",
"(",
"null",
"===",
"$",
"rootId",
")",
"{",
"return",
"$",
"this",
"->",
"redirect",
"(",
")",
"->",
"toUrl",
"(",
"'/'",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"redirect",
"(",
")",
"->",
"toRoute",
"(",
"'Grid\\Paragraph\\Render\\Paragraph'",
",",
"array",
"(",
"'locale'",
"=>",
"(",
"string",
")",
"$",
"this",
"->",
"locale",
"(",
")",
",",
"'paragraphId'",
"=>",
"$",
"rootId",
",",
")",
")",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"messenger",
"(",
")",
"->",
"add",
"(",
"'customize.preview.failed'",
",",
"'customize'",
",",
"Message",
"::",
"LEVEL_ERROR",
")",
";",
"return",
"$",
"this",
"->",
"redirect",
"(",
")",
"->",
"toRoute",
"(",
"'Grid\\Customize\\CssAdmin\\List'",
",",
"array",
"(",
"'locale'",
"=>",
"(",
"string",
")",
"$",
"this",
"->",
"locale",
"(",
")",
",",
")",
")",
";",
"}",
"}",
"}"
] | Preview a css | [
"Preview",
"a",
"css"
] | cfeb6e8a4732561c2215ec94e736c07f9b8bc990 | https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Customize/src/Grid/Customize/Controller/CssAdminController.php#L110-L181 |
8,825 | webriq/core | module/Customize/src/Grid/Customize/Controller/CssAdminController.php | CssAdminController.cancelAction | public function cancelAction()
{
/* @var $cssPreview \Grid\Customize\Service\CssPreview */
$params = $this->params();
$locator = $this->getServiceLocator();
$cssPreview = $locator->get( 'Grid\Customize\Service\CssPreview' );
$id = $params->fromRoute( 'id' );
$rootId = is_numeric( $id ) ? (int) $id : null;
if ( $cssPreview->hasPreviewById( $rootId ) )
{
@ unlink( 'public' . $cssPreview->getPreviewById( $rootId ) );
$cssPreview->unsetPreviewById( $rootId );
}
return $this->redirect()
->toRoute( 'Grid\Customize\CssAdmin\List', array(
'locale' => (string) $this->locale(),
) );
} | php | public function cancelAction()
{
/* @var $cssPreview \Grid\Customize\Service\CssPreview */
$params = $this->params();
$locator = $this->getServiceLocator();
$cssPreview = $locator->get( 'Grid\Customize\Service\CssPreview' );
$id = $params->fromRoute( 'id' );
$rootId = is_numeric( $id ) ? (int) $id : null;
if ( $cssPreview->hasPreviewById( $rootId ) )
{
@ unlink( 'public' . $cssPreview->getPreviewById( $rootId ) );
$cssPreview->unsetPreviewById( $rootId );
}
return $this->redirect()
->toRoute( 'Grid\Customize\CssAdmin\List', array(
'locale' => (string) $this->locale(),
) );
} | [
"public",
"function",
"cancelAction",
"(",
")",
"{",
"/* @var $cssPreview \\Grid\\Customize\\Service\\CssPreview */",
"$",
"params",
"=",
"$",
"this",
"->",
"params",
"(",
")",
";",
"$",
"locator",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
";",
"$",
"cssPreview",
"=",
"$",
"locator",
"->",
"get",
"(",
"'Grid\\Customize\\Service\\CssPreview'",
")",
";",
"$",
"id",
"=",
"$",
"params",
"->",
"fromRoute",
"(",
"'id'",
")",
";",
"$",
"rootId",
"=",
"is_numeric",
"(",
"$",
"id",
")",
"?",
"(",
"int",
")",
"$",
"id",
":",
"null",
";",
"if",
"(",
"$",
"cssPreview",
"->",
"hasPreviewById",
"(",
"$",
"rootId",
")",
")",
"{",
"@",
"unlink",
"(",
"'public'",
".",
"$",
"cssPreview",
"->",
"getPreviewById",
"(",
"$",
"rootId",
")",
")",
";",
"$",
"cssPreview",
"->",
"unsetPreviewById",
"(",
"$",
"rootId",
")",
";",
"}",
"return",
"$",
"this",
"->",
"redirect",
"(",
")",
"->",
"toRoute",
"(",
"'Grid\\Customize\\CssAdmin\\List'",
",",
"array",
"(",
"'locale'",
"=>",
"(",
"string",
")",
"$",
"this",
"->",
"locale",
"(",
")",
",",
")",
")",
";",
"}"
] | Cancel an edit of a css | [
"Cancel",
"an",
"edit",
"of",
"a",
"css"
] | cfeb6e8a4732561c2215ec94e736c07f9b8bc990 | https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Customize/src/Grid/Customize/Controller/CssAdminController.php#L186-L205 |
8,826 | webriq/core | module/Customize/src/Grid/Customize/Controller/CssAdminController.php | CssAdminController.resetPreviewsAction | public function resetPreviewsAction()
{
/* @var $cssPreview \Grid\Customize\Service\CssPreview */
$cssPreview = $this->getServiceLocator()
->get( 'Grid\Customize\Service\CssPreview' );
foreach ( $cssPreview->getPreviews() as $url )
{
@ unlink( 'public' . $url );
}
$cssPreview->unsetPreviews();
$this->messenger()
->add( 'customize.preview.reset',
'customize', Message::LEVEL_INFO );
return $this->redirect()
->toUrl( '/' );
} | php | public function resetPreviewsAction()
{
/* @var $cssPreview \Grid\Customize\Service\CssPreview */
$cssPreview = $this->getServiceLocator()
->get( 'Grid\Customize\Service\CssPreview' );
foreach ( $cssPreview->getPreviews() as $url )
{
@ unlink( 'public' . $url );
}
$cssPreview->unsetPreviews();
$this->messenger()
->add( 'customize.preview.reset',
'customize', Message::LEVEL_INFO );
return $this->redirect()
->toUrl( '/' );
} | [
"public",
"function",
"resetPreviewsAction",
"(",
")",
"{",
"/* @var $cssPreview \\Grid\\Customize\\Service\\CssPreview */",
"$",
"cssPreview",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'Grid\\Customize\\Service\\CssPreview'",
")",
";",
"foreach",
"(",
"$",
"cssPreview",
"->",
"getPreviews",
"(",
")",
"as",
"$",
"url",
")",
"{",
"@",
"unlink",
"(",
"'public'",
".",
"$",
"url",
")",
";",
"}",
"$",
"cssPreview",
"->",
"unsetPreviews",
"(",
")",
";",
"$",
"this",
"->",
"messenger",
"(",
")",
"->",
"add",
"(",
"'customize.preview.reset'",
",",
"'customize'",
",",
"Message",
"::",
"LEVEL_INFO",
")",
";",
"return",
"$",
"this",
"->",
"redirect",
"(",
")",
"->",
"toUrl",
"(",
"'/'",
")",
";",
"}"
] | Reset all previews | [
"Reset",
"all",
"previews"
] | cfeb6e8a4732561c2215ec94e736c07f9b8bc990 | https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Customize/src/Grid/Customize/Controller/CssAdminController.php#L210-L229 |
8,827 | gomaframework/GomaLogging | src/ExceptionLogger.php | ExceptionLogger.handleException | public static function handleException($exception)
{
$message = get_class($exception) . " " . $exception->getCode() . ":\n\n" . $exception->getMessage() . "\n" .
self::exception_get_dev_message($exception) . " in " .
$exception->getFile() . " on line " . $exception->getLine() . ".\n\n Backtrace: " . $exception->getTraceAsString();
$currentPreviousException = $exception;
while ($currentPreviousException = $currentPreviousException->getPrevious()) {
$message .= "\nPrevious: " . get_class($currentPreviousException) . " " . $currentPreviousException->getMessage() . "\n" . self::exception_get_dev_message($currentPreviousException) . "\n in "
. $currentPreviousException->getFile() . " on line " . $currentPreviousException->getLine() . ".\n" . $currentPreviousException->getTraceAsString();
}
if (self::isDeveloperPresentable($exception)) {
$uri = isset($_SERVER["REQUEST_URI"]) ? $_SERVER["REQUEST_URI"] : (isset($_SERVER["argv"]) ? implode(" ", $_SERVER["argv"]) : null);
Logger::log($message, Logger::LOG_LEVEL_ERROR);
$debugMsg = $message . "\n\n\n" . "URL: " . $uri . " \nPOST: ".print_r($_POST, true).
"GET: " . print_r($_GET, true) .
"SERVER: " . print_r($_SERVER, true) .
"HTTP: " . print_r(getallheaders(), true) .
"\nComposer: " . print_r(GomaENV::getProjectLevelComposerArray(), true) .
" Installed: " . print_r(GomaENV::getProjectLevelInstalledComposerArray(), true) . "\n\n";
Logger::log($debugMsg, Logger::LOG_LEVEL_DEBUG);
} else {
Logger::log($message, Logger::LOG_LEVEL_LOG);
}
} | php | public static function handleException($exception)
{
$message = get_class($exception) . " " . $exception->getCode() . ":\n\n" . $exception->getMessage() . "\n" .
self::exception_get_dev_message($exception) . " in " .
$exception->getFile() . " on line " . $exception->getLine() . ".\n\n Backtrace: " . $exception->getTraceAsString();
$currentPreviousException = $exception;
while ($currentPreviousException = $currentPreviousException->getPrevious()) {
$message .= "\nPrevious: " . get_class($currentPreviousException) . " " . $currentPreviousException->getMessage() . "\n" . self::exception_get_dev_message($currentPreviousException) . "\n in "
. $currentPreviousException->getFile() . " on line " . $currentPreviousException->getLine() . ".\n" . $currentPreviousException->getTraceAsString();
}
if (self::isDeveloperPresentable($exception)) {
$uri = isset($_SERVER["REQUEST_URI"]) ? $_SERVER["REQUEST_URI"] : (isset($_SERVER["argv"]) ? implode(" ", $_SERVER["argv"]) : null);
Logger::log($message, Logger::LOG_LEVEL_ERROR);
$debugMsg = $message . "\n\n\n" . "URL: " . $uri . " \nPOST: ".print_r($_POST, true).
"GET: " . print_r($_GET, true) .
"SERVER: " . print_r($_SERVER, true) .
"HTTP: " . print_r(getallheaders(), true) .
"\nComposer: " . print_r(GomaENV::getProjectLevelComposerArray(), true) .
" Installed: " . print_r(GomaENV::getProjectLevelInstalledComposerArray(), true) . "\n\n";
Logger::log($debugMsg, Logger::LOG_LEVEL_DEBUG);
} else {
Logger::log($message, Logger::LOG_LEVEL_LOG);
}
} | [
"public",
"static",
"function",
"handleException",
"(",
"$",
"exception",
")",
"{",
"$",
"message",
"=",
"get_class",
"(",
"$",
"exception",
")",
".",
"\" \"",
".",
"$",
"exception",
"->",
"getCode",
"(",
")",
".",
"\":\\n\\n\"",
".",
"$",
"exception",
"->",
"getMessage",
"(",
")",
".",
"\"\\n\"",
".",
"self",
"::",
"exception_get_dev_message",
"(",
"$",
"exception",
")",
".",
"\" in \"",
".",
"$",
"exception",
"->",
"getFile",
"(",
")",
".",
"\" on line \"",
".",
"$",
"exception",
"->",
"getLine",
"(",
")",
".",
"\".\\n\\n Backtrace: \"",
".",
"$",
"exception",
"->",
"getTraceAsString",
"(",
")",
";",
"$",
"currentPreviousException",
"=",
"$",
"exception",
";",
"while",
"(",
"$",
"currentPreviousException",
"=",
"$",
"currentPreviousException",
"->",
"getPrevious",
"(",
")",
")",
"{",
"$",
"message",
".=",
"\"\\nPrevious: \"",
".",
"get_class",
"(",
"$",
"currentPreviousException",
")",
".",
"\" \"",
".",
"$",
"currentPreviousException",
"->",
"getMessage",
"(",
")",
".",
"\"\\n\"",
".",
"self",
"::",
"exception_get_dev_message",
"(",
"$",
"currentPreviousException",
")",
".",
"\"\\n in \"",
".",
"$",
"currentPreviousException",
"->",
"getFile",
"(",
")",
".",
"\" on line \"",
".",
"$",
"currentPreviousException",
"->",
"getLine",
"(",
")",
".",
"\".\\n\"",
".",
"$",
"currentPreviousException",
"->",
"getTraceAsString",
"(",
")",
";",
"}",
"if",
"(",
"self",
"::",
"isDeveloperPresentable",
"(",
"$",
"exception",
")",
")",
"{",
"$",
"uri",
"=",
"isset",
"(",
"$",
"_SERVER",
"[",
"\"REQUEST_URI\"",
"]",
")",
"?",
"$",
"_SERVER",
"[",
"\"REQUEST_URI\"",
"]",
":",
"(",
"isset",
"(",
"$",
"_SERVER",
"[",
"\"argv\"",
"]",
")",
"?",
"implode",
"(",
"\" \"",
",",
"$",
"_SERVER",
"[",
"\"argv\"",
"]",
")",
":",
"null",
")",
";",
"Logger",
"::",
"log",
"(",
"$",
"message",
",",
"Logger",
"::",
"LOG_LEVEL_ERROR",
")",
";",
"$",
"debugMsg",
"=",
"$",
"message",
".",
"\"\\n\\n\\n\"",
".",
"\"URL: \"",
".",
"$",
"uri",
".",
"\" \\nPOST: \"",
".",
"print_r",
"(",
"$",
"_POST",
",",
"true",
")",
".",
"\"GET: \"",
".",
"print_r",
"(",
"$",
"_GET",
",",
"true",
")",
".",
"\"SERVER: \"",
".",
"print_r",
"(",
"$",
"_SERVER",
",",
"true",
")",
".",
"\"HTTP: \"",
".",
"print_r",
"(",
"getallheaders",
"(",
")",
",",
"true",
")",
".",
"\"\\nComposer: \"",
".",
"print_r",
"(",
"GomaENV",
"::",
"getProjectLevelComposerArray",
"(",
")",
",",
"true",
")",
".",
"\" Installed: \"",
".",
"print_r",
"(",
"GomaENV",
"::",
"getProjectLevelInstalledComposerArray",
"(",
")",
",",
"true",
")",
".",
"\"\\n\\n\"",
";",
"Logger",
"::",
"log",
"(",
"$",
"debugMsg",
",",
"Logger",
"::",
"LOG_LEVEL_DEBUG",
")",
";",
"}",
"else",
"{",
"Logger",
"::",
"log",
"(",
"$",
"message",
",",
"Logger",
"::",
"LOG_LEVEL_LOG",
")",
";",
"}",
"}"
] | At this point exceptions can be handled.
Return true if exception was handled and default handling or handling by others should be stopped.
@param Throwable $exception
@return bool|null | [
"At",
"this",
"point",
"exceptions",
"can",
"be",
"handled",
".",
"Return",
"true",
"if",
"exception",
"was",
"handled",
"and",
"default",
"handling",
"or",
"handling",
"by",
"others",
"should",
"be",
"stopped",
"."
] | 86b9b8b1734e6c5094b39fee52164ce56cc299f5 | https://github.com/gomaframework/GomaLogging/blob/86b9b8b1734e6c5094b39fee52164ce56cc299f5/src/ExceptionLogger.php#L44-L71 |
8,828 | laradic/service-provider | src/Plugins/Providers.php | Providers.startProvidersPlugin | protected function startProvidersPlugin($app)
{
switch ($this->registerProvidersOn) {
case 'register':
$this->onRegister('providers', function () {
$this->handleProviders();
});
break;
case 'booting':
$this->app->booting(function () {
$this->handleProviders();
});
break;
case 'boot':
$this->onBoot('providers', function () {
$this->handleProviders();
});
break;
case 'booted':
$this->app->booted(function () {
$this->handleProviders();
});
break;
default:
throw new \LogicException('registerProvidersOn not valid');
break;
}
} | php | protected function startProvidersPlugin($app)
{
switch ($this->registerProvidersOn) {
case 'register':
$this->onRegister('providers', function () {
$this->handleProviders();
});
break;
case 'booting':
$this->app->booting(function () {
$this->handleProviders();
});
break;
case 'boot':
$this->onBoot('providers', function () {
$this->handleProviders();
});
break;
case 'booted':
$this->app->booted(function () {
$this->handleProviders();
});
break;
default:
throw new \LogicException('registerProvidersOn not valid');
break;
}
} | [
"protected",
"function",
"startProvidersPlugin",
"(",
"$",
"app",
")",
"{",
"switch",
"(",
"$",
"this",
"->",
"registerProvidersOn",
")",
"{",
"case",
"'register'",
":",
"$",
"this",
"->",
"onRegister",
"(",
"'providers'",
",",
"function",
"(",
")",
"{",
"$",
"this",
"->",
"handleProviders",
"(",
")",
";",
"}",
")",
";",
"break",
";",
"case",
"'booting'",
":",
"$",
"this",
"->",
"app",
"->",
"booting",
"(",
"function",
"(",
")",
"{",
"$",
"this",
"->",
"handleProviders",
"(",
")",
";",
"}",
")",
";",
"break",
";",
"case",
"'boot'",
":",
"$",
"this",
"->",
"onBoot",
"(",
"'providers'",
",",
"function",
"(",
")",
"{",
"$",
"this",
"->",
"handleProviders",
"(",
")",
";",
"}",
")",
";",
"break",
";",
"case",
"'booted'",
":",
"$",
"this",
"->",
"app",
"->",
"booted",
"(",
"function",
"(",
")",
"{",
"$",
"this",
"->",
"handleProviders",
"(",
")",
";",
"}",
")",
";",
"break",
";",
"default",
":",
"throw",
"new",
"\\",
"LogicException",
"(",
"'registerProvidersOn not valid'",
")",
";",
"break",
";",
"}",
"}"
] | startProvidersPlugin method.
@param \Illuminate\Foundation\Application $app | [
"startProvidersPlugin",
"method",
"."
] | b1428d566b97b3662b405c64ff0cad8a89102033 | https://github.com/laradic/service-provider/blob/b1428d566b97b3662b405c64ff0cad8a89102033/src/Plugins/Providers.php#L58-L85 |
8,829 | laradic/service-provider | src/Plugins/Providers.php | Providers.handleProviders | protected function handleProviders()
{
// register deferred providers
foreach ($this->deferredProviders as $provider) {
$this->app->registerDeferredProvider($provider);
}
if ($this->registerProvidersMethod === 'register') {
$this->registerProviders();
} elseif ($this->registerProvidersMethod === 'resolve') {
$this->resolveProviders();
} else {
throw new \LogicException('registerProvidersMethod not valid');
}
} | php | protected function handleProviders()
{
// register deferred providers
foreach ($this->deferredProviders as $provider) {
$this->app->registerDeferredProvider($provider);
}
if ($this->registerProvidersMethod === 'register') {
$this->registerProviders();
} elseif ($this->registerProvidersMethod === 'resolve') {
$this->resolveProviders();
} else {
throw new \LogicException('registerProvidersMethod not valid');
}
} | [
"protected",
"function",
"handleProviders",
"(",
")",
"{",
"// register deferred providers",
"foreach",
"(",
"$",
"this",
"->",
"deferredProviders",
"as",
"$",
"provider",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"registerDeferredProvider",
"(",
"$",
"provider",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"registerProvidersMethod",
"===",
"'register'",
")",
"{",
"$",
"this",
"->",
"registerProviders",
"(",
")",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"registerProvidersMethod",
"===",
"'resolve'",
")",
"{",
"$",
"this",
"->",
"resolveProviders",
"(",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"'registerProvidersMethod not valid'",
")",
";",
"}",
"}"
] | handleProviders method. | [
"handleProviders",
"method",
"."
] | b1428d566b97b3662b405c64ff0cad8a89102033 | https://github.com/laradic/service-provider/blob/b1428d566b97b3662b405c64ff0cad8a89102033/src/Plugins/Providers.php#L90-L104 |
8,830 | laradic/service-provider | src/Plugins/Providers.php | Providers.resolveProviders | protected function resolveProviders()
{
foreach ($this->providers as $provider) {
$resolved = $this->resolveProvider($registered[] = $provider);
$resolved->register();
if ($this->registerProvidersOn === 'boot') {
$this->app->call([$provider, 'boot']);
}
}
} | php | protected function resolveProviders()
{
foreach ($this->providers as $provider) {
$resolved = $this->resolveProvider($registered[] = $provider);
$resolved->register();
if ($this->registerProvidersOn === 'boot') {
$this->app->call([$provider, 'boot']);
}
}
} | [
"protected",
"function",
"resolveProviders",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"providers",
"as",
"$",
"provider",
")",
"{",
"$",
"resolved",
"=",
"$",
"this",
"->",
"resolveProvider",
"(",
"$",
"registered",
"[",
"]",
"=",
"$",
"provider",
")",
";",
"$",
"resolved",
"->",
"register",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"registerProvidersOn",
"===",
"'boot'",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"call",
"(",
"[",
"$",
"provider",
",",
"'boot'",
"]",
")",
";",
"}",
"}",
"}"
] | resolveProviders method. | [
"resolveProviders",
"method",
"."
] | b1428d566b97b3662b405c64ff0cad8a89102033 | https://github.com/laradic/service-provider/blob/b1428d566b97b3662b405c64ff0cad8a89102033/src/Plugins/Providers.php#L119-L128 |
8,831 | GrupaZero/core | src/Gzero/Core/Services/LanguageService.php | LanguageService.getByCode | public function getByCode($code)
{
return $this->languages->filter(
function ($language) use ($code) {
return $language->code == $code;
}
)->first();
} | php | public function getByCode($code)
{
return $this->languages->filter(
function ($language) use ($code) {
return $language->code == $code;
}
)->first();
} | [
"public",
"function",
"getByCode",
"(",
"$",
"code",
")",
"{",
"return",
"$",
"this",
"->",
"languages",
"->",
"filter",
"(",
"function",
"(",
"$",
"language",
")",
"use",
"(",
"$",
"code",
")",
"{",
"return",
"$",
"language",
"->",
"code",
"==",
"$",
"code",
";",
"}",
")",
"->",
"first",
"(",
")",
";",
"}"
] | Get lang by lang code
@param string $code Lang code eg. "en"
@return \Gzero\Core\Models\Language | [
"Get",
"lang",
"by",
"lang",
"code"
] | 093e515234fa0385b259ba4d8bc7832174a44eab | https://github.com/GrupaZero/core/blob/093e515234fa0385b259ba4d8bc7832174a44eab/src/Gzero/Core/Services/LanguageService.php#L43-L50 |
8,832 | glendmaatita/Tolkien | src/Tolkien/Init.php | Init.create | public function create()
{
$blog_dir = getcwd() . '/' . $this->name . '/';
$this->createBlogDirectory($blog_dir);
$this->createConfigFile($blog_dir);
$this->createTemplateFile($blog_dir);
} | php | public function create()
{
$blog_dir = getcwd() . '/' . $this->name . '/';
$this->createBlogDirectory($blog_dir);
$this->createConfigFile($blog_dir);
$this->createTemplateFile($blog_dir);
} | [
"public",
"function",
"create",
"(",
")",
"{",
"$",
"blog_dir",
"=",
"getcwd",
"(",
")",
".",
"'/'",
".",
"$",
"this",
"->",
"name",
".",
"'/'",
";",
"$",
"this",
"->",
"createBlogDirectory",
"(",
"$",
"blog_dir",
")",
";",
"$",
"this",
"->",
"createConfigFile",
"(",
"$",
"blog_dir",
")",
";",
"$",
"this",
"->",
"createTemplateFile",
"(",
"$",
"blog_dir",
")",
";",
"}"
] | Create blog app with all its mandatory folder
@return void | [
"Create",
"blog",
"app",
"with",
"all",
"its",
"mandatory",
"folder"
] | e7c27a103f1a87411dfb8eef626cba381b27d233 | https://github.com/glendmaatita/Tolkien/blob/e7c27a103f1a87411dfb8eef626cba381b27d233/src/Tolkien/Init.php#L36-L42 |
8,833 | glendmaatita/Tolkien | src/Tolkien/Init.php | Init.createBlogDirectory | public function createBlogDirectory($blog_dir)
{
@mkdir($blog_dir , 0777, true );
$this->config = $this->configContent( $blog_dir );
@mkdir( $this->config['dir']['post'], 0777, true );
@mkdir( $this->config['dir']['page'], 0777, true );
@mkdir( $this->config['dir']['site'], 0777, true );
@mkdir( $this->config['dir']['asset'], 0777, true );
@mkdir( $this->config['dir']['layout'], 0777, true );
} | php | public function createBlogDirectory($blog_dir)
{
@mkdir($blog_dir , 0777, true );
$this->config = $this->configContent( $blog_dir );
@mkdir( $this->config['dir']['post'], 0777, true );
@mkdir( $this->config['dir']['page'], 0777, true );
@mkdir( $this->config['dir']['site'], 0777, true );
@mkdir( $this->config['dir']['asset'], 0777, true );
@mkdir( $this->config['dir']['layout'], 0777, true );
} | [
"public",
"function",
"createBlogDirectory",
"(",
"$",
"blog_dir",
")",
"{",
"@",
"mkdir",
"(",
"$",
"blog_dir",
",",
"0777",
",",
"true",
")",
";",
"$",
"this",
"->",
"config",
"=",
"$",
"this",
"->",
"configContent",
"(",
"$",
"blog_dir",
")",
";",
"@",
"mkdir",
"(",
"$",
"this",
"->",
"config",
"[",
"'dir'",
"]",
"[",
"'post'",
"]",
",",
"0777",
",",
"true",
")",
";",
"@",
"mkdir",
"(",
"$",
"this",
"->",
"config",
"[",
"'dir'",
"]",
"[",
"'page'",
"]",
",",
"0777",
",",
"true",
")",
";",
"@",
"mkdir",
"(",
"$",
"this",
"->",
"config",
"[",
"'dir'",
"]",
"[",
"'site'",
"]",
",",
"0777",
",",
"true",
")",
";",
"@",
"mkdir",
"(",
"$",
"this",
"->",
"config",
"[",
"'dir'",
"]",
"[",
"'asset'",
"]",
",",
"0777",
",",
"true",
")",
";",
"@",
"mkdir",
"(",
"$",
"this",
"->",
"config",
"[",
"'dir'",
"]",
"[",
"'layout'",
"]",
",",
"0777",
",",
"true",
")",
";",
"}"
] | Create Blog App Directories
@return void | [
"Create",
"Blog",
"App",
"Directories"
] | e7c27a103f1a87411dfb8eef626cba381b27d233 | https://github.com/glendmaatita/Tolkien/blob/e7c27a103f1a87411dfb8eef626cba381b27d233/src/Tolkien/Init.php#L49-L58 |
8,834 | glendmaatita/Tolkien | src/Tolkien/Init.php | Init.createTemplateFile | public function createTemplateFile()
{
// css
if (!is_dir($this->config['dir']['asset'] . '/css')) {
// dir doesn't exist, make it
mkdir($this->config['dir']['asset'] . '/css');
}
//js
if (!is_dir($this->config['dir']['asset'] . '/js')) {
mkdir($this->config['dir']['asset'] . '/js');
}
// css file
file_put_contents( $this->config['dir']['asset'] . '/css/bootstrap.min.css', file_get_contents(__DIR__ . '/tpl/css/bootstrap.min.css'));
file_put_contents( $this->config['dir']['asset'] . '/css/bootstrap-theme.min.css', file_get_contents(__DIR__ . '/tpl/css/bootstrap-theme.min.css'));
// js file
file_put_contents( $this->config['dir']['asset'] . '/js/jquery.js', file_get_contents(__DIR__ . '/tpl/js/jquery.js'));
file_put_contents( $this->config['dir']['asset'] . '/js/bootstrap.min.js', file_get_contents(__DIR__ . '/tpl/js/bootstrap.min.js'));
// index html
file_put_contents( $this->config['dir']['layout'] . '/index.html.tpl', file_get_contents(__DIR__ . '/tpl/index.html.tpl'));
// post layout
file_put_contents( $this->config['dir']['layout'] . '/post.html.tpl', file_get_contents(__DIR__ . '/tpl/post.html.tpl'));
// page layout
file_put_contents( $this->config['dir']['layout'] . '/page.html.tpl', file_get_contents(__DIR__ . '/tpl/page.html.tpl'));
// category layout
file_put_contents( $this->config['dir']['layout'] . '/category.html.tpl', file_get_contents(__DIR__ . '/tpl/category.html.tpl'));
// author layout
file_put_contents( $this->config['dir']['layout'] . '/author.html.tpl', file_get_contents(__DIR__ . '/tpl/author.html.tpl'));
// sidebar layout
file_put_contents( $this->config['dir']['layout'] . '/sidebar.html.tpl', file_get_contents(__DIR__ . '/tpl/sidebar.html.tpl'));
// header layout
file_put_contents( $this->config['dir']['layout'] . '/header.html.tpl', file_get_contents(__DIR__ . '/tpl/header.html.tpl'));
// master layout
file_put_contents( $this->config['dir']['layout'] . '/layout.html.tpl', file_get_contents(__DIR__ . '/tpl/layout.html.tpl'));
} | php | public function createTemplateFile()
{
// css
if (!is_dir($this->config['dir']['asset'] . '/css')) {
// dir doesn't exist, make it
mkdir($this->config['dir']['asset'] . '/css');
}
//js
if (!is_dir($this->config['dir']['asset'] . '/js')) {
mkdir($this->config['dir']['asset'] . '/js');
}
// css file
file_put_contents( $this->config['dir']['asset'] . '/css/bootstrap.min.css', file_get_contents(__DIR__ . '/tpl/css/bootstrap.min.css'));
file_put_contents( $this->config['dir']['asset'] . '/css/bootstrap-theme.min.css', file_get_contents(__DIR__ . '/tpl/css/bootstrap-theme.min.css'));
// js file
file_put_contents( $this->config['dir']['asset'] . '/js/jquery.js', file_get_contents(__DIR__ . '/tpl/js/jquery.js'));
file_put_contents( $this->config['dir']['asset'] . '/js/bootstrap.min.js', file_get_contents(__DIR__ . '/tpl/js/bootstrap.min.js'));
// index html
file_put_contents( $this->config['dir']['layout'] . '/index.html.tpl', file_get_contents(__DIR__ . '/tpl/index.html.tpl'));
// post layout
file_put_contents( $this->config['dir']['layout'] . '/post.html.tpl', file_get_contents(__DIR__ . '/tpl/post.html.tpl'));
// page layout
file_put_contents( $this->config['dir']['layout'] . '/page.html.tpl', file_get_contents(__DIR__ . '/tpl/page.html.tpl'));
// category layout
file_put_contents( $this->config['dir']['layout'] . '/category.html.tpl', file_get_contents(__DIR__ . '/tpl/category.html.tpl'));
// author layout
file_put_contents( $this->config['dir']['layout'] . '/author.html.tpl', file_get_contents(__DIR__ . '/tpl/author.html.tpl'));
// sidebar layout
file_put_contents( $this->config['dir']['layout'] . '/sidebar.html.tpl', file_get_contents(__DIR__ . '/tpl/sidebar.html.tpl'));
// header layout
file_put_contents( $this->config['dir']['layout'] . '/header.html.tpl', file_get_contents(__DIR__ . '/tpl/header.html.tpl'));
// master layout
file_put_contents( $this->config['dir']['layout'] . '/layout.html.tpl', file_get_contents(__DIR__ . '/tpl/layout.html.tpl'));
} | [
"public",
"function",
"createTemplateFile",
"(",
")",
"{",
"// css",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"this",
"->",
"config",
"[",
"'dir'",
"]",
"[",
"'asset'",
"]",
".",
"'/css'",
")",
")",
"{",
"// dir doesn't exist, make it",
"mkdir",
"(",
"$",
"this",
"->",
"config",
"[",
"'dir'",
"]",
"[",
"'asset'",
"]",
".",
"'/css'",
")",
";",
"}",
"//js",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"this",
"->",
"config",
"[",
"'dir'",
"]",
"[",
"'asset'",
"]",
".",
"'/js'",
")",
")",
"{",
"mkdir",
"(",
"$",
"this",
"->",
"config",
"[",
"'dir'",
"]",
"[",
"'asset'",
"]",
".",
"'/js'",
")",
";",
"}",
"// css file",
"file_put_contents",
"(",
"$",
"this",
"->",
"config",
"[",
"'dir'",
"]",
"[",
"'asset'",
"]",
".",
"'/css/bootstrap.min.css'",
",",
"file_get_contents",
"(",
"__DIR__",
".",
"'/tpl/css/bootstrap.min.css'",
")",
")",
";",
"file_put_contents",
"(",
"$",
"this",
"->",
"config",
"[",
"'dir'",
"]",
"[",
"'asset'",
"]",
".",
"'/css/bootstrap-theme.min.css'",
",",
"file_get_contents",
"(",
"__DIR__",
".",
"'/tpl/css/bootstrap-theme.min.css'",
")",
")",
";",
"// js file",
"file_put_contents",
"(",
"$",
"this",
"->",
"config",
"[",
"'dir'",
"]",
"[",
"'asset'",
"]",
".",
"'/js/jquery.js'",
",",
"file_get_contents",
"(",
"__DIR__",
".",
"'/tpl/js/jquery.js'",
")",
")",
";",
"file_put_contents",
"(",
"$",
"this",
"->",
"config",
"[",
"'dir'",
"]",
"[",
"'asset'",
"]",
".",
"'/js/bootstrap.min.js'",
",",
"file_get_contents",
"(",
"__DIR__",
".",
"'/tpl/js/bootstrap.min.js'",
")",
")",
";",
"// index html",
"file_put_contents",
"(",
"$",
"this",
"->",
"config",
"[",
"'dir'",
"]",
"[",
"'layout'",
"]",
".",
"'/index.html.tpl'",
",",
"file_get_contents",
"(",
"__DIR__",
".",
"'/tpl/index.html.tpl'",
")",
")",
";",
"// post layout",
"file_put_contents",
"(",
"$",
"this",
"->",
"config",
"[",
"'dir'",
"]",
"[",
"'layout'",
"]",
".",
"'/post.html.tpl'",
",",
"file_get_contents",
"(",
"__DIR__",
".",
"'/tpl/post.html.tpl'",
")",
")",
";",
"// page layout",
"file_put_contents",
"(",
"$",
"this",
"->",
"config",
"[",
"'dir'",
"]",
"[",
"'layout'",
"]",
".",
"'/page.html.tpl'",
",",
"file_get_contents",
"(",
"__DIR__",
".",
"'/tpl/page.html.tpl'",
")",
")",
";",
"// category layout",
"file_put_contents",
"(",
"$",
"this",
"->",
"config",
"[",
"'dir'",
"]",
"[",
"'layout'",
"]",
".",
"'/category.html.tpl'",
",",
"file_get_contents",
"(",
"__DIR__",
".",
"'/tpl/category.html.tpl'",
")",
")",
";",
"// author layout",
"file_put_contents",
"(",
"$",
"this",
"->",
"config",
"[",
"'dir'",
"]",
"[",
"'layout'",
"]",
".",
"'/author.html.tpl'",
",",
"file_get_contents",
"(",
"__DIR__",
".",
"'/tpl/author.html.tpl'",
")",
")",
";",
"// sidebar layout",
"file_put_contents",
"(",
"$",
"this",
"->",
"config",
"[",
"'dir'",
"]",
"[",
"'layout'",
"]",
".",
"'/sidebar.html.tpl'",
",",
"file_get_contents",
"(",
"__DIR__",
".",
"'/tpl/sidebar.html.tpl'",
")",
")",
";",
"// header layout",
"file_put_contents",
"(",
"$",
"this",
"->",
"config",
"[",
"'dir'",
"]",
"[",
"'layout'",
"]",
".",
"'/header.html.tpl'",
",",
"file_get_contents",
"(",
"__DIR__",
".",
"'/tpl/header.html.tpl'",
")",
")",
";",
"// master layout",
"file_put_contents",
"(",
"$",
"this",
"->",
"config",
"[",
"'dir'",
"]",
"[",
"'layout'",
"]",
".",
"'/layout.html.tpl'",
",",
"file_get_contents",
"(",
"__DIR__",
".",
"'/tpl/layout.html.tpl'",
")",
")",
";",
"}"
] | Creating template file. Template will be used for view
@return void | [
"Creating",
"template",
"file",
".",
"Template",
"will",
"be",
"used",
"for",
"view"
] | e7c27a103f1a87411dfb8eef626cba381b27d233 | https://github.com/glendmaatita/Tolkien/blob/e7c27a103f1a87411dfb8eef626cba381b27d233/src/Tolkien/Init.php#L76-L120 |
8,835 | glendmaatita/Tolkien | src/Tolkien/Init.php | Init.configContent | public function configContent($blog_dir)
{
$base_blog = basename($blog_dir);
return $array = array(
"config" => array(
"name" => $this->name,
"url" => '/',
"title" => "Your Site Title",
"tagline" => "Your Site Tagline",
"pagination" => 10),
"dir" => array(
"post" => $base_blog . "/_posts",
"page" => $base_blog . "/_pages",
"site" => $base_blog . "/_sites",
"asset" => $base_blog . "/_assets",
"layout" => $base_blog . "/_layouts",
),
"authors" => array(
'tolkien' => array(
'name' => 'John Ronald Reuel Tolkien',
'email' => '[email protected]',
'facebook' => 'Tolkien',
'twitter' => '@tolkien',
'github' => 'Tolkien',
'signature' => 'Creator of LoTR Trilogy'
)
)
);
} | php | public function configContent($blog_dir)
{
$base_blog = basename($blog_dir);
return $array = array(
"config" => array(
"name" => $this->name,
"url" => '/',
"title" => "Your Site Title",
"tagline" => "Your Site Tagline",
"pagination" => 10),
"dir" => array(
"post" => $base_blog . "/_posts",
"page" => $base_blog . "/_pages",
"site" => $base_blog . "/_sites",
"asset" => $base_blog . "/_assets",
"layout" => $base_blog . "/_layouts",
),
"authors" => array(
'tolkien' => array(
'name' => 'John Ronald Reuel Tolkien',
'email' => '[email protected]',
'facebook' => 'Tolkien',
'twitter' => '@tolkien',
'github' => 'Tolkien',
'signature' => 'Creator of LoTR Trilogy'
)
)
);
} | [
"public",
"function",
"configContent",
"(",
"$",
"blog_dir",
")",
"{",
"$",
"base_blog",
"=",
"basename",
"(",
"$",
"blog_dir",
")",
";",
"return",
"$",
"array",
"=",
"array",
"(",
"\"config\"",
"=>",
"array",
"(",
"\"name\"",
"=>",
"$",
"this",
"->",
"name",
",",
"\"url\"",
"=>",
"'/'",
",",
"\"title\"",
"=>",
"\"Your Site Title\"",
",",
"\"tagline\"",
"=>",
"\"Your Site Tagline\"",
",",
"\"pagination\"",
"=>",
"10",
")",
",",
"\"dir\"",
"=>",
"array",
"(",
"\"post\"",
"=>",
"$",
"base_blog",
".",
"\"/_posts\"",
",",
"\"page\"",
"=>",
"$",
"base_blog",
".",
"\"/_pages\"",
",",
"\"site\"",
"=>",
"$",
"base_blog",
".",
"\"/_sites\"",
",",
"\"asset\"",
"=>",
"$",
"base_blog",
".",
"\"/_assets\"",
",",
"\"layout\"",
"=>",
"$",
"base_blog",
".",
"\"/_layouts\"",
",",
")",
",",
"\"authors\"",
"=>",
"array",
"(",
"'tolkien'",
"=>",
"array",
"(",
"'name'",
"=>",
"'John Ronald Reuel Tolkien'",
",",
"'email'",
"=>",
"'[email protected]'",
",",
"'facebook'",
"=>",
"'Tolkien'",
",",
"'twitter'",
"=>",
"'@tolkien'",
",",
"'github'",
"=>",
"'Tolkien'",
",",
"'signature'",
"=>",
"'Creator of LoTR Trilogy'",
")",
")",
")",
";",
"}"
] | Content of config.yml
@return array | [
"Content",
"of",
"config",
".",
"yml"
] | e7c27a103f1a87411dfb8eef626cba381b27d233 | https://github.com/glendmaatita/Tolkien/blob/e7c27a103f1a87411dfb8eef626cba381b27d233/src/Tolkien/Init.php#L127-L156 |
8,836 | gridprinciples/friendly | src/Traits/Friendly.php | Friendly.block | public function block($model)
{
$deletedAtLeastOne = false;
if ($this->friends->count()) {
foreach ($this->friends as $friend) {
if ($friend->getKey() == $model->id) {
$friend->pivot->delete();
$this->resetFriends();
$deletedAtLeastOne = true;
}
}
}
return $deletedAtLeastOne;
} | php | public function block($model)
{
$deletedAtLeastOne = false;
if ($this->friends->count()) {
foreach ($this->friends as $friend) {
if ($friend->getKey() == $model->id) {
$friend->pivot->delete();
$this->resetFriends();
$deletedAtLeastOne = true;
}
}
}
return $deletedAtLeastOne;
} | [
"public",
"function",
"block",
"(",
"$",
"model",
")",
"{",
"$",
"deletedAtLeastOne",
"=",
"false",
";",
"if",
"(",
"$",
"this",
"->",
"friends",
"->",
"count",
"(",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"friends",
"as",
"$",
"friend",
")",
"{",
"if",
"(",
"$",
"friend",
"->",
"getKey",
"(",
")",
"==",
"$",
"model",
"->",
"id",
")",
"{",
"$",
"friend",
"->",
"pivot",
"->",
"delete",
"(",
")",
";",
"$",
"this",
"->",
"resetFriends",
"(",
")",
";",
"$",
"deletedAtLeastOne",
"=",
"true",
";",
"}",
"}",
"}",
"return",
"$",
"deletedAtLeastOne",
";",
"}"
] | Remove the connection between these two models. AKA "block user".
@param $model
@return bool | [
"Remove",
"the",
"connection",
"between",
"these",
"two",
"models",
".",
"AKA",
"block",
"user",
"."
] | cb5ffa8834b3f3f38275765339597f3355fd4f75 | https://github.com/gridprinciples/friendly/blob/cb5ffa8834b3f3f38275765339597f3355fd4f75/src/Traits/Friendly.php#L28-L44 |
8,837 | gridprinciples/friendly | src/Traits/Friendly.php | Friendly.approve | public function approve($model)
{
$approvedAtLeastOne = false;
if ($model->friends->count()) {
foreach ($model->friends as $friend) {
if ((int) $friend->getKey() === (int) $this->getKey()) {
$friend->pivot->approved_at = new \Carbon\Carbon;
$friend->pivot->save();
$this->resetFriends();
$approvedAtLeastOne = true;
}
}
}
return $approvedAtLeastOne;
} | php | public function approve($model)
{
$approvedAtLeastOne = false;
if ($model->friends->count()) {
foreach ($model->friends as $friend) {
if ((int) $friend->getKey() === (int) $this->getKey()) {
$friend->pivot->approved_at = new \Carbon\Carbon;
$friend->pivot->save();
$this->resetFriends();
$approvedAtLeastOne = true;
}
}
}
return $approvedAtLeastOne;
} | [
"public",
"function",
"approve",
"(",
"$",
"model",
")",
"{",
"$",
"approvedAtLeastOne",
"=",
"false",
";",
"if",
"(",
"$",
"model",
"->",
"friends",
"->",
"count",
"(",
")",
")",
"{",
"foreach",
"(",
"$",
"model",
"->",
"friends",
"as",
"$",
"friend",
")",
"{",
"if",
"(",
"(",
"int",
")",
"$",
"friend",
"->",
"getKey",
"(",
")",
"===",
"(",
"int",
")",
"$",
"this",
"->",
"getKey",
"(",
")",
")",
"{",
"$",
"friend",
"->",
"pivot",
"->",
"approved_at",
"=",
"new",
"\\",
"Carbon",
"\\",
"Carbon",
";",
"$",
"friend",
"->",
"pivot",
"->",
"save",
"(",
")",
";",
"$",
"this",
"->",
"resetFriends",
"(",
")",
";",
"$",
"approvedAtLeastOne",
"=",
"true",
";",
"}",
"}",
"}",
"return",
"$",
"approvedAtLeastOne",
";",
"}"
] | Approve an incoming connection request. AKA "approve request"
@param $model
@return bool | [
"Approve",
"an",
"incoming",
"connection",
"request",
".",
"AKA",
"approve",
"request"
] | cb5ffa8834b3f3f38275765339597f3355fd4f75 | https://github.com/gridprinciples/friendly/blob/cb5ffa8834b3f3f38275765339597f3355fd4f75/src/Traits/Friendly.php#L52-L69 |
8,838 | gridprinciples/friendly | src/Traits/Friendly.php | Friendly.getCurrentFriendsAttribute | public function getCurrentFriendsAttribute()
{
return $this->friends->filter(function ($item) {
$now = new \Carbon\Carbon;
if(!$item->pivot->approved_at)
{
return false;
}
switch (true) {
// no dates set
case !$item->pivot->end && !$item->pivot->start:
// start is set but is in the future
case !$item->pivot->end && $item->pivot->start && $item->pivot->start < $now:
// end is set but is in the past
case !$item->pivot->start && $item->pivot->end && $item->pivot->end > $now:
// both start and end are set, but we are currently between those dates
case $item->pivot->start && $item->pivot->start < $now && $item->pivot->end && $item->pivot->end > $now:
return true;
break;
}
// any other scenario fails
return false;
});
} | php | public function getCurrentFriendsAttribute()
{
return $this->friends->filter(function ($item) {
$now = new \Carbon\Carbon;
if(!$item->pivot->approved_at)
{
return false;
}
switch (true) {
// no dates set
case !$item->pivot->end && !$item->pivot->start:
// start is set but is in the future
case !$item->pivot->end && $item->pivot->start && $item->pivot->start < $now:
// end is set but is in the past
case !$item->pivot->start && $item->pivot->end && $item->pivot->end > $now:
// both start and end are set, but we are currently between those dates
case $item->pivot->start && $item->pivot->start < $now && $item->pivot->end && $item->pivot->end > $now:
return true;
break;
}
// any other scenario fails
return false;
});
} | [
"public",
"function",
"getCurrentFriendsAttribute",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"friends",
"->",
"filter",
"(",
"function",
"(",
"$",
"item",
")",
"{",
"$",
"now",
"=",
"new",
"\\",
"Carbon",
"\\",
"Carbon",
";",
"if",
"(",
"!",
"$",
"item",
"->",
"pivot",
"->",
"approved_at",
")",
"{",
"return",
"false",
";",
"}",
"switch",
"(",
"true",
")",
"{",
"// no dates set",
"case",
"!",
"$",
"item",
"->",
"pivot",
"->",
"end",
"&&",
"!",
"$",
"item",
"->",
"pivot",
"->",
"start",
":",
"// start is set but is in the future",
"case",
"!",
"$",
"item",
"->",
"pivot",
"->",
"end",
"&&",
"$",
"item",
"->",
"pivot",
"->",
"start",
"&&",
"$",
"item",
"->",
"pivot",
"->",
"start",
"<",
"$",
"now",
":",
"// end is set but is in the past",
"case",
"!",
"$",
"item",
"->",
"pivot",
"->",
"start",
"&&",
"$",
"item",
"->",
"pivot",
"->",
"end",
"&&",
"$",
"item",
"->",
"pivot",
"->",
"end",
">",
"$",
"now",
":",
"// both start and end are set, but we are currently between those dates",
"case",
"$",
"item",
"->",
"pivot",
"->",
"start",
"&&",
"$",
"item",
"->",
"pivot",
"->",
"start",
"<",
"$",
"now",
"&&",
"$",
"item",
"->",
"pivot",
"->",
"end",
"&&",
"$",
"item",
"->",
"pivot",
"->",
"end",
">",
"$",
"now",
":",
"return",
"true",
";",
"break",
";",
"}",
"// any other scenario fails",
"return",
"false",
";",
"}",
")",
";",
"}"
] | Filters the primary connections by ones that are currently active.
@return mixed | [
"Filters",
"the",
"primary",
"connections",
"by",
"ones",
"that",
"are",
"currently",
"active",
"."
] | cb5ffa8834b3f3f38275765339597f3355fd4f75 | https://github.com/gridprinciples/friendly/blob/cb5ffa8834b3f3f38275765339597f3355fd4f75/src/Traits/Friendly.php#L90-L120 |
8,839 | gridprinciples/friendly | src/Traits/Friendly.php | Friendly.mergeMineAndRequestedFriends | protected function mergeMineAndRequestedFriends()
{
$all = $this->sentRequests;
if($more = $this->receivedApprovedRequests->all())
{
foreach($more as $m)
{
$all->add($m);
}
}
return $all;
} | php | protected function mergeMineAndRequestedFriends()
{
$all = $this->sentRequests;
if($more = $this->receivedApprovedRequests->all())
{
foreach($more as $m)
{
$all->add($m);
}
}
return $all;
} | [
"protected",
"function",
"mergeMineAndRequestedFriends",
"(",
")",
"{",
"$",
"all",
"=",
"$",
"this",
"->",
"sentRequests",
";",
"if",
"(",
"$",
"more",
"=",
"$",
"this",
"->",
"receivedApprovedRequests",
"->",
"all",
"(",
")",
")",
"{",
"foreach",
"(",
"$",
"more",
"as",
"$",
"m",
")",
"{",
"$",
"all",
"->",
"add",
"(",
"$",
"m",
")",
";",
"}",
"}",
"return",
"$",
"all",
";",
"}"
] | Merge the result of two relationships.
@return mixed | [
"Merge",
"the",
"result",
"of",
"two",
"relationships",
"."
] | cb5ffa8834b3f3f38275765339597f3355fd4f75 | https://github.com/gridprinciples/friendly/blob/cb5ffa8834b3f3f38275765339597f3355fd4f75/src/Traits/Friendly.php#L173-L186 |
8,840 | EarthlingInteractive/PHPCMIPREST | lib/EarthIT/CMIPREST/ResultAssembler/CSVResultAssembler.php | EarthIT_CMIPREST_ResultAssembler_CSVResultAssembler.assembleResult | public function assembleResult( EarthIT_CMIPREST_ActionResult $result, TOGoS_Action $action=null, $ctx=null ) {
$rootRc = $result->getRootResourceClass();
$columnHeaders = array();
foreach( $rootRc->getFields() as $fn=>$field ) {
$columnHeaders[] = $fn;
}
$itemCollections = $result->getItemCollections();
$rows = array($columnHeaders);
foreach( $itemCollections['root'] as $item ) {
$row = array();
foreach( $columnHeaders as $c ) {
$row[$c] = $item[$c];
}
$rows[] = $row;
}
return $rows;
} | php | public function assembleResult( EarthIT_CMIPREST_ActionResult $result, TOGoS_Action $action=null, $ctx=null ) {
$rootRc = $result->getRootResourceClass();
$columnHeaders = array();
foreach( $rootRc->getFields() as $fn=>$field ) {
$columnHeaders[] = $fn;
}
$itemCollections = $result->getItemCollections();
$rows = array($columnHeaders);
foreach( $itemCollections['root'] as $item ) {
$row = array();
foreach( $columnHeaders as $c ) {
$row[$c] = $item[$c];
}
$rows[] = $row;
}
return $rows;
} | [
"public",
"function",
"assembleResult",
"(",
"EarthIT_CMIPREST_ActionResult",
"$",
"result",
",",
"TOGoS_Action",
"$",
"action",
"=",
"null",
",",
"$",
"ctx",
"=",
"null",
")",
"{",
"$",
"rootRc",
"=",
"$",
"result",
"->",
"getRootResourceClass",
"(",
")",
";",
"$",
"columnHeaders",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"rootRc",
"->",
"getFields",
"(",
")",
"as",
"$",
"fn",
"=>",
"$",
"field",
")",
"{",
"$",
"columnHeaders",
"[",
"]",
"=",
"$",
"fn",
";",
"}",
"$",
"itemCollections",
"=",
"$",
"result",
"->",
"getItemCollections",
"(",
")",
";",
"$",
"rows",
"=",
"array",
"(",
"$",
"columnHeaders",
")",
";",
"foreach",
"(",
"$",
"itemCollections",
"[",
"'root'",
"]",
"as",
"$",
"item",
")",
"{",
"$",
"row",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"columnHeaders",
"as",
"$",
"c",
")",
"{",
"$",
"row",
"[",
"$",
"c",
"]",
"=",
"$",
"item",
"[",
"$",
"c",
"]",
";",
"}",
"$",
"rows",
"[",
"]",
"=",
"$",
"row",
";",
"}",
"return",
"$",
"rows",
";",
"}"
] | Assemble a StorageResult into whatever format the thing that's
going to take the results needs. Normally this will be an array.
@param EarthIT_CMIPREST_ActionResult $result the return value of the action
@param TOGoS_Action $action the action that was invoked to get this result
@param mixed $ctx some value representing the context in which the action was done | [
"Assemble",
"a",
"StorageResult",
"into",
"whatever",
"format",
"the",
"thing",
"that",
"s",
"going",
"to",
"take",
"the",
"results",
"needs",
".",
"Normally",
"this",
"will",
"be",
"an",
"array",
"."
] | db0398ea4fc07fa62f2de9ba43f2f3137170d9f0 | https://github.com/EarthlingInteractive/PHPCMIPREST/blob/db0398ea4fc07fa62f2de9ba43f2f3137170d9f0/lib/EarthIT/CMIPREST/ResultAssembler/CSVResultAssembler.php#L15-L32 |
8,841 | EarthlingInteractive/PHPCMIPREST | lib/EarthIT/CMIPREST/ResultAssembler/CSVResultAssembler.php | EarthIT_CMIPREST_ResultAssembler_CSVResultAssembler.assembledResultToHttpResponse | public function assembledResultToHttpResponse( $assembled, TOGoS_Action $action=null, $ctx=null ) {
return Nife_Util::httpResponse(200, new EarthIT_CMIPREST_CSVBlob($assembled), array('content-type'=>'text/csv'));
} | php | public function assembledResultToHttpResponse( $assembled, TOGoS_Action $action=null, $ctx=null ) {
return Nife_Util::httpResponse(200, new EarthIT_CMIPREST_CSVBlob($assembled), array('content-type'=>'text/csv'));
} | [
"public",
"function",
"assembledResultToHttpResponse",
"(",
"$",
"assembled",
",",
"TOGoS_Action",
"$",
"action",
"=",
"null",
",",
"$",
"ctx",
"=",
"null",
")",
"{",
"return",
"Nife_Util",
"::",
"httpResponse",
"(",
"200",
",",
"new",
"EarthIT_CMIPREST_CSVBlob",
"(",
"$",
"assembled",
")",
",",
"array",
"(",
"'content-type'",
"=>",
"'text/csv'",
")",
")",
";",
"}"
] | Take the result returned by assembleResult and encode
it as a Nife_HTTP_Response | [
"Take",
"the",
"result",
"returned",
"by",
"assembleResult",
"and",
"encode",
"it",
"as",
"a",
"Nife_HTTP_Response"
] | db0398ea4fc07fa62f2de9ba43f2f3137170d9f0 | https://github.com/EarthlingInteractive/PHPCMIPREST/blob/db0398ea4fc07fa62f2de9ba43f2f3137170d9f0/lib/EarthIT/CMIPREST/ResultAssembler/CSVResultAssembler.php#L38-L40 |
8,842 | EarthlingInteractive/PHPCMIPREST | lib/EarthIT/CMIPREST/ResultAssembler/CSVResultAssembler.php | EarthIT_CMIPREST_ResultAssembler_CSVResultAssembler.exceptionToHttpResponse | public function exceptionToHttpResponse( Exception $e, TOGoS_Action $action=null, $ctx=null ) {
$userIsAuthenticated = ($ctx and method_exists($ctx,'userIsAuthenticated')) ? $ctx->userIsAuthenticated() : false;
return EarthIT_CMIPREST_Util::exceptionalNormalJsonHttpResponse($e, $userIsAuthenticated, array(
EarthIT_CMIPREST_Util::BASIC_WWW_AUTHENTICATION_REALM => $this->basicWwwAuthenticationRealm
));
} | php | public function exceptionToHttpResponse( Exception $e, TOGoS_Action $action=null, $ctx=null ) {
$userIsAuthenticated = ($ctx and method_exists($ctx,'userIsAuthenticated')) ? $ctx->userIsAuthenticated() : false;
return EarthIT_CMIPREST_Util::exceptionalNormalJsonHttpResponse($e, $userIsAuthenticated, array(
EarthIT_CMIPREST_Util::BASIC_WWW_AUTHENTICATION_REALM => $this->basicWwwAuthenticationRealm
));
} | [
"public",
"function",
"exceptionToHttpResponse",
"(",
"Exception",
"$",
"e",
",",
"TOGoS_Action",
"$",
"action",
"=",
"null",
",",
"$",
"ctx",
"=",
"null",
")",
"{",
"$",
"userIsAuthenticated",
"=",
"(",
"$",
"ctx",
"and",
"method_exists",
"(",
"$",
"ctx",
",",
"'userIsAuthenticated'",
")",
")",
"?",
"$",
"ctx",
"->",
"userIsAuthenticated",
"(",
")",
":",
"false",
";",
"return",
"EarthIT_CMIPREST_Util",
"::",
"exceptionalNormalJsonHttpResponse",
"(",
"$",
"e",
",",
"$",
"userIsAuthenticated",
",",
"array",
"(",
"EarthIT_CMIPREST_Util",
"::",
"BASIC_WWW_AUTHENTICATION_REALM",
"=>",
"$",
"this",
"->",
"basicWwwAuthenticationRealm",
")",
")",
";",
"}"
] | Encode the fact that an exception occurred as a Nife_HTTP_Response. | [
"Encode",
"the",
"fact",
"that",
"an",
"exception",
"occurred",
"as",
"a",
"Nife_HTTP_Response",
"."
] | db0398ea4fc07fa62f2de9ba43f2f3137170d9f0 | https://github.com/EarthlingInteractive/PHPCMIPREST/blob/db0398ea4fc07fa62f2de9ba43f2f3137170d9f0/lib/EarthIT/CMIPREST/ResultAssembler/CSVResultAssembler.php#L45-L50 |
8,843 | squire-assistant/debug | FatalErrorHandler/ClassNotFoundFatalErrorHandler.php | ClassNotFoundFatalErrorHandler.getClassCandidates | private function getClassCandidates($class)
{
if (!is_array($functions = spl_autoload_functions())) {
return array();
}
// find Symfony and Composer autoloaders
$classes = array();
foreach ($functions as $function) {
if (!is_array($function)) {
continue;
}
// get class loaders wrapped by DebugClassLoader
if ($function[0] instanceof DebugClassLoader) {
$function = $function[0]->getClassLoader();
if (!is_array($function)) {
continue;
}
}
if ($function[0] instanceof ComposerClassLoader || $function[0] instanceof SymfonyClassLoader) {
foreach ($function[0]->getPrefixes() as $prefix => $paths) {
foreach ($paths as $path) {
$classes = array_merge($classes, $this->findClassInPath($path, $class, $prefix));
}
}
}
if ($function[0] instanceof ComposerClassLoader) {
foreach ($function[0]->getPrefixesPsr4() as $prefix => $paths) {
foreach ($paths as $path) {
$classes = array_merge($classes, $this->findClassInPath($path, $class, $prefix));
}
}
}
}
return array_unique($classes);
} | php | private function getClassCandidates($class)
{
if (!is_array($functions = spl_autoload_functions())) {
return array();
}
// find Symfony and Composer autoloaders
$classes = array();
foreach ($functions as $function) {
if (!is_array($function)) {
continue;
}
// get class loaders wrapped by DebugClassLoader
if ($function[0] instanceof DebugClassLoader) {
$function = $function[0]->getClassLoader();
if (!is_array($function)) {
continue;
}
}
if ($function[0] instanceof ComposerClassLoader || $function[0] instanceof SymfonyClassLoader) {
foreach ($function[0]->getPrefixes() as $prefix => $paths) {
foreach ($paths as $path) {
$classes = array_merge($classes, $this->findClassInPath($path, $class, $prefix));
}
}
}
if ($function[0] instanceof ComposerClassLoader) {
foreach ($function[0]->getPrefixesPsr4() as $prefix => $paths) {
foreach ($paths as $path) {
$classes = array_merge($classes, $this->findClassInPath($path, $class, $prefix));
}
}
}
}
return array_unique($classes);
} | [
"private",
"function",
"getClassCandidates",
"(",
"$",
"class",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"functions",
"=",
"spl_autoload_functions",
"(",
")",
")",
")",
"{",
"return",
"array",
"(",
")",
";",
"}",
"// find Symfony and Composer autoloaders",
"$",
"classes",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"functions",
"as",
"$",
"function",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"function",
")",
")",
"{",
"continue",
";",
"}",
"// get class loaders wrapped by DebugClassLoader",
"if",
"(",
"$",
"function",
"[",
"0",
"]",
"instanceof",
"DebugClassLoader",
")",
"{",
"$",
"function",
"=",
"$",
"function",
"[",
"0",
"]",
"->",
"getClassLoader",
"(",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"function",
")",
")",
"{",
"continue",
";",
"}",
"}",
"if",
"(",
"$",
"function",
"[",
"0",
"]",
"instanceof",
"ComposerClassLoader",
"||",
"$",
"function",
"[",
"0",
"]",
"instanceof",
"SymfonyClassLoader",
")",
"{",
"foreach",
"(",
"$",
"function",
"[",
"0",
"]",
"->",
"getPrefixes",
"(",
")",
"as",
"$",
"prefix",
"=>",
"$",
"paths",
")",
"{",
"foreach",
"(",
"$",
"paths",
"as",
"$",
"path",
")",
"{",
"$",
"classes",
"=",
"array_merge",
"(",
"$",
"classes",
",",
"$",
"this",
"->",
"findClassInPath",
"(",
"$",
"path",
",",
"$",
"class",
",",
"$",
"prefix",
")",
")",
";",
"}",
"}",
"}",
"if",
"(",
"$",
"function",
"[",
"0",
"]",
"instanceof",
"ComposerClassLoader",
")",
"{",
"foreach",
"(",
"$",
"function",
"[",
"0",
"]",
"->",
"getPrefixesPsr4",
"(",
")",
"as",
"$",
"prefix",
"=>",
"$",
"paths",
")",
"{",
"foreach",
"(",
"$",
"paths",
"as",
"$",
"path",
")",
"{",
"$",
"classes",
"=",
"array_merge",
"(",
"$",
"classes",
",",
"$",
"this",
"->",
"findClassInPath",
"(",
"$",
"path",
",",
"$",
"class",
",",
"$",
"prefix",
")",
")",
";",
"}",
"}",
"}",
"}",
"return",
"array_unique",
"(",
"$",
"classes",
")",
";",
"}"
] | Tries to guess the full namespace for a given class name.
By default, it looks for PSR-0 and PSR-4 classes registered via a Symfony or a Composer
autoloader (that should cover all common cases).
@param string $class A class name (without its namespace)
@return array An array of possible fully qualified class names | [
"Tries",
"to",
"guess",
"the",
"full",
"namespace",
"for",
"a",
"given",
"class",
"name",
"."
] | c43819e74eea94cde8faf31c1a6b00f018e607a0 | https://github.com/squire-assistant/debug/blob/c43819e74eea94cde8faf31c1a6b00f018e607a0/FatalErrorHandler/ClassNotFoundFatalErrorHandler.php#L86-L125 |
8,844 | simondeeley/type | src/Helpers/TypeEqualityHelperMethods.php | TypeEqualityHelperMethods.isSameObjectAs | final private function isSameObjectAs(Type $type, int $flags = null): bool
{
if ($flags & TypeEquality::IGNORE_OBJECT_IDENTITY) {
return true;
}
return (spl_object_hash($this) === spl_object_hash($type)) ? true : false;
} | php | final private function isSameObjectAs(Type $type, int $flags = null): bool
{
if ($flags & TypeEquality::IGNORE_OBJECT_IDENTITY) {
return true;
}
return (spl_object_hash($this) === spl_object_hash($type)) ? true : false;
} | [
"final",
"private",
"function",
"isSameObjectAs",
"(",
"Type",
"$",
"type",
",",
"int",
"$",
"flags",
"=",
"null",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"flags",
"&",
"TypeEquality",
"::",
"IGNORE_OBJECT_IDENTITY",
")",
"{",
"return",
"true",
";",
"}",
"return",
"(",
"spl_object_hash",
"(",
"$",
"this",
")",
"===",
"spl_object_hash",
"(",
"$",
"type",
")",
")",
"?",
"true",
":",
"false",
";",
"}"
] | Check against an objects ID
Makes a comparison against an objects identity, obtained through the use
of spl_object_hash. Method returns true if both objects point to the
same PHP reference. Note that this method also returns true when the $flag
is set to ignore this type of check.
@param Type $type - the object to check against
@param int|null $flags - optional flags enable or disable certain checks
@return bool - Returns true if identities are equal | [
"Check",
"against",
"an",
"objects",
"ID"
] | 1c96f526fd8b532482517a1c647d956fa4e4e348 | https://github.com/simondeeley/type/blob/1c96f526fd8b532482517a1c647d956fa4e4e348/src/Helpers/TypeEqualityHelperMethods.php#L72-L79 |
8,845 | wasabi-cms/core | src/Model/Table/SettingsTable.php | SettingsTable.afterSave | public function afterSave(Event $event, Setting $entity, ArrayObject $options)
{
Cache::delete('settings', 'wasabi/core/longterm');
$this->eventManager()->dispatch(new Event('Wasabi.Settings.changed'));
} | php | public function afterSave(Event $event, Setting $entity, ArrayObject $options)
{
Cache::delete('settings', 'wasabi/core/longterm');
$this->eventManager()->dispatch(new Event('Wasabi.Settings.changed'));
} | [
"public",
"function",
"afterSave",
"(",
"Event",
"$",
"event",
",",
"Setting",
"$",
"entity",
",",
"ArrayObject",
"$",
"options",
")",
"{",
"Cache",
"::",
"delete",
"(",
"'settings'",
",",
"'wasabi/core/longterm'",
")",
";",
"$",
"this",
"->",
"eventManager",
"(",
")",
"->",
"dispatch",
"(",
"new",
"Event",
"(",
"'Wasabi.Settings.changed'",
")",
")",
";",
"}"
] | Called after an entity is saved.
@param Event $event An event instance.
@param Setting $entity The entity that triggered the event.
@param ArrayObject $options Additional options passed to the save call.
@return void | [
"Called",
"after",
"an",
"entity",
"is",
"saved",
"."
] | 0eadbb64d2fc201bacc63c93814adeca70e08f90 | https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/Model/Table/SettingsTable.php#L51-L55 |
8,846 | twister-php/twister | src/ORM/Collection.php | Collection.map | public function map(callable $callback)
{
$keys = array_keys($this->members);
$members = array_map($callback, $this->members, $keys);
return new static(array_combine($keys, $members));
} | php | public function map(callable $callback)
{
$keys = array_keys($this->members);
$members = array_map($callback, $this->members, $keys);
return new static(array_combine($keys, $members));
} | [
"public",
"function",
"map",
"(",
"callable",
"$",
"callback",
")",
"{",
"$",
"keys",
"=",
"array_keys",
"(",
"$",
"this",
"->",
"members",
")",
";",
"$",
"members",
"=",
"array_map",
"(",
"$",
"callback",
",",
"$",
"this",
"->",
"members",
",",
"$",
"keys",
")",
";",
"return",
"new",
"static",
"(",
"array_combine",
"(",
"$",
"keys",
",",
"$",
"members",
")",
")",
";",
"}"
] | Run a map over each of the members.
@link http://php.net/manual/en/function.array-map.php
@param callable $callback
@return static | [
"Run",
"a",
"map",
"over",
"each",
"of",
"the",
"members",
"."
] | c06ea2650331faf11590c017c850dc5f0bbc5c13 | https://github.com/twister-php/twister/blob/c06ea2650331faf11590c017c850dc5f0bbc5c13/src/ORM/Collection.php#L92-L97 |
8,847 | twister-php/twister | src/ORM/Collection.php | Collection.random | public function random($num = 1)
{
if ($num == 1)
return $this->members[array_rand($this->members)];
$keys = array_rand($this->members, $num);
return new static(array_intersect_key($this->members, array_flip($keys)));
} | php | public function random($num = 1)
{
if ($num == 1)
return $this->members[array_rand($this->members)];
$keys = array_rand($this->members, $num);
return new static(array_intersect_key($this->members, array_flip($keys)));
} | [
"public",
"function",
"random",
"(",
"$",
"num",
"=",
"1",
")",
"{",
"if",
"(",
"$",
"num",
"==",
"1",
")",
"return",
"$",
"this",
"->",
"members",
"[",
"array_rand",
"(",
"$",
"this",
"->",
"members",
")",
"]",
";",
"$",
"keys",
"=",
"array_rand",
"(",
"$",
"this",
"->",
"members",
",",
"$",
"num",
")",
";",
"return",
"new",
"static",
"(",
"array_intersect_key",
"(",
"$",
"this",
"->",
"members",
",",
"array_flip",
"(",
"$",
"keys",
")",
")",
")",
";",
"}"
] | Get one or more random members from the collection.
@link http://php.net/manual/en/function.array-rand.php
@param int $num
@return mixed | [
"Get",
"one",
"or",
"more",
"random",
"members",
"from",
"the",
"collection",
"."
] | c06ea2650331faf11590c017c850dc5f0bbc5c13 | https://github.com/twister-php/twister/blob/c06ea2650331faf11590c017c850dc5f0bbc5c13/src/ORM/Collection.php#L187-L194 |
8,848 | twister-php/twister | src/ORM/Collection.php | Collection.filter | public function filter(callable $callback = null)
{
return new static($callback ? array_filter($this->members, $callback) : array_filter($this->members));
} | php | public function filter(callable $callback = null)
{
return new static($callback ? array_filter($this->members, $callback) : array_filter($this->members));
} | [
"public",
"function",
"filter",
"(",
"callable",
"$",
"callback",
"=",
"null",
")",
"{",
"return",
"new",
"static",
"(",
"$",
"callback",
"?",
"array_filter",
"(",
"$",
"this",
"->",
"members",
",",
"$",
"callback",
")",
":",
"array_filter",
"(",
"$",
"this",
"->",
"members",
")",
")",
";",
"}"
] | Run a filter over each of the members.
@link http://php.net/manual/en/function.array-filter.php
@param callable|null $callback
@return static | [
"Run",
"a",
"filter",
"over",
"each",
"of",
"the",
"members",
"."
] | c06ea2650331faf11590c017c850dc5f0bbc5c13 | https://github.com/twister-php/twister/blob/c06ea2650331faf11590c017c850dc5f0bbc5c13/src/ORM/Collection.php#L257-L260 |
8,849 | tacowordpress/util | src/Util/Arr.php | Arr.median | public static function median($arr)
{
$vals = array_values($arr);
sort($vals);
$num_vals = count($vals);
return ($num_vals % 2)
? ($vals[$num_vals / 2] + $vals[($num_vals / 2) + 1]) / 2
: $vals[($num_vals + 1) / 2];
} | php | public static function median($arr)
{
$vals = array_values($arr);
sort($vals);
$num_vals = count($vals);
return ($num_vals % 2)
? ($vals[$num_vals / 2] + $vals[($num_vals / 2) + 1]) / 2
: $vals[($num_vals + 1) / 2];
} | [
"public",
"static",
"function",
"median",
"(",
"$",
"arr",
")",
"{",
"$",
"vals",
"=",
"array_values",
"(",
"$",
"arr",
")",
";",
"sort",
"(",
"$",
"vals",
")",
";",
"$",
"num_vals",
"=",
"count",
"(",
"$",
"vals",
")",
";",
"return",
"(",
"$",
"num_vals",
"%",
"2",
")",
"?",
"(",
"$",
"vals",
"[",
"$",
"num_vals",
"/",
"2",
"]",
"+",
"$",
"vals",
"[",
"(",
"$",
"num_vals",
"/",
"2",
")",
"+",
"1",
"]",
")",
"/",
"2",
":",
"$",
"vals",
"[",
"(",
"$",
"num_vals",
"+",
"1",
")",
"/",
"2",
"]",
";",
"}"
] | Get the median
@param array $arr
@return mixed | [
"Get",
"the",
"median"
] | a27f6f1c3f96a908c7480f359fd44028e89f26c3 | https://github.com/tacowordpress/util/blob/a27f6f1c3f96a908c7480f359fd44028e89f26c3/src/Util/Arr.php#L38-L47 |
8,850 | tacowordpress/util | src/Util/Arr.php | Arr.mode | public static function mode($arr)
{
$vals = array_count_values($arr);
asort($vals);
return end(array_keys($vals));
} | php | public static function mode($arr)
{
$vals = array_count_values($arr);
asort($vals);
return end(array_keys($vals));
} | [
"public",
"static",
"function",
"mode",
"(",
"$",
"arr",
")",
"{",
"$",
"vals",
"=",
"array_count_values",
"(",
"$",
"arr",
")",
";",
"asort",
"(",
"$",
"vals",
")",
";",
"return",
"end",
"(",
"array_keys",
"(",
"$",
"vals",
")",
")",
";",
"}"
] | Get the mode
@param array $arr
@return mixed | [
"Get",
"the",
"mode"
] | a27f6f1c3f96a908c7480f359fd44028e89f26c3 | https://github.com/tacowordpress/util/blob/a27f6f1c3f96a908c7480f359fd44028e89f26c3/src/Util/Arr.php#L55-L60 |
8,851 | tacowordpress/util | src/Util/Arr.php | Arr.withKeys | public static function withKeys($records, $keys)
{
if (!self::iterable($records)) {
return array();
}
$out = array();
foreach ($records as $n => $record) {
if (!self::iterable($record)) {
$out[$n] = $record;
continue;
}
$out[$n] = array();
foreach ($record as $k => $v) {
if (!in_array($k, $keys)) {
continue;
}
$out[$n][$k] = $v;
}
}
return $out;
} | php | public static function withKeys($records, $keys)
{
if (!self::iterable($records)) {
return array();
}
$out = array();
foreach ($records as $n => $record) {
if (!self::iterable($record)) {
$out[$n] = $record;
continue;
}
$out[$n] = array();
foreach ($record as $k => $v) {
if (!in_array($k, $keys)) {
continue;
}
$out[$n][$k] = $v;
}
}
return $out;
} | [
"public",
"static",
"function",
"withKeys",
"(",
"$",
"records",
",",
"$",
"keys",
")",
"{",
"if",
"(",
"!",
"self",
"::",
"iterable",
"(",
"$",
"records",
")",
")",
"{",
"return",
"array",
"(",
")",
";",
"}",
"$",
"out",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"records",
"as",
"$",
"n",
"=>",
"$",
"record",
")",
"{",
"if",
"(",
"!",
"self",
"::",
"iterable",
"(",
"$",
"record",
")",
")",
"{",
"$",
"out",
"[",
"$",
"n",
"]",
"=",
"$",
"record",
";",
"continue",
";",
"}",
"$",
"out",
"[",
"$",
"n",
"]",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"record",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"k",
",",
"$",
"keys",
")",
")",
"{",
"continue",
";",
"}",
"$",
"out",
"[",
"$",
"n",
"]",
"[",
"$",
"k",
"]",
"=",
"$",
"v",
";",
"}",
"}",
"return",
"$",
"out",
";",
"}"
] | Get the data only with specific keys
@param array $records
@param array $keys
@return array | [
"Get",
"the",
"data",
"only",
"with",
"specific",
"keys"
] | a27f6f1c3f96a908c7480f359fd44028e89f26c3 | https://github.com/tacowordpress/util/blob/a27f6f1c3f96a908c7480f359fd44028e89f26c3/src/Util/Arr.php#L69-L91 |
8,852 | tacowordpress/util | src/Util/Arr.php | Arr.apportion | public static function apportion($arr, $num_groups = 2, $strict_group_count = false, $backload = false)
{
if (!self::iterable($arr)) {
return array();
}
if ($backload) {
$arr = array_reverse($arr, true);
}
$apportioned = array();
$per_group = ceil(count($arr) / $num_groups);
if ($strict_group_count) {
$apportioned = array_chunk($arr, $per_group, true);
} else {
$shortage = ($per_group * $num_groups) - count($arr);
if ($shortage > 1) {
$keys = array_keys($arr);
$first_keys = array_splice($keys, 0, $per_group);
$first_group = array_splice($arr, 0, $per_group);
$first_group = array_combine($first_keys, $first_group);
$arr = array_combine($keys, $arr);
$remainders = self::apportion($arr, $num_groups - 1);
$apportioned = array_merge(array($first_group), $remainders);
} else {
$apportioned = array_chunk($arr, $per_group, true);
}
}
if ($backload) {
foreach ($apportioned as &$group) {
$group = array_reverse($group, true);
}
$apportioned = array_reverse($apportioned, true);
}
return $apportioned;
} | php | public static function apportion($arr, $num_groups = 2, $strict_group_count = false, $backload = false)
{
if (!self::iterable($arr)) {
return array();
}
if ($backload) {
$arr = array_reverse($arr, true);
}
$apportioned = array();
$per_group = ceil(count($arr) / $num_groups);
if ($strict_group_count) {
$apportioned = array_chunk($arr, $per_group, true);
} else {
$shortage = ($per_group * $num_groups) - count($arr);
if ($shortage > 1) {
$keys = array_keys($arr);
$first_keys = array_splice($keys, 0, $per_group);
$first_group = array_splice($arr, 0, $per_group);
$first_group = array_combine($first_keys, $first_group);
$arr = array_combine($keys, $arr);
$remainders = self::apportion($arr, $num_groups - 1);
$apportioned = array_merge(array($first_group), $remainders);
} else {
$apportioned = array_chunk($arr, $per_group, true);
}
}
if ($backload) {
foreach ($apportioned as &$group) {
$group = array_reverse($group, true);
}
$apportioned = array_reverse($apportioned, true);
}
return $apportioned;
} | [
"public",
"static",
"function",
"apportion",
"(",
"$",
"arr",
",",
"$",
"num_groups",
"=",
"2",
",",
"$",
"strict_group_count",
"=",
"false",
",",
"$",
"backload",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"self",
"::",
"iterable",
"(",
"$",
"arr",
")",
")",
"{",
"return",
"array",
"(",
")",
";",
"}",
"if",
"(",
"$",
"backload",
")",
"{",
"$",
"arr",
"=",
"array_reverse",
"(",
"$",
"arr",
",",
"true",
")",
";",
"}",
"$",
"apportioned",
"=",
"array",
"(",
")",
";",
"$",
"per_group",
"=",
"ceil",
"(",
"count",
"(",
"$",
"arr",
")",
"/",
"$",
"num_groups",
")",
";",
"if",
"(",
"$",
"strict_group_count",
")",
"{",
"$",
"apportioned",
"=",
"array_chunk",
"(",
"$",
"arr",
",",
"$",
"per_group",
",",
"true",
")",
";",
"}",
"else",
"{",
"$",
"shortage",
"=",
"(",
"$",
"per_group",
"*",
"$",
"num_groups",
")",
"-",
"count",
"(",
"$",
"arr",
")",
";",
"if",
"(",
"$",
"shortage",
">",
"1",
")",
"{",
"$",
"keys",
"=",
"array_keys",
"(",
"$",
"arr",
")",
";",
"$",
"first_keys",
"=",
"array_splice",
"(",
"$",
"keys",
",",
"0",
",",
"$",
"per_group",
")",
";",
"$",
"first_group",
"=",
"array_splice",
"(",
"$",
"arr",
",",
"0",
",",
"$",
"per_group",
")",
";",
"$",
"first_group",
"=",
"array_combine",
"(",
"$",
"first_keys",
",",
"$",
"first_group",
")",
";",
"$",
"arr",
"=",
"array_combine",
"(",
"$",
"keys",
",",
"$",
"arr",
")",
";",
"$",
"remainders",
"=",
"self",
"::",
"apportion",
"(",
"$",
"arr",
",",
"$",
"num_groups",
"-",
"1",
")",
";",
"$",
"apportioned",
"=",
"array_merge",
"(",
"array",
"(",
"$",
"first_group",
")",
",",
"$",
"remainders",
")",
";",
"}",
"else",
"{",
"$",
"apportioned",
"=",
"array_chunk",
"(",
"$",
"arr",
",",
"$",
"per_group",
",",
"true",
")",
";",
"}",
"}",
"if",
"(",
"$",
"backload",
")",
"{",
"foreach",
"(",
"$",
"apportioned",
"as",
"&",
"$",
"group",
")",
"{",
"$",
"group",
"=",
"array_reverse",
"(",
"$",
"group",
",",
"true",
")",
";",
"}",
"$",
"apportioned",
"=",
"array_reverse",
"(",
"$",
"apportioned",
",",
"true",
")",
";",
"}",
"return",
"$",
"apportioned",
";",
"}"
] | Split array into groups with nearly equal number of elements
@param array $arr
@param int $num_groups
@param bool $strict_group_count
@param bool $backload
@return array | [
"Split",
"array",
"into",
"groups",
"with",
"nearly",
"equal",
"number",
"of",
"elements"
] | a27f6f1c3f96a908c7480f359fd44028e89f26c3 | https://github.com/tacowordpress/util/blob/a27f6f1c3f96a908c7480f359fd44028e89f26c3/src/Util/Arr.php#L161-L197 |
8,853 | common-libs/user | src/legacy/auth.php | auth.logout | public static function logout() {
$_SESSION = [];
session_destroy();
session_unset();
self::$isGuest = true;
self::$user = user::guest();
} | php | public static function logout() {
$_SESSION = [];
session_destroy();
session_unset();
self::$isGuest = true;
self::$user = user::guest();
} | [
"public",
"static",
"function",
"logout",
"(",
")",
"{",
"$",
"_SESSION",
"=",
"[",
"]",
";",
"session_destroy",
"(",
")",
";",
"session_unset",
"(",
")",
";",
"self",
"::",
"$",
"isGuest",
"=",
"true",
";",
"self",
"::",
"$",
"user",
"=",
"user",
"::",
"guest",
"(",
")",
";",
"}"
] | logout the current user | [
"logout",
"the",
"current",
"user"
] | 820fce6748a59e8d692bf613b4694f903d9db6c1 | https://github.com/common-libs/user/blob/820fce6748a59e8d692bf613b4694f903d9db6c1/src/legacy/auth.php#L93-L99 |
8,854 | grnrbt/yii2-materialized-path-postgres-array | src/MaterializedPathBehavior.php | MaterializedPathBehavior.getPath | public function getPath($asArray = true)
{
$raw = $this->owner->{$this->pathAttribute};
return $asArray ? $this->convertPathFromPgToPhp($raw) : $raw;
} | php | public function getPath($asArray = true)
{
$raw = $this->owner->{$this->pathAttribute};
return $asArray ? $this->convertPathFromPgToPhp($raw) : $raw;
} | [
"public",
"function",
"getPath",
"(",
"$",
"asArray",
"=",
"true",
")",
"{",
"$",
"raw",
"=",
"$",
"this",
"->",
"owner",
"->",
"{",
"$",
"this",
"->",
"pathAttribute",
"}",
";",
"return",
"$",
"asArray",
"?",
"$",
"this",
"->",
"convertPathFromPgToPhp",
"(",
"$",
"raw",
")",
":",
"$",
"raw",
";",
"}"
] | Returns path of self node.
@param bool $asArray = true Return array instead string
@return array|string|\yii\db\ArrayExpression | [
"Returns",
"path",
"of",
"self",
"node",
"."
] | dbad565bf55236c8753dbc14fcee7bbec4030edf | https://github.com/grnrbt/yii2-materialized-path-postgres-array/blob/dbad565bf55236c8753dbc14fcee7bbec4030edf/src/MaterializedPathBehavior.php#L151-L155 |
8,855 | grnrbt/yii2-materialized-path-postgres-array | src/MaterializedPathBehavior.php | MaterializedPathBehavior.getParentPath | public function getParentPath($asArray = true)
{
if ($this->owner->isRoot()) {
return null;
}
$path = $this->owner->getPath();
array_pop($path);
return $asArray ? $path : $this->convertPathFromPhpToPg($path);
} | php | public function getParentPath($asArray = true)
{
if ($this->owner->isRoot()) {
return null;
}
$path = $this->owner->getPath();
array_pop($path);
return $asArray ? $path : $this->convertPathFromPhpToPg($path);
} | [
"public",
"function",
"getParentPath",
"(",
"$",
"asArray",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"owner",
"->",
"isRoot",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"path",
"=",
"$",
"this",
"->",
"owner",
"->",
"getPath",
"(",
")",
";",
"array_pop",
"(",
"$",
"path",
")",
";",
"return",
"$",
"asArray",
"?",
"$",
"path",
":",
"$",
"this",
"->",
"convertPathFromPhpToPg",
"(",
"$",
"path",
")",
";",
"}"
] | Returns path from root to parent node.
@param bool $asArray = true
@return null|string|array|\yii\db\ArrayExpression | [
"Returns",
"path",
"from",
"root",
"to",
"parent",
"node",
"."
] | dbad565bf55236c8753dbc14fcee7bbec4030edf | https://github.com/grnrbt/yii2-materialized-path-postgres-array/blob/dbad565bf55236c8753dbc14fcee7bbec4030edf/src/MaterializedPathBehavior.php#L163-L171 |
8,856 | grnrbt/yii2-materialized-path-postgres-array | src/MaterializedPathBehavior.php | MaterializedPathBehavior.getParents | public function getParents($depth = null)
{
/** @var \yii\db\ActiveQuery|MaterializedPathQueryTrait $query */
$query = $this->owner->find();
return $query->parentsOf($this->owner, $depth);
} | php | public function getParents($depth = null)
{
/** @var \yii\db\ActiveQuery|MaterializedPathQueryTrait $query */
$query = $this->owner->find();
return $query->parentsOf($this->owner, $depth);
} | [
"public",
"function",
"getParents",
"(",
"$",
"depth",
"=",
"null",
")",
"{",
"/** @var \\yii\\db\\ActiveQuery|MaterializedPathQueryTrait $query */",
"$",
"query",
"=",
"$",
"this",
"->",
"owner",
"->",
"find",
"(",
")",
";",
"return",
"$",
"query",
"->",
"parentsOf",
"(",
"$",
"this",
"->",
"owner",
",",
"$",
"depth",
")",
";",
"}"
] | Returns list of parents from root to self node.
@param int $depth = null
@return \yii\db\ActiveQuery | [
"Returns",
"list",
"of",
"parents",
"from",
"root",
"to",
"self",
"node",
"."
] | dbad565bf55236c8753dbc14fcee7bbec4030edf | https://github.com/grnrbt/yii2-materialized-path-postgres-array/blob/dbad565bf55236c8753dbc14fcee7bbec4030edf/src/MaterializedPathBehavior.php#L209-L214 |
8,857 | grnrbt/yii2-materialized-path-postgres-array | src/MaterializedPathBehavior.php | MaterializedPathBehavior.getRoot | public function getRoot()
{
$path = $this->owner->getPath();
$path = array_shift($path);
$query = $this->owner->find();
/** @var \yii\db\ActiveQuery $query */
$query
->andWhere([$this->keyColumn => $path])
->limit(1);
$query->multiple = false;
return $query;
} | php | public function getRoot()
{
$path = $this->owner->getPath();
$path = array_shift($path);
$query = $this->owner->find();
/** @var \yii\db\ActiveQuery $query */
$query
->andWhere([$this->keyColumn => $path])
->limit(1);
$query->multiple = false;
return $query;
} | [
"public",
"function",
"getRoot",
"(",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"owner",
"->",
"getPath",
"(",
")",
";",
"$",
"path",
"=",
"array_shift",
"(",
"$",
"path",
")",
";",
"$",
"query",
"=",
"$",
"this",
"->",
"owner",
"->",
"find",
"(",
")",
";",
"/** @var \\yii\\db\\ActiveQuery $query */",
"$",
"query",
"->",
"andWhere",
"(",
"[",
"$",
"this",
"->",
"keyColumn",
"=>",
"$",
"path",
"]",
")",
"->",
"limit",
"(",
"1",
")",
";",
"$",
"query",
"->",
"multiple",
"=",
"false",
";",
"return",
"$",
"query",
";",
"}"
] | Returns root node in self node's subtree.
@return \yii\db\ActiveQuery | [
"Returns",
"root",
"node",
"in",
"self",
"node",
"s",
"subtree",
"."
] | dbad565bf55236c8753dbc14fcee7bbec4030edf | https://github.com/grnrbt/yii2-materialized-path-postgres-array/blob/dbad565bf55236c8753dbc14fcee7bbec4030edf/src/MaterializedPathBehavior.php#L233-L244 |
8,858 | grnrbt/yii2-materialized-path-postgres-array | src/MaterializedPathBehavior.php | MaterializedPathBehavior.getDescendants | public function getDescendants($depth = null, $andSelf = false)
{
/** @var \yii\db\ActiveQuery|MaterializedPathQueryTrait $query */
$query = $this->owner->find();
return $query->descendantsOf($this->owner, $depth, $andSelf);
} | php | public function getDescendants($depth = null, $andSelf = false)
{
/** @var \yii\db\ActiveQuery|MaterializedPathQueryTrait $query */
$query = $this->owner->find();
return $query->descendantsOf($this->owner, $depth, $andSelf);
} | [
"public",
"function",
"getDescendants",
"(",
"$",
"depth",
"=",
"null",
",",
"$",
"andSelf",
"=",
"false",
")",
"{",
"/** @var \\yii\\db\\ActiveQuery|MaterializedPathQueryTrait $query */",
"$",
"query",
"=",
"$",
"this",
"->",
"owner",
"->",
"find",
"(",
")",
";",
"return",
"$",
"query",
"->",
"descendantsOf",
"(",
"$",
"this",
"->",
"owner",
",",
"$",
"depth",
",",
"$",
"andSelf",
")",
";",
"}"
] | Returns descendants as plain list.
@param int $depth = null
@param bool $andSelf = false
@return \yii\db\ActiveQuery|MaterializedPathQueryTrait | [
"Returns",
"descendants",
"as",
"plain",
"list",
"."
] | dbad565bf55236c8753dbc14fcee7bbec4030edf | https://github.com/grnrbt/yii2-materialized-path-postgres-array/blob/dbad565bf55236c8753dbc14fcee7bbec4030edf/src/MaterializedPathBehavior.php#L253-L258 |
8,859 | grnrbt/yii2-materialized-path-postgres-array | src/MaterializedPathBehavior.php | MaterializedPathBehavior.populateTree | public function populateTree($depth = null)
{
/** @var ActiveRecord|MaterializedPathBehavior $nodes */
$nodes = $this
->getDescendants($depth)
->indexBy($this->keyAttribute)
->all();
$relates = [];
foreach ($nodes as $key => $node) {
$parentKey = $node->getParentKey();
if (!isset($relates[$parentKey])) {
$relates[$parentKey] = [];
}
$relates[$parentKey][] = $node;
}
$nodes[$this->owner->{$this->keyAttribute}] = $this->owner;
foreach ($relates as $key => $children) {
$nodes[$key]->populateRelation('children', $children);
}
return $this->owner;
} | php | public function populateTree($depth = null)
{
/** @var ActiveRecord|MaterializedPathBehavior $nodes */
$nodes = $this
->getDescendants($depth)
->indexBy($this->keyAttribute)
->all();
$relates = [];
foreach ($nodes as $key => $node) {
$parentKey = $node->getParentKey();
if (!isset($relates[$parentKey])) {
$relates[$parentKey] = [];
}
$relates[$parentKey][] = $node;
}
$nodes[$this->owner->{$this->keyAttribute}] = $this->owner;
foreach ($relates as $key => $children) {
$nodes[$key]->populateRelation('children', $children);
}
return $this->owner;
} | [
"public",
"function",
"populateTree",
"(",
"$",
"depth",
"=",
"null",
")",
"{",
"/** @var ActiveRecord|MaterializedPathBehavior $nodes */",
"$",
"nodes",
"=",
"$",
"this",
"->",
"getDescendants",
"(",
"$",
"depth",
")",
"->",
"indexBy",
"(",
"$",
"this",
"->",
"keyAttribute",
")",
"->",
"all",
"(",
")",
";",
"$",
"relates",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"nodes",
"as",
"$",
"key",
"=>",
"$",
"node",
")",
"{",
"$",
"parentKey",
"=",
"$",
"node",
"->",
"getParentKey",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"relates",
"[",
"$",
"parentKey",
"]",
")",
")",
"{",
"$",
"relates",
"[",
"$",
"parentKey",
"]",
"=",
"[",
"]",
";",
"}",
"$",
"relates",
"[",
"$",
"parentKey",
"]",
"[",
"]",
"=",
"$",
"node",
";",
"}",
"$",
"nodes",
"[",
"$",
"this",
"->",
"owner",
"->",
"{",
"$",
"this",
"->",
"keyAttribute",
"}",
"]",
"=",
"$",
"this",
"->",
"owner",
";",
"foreach",
"(",
"$",
"relates",
"as",
"$",
"key",
"=>",
"$",
"children",
")",
"{",
"$",
"nodes",
"[",
"$",
"key",
"]",
"->",
"populateRelation",
"(",
"'children'",
",",
"$",
"children",
")",
";",
"}",
"return",
"$",
"this",
"->",
"owner",
";",
"}"
] | Returns descendants nodes as tree with self node in the root.
@param int $depth = null
@return MaterializedPathBehavior|ActiveRecord | [
"Returns",
"descendants",
"nodes",
"as",
"tree",
"with",
"self",
"node",
"in",
"the",
"root",
"."
] | dbad565bf55236c8753dbc14fcee7bbec4030edf | https://github.com/grnrbt/yii2-materialized-path-postgres-array/blob/dbad565bf55236c8753dbc14fcee7bbec4030edf/src/MaterializedPathBehavior.php#L534-L554 |
8,860 | grnrbt/yii2-materialized-path-postgres-array | src/MaterializedPathBehavior.php | MaterializedPathBehavior.getParentKey | public function getParentKey()
{
if ($this->owner->isRoot()) {
return null;
}
$path = $this->getPath();
return array_pop($path);
} | php | public function getParentKey()
{
if ($this->owner->isRoot()) {
return null;
}
$path = $this->getPath();
return array_pop($path);
} | [
"public",
"function",
"getParentKey",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"owner",
"->",
"isRoot",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"path",
"=",
"$",
"this",
"->",
"getPath",
"(",
")",
";",
"return",
"array_pop",
"(",
"$",
"path",
")",
";",
"}"
] | Returns key of parent.
@return mixed|null | [
"Returns",
"key",
"of",
"parent",
"."
] | dbad565bf55236c8753dbc14fcee7bbec4030edf | https://github.com/grnrbt/yii2-materialized-path-postgres-array/blob/dbad565bf55236c8753dbc14fcee7bbec4030edf/src/MaterializedPathBehavior.php#L561-L568 |
8,861 | indigophp-archive/codeception-fuel-module | fuel/fuel/core/classes/database/result.php | Database_Result.as_array | public function as_array($key = null, $value = null)
{
$results = array();
if ($key === null and $value === null)
{
// Indexed rows
foreach ($this as $row)
{
$results[] = $row;
}
}
elseif ($key === null)
{
// Indexed columns
if ($this->_as_object)
{
foreach ($this as $row)
{
$results[] = $row->$value;
}
}
else
{
foreach ($this as $row)
{
$results[] = $row[$value];
}
}
}
elseif ($value === null)
{
// Associative rows
if ($this->_as_object)
{
foreach ($this as $row)
{
$results[$row->$key] = $row;
}
}
else
{
foreach ($this as $row)
{
$results[$row[$key]] = $row;
}
}
}
else
{
// Associative columns
if ($this->_as_object)
{
foreach ($this as $row)
{
$results[$row->$key] = $row->$value;
}
}
else
{
foreach ($this as $row)
{
$results[$row[$key]] = $row[$value];
}
}
}
$this->rewind();
return $results;
} | php | public function as_array($key = null, $value = null)
{
$results = array();
if ($key === null and $value === null)
{
// Indexed rows
foreach ($this as $row)
{
$results[] = $row;
}
}
elseif ($key === null)
{
// Indexed columns
if ($this->_as_object)
{
foreach ($this as $row)
{
$results[] = $row->$value;
}
}
else
{
foreach ($this as $row)
{
$results[] = $row[$value];
}
}
}
elseif ($value === null)
{
// Associative rows
if ($this->_as_object)
{
foreach ($this as $row)
{
$results[$row->$key] = $row;
}
}
else
{
foreach ($this as $row)
{
$results[$row[$key]] = $row;
}
}
}
else
{
// Associative columns
if ($this->_as_object)
{
foreach ($this as $row)
{
$results[$row->$key] = $row->$value;
}
}
else
{
foreach ($this as $row)
{
$results[$row[$key]] = $row[$value];
}
}
}
$this->rewind();
return $results;
} | [
"public",
"function",
"as_array",
"(",
"$",
"key",
"=",
"null",
",",
"$",
"value",
"=",
"null",
")",
"{",
"$",
"results",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"key",
"===",
"null",
"and",
"$",
"value",
"===",
"null",
")",
"{",
"// Indexed rows",
"foreach",
"(",
"$",
"this",
"as",
"$",
"row",
")",
"{",
"$",
"results",
"[",
"]",
"=",
"$",
"row",
";",
"}",
"}",
"elseif",
"(",
"$",
"key",
"===",
"null",
")",
"{",
"// Indexed columns",
"if",
"(",
"$",
"this",
"->",
"_as_object",
")",
"{",
"foreach",
"(",
"$",
"this",
"as",
"$",
"row",
")",
"{",
"$",
"results",
"[",
"]",
"=",
"$",
"row",
"->",
"$",
"value",
";",
"}",
"}",
"else",
"{",
"foreach",
"(",
"$",
"this",
"as",
"$",
"row",
")",
"{",
"$",
"results",
"[",
"]",
"=",
"$",
"row",
"[",
"$",
"value",
"]",
";",
"}",
"}",
"}",
"elseif",
"(",
"$",
"value",
"===",
"null",
")",
"{",
"// Associative rows",
"if",
"(",
"$",
"this",
"->",
"_as_object",
")",
"{",
"foreach",
"(",
"$",
"this",
"as",
"$",
"row",
")",
"{",
"$",
"results",
"[",
"$",
"row",
"->",
"$",
"key",
"]",
"=",
"$",
"row",
";",
"}",
"}",
"else",
"{",
"foreach",
"(",
"$",
"this",
"as",
"$",
"row",
")",
"{",
"$",
"results",
"[",
"$",
"row",
"[",
"$",
"key",
"]",
"]",
"=",
"$",
"row",
";",
"}",
"}",
"}",
"else",
"{",
"// Associative columns",
"if",
"(",
"$",
"this",
"->",
"_as_object",
")",
"{",
"foreach",
"(",
"$",
"this",
"as",
"$",
"row",
")",
"{",
"$",
"results",
"[",
"$",
"row",
"->",
"$",
"key",
"]",
"=",
"$",
"row",
"->",
"$",
"value",
";",
"}",
"}",
"else",
"{",
"foreach",
"(",
"$",
"this",
"as",
"$",
"row",
")",
"{",
"$",
"results",
"[",
"$",
"row",
"[",
"$",
"key",
"]",
"]",
"=",
"$",
"row",
"[",
"$",
"value",
"]",
";",
"}",
"}",
"}",
"$",
"this",
"->",
"rewind",
"(",
")",
";",
"return",
"$",
"results",
";",
"}"
] | Return all of the rows in the result as an array.
// Indexed array of all rows
$rows = $result->as_array();
// Associative array of rows by "id"
$rows = $result->as_array('id');
// Associative array of rows, "id" => "name"
$rows = $result->as_array('id', 'name');
@param string column for associative keys
@param string column for values
@return array | [
"Return",
"all",
"of",
"the",
"rows",
"in",
"the",
"result",
"as",
"an",
"array",
"."
] | 0973b7cbd540a0e89cc5bb7af94627f77f09bf49 | https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/database/result.php#L104-L178 |
8,862 | indigophp-archive/codeception-fuel-module | fuel/fuel/core/classes/database/result.php | Database_Result.get | public function get($name, $default = null)
{
$row = $this->current();
if ($this->_as_object)
{
if (isset($row->$name))
{
return $row->$name;
}
}
else
{
if (isset($row[$name]))
{
return $row[$name];
}
}
return \Fuel::value($default);
} | php | public function get($name, $default = null)
{
$row = $this->current();
if ($this->_as_object)
{
if (isset($row->$name))
{
return $row->$name;
}
}
else
{
if (isset($row[$name]))
{
return $row[$name];
}
}
return \Fuel::value($default);
} | [
"public",
"function",
"get",
"(",
"$",
"name",
",",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"row",
"=",
"$",
"this",
"->",
"current",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"_as_object",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"row",
"->",
"$",
"name",
")",
")",
"{",
"return",
"$",
"row",
"->",
"$",
"name",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"isset",
"(",
"$",
"row",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"$",
"row",
"[",
"$",
"name",
"]",
";",
"}",
"}",
"return",
"\\",
"Fuel",
"::",
"value",
"(",
"$",
"default",
")",
";",
"}"
] | Return the named column from the current row.
// Get the "id" value
$id = $result->get('id');
@param string $name column to get
@param mixed $default default value if the column does not exist
@return mixed | [
"Return",
"the",
"named",
"column",
"from",
"the",
"current",
"row",
"."
] | 0973b7cbd540a0e89cc5bb7af94627f77f09bf49 | https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/database/result.php#L191-L211 |
8,863 | SocietyCMS/Menu | Repositories/Menu/MenuBuilder.php | MenuBuilder.getItemProviders | public function getItemProviders()
{
foreach ($this->modules->enabled() as $module) {
$name = studly_case($module->getName());
$class = 'Modules\\'.$name.'\\MenuExtenders\\MenuExtender';
if (class_exists($class)) {
$extender = $this->container->make($class);
$this->extenders->put($module->getName(), [
'content' => $extender->getContentItems(),
'static' => $extender->getStaticItems(),
]);
}
}
return $this->extenders;
} | php | public function getItemProviders()
{
foreach ($this->modules->enabled() as $module) {
$name = studly_case($module->getName());
$class = 'Modules\\'.$name.'\\MenuExtenders\\MenuExtender';
if (class_exists($class)) {
$extender = $this->container->make($class);
$this->extenders->put($module->getName(), [
'content' => $extender->getContentItems(),
'static' => $extender->getStaticItems(),
]);
}
}
return $this->extenders;
} | [
"public",
"function",
"getItemProviders",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"modules",
"->",
"enabled",
"(",
")",
"as",
"$",
"module",
")",
"{",
"$",
"name",
"=",
"studly_case",
"(",
"$",
"module",
"->",
"getName",
"(",
")",
")",
";",
"$",
"class",
"=",
"'Modules\\\\'",
".",
"$",
"name",
".",
"'\\\\MenuExtenders\\\\MenuExtender'",
";",
"if",
"(",
"class_exists",
"(",
"$",
"class",
")",
")",
"{",
"$",
"extender",
"=",
"$",
"this",
"->",
"container",
"->",
"make",
"(",
"$",
"class",
")",
";",
"$",
"this",
"->",
"extenders",
"->",
"put",
"(",
"$",
"module",
"->",
"getName",
"(",
")",
",",
"[",
"'content'",
"=>",
"$",
"extender",
"->",
"getContentItems",
"(",
")",
",",
"'static'",
"=>",
"$",
"extender",
"->",
"getStaticItems",
"(",
")",
",",
"]",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"extenders",
";",
"}"
] | Build the menu structure.
@return mixed | [
"Build",
"the",
"menu",
"structure",
"."
] | 417468edaa2be0051ae041ee614ab609f0ac8b49 | https://github.com/SocietyCMS/Menu/blob/417468edaa2be0051ae041ee614ab609f0ac8b49/Repositories/Menu/MenuBuilder.php#L51-L67 |
8,864 | SocietyCMS/Menu | Repositories/Menu/MenuBuilder.php | MenuBuilder.buildMenus | public function buildMenus()
{
$menu = Menu::whereIsRoot()->get();
foreach ($menu as $item) {
LavaryMenu::make(Str::slug($item->name), function ($menu) use ($item) {
$this->buildMenuItems($menu, $item);
});
}
} | php | public function buildMenus()
{
$menu = Menu::whereIsRoot()->get();
foreach ($menu as $item) {
LavaryMenu::make(Str::slug($item->name), function ($menu) use ($item) {
$this->buildMenuItems($menu, $item);
});
}
} | [
"public",
"function",
"buildMenus",
"(",
")",
"{",
"$",
"menu",
"=",
"Menu",
"::",
"whereIsRoot",
"(",
")",
"->",
"get",
"(",
")",
";",
"foreach",
"(",
"$",
"menu",
"as",
"$",
"item",
")",
"{",
"LavaryMenu",
"::",
"make",
"(",
"Str",
"::",
"slug",
"(",
"$",
"item",
"->",
"name",
")",
",",
"function",
"(",
"$",
"menu",
")",
"use",
"(",
"$",
"item",
")",
"{",
"$",
"this",
"->",
"buildMenuItems",
"(",
"$",
"menu",
",",
"$",
"item",
")",
";",
"}",
")",
";",
"}",
"}"
] | Build all Menus. | [
"Build",
"all",
"Menus",
"."
] | 417468edaa2be0051ae041ee614ab609f0ac8b49 | https://github.com/SocietyCMS/Menu/blob/417468edaa2be0051ae041ee614ab609f0ac8b49/Repositories/Menu/MenuBuilder.php#L72-L80 |
8,865 | fabsgc/framework | Core/Engine/Engine.php | Engine.init | public function init() {
if (!Config::config()['user']['debug']['maintenance']) {
date_default_timezone_set(Config::config()['user']['output']['timezone']);
$this->_setEnvironment();
$this->_route();
if ($this->_route == true) {
$this->_setDatabase();
$this->_setSecure();
$this->_setLibrary();
$this->_setEvent();
$this->_setCron();
$this->_setFunction();
$this->_setFunction($this->request->src);
$this->_setEvent($this->request->src);
}
}
} | php | public function init() {
if (!Config::config()['user']['debug']['maintenance']) {
date_default_timezone_set(Config::config()['user']['output']['timezone']);
$this->_setEnvironment();
$this->_route();
if ($this->_route == true) {
$this->_setDatabase();
$this->_setSecure();
$this->_setLibrary();
$this->_setEvent();
$this->_setCron();
$this->_setFunction();
$this->_setFunction($this->request->src);
$this->_setEvent($this->request->src);
}
}
} | [
"public",
"function",
"init",
"(",
")",
"{",
"if",
"(",
"!",
"Config",
"::",
"config",
"(",
")",
"[",
"'user'",
"]",
"[",
"'debug'",
"]",
"[",
"'maintenance'",
"]",
")",
"{",
"date_default_timezone_set",
"(",
"Config",
"::",
"config",
"(",
")",
"[",
"'user'",
"]",
"[",
"'output'",
"]",
"[",
"'timezone'",
"]",
")",
";",
"$",
"this",
"->",
"_setEnvironment",
"(",
")",
";",
"$",
"this",
"->",
"_route",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"_route",
"==",
"true",
")",
"{",
"$",
"this",
"->",
"_setDatabase",
"(",
")",
";",
"$",
"this",
"->",
"_setSecure",
"(",
")",
";",
"$",
"this",
"->",
"_setLibrary",
"(",
")",
";",
"$",
"this",
"->",
"_setEvent",
"(",
")",
";",
"$",
"this",
"->",
"_setCron",
"(",
")",
";",
"$",
"this",
"->",
"_setFunction",
"(",
")",
";",
"$",
"this",
"->",
"_setFunction",
"(",
"$",
"this",
"->",
"request",
"->",
"src",
")",
";",
"$",
"this",
"->",
"_setEvent",
"(",
"$",
"this",
"->",
"request",
"->",
"src",
")",
";",
"}",
"}",
"}"
] | initialization of the engine
@access public
@return void
@since 3.0
@package Gcs\Framework\Core\Engine | [
"initialization",
"of",
"the",
"engine"
] | 45e58182aba6a3c6381970a1fd3c17662cff2168 | https://github.com/fabsgc/framework/blob/45e58182aba6a3c6381970a1fd3c17662cff2168/Core/Engine/Engine.php#L80-L97 |
8,866 | fabsgc/framework | Core/Engine/Engine.php | Engine.initCron | public function initCron($src, $controller, $action) {
if (!Config::config()['user']['debug']['maintenance']) {
$this->_routeCron($src, $controller, $action);
if ($this->_route == true) {
$this->_setFunction($this->request->src);
$this->_setEvent($this->request->src);
}
}
} | php | public function initCron($src, $controller, $action) {
if (!Config::config()['user']['debug']['maintenance']) {
$this->_routeCron($src, $controller, $action);
if ($this->_route == true) {
$this->_setFunction($this->request->src);
$this->_setEvent($this->request->src);
}
}
} | [
"public",
"function",
"initCron",
"(",
"$",
"src",
",",
"$",
"controller",
",",
"$",
"action",
")",
"{",
"if",
"(",
"!",
"Config",
"::",
"config",
"(",
")",
"[",
"'user'",
"]",
"[",
"'debug'",
"]",
"[",
"'maintenance'",
"]",
")",
"{",
"$",
"this",
"->",
"_routeCron",
"(",
"$",
"src",
",",
"$",
"controller",
",",
"$",
"action",
")",
";",
"if",
"(",
"$",
"this",
"->",
"_route",
"==",
"true",
")",
"{",
"$",
"this",
"->",
"_setFunction",
"(",
"$",
"this",
"->",
"request",
"->",
"src",
")",
";",
"$",
"this",
"->",
"_setEvent",
"(",
"$",
"this",
"->",
"request",
"->",
"src",
")",
";",
"}",
"}",
"}"
] | initialization of the engine for cron
@access public
@param $src string
@param $controller string
@param $action string
@return void
@since 3.0
@package Gcs\Framework\Core\Engine | [
"initialization",
"of",
"the",
"engine",
"for",
"cron"
] | 45e58182aba6a3c6381970a1fd3c17662cff2168 | https://github.com/fabsgc/framework/blob/45e58182aba6a3c6381970a1fd3c17662cff2168/Core/Engine/Engine.php#L110-L119 |
8,867 | fabsgc/framework | Core/Engine/Engine.php | Engine._routeCron | private function _routeCron($src, $controller, $action) {
$this->request->name = '-' . $src . '_' . $controller . '_' . $action;
$this->request->src = $src;
$this->request->controller = $controller;
$this->request->action = $action;
$this->request->auth = new Auth($this->request->src);
$this->_route = true;
} | php | private function _routeCron($src, $controller, $action) {
$this->request->name = '-' . $src . '_' . $controller . '_' . $action;
$this->request->src = $src;
$this->request->controller = $controller;
$this->request->action = $action;
$this->request->auth = new Auth($this->request->src);
$this->_route = true;
} | [
"private",
"function",
"_routeCron",
"(",
"$",
"src",
",",
"$",
"controller",
",",
"$",
"action",
")",
"{",
"$",
"this",
"->",
"request",
"->",
"name",
"=",
"'-'",
".",
"$",
"src",
".",
"'_'",
".",
"$",
"controller",
".",
"'_'",
".",
"$",
"action",
";",
"$",
"this",
"->",
"request",
"->",
"src",
"=",
"$",
"src",
";",
"$",
"this",
"->",
"request",
"->",
"controller",
"=",
"$",
"controller",
";",
"$",
"this",
"->",
"request",
"->",
"action",
"=",
"$",
"action",
";",
"$",
"this",
"->",
"request",
"->",
"auth",
"=",
"new",
"Auth",
"(",
"$",
"this",
"->",
"request",
"->",
"src",
")",
";",
"$",
"this",
"->",
"_route",
"=",
"true",
";",
"}"
] | routing with cron
@access private
@param $src string
@param $controller string
@param $action string
@return void
@since 3.0
@package Gcs\Framework\Core\Engine | [
"routing",
"with",
"cron"
] | 45e58182aba6a3c6381970a1fd3c17662cff2168 | https://github.com/fabsgc/framework/blob/45e58182aba6a3c6381970a1fd3c17662cff2168/Core/Engine/Engine.php#L240-L247 |
8,868 | fabsgc/framework | Core/Engine/Engine.php | Engine._action | public function _action(&$class) {
ob_start();
$annotation = Annotation::getClass($class);
$this->_callAnnotation($class, $annotation, 'class', 'Before');
if (method_exists($class, 'action' . ucfirst($this->request->action))) {
$this->_callAnnotation($class, $annotation, 'methods', 'Before');
$action = 'action' . ucfirst($this->request->action);
$params = Injector::instance()->getArgsMethod($class, $action);
$reflectionMethod = new \ReflectionMethod($class, $action);
$output = $reflectionMethod->invokeArgs($class, $params);
$this->_callAnnotation($class, $annotation, 'methods', 'After');
$this->addError('Action "' . $this->request->src . '/' . ucfirst($this->request->controller) . '/action' . ucfirst($this->request->action) . '" called successfully', __FILE__, __LINE__, ERROR_INFORMATION);
}
else {
throw new Exception('The requested "' . $this->request->src . '/' . ucfirst($this->request->controller) . '/action' . ucfirst($this->request->action) . '" doesn\'t exist');
}
$this->_callAnnotation($class, $annotation, 'class', 'After');
$output = ob_get_contents() . $output;
ob_get_clean();
return $output;
} | php | public function _action(&$class) {
ob_start();
$annotation = Annotation::getClass($class);
$this->_callAnnotation($class, $annotation, 'class', 'Before');
if (method_exists($class, 'action' . ucfirst($this->request->action))) {
$this->_callAnnotation($class, $annotation, 'methods', 'Before');
$action = 'action' . ucfirst($this->request->action);
$params = Injector::instance()->getArgsMethod($class, $action);
$reflectionMethod = new \ReflectionMethod($class, $action);
$output = $reflectionMethod->invokeArgs($class, $params);
$this->_callAnnotation($class, $annotation, 'methods', 'After');
$this->addError('Action "' . $this->request->src . '/' . ucfirst($this->request->controller) . '/action' . ucfirst($this->request->action) . '" called successfully', __FILE__, __LINE__, ERROR_INFORMATION);
}
else {
throw new Exception('The requested "' . $this->request->src . '/' . ucfirst($this->request->controller) . '/action' . ucfirst($this->request->action) . '" doesn\'t exist');
}
$this->_callAnnotation($class, $annotation, 'class', 'After');
$output = ob_get_contents() . $output;
ob_get_clean();
return $output;
} | [
"public",
"function",
"_action",
"(",
"&",
"$",
"class",
")",
"{",
"ob_start",
"(",
")",
";",
"$",
"annotation",
"=",
"Annotation",
"::",
"getClass",
"(",
"$",
"class",
")",
";",
"$",
"this",
"->",
"_callAnnotation",
"(",
"$",
"class",
",",
"$",
"annotation",
",",
"'class'",
",",
"'Before'",
")",
";",
"if",
"(",
"method_exists",
"(",
"$",
"class",
",",
"'action'",
".",
"ucfirst",
"(",
"$",
"this",
"->",
"request",
"->",
"action",
")",
")",
")",
"{",
"$",
"this",
"->",
"_callAnnotation",
"(",
"$",
"class",
",",
"$",
"annotation",
",",
"'methods'",
",",
"'Before'",
")",
";",
"$",
"action",
"=",
"'action'",
".",
"ucfirst",
"(",
"$",
"this",
"->",
"request",
"->",
"action",
")",
";",
"$",
"params",
"=",
"Injector",
"::",
"instance",
"(",
")",
"->",
"getArgsMethod",
"(",
"$",
"class",
",",
"$",
"action",
")",
";",
"$",
"reflectionMethod",
"=",
"new",
"\\",
"ReflectionMethod",
"(",
"$",
"class",
",",
"$",
"action",
")",
";",
"$",
"output",
"=",
"$",
"reflectionMethod",
"->",
"invokeArgs",
"(",
"$",
"class",
",",
"$",
"params",
")",
";",
"$",
"this",
"->",
"_callAnnotation",
"(",
"$",
"class",
",",
"$",
"annotation",
",",
"'methods'",
",",
"'After'",
")",
";",
"$",
"this",
"->",
"addError",
"(",
"'Action \"'",
".",
"$",
"this",
"->",
"request",
"->",
"src",
".",
"'/'",
".",
"ucfirst",
"(",
"$",
"this",
"->",
"request",
"->",
"controller",
")",
".",
"'/action'",
".",
"ucfirst",
"(",
"$",
"this",
"->",
"request",
"->",
"action",
")",
".",
"'\" called successfully'",
",",
"__FILE__",
",",
"__LINE__",
",",
"ERROR_INFORMATION",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"Exception",
"(",
"'The requested \"'",
".",
"$",
"this",
"->",
"request",
"->",
"src",
".",
"'/'",
".",
"ucfirst",
"(",
"$",
"this",
"->",
"request",
"->",
"controller",
")",
".",
"'/action'",
".",
"ucfirst",
"(",
"$",
"this",
"->",
"request",
"->",
"action",
")",
".",
"'\" doesn\\'t exist'",
")",
";",
"}",
"$",
"this",
"->",
"_callAnnotation",
"(",
"$",
"class",
",",
"$",
"annotation",
",",
"'class'",
",",
"'After'",
")",
";",
"$",
"output",
"=",
"ob_get_contents",
"(",
")",
".",
"$",
"output",
";",
"ob_get_clean",
"(",
")",
";",
"return",
"$",
"output",
";",
"}"
] | call action from controller
@param &$class Controller
@throws Exception
@access public
@return string
@since 3.0
@package Gcs\Framework\Core\Engine | [
"call",
"action",
"from",
"controller"
] | 45e58182aba6a3c6381970a1fd3c17662cff2168 | https://github.com/fabsgc/framework/blob/45e58182aba6a3c6381970a1fd3c17662cff2168/Core/Engine/Engine.php#L312-L339 |
8,869 | fabsgc/framework | Core/Engine/Engine.php | Engine._callAnnotation | protected function _callAnnotation(Controller &$class, $annotation = [], $type = 'class', $annotationType = 'Before') {
foreach ($annotation[$type] as $action => $annotationClasses) {
foreach ($annotationClasses as $annotationClass) {
if ($annotationClass['annotation'] == $annotationType) {
/** @var \Gcs\Framework\Core\Annotation\Annotations\Common\Before $instance */
$instance = $annotationClass['instance'];
$className = $instance->class;
$methodName = $instance->method;
if (method_exists($className, $methodName)) {
if ($className == get_class($class)) {
$class->$methodName();
}
else {
$reflectionMethod = new \ReflectionMethod($className, $methodName);
echo $reflectionMethod->invoke(new $className());
}
}
else {
throw new MissingMethodException('The method "' . $methodName . '" from the class "' . $className . '" does not exist');
}
}
}
}
} | php | protected function _callAnnotation(Controller &$class, $annotation = [], $type = 'class', $annotationType = 'Before') {
foreach ($annotation[$type] as $action => $annotationClasses) {
foreach ($annotationClasses as $annotationClass) {
if ($annotationClass['annotation'] == $annotationType) {
/** @var \Gcs\Framework\Core\Annotation\Annotations\Common\Before $instance */
$instance = $annotationClass['instance'];
$className = $instance->class;
$methodName = $instance->method;
if (method_exists($className, $methodName)) {
if ($className == get_class($class)) {
$class->$methodName();
}
else {
$reflectionMethod = new \ReflectionMethod($className, $methodName);
echo $reflectionMethod->invoke(new $className());
}
}
else {
throw new MissingMethodException('The method "' . $methodName . '" from the class "' . $className . '" does not exist');
}
}
}
}
} | [
"protected",
"function",
"_callAnnotation",
"(",
"Controller",
"&",
"$",
"class",
",",
"$",
"annotation",
"=",
"[",
"]",
",",
"$",
"type",
"=",
"'class'",
",",
"$",
"annotationType",
"=",
"'Before'",
")",
"{",
"foreach",
"(",
"$",
"annotation",
"[",
"$",
"type",
"]",
"as",
"$",
"action",
"=>",
"$",
"annotationClasses",
")",
"{",
"foreach",
"(",
"$",
"annotationClasses",
"as",
"$",
"annotationClass",
")",
"{",
"if",
"(",
"$",
"annotationClass",
"[",
"'annotation'",
"]",
"==",
"$",
"annotationType",
")",
"{",
"/** @var \\Gcs\\Framework\\Core\\Annotation\\Annotations\\Common\\Before $instance */",
"$",
"instance",
"=",
"$",
"annotationClass",
"[",
"'instance'",
"]",
";",
"$",
"className",
"=",
"$",
"instance",
"->",
"class",
";",
"$",
"methodName",
"=",
"$",
"instance",
"->",
"method",
";",
"if",
"(",
"method_exists",
"(",
"$",
"className",
",",
"$",
"methodName",
")",
")",
"{",
"if",
"(",
"$",
"className",
"==",
"get_class",
"(",
"$",
"class",
")",
")",
"{",
"$",
"class",
"->",
"$",
"methodName",
"(",
")",
";",
"}",
"else",
"{",
"$",
"reflectionMethod",
"=",
"new",
"\\",
"ReflectionMethod",
"(",
"$",
"className",
",",
"$",
"methodName",
")",
";",
"echo",
"$",
"reflectionMethod",
"->",
"invoke",
"(",
"new",
"$",
"className",
"(",
")",
")",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"MissingMethodException",
"(",
"'The method \"'",
".",
"$",
"methodName",
".",
"'\" from the class \"'",
".",
"$",
"className",
".",
"'\" does not exist'",
")",
";",
"}",
"}",
"}",
"}",
"}"
] | call all annotation methods required
@param Controller $class
@param array $annotation
@param string $type
@param string $annotationType
@throws MissingMethodException
@access protected
@since 3.0
@package Gcs\Framework\Core\Engine | [
"call",
"all",
"annotation",
"methods",
"required"
] | 45e58182aba6a3c6381970a1fd3c17662cff2168 | https://github.com/fabsgc/framework/blob/45e58182aba6a3c6381970a1fd3c17662cff2168/Core/Engine/Engine.php#L353-L378 |
8,870 | fabsgc/framework | Core/Engine/Engine.php | Engine._setControllerFile | protected function _setControllerFile($src, $controller) {
$controllerPath = SRC_PATH . $src . '/' . SRC_CONTROLLER_PATH . ucfirst($controller) . '.php';
if (file_exists($controllerPath)) {
require_once($controllerPath);
return true;
}
return false;
} | php | protected function _setControllerFile($src, $controller) {
$controllerPath = SRC_PATH . $src . '/' . SRC_CONTROLLER_PATH . ucfirst($controller) . '.php';
if (file_exists($controllerPath)) {
require_once($controllerPath);
return true;
}
return false;
} | [
"protected",
"function",
"_setControllerFile",
"(",
"$",
"src",
",",
"$",
"controller",
")",
"{",
"$",
"controllerPath",
"=",
"SRC_PATH",
".",
"$",
"src",
".",
"'/'",
".",
"SRC_CONTROLLER_PATH",
".",
"ucfirst",
"(",
"$",
"controller",
")",
".",
"'.php'",
";",
"if",
"(",
"file_exists",
"(",
"$",
"controllerPath",
")",
")",
"{",
"require_once",
"(",
"$",
"controllerPath",
")",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | include the module
@access protected
@param $src string
@param $controller string
@return boolean
@since 3.0
@package Gcs\Framework\Core\Engine | [
"include",
"the",
"module"
] | 45e58182aba6a3c6381970a1fd3c17662cff2168 | https://github.com/fabsgc/framework/blob/45e58182aba6a3c6381970a1fd3c17662cff2168/Core/Engine/Engine.php#L390-L400 |
8,871 | fabsgc/framework | Core/Engine/Engine.php | Engine.run | public function run() {
if (!Config::config()['user']['debug']['maintenance']) {
if ($this->_route == false) {
$this->response->status(404);
$this->addError('routing failed : http://' . $this->request->env('HTTP_HOST') . $this->request->env('REQUEST_URI'), __FILE__, __LINE__, ERROR_WARNING);
}
else {
$this->_controller();
}
$this->response->run();
$this->addErrorHr(LOG_ERROR);
$this->addErrorHr(LOG_SYSTEM);
$this->_setHistory('');
if (Config::config()['user']['output']['minify'] && preg_match('#text/html#isU', $this->response->contentType())) {
$this->response->page($this->_minifyHtml($this->response->page()));
}
if (Config::config()['user']['debug']['environment'] == 'development' && Config::config()['user']['debug']['profiler']) {
$this->profiler->profiler($this->request, $this->response);
}
}
else {
$this->response->page($this->maintenance());
}
echo $this->response->page();
} | php | public function run() {
if (!Config::config()['user']['debug']['maintenance']) {
if ($this->_route == false) {
$this->response->status(404);
$this->addError('routing failed : http://' . $this->request->env('HTTP_HOST') . $this->request->env('REQUEST_URI'), __FILE__, __LINE__, ERROR_WARNING);
}
else {
$this->_controller();
}
$this->response->run();
$this->addErrorHr(LOG_ERROR);
$this->addErrorHr(LOG_SYSTEM);
$this->_setHistory('');
if (Config::config()['user']['output']['minify'] && preg_match('#text/html#isU', $this->response->contentType())) {
$this->response->page($this->_minifyHtml($this->response->page()));
}
if (Config::config()['user']['debug']['environment'] == 'development' && Config::config()['user']['debug']['profiler']) {
$this->profiler->profiler($this->request, $this->response);
}
}
else {
$this->response->page($this->maintenance());
}
echo $this->response->page();
} | [
"public",
"function",
"run",
"(",
")",
"{",
"if",
"(",
"!",
"Config",
"::",
"config",
"(",
")",
"[",
"'user'",
"]",
"[",
"'debug'",
"]",
"[",
"'maintenance'",
"]",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_route",
"==",
"false",
")",
"{",
"$",
"this",
"->",
"response",
"->",
"status",
"(",
"404",
")",
";",
"$",
"this",
"->",
"addError",
"(",
"'routing failed : http://'",
".",
"$",
"this",
"->",
"request",
"->",
"env",
"(",
"'HTTP_HOST'",
")",
".",
"$",
"this",
"->",
"request",
"->",
"env",
"(",
"'REQUEST_URI'",
")",
",",
"__FILE__",
",",
"__LINE__",
",",
"ERROR_WARNING",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"_controller",
"(",
")",
";",
"}",
"$",
"this",
"->",
"response",
"->",
"run",
"(",
")",
";",
"$",
"this",
"->",
"addErrorHr",
"(",
"LOG_ERROR",
")",
";",
"$",
"this",
"->",
"addErrorHr",
"(",
"LOG_SYSTEM",
")",
";",
"$",
"this",
"->",
"_setHistory",
"(",
"''",
")",
";",
"if",
"(",
"Config",
"::",
"config",
"(",
")",
"[",
"'user'",
"]",
"[",
"'output'",
"]",
"[",
"'minify'",
"]",
"&&",
"preg_match",
"(",
"'#text/html#isU'",
",",
"$",
"this",
"->",
"response",
"->",
"contentType",
"(",
")",
")",
")",
"{",
"$",
"this",
"->",
"response",
"->",
"page",
"(",
"$",
"this",
"->",
"_minifyHtml",
"(",
"$",
"this",
"->",
"response",
"->",
"page",
"(",
")",
")",
")",
";",
"}",
"if",
"(",
"Config",
"::",
"config",
"(",
")",
"[",
"'user'",
"]",
"[",
"'debug'",
"]",
"[",
"'environment'",
"]",
"==",
"'development'",
"&&",
"Config",
"::",
"config",
"(",
")",
"[",
"'user'",
"]",
"[",
"'debug'",
"]",
"[",
"'profiler'",
"]",
")",
"{",
"$",
"this",
"->",
"profiler",
"->",
"profiler",
"(",
"$",
"this",
"->",
"request",
",",
"$",
"this",
"->",
"response",
")",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"response",
"->",
"page",
"(",
"$",
"this",
"->",
"maintenance",
"(",
")",
")",
";",
"}",
"echo",
"$",
"this",
"->",
"response",
"->",
"page",
"(",
")",
";",
"}"
] | display the page
@access public
@return void
@since 3.0
@package Gcs\Framework\Core\Engine | [
"display",
"the",
"page"
] | 45e58182aba6a3c6381970a1fd3c17662cff2168 | https://github.com/fabsgc/framework/blob/45e58182aba6a3c6381970a1fd3c17662cff2168/Core/Engine/Engine.php#L410-L438 |
8,872 | fabsgc/framework | Core/Engine/Engine.php | Engine.runCron | public function runCron() {
if (!Config::config()['user']['debug']['maintenance']) {
$this->_controller();
$this->_setHistory('CRON');
}
echo $this->response->page();
} | php | public function runCron() {
if (!Config::config()['user']['debug']['maintenance']) {
$this->_controller();
$this->_setHistory('CRON');
}
echo $this->response->page();
} | [
"public",
"function",
"runCron",
"(",
")",
"{",
"if",
"(",
"!",
"Config",
"::",
"config",
"(",
")",
"[",
"'user'",
"]",
"[",
"'debug'",
"]",
"[",
"'maintenance'",
"]",
")",
"{",
"$",
"this",
"->",
"_controller",
"(",
")",
";",
"$",
"this",
"->",
"_setHistory",
"(",
"'CRON'",
")",
";",
"}",
"echo",
"$",
"this",
"->",
"response",
"->",
"page",
"(",
")",
";",
"}"
] | display the page for a cron
@access public
@return void
@since 3.0
@package Gcs\Framework\Core\Engine | [
"display",
"the",
"page",
"for",
"a",
"cron"
] | 45e58182aba6a3c6381970a1fd3c17662cff2168 | https://github.com/fabsgc/framework/blob/45e58182aba6a3c6381970a1fd3c17662cff2168/Core/Engine/Engine.php#L448-L455 |
8,873 | fabsgc/framework | Core/Engine/Engine.php | Engine._setHistory | private function _setHistory($message) {
$this->addError('URL : http://' . $this->request->env('HTTP_HOST') . $this->request->env('REQUEST_URI') . ' (' . $this->response->status() . ') / SRC "' . $this->request->src . '" / CONTROLLER "' . $this->request->controller . '" / ACTION "' . $this->request->action . '" / CACHE "' . $this->request->cache . '" / ORIGIN : ' . $this->request->env('HTTP_REFERER') . ' / IP : ' . $this->request->env('REMOTE_ADDR') . ' / ' . $message, 0, 0, 0, LOG_HISTORY);
} | php | private function _setHistory($message) {
$this->addError('URL : http://' . $this->request->env('HTTP_HOST') . $this->request->env('REQUEST_URI') . ' (' . $this->response->status() . ') / SRC "' . $this->request->src . '" / CONTROLLER "' . $this->request->controller . '" / ACTION "' . $this->request->action . '" / CACHE "' . $this->request->cache . '" / ORIGIN : ' . $this->request->env('HTTP_REFERER') . ' / IP : ' . $this->request->env('REMOTE_ADDR') . ' / ' . $message, 0, 0, 0, LOG_HISTORY);
} | [
"private",
"function",
"_setHistory",
"(",
"$",
"message",
")",
"{",
"$",
"this",
"->",
"addError",
"(",
"'URL : http://'",
".",
"$",
"this",
"->",
"request",
"->",
"env",
"(",
"'HTTP_HOST'",
")",
".",
"$",
"this",
"->",
"request",
"->",
"env",
"(",
"'REQUEST_URI'",
")",
".",
"' ('",
".",
"$",
"this",
"->",
"response",
"->",
"status",
"(",
")",
".",
"') / SRC \"'",
".",
"$",
"this",
"->",
"request",
"->",
"src",
".",
"'\" / CONTROLLER \"'",
".",
"$",
"this",
"->",
"request",
"->",
"controller",
".",
"'\" / ACTION \"'",
".",
"$",
"this",
"->",
"request",
"->",
"action",
".",
"'\" / CACHE \"'",
".",
"$",
"this",
"->",
"request",
"->",
"cache",
".",
"'\" / ORIGIN : '",
".",
"$",
"this",
"->",
"request",
"->",
"env",
"(",
"'HTTP_REFERER'",
")",
".",
"' / IP : '",
".",
"$",
"this",
"->",
"request",
"->",
"env",
"(",
"'REMOTE_ADDR'",
")",
".",
"' / '",
".",
"$",
"message",
",",
"0",
",",
"0",
",",
"0",
",",
"LOG_HISTORY",
")",
";",
"}"
] | log request in history
@access private
@param $message string
@return void
@since 3.0
@package Gcs\Framework\Core\Engine | [
"log",
"request",
"in",
"history"
] | 45e58182aba6a3c6381970a1fd3c17662cff2168 | https://github.com/fabsgc/framework/blob/45e58182aba6a3c6381970a1fd3c17662cff2168/Core/Engine/Engine.php#L653-L655 |
8,874 | gplcart/gapi | controllers/Credential.php | Credential.addCredential | public function addCredential($type)
{
$this->data_type = $type;
$this->setTitleEditCredential();
$this->setBreadcrumbEditCredential();
$this->credential->callHandler($type, 'edit');
} | php | public function addCredential($type)
{
$this->data_type = $type;
$this->setTitleEditCredential();
$this->setBreadcrumbEditCredential();
$this->credential->callHandler($type, 'edit');
} | [
"public",
"function",
"addCredential",
"(",
"$",
"type",
")",
"{",
"$",
"this",
"->",
"data_type",
"=",
"$",
"type",
";",
"$",
"this",
"->",
"setTitleEditCredential",
"(",
")",
";",
"$",
"this",
"->",
"setBreadcrumbEditCredential",
"(",
")",
";",
"$",
"this",
"->",
"credential",
"->",
"callHandler",
"(",
"$",
"type",
",",
"'edit'",
")",
";",
"}"
] | Route page callback
Displays the add credential page
@param string $type | [
"Route",
"page",
"callback",
"Displays",
"the",
"add",
"credential",
"page"
] | b1f8a737d8ff3b6a3e54f44d19af3295ce732fa8 | https://github.com/gplcart/gapi/blob/b1f8a737d8ff3b6a3e54f44d19af3295ce732fa8/controllers/Credential.php#L69-L77 |
8,875 | gplcart/gapi | controllers/Credential.php | Credential.editCredential | public function editCredential($credential_id)
{
$this->setCredential($credential_id);
$this->setTitleEditCredential();
$this->setBreadcrumbEditCredential();
$this->setData('credential', $this->data_credential);
$this->submitDeleteCredential();
$this->credential->callHandler($this->data_credential['type'], 'edit');
} | php | public function editCredential($credential_id)
{
$this->setCredential($credential_id);
$this->setTitleEditCredential();
$this->setBreadcrumbEditCredential();
$this->setData('credential', $this->data_credential);
$this->submitDeleteCredential();
$this->credential->callHandler($this->data_credential['type'], 'edit');
} | [
"public",
"function",
"editCredential",
"(",
"$",
"credential_id",
")",
"{",
"$",
"this",
"->",
"setCredential",
"(",
"$",
"credential_id",
")",
";",
"$",
"this",
"->",
"setTitleEditCredential",
"(",
")",
";",
"$",
"this",
"->",
"setBreadcrumbEditCredential",
"(",
")",
";",
"$",
"this",
"->",
"setData",
"(",
"'credential'",
",",
"$",
"this",
"->",
"data_credential",
")",
";",
"$",
"this",
"->",
"submitDeleteCredential",
"(",
")",
";",
"$",
"this",
"->",
"credential",
"->",
"callHandler",
"(",
"$",
"this",
"->",
"data_credential",
"[",
"'type'",
"]",
",",
"'edit'",
")",
";",
"}"
] | Route page callback
Displays the edit credential page
@param int $credential_id | [
"Route",
"page",
"callback",
"Displays",
"the",
"edit",
"credential",
"page"
] | b1f8a737d8ff3b6a3e54f44d19af3295ce732fa8 | https://github.com/gplcart/gapi/blob/b1f8a737d8ff3b6a3e54f44d19af3295ce732fa8/controllers/Credential.php#L123-L133 |
8,876 | gplcart/gapi | controllers/Credential.php | Credential.setCredential | protected function setCredential($credential_id)
{
if (is_numeric($credential_id)) {
$this->data_credential = $this->credential->get($credential_id);
if (empty($this->data_credential)) {
$this->outputHttpStatus(404);
}
}
} | php | protected function setCredential($credential_id)
{
if (is_numeric($credential_id)) {
$this->data_credential = $this->credential->get($credential_id);
if (empty($this->data_credential)) {
$this->outputHttpStatus(404);
}
}
} | [
"protected",
"function",
"setCredential",
"(",
"$",
"credential_id",
")",
"{",
"if",
"(",
"is_numeric",
"(",
"$",
"credential_id",
")",
")",
"{",
"$",
"this",
"->",
"data_credential",
"=",
"$",
"this",
"->",
"credential",
"->",
"get",
"(",
"$",
"credential_id",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"data_credential",
")",
")",
"{",
"$",
"this",
"->",
"outputHttpStatus",
"(",
"404",
")",
";",
"}",
"}",
"}"
] | Sets the credential data
@param $credential_id | [
"Sets",
"the",
"credential",
"data"
] | b1f8a737d8ff3b6a3e54f44d19af3295ce732fa8 | https://github.com/gplcart/gapi/blob/b1f8a737d8ff3b6a3e54f44d19af3295ce732fa8/controllers/Credential.php#L139-L147 |
8,877 | gplcart/gapi | controllers/Credential.php | Credential.setTitleEditCredential | protected function setTitleEditCredential()
{
if (isset($this->data_credential['name'])) {
$text = $this->text('Edit %name', array('%name' => $this->data_credential['name']));
} else {
$text = $this->text('Add credential');
}
$this->setTitle($text);
} | php | protected function setTitleEditCredential()
{
if (isset($this->data_credential['name'])) {
$text = $this->text('Edit %name', array('%name' => $this->data_credential['name']));
} else {
$text = $this->text('Add credential');
}
$this->setTitle($text);
} | [
"protected",
"function",
"setTitleEditCredential",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"data_credential",
"[",
"'name'",
"]",
")",
")",
"{",
"$",
"text",
"=",
"$",
"this",
"->",
"text",
"(",
"'Edit %name'",
",",
"array",
"(",
"'%name'",
"=>",
"$",
"this",
"->",
"data_credential",
"[",
"'name'",
"]",
")",
")",
";",
"}",
"else",
"{",
"$",
"text",
"=",
"$",
"this",
"->",
"text",
"(",
"'Add credential'",
")",
";",
"}",
"$",
"this",
"->",
"setTitle",
"(",
"$",
"text",
")",
";",
"}"
] | Set titles on the edit credential page | [
"Set",
"titles",
"on",
"the",
"edit",
"credential",
"page"
] | b1f8a737d8ff3b6a3e54f44d19af3295ce732fa8 | https://github.com/gplcart/gapi/blob/b1f8a737d8ff3b6a3e54f44d19af3295ce732fa8/controllers/Credential.php#L152-L161 |
8,878 | gplcart/gapi | controllers/Credential.php | Credential.setBreadcrumbEditCredential | protected function setBreadcrumbEditCredential()
{
$breadcrumbs = array();
$breadcrumbs[] = array(
'url' => $this->url('admin'),
'text' => $this->text('Dashboard')
);
$breadcrumbs[] = array(
'text' => $this->text('Google API credentials'),
'url' => $this->url('admin/report/gapi')
);
$this->setBreadcrumbs($breadcrumbs);
} | php | protected function setBreadcrumbEditCredential()
{
$breadcrumbs = array();
$breadcrumbs[] = array(
'url' => $this->url('admin'),
'text' => $this->text('Dashboard')
);
$breadcrumbs[] = array(
'text' => $this->text('Google API credentials'),
'url' => $this->url('admin/report/gapi')
);
$this->setBreadcrumbs($breadcrumbs);
} | [
"protected",
"function",
"setBreadcrumbEditCredential",
"(",
")",
"{",
"$",
"breadcrumbs",
"=",
"array",
"(",
")",
";",
"$",
"breadcrumbs",
"[",
"]",
"=",
"array",
"(",
"'url'",
"=>",
"$",
"this",
"->",
"url",
"(",
"'admin'",
")",
",",
"'text'",
"=>",
"$",
"this",
"->",
"text",
"(",
"'Dashboard'",
")",
")",
";",
"$",
"breadcrumbs",
"[",
"]",
"=",
"array",
"(",
"'text'",
"=>",
"$",
"this",
"->",
"text",
"(",
"'Google API credentials'",
")",
",",
"'url'",
"=>",
"$",
"this",
"->",
"url",
"(",
"'admin/report/gapi'",
")",
")",
";",
"$",
"this",
"->",
"setBreadcrumbs",
"(",
"$",
"breadcrumbs",
")",
";",
"}"
] | Set breadcrumbs on the edit credential page | [
"Set",
"breadcrumbs",
"on",
"the",
"edit",
"credential",
"page"
] | b1f8a737d8ff3b6a3e54f44d19af3295ce732fa8 | https://github.com/gplcart/gapi/blob/b1f8a737d8ff3b6a3e54f44d19af3295ce732fa8/controllers/Credential.php#L166-L181 |
8,879 | gplcart/gapi | controllers/Credential.php | Credential.validateKeyCredential | protected function validateKeyCredential()
{
if (!$this->isPosted('save')) {
return false;
}
$this->setSubmitted('credential');
$this->validateElement(array('name' => $this->text('Name')), 'length', array(1, 255));
$this->validateElement(array('data.key' => $this->text('Key')), 'length', array(1, 255));
return !$this->hasErrors();
} | php | protected function validateKeyCredential()
{
if (!$this->isPosted('save')) {
return false;
}
$this->setSubmitted('credential');
$this->validateElement(array('name' => $this->text('Name')), 'length', array(1, 255));
$this->validateElement(array('data.key' => $this->text('Key')), 'length', array(1, 255));
return !$this->hasErrors();
} | [
"protected",
"function",
"validateKeyCredential",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isPosted",
"(",
"'save'",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"setSubmitted",
"(",
"'credential'",
")",
";",
"$",
"this",
"->",
"validateElement",
"(",
"array",
"(",
"'name'",
"=>",
"$",
"this",
"->",
"text",
"(",
"'Name'",
")",
")",
",",
"'length'",
",",
"array",
"(",
"1",
",",
"255",
")",
")",
";",
"$",
"this",
"->",
"validateElement",
"(",
"array",
"(",
"'data.key'",
"=>",
"$",
"this",
"->",
"text",
"(",
"'Key'",
")",
")",
",",
"'length'",
",",
"array",
"(",
"1",
",",
"255",
")",
")",
";",
"return",
"!",
"$",
"this",
"->",
"hasErrors",
"(",
")",
";",
"}"
] | Validates "API key" credential data
@return bool | [
"Validates",
"API",
"key",
"credential",
"data"
] | b1f8a737d8ff3b6a3e54f44d19af3295ce732fa8 | https://github.com/gplcart/gapi/blob/b1f8a737d8ff3b6a3e54f44d19af3295ce732fa8/controllers/Credential.php#L187-L198 |
8,880 | gplcart/gapi | controllers/Credential.php | Credential.validateOauthCredential | protected function validateOauthCredential()
{
if (!$this->isPosted('save')) {
return false;
}
$this->setSubmitted('credential');
$this->validateElement(array('name' => $this->text('Name')), 'length', array(1, 255));
$this->validateElement(array('data.id' => $this->text('Client ID')), 'length', array(1, 255));
$this->validateElement(array('data.secret' => $this->text('Client secret')), 'length', array(1, 255));
return !$this->hasErrors();
} | php | protected function validateOauthCredential()
{
if (!$this->isPosted('save')) {
return false;
}
$this->setSubmitted('credential');
$this->validateElement(array('name' => $this->text('Name')), 'length', array(1, 255));
$this->validateElement(array('data.id' => $this->text('Client ID')), 'length', array(1, 255));
$this->validateElement(array('data.secret' => $this->text('Client secret')), 'length', array(1, 255));
return !$this->hasErrors();
} | [
"protected",
"function",
"validateOauthCredential",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isPosted",
"(",
"'save'",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"setSubmitted",
"(",
"'credential'",
")",
";",
"$",
"this",
"->",
"validateElement",
"(",
"array",
"(",
"'name'",
"=>",
"$",
"this",
"->",
"text",
"(",
"'Name'",
")",
")",
",",
"'length'",
",",
"array",
"(",
"1",
",",
"255",
")",
")",
";",
"$",
"this",
"->",
"validateElement",
"(",
"array",
"(",
"'data.id'",
"=>",
"$",
"this",
"->",
"text",
"(",
"'Client ID'",
")",
")",
",",
"'length'",
",",
"array",
"(",
"1",
",",
"255",
")",
")",
";",
"$",
"this",
"->",
"validateElement",
"(",
"array",
"(",
"'data.secret'",
"=>",
"$",
"this",
"->",
"text",
"(",
"'Client secret'",
")",
")",
",",
"'length'",
",",
"array",
"(",
"1",
",",
"255",
")",
")",
";",
"return",
"!",
"$",
"this",
"->",
"hasErrors",
"(",
")",
";",
"}"
] | Validates "OAuth" credential data
@return bool | [
"Validates",
"OAuth",
"credential",
"data"
] | b1f8a737d8ff3b6a3e54f44d19af3295ce732fa8 | https://github.com/gplcart/gapi/blob/b1f8a737d8ff3b6a3e54f44d19af3295ce732fa8/controllers/Credential.php#L204-L216 |
8,881 | gplcart/gapi | controllers/Credential.php | Credential.validateServiceCredential | protected function validateServiceCredential()
{
if (!$this->isPosted('save')) {
return false;
}
$this->setSubmitted('credential');
$this->validateElement(array('name' => $this->text('Name')), 'length', array(1, 255));
$this->validateFileUploadCredential();
return !$this->hasErrors();
} | php | protected function validateServiceCredential()
{
if (!$this->isPosted('save')) {
return false;
}
$this->setSubmitted('credential');
$this->validateElement(array('name' => $this->text('Name')), 'length', array(1, 255));
$this->validateFileUploadCredential();
return !$this->hasErrors();
} | [
"protected",
"function",
"validateServiceCredential",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isPosted",
"(",
"'save'",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"setSubmitted",
"(",
"'credential'",
")",
";",
"$",
"this",
"->",
"validateElement",
"(",
"array",
"(",
"'name'",
"=>",
"$",
"this",
"->",
"text",
"(",
"'Name'",
")",
")",
",",
"'length'",
",",
"array",
"(",
"1",
",",
"255",
")",
")",
";",
"$",
"this",
"->",
"validateFileUploadCredential",
"(",
")",
";",
"return",
"!",
"$",
"this",
"->",
"hasErrors",
"(",
")",
";",
"}"
] | Validates "Service" credential data
@return bool | [
"Validates",
"Service",
"credential",
"data"
] | b1f8a737d8ff3b6a3e54f44d19af3295ce732fa8 | https://github.com/gplcart/gapi/blob/b1f8a737d8ff3b6a3e54f44d19af3295ce732fa8/controllers/Credential.php#L222-L233 |
8,882 | gplcart/gapi | controllers/Credential.php | Credential.validateFileUploadCredential | protected function validateFileUploadCredential()
{
$upload = $this->request->file('file');
if (empty($upload)) {
if (!isset($this->data_credential['credential_id'])) {
$this->setError('data.file', $this->text('File is required'));
return false;
}
return null;
}
if ($this->isError()) {
return null;
}
$result = $this->file_transfer->upload($upload, false, gplcart_file_private_module('gapi'));
if ($result !== true) {
$this->setError('data.file', $result);
return false;
}
$file = $this->file_transfer->getTransferred();
$decoded = json_decode(file_get_contents($file), true);
if (empty($decoded['private_key'])) {
unlink($file);
$this->setError('data.file', $this->text('Failed to read JSON file'));
return false;
}
if (isset($this->data_credential['data']['file'])) {
$existing = gplcart_file_absolute($this->data_credential['data']['file']);
if (file_exists($existing)) {
unlink($existing);
}
}
$this->setSubmitted('data.file', gplcart_file_relative($file));
return true;
} | php | protected function validateFileUploadCredential()
{
$upload = $this->request->file('file');
if (empty($upload)) {
if (!isset($this->data_credential['credential_id'])) {
$this->setError('data.file', $this->text('File is required'));
return false;
}
return null;
}
if ($this->isError()) {
return null;
}
$result = $this->file_transfer->upload($upload, false, gplcart_file_private_module('gapi'));
if ($result !== true) {
$this->setError('data.file', $result);
return false;
}
$file = $this->file_transfer->getTransferred();
$decoded = json_decode(file_get_contents($file), true);
if (empty($decoded['private_key'])) {
unlink($file);
$this->setError('data.file', $this->text('Failed to read JSON file'));
return false;
}
if (isset($this->data_credential['data']['file'])) {
$existing = gplcart_file_absolute($this->data_credential['data']['file']);
if (file_exists($existing)) {
unlink($existing);
}
}
$this->setSubmitted('data.file', gplcart_file_relative($file));
return true;
} | [
"protected",
"function",
"validateFileUploadCredential",
"(",
")",
"{",
"$",
"upload",
"=",
"$",
"this",
"->",
"request",
"->",
"file",
"(",
"'file'",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"upload",
")",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"data_credential",
"[",
"'credential_id'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"setError",
"(",
"'data.file'",
",",
"$",
"this",
"->",
"text",
"(",
"'File is required'",
")",
")",
";",
"return",
"false",
";",
"}",
"return",
"null",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"isError",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"result",
"=",
"$",
"this",
"->",
"file_transfer",
"->",
"upload",
"(",
"$",
"upload",
",",
"false",
",",
"gplcart_file_private_module",
"(",
"'gapi'",
")",
")",
";",
"if",
"(",
"$",
"result",
"!==",
"true",
")",
"{",
"$",
"this",
"->",
"setError",
"(",
"'data.file'",
",",
"$",
"result",
")",
";",
"return",
"false",
";",
"}",
"$",
"file",
"=",
"$",
"this",
"->",
"file_transfer",
"->",
"getTransferred",
"(",
")",
";",
"$",
"decoded",
"=",
"json_decode",
"(",
"file_get_contents",
"(",
"$",
"file",
")",
",",
"true",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"decoded",
"[",
"'private_key'",
"]",
")",
")",
"{",
"unlink",
"(",
"$",
"file",
")",
";",
"$",
"this",
"->",
"setError",
"(",
"'data.file'",
",",
"$",
"this",
"->",
"text",
"(",
"'Failed to read JSON file'",
")",
")",
";",
"return",
"false",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"data_credential",
"[",
"'data'",
"]",
"[",
"'file'",
"]",
")",
")",
"{",
"$",
"existing",
"=",
"gplcart_file_absolute",
"(",
"$",
"this",
"->",
"data_credential",
"[",
"'data'",
"]",
"[",
"'file'",
"]",
")",
";",
"if",
"(",
"file_exists",
"(",
"$",
"existing",
")",
")",
"{",
"unlink",
"(",
"$",
"existing",
")",
";",
"}",
"}",
"$",
"this",
"->",
"setSubmitted",
"(",
"'data.file'",
",",
"gplcart_file_relative",
"(",
"$",
"file",
")",
")",
";",
"return",
"true",
";",
"}"
] | Validates JSON file upload
@return bool | [
"Validates",
"JSON",
"file",
"upload"
] | b1f8a737d8ff3b6a3e54f44d19af3295ce732fa8 | https://github.com/gplcart/gapi/blob/b1f8a737d8ff3b6a3e54f44d19af3295ce732fa8/controllers/Credential.php#L239-L282 |
8,883 | gplcart/gapi | controllers/Credential.php | Credential.updateSubmittedCredential | protected function updateSubmittedCredential()
{
$this->controlAccess('module_gapi_credential_edit');
if ($this->credential->update($this->data_credential['credential_id'], $this->getSubmitted())) {
$this->redirect('admin/report/gapi', $this->text('Credential has been updated'), 'success');
}
$this->redirect('', $this->text('Credential has not been updated'), 'warning');
} | php | protected function updateSubmittedCredential()
{
$this->controlAccess('module_gapi_credential_edit');
if ($this->credential->update($this->data_credential['credential_id'], $this->getSubmitted())) {
$this->redirect('admin/report/gapi', $this->text('Credential has been updated'), 'success');
}
$this->redirect('', $this->text('Credential has not been updated'), 'warning');
} | [
"protected",
"function",
"updateSubmittedCredential",
"(",
")",
"{",
"$",
"this",
"->",
"controlAccess",
"(",
"'module_gapi_credential_edit'",
")",
";",
"if",
"(",
"$",
"this",
"->",
"credential",
"->",
"update",
"(",
"$",
"this",
"->",
"data_credential",
"[",
"'credential_id'",
"]",
",",
"$",
"this",
"->",
"getSubmitted",
"(",
")",
")",
")",
"{",
"$",
"this",
"->",
"redirect",
"(",
"'admin/report/gapi'",
",",
"$",
"this",
"->",
"text",
"(",
"'Credential has been updated'",
")",
",",
"'success'",
")",
";",
"}",
"$",
"this",
"->",
"redirect",
"(",
"''",
",",
"$",
"this",
"->",
"text",
"(",
"'Credential has not been updated'",
")",
",",
"'warning'",
")",
";",
"}"
] | Updates a submitted credential | [
"Updates",
"a",
"submitted",
"credential"
] | b1f8a737d8ff3b6a3e54f44d19af3295ce732fa8 | https://github.com/gplcart/gapi/blob/b1f8a737d8ff3b6a3e54f44d19af3295ce732fa8/controllers/Credential.php#L299-L308 |
8,884 | gplcart/gapi | controllers/Credential.php | Credential.addSubmittedCredential | protected function addSubmittedCredential()
{
$this->controlAccess('module_gapi_credential_add');
$submitted = $this->getSubmitted();
$submitted['type'] = $this->data_type;
if ($this->credential->add($submitted)) {
$this->redirect('admin/report/gapi', $this->text('Credential has been added'), 'success');
}
$this->redirect('', $this->text('Credential has not been added'), 'warning');
} | php | protected function addSubmittedCredential()
{
$this->controlAccess('module_gapi_credential_add');
$submitted = $this->getSubmitted();
$submitted['type'] = $this->data_type;
if ($this->credential->add($submitted)) {
$this->redirect('admin/report/gapi', $this->text('Credential has been added'), 'success');
}
$this->redirect('', $this->text('Credential has not been added'), 'warning');
} | [
"protected",
"function",
"addSubmittedCredential",
"(",
")",
"{",
"$",
"this",
"->",
"controlAccess",
"(",
"'module_gapi_credential_add'",
")",
";",
"$",
"submitted",
"=",
"$",
"this",
"->",
"getSubmitted",
"(",
")",
";",
"$",
"submitted",
"[",
"'type'",
"]",
"=",
"$",
"this",
"->",
"data_type",
";",
"if",
"(",
"$",
"this",
"->",
"credential",
"->",
"add",
"(",
"$",
"submitted",
")",
")",
"{",
"$",
"this",
"->",
"redirect",
"(",
"'admin/report/gapi'",
",",
"$",
"this",
"->",
"text",
"(",
"'Credential has been added'",
")",
",",
"'success'",
")",
";",
"}",
"$",
"this",
"->",
"redirect",
"(",
"''",
",",
"$",
"this",
"->",
"text",
"(",
"'Credential has not been added'",
")",
",",
"'warning'",
")",
";",
"}"
] | Adds a submitted credential | [
"Adds",
"a",
"submitted",
"credential"
] | b1f8a737d8ff3b6a3e54f44d19af3295ce732fa8 | https://github.com/gplcart/gapi/blob/b1f8a737d8ff3b6a3e54f44d19af3295ce732fa8/controllers/Credential.php#L313-L325 |
8,885 | gplcart/gapi | controllers/Credential.php | Credential.submitDeleteCredential | protected function submitDeleteCredential()
{
if ($this->isPosted('delete') && isset($this->data_credential['credential_id'])) {
$this->controlAccess('module_gapi_credential_delete');
if ($this->credential->callHandler($this->data_credential['type'], 'delete', array(
$this->data_credential['credential_id']))) {
$this->redirect('admin/report/gapi', $this->text('Credential has been deleted'), 'success');
}
$this->redirect('', $this->text('Credential has not been deleted'), 'warning');
}
} | php | protected function submitDeleteCredential()
{
if ($this->isPosted('delete') && isset($this->data_credential['credential_id'])) {
$this->controlAccess('module_gapi_credential_delete');
if ($this->credential->callHandler($this->data_credential['type'], 'delete', array(
$this->data_credential['credential_id']))) {
$this->redirect('admin/report/gapi', $this->text('Credential has been deleted'), 'success');
}
$this->redirect('', $this->text('Credential has not been deleted'), 'warning');
}
} | [
"protected",
"function",
"submitDeleteCredential",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isPosted",
"(",
"'delete'",
")",
"&&",
"isset",
"(",
"$",
"this",
"->",
"data_credential",
"[",
"'credential_id'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"controlAccess",
"(",
"'module_gapi_credential_delete'",
")",
";",
"if",
"(",
"$",
"this",
"->",
"credential",
"->",
"callHandler",
"(",
"$",
"this",
"->",
"data_credential",
"[",
"'type'",
"]",
",",
"'delete'",
",",
"array",
"(",
"$",
"this",
"->",
"data_credential",
"[",
"'credential_id'",
"]",
")",
")",
")",
"{",
"$",
"this",
"->",
"redirect",
"(",
"'admin/report/gapi'",
",",
"$",
"this",
"->",
"text",
"(",
"'Credential has been deleted'",
")",
",",
"'success'",
")",
";",
"}",
"$",
"this",
"->",
"redirect",
"(",
"''",
",",
"$",
"this",
"->",
"text",
"(",
"'Credential has not been deleted'",
")",
",",
"'warning'",
")",
";",
"}",
"}"
] | Delete a submitted credential | [
"Delete",
"a",
"submitted",
"credential"
] | b1f8a737d8ff3b6a3e54f44d19af3295ce732fa8 | https://github.com/gplcart/gapi/blob/b1f8a737d8ff3b6a3e54f44d19af3295ce732fa8/controllers/Credential.php#L330-L343 |
8,886 | gplcart/gapi | controllers/Credential.php | Credential.listCredential | public function listCredential()
{
$this->actionListCredential();
$this->setTitleListCredential();
$this->setBreadcrumbListCredential();
$this->setFilterListCredential();
$this->setPagerListCredential();
$this->setData('credentials', $this->getListCredential());
$this->setData('handlers', $this->credential->getHandlers());
$this->outputListCredential();
} | php | public function listCredential()
{
$this->actionListCredential();
$this->setTitleListCredential();
$this->setBreadcrumbListCredential();
$this->setFilterListCredential();
$this->setPagerListCredential();
$this->setData('credentials', $this->getListCredential());
$this->setData('handlers', $this->credential->getHandlers());
$this->outputListCredential();
} | [
"public",
"function",
"listCredential",
"(",
")",
"{",
"$",
"this",
"->",
"actionListCredential",
"(",
")",
";",
"$",
"this",
"->",
"setTitleListCredential",
"(",
")",
";",
"$",
"this",
"->",
"setBreadcrumbListCredential",
"(",
")",
";",
"$",
"this",
"->",
"setFilterListCredential",
"(",
")",
";",
"$",
"this",
"->",
"setPagerListCredential",
"(",
")",
";",
"$",
"this",
"->",
"setData",
"(",
"'credentials'",
",",
"$",
"this",
"->",
"getListCredential",
"(",
")",
")",
";",
"$",
"this",
"->",
"setData",
"(",
"'handlers'",
",",
"$",
"this",
"->",
"credential",
"->",
"getHandlers",
"(",
")",
")",
";",
"$",
"this",
"->",
"outputListCredential",
"(",
")",
";",
"}"
] | Route callback
Displays the credential overview page | [
"Route",
"callback",
"Displays",
"the",
"credential",
"overview",
"page"
] | b1f8a737d8ff3b6a3e54f44d19af3295ce732fa8 | https://github.com/gplcart/gapi/blob/b1f8a737d8ff3b6a3e54f44d19af3295ce732fa8/controllers/Credential.php#L349-L360 |
8,887 | gplcart/gapi | controllers/Credential.php | Credential.actionListCredential | protected function actionListCredential()
{
list($selected, $action) = $this->getPostedAction();
$deleted = 0;
foreach ($selected as $id) {
if ($action === 'delete' && $this->access('module_gapi_credential_delete')) {
$credential = $this->credential->get($id);
$deleted += (int) $this->credential->callHandler($credential['type'], 'delete', array(
$credential['credential_id']));
}
}
if ($deleted > 0) {
$message = $this->text('Deleted %num item(s)', array('%num' => $deleted));
$this->setMessage($message, 'success');
}
} | php | protected function actionListCredential()
{
list($selected, $action) = $this->getPostedAction();
$deleted = 0;
foreach ($selected as $id) {
if ($action === 'delete' && $this->access('module_gapi_credential_delete')) {
$credential = $this->credential->get($id);
$deleted += (int) $this->credential->callHandler($credential['type'], 'delete', array(
$credential['credential_id']));
}
}
if ($deleted > 0) {
$message = $this->text('Deleted %num item(s)', array('%num' => $deleted));
$this->setMessage($message, 'success');
}
} | [
"protected",
"function",
"actionListCredential",
"(",
")",
"{",
"list",
"(",
"$",
"selected",
",",
"$",
"action",
")",
"=",
"$",
"this",
"->",
"getPostedAction",
"(",
")",
";",
"$",
"deleted",
"=",
"0",
";",
"foreach",
"(",
"$",
"selected",
"as",
"$",
"id",
")",
"{",
"if",
"(",
"$",
"action",
"===",
"'delete'",
"&&",
"$",
"this",
"->",
"access",
"(",
"'module_gapi_credential_delete'",
")",
")",
"{",
"$",
"credential",
"=",
"$",
"this",
"->",
"credential",
"->",
"get",
"(",
"$",
"id",
")",
";",
"$",
"deleted",
"+=",
"(",
"int",
")",
"$",
"this",
"->",
"credential",
"->",
"callHandler",
"(",
"$",
"credential",
"[",
"'type'",
"]",
",",
"'delete'",
",",
"array",
"(",
"$",
"credential",
"[",
"'credential_id'",
"]",
")",
")",
";",
"}",
"}",
"if",
"(",
"$",
"deleted",
">",
"0",
")",
"{",
"$",
"message",
"=",
"$",
"this",
"->",
"text",
"(",
"'Deleted %num item(s)'",
",",
"array",
"(",
"'%num'",
"=>",
"$",
"deleted",
")",
")",
";",
"$",
"this",
"->",
"setMessage",
"(",
"$",
"message",
",",
"'success'",
")",
";",
"}",
"}"
] | Applies an action to the selected credentials | [
"Applies",
"an",
"action",
"to",
"the",
"selected",
"credentials"
] | b1f8a737d8ff3b6a3e54f44d19af3295ce732fa8 | https://github.com/gplcart/gapi/blob/b1f8a737d8ff3b6a3e54f44d19af3295ce732fa8/controllers/Credential.php#L365-L383 |
8,888 | gplcart/gapi | controllers/Credential.php | Credential.getListCredential | protected function getListCredential()
{
$options = $this->query_filter;
$options['limit'] = $this->data_limit;
return $this->credential->getList($options);
} | php | protected function getListCredential()
{
$options = $this->query_filter;
$options['limit'] = $this->data_limit;
return $this->credential->getList($options);
} | [
"protected",
"function",
"getListCredential",
"(",
")",
"{",
"$",
"options",
"=",
"$",
"this",
"->",
"query_filter",
";",
"$",
"options",
"[",
"'limit'",
"]",
"=",
"$",
"this",
"->",
"data_limit",
";",
"return",
"$",
"this",
"->",
"credential",
"->",
"getList",
"(",
"$",
"options",
")",
";",
"}"
] | Returns an array of credentials
@return array | [
"Returns",
"an",
"array",
"of",
"credentials"
] | b1f8a737d8ff3b6a3e54f44d19af3295ce732fa8 | https://github.com/gplcart/gapi/blob/b1f8a737d8ff3b6a3e54f44d19af3295ce732fa8/controllers/Credential.php#L414-L420 |
8,889 | vworldat/AttachmentBundle | Model/Attachment.php | Attachment.saveRememberedCustomName | public function saveRememberedCustomName()
{
if (null === $this->rememberName || !$this->hasLoadedLinks())
{
return;
}
foreach ($this->collAttachmentLinks as $attachmentLink)
{
/* @var $attachmentLink AttachmentLink */
$attachmentLink
->setCustomName($this->rememberName)
->save()
;
}
return $this;
} | php | public function saveRememberedCustomName()
{
if (null === $this->rememberName || !$this->hasLoadedLinks())
{
return;
}
foreach ($this->collAttachmentLinks as $attachmentLink)
{
/* @var $attachmentLink AttachmentLink */
$attachmentLink
->setCustomName($this->rememberName)
->save()
;
}
return $this;
} | [
"public",
"function",
"saveRememberedCustomName",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"rememberName",
"||",
"!",
"$",
"this",
"->",
"hasLoadedLinks",
"(",
")",
")",
"{",
"return",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"collAttachmentLinks",
"as",
"$",
"attachmentLink",
")",
"{",
"/* @var $attachmentLink AttachmentLink */",
"$",
"attachmentLink",
"->",
"setCustomName",
"(",
"$",
"this",
"->",
"rememberName",
")",
"->",
"save",
"(",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Save custom name to all loaded AttachmentLinks if it has been set from the outside.
@return Attachment | [
"Save",
"custom",
"name",
"to",
"all",
"loaded",
"AttachmentLinks",
"if",
"it",
"has",
"been",
"set",
"from",
"the",
"outside",
"."
] | fb179c913e135164e0d1ebc69dcaf8b4782370dd | https://github.com/vworldat/AttachmentBundle/blob/fb179c913e135164e0d1ebc69dcaf8b4782370dd/Model/Attachment.php#L126-L143 |
8,890 | vworldat/AttachmentBundle | Model/Attachment.php | Attachment.getLinkForObject | public function getLinkForObject(AttachableObjectInterface $object, $fieldName = null)
{
return AttachmentLinkQuery::create()
->filterByAttachment($this)
->filterByAttachableObject($object)
->filterByModelField($fieldName)
->findOne()
;
} | php | public function getLinkForObject(AttachableObjectInterface $object, $fieldName = null)
{
return AttachmentLinkQuery::create()
->filterByAttachment($this)
->filterByAttachableObject($object)
->filterByModelField($fieldName)
->findOne()
;
} | [
"public",
"function",
"getLinkForObject",
"(",
"AttachableObjectInterface",
"$",
"object",
",",
"$",
"fieldName",
"=",
"null",
")",
"{",
"return",
"AttachmentLinkQuery",
"::",
"create",
"(",
")",
"->",
"filterByAttachment",
"(",
"$",
"this",
")",
"->",
"filterByAttachableObject",
"(",
"$",
"object",
")",
"->",
"filterByModelField",
"(",
"$",
"fieldName",
")",
"->",
"findOne",
"(",
")",
";",
"}"
] | Get the AttachmentLink for a specific attachable object and field name.
@param AttachableObjectInterface $object
@param string $fieldName
@return AttachmentLink | [
"Get",
"the",
"AttachmentLink",
"for",
"a",
"specific",
"attachable",
"object",
"and",
"field",
"name",
"."
] | fb179c913e135164e0d1ebc69dcaf8b4782370dd | https://github.com/vworldat/AttachmentBundle/blob/fb179c913e135164e0d1ebc69dcaf8b4782370dd/Model/Attachment.php#L211-L219 |
8,891 | meridius/helpers | src/ExcelHelper.php | ExcelHelper.getExcelColumnName | public static function getExcelColumnName($num) {
$num--;
for ($name = ''; $num >= 0; $num = intval($num / 26) - 1) {
$name = chr($num % 26 + 0x41) . $name;
}
return $name;
} | php | public static function getExcelColumnName($num) {
$num--;
for ($name = ''; $num >= 0; $num = intval($num / 26) - 1) {
$name = chr($num % 26 + 0x41) . $name;
}
return $name;
} | [
"public",
"static",
"function",
"getExcelColumnName",
"(",
"$",
"num",
")",
"{",
"$",
"num",
"--",
";",
"for",
"(",
"$",
"name",
"=",
"''",
";",
"$",
"num",
">=",
"0",
";",
"$",
"num",
"=",
"intval",
"(",
"$",
"num",
"/",
"26",
")",
"-",
"1",
")",
"{",
"$",
"name",
"=",
"chr",
"(",
"$",
"num",
"%",
"26",
"+",
"0x41",
")",
".",
"$",
"name",
";",
"}",
"return",
"$",
"name",
";",
"}"
] | Converts numbers to Excel-like column names
A = 1
@param int $num
@return string | [
"Converts",
"numbers",
"to",
"Excel",
"-",
"like",
"column",
"names",
"A",
"=",
"1"
] | 108dac43a0bb90d95ebcf8e6f5a21f37221764f1 | https://github.com/meridius/helpers/blob/108dac43a0bb90d95ebcf8e6f5a21f37221764f1/src/ExcelHelper.php#L15-L21 |
8,892 | meridius/helpers | src/ExcelHelper.php | ExcelHelper.getExcelColumnNumber | public static function getExcelColumnNumber($letters) {
$num = 0;
$arr = array_reverse(str_split($letters));
$arrSize = count($arr);
for ($i = 0; $i < $arrSize; $i++) {
$num += (ord(strtolower($arr[$i])) - 96) * (pow(26, $i));
}
return $num;
} | php | public static function getExcelColumnNumber($letters) {
$num = 0;
$arr = array_reverse(str_split($letters));
$arrSize = count($arr);
for ($i = 0; $i < $arrSize; $i++) {
$num += (ord(strtolower($arr[$i])) - 96) * (pow(26, $i));
}
return $num;
} | [
"public",
"static",
"function",
"getExcelColumnNumber",
"(",
"$",
"letters",
")",
"{",
"$",
"num",
"=",
"0",
";",
"$",
"arr",
"=",
"array_reverse",
"(",
"str_split",
"(",
"$",
"letters",
")",
")",
";",
"$",
"arrSize",
"=",
"count",
"(",
"$",
"arr",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"arrSize",
";",
"$",
"i",
"++",
")",
"{",
"$",
"num",
"+=",
"(",
"ord",
"(",
"strtolower",
"(",
"$",
"arr",
"[",
"$",
"i",
"]",
")",
")",
"-",
"96",
")",
"*",
"(",
"pow",
"(",
"26",
",",
"$",
"i",
")",
")",
";",
"}",
"return",
"$",
"num",
";",
"}"
] | Converts Excel-like column names to numbers
@param string $letters
@return int | [
"Converts",
"Excel",
"-",
"like",
"column",
"names",
"to",
"numbers"
] | 108dac43a0bb90d95ebcf8e6f5a21f37221764f1 | https://github.com/meridius/helpers/blob/108dac43a0bb90d95ebcf8e6f5a21f37221764f1/src/ExcelHelper.php#L28-L37 |
8,893 | mtoolkit/mtoolkit-network | src/rpc/json/server/MRPCJsonWebServiceDefinition.php | MRPCJsonWebServiceDefinition.initMethodDefinitionList | private function initMethodDefinitionList()
{
$class = new \ReflectionClass( $this->className );
$methods = $class->getMethods( \ReflectionMethod::IS_PUBLIC );
foreach( $methods as /* @var $reflect \ReflectionMethod */
$reflect )
{
if( $reflect->class != $this->className )
{
continue;
}
$docComment = $reflect->getDocComment();
$phpDoc = array(
'name' => $reflect->getName(),
'definition' => implode( "\n", array_map( 'trim', explode( "\n", $docComment ) ) )
);
$this->methodDefinitionList[] = $phpDoc;
}
} | php | private function initMethodDefinitionList()
{
$class = new \ReflectionClass( $this->className );
$methods = $class->getMethods( \ReflectionMethod::IS_PUBLIC );
foreach( $methods as /* @var $reflect \ReflectionMethod */
$reflect )
{
if( $reflect->class != $this->className )
{
continue;
}
$docComment = $reflect->getDocComment();
$phpDoc = array(
'name' => $reflect->getName(),
'definition' => implode( "\n", array_map( 'trim', explode( "\n", $docComment ) ) )
);
$this->methodDefinitionList[] = $phpDoc;
}
} | [
"private",
"function",
"initMethodDefinitionList",
"(",
")",
"{",
"$",
"class",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"this",
"->",
"className",
")",
";",
"$",
"methods",
"=",
"$",
"class",
"->",
"getMethods",
"(",
"\\",
"ReflectionMethod",
"::",
"IS_PUBLIC",
")",
";",
"foreach",
"(",
"$",
"methods",
"as",
"/* @var $reflect \\ReflectionMethod */",
"$",
"reflect",
")",
"{",
"if",
"(",
"$",
"reflect",
"->",
"class",
"!=",
"$",
"this",
"->",
"className",
")",
"{",
"continue",
";",
"}",
"$",
"docComment",
"=",
"$",
"reflect",
"->",
"getDocComment",
"(",
")",
";",
"$",
"phpDoc",
"=",
"array",
"(",
"'name'",
"=>",
"$",
"reflect",
"->",
"getName",
"(",
")",
",",
"'definition'",
"=>",
"implode",
"(",
"\"\\n\"",
",",
"array_map",
"(",
"'trim'",
",",
"explode",
"(",
"\"\\n\"",
",",
"$",
"docComment",
")",
")",
")",
")",
";",
"$",
"this",
"->",
"methodDefinitionList",
"[",
"]",
"=",
"$",
"phpDoc",
";",
"}",
"}"
] | Sets the array of the definitions of the methods. | [
"Sets",
"the",
"array",
"of",
"the",
"definitions",
"of",
"the",
"methods",
"."
] | eecf251df546a60ecb693fd3983e78cb946cb9d4 | https://github.com/mtoolkit/mtoolkit-network/blob/eecf251df546a60ecb693fd3983e78cb946cb9d4/src/rpc/json/server/MRPCJsonWebServiceDefinition.php#L47-L68 |
8,894 | chrismou/phergie-irc-plugin-react-weather | src/Provider/Wunderground.php | Wunderground.getApiRequestUrl | public function getApiRequestUrl(Event $event)
{
$params = $event->getCustomParams();
// Final parameter should be the country
$country = $params[count($params) - 1];
// Remove the final paramater
unset($params[count($params) - 1]);
// Merge the remainder of the supplied params and remove disallowed punctuation
$place = trim(implode("_", preg_replace('/[^\da-z\ ]/i', '', $params)));
return sprintf("%s/%s/conditions/q/%s/%s.json", $this->apiUrl, $this->appId, $country, $place);
} | php | public function getApiRequestUrl(Event $event)
{
$params = $event->getCustomParams();
// Final parameter should be the country
$country = $params[count($params) - 1];
// Remove the final paramater
unset($params[count($params) - 1]);
// Merge the remainder of the supplied params and remove disallowed punctuation
$place = trim(implode("_", preg_replace('/[^\da-z\ ]/i', '', $params)));
return sprintf("%s/%s/conditions/q/%s/%s.json", $this->apiUrl, $this->appId, $country, $place);
} | [
"public",
"function",
"getApiRequestUrl",
"(",
"Event",
"$",
"event",
")",
"{",
"$",
"params",
"=",
"$",
"event",
"->",
"getCustomParams",
"(",
")",
";",
"// Final parameter should be the country",
"$",
"country",
"=",
"$",
"params",
"[",
"count",
"(",
"$",
"params",
")",
"-",
"1",
"]",
";",
"// Remove the final paramater",
"unset",
"(",
"$",
"params",
"[",
"count",
"(",
"$",
"params",
")",
"-",
"1",
"]",
")",
";",
"// Merge the remainder of the supplied params and remove disallowed punctuation",
"$",
"place",
"=",
"trim",
"(",
"implode",
"(",
"\"_\"",
",",
"preg_replace",
"(",
"'/[^\\da-z\\ ]/i'",
",",
"''",
",",
"$",
"params",
")",
")",
")",
";",
"return",
"sprintf",
"(",
"\"%s/%s/conditions/q/%s/%s.json\"",
",",
"$",
"this",
"->",
"apiUrl",
",",
"$",
"this",
"->",
"appId",
",",
"$",
"country",
",",
"$",
"place",
")",
";",
"}"
] | Return the url for the API request
@param \Phergie\Irc\Plugin\React\Command\CommandEvent $event
@return string | [
"Return",
"the",
"url",
"for",
"the",
"API",
"request"
] | 9bc0e0b6d49f629a8c1c8df25a5561f5cf2901a2 | https://github.com/chrismou/phergie-irc-plugin-react-weather/blob/9bc0e0b6d49f629a8c1c8df25a5561f5cf2901a2/src/Provider/Wunderground.php#L41-L52 |
8,895 | asbsoft/yii2-common_2_170212 | base/ModulesManager.php | ModulesManager.instance | public static function instance()
{
if (empty(static::$_modmgr)) {
$module = Yii::$app->getModule(static::$modulesManagerModuleUid);
if (!empty($module) && $module instanceof UniModule) {
static::$_modmgr = $module->getDataModel(static::$modulesManagerModelAlias);
} else {
static::$_modmgr = new static;
}
}
return static::$_modmgr;
} | php | public static function instance()
{
if (empty(static::$_modmgr)) {
$module = Yii::$app->getModule(static::$modulesManagerModuleUid);
if (!empty($module) && $module instanceof UniModule) {
static::$_modmgr = $module->getDataModel(static::$modulesManagerModelAlias);
} else {
static::$_modmgr = new static;
}
}
return static::$_modmgr;
} | [
"public",
"static",
"function",
"instance",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"static",
"::",
"$",
"_modmgr",
")",
")",
"{",
"$",
"module",
"=",
"Yii",
"::",
"$",
"app",
"->",
"getModule",
"(",
"static",
"::",
"$",
"modulesManagerModuleUid",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"module",
")",
"&&",
"$",
"module",
"instanceof",
"UniModule",
")",
"{",
"static",
"::",
"$",
"_modmgr",
"=",
"$",
"module",
"->",
"getDataModel",
"(",
"static",
"::",
"$",
"modulesManagerModelAlias",
")",
";",
"}",
"else",
"{",
"static",
"::",
"$",
"_modmgr",
"=",
"new",
"static",
";",
"}",
"}",
"return",
"static",
"::",
"$",
"_modmgr",
";",
"}"
] | Get modules manager instance | [
"Get",
"modules",
"manager",
"instance"
] | 6c58012ff89225d7d4e42b200cf39e009e9d9dac | https://github.com/asbsoft/yii2-common_2_170212/blob/6c58012ff89225d7d4e42b200cf39e009e9d9dac/base/ModulesManager.php#L49-L60 |
8,896 | asbsoft/yii2-common_2_170212 | base/ModulesManager.php | ModulesManager.setAlreadyAddSubmodulesFor | public static function setAlreadyAddSubmodulesFor($module, $app = null)
{
if (empty($app)) {
$app = Yii::$app;
}
$appKey = UniApplication::appKey($app);
if($module instanceof YiiBaseModule) {
static::$_modulesWithInstalledSubmodules[$appKey][$module::className()] = $module->uniqueId; // uniqueId for Yii::$app = ''
}
} | php | public static function setAlreadyAddSubmodulesFor($module, $app = null)
{
if (empty($app)) {
$app = Yii::$app;
}
$appKey = UniApplication::appKey($app);
if($module instanceof YiiBaseModule) {
static::$_modulesWithInstalledSubmodules[$appKey][$module::className()] = $module->uniqueId; // uniqueId for Yii::$app = ''
}
} | [
"public",
"static",
"function",
"setAlreadyAddSubmodulesFor",
"(",
"$",
"module",
",",
"$",
"app",
"=",
"null",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"app",
")",
")",
"{",
"$",
"app",
"=",
"Yii",
"::",
"$",
"app",
";",
"}",
"$",
"appKey",
"=",
"UniApplication",
"::",
"appKey",
"(",
"$",
"app",
")",
";",
"if",
"(",
"$",
"module",
"instanceof",
"YiiBaseModule",
")",
"{",
"static",
"::",
"$",
"_modulesWithInstalledSubmodules",
"[",
"$",
"appKey",
"]",
"[",
"$",
"module",
"::",
"className",
"(",
")",
"]",
"=",
"$",
"module",
"->",
"uniqueId",
";",
"// uniqueId for Yii::$app = ''",
"}",
"}"
] | Add new module to list modules with already installed submodules.
@param yii\base\Module $module
@param yii\base\Application $app | [
"Add",
"new",
"module",
"to",
"list",
"modules",
"with",
"already",
"installed",
"submodules",
"."
] | 6c58012ff89225d7d4e42b200cf39e009e9d9dac | https://github.com/asbsoft/yii2-common_2_170212/blob/6c58012ff89225d7d4e42b200cf39e009e9d9dac/base/ModulesManager.php#L69-L78 |
8,897 | asbsoft/yii2-common_2_170212 | base/ModulesManager.php | ModulesManager.modulesNamesList | public static function modulesNamesList($module = null, $onlyActivated = true, $forModmgr = false
, $onlyUniModule = false, $onlyLoaded = false, $indent = '. ')
{
$list = [];
if (empty($module)) {
$module = Yii::$app;
}
$modmgr = static::instance();
if (method_exists ($modmgr, 'registeredModuleName')) {
$label = $modmgr::registeredModuleName($module->uniqueId);
}
if (empty($label) && $module instanceof UniModule) {
$label = $module->inform('label');
}
if (empty($label)) {
$label = Yii::t(self::$tc, 'Module') . ' ' . $module->uniqueId;
}
if ($module != Yii::$app) { // skip application itself
if (!$onlyUniModule || $module instanceof UniModule) {
$prefix = str_repeat($indent, count(explode('/', $module->uniqueId)));
$muid = $module->uniqueId;
if ($forModmgr) {
$muid = $modmgr::tonumberModuleUniqueId($muid);
}
$list[$muid] = $prefix . $label;
}
}
$staticSubmodules = $module->modules;
$dynSubmodules = $modmgr->getSubmodules($module, $onlyActivated);
$module->modules = ArrayHelper::merge($dynSubmodules, $staticSubmodules);
if (empty($module->modules)) {
return $list;
}
// add submodules list
foreach ($module->modules as $childId => $childModule) {
if (!$onlyLoaded && is_array($childModule)) {
$childModule = $module->getModule($childId);
//$childModule = Yii::$app->getModule($module->uniqueId . '/' . $childId);
}
if ($childModule instanceof YiiBaseModule) {
$list += static::modulesNamesList($childModule, $onlyActivated, $forModmgr, $onlyUniModule, $onlyLoaded, $indent);
}
}
return $list;
} | php | public static function modulesNamesList($module = null, $onlyActivated = true, $forModmgr = false
, $onlyUniModule = false, $onlyLoaded = false, $indent = '. ')
{
$list = [];
if (empty($module)) {
$module = Yii::$app;
}
$modmgr = static::instance();
if (method_exists ($modmgr, 'registeredModuleName')) {
$label = $modmgr::registeredModuleName($module->uniqueId);
}
if (empty($label) && $module instanceof UniModule) {
$label = $module->inform('label');
}
if (empty($label)) {
$label = Yii::t(self::$tc, 'Module') . ' ' . $module->uniqueId;
}
if ($module != Yii::$app) { // skip application itself
if (!$onlyUniModule || $module instanceof UniModule) {
$prefix = str_repeat($indent, count(explode('/', $module->uniqueId)));
$muid = $module->uniqueId;
if ($forModmgr) {
$muid = $modmgr::tonumberModuleUniqueId($muid);
}
$list[$muid] = $prefix . $label;
}
}
$staticSubmodules = $module->modules;
$dynSubmodules = $modmgr->getSubmodules($module, $onlyActivated);
$module->modules = ArrayHelper::merge($dynSubmodules, $staticSubmodules);
if (empty($module->modules)) {
return $list;
}
// add submodules list
foreach ($module->modules as $childId => $childModule) {
if (!$onlyLoaded && is_array($childModule)) {
$childModule = $module->getModule($childId);
//$childModule = Yii::$app->getModule($module->uniqueId . '/' . $childId);
}
if ($childModule instanceof YiiBaseModule) {
$list += static::modulesNamesList($childModule, $onlyActivated, $forModmgr, $onlyUniModule, $onlyLoaded, $indent);
}
}
return $list;
} | [
"public",
"static",
"function",
"modulesNamesList",
"(",
"$",
"module",
"=",
"null",
",",
"$",
"onlyActivated",
"=",
"true",
",",
"$",
"forModmgr",
"=",
"false",
",",
"$",
"onlyUniModule",
"=",
"false",
",",
"$",
"onlyLoaded",
"=",
"false",
",",
"$",
"indent",
"=",
"'. '",
")",
"{",
"$",
"list",
"=",
"[",
"]",
";",
"if",
"(",
"empty",
"(",
"$",
"module",
")",
")",
"{",
"$",
"module",
"=",
"Yii",
"::",
"$",
"app",
";",
"}",
"$",
"modmgr",
"=",
"static",
"::",
"instance",
"(",
")",
";",
"if",
"(",
"method_exists",
"(",
"$",
"modmgr",
",",
"'registeredModuleName'",
")",
")",
"{",
"$",
"label",
"=",
"$",
"modmgr",
"::",
"registeredModuleName",
"(",
"$",
"module",
"->",
"uniqueId",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"label",
")",
"&&",
"$",
"module",
"instanceof",
"UniModule",
")",
"{",
"$",
"label",
"=",
"$",
"module",
"->",
"inform",
"(",
"'label'",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"label",
")",
")",
"{",
"$",
"label",
"=",
"Yii",
"::",
"t",
"(",
"self",
"::",
"$",
"tc",
",",
"'Module'",
")",
".",
"' '",
".",
"$",
"module",
"->",
"uniqueId",
";",
"}",
"if",
"(",
"$",
"module",
"!=",
"Yii",
"::",
"$",
"app",
")",
"{",
"// skip application itself",
"if",
"(",
"!",
"$",
"onlyUniModule",
"||",
"$",
"module",
"instanceof",
"UniModule",
")",
"{",
"$",
"prefix",
"=",
"str_repeat",
"(",
"$",
"indent",
",",
"count",
"(",
"explode",
"(",
"'/'",
",",
"$",
"module",
"->",
"uniqueId",
")",
")",
")",
";",
"$",
"muid",
"=",
"$",
"module",
"->",
"uniqueId",
";",
"if",
"(",
"$",
"forModmgr",
")",
"{",
"$",
"muid",
"=",
"$",
"modmgr",
"::",
"tonumberModuleUniqueId",
"(",
"$",
"muid",
")",
";",
"}",
"$",
"list",
"[",
"$",
"muid",
"]",
"=",
"$",
"prefix",
".",
"$",
"label",
";",
"}",
"}",
"$",
"staticSubmodules",
"=",
"$",
"module",
"->",
"modules",
";",
"$",
"dynSubmodules",
"=",
"$",
"modmgr",
"->",
"getSubmodules",
"(",
"$",
"module",
",",
"$",
"onlyActivated",
")",
";",
"$",
"module",
"->",
"modules",
"=",
"ArrayHelper",
"::",
"merge",
"(",
"$",
"dynSubmodules",
",",
"$",
"staticSubmodules",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"module",
"->",
"modules",
")",
")",
"{",
"return",
"$",
"list",
";",
"}",
"// add submodules list",
"foreach",
"(",
"$",
"module",
"->",
"modules",
"as",
"$",
"childId",
"=>",
"$",
"childModule",
")",
"{",
"if",
"(",
"!",
"$",
"onlyLoaded",
"&&",
"is_array",
"(",
"$",
"childModule",
")",
")",
"{",
"$",
"childModule",
"=",
"$",
"module",
"->",
"getModule",
"(",
"$",
"childId",
")",
";",
"//$childModule = Yii::$app->getModule($module->uniqueId . '/' . $childId);",
"}",
"if",
"(",
"$",
"childModule",
"instanceof",
"YiiBaseModule",
")",
"{",
"$",
"list",
"+=",
"static",
"::",
"modulesNamesList",
"(",
"$",
"childModule",
",",
"$",
"onlyActivated",
",",
"$",
"forModmgr",
",",
"$",
"onlyUniModule",
",",
"$",
"onlyLoaded",
",",
"$",
"indent",
")",
";",
"}",
"}",
"return",
"$",
"list",
";",
"}"
] | Get modules list in format uniqueId => label.
Use for modules dropdown list.
@param yii\base\Module|empty $module "parent"(container) module
@param boolean $onlyActivated if true show only activated in Modules manager
@param boolean $forModmgr if true not expand to string moduleId-number from Modules manager
@param boolean $onlyUniModule if false show only UniModule modules
@param boolean $onlyLoaded if false show only loaded modules
@param string $indent
@return array of module's uniqueId => module's label | [
"Get",
"modules",
"list",
"in",
"format",
"uniqueId",
"=",
">",
"label",
".",
"Use",
"for",
"modules",
"dropdown",
"list",
"."
] | 6c58012ff89225d7d4e42b200cf39e009e9d9dac | https://github.com/asbsoft/yii2-common_2_170212/blob/6c58012ff89225d7d4e42b200cf39e009e9d9dac/base/ModulesManager.php#L138-L187 |
8,898 | asbsoft/yii2-common_2_170212 | base/ModulesManager.php | ModulesManager.initSubmodules | public static function initSubmodules($module)
{
$submodules = ArrayHelper::merge($module->modules, static::submodules($module));
foreach ($submodules as $submoduleId => $submodule) {
if (is_array($submodule)) $submodule = $module->getModule($submoduleId);
if (empty($submodule)) continue;
static::initSubmodules($submodule);
}
} | php | public static function initSubmodules($module)
{
$submodules = ArrayHelper::merge($module->modules, static::submodules($module));
foreach ($submodules as $submoduleId => $submodule) {
if (is_array($submodule)) $submodule = $module->getModule($submoduleId);
if (empty($submodule)) continue;
static::initSubmodules($submodule);
}
} | [
"public",
"static",
"function",
"initSubmodules",
"(",
"$",
"module",
")",
"{",
"$",
"submodules",
"=",
"ArrayHelper",
"::",
"merge",
"(",
"$",
"module",
"->",
"modules",
",",
"static",
"::",
"submodules",
"(",
"$",
"module",
")",
")",
";",
"foreach",
"(",
"$",
"submodules",
"as",
"$",
"submoduleId",
"=>",
"$",
"submodule",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"submodule",
")",
")",
"$",
"submodule",
"=",
"$",
"module",
"->",
"getModule",
"(",
"$",
"submoduleId",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"submodule",
")",
")",
"continue",
";",
"static",
"::",
"initSubmodules",
"(",
"$",
"submodule",
")",
";",
"}",
"}"
] | Recursively init all submodules of module.
@param \yii\base\Module $module | [
"Recursively",
"init",
"all",
"submodules",
"of",
"module",
"."
] | 6c58012ff89225d7d4e42b200cf39e009e9d9dac | https://github.com/asbsoft/yii2-common_2_170212/blob/6c58012ff89225d7d4e42b200cf39e009e9d9dac/base/ModulesManager.php#L263-L271 |
8,899 | Solve/Solve | SolveConsole/Controllers/GenController.php | GenController.modelAction | public function modelAction() {
$name = ucfirst(Inflector::camelize($this->getFirstParamOrAsk('Enter model name')));
$path = DC::getEnvironment()->getUserClassesRoot() . 'db/';
$mo = ModelOperator::getInstance($path);
if ($mo->getModelStructure($name)) {
$this->warning('model ' . $name . ' is already exists', '~ model exists, skipping:');
return true;
}
$mo->generateBasicStructure($name);
$mo->saveModelStructure($name);
$this->notify($path . 'structure/' . $name . '.yml', '+ model created');
} | php | public function modelAction() {
$name = ucfirst(Inflector::camelize($this->getFirstParamOrAsk('Enter model name')));
$path = DC::getEnvironment()->getUserClassesRoot() . 'db/';
$mo = ModelOperator::getInstance($path);
if ($mo->getModelStructure($name)) {
$this->warning('model ' . $name . ' is already exists', '~ model exists, skipping:');
return true;
}
$mo->generateBasicStructure($name);
$mo->saveModelStructure($name);
$this->notify($path . 'structure/' . $name . '.yml', '+ model created');
} | [
"public",
"function",
"modelAction",
"(",
")",
"{",
"$",
"name",
"=",
"ucfirst",
"(",
"Inflector",
"::",
"camelize",
"(",
"$",
"this",
"->",
"getFirstParamOrAsk",
"(",
"'Enter model name'",
")",
")",
")",
";",
"$",
"path",
"=",
"DC",
"::",
"getEnvironment",
"(",
")",
"->",
"getUserClassesRoot",
"(",
")",
".",
"'db/'",
";",
"$",
"mo",
"=",
"ModelOperator",
"::",
"getInstance",
"(",
"$",
"path",
")",
";",
"if",
"(",
"$",
"mo",
"->",
"getModelStructure",
"(",
"$",
"name",
")",
")",
"{",
"$",
"this",
"->",
"warning",
"(",
"'model '",
".",
"$",
"name",
".",
"' is already exists'",
",",
"'~ model exists, skipping:'",
")",
";",
"return",
"true",
";",
"}",
"$",
"mo",
"->",
"generateBasicStructure",
"(",
"$",
"name",
")",
";",
"$",
"mo",
"->",
"saveModelStructure",
"(",
"$",
"name",
")",
";",
"$",
"this",
"->",
"notify",
"(",
"$",
"path",
".",
"'structure/'",
".",
"$",
"name",
".",
"'.yml'",
",",
"'+ model created'",
")",
";",
"}"
] | Generates default database model structure | [
"Generates",
"default",
"database",
"model",
"structure"
] | b2ac834c37831ba6049dafa28255d32b4ea0bf1d | https://github.com/Solve/Solve/blob/b2ac834c37831ba6049dafa28255d32b4ea0bf1d/SolveConsole/Controllers/GenController.php#L34-L45 |
Subsets and Splits