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
| partition
stringclasses 1
value |
---|---|---|---|---|---|---|---|---|---|---|---|
miaoxing/plugin | src/Service/V.php | V.addRule | public function addRule($name, $args)
{
$this->options['rules'][$this->lastKey][$name] = $args;
$this->lastRule = $name;
return $this;
} | php | public function addRule($name, $args)
{
$this->options['rules'][$this->lastKey][$name] = $args;
$this->lastRule = $name;
return $this;
} | [
"public",
"function",
"addRule",
"(",
"$",
"name",
",",
"$",
"args",
")",
"{",
"$",
"this",
"->",
"options",
"[",
"'rules'",
"]",
"[",
"$",
"this",
"->",
"lastKey",
"]",
"[",
"$",
"name",
"]",
"=",
"$",
"args",
";",
"$",
"this",
"->",
"lastRule",
"=",
"$",
"name",
";",
"return",
"$",
"this",
";",
"}"
] | Add rule for current field
@param string $name
@param mixed $args
@return $this | [
"Add",
"rule",
"for",
"current",
"field"
] | f287a1e6c97abba6f06906255b8c26e8ab0afe61 | https://github.com/miaoxing/plugin/blob/f287a1e6c97abba6f06906255b8c26e8ab0afe61/src/Service/V.php#L364-L370 | train |
danielgp/common-lib | source/MySQLiByDanielGPqueries.php | MySQLiByDanielGPqueries.getForeignKeysQuery | protected function getForeignKeysQuery($value)
{
$flt = [
'TABLE_SCHEMA' => $value['REFERENCED_TABLE_SCHEMA'],
'TABLE_NAME' => $value['REFERENCED_TABLE_NAME'],
'DATA_TYPE' => ['char', 'varchar', 'text'],
];
if (array_key_exists('LIMIT', $value)) {
$flt['LIMIT'] = $value['LIMIT'];
}
return $this->sQueryMySqlColumns($flt);
} | php | protected function getForeignKeysQuery($value)
{
$flt = [
'TABLE_SCHEMA' => $value['REFERENCED_TABLE_SCHEMA'],
'TABLE_NAME' => $value['REFERENCED_TABLE_NAME'],
'DATA_TYPE' => ['char', 'varchar', 'text'],
];
if (array_key_exists('LIMIT', $value)) {
$flt['LIMIT'] = $value['LIMIT'];
}
return $this->sQueryMySqlColumns($flt);
} | [
"protected",
"function",
"getForeignKeysQuery",
"(",
"$",
"value",
")",
"{",
"$",
"flt",
"=",
"[",
"'TABLE_SCHEMA'",
"=>",
"$",
"value",
"[",
"'REFERENCED_TABLE_SCHEMA'",
"]",
",",
"'TABLE_NAME'",
"=>",
"$",
"value",
"[",
"'REFERENCED_TABLE_NAME'",
"]",
",",
"'DATA_TYPE'",
"=>",
"[",
"'char'",
",",
"'varchar'",
",",
"'text'",
"]",
",",
"]",
";",
"if",
"(",
"array_key_exists",
"(",
"'LIMIT'",
",",
"$",
"value",
")",
")",
"{",
"$",
"flt",
"[",
"'LIMIT'",
"]",
"=",
"$",
"value",
"[",
"'LIMIT'",
"]",
";",
"}",
"return",
"$",
"this",
"->",
"sQueryMySqlColumns",
"(",
"$",
"flt",
")",
";",
"}"
] | prepares the query to detect FKs
@param array $value
@return string | [
"prepares",
"the",
"query",
"to",
"detect",
"FKs"
] | 627b99b4408414c7cd21a6c8016f6468dc9216b2 | https://github.com/danielgp/common-lib/blob/627b99b4408414c7cd21a6c8016f6468dc9216b2/source/MySQLiByDanielGPqueries.php#L62-L73 | train |
danielgp/common-lib | source/MySQLiByDanielGPqueries.php | MySQLiByDanielGPqueries.sManageDynamicFilters | private function sManageDynamicFilters($filterArray = null, $tableToApplyFilterTo = '')
{
if (is_null($filterArray)) {
return '';
}
$fltr = [];
unset($filterArray['LIMIT']);
foreach ($filterArray as $key => $value) {
$fltr[] = '`' . $tableToApplyFilterTo . '`.`' . $key . '` ' . $this->sGlueFilterValIntoWhereStr($value);
}
return $this->sManageDynamicFiltersFinal($fltr);
} | php | private function sManageDynamicFilters($filterArray = null, $tableToApplyFilterTo = '')
{
if (is_null($filterArray)) {
return '';
}
$fltr = [];
unset($filterArray['LIMIT']);
foreach ($filterArray as $key => $value) {
$fltr[] = '`' . $tableToApplyFilterTo . '`.`' . $key . '` ' . $this->sGlueFilterValIntoWhereStr($value);
}
return $this->sManageDynamicFiltersFinal($fltr);
} | [
"private",
"function",
"sManageDynamicFilters",
"(",
"$",
"filterArray",
"=",
"null",
",",
"$",
"tableToApplyFilterTo",
"=",
"''",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"filterArray",
")",
")",
"{",
"return",
"''",
";",
"}",
"$",
"fltr",
"=",
"[",
"]",
";",
"unset",
"(",
"$",
"filterArray",
"[",
"'LIMIT'",
"]",
")",
";",
"foreach",
"(",
"$",
"filterArray",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"fltr",
"[",
"]",
"=",
"'`'",
".",
"$",
"tableToApplyFilterTo",
".",
"'`.`'",
".",
"$",
"key",
".",
"'` '",
".",
"$",
"this",
"->",
"sGlueFilterValIntoWhereStr",
"(",
"$",
"value",
")",
";",
"}",
"return",
"$",
"this",
"->",
"sManageDynamicFiltersFinal",
"(",
"$",
"fltr",
")",
";",
"}"
] | Internal function to manage the filters passed to the query
@param null|array $filterArray
@param string $tableToApplyFilterTo
@return string | [
"Internal",
"function",
"to",
"manage",
"the",
"filters",
"passed",
"to",
"the",
"query"
] | 627b99b4408414c7cd21a6c8016f6468dc9216b2 | https://github.com/danielgp/common-lib/blob/627b99b4408414c7cd21a6c8016f6468dc9216b2/source/MySQLiByDanielGPqueries.php#L124-L135 | train |
danielgp/common-lib | source/MySQLiByDanielGPqueries.php | MySQLiByDanielGPqueries.setArrayLineArrayToFilter | private function setArrayLineArrayToFilter($key, $value, $referenceTable)
{
$filters2 = implode(', ', array_diff($value, ['']));
if ($filters2 != '') {
return '(' . $referenceTable . '`' . $key . '` IN ("'
. str_replace(',', '","', str_replace(["'", '"'], '', $filters2)) . '"))';
}
return '';
} | php | private function setArrayLineArrayToFilter($key, $value, $referenceTable)
{
$filters2 = implode(', ', array_diff($value, ['']));
if ($filters2 != '') {
return '(' . $referenceTable . '`' . $key . '` IN ("'
. str_replace(',', '","', str_replace(["'", '"'], '', $filters2)) . '"))';
}
return '';
} | [
"private",
"function",
"setArrayLineArrayToFilter",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"referenceTable",
")",
"{",
"$",
"filters2",
"=",
"implode",
"(",
"', '",
",",
"array_diff",
"(",
"$",
"value",
",",
"[",
"''",
"]",
")",
")",
";",
"if",
"(",
"$",
"filters2",
"!=",
"''",
")",
"{",
"return",
"'('",
".",
"$",
"referenceTable",
".",
"'`'",
".",
"$",
"key",
".",
"'` IN (\"'",
".",
"str_replace",
"(",
"','",
",",
"'\",\"'",
",",
"str_replace",
"(",
"[",
"\"'\"",
",",
"'\"'",
"]",
",",
"''",
",",
"$",
"filters2",
")",
")",
".",
"'\"))'",
";",
"}",
"return",
"''",
";",
"}"
] | Builds an filter string from pair of key and value, where value is array
@param string $key
@param array $value
@param string $referenceTable
@return string | [
"Builds",
"an",
"filter",
"string",
"from",
"pair",
"of",
"key",
"and",
"value",
"where",
"value",
"is",
"array"
] | 627b99b4408414c7cd21a6c8016f6468dc9216b2 | https://github.com/danielgp/common-lib/blob/627b99b4408414c7cd21a6c8016f6468dc9216b2/source/MySQLiByDanielGPqueries.php#L272-L280 | train |
danielgp/common-lib | source/MySQLiByDanielGPqueries.php | MySQLiByDanielGPqueries.setArrayLineToFilter | private function setArrayLineToFilter($key, $value)
{
$fTemp = '=';
if ((substr($value, 0, 1) == '%') && (substr($value, -1) == '%')) {
$fTemp = 'LIKE';
}
return '(`' . $key . '` ' . $fTemp . '"' . $value . '")';
} | php | private function setArrayLineToFilter($key, $value)
{
$fTemp = '=';
if ((substr($value, 0, 1) == '%') && (substr($value, -1) == '%')) {
$fTemp = 'LIKE';
}
return '(`' . $key . '` ' . $fTemp . '"' . $value . '")';
} | [
"private",
"function",
"setArrayLineToFilter",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"$",
"fTemp",
"=",
"'='",
";",
"if",
"(",
"(",
"substr",
"(",
"$",
"value",
",",
"0",
",",
"1",
")",
"==",
"'%'",
")",
"&&",
"(",
"substr",
"(",
"$",
"value",
",",
"-",
"1",
")",
"==",
"'%'",
")",
")",
"{",
"$",
"fTemp",
"=",
"'LIKE'",
";",
"}",
"return",
"'(`'",
".",
"$",
"key",
".",
"'` '",
".",
"$",
"fTemp",
".",
"'\"'",
".",
"$",
"value",
".",
"'\")'",
";",
"}"
] | Builds an filter string from pair of key and value, none array
@param string $key
@param int|float|string $value
@return string | [
"Builds",
"an",
"filter",
"string",
"from",
"pair",
"of",
"key",
"and",
"value",
"none",
"array"
] | 627b99b4408414c7cd21a6c8016f6468dc9216b2 | https://github.com/danielgp/common-lib/blob/627b99b4408414c7cd21a6c8016f6468dc9216b2/source/MySQLiByDanielGPqueries.php#L289-L296 | train |
anime-db/catalog-bundle | src/Controller/PluginController.php | PluginController.installedAction | public function installedAction(Request $request)
{
$response = $this->getCacheTimeKeeper()->getResponse('AnimeDbAppBundle:Plugin');
// response was not modified for this request
if ($response->isNotModified($request)) {
return $response;
}
/* @var $rep EntityRepository */
$rep = $this->getDoctrine()->getRepository('AnimeDbAppBundle:Plugin');
return $this->render('AnimeDbCatalogBundle:Plugin:installed.html.twig', [
'plugins' => $rep->findAll(),
], $response);
} | php | public function installedAction(Request $request)
{
$response = $this->getCacheTimeKeeper()->getResponse('AnimeDbAppBundle:Plugin');
// response was not modified for this request
if ($response->isNotModified($request)) {
return $response;
}
/* @var $rep EntityRepository */
$rep = $this->getDoctrine()->getRepository('AnimeDbAppBundle:Plugin');
return $this->render('AnimeDbCatalogBundle:Plugin:installed.html.twig', [
'plugins' => $rep->findAll(),
], $response);
} | [
"public",
"function",
"installedAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"getCacheTimeKeeper",
"(",
")",
"->",
"getResponse",
"(",
"'AnimeDbAppBundle:Plugin'",
")",
";",
"// response was not modified for this request",
"if",
"(",
"$",
"response",
"->",
"isNotModified",
"(",
"$",
"request",
")",
")",
"{",
"return",
"$",
"response",
";",
"}",
"/* @var $rep EntityRepository */",
"$",
"rep",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getRepository",
"(",
"'AnimeDbAppBundle:Plugin'",
")",
";",
"return",
"$",
"this",
"->",
"render",
"(",
"'AnimeDbCatalogBundle:Plugin:installed.html.twig'",
",",
"[",
"'plugins'",
"=>",
"$",
"rep",
"->",
"findAll",
"(",
")",
",",
"]",
",",
"$",
"response",
")",
";",
"}"
] | Installed plugins.
@param Request $request
@return Response | [
"Installed",
"plugins",
"."
] | 631b6f92a654e91bee84f46218c52cf42bdb8606 | https://github.com/anime-db/catalog-bundle/blob/631b6f92a654e91bee84f46218c52cf42bdb8606/src/Controller/PluginController.php#L38-L52 | train |
anime-db/catalog-bundle | src/Controller/PluginController.php | PluginController.storeAction | public function storeAction(Request $request)
{
$response = $this->getCacheTimeKeeper()->getResponse([], self::CACHE_LIFETIME);
// response was not modified for this request
if ($response->isNotModified($request)) {
return $response;
}
$plugins = [];
$data = $this->get('anime_db.api.client')->getPlugins();
foreach ($data['plugins'] as $plugin) {
$plugins[$plugin['name']] = $plugin;
$plugins[$plugin['name']]['installed'] = false;
}
/* @var $rep EntityRepository */
$rep = $this->getDoctrine()->getRepository('AnimeDbAppBundle:Plugin');
/* @var $plugin Plugin */
foreach ($rep->findAll() as $plugin) {
$plugins[$plugin->getName()]['installed'] = true;
}
return $this->render('AnimeDbCatalogBundle:Plugin:store.html.twig', [
'plugins' => $plugins,
], $response);
} | php | public function storeAction(Request $request)
{
$response = $this->getCacheTimeKeeper()->getResponse([], self::CACHE_LIFETIME);
// response was not modified for this request
if ($response->isNotModified($request)) {
return $response;
}
$plugins = [];
$data = $this->get('anime_db.api.client')->getPlugins();
foreach ($data['plugins'] as $plugin) {
$plugins[$plugin['name']] = $plugin;
$plugins[$plugin['name']]['installed'] = false;
}
/* @var $rep EntityRepository */
$rep = $this->getDoctrine()->getRepository('AnimeDbAppBundle:Plugin');
/* @var $plugin Plugin */
foreach ($rep->findAll() as $plugin) {
$plugins[$plugin->getName()]['installed'] = true;
}
return $this->render('AnimeDbCatalogBundle:Plugin:store.html.twig', [
'plugins' => $plugins,
], $response);
} | [
"public",
"function",
"storeAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"getCacheTimeKeeper",
"(",
")",
"->",
"getResponse",
"(",
"[",
"]",
",",
"self",
"::",
"CACHE_LIFETIME",
")",
";",
"// response was not modified for this request",
"if",
"(",
"$",
"response",
"->",
"isNotModified",
"(",
"$",
"request",
")",
")",
"{",
"return",
"$",
"response",
";",
"}",
"$",
"plugins",
"=",
"[",
"]",
";",
"$",
"data",
"=",
"$",
"this",
"->",
"get",
"(",
"'anime_db.api.client'",
")",
"->",
"getPlugins",
"(",
")",
";",
"foreach",
"(",
"$",
"data",
"[",
"'plugins'",
"]",
"as",
"$",
"plugin",
")",
"{",
"$",
"plugins",
"[",
"$",
"plugin",
"[",
"'name'",
"]",
"]",
"=",
"$",
"plugin",
";",
"$",
"plugins",
"[",
"$",
"plugin",
"[",
"'name'",
"]",
"]",
"[",
"'installed'",
"]",
"=",
"false",
";",
"}",
"/* @var $rep EntityRepository */",
"$",
"rep",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getRepository",
"(",
"'AnimeDbAppBundle:Plugin'",
")",
";",
"/* @var $plugin Plugin */",
"foreach",
"(",
"$",
"rep",
"->",
"findAll",
"(",
")",
"as",
"$",
"plugin",
")",
"{",
"$",
"plugins",
"[",
"$",
"plugin",
"->",
"getName",
"(",
")",
"]",
"[",
"'installed'",
"]",
"=",
"true",
";",
"}",
"return",
"$",
"this",
"->",
"render",
"(",
"'AnimeDbCatalogBundle:Plugin:store.html.twig'",
",",
"[",
"'plugins'",
"=>",
"$",
"plugins",
",",
"]",
",",
"$",
"response",
")",
";",
"}"
] | Store of plugins.
@param Request $request
@return Response | [
"Store",
"of",
"plugins",
"."
] | 631b6f92a654e91bee84f46218c52cf42bdb8606 | https://github.com/anime-db/catalog-bundle/blob/631b6f92a654e91bee84f46218c52cf42bdb8606/src/Controller/PluginController.php#L61-L86 | train |
koolkode/context | src/Locator/BindingServiceLocator.php | BindingServiceLocator.getIterator | public function getIterator()
{
if($this->shared)
{
foreach($this->bindings as $key => $binding)
{
if(empty($this->bound[$key]))
{
$this->bound[$key] = $this->container->getBound($binding);
}
}
return new \ArrayIterator($this->bound);
}
$bound = [];
foreach($this->bindings as $key => $binding)
{
$bound[$key] = $this->container->getBound($binding);
}
return new \ArrayIterator($bound);
} | php | public function getIterator()
{
if($this->shared)
{
foreach($this->bindings as $key => $binding)
{
if(empty($this->bound[$key]))
{
$this->bound[$key] = $this->container->getBound($binding);
}
}
return new \ArrayIterator($this->bound);
}
$bound = [];
foreach($this->bindings as $key => $binding)
{
$bound[$key] = $this->container->getBound($binding);
}
return new \ArrayIterator($bound);
} | [
"public",
"function",
"getIterator",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"shared",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"bindings",
"as",
"$",
"key",
"=>",
"$",
"binding",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"bound",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"this",
"->",
"bound",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"container",
"->",
"getBound",
"(",
"$",
"binding",
")",
";",
"}",
"}",
"return",
"new",
"\\",
"ArrayIterator",
"(",
"$",
"this",
"->",
"bound",
")",
";",
"}",
"$",
"bound",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"bindings",
"as",
"$",
"key",
"=>",
"$",
"binding",
")",
"{",
"$",
"bound",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"container",
"->",
"getBound",
"(",
"$",
"binding",
")",
";",
"}",
"return",
"new",
"\\",
"ArrayIterator",
"(",
"$",
"bound",
")",
";",
"}"
] | Provides an iterator on top of all registered services, obtaining the iterator triggers
loading of ALL registered services from the DI container.
@return \ArrayIterator<string, object> | [
"Provides",
"an",
"iterator",
"on",
"top",
"of",
"all",
"registered",
"services",
"obtaining",
"the",
"iterator",
"triggers",
"loading",
"of",
"ALL",
"registered",
"services",
"from",
"the",
"DI",
"container",
"."
] | f4aa614eb4ca1080bd89c7a2a54c9467c5b17a36 | https://github.com/koolkode/context/blob/f4aa614eb4ca1080bd89c7a2a54c9467c5b17a36/src/Locator/BindingServiceLocator.php#L87-L110 | train |
koolkode/context | src/Locator/BindingServiceLocator.php | BindingServiceLocator.registerService | public function registerService(BindingInterface $binding, $name = NULL)
{
$key = ($name === NULL) ? $binding->getTypeName() : (string)$name;
if(isset($this->bindings[$key]))
{
throw new DuplicateServiceRegistrationException(sprintf('Service "%s" is already registered', $key));
}
$this->bindings[$key] = $binding;
} | php | public function registerService(BindingInterface $binding, $name = NULL)
{
$key = ($name === NULL) ? $binding->getTypeName() : (string)$name;
if(isset($this->bindings[$key]))
{
throw new DuplicateServiceRegistrationException(sprintf('Service "%s" is already registered', $key));
}
$this->bindings[$key] = $binding;
} | [
"public",
"function",
"registerService",
"(",
"BindingInterface",
"$",
"binding",
",",
"$",
"name",
"=",
"NULL",
")",
"{",
"$",
"key",
"=",
"(",
"$",
"name",
"===",
"NULL",
")",
"?",
"$",
"binding",
"->",
"getTypeName",
"(",
")",
":",
"(",
"string",
")",
"$",
"name",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"bindings",
"[",
"$",
"key",
"]",
")",
")",
"{",
"throw",
"new",
"DuplicateServiceRegistrationException",
"(",
"sprintf",
"(",
"'Service \"%s\" is already registered'",
",",
"$",
"key",
")",
")",
";",
"}",
"$",
"this",
"->",
"bindings",
"[",
"$",
"key",
"]",
"=",
"$",
"binding",
";",
"}"
] | Register a binding in the locator, will use the name of the bound type when no
name for the service is given.
@param BindingInterface $binding The binding being used to load the service.
@param string $name Optional name of the registered service.
@throws DuplicateServiceRegistrationException | [
"Register",
"a",
"binding",
"in",
"the",
"locator",
"will",
"use",
"the",
"name",
"of",
"the",
"bound",
"type",
"when",
"no",
"name",
"for",
"the",
"service",
"is",
"given",
"."
] | f4aa614eb4ca1080bd89c7a2a54c9467c5b17a36 | https://github.com/koolkode/context/blob/f4aa614eb4ca1080bd89c7a2a54c9467c5b17a36/src/Locator/BindingServiceLocator.php#L149-L159 | train |
hamjoint/mustard-media | src/lib/Http/Controllers/MediaController.php | MediaController.getPhoto | public function getPhoto($photoId, $size = 'large')
{
$photo = Photo::findOrFail($photoId);
switch ($size) {
case 'large':
return response()->download(storage_path().'/app/'.$photo->pathLarge);
case 'small':
return response()->download(storage_path().'/app/'.$photo->pathSmall);
}
abort(404);
} | php | public function getPhoto($photoId, $size = 'large')
{
$photo = Photo::findOrFail($photoId);
switch ($size) {
case 'large':
return response()->download(storage_path().'/app/'.$photo->pathLarge);
case 'small':
return response()->download(storage_path().'/app/'.$photo->pathSmall);
}
abort(404);
} | [
"public",
"function",
"getPhoto",
"(",
"$",
"photoId",
",",
"$",
"size",
"=",
"'large'",
")",
"{",
"$",
"photo",
"=",
"Photo",
"::",
"findOrFail",
"(",
"$",
"photoId",
")",
";",
"switch",
"(",
"$",
"size",
")",
"{",
"case",
"'large'",
":",
"return",
"response",
"(",
")",
"->",
"download",
"(",
"storage_path",
"(",
")",
".",
"'/app/'",
".",
"$",
"photo",
"->",
"pathLarge",
")",
";",
"case",
"'small'",
":",
"return",
"response",
"(",
")",
"->",
"download",
"(",
"storage_path",
"(",
")",
".",
"'/app/'",
".",
"$",
"photo",
"->",
"pathSmall",
")",
";",
"}",
"abort",
"(",
"404",
")",
";",
"}"
] | Return a photo as a response.
@param int $photoId
@param string $size
@return \Illuminate\Http\Response | [
"Return",
"a",
"photo",
"as",
"a",
"response",
"."
] | d3c799dbc3578e1e1022bb4eccae7a20e285ba06 | https://github.com/hamjoint/mustard-media/blob/d3c799dbc3578e1e1022bb4eccae7a20e285ba06/src/lib/Http/Controllers/MediaController.php#L38-L50 | train |
Horat1us/array-js-prototype | src/Collection.php | Collection.getLength | public function getLength()
{
if (!$this->container) {
return 0;
}
$count = count($this->container);
$keys = array_keys($this->container);
return (array_keys($this->container) === range(0, $count - 1))
? $count
: max($keys);
} | php | public function getLength()
{
if (!$this->container) {
return 0;
}
$count = count($this->container);
$keys = array_keys($this->container);
return (array_keys($this->container) === range(0, $count - 1))
? $count
: max($keys);
} | [
"public",
"function",
"getLength",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"container",
")",
"{",
"return",
"0",
";",
"}",
"$",
"count",
"=",
"count",
"(",
"$",
"this",
"->",
"container",
")",
";",
"$",
"keys",
"=",
"array_keys",
"(",
"$",
"this",
"->",
"container",
")",
";",
"return",
"(",
"array_keys",
"(",
"$",
"this",
"->",
"container",
")",
"===",
"range",
"(",
"0",
",",
"$",
"count",
"-",
"1",
")",
")",
"?",
"$",
"count",
":",
"max",
"(",
"$",
"keys",
")",
";",
"}"
] | Copying JS-like .length behavior
@return integer|string | [
"Copying",
"JS",
"-",
"like",
".",
"length",
"behavior"
] | 2dd6843eb221f81c2488237f164fdd392e98147a | https://github.com/Horat1us/array-js-prototype/blob/2dd6843eb221f81c2488237f164fdd392e98147a/src/Collection.php#L80-L91 | train |
oyepez003/YepsuaRADBundle | Controller/CRUDController.php | CRUDController.crudShow | public function crudShow(Request $request, $id)
{
try{
$entity = $this->throwEntityNotFoundException($this->getRepository()->find($id));
$form = $this->createDeleteForm($id)->createView();
return $this->commonsResponseVars(compact('entity','form'));
}catch(\Exception $e){
return $this->failure($e);
}
} | php | public function crudShow(Request $request, $id)
{
try{
$entity = $this->throwEntityNotFoundException($this->getRepository()->find($id));
$form = $this->createDeleteForm($id)->createView();
return $this->commonsResponseVars(compact('entity','form'));
}catch(\Exception $e){
return $this->failure($e);
}
} | [
"public",
"function",
"crudShow",
"(",
"Request",
"$",
"request",
",",
"$",
"id",
")",
"{",
"try",
"{",
"$",
"entity",
"=",
"$",
"this",
"->",
"throwEntityNotFoundException",
"(",
"$",
"this",
"->",
"getRepository",
"(",
")",
"->",
"find",
"(",
"$",
"id",
")",
")",
";",
"$",
"form",
"=",
"$",
"this",
"->",
"createDeleteForm",
"(",
"$",
"id",
")",
"->",
"createView",
"(",
")",
";",
"return",
"$",
"this",
"->",
"commonsResponseVars",
"(",
"compact",
"(",
"'entity'",
",",
"'form'",
")",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"return",
"$",
"this",
"->",
"failure",
"(",
"$",
"e",
")",
";",
"}",
"}"
] | Finds and displays an entity.
@param \Symfony\Component\HttpFoundation\Request $request
@param type $id
@return type | [
"Finds",
"and",
"displays",
"an",
"entity",
"."
] | 5e8c79f49201d5b2ba9487f16624a3f245941672 | https://github.com/oyepez003/YepsuaRADBundle/blob/5e8c79f49201d5b2ba9487f16624a3f245941672/Controller/CRUDController.php#L113-L124 | train |
oyepez003/YepsuaRADBundle | Controller/CRUDController.php | CRUDController.crudUpdate | public function crudUpdate(Request $request, $id)
{
try{
$entity = $this->throwEntityNotFoundException($this->getRepository()->find($id));
$form = $this->createForm($this->getEntityType(), $entity);
$form->submit($request);
$page = static::EDIT_VIEW;
if ($form->isValid()) {
$page = static::SHOW_VIEW;
$this->saveEntity($entity);
$form = $this->createDeleteForm($id)->createView();
return $this->render($page, $this->commonsResponseVars(compact('entity','form')));
}
$form = $form->createView();
$delete_form = $this->createDeleteForm($id)->createView();
return $this->success($page, $this->commonsResponseVars(compact('entity','form','delete_form')));
}catch(\Exception $e){
return $this->failure($e);
}
} | php | public function crudUpdate(Request $request, $id)
{
try{
$entity = $this->throwEntityNotFoundException($this->getRepository()->find($id));
$form = $this->createForm($this->getEntityType(), $entity);
$form->submit($request);
$page = static::EDIT_VIEW;
if ($form->isValid()) {
$page = static::SHOW_VIEW;
$this->saveEntity($entity);
$form = $this->createDeleteForm($id)->createView();
return $this->render($page, $this->commonsResponseVars(compact('entity','form')));
}
$form = $form->createView();
$delete_form = $this->createDeleteForm($id)->createView();
return $this->success($page, $this->commonsResponseVars(compact('entity','form','delete_form')));
}catch(\Exception $e){
return $this->failure($e);
}
} | [
"public",
"function",
"crudUpdate",
"(",
"Request",
"$",
"request",
",",
"$",
"id",
")",
"{",
"try",
"{",
"$",
"entity",
"=",
"$",
"this",
"->",
"throwEntityNotFoundException",
"(",
"$",
"this",
"->",
"getRepository",
"(",
")",
"->",
"find",
"(",
"$",
"id",
")",
")",
";",
"$",
"form",
"=",
"$",
"this",
"->",
"createForm",
"(",
"$",
"this",
"->",
"getEntityType",
"(",
")",
",",
"$",
"entity",
")",
";",
"$",
"form",
"->",
"submit",
"(",
"$",
"request",
")",
";",
"$",
"page",
"=",
"static",
"::",
"EDIT_VIEW",
";",
"if",
"(",
"$",
"form",
"->",
"isValid",
"(",
")",
")",
"{",
"$",
"page",
"=",
"static",
"::",
"SHOW_VIEW",
";",
"$",
"this",
"->",
"saveEntity",
"(",
"$",
"entity",
")",
";",
"$",
"form",
"=",
"$",
"this",
"->",
"createDeleteForm",
"(",
"$",
"id",
")",
"->",
"createView",
"(",
")",
";",
"return",
"$",
"this",
"->",
"render",
"(",
"$",
"page",
",",
"$",
"this",
"->",
"commonsResponseVars",
"(",
"compact",
"(",
"'entity'",
",",
"'form'",
")",
")",
")",
";",
"}",
"$",
"form",
"=",
"$",
"form",
"->",
"createView",
"(",
")",
";",
"$",
"delete_form",
"=",
"$",
"this",
"->",
"createDeleteForm",
"(",
"$",
"id",
")",
"->",
"createView",
"(",
")",
";",
"return",
"$",
"this",
"->",
"success",
"(",
"$",
"page",
",",
"$",
"this",
"->",
"commonsResponseVars",
"(",
"compact",
"(",
"'entity'",
",",
"'form'",
",",
"'delete_form'",
")",
")",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"return",
"$",
"this",
"->",
"failure",
"(",
"$",
"e",
")",
";",
"}",
"}"
] | Edits an existing entity.
@param \Symfony\Component\HttpFoundation\Request $request
@param type $id
@return type | [
"Edits",
"an",
"existing",
"entity",
"."
] | 5e8c79f49201d5b2ba9487f16624a3f245941672 | https://github.com/oyepez003/YepsuaRADBundle/blob/5e8c79f49201d5b2ba9487f16624a3f245941672/Controller/CRUDController.php#L154-L178 | train |
libreworks/caridea-dao | src/Exception/Translator/MongoDb.php | MongoDb.translate | public static function translate(\Exception $e): \Exception
{
if ($e instanceof \MongoDB\Driver\Exception\ConnectionException ||
$e instanceof \MongoDB\Driver\Exception\ExecutionTimeoutException) {
return new \Caridea\Dao\Exception\Unreachable("System unreachable or connection timed out", $e->getCode(), $e);
} elseif ($e instanceof \MongoDB\Driver\Exception\InvalidArgumentException ||
$e instanceof \MongoDB\Driver\Exception\LogicException ||
$e instanceof \MongoDB\Exception\BadMethodCallException) {
return new \Caridea\Dao\Exception\Inoperable("Invalid API usage", $e->getCode(), $e);
} elseif ($e instanceof \MongoDB\GridFS\Exception\FileNotFoundException ||
$e instanceof \MongoDB\GridFS\Exception\CorruptFileException) {
return new \Caridea\Dao\Exception\Unretrievable("Data could not be retrieved", $e->getCode(), $e);
} elseif ($e instanceof \MongoDB\Driver\Exception\RuntimeException &&
($e->getCode() == 11000 || 'E11000' == substr($e->getMessage(), 0, 6))) {
return new \Caridea\Dao\Exception\Duplicative("Unique constraint violation", 409, $e);
} elseif ($e instanceof \MongoDB\Driver\Exception\BulkWriteException &&
$e->getMessage() == 'Document failed validation') {
return new \Caridea\Dao\Exception\Violating("Constraint violation", 422, $e);
}
return new \Caridea\Dao\Exception\Generic("Uncategorized database error", 0, $e);
} | php | public static function translate(\Exception $e): \Exception
{
if ($e instanceof \MongoDB\Driver\Exception\ConnectionException ||
$e instanceof \MongoDB\Driver\Exception\ExecutionTimeoutException) {
return new \Caridea\Dao\Exception\Unreachable("System unreachable or connection timed out", $e->getCode(), $e);
} elseif ($e instanceof \MongoDB\Driver\Exception\InvalidArgumentException ||
$e instanceof \MongoDB\Driver\Exception\LogicException ||
$e instanceof \MongoDB\Exception\BadMethodCallException) {
return new \Caridea\Dao\Exception\Inoperable("Invalid API usage", $e->getCode(), $e);
} elseif ($e instanceof \MongoDB\GridFS\Exception\FileNotFoundException ||
$e instanceof \MongoDB\GridFS\Exception\CorruptFileException) {
return new \Caridea\Dao\Exception\Unretrievable("Data could not be retrieved", $e->getCode(), $e);
} elseif ($e instanceof \MongoDB\Driver\Exception\RuntimeException &&
($e->getCode() == 11000 || 'E11000' == substr($e->getMessage(), 0, 6))) {
return new \Caridea\Dao\Exception\Duplicative("Unique constraint violation", 409, $e);
} elseif ($e instanceof \MongoDB\Driver\Exception\BulkWriteException &&
$e->getMessage() == 'Document failed validation') {
return new \Caridea\Dao\Exception\Violating("Constraint violation", 422, $e);
}
return new \Caridea\Dao\Exception\Generic("Uncategorized database error", 0, $e);
} | [
"public",
"static",
"function",
"translate",
"(",
"\\",
"Exception",
"$",
"e",
")",
":",
"\\",
"Exception",
"{",
"if",
"(",
"$",
"e",
"instanceof",
"\\",
"MongoDB",
"\\",
"Driver",
"\\",
"Exception",
"\\",
"ConnectionException",
"||",
"$",
"e",
"instanceof",
"\\",
"MongoDB",
"\\",
"Driver",
"\\",
"Exception",
"\\",
"ExecutionTimeoutException",
")",
"{",
"return",
"new",
"\\",
"Caridea",
"\\",
"Dao",
"\\",
"Exception",
"\\",
"Unreachable",
"(",
"\"System unreachable or connection timed out\"",
",",
"$",
"e",
"->",
"getCode",
"(",
")",
",",
"$",
"e",
")",
";",
"}",
"elseif",
"(",
"$",
"e",
"instanceof",
"\\",
"MongoDB",
"\\",
"Driver",
"\\",
"Exception",
"\\",
"InvalidArgumentException",
"||",
"$",
"e",
"instanceof",
"\\",
"MongoDB",
"\\",
"Driver",
"\\",
"Exception",
"\\",
"LogicException",
"||",
"$",
"e",
"instanceof",
"\\",
"MongoDB",
"\\",
"Exception",
"\\",
"BadMethodCallException",
")",
"{",
"return",
"new",
"\\",
"Caridea",
"\\",
"Dao",
"\\",
"Exception",
"\\",
"Inoperable",
"(",
"\"Invalid API usage\"",
",",
"$",
"e",
"->",
"getCode",
"(",
")",
",",
"$",
"e",
")",
";",
"}",
"elseif",
"(",
"$",
"e",
"instanceof",
"\\",
"MongoDB",
"\\",
"GridFS",
"\\",
"Exception",
"\\",
"FileNotFoundException",
"||",
"$",
"e",
"instanceof",
"\\",
"MongoDB",
"\\",
"GridFS",
"\\",
"Exception",
"\\",
"CorruptFileException",
")",
"{",
"return",
"new",
"\\",
"Caridea",
"\\",
"Dao",
"\\",
"Exception",
"\\",
"Unretrievable",
"(",
"\"Data could not be retrieved\"",
",",
"$",
"e",
"->",
"getCode",
"(",
")",
",",
"$",
"e",
")",
";",
"}",
"elseif",
"(",
"$",
"e",
"instanceof",
"\\",
"MongoDB",
"\\",
"Driver",
"\\",
"Exception",
"\\",
"RuntimeException",
"&&",
"(",
"$",
"e",
"->",
"getCode",
"(",
")",
"==",
"11000",
"||",
"'E11000'",
"==",
"substr",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"0",
",",
"6",
")",
")",
")",
"{",
"return",
"new",
"\\",
"Caridea",
"\\",
"Dao",
"\\",
"Exception",
"\\",
"Duplicative",
"(",
"\"Unique constraint violation\"",
",",
"409",
",",
"$",
"e",
")",
";",
"}",
"elseif",
"(",
"$",
"e",
"instanceof",
"\\",
"MongoDB",
"\\",
"Driver",
"\\",
"Exception",
"\\",
"BulkWriteException",
"&&",
"$",
"e",
"->",
"getMessage",
"(",
")",
"==",
"'Document failed validation'",
")",
"{",
"return",
"new",
"\\",
"Caridea",
"\\",
"Dao",
"\\",
"Exception",
"\\",
"Violating",
"(",
"\"Constraint violation\"",
",",
"422",
",",
"$",
"e",
")",
";",
"}",
"return",
"new",
"\\",
"Caridea",
"\\",
"Dao",
"\\",
"Exception",
"\\",
"Generic",
"(",
"\"Uncategorized database error\"",
",",
"0",
",",
"$",
"e",
")",
";",
"}"
] | Translates a MongoDB exception.
@param \Exception $e The exception to translate
@return \Exception The exception to use | [
"Translates",
"a",
"MongoDB",
"exception",
"."
] | 22c2fc81f63050ad23f7b0c40e430ff026e1e767 | https://github.com/libreworks/caridea-dao/blob/22c2fc81f63050ad23f7b0c40e430ff026e1e767/src/Exception/Translator/MongoDb.php#L37-L57 | train |
mtils/cmsable | src/Cmsable/Translation/Translator.php | Translator.overwrite | public function overwrite($key, $message=null)
{
if (!is_array($key)) {
$this->overwrites[$key] = $message;
return $this;
}
foreach ($key as $k=>$v) {
$this->overwrite($k, $v);
}
return $this;
} | php | public function overwrite($key, $message=null)
{
if (!is_array($key)) {
$this->overwrites[$key] = $message;
return $this;
}
foreach ($key as $k=>$v) {
$this->overwrite($k, $v);
}
return $this;
} | [
"public",
"function",
"overwrite",
"(",
"$",
"key",
",",
"$",
"message",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"key",
")",
")",
"{",
"$",
"this",
"->",
"overwrites",
"[",
"$",
"key",
"]",
"=",
"$",
"message",
";",
"return",
"$",
"this",
";",
"}",
"foreach",
"(",
"$",
"key",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"this",
"->",
"overwrite",
"(",
"$",
"k",
",",
"$",
"v",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Overwrite one or more lang keys
@param string|array $key
@param mixed $message (optional)
@return self | [
"Overwrite",
"one",
"or",
"more",
"lang",
"keys"
] | 03ae84ee3c7d46146f2a1cf687e5c29d6de4286d | https://github.com/mtils/cmsable/blob/03ae84ee3c7d46146f2a1cf687e5c29d6de4286d/src/Cmsable/Translation/Translator.php#L69-L81 | train |
yuncms/yii2-article | frontend/controllers/ArticleController.php | ArticleController.findModelByUUID | protected function findModelByUUID($uuid)
{
if (($model = Article::findOne(['uuid' => $uuid])) != null) {
return $model;
}
throw new NotFoundHttpException(Yii::t('yii', 'The requested page does not exist'));
} | php | protected function findModelByUUID($uuid)
{
if (($model = Article::findOne(['uuid' => $uuid])) != null) {
return $model;
}
throw new NotFoundHttpException(Yii::t('yii', 'The requested page does not exist'));
} | [
"protected",
"function",
"findModelByUUID",
"(",
"$",
"uuid",
")",
"{",
"if",
"(",
"(",
"$",
"model",
"=",
"Article",
"::",
"findOne",
"(",
"[",
"'uuid'",
"=>",
"$",
"uuid",
"]",
")",
")",
"!=",
"null",
")",
"{",
"return",
"$",
"model",
";",
"}",
"throw",
"new",
"NotFoundHttpException",
"(",
"Yii",
"::",
"t",
"(",
"'yii'",
",",
"'The requested page does not exist'",
")",
")",
";",
"}"
] | Finds the Article model based on its primary key value.
If the model is not found, a 404 HTTP exception will be thrown.
@param string $uuid
@return Article the loaded model
@throws NotFoundHttpException if the model cannot be found | [
"Finds",
"the",
"Article",
"model",
"based",
"on",
"its",
"primary",
"key",
"value",
".",
"If",
"the",
"model",
"is",
"not",
"found",
"a",
"404",
"HTTP",
"exception",
"will",
"be",
"thrown",
"."
] | 177ec4d3d143b2f2a69bce760e873485cf3df192 | https://github.com/yuncms/yii2-article/blob/177ec4d3d143b2f2a69bce760e873485cf3df192/frontend/controllers/ArticleController.php#L240-L246 | train |
nicodevs/laito | src/Laito/Session/Tokens/FileTokens.php | FileTokens.get | public function get($hash = null)
{
// If the hash is not received, get it from the request
$hash = $hash?: $this->app->request->token();
// Determine token path
$path = $this->path($hash);
// Abort if the session does not exist
if (!file_exists($path)) {
return false;
}
// Update token file modification time
touch($path);
// Get session data
$data = json_decode(file_get_contents($path), true);
// Return session
return $data;
} | php | public function get($hash = null)
{
// If the hash is not received, get it from the request
$hash = $hash?: $this->app->request->token();
// Determine token path
$path = $this->path($hash);
// Abort if the session does not exist
if (!file_exists($path)) {
return false;
}
// Update token file modification time
touch($path);
// Get session data
$data = json_decode(file_get_contents($path), true);
// Return session
return $data;
} | [
"public",
"function",
"get",
"(",
"$",
"hash",
"=",
"null",
")",
"{",
"// If the hash is not received, get it from the request",
"$",
"hash",
"=",
"$",
"hash",
"?",
":",
"$",
"this",
"->",
"app",
"->",
"request",
"->",
"token",
"(",
")",
";",
"// Determine token path",
"$",
"path",
"=",
"$",
"this",
"->",
"path",
"(",
"$",
"hash",
")",
";",
"// Abort if the session does not exist",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"path",
")",
")",
"{",
"return",
"false",
";",
"}",
"// Update token file modification time",
"touch",
"(",
"$",
"path",
")",
";",
"// Get session data",
"$",
"data",
"=",
"json_decode",
"(",
"file_get_contents",
"(",
"$",
"path",
")",
",",
"true",
")",
";",
"// Return session",
"return",
"$",
"data",
";",
"}"
] | Gets the token data
@param string $hash Token hash
@return array|bool Token data or false | [
"Gets",
"the",
"token",
"data"
] | d2d28abfcbf981c4decfec28ce94f8849600e9fe | https://github.com/nicodevs/laito/blob/d2d28abfcbf981c4decfec28ce94f8849600e9fe/src/Laito/Session/Tokens/FileTokens.php#L32-L53 | train |
nicodevs/laito | src/Laito/Session/Tokens/FileTokens.php | FileTokens.create | public function create($data = [])
{
// Create a random hash
$hash = $this->hash();
// Store the file in the tokens storage
$data = array_merge($data, ['token' => $hash, 'timestamp' => time()]);
$stored = file_put_contents($this->path($hash), json_encode($data));
// Return the data or false in case of failure
return ($stored)? $data : false;
} | php | public function create($data = [])
{
// Create a random hash
$hash = $this->hash();
// Store the file in the tokens storage
$data = array_merge($data, ['token' => $hash, 'timestamp' => time()]);
$stored = file_put_contents($this->path($hash), json_encode($data));
// Return the data or false in case of failure
return ($stored)? $data : false;
} | [
"public",
"function",
"create",
"(",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"// Create a random hash",
"$",
"hash",
"=",
"$",
"this",
"->",
"hash",
"(",
")",
";",
"// Store the file in the tokens storage",
"$",
"data",
"=",
"array_merge",
"(",
"$",
"data",
",",
"[",
"'token'",
"=>",
"$",
"hash",
",",
"'timestamp'",
"=>",
"time",
"(",
")",
"]",
")",
";",
"$",
"stored",
"=",
"file_put_contents",
"(",
"$",
"this",
"->",
"path",
"(",
"$",
"hash",
")",
",",
"json_encode",
"(",
"$",
"data",
")",
")",
";",
"// Return the data or false in case of failure",
"return",
"(",
"$",
"stored",
")",
"?",
"$",
"data",
":",
"false",
";",
"}"
] | Creates a token
@param array $data Data to store
@return Token data | [
"Creates",
"a",
"token"
] | d2d28abfcbf981c4decfec28ce94f8849600e9fe | https://github.com/nicodevs/laito/blob/d2d28abfcbf981c4decfec28ce94f8849600e9fe/src/Laito/Session/Tokens/FileTokens.php#L61-L72 | train |
nicodevs/laito | src/Laito/Session/Tokens/FileTokens.php | FileTokens.update | public function update($hash = null, $data)
{
// If the hash is not received, get it from the request
$hash = $hash?: $this->app->request->token();
// Update the file in the tokens storage
$token = $this->get($hash);
$data = array_merge_recursive($token, $data);
$stored = file_put_contents($this->path($hash), json_encode($data));
// Return the data or false in case of failure
return ($stored)? $data : false;
} | php | public function update($hash = null, $data)
{
// If the hash is not received, get it from the request
$hash = $hash?: $this->app->request->token();
// Update the file in the tokens storage
$token = $this->get($hash);
$data = array_merge_recursive($token, $data);
$stored = file_put_contents($this->path($hash), json_encode($data));
// Return the data or false in case of failure
return ($stored)? $data : false;
} | [
"public",
"function",
"update",
"(",
"$",
"hash",
"=",
"null",
",",
"$",
"data",
")",
"{",
"// If the hash is not received, get it from the request",
"$",
"hash",
"=",
"$",
"hash",
"?",
":",
"$",
"this",
"->",
"app",
"->",
"request",
"->",
"token",
"(",
")",
";",
"// Update the file in the tokens storage",
"$",
"token",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"hash",
")",
";",
"$",
"data",
"=",
"array_merge_recursive",
"(",
"$",
"token",
",",
"$",
"data",
")",
";",
"$",
"stored",
"=",
"file_put_contents",
"(",
"$",
"this",
"->",
"path",
"(",
"$",
"hash",
")",
",",
"json_encode",
"(",
"$",
"data",
")",
")",
";",
"// Return the data or false in case of failure",
"return",
"(",
"$",
"stored",
")",
"?",
"$",
"data",
":",
"false",
";",
"}"
] | Updates a token
@param string $hash Token hash
@param array $data Data to store
@return Token data | [
"Updates",
"a",
"token"
] | d2d28abfcbf981c4decfec28ce94f8849600e9fe | https://github.com/nicodevs/laito/blob/d2d28abfcbf981c4decfec28ce94f8849600e9fe/src/Laito/Session/Tokens/FileTokens.php#L81-L93 | train |
nicodevs/laito | src/Laito/Session/Tokens/FileTokens.php | FileTokens.destroy | public function destroy($hash = null)
{
// If the hash is not received, get it from the request
$hash = $hash?: $this->app->request->token();
// Abort if the file does not exist
$path = $this->path($hash);
if (!file_exists($path)) {
return true;
}
// Otherwise, remove the token file
$success = unlink($path);
if (!$success) {
throw new Exception("The session could not be erased", 500);
}
// Return success
return $success;
} | php | public function destroy($hash = null)
{
// If the hash is not received, get it from the request
$hash = $hash?: $this->app->request->token();
// Abort if the file does not exist
$path = $this->path($hash);
if (!file_exists($path)) {
return true;
}
// Otherwise, remove the token file
$success = unlink($path);
if (!$success) {
throw new Exception("The session could not be erased", 500);
}
// Return success
return $success;
} | [
"public",
"function",
"destroy",
"(",
"$",
"hash",
"=",
"null",
")",
"{",
"// If the hash is not received, get it from the request",
"$",
"hash",
"=",
"$",
"hash",
"?",
":",
"$",
"this",
"->",
"app",
"->",
"request",
"->",
"token",
"(",
")",
";",
"// Abort if the file does not exist",
"$",
"path",
"=",
"$",
"this",
"->",
"path",
"(",
"$",
"hash",
")",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"path",
")",
")",
"{",
"return",
"true",
";",
"}",
"// Otherwise, remove the token file",
"$",
"success",
"=",
"unlink",
"(",
"$",
"path",
")",
";",
"if",
"(",
"!",
"$",
"success",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"The session could not be erased\"",
",",
"500",
")",
";",
"}",
"// Return success",
"return",
"$",
"success",
";",
"}"
] | Destroys a token
@param string $hash Token hash
@return bool Success or failure | [
"Destroys",
"a",
"token"
] | d2d28abfcbf981c4decfec28ce94f8849600e9fe | https://github.com/nicodevs/laito/blob/d2d28abfcbf981c4decfec28ce94f8849600e9fe/src/Laito/Session/Tokens/FileTokens.php#L101-L120 | train |
TuumPHP/Web | src/Stack/Dispatcher.php | Dispatcher.prepare | private function prepare($route)
{
$this->route = $route;
$this->setBeforeFilter($route->before());
$this->setAfterRelease($route->after());
} | php | private function prepare($route)
{
$this->route = $route;
$this->setBeforeFilter($route->before());
$this->setAfterRelease($route->after());
} | [
"private",
"function",
"prepare",
"(",
"$",
"route",
")",
"{",
"$",
"this",
"->",
"route",
"=",
"$",
"route",
";",
"$",
"this",
"->",
"setBeforeFilter",
"(",
"$",
"route",
"->",
"before",
"(",
")",
")",
";",
"$",
"this",
"->",
"setAfterRelease",
"(",
"$",
"route",
"->",
"after",
"(",
")",
")",
";",
"}"
] | prepares before filters and after releases from route.
@param Route $route | [
"prepares",
"before",
"filters",
"and",
"after",
"releases",
"from",
"route",
"."
] | 8f296b6358aa93226ce08d6cc54a309f5b0a9820 | https://github.com/TuumPHP/Web/blob/8f296b6358aa93226ce08d6cc54a309f5b0a9820/src/Stack/Dispatcher.php#L78-L83 | train |
translationexchange/tml-php-clientsdk | library/Tr8n/LanguageContext.php | LanguageContext.fallbackRule | function fallbackRule() {
if (!isset($this->fallback_rule)) {
foreach($this->rules as $key => $rule) {
if ($rule->isFallback()) {
$this->fallback_rule = $rule;
}
}
}
return $this->fallback_rule;
} | php | function fallbackRule() {
if (!isset($this->fallback_rule)) {
foreach($this->rules as $key => $rule) {
if ($rule->isFallback()) {
$this->fallback_rule = $rule;
}
}
}
return $this->fallback_rule;
} | [
"function",
"fallbackRule",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"fallback_rule",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"rules",
"as",
"$",
"key",
"=>",
"$",
"rule",
")",
"{",
"if",
"(",
"$",
"rule",
"->",
"isFallback",
"(",
")",
")",
"{",
"$",
"this",
"->",
"fallback_rule",
"=",
"$",
"rule",
";",
"}",
"}",
"}",
"return",
"$",
"this",
"->",
"fallback_rule",
";",
"}"
] | Fallback rule usually has a key of "other", but that may not be necessary in all cases.
@return mixed | [
"Fallback",
"rule",
"usually",
"has",
"a",
"key",
"of",
"other",
"but",
"that",
"may",
"not",
"be",
"necessary",
"in",
"all",
"cases",
"."
] | fe51473824e62cfd883c6aa0c6a3783a16ce8425 | https://github.com/translationexchange/tml-php-clientsdk/blob/fe51473824e62cfd883c6aa0c6a3783a16ce8425/library/Tr8n/LanguageContext.php#L119-L129 | train |
sokil/CommandBusBundle | src/CommandBus/CommandHandlerServiceResolver.php | CommandHandlerServiceResolver.get | public function get($handlerServiceId)
{
$handler = $this->container->get($handlerServiceId);
if (!$handler instanceof CommandHandlerInterface) {
throw new \InvalidArgumentException('Handler must be instance if ' . CommandHandlerInterface::class);
}
return $handler;
} | php | public function get($handlerServiceId)
{
$handler = $this->container->get($handlerServiceId);
if (!$handler instanceof CommandHandlerInterface) {
throw new \InvalidArgumentException('Handler must be instance if ' . CommandHandlerInterface::class);
}
return $handler;
} | [
"public",
"function",
"get",
"(",
"$",
"handlerServiceId",
")",
"{",
"$",
"handler",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"$",
"handlerServiceId",
")",
";",
"if",
"(",
"!",
"$",
"handler",
"instanceof",
"CommandHandlerInterface",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Handler must be instance if '",
".",
"CommandHandlerInterface",
"::",
"class",
")",
";",
"}",
"return",
"$",
"handler",
";",
"}"
] | Get command handler
@param string $handlerServiceId
@return CommandHandlerInterface | [
"Get",
"command",
"handler"
] | 7cfdd5f1e8a77f0620b94dd5214091a2159a143d | https://github.com/sokil/CommandBusBundle/blob/7cfdd5f1e8a77f0620b94dd5214091a2159a143d/src/CommandBus/CommandHandlerServiceResolver.php#L30-L39 | train |
eureka-framework/component-cache | src/Cache/CacheFactory.php | CacheFactory.engine | protected static function engine()
{
$engine = '';
foreach (static::$engines as $name => $function) {
if ($function === null || function_exists($function)) {
$engine = $name;
break;
}
}
return $engine;
} | php | protected static function engine()
{
$engine = '';
foreach (static::$engines as $name => $function) {
if ($function === null || function_exists($function)) {
$engine = $name;
break;
}
}
return $engine;
} | [
"protected",
"static",
"function",
"engine",
"(",
")",
"{",
"$",
"engine",
"=",
"''",
";",
"foreach",
"(",
"static",
"::",
"$",
"engines",
"as",
"$",
"name",
"=>",
"$",
"function",
")",
"{",
"if",
"(",
"$",
"function",
"===",
"null",
"||",
"function_exists",
"(",
"$",
"function",
")",
")",
"{",
"$",
"engine",
"=",
"$",
"name",
";",
"break",
";",
"}",
"}",
"return",
"$",
"engine",
";",
"}"
] | Get name of php Cache engine used.
@return string engine | [
"Get",
"name",
"of",
"php",
"Cache",
"engine",
"used",
"."
] | c110441ac7bb20edd2ecd8162f4302596d875785 | https://github.com/eureka-framework/component-cache/blob/c110441ac7bb20edd2ecd8162f4302596d875785/src/Cache/CacheFactory.php#L36-L48 | train |
eureka-framework/component-cache | src/Cache/CacheFactory.php | CacheFactory.build | public static function build($engine = null, $namespace = '\Eureka\Component\Cache')
{
if (null === $engine) {
$engine = static::engine();
}
if (empty(static::$instances[$engine])) {
$class = $namespace . '\\' . 'CacheWrapper' . $engine;
static::$instances[$engine] = new $class();
}
return static::$instances[$engine];
} | php | public static function build($engine = null, $namespace = '\Eureka\Component\Cache')
{
if (null === $engine) {
$engine = static::engine();
}
if (empty(static::$instances[$engine])) {
$class = $namespace . '\\' . 'CacheWrapper' . $engine;
static::$instances[$engine] = new $class();
}
return static::$instances[$engine];
} | [
"public",
"static",
"function",
"build",
"(",
"$",
"engine",
"=",
"null",
",",
"$",
"namespace",
"=",
"'\\Eureka\\Component\\Cache'",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"engine",
")",
"{",
"$",
"engine",
"=",
"static",
"::",
"engine",
"(",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"static",
"::",
"$",
"instances",
"[",
"$",
"engine",
"]",
")",
")",
"{",
"$",
"class",
"=",
"$",
"namespace",
".",
"'\\\\'",
".",
"'CacheWrapper'",
".",
"$",
"engine",
";",
"static",
"::",
"$",
"instances",
"[",
"$",
"engine",
"]",
"=",
"new",
"$",
"class",
"(",
")",
";",
"}",
"return",
"static",
"::",
"$",
"instances",
"[",
"$",
"engine",
"]",
";",
"}"
] | Instantiate Cache Wrapper object & return it.
@param string $engine Class name of the engine to use.
@param string $namespace
@return CacheWrapperAbstract | [
"Instantiate",
"Cache",
"Wrapper",
"object",
"&",
"return",
"it",
"."
] | c110441ac7bb20edd2ecd8162f4302596d875785 | https://github.com/eureka-framework/component-cache/blob/c110441ac7bb20edd2ecd8162f4302596d875785/src/Cache/CacheFactory.php#L58-L70 | train |
Kris-Kuiper/sFire-Framework | src/Translation/Translation.php | Translation.translate | public static function translate($key, $params = [], $language = null, Viewmodel $viewmodel = null) {
$identifier = null;
if(null !== $viewmodel) {
$identifier = static :: load($viewmodel);
}
if(null === $key) {
$key = '';
}
//Check if key is a string
if(false === is_string($key)) {
return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($key)), E_USER_ERROR);
}
//Check if params is an array
if(null !== $params && false === is_array($params)) {
return trigger_error(sprintf('Argument 2 passed to %s() must be of the type array, "%s" given', __METHOD__, gettype($params)), E_USER_ERROR);
}
//Check if language is a string
if(null !== $language && false === is_string($language)) {
return trigger_error(sprintf('Argument 3 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($language)), E_USER_ERROR);
}
//Set default language if non given
if(null === $language) {
$language = static :: $language;
}
//If identifier is known (usually with a viewmodel as last param)
if(null !== $identifier) {
if(true === isset(static :: $translations[$identifier], static :: $translations[$identifier][$language])) {
if(true === isset(static :: $translations[$identifier][$language][$key])) {
return vsprintf(static :: $translations[$identifier][$language][$key], $params);
}
}
}
//Check the full resource for the translation
foreach(static :: $translations as $translation) {
if(true === isset($translation[$language][$key])) {
return vsprintf($translation[$language][$key], $params);
}
}
//No translation found
return vsprintf($key, $params);
} | php | public static function translate($key, $params = [], $language = null, Viewmodel $viewmodel = null) {
$identifier = null;
if(null !== $viewmodel) {
$identifier = static :: load($viewmodel);
}
if(null === $key) {
$key = '';
}
//Check if key is a string
if(false === is_string($key)) {
return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($key)), E_USER_ERROR);
}
//Check if params is an array
if(null !== $params && false === is_array($params)) {
return trigger_error(sprintf('Argument 2 passed to %s() must be of the type array, "%s" given', __METHOD__, gettype($params)), E_USER_ERROR);
}
//Check if language is a string
if(null !== $language && false === is_string($language)) {
return trigger_error(sprintf('Argument 3 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($language)), E_USER_ERROR);
}
//Set default language if non given
if(null === $language) {
$language = static :: $language;
}
//If identifier is known (usually with a viewmodel as last param)
if(null !== $identifier) {
if(true === isset(static :: $translations[$identifier], static :: $translations[$identifier][$language])) {
if(true === isset(static :: $translations[$identifier][$language][$key])) {
return vsprintf(static :: $translations[$identifier][$language][$key], $params);
}
}
}
//Check the full resource for the translation
foreach(static :: $translations as $translation) {
if(true === isset($translation[$language][$key])) {
return vsprintf($translation[$language][$key], $params);
}
}
//No translation found
return vsprintf($key, $params);
} | [
"public",
"static",
"function",
"translate",
"(",
"$",
"key",
",",
"$",
"params",
"=",
"[",
"]",
",",
"$",
"language",
"=",
"null",
",",
"Viewmodel",
"$",
"viewmodel",
"=",
"null",
")",
"{",
"$",
"identifier",
"=",
"null",
";",
"if",
"(",
"null",
"!==",
"$",
"viewmodel",
")",
"{",
"$",
"identifier",
"=",
"static",
"::",
"load",
"(",
"$",
"viewmodel",
")",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"key",
")",
"{",
"$",
"key",
"=",
"''",
";",
"}",
"//Check if key is a string\r",
"if",
"(",
"false",
"===",
"is_string",
"(",
"$",
"key",
")",
")",
"{",
"return",
"trigger_error",
"(",
"sprintf",
"(",
"'Argument 1 passed to %s() must be of the type string, \"%s\" given'",
",",
"__METHOD__",
",",
"gettype",
"(",
"$",
"key",
")",
")",
",",
"E_USER_ERROR",
")",
";",
"}",
"//Check if params is an array\r",
"if",
"(",
"null",
"!==",
"$",
"params",
"&&",
"false",
"===",
"is_array",
"(",
"$",
"params",
")",
")",
"{",
"return",
"trigger_error",
"(",
"sprintf",
"(",
"'Argument 2 passed to %s() must be of the type array, \"%s\" given'",
",",
"__METHOD__",
",",
"gettype",
"(",
"$",
"params",
")",
")",
",",
"E_USER_ERROR",
")",
";",
"}",
"//Check if language is a string\r",
"if",
"(",
"null",
"!==",
"$",
"language",
"&&",
"false",
"===",
"is_string",
"(",
"$",
"language",
")",
")",
"{",
"return",
"trigger_error",
"(",
"sprintf",
"(",
"'Argument 3 passed to %s() must be of the type string, \"%s\" given'",
",",
"__METHOD__",
",",
"gettype",
"(",
"$",
"language",
")",
")",
",",
"E_USER_ERROR",
")",
";",
"}",
"//Set default language if non given\r",
"if",
"(",
"null",
"===",
"$",
"language",
")",
"{",
"$",
"language",
"=",
"static",
"::",
"$",
"language",
";",
"}",
"//If identifier is known (usually with a viewmodel as last param)\r",
"if",
"(",
"null",
"!==",
"$",
"identifier",
")",
"{",
"if",
"(",
"true",
"===",
"isset",
"(",
"static",
"::",
"$",
"translations",
"[",
"$",
"identifier",
"]",
",",
"static",
"::",
"$",
"translations",
"[",
"$",
"identifier",
"]",
"[",
"$",
"language",
"]",
")",
")",
"{",
"if",
"(",
"true",
"===",
"isset",
"(",
"static",
"::",
"$",
"translations",
"[",
"$",
"identifier",
"]",
"[",
"$",
"language",
"]",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"vsprintf",
"(",
"static",
"::",
"$",
"translations",
"[",
"$",
"identifier",
"]",
"[",
"$",
"language",
"]",
"[",
"$",
"key",
"]",
",",
"$",
"params",
")",
";",
"}",
"}",
"}",
"//Check the full resource for the translation\r",
"foreach",
"(",
"static",
"::",
"$",
"translations",
"as",
"$",
"translation",
")",
"{",
"if",
"(",
"true",
"===",
"isset",
"(",
"$",
"translation",
"[",
"$",
"language",
"]",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"vsprintf",
"(",
"$",
"translation",
"[",
"$",
"language",
"]",
"[",
"$",
"key",
"]",
",",
"$",
"params",
")",
";",
"}",
"}",
"//No translation found\r",
"return",
"vsprintf",
"(",
"$",
"key",
",",
"$",
"params",
")",
";",
"}"
] | Translate text based on a key
@param string $key
@param array $params
@param string $language
@param sFire\MVC\Viewmodel $viewmodel
@return string | [
"Translate",
"text",
"based",
"on",
"a",
"key"
] | deefe1d9d2b40e7326381e8dcd4f01f9aa61885c | https://github.com/Kris-Kuiper/sFire-Framework/blob/deefe1d9d2b40e7326381e8dcd4f01f9aa61885c/src/Translation/Translation.php#L41-L94 | train |
Kris-Kuiper/sFire-Framework | src/Translation/Translation.php | Translation.load | public static function load($source) {
if(false === is_string($source) && false === $source instanceof Viewmodel) {
return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string or instance of sFire\MVC\Viewmodel, "%s" given', __METHOD__, gettype($source)), E_USER_ERROR);
}
$file = $source;
if($source instanceof Viewmodel) {
$path = Path :: get('modules') . Router :: getRoute() -> getModule() . DIRECTORY_SEPARATOR;
$views = $path . Application :: get(['directory', 'view']);
$translations = $path . Application :: get(['directory', 'translation']);
$extension = Application :: get(['extensions', 'view']);
$file = preg_replace('#^'. preg_quote($views) .'#', '', $source -> getFile());
$file = preg_replace('#'. preg_quote($extension) .'$#', '', $file);
}
$module = Router :: getRoute() -> getModule();
$extension = Application :: get(['extensions', 'translation']);
$file = str_replace('.', DIRECTORY_SEPARATOR, $file);
$file = Path :: get('modules') . $module . DIRECTORY_SEPARATOR . Application :: get(['directory', 'translation']) . $file . $extension;
$file = new File($file);
$identifier = md5($file -> entity() -> getBasepath());
$cache = new File(Path :: get('cache-translation') . $identifier);
if(false === $file -> exists() && false === $source instanceof Viewmodel) {
return trigger_error(sprintf('Translation file "%s" used in %s() does not exists', $file -> entity() -> getBasepath(), __METHOD__), E_USER_ERROR);
}
static :: cache($cache, $file);
return $identifier;
} | php | public static function load($source) {
if(false === is_string($source) && false === $source instanceof Viewmodel) {
return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string or instance of sFire\MVC\Viewmodel, "%s" given', __METHOD__, gettype($source)), E_USER_ERROR);
}
$file = $source;
if($source instanceof Viewmodel) {
$path = Path :: get('modules') . Router :: getRoute() -> getModule() . DIRECTORY_SEPARATOR;
$views = $path . Application :: get(['directory', 'view']);
$translations = $path . Application :: get(['directory', 'translation']);
$extension = Application :: get(['extensions', 'view']);
$file = preg_replace('#^'. preg_quote($views) .'#', '', $source -> getFile());
$file = preg_replace('#'. preg_quote($extension) .'$#', '', $file);
}
$module = Router :: getRoute() -> getModule();
$extension = Application :: get(['extensions', 'translation']);
$file = str_replace('.', DIRECTORY_SEPARATOR, $file);
$file = Path :: get('modules') . $module . DIRECTORY_SEPARATOR . Application :: get(['directory', 'translation']) . $file . $extension;
$file = new File($file);
$identifier = md5($file -> entity() -> getBasepath());
$cache = new File(Path :: get('cache-translation') . $identifier);
if(false === $file -> exists() && false === $source instanceof Viewmodel) {
return trigger_error(sprintf('Translation file "%s" used in %s() does not exists', $file -> entity() -> getBasepath(), __METHOD__), E_USER_ERROR);
}
static :: cache($cache, $file);
return $identifier;
} | [
"public",
"static",
"function",
"load",
"(",
"$",
"source",
")",
"{",
"if",
"(",
"false",
"===",
"is_string",
"(",
"$",
"source",
")",
"&&",
"false",
"===",
"$",
"source",
"instanceof",
"Viewmodel",
")",
"{",
"return",
"trigger_error",
"(",
"sprintf",
"(",
"'Argument 1 passed to %s() must be of the type string or instance of sFire\\MVC\\Viewmodel, \"%s\" given'",
",",
"__METHOD__",
",",
"gettype",
"(",
"$",
"source",
")",
")",
",",
"E_USER_ERROR",
")",
";",
"}",
"$",
"file",
"=",
"$",
"source",
";",
"if",
"(",
"$",
"source",
"instanceof",
"Viewmodel",
")",
"{",
"$",
"path",
"=",
"Path",
"::",
"get",
"(",
"'modules'",
")",
".",
"Router",
"::",
"getRoute",
"(",
")",
"->",
"getModule",
"(",
")",
".",
"DIRECTORY_SEPARATOR",
";",
"$",
"views",
"=",
"$",
"path",
".",
"Application",
"::",
"get",
"(",
"[",
"'directory'",
",",
"'view'",
"]",
")",
";",
"$",
"translations",
"=",
"$",
"path",
".",
"Application",
"::",
"get",
"(",
"[",
"'directory'",
",",
"'translation'",
"]",
")",
";",
"$",
"extension",
"=",
"Application",
"::",
"get",
"(",
"[",
"'extensions'",
",",
"'view'",
"]",
")",
";",
"$",
"file",
"=",
"preg_replace",
"(",
"'#^'",
".",
"preg_quote",
"(",
"$",
"views",
")",
".",
"'#'",
",",
"''",
",",
"$",
"source",
"->",
"getFile",
"(",
")",
")",
";",
"$",
"file",
"=",
"preg_replace",
"(",
"'#'",
".",
"preg_quote",
"(",
"$",
"extension",
")",
".",
"'$#'",
",",
"''",
",",
"$",
"file",
")",
";",
"}",
"$",
"module",
"=",
"Router",
"::",
"getRoute",
"(",
")",
"->",
"getModule",
"(",
")",
";",
"$",
"extension",
"=",
"Application",
"::",
"get",
"(",
"[",
"'extensions'",
",",
"'translation'",
"]",
")",
";",
"$",
"file",
"=",
"str_replace",
"(",
"'.'",
",",
"DIRECTORY_SEPARATOR",
",",
"$",
"file",
")",
";",
"$",
"file",
"=",
"Path",
"::",
"get",
"(",
"'modules'",
")",
".",
"$",
"module",
".",
"DIRECTORY_SEPARATOR",
".",
"Application",
"::",
"get",
"(",
"[",
"'directory'",
",",
"'translation'",
"]",
")",
".",
"$",
"file",
".",
"$",
"extension",
";",
"$",
"file",
"=",
"new",
"File",
"(",
"$",
"file",
")",
";",
"$",
"identifier",
"=",
"md5",
"(",
"$",
"file",
"->",
"entity",
"(",
")",
"->",
"getBasepath",
"(",
")",
")",
";",
"$",
"cache",
"=",
"new",
"File",
"(",
"Path",
"::",
"get",
"(",
"'cache-translation'",
")",
".",
"$",
"identifier",
")",
";",
"if",
"(",
"false",
"===",
"$",
"file",
"->",
"exists",
"(",
")",
"&&",
"false",
"===",
"$",
"source",
"instanceof",
"Viewmodel",
")",
"{",
"return",
"trigger_error",
"(",
"sprintf",
"(",
"'Translation file \"%s\" used in %s() does not exists'",
",",
"$",
"file",
"->",
"entity",
"(",
")",
"->",
"getBasepath",
"(",
")",
",",
"__METHOD__",
")",
",",
"E_USER_ERROR",
")",
";",
"}",
"static",
"::",
"cache",
"(",
"$",
"cache",
",",
"$",
"file",
")",
";",
"return",
"$",
"identifier",
";",
"}"
] | Loads a new translation file
@param string|sFire\MVC\Viewmodel $source
@return string | [
"Loads",
"a",
"new",
"translation",
"file"
] | deefe1d9d2b40e7326381e8dcd4f01f9aa61885c | https://github.com/Kris-Kuiper/sFire-Framework/blob/deefe1d9d2b40e7326381e8dcd4f01f9aa61885c/src/Translation/Translation.php#L102-L135 | train |
Kris-Kuiper/sFire-Framework | src/Translation/Translation.php | Translation.cache | private static function cache(File $cache, File $file) {
if(false === isset(static :: $translations[$cache -> entity() -> getName()])) {
$parse = true;
if(true === $cache -> exists()) {
if($cache -> entity() -> getModificationTime() >= $file -> entity() -> getModificationTime()) {
$parse = false;
}
}
//Check if file needs to be parsed
if(true === $parse) {
$content = serialize(static :: parse($file));
$cache -> create() -> flush() -> append($content);
}
static :: $translations[$cache -> entity() -> getName()] = unserialize($cache -> getContent());
}
} | php | private static function cache(File $cache, File $file) {
if(false === isset(static :: $translations[$cache -> entity() -> getName()])) {
$parse = true;
if(true === $cache -> exists()) {
if($cache -> entity() -> getModificationTime() >= $file -> entity() -> getModificationTime()) {
$parse = false;
}
}
//Check if file needs to be parsed
if(true === $parse) {
$content = serialize(static :: parse($file));
$cache -> create() -> flush() -> append($content);
}
static :: $translations[$cache -> entity() -> getName()] = unserialize($cache -> getContent());
}
} | [
"private",
"static",
"function",
"cache",
"(",
"File",
"$",
"cache",
",",
"File",
"$",
"file",
")",
"{",
"if",
"(",
"false",
"===",
"isset",
"(",
"static",
"::",
"$",
"translations",
"[",
"$",
"cache",
"->",
"entity",
"(",
")",
"->",
"getName",
"(",
")",
"]",
")",
")",
"{",
"$",
"parse",
"=",
"true",
";",
"if",
"(",
"true",
"===",
"$",
"cache",
"->",
"exists",
"(",
")",
")",
"{",
"if",
"(",
"$",
"cache",
"->",
"entity",
"(",
")",
"->",
"getModificationTime",
"(",
")",
">=",
"$",
"file",
"->",
"entity",
"(",
")",
"->",
"getModificationTime",
"(",
")",
")",
"{",
"$",
"parse",
"=",
"false",
";",
"}",
"}",
"//Check if file needs to be parsed\r",
"if",
"(",
"true",
"===",
"$",
"parse",
")",
"{",
"$",
"content",
"=",
"serialize",
"(",
"static",
"::",
"parse",
"(",
"$",
"file",
")",
")",
";",
"$",
"cache",
"->",
"create",
"(",
")",
"->",
"flush",
"(",
")",
"->",
"append",
"(",
"$",
"content",
")",
";",
"}",
"static",
"::",
"$",
"translations",
"[",
"$",
"cache",
"->",
"entity",
"(",
")",
"->",
"getName",
"(",
")",
"]",
"=",
"unserialize",
"(",
"$",
"cache",
"->",
"getContent",
"(",
")",
")",
";",
"}",
"}"
] | Returns cache if exists, otherwise the translation cache file is created, filled with content and returned
@param sFire\System\File $cache
@param sFire\System\File $file | [
"Returns",
"cache",
"if",
"exists",
"otherwise",
"the",
"translation",
"cache",
"file",
"is",
"created",
"filled",
"with",
"content",
"and",
"returned"
] | deefe1d9d2b40e7326381e8dcd4f01f9aa61885c | https://github.com/Kris-Kuiper/sFire-Framework/blob/deefe1d9d2b40e7326381e8dcd4f01f9aa61885c/src/Translation/Translation.php#L166-L188 | train |
Kris-Kuiper/sFire-Framework | src/Translation/Translation.php | Translation.parse | private static function parse(File $file) {
$lines = explode("\n", $file -> getContent());
$languages = [];
foreach($lines as $index => $line) {
$line = trim($line);
if('' === $line) {
continue;
}
//Check for language format
preg_match('#^\[([a-z_\-0-9]+)\]#i', $line, $language);
if(count($language) === 2) {
$lg = $language[1];
$languages[$lg] = [];
continue;
}
//If there is no language found
if(false === isset($lg)) {
return trigger_error(sprintf('Missing language title in translation file "%s" on line %s', $file -> entity() -> getBasepath(), ++$index), E_USER_ERROR);
}
//Match the format (key value) on a single translation line
preg_match('#^(\'|")(.*)(\1)\s+(\'|")(.*)(\3)$#', $line, $match);
if(count($match) !== 7) {
return trigger_error(sprintf('Incorrect format in translation file "%s" on line %s', $file -> entity() -> getBasepath(), ++$index), E_USER_ERROR);
}
$languages[$lg][$match[2]] = $match[5];
}
return $languages;
} | php | private static function parse(File $file) {
$lines = explode("\n", $file -> getContent());
$languages = [];
foreach($lines as $index => $line) {
$line = trim($line);
if('' === $line) {
continue;
}
//Check for language format
preg_match('#^\[([a-z_\-0-9]+)\]#i', $line, $language);
if(count($language) === 2) {
$lg = $language[1];
$languages[$lg] = [];
continue;
}
//If there is no language found
if(false === isset($lg)) {
return trigger_error(sprintf('Missing language title in translation file "%s" on line %s', $file -> entity() -> getBasepath(), ++$index), E_USER_ERROR);
}
//Match the format (key value) on a single translation line
preg_match('#^(\'|")(.*)(\1)\s+(\'|")(.*)(\3)$#', $line, $match);
if(count($match) !== 7) {
return trigger_error(sprintf('Incorrect format in translation file "%s" on line %s', $file -> entity() -> getBasepath(), ++$index), E_USER_ERROR);
}
$languages[$lg][$match[2]] = $match[5];
}
return $languages;
} | [
"private",
"static",
"function",
"parse",
"(",
"File",
"$",
"file",
")",
"{",
"$",
"lines",
"=",
"explode",
"(",
"\"\\n\"",
",",
"$",
"file",
"->",
"getContent",
"(",
")",
")",
";",
"$",
"languages",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"lines",
"as",
"$",
"index",
"=>",
"$",
"line",
")",
"{",
"$",
"line",
"=",
"trim",
"(",
"$",
"line",
")",
";",
"if",
"(",
"''",
"===",
"$",
"line",
")",
"{",
"continue",
";",
"}",
"//Check for language format\r",
"preg_match",
"(",
"'#^\\[([a-z_\\-0-9]+)\\]#i'",
",",
"$",
"line",
",",
"$",
"language",
")",
";",
"if",
"(",
"count",
"(",
"$",
"language",
")",
"===",
"2",
")",
"{",
"$",
"lg",
"=",
"$",
"language",
"[",
"1",
"]",
";",
"$",
"languages",
"[",
"$",
"lg",
"]",
"=",
"[",
"]",
";",
"continue",
";",
"}",
"//If there is no language found\r",
"if",
"(",
"false",
"===",
"isset",
"(",
"$",
"lg",
")",
")",
"{",
"return",
"trigger_error",
"(",
"sprintf",
"(",
"'Missing language title in translation file \"%s\" on line %s'",
",",
"$",
"file",
"->",
"entity",
"(",
")",
"->",
"getBasepath",
"(",
")",
",",
"++",
"$",
"index",
")",
",",
"E_USER_ERROR",
")",
";",
"}",
"//Match the format (key value) on a single translation line\r",
"preg_match",
"(",
"'#^(\\'|\")(.*)(\\1)\\s+(\\'|\")(.*)(\\3)$#'",
",",
"$",
"line",
",",
"$",
"match",
")",
";",
"if",
"(",
"count",
"(",
"$",
"match",
")",
"!==",
"7",
")",
"{",
"return",
"trigger_error",
"(",
"sprintf",
"(",
"'Incorrect format in translation file \"%s\" on line %s'",
",",
"$",
"file",
"->",
"entity",
"(",
")",
"->",
"getBasepath",
"(",
")",
",",
"++",
"$",
"index",
")",
",",
"E_USER_ERROR",
")",
";",
"}",
"$",
"languages",
"[",
"$",
"lg",
"]",
"[",
"$",
"match",
"[",
"2",
"]",
"]",
"=",
"$",
"match",
"[",
"5",
"]",
";",
"}",
"return",
"$",
"languages",
";",
"}"
] | Parses a translation file and converts it into an array
@param sFire\System\File $file
@return array | [
"Parses",
"a",
"translation",
"file",
"and",
"converts",
"it",
"into",
"an",
"array"
] | deefe1d9d2b40e7326381e8dcd4f01f9aa61885c | https://github.com/Kris-Kuiper/sFire-Framework/blob/deefe1d9d2b40e7326381e8dcd4f01f9aa61885c/src/Translation/Translation.php#L196-L236 | train |
itkg/core | src/Itkg/Core/Command/DatabaseUpdate/ReleaseChecker.php | ReleaseChecker.check | public function check(array $scripts, array $rollbacks)
{
$this->checkScripts($scripts, $rollbacks);
foreach ($scripts as $k => $script) {
$this->checkScript($script, $rollbacks[$k]);
}
} | php | public function check(array $scripts, array $rollbacks)
{
$this->checkScripts($scripts, $rollbacks);
foreach ($scripts as $k => $script) {
$this->checkScript($script, $rollbacks[$k]);
}
} | [
"public",
"function",
"check",
"(",
"array",
"$",
"scripts",
",",
"array",
"$",
"rollbacks",
")",
"{",
"$",
"this",
"->",
"checkScripts",
"(",
"$",
"scripts",
",",
"$",
"rollbacks",
")",
";",
"foreach",
"(",
"$",
"scripts",
"as",
"$",
"k",
"=>",
"$",
"script",
")",
"{",
"$",
"this",
"->",
"checkScript",
"(",
"$",
"script",
",",
"$",
"rollbacks",
"[",
"$",
"k",
"]",
")",
";",
"}",
"}"
] | Check a release scripts & rollbacks
and each script separately
@param array $scripts
@param array $rollbacks
@throws \RuntimeException
@throws \LogicException
@throws \InvalidArgumentException | [
"Check",
"a",
"release",
"scripts",
"&",
"rollbacks",
"and",
"each",
"script",
"separately"
] | e5e4efb05feb4d23b0df41f2b21fd095103e593b | https://github.com/itkg/core/blob/e5e4efb05feb4d23b0df41f2b21fd095103e593b/src/Itkg/Core/Command/DatabaseUpdate/ReleaseChecker.php#L35-L43 | train |
bandama-framework/bandama-framework | src/Configuration.php | Configuration.get | public function get($key) {
if (isset($this->settings[$key])) {
return $this->settings[$key];
}
return null;
} | php | public function get($key) {
if (isset($this->settings[$key])) {
return $this->settings[$key];
}
return null;
} | [
"public",
"function",
"get",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"settings",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"settings",
"[",
"$",
"key",
"]",
";",
"}",
"return",
"null",
";",
"}"
] | Get configuration parameter by key if exists else return null
@return mixed | [
"Get",
"configuration",
"parameter",
"by",
"key",
"if",
"exists",
"else",
"return",
"null"
] | 234ed703baf9e31268941c9d5f6d5e004cc53066 | https://github.com/bandama-framework/bandama-framework/blob/234ed703baf9e31268941c9d5f6d5e004cc53066/src/Configuration.php#L54-L60 | train |
gplcart/cli | controllers/commands/FieldValue.php | FieldValue.cmdGetFieldValue | public function cmdGetFieldValue()
{
$result = $this->getListFieldValue();
$this->outputFormat($result);
$this->outputFormatTableFieldValue($result);
$this->output();
} | php | public function cmdGetFieldValue()
{
$result = $this->getListFieldValue();
$this->outputFormat($result);
$this->outputFormatTableFieldValue($result);
$this->output();
} | [
"public",
"function",
"cmdGetFieldValue",
"(",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"getListFieldValue",
"(",
")",
";",
"$",
"this",
"->",
"outputFormat",
"(",
"$",
"result",
")",
";",
"$",
"this",
"->",
"outputFormatTableFieldValue",
"(",
"$",
"result",
")",
";",
"$",
"this",
"->",
"output",
"(",
")",
";",
"}"
] | Callback for "field-value-get" command | [
"Callback",
"for",
"field",
"-",
"value",
"-",
"get",
"command"
] | e57dba53e291a225b4bff0c0d9b23d685dd1c125 | https://github.com/gplcart/cli/blob/e57dba53e291a225b4bff0c0d9b23d685dd1c125/controllers/commands/FieldValue.php#L40-L46 | train |
gplcart/cli | controllers/commands/FieldValue.php | FieldValue.cmdDeleteFieldValue | public function cmdDeleteFieldValue()
{
$id = $this->getParam(0);
if (empty($id) || !is_numeric($id)) {
$this->errorAndExit($this->text('Invalid command'));
}
if ($this->getParam('field')) {
$deleted = $count = 0;
foreach ($this->field_value->getList(array('field_id' => $id)) as $item) {
$count++;
$deleted += (int) $this->field_value->delete($item['field_value_id']);
}
$result = $count && $count == $deleted;
} else {
$result = $this->field_value->delete($id);
}
if (empty($result)) {
$this->errorAndExit($this->text('Unexpected result'));
}
$this->output();
} | php | public function cmdDeleteFieldValue()
{
$id = $this->getParam(0);
if (empty($id) || !is_numeric($id)) {
$this->errorAndExit($this->text('Invalid command'));
}
if ($this->getParam('field')) {
$deleted = $count = 0;
foreach ($this->field_value->getList(array('field_id' => $id)) as $item) {
$count++;
$deleted += (int) $this->field_value->delete($item['field_value_id']);
}
$result = $count && $count == $deleted;
} else {
$result = $this->field_value->delete($id);
}
if (empty($result)) {
$this->errorAndExit($this->text('Unexpected result'));
}
$this->output();
} | [
"public",
"function",
"cmdDeleteFieldValue",
"(",
")",
"{",
"$",
"id",
"=",
"$",
"this",
"->",
"getParam",
"(",
"0",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"id",
")",
"||",
"!",
"is_numeric",
"(",
"$",
"id",
")",
")",
"{",
"$",
"this",
"->",
"errorAndExit",
"(",
"$",
"this",
"->",
"text",
"(",
"'Invalid command'",
")",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"getParam",
"(",
"'field'",
")",
")",
"{",
"$",
"deleted",
"=",
"$",
"count",
"=",
"0",
";",
"foreach",
"(",
"$",
"this",
"->",
"field_value",
"->",
"getList",
"(",
"array",
"(",
"'field_id'",
"=>",
"$",
"id",
")",
")",
"as",
"$",
"item",
")",
"{",
"$",
"count",
"++",
";",
"$",
"deleted",
"+=",
"(",
"int",
")",
"$",
"this",
"->",
"field_value",
"->",
"delete",
"(",
"$",
"item",
"[",
"'field_value_id'",
"]",
")",
";",
"}",
"$",
"result",
"=",
"$",
"count",
"&&",
"$",
"count",
"==",
"$",
"deleted",
";",
"}",
"else",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"field_value",
"->",
"delete",
"(",
"$",
"id",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"result",
")",
")",
"{",
"$",
"this",
"->",
"errorAndExit",
"(",
"$",
"this",
"->",
"text",
"(",
"'Unexpected result'",
")",
")",
";",
"}",
"$",
"this",
"->",
"output",
"(",
")",
";",
"}"
] | Callback for "field-value-delete" command | [
"Callback",
"for",
"field",
"-",
"value",
"-",
"delete",
"command"
] | e57dba53e291a225b4bff0c0d9b23d685dd1c125 | https://github.com/gplcart/cli/blob/e57dba53e291a225b4bff0c0d9b23d685dd1c125/controllers/commands/FieldValue.php#L51-L77 | train |
gplcart/cli | controllers/commands/FieldValue.php | FieldValue.cmdUpdateFieldValue | public function cmdUpdateFieldValue()
{
$params = $this->getParam();
if (empty($params[0]) || count($params) < 2) {
$this->errorAndExit($this->text('Invalid command'));
}
if (!is_numeric($params[0])) {
$this->errorAndExit($this->text('Invalid argument'));
}
$this->setSubmitted(null, $params);
$this->setSubmitted('update', $params[0]);
$this->validateComponent('field_value');
$this->updateFieldValue($params[0]);
$this->output();
} | php | public function cmdUpdateFieldValue()
{
$params = $this->getParam();
if (empty($params[0]) || count($params) < 2) {
$this->errorAndExit($this->text('Invalid command'));
}
if (!is_numeric($params[0])) {
$this->errorAndExit($this->text('Invalid argument'));
}
$this->setSubmitted(null, $params);
$this->setSubmitted('update', $params[0]);
$this->validateComponent('field_value');
$this->updateFieldValue($params[0]);
$this->output();
} | [
"public",
"function",
"cmdUpdateFieldValue",
"(",
")",
"{",
"$",
"params",
"=",
"$",
"this",
"->",
"getParam",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"params",
"[",
"0",
"]",
")",
"||",
"count",
"(",
"$",
"params",
")",
"<",
"2",
")",
"{",
"$",
"this",
"->",
"errorAndExit",
"(",
"$",
"this",
"->",
"text",
"(",
"'Invalid command'",
")",
")",
";",
"}",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"params",
"[",
"0",
"]",
")",
")",
"{",
"$",
"this",
"->",
"errorAndExit",
"(",
"$",
"this",
"->",
"text",
"(",
"'Invalid argument'",
")",
")",
";",
"}",
"$",
"this",
"->",
"setSubmitted",
"(",
"null",
",",
"$",
"params",
")",
";",
"$",
"this",
"->",
"setSubmitted",
"(",
"'update'",
",",
"$",
"params",
"[",
"0",
"]",
")",
";",
"$",
"this",
"->",
"validateComponent",
"(",
"'field_value'",
")",
";",
"$",
"this",
"->",
"updateFieldValue",
"(",
"$",
"params",
"[",
"0",
"]",
")",
";",
"$",
"this",
"->",
"output",
"(",
")",
";",
"}"
] | Callback for "field-value-update" command | [
"Callback",
"for",
"field",
"-",
"value",
"-",
"update",
"command"
] | e57dba53e291a225b4bff0c0d9b23d685dd1c125 | https://github.com/gplcart/cli/blob/e57dba53e291a225b4bff0c0d9b23d685dd1c125/controllers/commands/FieldValue.php#L96-L114 | train |
gplcart/cli | controllers/commands/FieldValue.php | FieldValue.getListFieldValue | protected function getListFieldValue()
{
$id = $this->getParam(0);
if (!isset($id)) {
return $this->field_value->getList(array('limit' => $this->getLimit()));
}
if ($this->getParam('field')) {
return $this->field_value->getList(array('field_id' => $id, 'limit' => $this->getLimit()));
}
if (!is_numeric($id)) {
$this->errorAndExit($this->text('Invalid argument'));
}
$result = $this->field_value->get($id);
if (empty($result)) {
$this->errorAndExit($this->text('Unexpected result'));
}
return array($result);
} | php | protected function getListFieldValue()
{
$id = $this->getParam(0);
if (!isset($id)) {
return $this->field_value->getList(array('limit' => $this->getLimit()));
}
if ($this->getParam('field')) {
return $this->field_value->getList(array('field_id' => $id, 'limit' => $this->getLimit()));
}
if (!is_numeric($id)) {
$this->errorAndExit($this->text('Invalid argument'));
}
$result = $this->field_value->get($id);
if (empty($result)) {
$this->errorAndExit($this->text('Unexpected result'));
}
return array($result);
} | [
"protected",
"function",
"getListFieldValue",
"(",
")",
"{",
"$",
"id",
"=",
"$",
"this",
"->",
"getParam",
"(",
"0",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"id",
")",
")",
"{",
"return",
"$",
"this",
"->",
"field_value",
"->",
"getList",
"(",
"array",
"(",
"'limit'",
"=>",
"$",
"this",
"->",
"getLimit",
"(",
")",
")",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"getParam",
"(",
"'field'",
")",
")",
"{",
"return",
"$",
"this",
"->",
"field_value",
"->",
"getList",
"(",
"array",
"(",
"'field_id'",
"=>",
"$",
"id",
",",
"'limit'",
"=>",
"$",
"this",
"->",
"getLimit",
"(",
")",
")",
")",
";",
"}",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"id",
")",
")",
"{",
"$",
"this",
"->",
"errorAndExit",
"(",
"$",
"this",
"->",
"text",
"(",
"'Invalid argument'",
")",
")",
";",
"}",
"$",
"result",
"=",
"$",
"this",
"->",
"field_value",
"->",
"get",
"(",
"$",
"id",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"result",
")",
")",
"{",
"$",
"this",
"->",
"errorAndExit",
"(",
"$",
"this",
"->",
"text",
"(",
"'Unexpected result'",
")",
")",
";",
"}",
"return",
"array",
"(",
"$",
"result",
")",
";",
"}"
] | Returns an array of field values
@return array | [
"Returns",
"an",
"array",
"of",
"field",
"values"
] | e57dba53e291a225b4bff0c0d9b23d685dd1c125 | https://github.com/gplcart/cli/blob/e57dba53e291a225b4bff0c0d9b23d685dd1c125/controllers/commands/FieldValue.php#L120-L143 | train |
gplcart/cli | controllers/commands/FieldValue.php | FieldValue.addFieldValue | protected function addFieldValue()
{
if (!$this->isError()) {
$id = $this->field_value->add($this->getSubmitted());
if (empty($id)) {
$this->errorAndExit($this->text('Unexpected result'));
}
$this->line($id);
}
} | php | protected function addFieldValue()
{
if (!$this->isError()) {
$id = $this->field_value->add($this->getSubmitted());
if (empty($id)) {
$this->errorAndExit($this->text('Unexpected result'));
}
$this->line($id);
}
} | [
"protected",
"function",
"addFieldValue",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isError",
"(",
")",
")",
"{",
"$",
"id",
"=",
"$",
"this",
"->",
"field_value",
"->",
"add",
"(",
"$",
"this",
"->",
"getSubmitted",
"(",
")",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"id",
")",
")",
"{",
"$",
"this",
"->",
"errorAndExit",
"(",
"$",
"this",
"->",
"text",
"(",
"'Unexpected result'",
")",
")",
";",
"}",
"$",
"this",
"->",
"line",
"(",
"$",
"id",
")",
";",
"}",
"}"
] | Add a new field value | [
"Add",
"a",
"new",
"field",
"value"
] | e57dba53e291a225b4bff0c0d9b23d685dd1c125 | https://github.com/gplcart/cli/blob/e57dba53e291a225b4bff0c0d9b23d685dd1c125/controllers/commands/FieldValue.php#L177-L186 | train |
gplcart/cli | controllers/commands/FieldValue.php | FieldValue.submitAddFieldValue | protected function submitAddFieldValue()
{
$this->setSubmitted(null, $this->getParam());
$this->validateComponent('field_value');
$this->addFieldValue();
} | php | protected function submitAddFieldValue()
{
$this->setSubmitted(null, $this->getParam());
$this->validateComponent('field_value');
$this->addFieldValue();
} | [
"protected",
"function",
"submitAddFieldValue",
"(",
")",
"{",
"$",
"this",
"->",
"setSubmitted",
"(",
"null",
",",
"$",
"this",
"->",
"getParam",
"(",
")",
")",
";",
"$",
"this",
"->",
"validateComponent",
"(",
"'field_value'",
")",
";",
"$",
"this",
"->",
"addFieldValue",
"(",
")",
";",
"}"
] | Add a new field value at once | [
"Add",
"a",
"new",
"field",
"value",
"at",
"once"
] | e57dba53e291a225b4bff0c0d9b23d685dd1c125 | https://github.com/gplcart/cli/blob/e57dba53e291a225b4bff0c0d9b23d685dd1c125/controllers/commands/FieldValue.php#L202-L207 | train |
gplcart/cli | controllers/commands/FieldValue.php | FieldValue.wizardAddFieldValue | protected function wizardAddFieldValue()
{
// Required
$this->validatePrompt('title', $this->text('Title'), 'field_value');
$this->validatePrompt('field_id', $this->text('Field ID'), 'field_value');
// Optional
$this->validatePrompt('color', $this->text('Color'), 'field_value', '');
$this->validatePrompt('weight', $this->text('Weight'), 'field_value', 0);
$this->validateComponent('field_value');
$this->addFieldValue();
} | php | protected function wizardAddFieldValue()
{
// Required
$this->validatePrompt('title', $this->text('Title'), 'field_value');
$this->validatePrompt('field_id', $this->text('Field ID'), 'field_value');
// Optional
$this->validatePrompt('color', $this->text('Color'), 'field_value', '');
$this->validatePrompt('weight', $this->text('Weight'), 'field_value', 0);
$this->validateComponent('field_value');
$this->addFieldValue();
} | [
"protected",
"function",
"wizardAddFieldValue",
"(",
")",
"{",
"// Required",
"$",
"this",
"->",
"validatePrompt",
"(",
"'title'",
",",
"$",
"this",
"->",
"text",
"(",
"'Title'",
")",
",",
"'field_value'",
")",
";",
"$",
"this",
"->",
"validatePrompt",
"(",
"'field_id'",
",",
"$",
"this",
"->",
"text",
"(",
"'Field ID'",
")",
",",
"'field_value'",
")",
";",
"// Optional",
"$",
"this",
"->",
"validatePrompt",
"(",
"'color'",
",",
"$",
"this",
"->",
"text",
"(",
"'Color'",
")",
",",
"'field_value'",
",",
"''",
")",
";",
"$",
"this",
"->",
"validatePrompt",
"(",
"'weight'",
",",
"$",
"this",
"->",
"text",
"(",
"'Weight'",
")",
",",
"'field_value'",
",",
"0",
")",
";",
"$",
"this",
"->",
"validateComponent",
"(",
"'field_value'",
")",
";",
"$",
"this",
"->",
"addFieldValue",
"(",
")",
";",
"}"
] | Add a new field value step by step | [
"Add",
"a",
"new",
"field",
"value",
"step",
"by",
"step"
] | e57dba53e291a225b4bff0c0d9b23d685dd1c125 | https://github.com/gplcart/cli/blob/e57dba53e291a225b4bff0c0d9b23d685dd1c125/controllers/commands/FieldValue.php#L212-L224 | train |
Dhii/stringable-helper-base | src/StringableJoinCapableTrait.php | StringableJoinCapableTrait._stringableJoin | protected function _stringableJoin($parts, $delim)
{
$parts = $this->_normalizeIterable($parts);
$i = 0;
$result = '';
foreach ($parts as $_part) {
try {
$_part = $this->_normalizeString($_part);
} catch (InvalidArgumentException $e) {
throw $this->_createOutOfRangeException($this->__('Invalid string part'), null, $e, $_part);
}
if ($i) {
$result .= $delim;
}
$result .= $_part;
++$i;
};
return $result;
} | php | protected function _stringableJoin($parts, $delim)
{
$parts = $this->_normalizeIterable($parts);
$i = 0;
$result = '';
foreach ($parts as $_part) {
try {
$_part = $this->_normalizeString($_part);
} catch (InvalidArgumentException $e) {
throw $this->_createOutOfRangeException($this->__('Invalid string part'), null, $e, $_part);
}
if ($i) {
$result .= $delim;
}
$result .= $_part;
++$i;
};
return $result;
} | [
"protected",
"function",
"_stringableJoin",
"(",
"$",
"parts",
",",
"$",
"delim",
")",
"{",
"$",
"parts",
"=",
"$",
"this",
"->",
"_normalizeIterable",
"(",
"$",
"parts",
")",
";",
"$",
"i",
"=",
"0",
";",
"$",
"result",
"=",
"''",
";",
"foreach",
"(",
"$",
"parts",
"as",
"$",
"_part",
")",
"{",
"try",
"{",
"$",
"_part",
"=",
"$",
"this",
"->",
"_normalizeString",
"(",
"$",
"_part",
")",
";",
"}",
"catch",
"(",
"InvalidArgumentException",
"$",
"e",
")",
"{",
"throw",
"$",
"this",
"->",
"_createOutOfRangeException",
"(",
"$",
"this",
"->",
"__",
"(",
"'Invalid string part'",
")",
",",
"null",
",",
"$",
"e",
",",
"$",
"_part",
")",
";",
"}",
"if",
"(",
"$",
"i",
")",
"{",
"$",
"result",
".=",
"$",
"delim",
";",
"}",
"$",
"result",
".=",
"$",
"_part",
";",
"++",
"$",
"i",
";",
"}",
";",
"return",
"$",
"result",
";",
"}"
] | Joins a list of parts using a delimiter.
@param array|stdClass|Traversable $parts The list of parts to join.
@param string|Stringable $delim The delimiter to use for joining.
@throws InvalidArgumentException If the list of parts or the delimiter is invalid.
@throws OutOfRangeException If one of the parts or the delimiter cannot be normalized to string.
@return string A string consisting of parts joined by delimiter. | [
"Joins",
"a",
"list",
"of",
"parts",
"using",
"a",
"delimiter",
"."
] | 904254409800710665135a751659b59d140a2b40 | https://github.com/Dhii/stringable-helper-base/blob/904254409800710665135a751659b59d140a2b40/src/StringableJoinCapableTrait.php#L30-L51 | train |
Subscribo/dependencyresolver | src/Subscribo/DependencyResolver/DependencyResolver.php | DependencyResolver.reorder | public static function reorder(array $data, array $order, $throwExceptionIfKeyNotFound = false, $throwExceptionIfExtraData = false) {
$result = array();
foreach($order as $orderedKey) {
if (array_key_exists($orderedKey, $data)) {
$result[$orderedKey] = $data[$orderedKey];
unset($data[$orderedKey]);
} elseif ($throwExceptionIfKeyNotFound) {
throw new KeyNotFoundException("Key '".$orderedKey."' not found in data.");
}
}
if (empty($data)) {
return $result;
}
if ($throwExceptionIfExtraData) {
throw new ExtraDataException("Extra data found.");
}
foreach ($data as $key => $value) {
$result[$key] = $value;
}
return $result;
} | php | public static function reorder(array $data, array $order, $throwExceptionIfKeyNotFound = false, $throwExceptionIfExtraData = false) {
$result = array();
foreach($order as $orderedKey) {
if (array_key_exists($orderedKey, $data)) {
$result[$orderedKey] = $data[$orderedKey];
unset($data[$orderedKey]);
} elseif ($throwExceptionIfKeyNotFound) {
throw new KeyNotFoundException("Key '".$orderedKey."' not found in data.");
}
}
if (empty($data)) {
return $result;
}
if ($throwExceptionIfExtraData) {
throw new ExtraDataException("Extra data found.");
}
foreach ($data as $key => $value) {
$result[$key] = $value;
}
return $result;
} | [
"public",
"static",
"function",
"reorder",
"(",
"array",
"$",
"data",
",",
"array",
"$",
"order",
",",
"$",
"throwExceptionIfKeyNotFound",
"=",
"false",
",",
"$",
"throwExceptionIfExtraData",
"=",
"false",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"order",
"as",
"$",
"orderedKey",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"orderedKey",
",",
"$",
"data",
")",
")",
"{",
"$",
"result",
"[",
"$",
"orderedKey",
"]",
"=",
"$",
"data",
"[",
"$",
"orderedKey",
"]",
";",
"unset",
"(",
"$",
"data",
"[",
"$",
"orderedKey",
"]",
")",
";",
"}",
"elseif",
"(",
"$",
"throwExceptionIfKeyNotFound",
")",
"{",
"throw",
"new",
"KeyNotFoundException",
"(",
"\"Key '\"",
".",
"$",
"orderedKey",
".",
"\"' not found in data.\"",
")",
";",
"}",
"}",
"if",
"(",
"empty",
"(",
"$",
"data",
")",
")",
"{",
"return",
"$",
"result",
";",
"}",
"if",
"(",
"$",
"throwExceptionIfExtraData",
")",
"{",
"throw",
"new",
"ExtraDataException",
"(",
"\"Extra data found.\"",
")",
";",
"}",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"result",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Orders data based on order of values in order array
@param array $data
@param array $order
@param bool $throwExceptionIfKeyNotFound
@param bool $throwExceptionIfExtraData
@return array
@throws \Subscribo\DependencyResolver\KeyNotFoundException may be thrown, if key is not found in data
@throws \Subscribo\DependencyResolver\ExtraDataException may be thrown, if data is found, which did not had their counterpart in order parameter | [
"Orders",
"data",
"based",
"on",
"order",
"of",
"values",
"in",
"order",
"array"
] | c345569ca497b6d7e2ade4a93eb19bb535b8b857 | https://github.com/Subscribo/dependencyresolver/blob/c345569ca497b6d7e2ade4a93eb19bb535b8b857/src/Subscribo/DependencyResolver/DependencyResolver.php#L89-L109 | train |
rawphp/RawBase | lib/Model.php | Model.init | public function init( $config = NULL )
{
parent::init( $config );
if ( isset( $config[ 'id' ] ) )
{
$this->id = ( int )$config[ 'id' ];
}
$this->doAction( self::ON_MODEL_INIT_ACTION );
} | php | public function init( $config = NULL )
{
parent::init( $config );
if ( isset( $config[ 'id' ] ) )
{
$this->id = ( int )$config[ 'id' ];
}
$this->doAction( self::ON_MODEL_INIT_ACTION );
} | [
"public",
"function",
"init",
"(",
"$",
"config",
"=",
"NULL",
")",
"{",
"parent",
"::",
"init",
"(",
"$",
"config",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"config",
"[",
"'id'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"id",
"=",
"(",
"int",
")",
"$",
"config",
"[",
"'id'",
"]",
";",
"}",
"$",
"this",
"->",
"doAction",
"(",
"self",
"::",
"ON_MODEL_INIT_ACTION",
")",
";",
"}"
] | Initialises the model.
@param array $config configuration array
@action ON_MODEL_INIT_ACTION | [
"Initialises",
"the",
"model",
"."
] | 509843f6338bbd8323b685d0ed5e80717a54c2ff | https://github.com/rawphp/RawBase/blob/509843f6338bbd8323b685d0ed5e80717a54c2ff/lib/Model.php#L61-L71 | train |
prolic/HumusMvc | src/HumusMvc/Navigation/Service/NavigationFactory.php | NavigationFactory.createService | public function createService(ServiceLocatorInterface $serviceLocator)
{
$config = $serviceLocator->get('Config');
$navigationConfig = $config['navigation'];
$navigation = new Navigation($navigationConfig);
return $navigation;
} | php | public function createService(ServiceLocatorInterface $serviceLocator)
{
$config = $serviceLocator->get('Config');
$navigationConfig = $config['navigation'];
$navigation = new Navigation($navigationConfig);
return $navigation;
} | [
"public",
"function",
"createService",
"(",
"ServiceLocatorInterface",
"$",
"serviceLocator",
")",
"{",
"$",
"config",
"=",
"$",
"serviceLocator",
"->",
"get",
"(",
"'Config'",
")",
";",
"$",
"navigationConfig",
"=",
"$",
"config",
"[",
"'navigation'",
"]",
";",
"$",
"navigation",
"=",
"new",
"Navigation",
"(",
"$",
"navigationConfig",
")",
";",
"return",
"$",
"navigation",
";",
"}"
] | Create navigation service
@param ServiceLocatorInterface $serviceLocator
@return Navigation | [
"Create",
"navigation",
"service"
] | 09e8c6422d84b57745cc643047e10761be2a21a7 | https://github.com/prolic/HumusMvc/blob/09e8c6422d84b57745cc643047e10761be2a21a7/src/HumusMvc/Navigation/Service/NavigationFactory.php#L38-L44 | train |
eureka-framework/component-orm | src/Orm/Column.php | Column.getProperty | public function getProperty()
{
return '
/**
* @var ' . $this->getType()->getType() . ' $' . $this->getPropertyName() . '
*/
protected $' . $this->getPropertyName() . ' = ' . $this->getDefault(true) . ';';
} | php | public function getProperty()
{
return '
/**
* @var ' . $this->getType()->getType() . ' $' . $this->getPropertyName() . '
*/
protected $' . $this->getPropertyName() . ' = ' . $this->getDefault(true) . ';';
} | [
"public",
"function",
"getProperty",
"(",
")",
"{",
"return",
"'\n /**\n * @var '",
".",
"$",
"this",
"->",
"getType",
"(",
")",
"->",
"getType",
"(",
")",
".",
"' $'",
".",
"$",
"this",
"->",
"getPropertyName",
"(",
")",
".",
"'\n */\n protected $'",
".",
"$",
"this",
"->",
"getPropertyName",
"(",
")",
".",
"' = '",
".",
"$",
"this",
"->",
"getDefault",
"(",
"true",
")",
".",
"';'",
";",
"}"
] | Get property declaration.
@return string | [
"Get",
"property",
"declaration",
"."
] | bce48121d26c4e923534f9dc70da597634184316 | https://github.com/eureka-framework/component-orm/blob/bce48121d26c4e923534f9dc70da597634184316/src/Orm/Column.php#L78-L85 | train |
eureka-framework/component-orm | src/Orm/Column.php | Column.getGetter | public function getGetter()
{
return '
/**
* Get value for field "' . $this->getName() . '"
*
* @return ' . $this->getType()->getType() . '
*/
public function ' . $this->getMethodNameGet() . '()
{
return $this->' . $this->getPropertyName() . ';
}';
} | php | public function getGetter()
{
return '
/**
* Get value for field "' . $this->getName() . '"
*
* @return ' . $this->getType()->getType() . '
*/
public function ' . $this->getMethodNameGet() . '()
{
return $this->' . $this->getPropertyName() . ';
}';
} | [
"public",
"function",
"getGetter",
"(",
")",
"{",
"return",
"'\n /**\n * Get value for field \"'",
".",
"$",
"this",
"->",
"getName",
"(",
")",
".",
"'\"\n *\n * @return '",
".",
"$",
"this",
"->",
"getType",
"(",
")",
"->",
"getType",
"(",
")",
".",
"'\n */\n public function '",
".",
"$",
"this",
"->",
"getMethodNameGet",
"(",
")",
".",
"'()\n {\n return $this->'",
".",
"$",
"this",
"->",
"getPropertyName",
"(",
")",
".",
"';\n }'",
";",
"}"
] | Get method getter.
@return string | [
"Get",
"method",
"getter",
"."
] | bce48121d26c4e923534f9dc70da597634184316 | https://github.com/eureka-framework/component-orm/blob/bce48121d26c4e923534f9dc70da597634184316/src/Orm/Column.php#L92-L104 | train |
eureka-framework/component-orm | src/Orm/Column.php | Column.getSetter | public function getSetter()
{
$varname = '$' . $this->getPropertyName();
$autoinc = '';
$cast = $this->getType()->getCastMethod() . ' ';
if ($this->isNullable()) {
$forceCast = $varname . ' = (' . $varname . ' === null ? ' . $varname . ' : ' . $cast . $varname . ');';
} else {
$forceCast = $varname . ' = ' . $cast . $varname . ';';
}
list($forceCheck, $exception) = $this->getCheck();
//~ Prepend with overridden method setAutoIncrementId() for Observer/Subject when we insert new data.
if ($this->isAutoIncrement()) {
$autoinc = '
/**
* Overridden method setAutoIncrementId().
*
* @param ' . $this->getType()->getType() . ' ' . $varname . '
* @return self
*/
public function setAutoIncrementId(' . $varname . ')
{
return $this->' . $this->getMethodNameSet() . '(' . $varname . ');
}';
}
return $autoinc . '
/**
* Set value for field "' . $this->getName() . '"
*
* @param ' . $this->getType()->getType() . ' ' . $varname . '
* @return self' . (!empty($exception) ? "\n * @throws " . $exception : '') . '
*/
public function ' . $this->getMethodNameSet() . '(' . $varname . ')
{
' . $forceCast . (!empty($forceCheck) ? "\n" . $forceCheck . "\n" : '') . '
if ($this->exists() && $this->' . $this->getPropertyName() . ' !== ' . $varname . ') {
$this->updated[\'' . $this->getPropertyName() . '\'] = true;
}
$this->' . $this->getPropertyName() . ' = ' . $varname . ';
return $this;
}';
} | php | public function getSetter()
{
$varname = '$' . $this->getPropertyName();
$autoinc = '';
$cast = $this->getType()->getCastMethod() . ' ';
if ($this->isNullable()) {
$forceCast = $varname . ' = (' . $varname . ' === null ? ' . $varname . ' : ' . $cast . $varname . ');';
} else {
$forceCast = $varname . ' = ' . $cast . $varname . ';';
}
list($forceCheck, $exception) = $this->getCheck();
//~ Prepend with overridden method setAutoIncrementId() for Observer/Subject when we insert new data.
if ($this->isAutoIncrement()) {
$autoinc = '
/**
* Overridden method setAutoIncrementId().
*
* @param ' . $this->getType()->getType() . ' ' . $varname . '
* @return self
*/
public function setAutoIncrementId(' . $varname . ')
{
return $this->' . $this->getMethodNameSet() . '(' . $varname . ');
}';
}
return $autoinc . '
/**
* Set value for field "' . $this->getName() . '"
*
* @param ' . $this->getType()->getType() . ' ' . $varname . '
* @return self' . (!empty($exception) ? "\n * @throws " . $exception : '') . '
*/
public function ' . $this->getMethodNameSet() . '(' . $varname . ')
{
' . $forceCast . (!empty($forceCheck) ? "\n" . $forceCheck . "\n" : '') . '
if ($this->exists() && $this->' . $this->getPropertyName() . ' !== ' . $varname . ') {
$this->updated[\'' . $this->getPropertyName() . '\'] = true;
}
$this->' . $this->getPropertyName() . ' = ' . $varname . ';
return $this;
}';
} | [
"public",
"function",
"getSetter",
"(",
")",
"{",
"$",
"varname",
"=",
"'$'",
".",
"$",
"this",
"->",
"getPropertyName",
"(",
")",
";",
"$",
"autoinc",
"=",
"''",
";",
"$",
"cast",
"=",
"$",
"this",
"->",
"getType",
"(",
")",
"->",
"getCastMethod",
"(",
")",
".",
"' '",
";",
"if",
"(",
"$",
"this",
"->",
"isNullable",
"(",
")",
")",
"{",
"$",
"forceCast",
"=",
"$",
"varname",
".",
"' = ('",
".",
"$",
"varname",
".",
"' === null ? '",
".",
"$",
"varname",
".",
"' : '",
".",
"$",
"cast",
".",
"$",
"varname",
".",
"');'",
";",
"}",
"else",
"{",
"$",
"forceCast",
"=",
"$",
"varname",
".",
"' = '",
".",
"$",
"cast",
".",
"$",
"varname",
".",
"';'",
";",
"}",
"list",
"(",
"$",
"forceCheck",
",",
"$",
"exception",
")",
"=",
"$",
"this",
"->",
"getCheck",
"(",
")",
";",
"//~ Prepend with overridden method setAutoIncrementId() for Observer/Subject when we insert new data.",
"if",
"(",
"$",
"this",
"->",
"isAutoIncrement",
"(",
")",
")",
"{",
"$",
"autoinc",
"=",
"'\n /**\n * Overridden method setAutoIncrementId().\n *\n * @param '",
".",
"$",
"this",
"->",
"getType",
"(",
")",
"->",
"getType",
"(",
")",
".",
"' '",
".",
"$",
"varname",
".",
"'\n * @return self\n */\n public function setAutoIncrementId('",
".",
"$",
"varname",
".",
"')\n {\n return $this->'",
".",
"$",
"this",
"->",
"getMethodNameSet",
"(",
")",
".",
"'('",
".",
"$",
"varname",
".",
"');\n }'",
";",
"}",
"return",
"$",
"autoinc",
".",
"'\n /**\n * Set value for field \"'",
".",
"$",
"this",
"->",
"getName",
"(",
")",
".",
"'\"\n *\n * @param '",
".",
"$",
"this",
"->",
"getType",
"(",
")",
"->",
"getType",
"(",
")",
".",
"' '",
".",
"$",
"varname",
".",
"'\n * @return self'",
".",
"(",
"!",
"empty",
"(",
"$",
"exception",
")",
"?",
"\"\\n * @throws \"",
".",
"$",
"exception",
":",
"''",
")",
".",
"'\n */\n public function '",
".",
"$",
"this",
"->",
"getMethodNameSet",
"(",
")",
".",
"'('",
".",
"$",
"varname",
".",
"')\n {\n '",
".",
"$",
"forceCast",
".",
"(",
"!",
"empty",
"(",
"$",
"forceCheck",
")",
"?",
"\"\\n\"",
".",
"$",
"forceCheck",
".",
"\"\\n\"",
":",
"''",
")",
".",
"'\n\n if ($this->exists() && $this->'",
".",
"$",
"this",
"->",
"getPropertyName",
"(",
")",
".",
"' !== '",
".",
"$",
"varname",
".",
"') {\n $this->updated[\\''",
".",
"$",
"this",
"->",
"getPropertyName",
"(",
")",
".",
"'\\'] = true;\n }\n\n $this->'",
".",
"$",
"this",
"->",
"getPropertyName",
"(",
")",
".",
"' = '",
".",
"$",
"varname",
".",
"';\n\n return $this;\n }'",
";",
"}"
] | Get method setter.
@return string | [
"Get",
"method",
"setter",
"."
] | bce48121d26c4e923534f9dc70da597634184316 | https://github.com/eureka-framework/component-orm/blob/bce48121d26c4e923534f9dc70da597634184316/src/Orm/Column.php#L111-L159 | train |
eureka-framework/component-orm | src/Orm/Column.php | Column.getName | public function getName($withoutPrefix = false)
{
$name = $this->name;
if ($withoutPrefix && stripos($name, $this->dbPrefix) === 0) {
$name = substr($name, strlen($this->dbPrefix));
}
return $name;
} | php | public function getName($withoutPrefix = false)
{
$name = $this->name;
if ($withoutPrefix && stripos($name, $this->dbPrefix) === 0) {
$name = substr($name, strlen($this->dbPrefix));
}
return $name;
} | [
"public",
"function",
"getName",
"(",
"$",
"withoutPrefix",
"=",
"false",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"name",
";",
"if",
"(",
"$",
"withoutPrefix",
"&&",
"stripos",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"dbPrefix",
")",
"===",
"0",
")",
"{",
"$",
"name",
"=",
"substr",
"(",
"$",
"name",
",",
"strlen",
"(",
"$",
"this",
"->",
"dbPrefix",
")",
")",
";",
"}",
"return",
"$",
"name",
";",
"}"
] | Get name.
Can remove table prefix.
@param bool $withoutPrefix
@return string | [
"Get",
"name",
".",
"Can",
"remove",
"table",
"prefix",
"."
] | bce48121d26c4e923534f9dc70da597634184316 | https://github.com/eureka-framework/component-orm/blob/bce48121d26c4e923534f9dc70da597634184316/src/Orm/Column.php#L168-L176 | train |
eureka-framework/component-orm | src/Orm/Column.php | Column.setData | protected function setData(\stdClass $column)
{
$this->setName($column->Field);
$this->setIsPrimaryKey(($column->Key === 'PRI'));
$this->setIsKey(!empty($column->Key));
$this->setType($column->Type);
$this->setIsNullable(($column->Null === 'YES'));
$this->setDefault($column->Default);
$this->setExtra($column->Extra);
return $this;
} | php | protected function setData(\stdClass $column)
{
$this->setName($column->Field);
$this->setIsPrimaryKey(($column->Key === 'PRI'));
$this->setIsKey(!empty($column->Key));
$this->setType($column->Type);
$this->setIsNullable(($column->Null === 'YES'));
$this->setDefault($column->Default);
$this->setExtra($column->Extra);
return $this;
} | [
"protected",
"function",
"setData",
"(",
"\\",
"stdClass",
"$",
"column",
")",
"{",
"$",
"this",
"->",
"setName",
"(",
"$",
"column",
"->",
"Field",
")",
";",
"$",
"this",
"->",
"setIsPrimaryKey",
"(",
"(",
"$",
"column",
"->",
"Key",
"===",
"'PRI'",
")",
")",
";",
"$",
"this",
"->",
"setIsKey",
"(",
"!",
"empty",
"(",
"$",
"column",
"->",
"Key",
")",
")",
";",
"$",
"this",
"->",
"setType",
"(",
"$",
"column",
"->",
"Type",
")",
";",
"$",
"this",
"->",
"setIsNullable",
"(",
"(",
"$",
"column",
"->",
"Null",
"===",
"'YES'",
")",
")",
";",
"$",
"this",
"->",
"setDefault",
"(",
"$",
"column",
"->",
"Default",
")",
";",
"$",
"this",
"->",
"setExtra",
"(",
"$",
"column",
"->",
"Extra",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Set column data from db query
@param \stdClass $column
@return self | [
"Set",
"column",
"data",
"from",
"db",
"query"
] | bce48121d26c4e923534f9dc70da597634184316 | https://github.com/eureka-framework/component-orm/blob/bce48121d26c4e923534f9dc70da597634184316/src/Orm/Column.php#L264-L275 | train |
eureka-framework/component-orm | src/Orm/Column.php | Column.getMethodNameGet | public function getMethodNameGet()
{
$methodName = str_replace(' ', '', ucwords(str_replace(array(
'_is_', '_has_', '_in_', '_',
), ' ', strtolower($this->getName(true)))));
$type = $this->getType();
switch (true) {
case ($type instanceof Type\TypeBool) && stripos($this->getName(), '_has_') !== false:
$methodPrefix = 'has';
break;
case ($type instanceof Type\TypeBool) && stripos($this->getName(), '_is_') !== false:
$methodPrefix = 'is';
break;
case ($type instanceof Type\TypeBool) && stripos($this->getName(), '_in_') !== false:
$methodPrefix = 'in';
break;
default:
$methodPrefix = 'get';
break;
}
return $methodPrefix . $methodName;
} | php | public function getMethodNameGet()
{
$methodName = str_replace(' ', '', ucwords(str_replace(array(
'_is_', '_has_', '_in_', '_',
), ' ', strtolower($this->getName(true)))));
$type = $this->getType();
switch (true) {
case ($type instanceof Type\TypeBool) && stripos($this->getName(), '_has_') !== false:
$methodPrefix = 'has';
break;
case ($type instanceof Type\TypeBool) && stripos($this->getName(), '_is_') !== false:
$methodPrefix = 'is';
break;
case ($type instanceof Type\TypeBool) && stripos($this->getName(), '_in_') !== false:
$methodPrefix = 'in';
break;
default:
$methodPrefix = 'get';
break;
}
return $methodPrefix . $methodName;
} | [
"public",
"function",
"getMethodNameGet",
"(",
")",
"{",
"$",
"methodName",
"=",
"str_replace",
"(",
"' '",
",",
"''",
",",
"ucwords",
"(",
"str_replace",
"(",
"array",
"(",
"'_is_'",
",",
"'_has_'",
",",
"'_in_'",
",",
"'_'",
",",
")",
",",
"' '",
",",
"strtolower",
"(",
"$",
"this",
"->",
"getName",
"(",
"true",
")",
")",
")",
")",
")",
";",
"$",
"type",
"=",
"$",
"this",
"->",
"getType",
"(",
")",
";",
"switch",
"(",
"true",
")",
"{",
"case",
"(",
"$",
"type",
"instanceof",
"Type",
"\\",
"TypeBool",
")",
"&&",
"stripos",
"(",
"$",
"this",
"->",
"getName",
"(",
")",
",",
"'_has_'",
")",
"!==",
"false",
":",
"$",
"methodPrefix",
"=",
"'has'",
";",
"break",
";",
"case",
"(",
"$",
"type",
"instanceof",
"Type",
"\\",
"TypeBool",
")",
"&&",
"stripos",
"(",
"$",
"this",
"->",
"getName",
"(",
")",
",",
"'_is_'",
")",
"!==",
"false",
":",
"$",
"methodPrefix",
"=",
"'is'",
";",
"break",
";",
"case",
"(",
"$",
"type",
"instanceof",
"Type",
"\\",
"TypeBool",
")",
"&&",
"stripos",
"(",
"$",
"this",
"->",
"getName",
"(",
")",
",",
"'_in_'",
")",
"!==",
"false",
":",
"$",
"methodPrefix",
"=",
"'in'",
";",
"break",
";",
"default",
":",
"$",
"methodPrefix",
"=",
"'get'",
";",
"break",
";",
"}",
"return",
"$",
"methodPrefix",
".",
"$",
"methodName",
";",
"}"
] | Get method name for getter.
@return string | [
"Get",
"method",
"name",
"for",
"getter",
"."
] | bce48121d26c4e923534f9dc70da597634184316 | https://github.com/eureka-framework/component-orm/blob/bce48121d26c4e923534f9dc70da597634184316/src/Orm/Column.php#L302-L326 | train |
eureka-framework/component-orm | src/Orm/Column.php | Column.setExtra | protected function setExtra($extra)
{
if (empty($extra)) {
return $this;
}
switch ($extra) {
case 'auto_increment':
$this->isAutoIncrement = true;
break;
}
return $this;
} | php | protected function setExtra($extra)
{
if (empty($extra)) {
return $this;
}
switch ($extra) {
case 'auto_increment':
$this->isAutoIncrement = true;
break;
}
return $this;
} | [
"protected",
"function",
"setExtra",
"(",
"$",
"extra",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"extra",
")",
")",
"{",
"return",
"$",
"this",
";",
"}",
"switch",
"(",
"$",
"extra",
")",
"{",
"case",
"'auto_increment'",
":",
"$",
"this",
"->",
"isAutoIncrement",
"=",
"true",
";",
"break",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Set extra info.
@param string $extra
@return self | [
"Set",
"extra",
"info",
"."
] | bce48121d26c4e923534f9dc70da597634184316 | https://github.com/eureka-framework/component-orm/blob/bce48121d26c4e923534f9dc70da597634184316/src/Orm/Column.php#L430-L443 | train |
eureka-framework/component-orm | src/Orm/Column.php | Column.getCheck | protected function getCheck()
{
$check = array(0 => '', 1 => '');
$type = $this->getType();
switch ($type->getType()) {
case 'int':
case 'float':
if ($type->isUnsigned()) {
$check[1] = '\UnderflowException';
$check[0] = '
if ($this->' . $this->getPropertyName() . ' < 0) {
throw new \UnderflowException(\'Value of "' . $this->getPropertyName() . '" must be greater than 0\');
}';
}
break;
}
return $check;
} | php | protected function getCheck()
{
$check = array(0 => '', 1 => '');
$type = $this->getType();
switch ($type->getType()) {
case 'int':
case 'float':
if ($type->isUnsigned()) {
$check[1] = '\UnderflowException';
$check[0] = '
if ($this->' . $this->getPropertyName() . ' < 0) {
throw new \UnderflowException(\'Value of "' . $this->getPropertyName() . '" must be greater than 0\');
}';
}
break;
}
return $check;
} | [
"protected",
"function",
"getCheck",
"(",
")",
"{",
"$",
"check",
"=",
"array",
"(",
"0",
"=>",
"''",
",",
"1",
"=>",
"''",
")",
";",
"$",
"type",
"=",
"$",
"this",
"->",
"getType",
"(",
")",
";",
"switch",
"(",
"$",
"type",
"->",
"getType",
"(",
")",
")",
"{",
"case",
"'int'",
":",
"case",
"'float'",
":",
"if",
"(",
"$",
"type",
"->",
"isUnsigned",
"(",
")",
")",
"{",
"$",
"check",
"[",
"1",
"]",
"=",
"'\\UnderflowException'",
";",
"$",
"check",
"[",
"0",
"]",
"=",
"'\n if ($this->'",
".",
"$",
"this",
"->",
"getPropertyName",
"(",
")",
".",
"' < 0) {\n throw new \\UnderflowException(\\'Value of \"'",
".",
"$",
"this",
"->",
"getPropertyName",
"(",
")",
".",
"'\" must be greater than 0\\');\n }'",
";",
"}",
"break",
";",
"}",
"return",
"$",
"check",
";",
"}"
] | Get check condition for numeric values & underflow if necessary.
@return string | [
"Get",
"check",
"condition",
"for",
"numeric",
"values",
"&",
"underflow",
"if",
"necessary",
"."
] | bce48121d26c4e923534f9dc70da597634184316 | https://github.com/eureka-framework/component-orm/blob/bce48121d26c4e923534f9dc70da597634184316/src/Orm/Column.php#L450-L469 | train |
SimpleAPI/Core | sources/Router.php | Router.run | public function run($url = null, $method = null)
{
$route = $this->altoRouter->match($url, $method);
if (!$route) {
throw new NotFoundException(((isset($_SERVER['REQUEST_URI']) && !empty($_SERVER['REQUEST_URI'])) ? $_SERVER['REQUEST_URI'] : (($url != null) ? $url : "/")) . " is not reachable.");
}
if (!isset($route['target']['c']) || !isset($route['target']['a']) || !isset($route['params'])) {
throw new FrameworkException('Internal Framework Error. [!BAD_ROUTER_TARGET]', 001);
}
if (is_callable(array($route['target']['c'], 'getInstance'))) {
$controller = $route['target']['c']::getInstance();
if (method_exists($controller, $route['target']['a'])) {
call_user_func(array($controller, $route['target']['a']), array_values($route['params']));
$controller->response->send();
} else {
throw new FrameworkException('Internal Framework Error. [METHOD_DOES_NOT_EXISTS]', 002);
}
} else {
throw new FrameworkException('Internal Framework Error. [CONTROLLER_DOES_NOT_EXISTS]', 003);
}
} | php | public function run($url = null, $method = null)
{
$route = $this->altoRouter->match($url, $method);
if (!$route) {
throw new NotFoundException(((isset($_SERVER['REQUEST_URI']) && !empty($_SERVER['REQUEST_URI'])) ? $_SERVER['REQUEST_URI'] : (($url != null) ? $url : "/")) . " is not reachable.");
}
if (!isset($route['target']['c']) || !isset($route['target']['a']) || !isset($route['params'])) {
throw new FrameworkException('Internal Framework Error. [!BAD_ROUTER_TARGET]', 001);
}
if (is_callable(array($route['target']['c'], 'getInstance'))) {
$controller = $route['target']['c']::getInstance();
if (method_exists($controller, $route['target']['a'])) {
call_user_func(array($controller, $route['target']['a']), array_values($route['params']));
$controller->response->send();
} else {
throw new FrameworkException('Internal Framework Error. [METHOD_DOES_NOT_EXISTS]', 002);
}
} else {
throw new FrameworkException('Internal Framework Error. [CONTROLLER_DOES_NOT_EXISTS]', 003);
}
} | [
"public",
"function",
"run",
"(",
"$",
"url",
"=",
"null",
",",
"$",
"method",
"=",
"null",
")",
"{",
"$",
"route",
"=",
"$",
"this",
"->",
"altoRouter",
"->",
"match",
"(",
"$",
"url",
",",
"$",
"method",
")",
";",
"if",
"(",
"!",
"$",
"route",
")",
"{",
"throw",
"new",
"NotFoundException",
"(",
"(",
"(",
"isset",
"(",
"$",
"_SERVER",
"[",
"'REQUEST_URI'",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"_SERVER",
"[",
"'REQUEST_URI'",
"]",
")",
")",
"?",
"$",
"_SERVER",
"[",
"'REQUEST_URI'",
"]",
":",
"(",
"(",
"$",
"url",
"!=",
"null",
")",
"?",
"$",
"url",
":",
"\"/\"",
")",
")",
".",
"\" is not reachable.\"",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"route",
"[",
"'target'",
"]",
"[",
"'c'",
"]",
")",
"||",
"!",
"isset",
"(",
"$",
"route",
"[",
"'target'",
"]",
"[",
"'a'",
"]",
")",
"||",
"!",
"isset",
"(",
"$",
"route",
"[",
"'params'",
"]",
")",
")",
"{",
"throw",
"new",
"FrameworkException",
"(",
"'Internal Framework Error. [!BAD_ROUTER_TARGET]'",
",",
"001",
")",
";",
"}",
"if",
"(",
"is_callable",
"(",
"array",
"(",
"$",
"route",
"[",
"'target'",
"]",
"[",
"'c'",
"]",
",",
"'getInstance'",
")",
")",
")",
"{",
"$",
"controller",
"=",
"$",
"route",
"[",
"'target'",
"]",
"[",
"'c'",
"]",
"::",
"getInstance",
"(",
")",
";",
"if",
"(",
"method_exists",
"(",
"$",
"controller",
",",
"$",
"route",
"[",
"'target'",
"]",
"[",
"'a'",
"]",
")",
")",
"{",
"call_user_func",
"(",
"array",
"(",
"$",
"controller",
",",
"$",
"route",
"[",
"'target'",
"]",
"[",
"'a'",
"]",
")",
",",
"array_values",
"(",
"$",
"route",
"[",
"'params'",
"]",
")",
")",
";",
"$",
"controller",
"->",
"response",
"->",
"send",
"(",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"FrameworkException",
"(",
"'Internal Framework Error. [METHOD_DOES_NOT_EXISTS]'",
",",
"002",
")",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"FrameworkException",
"(",
"'Internal Framework Error. [CONTROLLER_DOES_NOT_EXISTS]'",
",",
"003",
")",
";",
"}",
"}"
] | This function runs the router and call the apropriate | [
"This",
"function",
"runs",
"the",
"router",
"and",
"call",
"the",
"apropriate"
] | 4545f1e8f2242832d4b3dc9bb59541a086a01188 | https://github.com/SimpleAPI/Core/blob/4545f1e8f2242832d4b3dc9bb59541a086a01188/sources/Router.php#L94-L114 | train |
attogram/shared-media-orm | src/Attogram/SharedMedia/Orm/Base/CategoryQuery.php | CategoryQuery.filterByFiles | public function filterByFiles($files = null, $comparison = null)
{
if (is_array($files)) {
$useMinMax = false;
if (isset($files['min'])) {
$this->addUsingAlias(CategoryTableMap::COL_FILES, $files['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($files['max'])) {
$this->addUsingAlias(CategoryTableMap::COL_FILES, $files['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CategoryTableMap::COL_FILES, $files, $comparison);
} | php | public function filterByFiles($files = null, $comparison = null)
{
if (is_array($files)) {
$useMinMax = false;
if (isset($files['min'])) {
$this->addUsingAlias(CategoryTableMap::COL_FILES, $files['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($files['max'])) {
$this->addUsingAlias(CategoryTableMap::COL_FILES, $files['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CategoryTableMap::COL_FILES, $files, $comparison);
} | [
"public",
"function",
"filterByFiles",
"(",
"$",
"files",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"files",
")",
")",
"{",
"$",
"useMinMax",
"=",
"false",
";",
"if",
"(",
"isset",
"(",
"$",
"files",
"[",
"'min'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"addUsingAlias",
"(",
"CategoryTableMap",
"::",
"COL_FILES",
",",
"$",
"files",
"[",
"'min'",
"]",
",",
"Criteria",
"::",
"GREATER_EQUAL",
")",
";",
"$",
"useMinMax",
"=",
"true",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"files",
"[",
"'max'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"addUsingAlias",
"(",
"CategoryTableMap",
"::",
"COL_FILES",
",",
"$",
"files",
"[",
"'max'",
"]",
",",
"Criteria",
"::",
"LESS_EQUAL",
")",
";",
"$",
"useMinMax",
"=",
"true",
";",
"}",
"if",
"(",
"$",
"useMinMax",
")",
"{",
"return",
"$",
"this",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"CategoryTableMap",
"::",
"COL_FILES",
",",
"$",
"files",
",",
"$",
"comparison",
")",
";",
"}"
] | Filter the query on the files column
Example usage:
<code>
$query->filterByFiles(1234); // WHERE files = 1234
$query->filterByFiles(array(12, 34)); // WHERE files IN (12, 34)
$query->filterByFiles(array('min' => 12)); // WHERE files > 12
</code>
@param mixed $files The value to use as filter.
Use scalar values for equality.
Use array values for in_array() equivalent.
Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return $this|ChildCategoryQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"files",
"column"
] | 81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8 | https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Base/CategoryQuery.php#L501-L522 | train |
attogram/shared-media-orm | src/Attogram/SharedMedia/Orm/Base/CategoryQuery.php | CategoryQuery.filterBySubcats | public function filterBySubcats($subcats = null, $comparison = null)
{
if (is_array($subcats)) {
$useMinMax = false;
if (isset($subcats['min'])) {
$this->addUsingAlias(CategoryTableMap::COL_SUBCATS, $subcats['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($subcats['max'])) {
$this->addUsingAlias(CategoryTableMap::COL_SUBCATS, $subcats['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CategoryTableMap::COL_SUBCATS, $subcats, $comparison);
} | php | public function filterBySubcats($subcats = null, $comparison = null)
{
if (is_array($subcats)) {
$useMinMax = false;
if (isset($subcats['min'])) {
$this->addUsingAlias(CategoryTableMap::COL_SUBCATS, $subcats['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($subcats['max'])) {
$this->addUsingAlias(CategoryTableMap::COL_SUBCATS, $subcats['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CategoryTableMap::COL_SUBCATS, $subcats, $comparison);
} | [
"public",
"function",
"filterBySubcats",
"(",
"$",
"subcats",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"subcats",
")",
")",
"{",
"$",
"useMinMax",
"=",
"false",
";",
"if",
"(",
"isset",
"(",
"$",
"subcats",
"[",
"'min'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"addUsingAlias",
"(",
"CategoryTableMap",
"::",
"COL_SUBCATS",
",",
"$",
"subcats",
"[",
"'min'",
"]",
",",
"Criteria",
"::",
"GREATER_EQUAL",
")",
";",
"$",
"useMinMax",
"=",
"true",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"subcats",
"[",
"'max'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"addUsingAlias",
"(",
"CategoryTableMap",
"::",
"COL_SUBCATS",
",",
"$",
"subcats",
"[",
"'max'",
"]",
",",
"Criteria",
"::",
"LESS_EQUAL",
")",
";",
"$",
"useMinMax",
"=",
"true",
";",
"}",
"if",
"(",
"$",
"useMinMax",
")",
"{",
"return",
"$",
"this",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"CategoryTableMap",
"::",
"COL_SUBCATS",
",",
"$",
"subcats",
",",
"$",
"comparison",
")",
";",
"}"
] | Filter the query on the subcats column
Example usage:
<code>
$query->filterBySubcats(1234); // WHERE subcats = 1234
$query->filterBySubcats(array(12, 34)); // WHERE subcats IN (12, 34)
$query->filterBySubcats(array('min' => 12)); // WHERE subcats > 12
</code>
@param mixed $subcats The value to use as filter.
Use scalar values for equality.
Use array values for in_array() equivalent.
Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return $this|ChildCategoryQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"subcats",
"column"
] | 81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8 | https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Base/CategoryQuery.php#L542-L563 | train |
attogram/shared-media-orm | src/Attogram/SharedMedia/Orm/Base/CategoryQuery.php | CategoryQuery.filterBySize | public function filterBySize($size = null, $comparison = null)
{
if (is_array($size)) {
$useMinMax = false;
if (isset($size['min'])) {
$this->addUsingAlias(CategoryTableMap::COL_SIZE, $size['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($size['max'])) {
$this->addUsingAlias(CategoryTableMap::COL_SIZE, $size['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CategoryTableMap::COL_SIZE, $size, $comparison);
} | php | public function filterBySize($size = null, $comparison = null)
{
if (is_array($size)) {
$useMinMax = false;
if (isset($size['min'])) {
$this->addUsingAlias(CategoryTableMap::COL_SIZE, $size['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($size['max'])) {
$this->addUsingAlias(CategoryTableMap::COL_SIZE, $size['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CategoryTableMap::COL_SIZE, $size, $comparison);
} | [
"public",
"function",
"filterBySize",
"(",
"$",
"size",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"size",
")",
")",
"{",
"$",
"useMinMax",
"=",
"false",
";",
"if",
"(",
"isset",
"(",
"$",
"size",
"[",
"'min'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"addUsingAlias",
"(",
"CategoryTableMap",
"::",
"COL_SIZE",
",",
"$",
"size",
"[",
"'min'",
"]",
",",
"Criteria",
"::",
"GREATER_EQUAL",
")",
";",
"$",
"useMinMax",
"=",
"true",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"size",
"[",
"'max'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"addUsingAlias",
"(",
"CategoryTableMap",
"::",
"COL_SIZE",
",",
"$",
"size",
"[",
"'max'",
"]",
",",
"Criteria",
"::",
"LESS_EQUAL",
")",
";",
"$",
"useMinMax",
"=",
"true",
";",
"}",
"if",
"(",
"$",
"useMinMax",
")",
"{",
"return",
"$",
"this",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"CategoryTableMap",
"::",
"COL_SIZE",
",",
"$",
"size",
",",
"$",
"comparison",
")",
";",
"}"
] | Filter the query on the size column
Example usage:
<code>
$query->filterBySize(1234); // WHERE size = 1234
$query->filterBySize(array(12, 34)); // WHERE size IN (12, 34)
$query->filterBySize(array('min' => 12)); // WHERE size > 12
</code>
@param mixed $size The value to use as filter.
Use scalar values for equality.
Use array values for in_array() equivalent.
Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return $this|ChildCategoryQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"size",
"column"
] | 81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8 | https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Base/CategoryQuery.php#L624-L645 | train |
attogram/shared-media-orm | src/Attogram/SharedMedia/Orm/Base/CategoryQuery.php | CategoryQuery.filterByHidden | public function filterByHidden($hidden = null, $comparison = null)
{
if (is_string($hidden)) {
$hidden = in_array(strtolower($hidden), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
}
return $this->addUsingAlias(CategoryTableMap::COL_HIDDEN, $hidden, $comparison);
} | php | public function filterByHidden($hidden = null, $comparison = null)
{
if (is_string($hidden)) {
$hidden = in_array(strtolower($hidden), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
}
return $this->addUsingAlias(CategoryTableMap::COL_HIDDEN, $hidden, $comparison);
} | [
"public",
"function",
"filterByHidden",
"(",
"$",
"hidden",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"hidden",
")",
")",
"{",
"$",
"hidden",
"=",
"in_array",
"(",
"strtolower",
"(",
"$",
"hidden",
")",
",",
"array",
"(",
"'false'",
",",
"'off'",
",",
"'-'",
",",
"'no'",
",",
"'n'",
",",
"'0'",
",",
"''",
")",
")",
"?",
"false",
":",
"true",
";",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"CategoryTableMap",
"::",
"COL_HIDDEN",
",",
"$",
"hidden",
",",
"$",
"comparison",
")",
";",
"}"
] | Filter the query on the hidden column
Example usage:
<code>
$query->filterByHidden(true); // WHERE hidden = true
$query->filterByHidden('yes'); // WHERE hidden = true
</code>
@param boolean|string $hidden The value to use as filter.
Non-boolean arguments are converted using the following rules:
* 1, '1', 'true', 'on', and 'yes' are converted to boolean true
* 0, '0', 'false', 'off', and 'no' are converted to boolean false
Check on string values is case insensitive (so 'FaLsE' is seen as 'false').
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return $this|ChildCategoryQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"hidden",
"column"
] | 81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8 | https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Base/CategoryQuery.php#L665-L672 | train |
attogram/shared-media-orm | src/Attogram/SharedMedia/Orm/Base/CategoryQuery.php | CategoryQuery.filterByTreeLeft | public function filterByTreeLeft($treeLeft = null, $comparison = null)
{
if (is_array($treeLeft)) {
$useMinMax = false;
if (isset($treeLeft['min'])) {
$this->addUsingAlias(CategoryTableMap::COL_TREE_LEFT, $treeLeft['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($treeLeft['max'])) {
$this->addUsingAlias(CategoryTableMap::COL_TREE_LEFT, $treeLeft['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CategoryTableMap::COL_TREE_LEFT, $treeLeft, $comparison);
} | php | public function filterByTreeLeft($treeLeft = null, $comparison = null)
{
if (is_array($treeLeft)) {
$useMinMax = false;
if (isset($treeLeft['min'])) {
$this->addUsingAlias(CategoryTableMap::COL_TREE_LEFT, $treeLeft['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($treeLeft['max'])) {
$this->addUsingAlias(CategoryTableMap::COL_TREE_LEFT, $treeLeft['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CategoryTableMap::COL_TREE_LEFT, $treeLeft, $comparison);
} | [
"public",
"function",
"filterByTreeLeft",
"(",
"$",
"treeLeft",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"treeLeft",
")",
")",
"{",
"$",
"useMinMax",
"=",
"false",
";",
"if",
"(",
"isset",
"(",
"$",
"treeLeft",
"[",
"'min'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"addUsingAlias",
"(",
"CategoryTableMap",
"::",
"COL_TREE_LEFT",
",",
"$",
"treeLeft",
"[",
"'min'",
"]",
",",
"Criteria",
"::",
"GREATER_EQUAL",
")",
";",
"$",
"useMinMax",
"=",
"true",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"treeLeft",
"[",
"'max'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"addUsingAlias",
"(",
"CategoryTableMap",
"::",
"COL_TREE_LEFT",
",",
"$",
"treeLeft",
"[",
"'max'",
"]",
",",
"Criteria",
"::",
"LESS_EQUAL",
")",
";",
"$",
"useMinMax",
"=",
"true",
";",
"}",
"if",
"(",
"$",
"useMinMax",
")",
"{",
"return",
"$",
"this",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"CategoryTableMap",
"::",
"COL_TREE_LEFT",
",",
"$",
"treeLeft",
",",
"$",
"comparison",
")",
";",
"}"
] | Filter the query on the tree_left column
Example usage:
<code>
$query->filterByTreeLeft(1234); // WHERE tree_left = 1234
$query->filterByTreeLeft(array(12, 34)); // WHERE tree_left IN (12, 34)
$query->filterByTreeLeft(array('min' => 12)); // WHERE tree_left > 12
</code>
@param mixed $treeLeft The value to use as filter.
Use scalar values for equality.
Use array values for in_array() equivalent.
Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return $this|ChildCategoryQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"tree_left",
"column"
] | 81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8 | https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Base/CategoryQuery.php#L778-L799 | train |
attogram/shared-media-orm | src/Attogram/SharedMedia/Orm/Base/CategoryQuery.php | CategoryQuery.filterByTreeRight | public function filterByTreeRight($treeRight = null, $comparison = null)
{
if (is_array($treeRight)) {
$useMinMax = false;
if (isset($treeRight['min'])) {
$this->addUsingAlias(CategoryTableMap::COL_TREE_RIGHT, $treeRight['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($treeRight['max'])) {
$this->addUsingAlias(CategoryTableMap::COL_TREE_RIGHT, $treeRight['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CategoryTableMap::COL_TREE_RIGHT, $treeRight, $comparison);
} | php | public function filterByTreeRight($treeRight = null, $comparison = null)
{
if (is_array($treeRight)) {
$useMinMax = false;
if (isset($treeRight['min'])) {
$this->addUsingAlias(CategoryTableMap::COL_TREE_RIGHT, $treeRight['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($treeRight['max'])) {
$this->addUsingAlias(CategoryTableMap::COL_TREE_RIGHT, $treeRight['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CategoryTableMap::COL_TREE_RIGHT, $treeRight, $comparison);
} | [
"public",
"function",
"filterByTreeRight",
"(",
"$",
"treeRight",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"treeRight",
")",
")",
"{",
"$",
"useMinMax",
"=",
"false",
";",
"if",
"(",
"isset",
"(",
"$",
"treeRight",
"[",
"'min'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"addUsingAlias",
"(",
"CategoryTableMap",
"::",
"COL_TREE_RIGHT",
",",
"$",
"treeRight",
"[",
"'min'",
"]",
",",
"Criteria",
"::",
"GREATER_EQUAL",
")",
";",
"$",
"useMinMax",
"=",
"true",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"treeRight",
"[",
"'max'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"addUsingAlias",
"(",
"CategoryTableMap",
"::",
"COL_TREE_RIGHT",
",",
"$",
"treeRight",
"[",
"'max'",
"]",
",",
"Criteria",
"::",
"LESS_EQUAL",
")",
";",
"$",
"useMinMax",
"=",
"true",
";",
"}",
"if",
"(",
"$",
"useMinMax",
")",
"{",
"return",
"$",
"this",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"CategoryTableMap",
"::",
"COL_TREE_RIGHT",
",",
"$",
"treeRight",
",",
"$",
"comparison",
")",
";",
"}"
] | Filter the query on the tree_right column
Example usage:
<code>
$query->filterByTreeRight(1234); // WHERE tree_right = 1234
$query->filterByTreeRight(array(12, 34)); // WHERE tree_right IN (12, 34)
$query->filterByTreeRight(array('min' => 12)); // WHERE tree_right > 12
</code>
@param mixed $treeRight The value to use as filter.
Use scalar values for equality.
Use array values for in_array() equivalent.
Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return $this|ChildCategoryQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"tree_right",
"column"
] | 81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8 | https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Base/CategoryQuery.php#L819-L840 | train |
attogram/shared-media-orm | src/Attogram/SharedMedia/Orm/Base/CategoryQuery.php | CategoryQuery.filterByTreeLevel | public function filterByTreeLevel($treeLevel = null, $comparison = null)
{
if (is_array($treeLevel)) {
$useMinMax = false;
if (isset($treeLevel['min'])) {
$this->addUsingAlias(CategoryTableMap::COL_TREE_LEVEL, $treeLevel['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($treeLevel['max'])) {
$this->addUsingAlias(CategoryTableMap::COL_TREE_LEVEL, $treeLevel['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CategoryTableMap::COL_TREE_LEVEL, $treeLevel, $comparison);
} | php | public function filterByTreeLevel($treeLevel = null, $comparison = null)
{
if (is_array($treeLevel)) {
$useMinMax = false;
if (isset($treeLevel['min'])) {
$this->addUsingAlias(CategoryTableMap::COL_TREE_LEVEL, $treeLevel['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($treeLevel['max'])) {
$this->addUsingAlias(CategoryTableMap::COL_TREE_LEVEL, $treeLevel['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CategoryTableMap::COL_TREE_LEVEL, $treeLevel, $comparison);
} | [
"public",
"function",
"filterByTreeLevel",
"(",
"$",
"treeLevel",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"treeLevel",
")",
")",
"{",
"$",
"useMinMax",
"=",
"false",
";",
"if",
"(",
"isset",
"(",
"$",
"treeLevel",
"[",
"'min'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"addUsingAlias",
"(",
"CategoryTableMap",
"::",
"COL_TREE_LEVEL",
",",
"$",
"treeLevel",
"[",
"'min'",
"]",
",",
"Criteria",
"::",
"GREATER_EQUAL",
")",
";",
"$",
"useMinMax",
"=",
"true",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"treeLevel",
"[",
"'max'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"addUsingAlias",
"(",
"CategoryTableMap",
"::",
"COL_TREE_LEVEL",
",",
"$",
"treeLevel",
"[",
"'max'",
"]",
",",
"Criteria",
"::",
"LESS_EQUAL",
")",
";",
"$",
"useMinMax",
"=",
"true",
";",
"}",
"if",
"(",
"$",
"useMinMax",
")",
"{",
"return",
"$",
"this",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"CategoryTableMap",
"::",
"COL_TREE_LEVEL",
",",
"$",
"treeLevel",
",",
"$",
"comparison",
")",
";",
"}"
] | Filter the query on the tree_level column
Example usage:
<code>
$query->filterByTreeLevel(1234); // WHERE tree_level = 1234
$query->filterByTreeLevel(array(12, 34)); // WHERE tree_level IN (12, 34)
$query->filterByTreeLevel(array('min' => 12)); // WHERE tree_level > 12
</code>
@param mixed $treeLevel The value to use as filter.
Use scalar values for equality.
Use array values for in_array() equivalent.
Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return $this|ChildCategoryQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"tree_level",
"column"
] | 81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8 | https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Base/CategoryQuery.php#L860-L881 | train |
attogram/shared-media-orm | src/Attogram/SharedMedia/Orm/Base/CategoryQuery.php | CategoryQuery.filterBySource | public function filterBySource($source, $comparison = null)
{
if ($source instanceof \Attogram\SharedMedia\Orm\Source) {
return $this
->addUsingAlias(CategoryTableMap::COL_SOURCE_ID, $source->getId(), $comparison);
} elseif ($source instanceof ObjectCollection) {
if (null === $comparison) {
$comparison = Criteria::IN;
}
return $this
->addUsingAlias(CategoryTableMap::COL_SOURCE_ID, $source->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterBySource() only accepts arguments of type \Attogram\SharedMedia\Orm\Source or Collection');
}
} | php | public function filterBySource($source, $comparison = null)
{
if ($source instanceof \Attogram\SharedMedia\Orm\Source) {
return $this
->addUsingAlias(CategoryTableMap::COL_SOURCE_ID, $source->getId(), $comparison);
} elseif ($source instanceof ObjectCollection) {
if (null === $comparison) {
$comparison = Criteria::IN;
}
return $this
->addUsingAlias(CategoryTableMap::COL_SOURCE_ID, $source->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterBySource() only accepts arguments of type \Attogram\SharedMedia\Orm\Source or Collection');
}
} | [
"public",
"function",
"filterBySource",
"(",
"$",
"source",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"source",
"instanceof",
"\\",
"Attogram",
"\\",
"SharedMedia",
"\\",
"Orm",
"\\",
"Source",
")",
"{",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"CategoryTableMap",
"::",
"COL_SOURCE_ID",
",",
"$",
"source",
"->",
"getId",
"(",
")",
",",
"$",
"comparison",
")",
";",
"}",
"elseif",
"(",
"$",
"source",
"instanceof",
"ObjectCollection",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"CategoryTableMap",
"::",
"COL_SOURCE_ID",
",",
"$",
"source",
"->",
"toKeyValue",
"(",
"'PrimaryKey'",
",",
"'Id'",
")",
",",
"$",
"comparison",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"PropelException",
"(",
"'filterBySource() only accepts arguments of type \\Attogram\\SharedMedia\\Orm\\Source or Collection'",
")",
";",
"}",
"}"
] | Filter the query by a related \Attogram\SharedMedia\Orm\Source object
@param \Attogram\SharedMedia\Orm\Source|ObjectCollection $source The related object(s) to use as filter
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@throws \Propel\Runtime\Exception\PropelException
@return ChildCategoryQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"by",
"a",
"related",
"\\",
"Attogram",
"\\",
"SharedMedia",
"\\",
"Orm",
"\\",
"Source",
"object"
] | 81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8 | https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Base/CategoryQuery.php#L893-L908 | train |
attogram/shared-media-orm | src/Attogram/SharedMedia/Orm/Base/CategoryQuery.php | CategoryQuery.filterByC2M | public function filterByC2M($c2M, $comparison = null)
{
if ($c2M instanceof \Attogram\SharedMedia\Orm\C2M) {
return $this
->addUsingAlias(CategoryTableMap::COL_ID, $c2M->getCategoryId(), $comparison);
} elseif ($c2M instanceof ObjectCollection) {
return $this
->useC2MQuery()
->filterByPrimaryKeys($c2M->getPrimaryKeys())
->endUse();
} else {
throw new PropelException('filterByC2M() only accepts arguments of type \Attogram\SharedMedia\Orm\C2M or Collection');
}
} | php | public function filterByC2M($c2M, $comparison = null)
{
if ($c2M instanceof \Attogram\SharedMedia\Orm\C2M) {
return $this
->addUsingAlias(CategoryTableMap::COL_ID, $c2M->getCategoryId(), $comparison);
} elseif ($c2M instanceof ObjectCollection) {
return $this
->useC2MQuery()
->filterByPrimaryKeys($c2M->getPrimaryKeys())
->endUse();
} else {
throw new PropelException('filterByC2M() only accepts arguments of type \Attogram\SharedMedia\Orm\C2M or Collection');
}
} | [
"public",
"function",
"filterByC2M",
"(",
"$",
"c2M",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"c2M",
"instanceof",
"\\",
"Attogram",
"\\",
"SharedMedia",
"\\",
"Orm",
"\\",
"C2M",
")",
"{",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"CategoryTableMap",
"::",
"COL_ID",
",",
"$",
"c2M",
"->",
"getCategoryId",
"(",
")",
",",
"$",
"comparison",
")",
";",
"}",
"elseif",
"(",
"$",
"c2M",
"instanceof",
"ObjectCollection",
")",
"{",
"return",
"$",
"this",
"->",
"useC2MQuery",
"(",
")",
"->",
"filterByPrimaryKeys",
"(",
"$",
"c2M",
"->",
"getPrimaryKeys",
"(",
")",
")",
"->",
"endUse",
"(",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"PropelException",
"(",
"'filterByC2M() only accepts arguments of type \\Attogram\\SharedMedia\\Orm\\C2M or Collection'",
")",
";",
"}",
"}"
] | Filter the query by a related \Attogram\SharedMedia\Orm\C2M object
@param \Attogram\SharedMedia\Orm\C2M|ObjectCollection $c2M the related object to use as filter
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return ChildCategoryQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"by",
"a",
"related",
"\\",
"Attogram",
"\\",
"SharedMedia",
"\\",
"Orm",
"\\",
"C2M",
"object"
] | 81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8 | https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Base/CategoryQuery.php#L968-L981 | train |
attogram/shared-media-orm | src/Attogram/SharedMedia/Orm/Base/CategoryQuery.php | CategoryQuery.descendantsOf | public function descendantsOf(ChildCategory $category)
{
return $this
->addUsingAlias(ChildCategory::LEFT_COL, $category->getLeftValue(), Criteria::GREATER_THAN)
->addUsingAlias(ChildCategory::LEFT_COL, $category->getRightValue(), Criteria::LESS_THAN);
} | php | public function descendantsOf(ChildCategory $category)
{
return $this
->addUsingAlias(ChildCategory::LEFT_COL, $category->getLeftValue(), Criteria::GREATER_THAN)
->addUsingAlias(ChildCategory::LEFT_COL, $category->getRightValue(), Criteria::LESS_THAN);
} | [
"public",
"function",
"descendantsOf",
"(",
"ChildCategory",
"$",
"category",
")",
"{",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"ChildCategory",
"::",
"LEFT_COL",
",",
"$",
"category",
"->",
"getLeftValue",
"(",
")",
",",
"Criteria",
"::",
"GREATER_THAN",
")",
"->",
"addUsingAlias",
"(",
"ChildCategory",
"::",
"LEFT_COL",
",",
"$",
"category",
"->",
"getRightValue",
"(",
")",
",",
"Criteria",
"::",
"LESS_THAN",
")",
";",
"}"
] | Filter the query to restrict the result to descendants of an object
@param ChildCategory $category The object to use for descendant search
@return $this|ChildCategoryQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"to",
"restrict",
"the",
"result",
"to",
"descendants",
"of",
"an",
"object"
] | 81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8 | https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Base/CategoryQuery.php#L1258-L1263 | train |
attogram/shared-media-orm | src/Attogram/SharedMedia/Orm/Base/CategoryQuery.php | CategoryQuery.childrenOf | public function childrenOf(ChildCategory $category)
{
return $this
->descendantsOf($category)
->addUsingAlias(ChildCategory::LEVEL_COL, $category->getLevel() + 1, Criteria::EQUAL);
} | php | public function childrenOf(ChildCategory $category)
{
return $this
->descendantsOf($category)
->addUsingAlias(ChildCategory::LEVEL_COL, $category->getLevel() + 1, Criteria::EQUAL);
} | [
"public",
"function",
"childrenOf",
"(",
"ChildCategory",
"$",
"category",
")",
"{",
"return",
"$",
"this",
"->",
"descendantsOf",
"(",
"$",
"category",
")",
"->",
"addUsingAlias",
"(",
"ChildCategory",
"::",
"LEVEL_COL",
",",
"$",
"category",
"->",
"getLevel",
"(",
")",
"+",
"1",
",",
"Criteria",
"::",
"EQUAL",
")",
";",
"}"
] | Filter the query to restrict the result to children of an object
@param ChildCategory $category The object to use for child search
@return $this|ChildCategoryQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"to",
"restrict",
"the",
"result",
"to",
"children",
"of",
"an",
"object"
] | 81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8 | https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Base/CategoryQuery.php#L1287-L1292 | train |
attogram/shared-media-orm | src/Attogram/SharedMedia/Orm/Base/CategoryQuery.php | CategoryQuery.siblingsOf | public function siblingsOf(ChildCategory $category, ConnectionInterface $con = null)
{
if ($category->isRoot()) {
return $this->
add(ChildCategory::LEVEL_COL, '1<>1', Criteria::CUSTOM);
} else {
return $this
->childrenOf($category->getParent($con))
->prune($category);
}
} | php | public function siblingsOf(ChildCategory $category, ConnectionInterface $con = null)
{
if ($category->isRoot()) {
return $this->
add(ChildCategory::LEVEL_COL, '1<>1', Criteria::CUSTOM);
} else {
return $this
->childrenOf($category->getParent($con))
->prune($category);
}
} | [
"public",
"function",
"siblingsOf",
"(",
"ChildCategory",
"$",
"category",
",",
"ConnectionInterface",
"$",
"con",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"category",
"->",
"isRoot",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"add",
"(",
"ChildCategory",
"::",
"LEVEL_COL",
",",
"'1<>1'",
",",
"Criteria",
"::",
"CUSTOM",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"childrenOf",
"(",
"$",
"category",
"->",
"getParent",
"(",
"$",
"con",
")",
")",
"->",
"prune",
"(",
"$",
"category",
")",
";",
"}",
"}"
] | Filter the query to restrict the result to siblings of an object.
The result does not include the object passed as parameter.
@param ChildCategory $category The object to use for sibling search
@param ConnectionInterface $con Connection to use.
@return $this|ChildCategoryQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"to",
"restrict",
"the",
"result",
"to",
"siblings",
"of",
"an",
"object",
".",
"The",
"result",
"does",
"not",
"include",
"the",
"object",
"passed",
"as",
"parameter",
"."
] | 81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8 | https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Base/CategoryQuery.php#L1303-L1313 | train |
attogram/shared-media-orm | src/Attogram/SharedMedia/Orm/Base/CategoryQuery.php | CategoryQuery.ancestorsOf | public function ancestorsOf(ChildCategory $category)
{
return $this
->addUsingAlias(ChildCategory::LEFT_COL, $category->getLeftValue(), Criteria::LESS_THAN)
->addUsingAlias(ChildCategory::RIGHT_COL, $category->getRightValue(), Criteria::GREATER_THAN);
} | php | public function ancestorsOf(ChildCategory $category)
{
return $this
->addUsingAlias(ChildCategory::LEFT_COL, $category->getLeftValue(), Criteria::LESS_THAN)
->addUsingAlias(ChildCategory::RIGHT_COL, $category->getRightValue(), Criteria::GREATER_THAN);
} | [
"public",
"function",
"ancestorsOf",
"(",
"ChildCategory",
"$",
"category",
")",
"{",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"ChildCategory",
"::",
"LEFT_COL",
",",
"$",
"category",
"->",
"getLeftValue",
"(",
")",
",",
"Criteria",
"::",
"LESS_THAN",
")",
"->",
"addUsingAlias",
"(",
"ChildCategory",
"::",
"RIGHT_COL",
",",
"$",
"category",
"->",
"getRightValue",
"(",
")",
",",
"Criteria",
"::",
"GREATER_THAN",
")",
";",
"}"
] | Filter the query to restrict the result to ancestors of an object
@param ChildCategory $category The object to use for ancestors search
@return $this|ChildCategoryQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"to",
"restrict",
"the",
"result",
"to",
"ancestors",
"of",
"an",
"object"
] | 81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8 | https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Base/CategoryQuery.php#L1322-L1327 | train |
attogram/shared-media-orm | src/Attogram/SharedMedia/Orm/Base/CategoryQuery.php | CategoryQuery.orderByBranch | public function orderByBranch($reverse = false)
{
if ($reverse) {
return $this
->addDescendingOrderByColumn(ChildCategory::LEFT_COL);
} else {
return $this
->addAscendingOrderByColumn(ChildCategory::LEFT_COL);
}
} | php | public function orderByBranch($reverse = false)
{
if ($reverse) {
return $this
->addDescendingOrderByColumn(ChildCategory::LEFT_COL);
} else {
return $this
->addAscendingOrderByColumn(ChildCategory::LEFT_COL);
}
} | [
"public",
"function",
"orderByBranch",
"(",
"$",
"reverse",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"reverse",
")",
"{",
"return",
"$",
"this",
"->",
"addDescendingOrderByColumn",
"(",
"ChildCategory",
"::",
"LEFT_COL",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"addAscendingOrderByColumn",
"(",
"ChildCategory",
"::",
"LEFT_COL",
")",
";",
"}",
"}"
] | Order the result by branch, i.e. natural tree order
@param bool $reverse if true, reverses the order
@return $this|ChildCategoryQuery The current query, for fluid interface | [
"Order",
"the",
"result",
"by",
"branch",
"i",
".",
"e",
".",
"natural",
"tree",
"order"
] | 81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8 | https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Base/CategoryQuery.php#L1351-L1360 | train |
attogram/shared-media-orm | src/Attogram/SharedMedia/Orm/Base/CategoryQuery.php | CategoryQuery.orderByLevel | public function orderByLevel($reverse = false)
{
if ($reverse) {
return $this
->addDescendingOrderByColumn(ChildCategory::LEVEL_COL)
->addDescendingOrderByColumn(ChildCategory::LEFT_COL);
} else {
return $this
->addAscendingOrderByColumn(ChildCategory::LEVEL_COL)
->addAscendingOrderByColumn(ChildCategory::LEFT_COL);
}
} | php | public function orderByLevel($reverse = false)
{
if ($reverse) {
return $this
->addDescendingOrderByColumn(ChildCategory::LEVEL_COL)
->addDescendingOrderByColumn(ChildCategory::LEFT_COL);
} else {
return $this
->addAscendingOrderByColumn(ChildCategory::LEVEL_COL)
->addAscendingOrderByColumn(ChildCategory::LEFT_COL);
}
} | [
"public",
"function",
"orderByLevel",
"(",
"$",
"reverse",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"reverse",
")",
"{",
"return",
"$",
"this",
"->",
"addDescendingOrderByColumn",
"(",
"ChildCategory",
"::",
"LEVEL_COL",
")",
"->",
"addDescendingOrderByColumn",
"(",
"ChildCategory",
"::",
"LEFT_COL",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"addAscendingOrderByColumn",
"(",
"ChildCategory",
"::",
"LEVEL_COL",
")",
"->",
"addAscendingOrderByColumn",
"(",
"ChildCategory",
"::",
"LEFT_COL",
")",
";",
"}",
"}"
] | Order the result by level, the closer to the root first
@param bool $reverse if true, reverses the order
@return $this|ChildCategoryQuery The current query, for fluid interface | [
"Order",
"the",
"result",
"by",
"level",
"the",
"closer",
"to",
"the",
"root",
"first"
] | 81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8 | https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Base/CategoryQuery.php#L1369-L1380 | train |
attogram/shared-media-orm | src/Attogram/SharedMedia/Orm/Base/CategoryQuery.php | CategoryQuery.findRoot | public function findRoot(ConnectionInterface $con = null)
{
return $this
->addUsingAlias(ChildCategory::LEFT_COL, 1, Criteria::EQUAL)
->findOne($con);
} | php | public function findRoot(ConnectionInterface $con = null)
{
return $this
->addUsingAlias(ChildCategory::LEFT_COL, 1, Criteria::EQUAL)
->findOne($con);
} | [
"public",
"function",
"findRoot",
"(",
"ConnectionInterface",
"$",
"con",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"ChildCategory",
"::",
"LEFT_COL",
",",
"1",
",",
"Criteria",
"::",
"EQUAL",
")",
"->",
"findOne",
"(",
"$",
"con",
")",
";",
"}"
] | Returns the root node for the tree
@param ConnectionInterface $con Connection to use.
@return ChildCategory The tree root object | [
"Returns",
"the",
"root",
"node",
"for",
"the",
"tree"
] | 81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8 | https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Base/CategoryQuery.php#L1389-L1394 | train |
attogram/shared-media-orm | src/Attogram/SharedMedia/Orm/Base/CategoryQuery.php | CategoryQuery.retrieveRoot | static public function retrieveRoot(ConnectionInterface $con = null)
{
$c = new Criteria(CategoryTableMap::DATABASE_NAME);
$c->add(ChildCategory::LEFT_COL, 1, Criteria::EQUAL);
return ChildCategoryQuery::create(null, $c)->findOne($con);
} | php | static public function retrieveRoot(ConnectionInterface $con = null)
{
$c = new Criteria(CategoryTableMap::DATABASE_NAME);
$c->add(ChildCategory::LEFT_COL, 1, Criteria::EQUAL);
return ChildCategoryQuery::create(null, $c)->findOne($con);
} | [
"static",
"public",
"function",
"retrieveRoot",
"(",
"ConnectionInterface",
"$",
"con",
"=",
"null",
")",
"{",
"$",
"c",
"=",
"new",
"Criteria",
"(",
"CategoryTableMap",
"::",
"DATABASE_NAME",
")",
";",
"$",
"c",
"->",
"add",
"(",
"ChildCategory",
"::",
"LEFT_COL",
",",
"1",
",",
"Criteria",
"::",
"EQUAL",
")",
";",
"return",
"ChildCategoryQuery",
"::",
"create",
"(",
"null",
",",
"$",
"c",
")",
"->",
"findOne",
"(",
"$",
"con",
")",
";",
"}"
] | Returns the root node for a given scope
@param ConnectionInterface $con Connection to use.
@return ChildCategory Propel object for root node | [
"Returns",
"the",
"root",
"node",
"for",
"a",
"given",
"scope"
] | 81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8 | https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Base/CategoryQuery.php#L1416-L1422 | train |
attogram/shared-media-orm | src/Attogram/SharedMedia/Orm/Base/CategoryQuery.php | CategoryQuery.retrieveTree | static public function retrieveTree(Criteria $criteria = null, ConnectionInterface $con = null)
{
if (null === $criteria) {
$criteria = new Criteria(CategoryTableMap::DATABASE_NAME);
}
$criteria->addAscendingOrderByColumn(ChildCategory::LEFT_COL);
return ChildCategoryQuery::create(null, $criteria)->find($con);
} | php | static public function retrieveTree(Criteria $criteria = null, ConnectionInterface $con = null)
{
if (null === $criteria) {
$criteria = new Criteria(CategoryTableMap::DATABASE_NAME);
}
$criteria->addAscendingOrderByColumn(ChildCategory::LEFT_COL);
return ChildCategoryQuery::create(null, $criteria)->find($con);
} | [
"static",
"public",
"function",
"retrieveTree",
"(",
"Criteria",
"$",
"criteria",
"=",
"null",
",",
"ConnectionInterface",
"$",
"con",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"criteria",
")",
"{",
"$",
"criteria",
"=",
"new",
"Criteria",
"(",
"CategoryTableMap",
"::",
"DATABASE_NAME",
")",
";",
"}",
"$",
"criteria",
"->",
"addAscendingOrderByColumn",
"(",
"ChildCategory",
"::",
"LEFT_COL",
")",
";",
"return",
"ChildCategoryQuery",
"::",
"create",
"(",
"null",
",",
"$",
"criteria",
")",
"->",
"find",
"(",
"$",
"con",
")",
";",
"}"
] | Returns the whole tree node for a given scope
@param Criteria $criteria Optional Criteria to filter the query
@param ConnectionInterface $con Connection to use.
@return ChildCategory[]|ObjectCollection|mixed the list of results, formatted by the current formatter | [
"Returns",
"the",
"whole",
"tree",
"node",
"for",
"a",
"given",
"scope"
] | 81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8 | https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Base/CategoryQuery.php#L1431-L1439 | train |
attogram/shared-media-orm | src/Attogram/SharedMedia/Orm/Base/CategoryQuery.php | CategoryQuery.isValid | static public function isValid(ChildCategory $node = null)
{
if (is_object($node) && $node->getRightValue() > $node->getLeftValue()) {
return true;
} else {
return false;
}
} | php | static public function isValid(ChildCategory $node = null)
{
if (is_object($node) && $node->getRightValue() > $node->getLeftValue()) {
return true;
} else {
return false;
}
} | [
"static",
"public",
"function",
"isValid",
"(",
"ChildCategory",
"$",
"node",
"=",
"null",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"node",
")",
"&&",
"$",
"node",
"->",
"getRightValue",
"(",
")",
">",
"$",
"node",
"->",
"getLeftValue",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] | Tests if node is valid
@param ChildCategory $node Propel object for src node
@return bool | [
"Tests",
"if",
"node",
"is",
"valid"
] | 81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8 | https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Base/CategoryQuery.php#L1447-L1454 | train |
attogram/shared-media-orm | src/Attogram/SharedMedia/Orm/Base/CategoryQuery.php | CategoryQuery.updateLoadedNodes | static public function updateLoadedNodes($prune = null, ConnectionInterface $con = null)
{
if (Propel::isInstancePoolingEnabled()) {
$keys = array();
/** @var $obj ChildCategory */
foreach (CategoryTableMap::$instances as $obj) {
if (!$prune || !$prune->equals($obj)) {
$keys[] = $obj->getPrimaryKey();
}
}
if (!empty($keys)) {
// We don't need to alter the object instance pool; we're just modifying these ones
// already in the pool.
$criteria = new Criteria(CategoryTableMap::DATABASE_NAME);
$criteria->add(CategoryTableMap::COL_ID, $keys, Criteria::IN);
$dataFetcher = ChildCategoryQuery::create(null, $criteria)->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
while ($row = $dataFetcher->fetch()) {
$key = CategoryTableMap::getPrimaryKeyHashFromRow($row, 0);
/** @var $object ChildCategory */
if (null !== ($object = CategoryTableMap::getInstanceFromPool($key))) {
$object->setLeftValue($row[11]);
$object->setRightValue($row[12]);
$object->setLevel($row[13]);
$object->clearNestedSetChildren();
}
}
$dataFetcher->close();
}
}
} | php | static public function updateLoadedNodes($prune = null, ConnectionInterface $con = null)
{
if (Propel::isInstancePoolingEnabled()) {
$keys = array();
/** @var $obj ChildCategory */
foreach (CategoryTableMap::$instances as $obj) {
if (!$prune || !$prune->equals($obj)) {
$keys[] = $obj->getPrimaryKey();
}
}
if (!empty($keys)) {
// We don't need to alter the object instance pool; we're just modifying these ones
// already in the pool.
$criteria = new Criteria(CategoryTableMap::DATABASE_NAME);
$criteria->add(CategoryTableMap::COL_ID, $keys, Criteria::IN);
$dataFetcher = ChildCategoryQuery::create(null, $criteria)->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
while ($row = $dataFetcher->fetch()) {
$key = CategoryTableMap::getPrimaryKeyHashFromRow($row, 0);
/** @var $object ChildCategory */
if (null !== ($object = CategoryTableMap::getInstanceFromPool($key))) {
$object->setLeftValue($row[11]);
$object->setRightValue($row[12]);
$object->setLevel($row[13]);
$object->clearNestedSetChildren();
}
}
$dataFetcher->close();
}
}
} | [
"static",
"public",
"function",
"updateLoadedNodes",
"(",
"$",
"prune",
"=",
"null",
",",
"ConnectionInterface",
"$",
"con",
"=",
"null",
")",
"{",
"if",
"(",
"Propel",
"::",
"isInstancePoolingEnabled",
"(",
")",
")",
"{",
"$",
"keys",
"=",
"array",
"(",
")",
";",
"/** @var $obj ChildCategory */",
"foreach",
"(",
"CategoryTableMap",
"::",
"$",
"instances",
"as",
"$",
"obj",
")",
"{",
"if",
"(",
"!",
"$",
"prune",
"||",
"!",
"$",
"prune",
"->",
"equals",
"(",
"$",
"obj",
")",
")",
"{",
"$",
"keys",
"[",
"]",
"=",
"$",
"obj",
"->",
"getPrimaryKey",
"(",
")",
";",
"}",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"keys",
")",
")",
"{",
"// We don't need to alter the object instance pool; we're just modifying these ones",
"// already in the pool.",
"$",
"criteria",
"=",
"new",
"Criteria",
"(",
"CategoryTableMap",
"::",
"DATABASE_NAME",
")",
";",
"$",
"criteria",
"->",
"add",
"(",
"CategoryTableMap",
"::",
"COL_ID",
",",
"$",
"keys",
",",
"Criteria",
"::",
"IN",
")",
";",
"$",
"dataFetcher",
"=",
"ChildCategoryQuery",
"::",
"create",
"(",
"null",
",",
"$",
"criteria",
")",
"->",
"setFormatter",
"(",
"ModelCriteria",
"::",
"FORMAT_STATEMENT",
")",
"->",
"find",
"(",
"$",
"con",
")",
";",
"while",
"(",
"$",
"row",
"=",
"$",
"dataFetcher",
"->",
"fetch",
"(",
")",
")",
"{",
"$",
"key",
"=",
"CategoryTableMap",
"::",
"getPrimaryKeyHashFromRow",
"(",
"$",
"row",
",",
"0",
")",
";",
"/** @var $object ChildCategory */",
"if",
"(",
"null",
"!==",
"(",
"$",
"object",
"=",
"CategoryTableMap",
"::",
"getInstanceFromPool",
"(",
"$",
"key",
")",
")",
")",
"{",
"$",
"object",
"->",
"setLeftValue",
"(",
"$",
"row",
"[",
"11",
"]",
")",
";",
"$",
"object",
"->",
"setRightValue",
"(",
"$",
"row",
"[",
"12",
"]",
")",
";",
"$",
"object",
"->",
"setLevel",
"(",
"$",
"row",
"[",
"13",
"]",
")",
";",
"$",
"object",
"->",
"clearNestedSetChildren",
"(",
")",
";",
"}",
"}",
"$",
"dataFetcher",
"->",
"close",
"(",
")",
";",
"}",
"}",
"}"
] | Reload all already loaded nodes to sync them with updated db
@param ChildCategory $prune Object to prune from the update
@param ConnectionInterface $con Connection to use. | [
"Reload",
"all",
"already",
"loaded",
"nodes",
"to",
"sync",
"them",
"with",
"updated",
"db"
] | 81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8 | https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Base/CategoryQuery.php#L1542-L1572 | train |
vukbgit/PHPCraft.Subject | src/Traits/Images.php | Images.resizeImage | protected function resizeImage($path, $width, $height)
{
$this->images->open('Gd',$path);
$this->images->resize($width, $height);
} | php | protected function resizeImage($path, $width, $height)
{
$this->images->open('Gd',$path);
$this->images->resize($width, $height);
} | [
"protected",
"function",
"resizeImage",
"(",
"$",
"path",
",",
"$",
"width",
",",
"$",
"height",
")",
"{",
"$",
"this",
"->",
"images",
"->",
"open",
"(",
"'Gd'",
",",
"$",
"path",
")",
";",
"$",
"this",
"->",
"images",
"->",
"resize",
"(",
"$",
"width",
",",
"$",
"height",
")",
";",
"}"
] | resizes an image
@param string $path
@param int $width
@param int $height | [
"resizes",
"an",
"image"
] | a43ad7868098ff1e7bda6819547ea64f9a853732 | https://github.com/vukbgit/PHPCraft.Subject/blob/a43ad7868098ff1e7bda6819547ea64f9a853732/src/Traits/Images.php#L51-L55 | train |
titledk/silverstripe-identity | code/Identity.php | Identity.get_colors | public static function get_colors($type = 'hex')
{
$cached = self::$colorsCached;
if (isset($cached[$type])) return $cached[$type];
$colors = Config::inst()->get('Identity', 'colors');
if ($type == 'rgb') {
$rgbColors = [];
foreach ($colors as $name => $c) {
$rgbColors[$name] = self::hex2rgb($c);
}
$colors = $rgbColors;
}
self::$colorsCached[$type] = $colors;
return $colors;
} | php | public static function get_colors($type = 'hex')
{
$cached = self::$colorsCached;
if (isset($cached[$type])) return $cached[$type];
$colors = Config::inst()->get('Identity', 'colors');
if ($type == 'rgb') {
$rgbColors = [];
foreach ($colors as $name => $c) {
$rgbColors[$name] = self::hex2rgb($c);
}
$colors = $rgbColors;
}
self::$colorsCached[$type] = $colors;
return $colors;
} | [
"public",
"static",
"function",
"get_colors",
"(",
"$",
"type",
"=",
"'hex'",
")",
"{",
"$",
"cached",
"=",
"self",
"::",
"$",
"colorsCached",
";",
"if",
"(",
"isset",
"(",
"$",
"cached",
"[",
"$",
"type",
"]",
")",
")",
"return",
"$",
"cached",
"[",
"$",
"type",
"]",
";",
"$",
"colors",
"=",
"Config",
"::",
"inst",
"(",
")",
"->",
"get",
"(",
"'Identity'",
",",
"'colors'",
")",
";",
"if",
"(",
"$",
"type",
"==",
"'rgb'",
")",
"{",
"$",
"rgbColors",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"colors",
"as",
"$",
"name",
"=>",
"$",
"c",
")",
"{",
"$",
"rgbColors",
"[",
"$",
"name",
"]",
"=",
"self",
"::",
"hex2rgb",
"(",
"$",
"c",
")",
";",
"}",
"$",
"colors",
"=",
"$",
"rgbColors",
";",
"}",
"self",
"::",
"$",
"colorsCached",
"[",
"$",
"type",
"]",
"=",
"$",
"colors",
";",
"return",
"$",
"colors",
";",
"}"
] | Identify colors in either hex or rgb
@param string $type
@return array | [
"Identify",
"colors",
"in",
"either",
"hex",
"or",
"rgb"
] | 27cf7edd6bdb2d220b718bafba6b2959243d23cf | https://github.com/titledk/silverstripe-identity/blob/27cf7edd6bdb2d220b718bafba6b2959243d23cf/code/Identity.php#L23-L38 | train |
titledk/silverstripe-identity | code/Identity.php | Identity.hex2rgb | public static function hex2rgb($hex)
{
$hex = str_replace("#", "", $hex);
$r = hexdec(substr($hex,0,2));
$g = hexdec(substr($hex,2,2));
$b = hexdec(substr($hex,4,2));
return "$r,$g,$b";
} | php | public static function hex2rgb($hex)
{
$hex = str_replace("#", "", $hex);
$r = hexdec(substr($hex,0,2));
$g = hexdec(substr($hex,2,2));
$b = hexdec(substr($hex,4,2));
return "$r,$g,$b";
} | [
"public",
"static",
"function",
"hex2rgb",
"(",
"$",
"hex",
")",
"{",
"$",
"hex",
"=",
"str_replace",
"(",
"\"#\"",
",",
"\"\"",
",",
"$",
"hex",
")",
";",
"$",
"r",
"=",
"hexdec",
"(",
"substr",
"(",
"$",
"hex",
",",
"0",
",",
"2",
")",
")",
";",
"$",
"g",
"=",
"hexdec",
"(",
"substr",
"(",
"$",
"hex",
",",
"2",
",",
"2",
")",
")",
";",
"$",
"b",
"=",
"hexdec",
"(",
"substr",
"(",
"$",
"hex",
",",
"4",
",",
"2",
")",
")",
";",
"return",
"\"$r,$g,$b\"",
";",
"}"
] | Helper for converting a color to rbg
@param $hex
@return string | [
"Helper",
"for",
"converting",
"a",
"color",
"to",
"rbg"
] | 27cf7edd6bdb2d220b718bafba6b2959243d23cf | https://github.com/titledk/silverstripe-identity/blob/27cf7edd6bdb2d220b718bafba6b2959243d23cf/code/Identity.php#L45-L52 | train |
zarathustra323/modlr-data | src/Zarathustra/ModlrData/Resource/Collection.php | Collection.getResourceTypes | public function getResourceTypes()
{
$types = [];
foreach ($this as $entity) {
$types[] = $entity->getType();
}
return array_unique($types);
} | php | public function getResourceTypes()
{
$types = [];
foreach ($this as $entity) {
$types[] = $entity->getType();
}
return array_unique($types);
} | [
"public",
"function",
"getResourceTypes",
"(",
")",
"{",
"$",
"types",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"as",
"$",
"entity",
")",
"{",
"$",
"types",
"[",
"]",
"=",
"$",
"entity",
"->",
"getType",
"(",
")",
";",
"}",
"return",
"array_unique",
"(",
"$",
"types",
")",
";",
"}"
] | Gets a unique list of all entity types assigned to this collection.
@return array | [
"Gets",
"a",
"unique",
"list",
"of",
"all",
"entity",
"types",
"assigned",
"to",
"this",
"collection",
"."
] | 7c2c767216055f75abf8cf22e2200f11998ed24e | https://github.com/zarathustra323/modlr-data/blob/7c2c767216055f75abf8cf22e2200f11998ed24e/src/Zarathustra/ModlrData/Resource/Collection.php#L45-L52 | train |
Nicofuma/phpbb-ext-webprofiler | phpbb/profiler/profiler_listener.php | profiler_listener.on_common | public function on_common()
{
if (substr($GLOBALS['request']->server('SCRIPT_NAME'), -7) === 'app.php')
{
return;
}
try {
$this->request_stack->push($this->symfony_request);
$this->dispatcher->dispatch(KernelEvents::REQUEST,
new GetResponseEvent(
$this->http_kernel,
$this->request_stack->getCurrentRequest(),
HttpKernelInterface::MASTER_REQUEST
));
}
catch (\Exception $e)
{
}
} | php | public function on_common()
{
if (substr($GLOBALS['request']->server('SCRIPT_NAME'), -7) === 'app.php')
{
return;
}
try {
$this->request_stack->push($this->symfony_request);
$this->dispatcher->dispatch(KernelEvents::REQUEST,
new GetResponseEvent(
$this->http_kernel,
$this->request_stack->getCurrentRequest(),
HttpKernelInterface::MASTER_REQUEST
));
}
catch (\Exception $e)
{
}
} | [
"public",
"function",
"on_common",
"(",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"GLOBALS",
"[",
"'request'",
"]",
"->",
"server",
"(",
"'SCRIPT_NAME'",
")",
",",
"-",
"7",
")",
"===",
"'app.php'",
")",
"{",
"return",
";",
"}",
"try",
"{",
"$",
"this",
"->",
"request_stack",
"->",
"push",
"(",
"$",
"this",
"->",
"symfony_request",
")",
";",
"$",
"this",
"->",
"dispatcher",
"->",
"dispatch",
"(",
"KernelEvents",
"::",
"REQUEST",
",",
"new",
"GetResponseEvent",
"(",
"$",
"this",
"->",
"http_kernel",
",",
"$",
"this",
"->",
"request_stack",
"->",
"getCurrentRequest",
"(",
")",
",",
"HttpKernelInterface",
"::",
"MASTER_REQUEST",
")",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"}",
"}"
] | Emulate the kernel request event | [
"Emulate",
"the",
"kernel",
"request",
"event"
] | 5f52e2b67f5b8278af18907615f30ffe20f4802c | https://github.com/Nicofuma/phpbb-ext-webprofiler/blob/5f52e2b67f5b8278af18907615f30ffe20f4802c/phpbb/profiler/profiler_listener.php#L56-L76 | train |
Nicofuma/phpbb-ext-webprofiler | phpbb/profiler/profiler_listener.php | profiler_listener.on_garbage_collection | public function on_garbage_collection()
{
if (substr($GLOBALS['request']->server('SCRIPT_NAME'), -7) === 'app.php')
{
return;
}
// An Exception is throw because the TraceableEventDispatcher
// stop all the events when KernelEvents::RESPONSE is trigger.
// But because we are emulating the event through the
// garbage_collection event, we got an exception at the end
// of the dispatching of the event.
// (stop() is called on an already stopped() event)
set_exception_handler(array($this, 'exception_handler'));
try {
$response = new Response('<html><body></body></html>');
$this->dispatcher->dispatch(KernelEvents::RESPONSE,
new FilterResponseEvent(
$this->http_kernel,
$this->request_stack->getCurrentRequest(),
HttpKernelInterface::MASTER_REQUEST,
$response
));
if ($this->redirect_url !== null)
{
$url = $this->redirect_url;
// Redirect via an HTML form for PITA webservers
if (@preg_match('#Microsoft|WebSTAR|Xitami#', getenv('SERVER_SOFTWARE')))
{
header('Refresh: 0; URL=' . $url);
echo '<!DOCTYPE html>';
echo '<html dir="Direction" lang="en">';
echo '<head>';
echo '<meta charset="utf-8">';
echo '<meta http-equiv="refresh" content="0; url=' . str_replace('&', '&', $url) . '" />';
echo '<title>Redirect</title>';
echo '</head>';
echo '<body>';
echo '<div style="text-align: center;"><a href="' . str_replace('&', '&', $url) . '">Redirect</a></div>';
echo '</body>';
echo '</html>';
$this->dispatcher->dispatch(KernelEvents::TERMINATE,
new PostResponseEvent($this->http_kernel,
$this->request_stack->getCurrentRequest(),
$response
)
);
exit;
}
// Behave as per HTTP/1.1 spec for others
header('Location: ' . $url);
$this->dispatcher->dispatch(KernelEvents::TERMINATE,
new PostResponseEvent($this->http_kernel,
$this->request_stack->getCurrentRequest(),
$response
)
);
exit;
}
else if ($response->getContent() !== '<html><body></body></html>')
{
if ('<html><body></body></html>' !== $response->getContent())
{
echo $response->getContent();
}
}
$this->dispatcher->dispatch(KernelEvents::TERMINATE,
new PostResponseEvent($this->http_kernel,
$this->request_stack->getCurrentRequest(),
$response
)
);
}
catch (\Exception $e)
{dump($e);
}
} | php | public function on_garbage_collection()
{
if (substr($GLOBALS['request']->server('SCRIPT_NAME'), -7) === 'app.php')
{
return;
}
// An Exception is throw because the TraceableEventDispatcher
// stop all the events when KernelEvents::RESPONSE is trigger.
// But because we are emulating the event through the
// garbage_collection event, we got an exception at the end
// of the dispatching of the event.
// (stop() is called on an already stopped() event)
set_exception_handler(array($this, 'exception_handler'));
try {
$response = new Response('<html><body></body></html>');
$this->dispatcher->dispatch(KernelEvents::RESPONSE,
new FilterResponseEvent(
$this->http_kernel,
$this->request_stack->getCurrentRequest(),
HttpKernelInterface::MASTER_REQUEST,
$response
));
if ($this->redirect_url !== null)
{
$url = $this->redirect_url;
// Redirect via an HTML form for PITA webservers
if (@preg_match('#Microsoft|WebSTAR|Xitami#', getenv('SERVER_SOFTWARE')))
{
header('Refresh: 0; URL=' . $url);
echo '<!DOCTYPE html>';
echo '<html dir="Direction" lang="en">';
echo '<head>';
echo '<meta charset="utf-8">';
echo '<meta http-equiv="refresh" content="0; url=' . str_replace('&', '&', $url) . '" />';
echo '<title>Redirect</title>';
echo '</head>';
echo '<body>';
echo '<div style="text-align: center;"><a href="' . str_replace('&', '&', $url) . '">Redirect</a></div>';
echo '</body>';
echo '</html>';
$this->dispatcher->dispatch(KernelEvents::TERMINATE,
new PostResponseEvent($this->http_kernel,
$this->request_stack->getCurrentRequest(),
$response
)
);
exit;
}
// Behave as per HTTP/1.1 spec for others
header('Location: ' . $url);
$this->dispatcher->dispatch(KernelEvents::TERMINATE,
new PostResponseEvent($this->http_kernel,
$this->request_stack->getCurrentRequest(),
$response
)
);
exit;
}
else if ($response->getContent() !== '<html><body></body></html>')
{
if ('<html><body></body></html>' !== $response->getContent())
{
echo $response->getContent();
}
}
$this->dispatcher->dispatch(KernelEvents::TERMINATE,
new PostResponseEvent($this->http_kernel,
$this->request_stack->getCurrentRequest(),
$response
)
);
}
catch (\Exception $e)
{dump($e);
}
} | [
"public",
"function",
"on_garbage_collection",
"(",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"GLOBALS",
"[",
"'request'",
"]",
"->",
"server",
"(",
"'SCRIPT_NAME'",
")",
",",
"-",
"7",
")",
"===",
"'app.php'",
")",
"{",
"return",
";",
"}",
"// An Exception is throw because the TraceableEventDispatcher",
"// stop all the events when KernelEvents::RESPONSE is trigger.",
"// But because we are emulating the event through the",
"// garbage_collection event, we got an exception at the end",
"// of the dispatching of the event.",
"// (stop() is called on an already stopped() event)",
"set_exception_handler",
"(",
"array",
"(",
"$",
"this",
",",
"'exception_handler'",
")",
")",
";",
"try",
"{",
"$",
"response",
"=",
"new",
"Response",
"(",
"'<html><body></body></html>'",
")",
";",
"$",
"this",
"->",
"dispatcher",
"->",
"dispatch",
"(",
"KernelEvents",
"::",
"RESPONSE",
",",
"new",
"FilterResponseEvent",
"(",
"$",
"this",
"->",
"http_kernel",
",",
"$",
"this",
"->",
"request_stack",
"->",
"getCurrentRequest",
"(",
")",
",",
"HttpKernelInterface",
"::",
"MASTER_REQUEST",
",",
"$",
"response",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"redirect_url",
"!==",
"null",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"redirect_url",
";",
"// Redirect via an HTML form for PITA webservers",
"if",
"(",
"@",
"preg_match",
"(",
"'#Microsoft|WebSTAR|Xitami#'",
",",
"getenv",
"(",
"'SERVER_SOFTWARE'",
")",
")",
")",
"{",
"header",
"(",
"'Refresh: 0; URL='",
".",
"$",
"url",
")",
";",
"echo",
"'<!DOCTYPE html>'",
";",
"echo",
"'<html dir=\"Direction\" lang=\"en\">'",
";",
"echo",
"'<head>'",
";",
"echo",
"'<meta charset=\"utf-8\">'",
";",
"echo",
"'<meta http-equiv=\"refresh\" content=\"0; url='",
".",
"str_replace",
"(",
"'&'",
",",
"'&'",
",",
"$",
"url",
")",
".",
"'\" />'",
";",
"echo",
"'<title>Redirect</title>'",
";",
"echo",
"'</head>'",
";",
"echo",
"'<body>'",
";",
"echo",
"'<div style=\"text-align: center;\"><a href=\"'",
".",
"str_replace",
"(",
"'&'",
",",
"'&'",
",",
"$",
"url",
")",
".",
"'\">Redirect</a></div>'",
";",
"echo",
"'</body>'",
";",
"echo",
"'</html>'",
";",
"$",
"this",
"->",
"dispatcher",
"->",
"dispatch",
"(",
"KernelEvents",
"::",
"TERMINATE",
",",
"new",
"PostResponseEvent",
"(",
"$",
"this",
"->",
"http_kernel",
",",
"$",
"this",
"->",
"request_stack",
"->",
"getCurrentRequest",
"(",
")",
",",
"$",
"response",
")",
")",
";",
"exit",
";",
"}",
"// Behave as per HTTP/1.1 spec for others",
"header",
"(",
"'Location: '",
".",
"$",
"url",
")",
";",
"$",
"this",
"->",
"dispatcher",
"->",
"dispatch",
"(",
"KernelEvents",
"::",
"TERMINATE",
",",
"new",
"PostResponseEvent",
"(",
"$",
"this",
"->",
"http_kernel",
",",
"$",
"this",
"->",
"request_stack",
"->",
"getCurrentRequest",
"(",
")",
",",
"$",
"response",
")",
")",
";",
"exit",
";",
"}",
"else",
"if",
"(",
"$",
"response",
"->",
"getContent",
"(",
")",
"!==",
"'<html><body></body></html>'",
")",
"{",
"if",
"(",
"'<html><body></body></html>'",
"!==",
"$",
"response",
"->",
"getContent",
"(",
")",
")",
"{",
"echo",
"$",
"response",
"->",
"getContent",
"(",
")",
";",
"}",
"}",
"$",
"this",
"->",
"dispatcher",
"->",
"dispatch",
"(",
"KernelEvents",
"::",
"TERMINATE",
",",
"new",
"PostResponseEvent",
"(",
"$",
"this",
"->",
"http_kernel",
",",
"$",
"this",
"->",
"request_stack",
"->",
"getCurrentRequest",
"(",
")",
",",
"$",
"response",
")",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"dump",
"(",
"$",
"e",
")",
";",
"}",
"}"
] | Emulate the kernel response event | [
"Emulate",
"the",
"kernel",
"response",
"event"
] | 5f52e2b67f5b8278af18907615f30ffe20f4802c | https://github.com/Nicofuma/phpbb-ext-webprofiler/blob/5f52e2b67f5b8278af18907615f30ffe20f4802c/phpbb/profiler/profiler_listener.php#L81-L164 | train |
Nicofuma/phpbb-ext-webprofiler | phpbb/profiler/profiler_listener.php | profiler_listener.onKernelResponse | public function onKernelResponse(FilterResponseEvent $event)
{
$result = parent::onKernelResponse($event);
$content = ob_get_contents();
if ($this->request_stack->getCurrentRequest()->getMethod() === 'POST' && empty($content))
{
$event->stopPropagation();
}
return $result;
} | php | public function onKernelResponse(FilterResponseEvent $event)
{
$result = parent::onKernelResponse($event);
$content = ob_get_contents();
if ($this->request_stack->getCurrentRequest()->getMethod() === 'POST' && empty($content))
{
$event->stopPropagation();
}
return $result;
} | [
"public",
"function",
"onKernelResponse",
"(",
"FilterResponseEvent",
"$",
"event",
")",
"{",
"$",
"result",
"=",
"parent",
"::",
"onKernelResponse",
"(",
"$",
"event",
")",
";",
"$",
"content",
"=",
"ob_get_contents",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"request_stack",
"->",
"getCurrentRequest",
"(",
")",
"->",
"getMethod",
"(",
")",
"===",
"'POST'",
"&&",
"empty",
"(",
"$",
"content",
")",
")",
"{",
"$",
"event",
"->",
"stopPropagation",
"(",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Avoid the injection of the toolbar
@param FilterResponseEvent $event | [
"Avoid",
"the",
"injection",
"of",
"the",
"toolbar"
] | 5f52e2b67f5b8278af18907615f30ffe20f4802c | https://github.com/Nicofuma/phpbb-ext-webprofiler/blob/5f52e2b67f5b8278af18907615f30ffe20f4802c/phpbb/profiler/profiler_listener.php#L184-L195 | train |
acgrid/phprofiling | src/Item.php | Item.& | public function &refScopeStatistic($scope)
{
if(!isset($this->statistics[$scope])) $this->statistics[$scope] = [];
return $this->statistics[$scope];
} | php | public function &refScopeStatistic($scope)
{
if(!isset($this->statistics[$scope])) $this->statistics[$scope] = [];
return $this->statistics[$scope];
} | [
"public",
"function",
"&",
"refScopeStatistic",
"(",
"$",
"scope",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"statistics",
"[",
"$",
"scope",
"]",
")",
")",
"$",
"this",
"->",
"statistics",
"[",
"$",
"scope",
"]",
"=",
"[",
"]",
";",
"return",
"$",
"this",
"->",
"statistics",
"[",
"$",
"scope",
"]",
";",
"}"
] | Return a reference for batch editing.
Do not replace the whole variable into non-array value!
@param string $scope
@return array | [
"Return",
"a",
"reference",
"for",
"batch",
"editing",
".",
"Do",
"not",
"replace",
"the",
"whole",
"variable",
"into",
"non",
"-",
"array",
"value!"
] | 537aaad74892848060646c2764e8c85232daceae | https://github.com/acgrid/phprofiling/blob/537aaad74892848060646c2764e8c85232daceae/src/Item.php#L140-L144 | train |
squareproton/Bond | src/Bond/Di/Configurator.php | Configurator.load | public function load()
{
$output = [];
$args = func_get_args();
foreach( $args as $arg ) {
if( is_array($arg) ) {
$output = array_merge(
call_user_func_array( [$this, 'load'], $arg ),
$output
);
} else {
$this->loadHandler($arg);
$output[] = $arg;
}
}
return $output;
} | php | public function load()
{
$output = [];
$args = func_get_args();
foreach( $args as $arg ) {
if( is_array($arg) ) {
$output = array_merge(
call_user_func_array( [$this, 'load'], $arg ),
$output
);
} else {
$this->loadHandler($arg);
$output[] = $arg;
}
}
return $output;
} | [
"public",
"function",
"load",
"(",
")",
"{",
"$",
"output",
"=",
"[",
"]",
";",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"foreach",
"(",
"$",
"args",
"as",
"$",
"arg",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"arg",
")",
")",
"{",
"$",
"output",
"=",
"array_merge",
"(",
"call_user_func_array",
"(",
"[",
"$",
"this",
",",
"'load'",
"]",
",",
"$",
"arg",
")",
",",
"$",
"output",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"loadHandler",
"(",
"$",
"arg",
")",
";",
"$",
"output",
"[",
"]",
"=",
"$",
"arg",
";",
"}",
"}",
"return",
"$",
"output",
";",
"}"
] | Load a collection of assets into the Di container.
Provides a whole load of syntatic sugar so you can basically pass this a combination of arrays, assets, multiple args, ... whatever
The actual work is done by loadHandler
@return mixed[]. Array of the individual assets loaded. | [
"Load",
"a",
"collection",
"of",
"assets",
"into",
"the",
"Di",
"container",
".",
"Provides",
"a",
"whole",
"load",
"of",
"syntatic",
"sugar",
"so",
"you",
"can",
"basically",
"pass",
"this",
"a",
"combination",
"of",
"arrays",
"assets",
"multiple",
"args",
"...",
"whatever",
"The",
"actual",
"work",
"is",
"done",
"by",
"loadHandler"
] | a04ad9dd1a35adeaec98237716c2a41ce02b4f1a | https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Di/Configurator.php#L59-L75 | train |
reliv/rcm-config | src/Model/ConfigModel.php | ConfigModel.getList | public function getList()
{
$category = $this->getCategory();
$list = $this->getCategoryConfig($category);
foreach ($list as $context => $config) {
$list[$context] = $this->getAll($context);
}
return $list;
} | php | public function getList()
{
$category = $this->getCategory();
$list = $this->getCategoryConfig($category);
foreach ($list as $context => $config) {
$list[$context] = $this->getAll($context);
}
return $list;
} | [
"public",
"function",
"getList",
"(",
")",
"{",
"$",
"category",
"=",
"$",
"this",
"->",
"getCategory",
"(",
")",
";",
"$",
"list",
"=",
"$",
"this",
"->",
"getCategoryConfig",
"(",
"$",
"category",
")",
";",
"foreach",
"(",
"$",
"list",
"as",
"$",
"context",
"=>",
"$",
"config",
")",
"{",
"$",
"list",
"[",
"$",
"context",
"]",
"=",
"$",
"this",
"->",
"getAll",
"(",
"$",
"context",
")",
";",
"}",
"return",
"$",
"list",
";",
"}"
] | Get All config entries
@return array | [
"Get",
"All",
"config",
"entries"
] | 3e8cdea57a8688b06997ce1b167b8410bccac09e | https://github.com/reliv/rcm-config/blob/3e8cdea57a8688b06997ce1b167b8410bccac09e/src/Model/ConfigModel.php#L94-L105 | train |
irfantoor/engine | src/Engine.php | Engine.classname | public function classname($id)
{
# todo -- returns null class instead of null
return isset($this->classes[$id]) ? $this->classes[$id] : null;
} | php | public function classname($id)
{
# todo -- returns null class instead of null
return isset($this->classes[$id]) ? $this->classes[$id] : null;
} | [
"public",
"function",
"classname",
"(",
"$",
"id",
")",
"{",
"# todo -- returns null class instead of null",
"return",
"isset",
"(",
"$",
"this",
"->",
"classes",
"[",
"$",
"id",
"]",
")",
"?",
"$",
"this",
"->",
"classes",
"[",
"$",
"id",
"]",
":",
"null",
";",
"}"
] | Returns the default or configured classname with namespace
@param string $id
@return string | [
"Returns",
"the",
"default",
"or",
"configured",
"classname",
"with",
"namespace"
] | 4d2d221add749f75100d0b4ffe1488cdbf7af5d3 | https://github.com/irfantoor/engine/blob/4d2d221add749f75100d0b4ffe1488cdbf7af5d3/src/Engine.php#L158-L162 | train |
irfantoor/engine | src/Engine.php | Engine.run | function run()
{
$request = $this->getServerRequest();
$response = $this->getResponse();
$uri = $request->getUri();
$basepath = $uri->getBasePath();
$args = explode('/', htmlspecialchars($basepath));
$response = $this->process($request, $response, $args);
$this->finalize($request, $response, $args);
} | php | function run()
{
$request = $this->getServerRequest();
$response = $this->getResponse();
$uri = $request->getUri();
$basepath = $uri->getBasePath();
$args = explode('/', htmlspecialchars($basepath));
$response = $this->process($request, $response, $args);
$this->finalize($request, $response, $args);
} | [
"function",
"run",
"(",
")",
"{",
"$",
"request",
"=",
"$",
"this",
"->",
"getServerRequest",
"(",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"getResponse",
"(",
")",
";",
"$",
"uri",
"=",
"$",
"request",
"->",
"getUri",
"(",
")",
";",
"$",
"basepath",
"=",
"$",
"uri",
"->",
"getBasePath",
"(",
")",
";",
"$",
"args",
"=",
"explode",
"(",
"'/'",
",",
"htmlspecialchars",
"(",
"$",
"basepath",
")",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"process",
"(",
"$",
"request",
",",
"$",
"response",
",",
"$",
"args",
")",
";",
"$",
"this",
"->",
"finalize",
"(",
"$",
"request",
",",
"$",
"response",
",",
"$",
"args",
")",
";",
"}"
] | Runs the engine, the processes the request | [
"Runs",
"the",
"engine",
"the",
"processes",
"the",
"request"
] | 4d2d221add749f75100d0b4ffe1488cdbf7af5d3 | https://github.com/irfantoor/engine/blob/4d2d221add749f75100d0b4ffe1488cdbf7af5d3/src/Engine.php#L168-L179 | train |
OUTRAGElib/psr7-file-stream | lib/Stream.php | Stream.setFilePointer | public function setFilePointer($pointer)
{
if(!is_resource($pointer))
throw new InvalidArgumentException("Invalid type - not a file resource");
$this->pointer = $pointer;
# and now to set everything up...
$metadata = stream_get_meta_data($this->pointer);
# can this stream be read from?
if(isset($metadata["mode"]))
{
$mode = rtrim($metadata["mode"], "bt");
$super = (boolean) preg_match("/\+$/", $mode);
$mode = rtrim($mode, "+");
switch($mode)
{
case "r":
$this->is_readable = true;
break;
case "w":
case "a":
case "x":
case "c":
$this->is_readable = $super;
break;
default:
throw new LogicException("Invalid file access type: '".$metadata["mode"]."'");
break;
}
}
# can this stream be written to?
if(isset($metadata["mode"]))
{
$mode = rtrim($metadata["mode"], "bt");
$super = (boolean) preg_match("/\+$/", $mode);
$mode = rtrim($mode, "+");
switch($mode)
{
case "r":
$this->is_writable = $super;
break;
case "w":
case "a":
case "x":
case "c":
$this->is_writable = true;
break;
default:
throw new LogicException("Invalid file access type: '".$metadata["mode"]."'");
break;
}
}
# does this stream support seek functionality?
if(isset($metadata["seekable"]))
$this->is_seekable = (boolean) $metadata["seekable"];
return null;
} | php | public function setFilePointer($pointer)
{
if(!is_resource($pointer))
throw new InvalidArgumentException("Invalid type - not a file resource");
$this->pointer = $pointer;
# and now to set everything up...
$metadata = stream_get_meta_data($this->pointer);
# can this stream be read from?
if(isset($metadata["mode"]))
{
$mode = rtrim($metadata["mode"], "bt");
$super = (boolean) preg_match("/\+$/", $mode);
$mode = rtrim($mode, "+");
switch($mode)
{
case "r":
$this->is_readable = true;
break;
case "w":
case "a":
case "x":
case "c":
$this->is_readable = $super;
break;
default:
throw new LogicException("Invalid file access type: '".$metadata["mode"]."'");
break;
}
}
# can this stream be written to?
if(isset($metadata["mode"]))
{
$mode = rtrim($metadata["mode"], "bt");
$super = (boolean) preg_match("/\+$/", $mode);
$mode = rtrim($mode, "+");
switch($mode)
{
case "r":
$this->is_writable = $super;
break;
case "w":
case "a":
case "x":
case "c":
$this->is_writable = true;
break;
default:
throw new LogicException("Invalid file access type: '".$metadata["mode"]."'");
break;
}
}
# does this stream support seek functionality?
if(isset($metadata["seekable"]))
$this->is_seekable = (boolean) $metadata["seekable"];
return null;
} | [
"public",
"function",
"setFilePointer",
"(",
"$",
"pointer",
")",
"{",
"if",
"(",
"!",
"is_resource",
"(",
"$",
"pointer",
")",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Invalid type - not a file resource\"",
")",
";",
"$",
"this",
"->",
"pointer",
"=",
"$",
"pointer",
";",
"# and now to set everything up...",
"$",
"metadata",
"=",
"stream_get_meta_data",
"(",
"$",
"this",
"->",
"pointer",
")",
";",
"# can this stream be read from?",
"if",
"(",
"isset",
"(",
"$",
"metadata",
"[",
"\"mode\"",
"]",
")",
")",
"{",
"$",
"mode",
"=",
"rtrim",
"(",
"$",
"metadata",
"[",
"\"mode\"",
"]",
",",
"\"bt\"",
")",
";",
"$",
"super",
"=",
"(",
"boolean",
")",
"preg_match",
"(",
"\"/\\+$/\"",
",",
"$",
"mode",
")",
";",
"$",
"mode",
"=",
"rtrim",
"(",
"$",
"mode",
",",
"\"+\"",
")",
";",
"switch",
"(",
"$",
"mode",
")",
"{",
"case",
"\"r\"",
":",
"$",
"this",
"->",
"is_readable",
"=",
"true",
";",
"break",
";",
"case",
"\"w\"",
":",
"case",
"\"a\"",
":",
"case",
"\"x\"",
":",
"case",
"\"c\"",
":",
"$",
"this",
"->",
"is_readable",
"=",
"$",
"super",
";",
"break",
";",
"default",
":",
"throw",
"new",
"LogicException",
"(",
"\"Invalid file access type: '\"",
".",
"$",
"metadata",
"[",
"\"mode\"",
"]",
".",
"\"'\"",
")",
";",
"break",
";",
"}",
"}",
"# can this stream be written to?",
"if",
"(",
"isset",
"(",
"$",
"metadata",
"[",
"\"mode\"",
"]",
")",
")",
"{",
"$",
"mode",
"=",
"rtrim",
"(",
"$",
"metadata",
"[",
"\"mode\"",
"]",
",",
"\"bt\"",
")",
";",
"$",
"super",
"=",
"(",
"boolean",
")",
"preg_match",
"(",
"\"/\\+$/\"",
",",
"$",
"mode",
")",
";",
"$",
"mode",
"=",
"rtrim",
"(",
"$",
"mode",
",",
"\"+\"",
")",
";",
"switch",
"(",
"$",
"mode",
")",
"{",
"case",
"\"r\"",
":",
"$",
"this",
"->",
"is_writable",
"=",
"$",
"super",
";",
"break",
";",
"case",
"\"w\"",
":",
"case",
"\"a\"",
":",
"case",
"\"x\"",
":",
"case",
"\"c\"",
":",
"$",
"this",
"->",
"is_writable",
"=",
"true",
";",
"break",
";",
"default",
":",
"throw",
"new",
"LogicException",
"(",
"\"Invalid file access type: '\"",
".",
"$",
"metadata",
"[",
"\"mode\"",
"]",
".",
"\"'\"",
")",
";",
"break",
";",
"}",
"}",
"# does this stream support seek functionality?",
"if",
"(",
"isset",
"(",
"$",
"metadata",
"[",
"\"seekable\"",
"]",
")",
")",
"$",
"this",
"->",
"is_seekable",
"=",
"(",
"boolean",
")",
"$",
"metadata",
"[",
"\"seekable\"",
"]",
";",
"return",
"null",
";",
"}"
] | Set the file pointer | [
"Set",
"the",
"file",
"pointer"
] | 8da9ecad1e4190f31f8776aeadd9c7db41107f68 | https://github.com/OUTRAGElib/psr7-file-stream/blob/8da9ecad1e4190f31f8776aeadd9c7db41107f68/lib/Stream.php#L46-L115 | train |
libreworks/caridea-auth | src/Adapter/MongoDb.php | MongoDb.getResults | protected function getResults(string $username, ServerRequestInterface $request): \MongoDB\Driver\Cursor
{
$q = new \MongoDB\Driver\Query(
array_merge($this->query, [($this->fieldUser) => $username]),
['projection' => [($this->fieldUser) => true, ($this->fieldPass) => true]]
);
return $this->manager->executeQuery($this->collection, $q, $this->rp);
} | php | protected function getResults(string $username, ServerRequestInterface $request): \MongoDB\Driver\Cursor
{
$q = new \MongoDB\Driver\Query(
array_merge($this->query, [($this->fieldUser) => $username]),
['projection' => [($this->fieldUser) => true, ($this->fieldPass) => true]]
);
return $this->manager->executeQuery($this->collection, $q, $this->rp);
} | [
"protected",
"function",
"getResults",
"(",
"string",
"$",
"username",
",",
"ServerRequestInterface",
"$",
"request",
")",
":",
"\\",
"MongoDB",
"\\",
"Driver",
"\\",
"Cursor",
"{",
"$",
"q",
"=",
"new",
"\\",
"MongoDB",
"\\",
"Driver",
"\\",
"Query",
"(",
"array_merge",
"(",
"$",
"this",
"->",
"query",
",",
"[",
"(",
"$",
"this",
"->",
"fieldUser",
")",
"=>",
"$",
"username",
"]",
")",
",",
"[",
"'projection'",
"=>",
"[",
"(",
"$",
"this",
"->",
"fieldUser",
")",
"=>",
"true",
",",
"(",
"$",
"this",
"->",
"fieldPass",
")",
"=>",
"true",
"]",
"]",
")",
";",
"return",
"$",
"this",
"->",
"manager",
"->",
"executeQuery",
"(",
"$",
"this",
"->",
"collection",
",",
"$",
"q",
",",
"$",
"this",
"->",
"rp",
")",
";",
"}"
] | Queries the MongoDB collection.
@param string $username The username to use for parameter binding
@param ServerRequestInterface $request The Server Request message (to use for additional parameter binding)
@return \MongoDB\Driver\Cursor The results cursor | [
"Queries",
"the",
"MongoDB",
"collection",
"."
] | 1bf965c57716942b18ca3204629f6bda99cf876a | https://github.com/libreworks/caridea-auth/blob/1bf965c57716942b18ca3204629f6bda99cf876a/src/Adapter/MongoDb.php#L119-L126 | train |
libreworks/caridea-auth | src/Adapter/MongoDb.php | MongoDb.fetchResult | protected function fetchResult(\MongoDB\Driver\Cursor $results, string $username): \stdClass
{
$values = $results->toArray();
if (count($values) > 1) {
throw new \Caridea\Auth\Exception\UsernameAmbiguous($username);
} elseif (count($values) == 0) {
throw new \Caridea\Auth\Exception\UsernameNotFound($username);
}
return current($values);
} | php | protected function fetchResult(\MongoDB\Driver\Cursor $results, string $username): \stdClass
{
$values = $results->toArray();
if (count($values) > 1) {
throw new \Caridea\Auth\Exception\UsernameAmbiguous($username);
} elseif (count($values) == 0) {
throw new \Caridea\Auth\Exception\UsernameNotFound($username);
}
return current($values);
} | [
"protected",
"function",
"fetchResult",
"(",
"\\",
"MongoDB",
"\\",
"Driver",
"\\",
"Cursor",
"$",
"results",
",",
"string",
"$",
"username",
")",
":",
"\\",
"stdClass",
"{",
"$",
"values",
"=",
"$",
"results",
"->",
"toArray",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"values",
")",
">",
"1",
")",
"{",
"throw",
"new",
"\\",
"Caridea",
"\\",
"Auth",
"\\",
"Exception",
"\\",
"UsernameAmbiguous",
"(",
"$",
"username",
")",
";",
"}",
"elseif",
"(",
"count",
"(",
"$",
"values",
")",
"==",
"0",
")",
"{",
"throw",
"new",
"\\",
"Caridea",
"\\",
"Auth",
"\\",
"Exception",
"\\",
"UsernameNotFound",
"(",
"$",
"username",
")",
";",
"}",
"return",
"current",
"(",
"$",
"values",
")",
";",
"}"
] | Fetches a single result from the Mongo Cursor.
@param \MongoCursor $results The results
@param string $username The attempted username (for Exception purposes)
@return \stdClass A single MongoDB document
@throws \Caridea\Auth\Exception\UsernameAmbiguous If there is more than 1 result
@throws \Caridea\Auth\Exception\UsernameNotFound If there are 0 results | [
"Fetches",
"a",
"single",
"result",
"from",
"the",
"Mongo",
"Cursor",
"."
] | 1bf965c57716942b18ca3204629f6bda99cf876a | https://github.com/libreworks/caridea-auth/blob/1bf965c57716942b18ca3204629f6bda99cf876a/src/Adapter/MongoDb.php#L137-L146 | train |
native5/native5-sdk-client-php | src/Native5/Sessions/CachedSessionHandler.php | CachedSessionHandler.destroy | public function destroy($sessionId)
{
$sql = 'DELETE from tbl_sessions where SESSION_ID=:SESSID';
$delete = $this->_db->prepare($sql);
$delete->execute(array(':SESSID' => $sessionId));
$this->_cache->delete($sessionId);
return true;
} | php | public function destroy($sessionId)
{
$sql = 'DELETE from tbl_sessions where SESSION_ID=:SESSID';
$delete = $this->_db->prepare($sql);
$delete->execute(array(':SESSID' => $sessionId));
$this->_cache->delete($sessionId);
return true;
} | [
"public",
"function",
"destroy",
"(",
"$",
"sessionId",
")",
"{",
"$",
"sql",
"=",
"'DELETE from tbl_sessions where SESSION_ID=:SESSID'",
";",
"$",
"delete",
"=",
"$",
"this",
"->",
"_db",
"->",
"prepare",
"(",
"$",
"sql",
")",
";",
"$",
"delete",
"->",
"execute",
"(",
"array",
"(",
"':SESSID'",
"=>",
"$",
"sessionId",
")",
")",
";",
"$",
"this",
"->",
"_cache",
"->",
"delete",
"(",
"$",
"sessionId",
")",
";",
"return",
"true",
";",
"}"
] | destroy Destroying the session deletes it from the cache as
well as the backend database.
@param mixed $sessionId The session id
@access public
@return void | [
"destroy",
"Destroying",
"the",
"session",
"deletes",
"it",
"from",
"the",
"cache",
"as",
"well",
"as",
"the",
"backend",
"database",
"."
] | e1f598cf27654d81bb5facace1990b737242a2f9 | https://github.com/native5/native5-sdk-client-php/blob/e1f598cf27654d81bb5facace1990b737242a2f9/src/Native5/Sessions/CachedSessionHandler.php#L78-L87 | train |
native5/native5-sdk-client-php | src/Native5/Sessions/CachedSessionHandler.php | CachedSessionHandler.gc | public function gc($lifetime)
{
$sql = 'DELETE from tbl_sessions where LAST_ACCESSED < DATE_SUB(NOW(), INTERVAL :LIFETIME SECOND)';
$delete = $this->_db->prepare($sql);
$count = $delete->execute(array(':LIFETIME' => $lifetime));
return true;
} | php | public function gc($lifetime)
{
$sql = 'DELETE from tbl_sessions where LAST_ACCESSED < DATE_SUB(NOW(), INTERVAL :LIFETIME SECOND)';
$delete = $this->_db->prepare($sql);
$count = $delete->execute(array(':LIFETIME' => $lifetime));
return true;
} | [
"public",
"function",
"gc",
"(",
"$",
"lifetime",
")",
"{",
"$",
"sql",
"=",
"'DELETE from tbl_sessions where LAST_ACCESSED < DATE_SUB(NOW(), INTERVAL :LIFETIME SECOND)'",
";",
"$",
"delete",
"=",
"$",
"this",
"->",
"_db",
"->",
"prepare",
"(",
"$",
"sql",
")",
";",
"$",
"count",
"=",
"$",
"delete",
"->",
"execute",
"(",
"array",
"(",
"':LIFETIME'",
"=>",
"$",
"lifetime",
")",
")",
";",
"return",
"true",
";",
"}"
] | Garbage collection causes all expired sessions to be deleted.
@param mixed $lifetime The max-lifetime of the session.
@access public
@return void | [
"Garbage",
"collection",
"causes",
"all",
"expired",
"sessions",
"to",
"be",
"deleted",
"."
] | e1f598cf27654d81bb5facace1990b737242a2f9 | https://github.com/native5/native5-sdk-client-php/blob/e1f598cf27654d81bb5facace1990b737242a2f9/src/Native5/Sessions/CachedSessionHandler.php#L98-L106 | train |
native5/native5-sdk-client-php | src/Native5/Sessions/CachedSessionHandler.php | CachedSessionHandler.open | public function open($savePath, $sessionName)
{
$sql = 'INSERT INTO tbl_sessions (SESSION_ID, SESSION_DATA) values (:SESSID, :SESSDATA) ON DUPLICATE KEY UPDATE LAST_ACCESSED=NOW()';
$stmt = $this->_db->prepare($sql);
$stmt->execute(array(':SESSID' => session_id(), ':SESSDATA' => ''));
} | php | public function open($savePath, $sessionName)
{
$sql = 'INSERT INTO tbl_sessions (SESSION_ID, SESSION_DATA) values (:SESSID, :SESSDATA) ON DUPLICATE KEY UPDATE LAST_ACCESSED=NOW()';
$stmt = $this->_db->prepare($sql);
$stmt->execute(array(':SESSID' => session_id(), ':SESSDATA' => ''));
} | [
"public",
"function",
"open",
"(",
"$",
"savePath",
",",
"$",
"sessionName",
")",
"{",
"$",
"sql",
"=",
"'INSERT INTO tbl_sessions (SESSION_ID, SESSION_DATA) values (:SESSID, :SESSDATA) ON DUPLICATE KEY UPDATE LAST_ACCESSED=NOW()'",
";",
"$",
"stmt",
"=",
"$",
"this",
"->",
"_db",
"->",
"prepare",
"(",
"$",
"sql",
")",
";",
"$",
"stmt",
"->",
"execute",
"(",
"array",
"(",
"':SESSID'",
"=>",
"session_id",
"(",
")",
",",
"':SESSDATA'",
"=>",
"''",
")",
")",
";",
"}"
] | open Opening the session causes an insert into the sessions table.
@param mixed $savePath SavePath, relevant only while persisting to disk.
@param mixed $sessionName SessionName
@access public
@return void | [
"open",
"Opening",
"the",
"session",
"causes",
"an",
"insert",
"into",
"the",
"sessions",
"table",
"."
] | e1f598cf27654d81bb5facace1990b737242a2f9 | https://github.com/native5/native5-sdk-client-php/blob/e1f598cf27654d81bb5facace1990b737242a2f9/src/Native5/Sessions/CachedSessionHandler.php#L118-L124 | train |
xZ1mEFx/yii2-base | db/ActiveRecord.php | ActiveRecord.lockTables | public static function lockTables($table = NULL, $blockType = 'WRITE')
{
$sql = "LOCK TABLES ";
if ($table === NULL) {
$sql .= self::tableName() . " $blockType";
} else {
$tmpSql = '';
foreach ((is_array($table) ? $table : [$table]) as $key => $value) {
$tmpSql .= empty($tmpSql) ? '' : ', ';
$tmpSql .= "$value";
$tmpSql .= is_string($key) ? " $key" : '';
$tmpSql .= " $blockType";
}
$sql .= $tmpSql;
}
// die(Yii::$app->db->createCommand($sql)->rawSql);
Yii::$app->db->createCommand($sql)->query();
} | php | public static function lockTables($table = NULL, $blockType = 'WRITE')
{
$sql = "LOCK TABLES ";
if ($table === NULL) {
$sql .= self::tableName() . " $blockType";
} else {
$tmpSql = '';
foreach ((is_array($table) ? $table : [$table]) as $key => $value) {
$tmpSql .= empty($tmpSql) ? '' : ', ';
$tmpSql .= "$value";
$tmpSql .= is_string($key) ? " $key" : '';
$tmpSql .= " $blockType";
}
$sql .= $tmpSql;
}
// die(Yii::$app->db->createCommand($sql)->rawSql);
Yii::$app->db->createCommand($sql)->query();
} | [
"public",
"static",
"function",
"lockTables",
"(",
"$",
"table",
"=",
"NULL",
",",
"$",
"blockType",
"=",
"'WRITE'",
")",
"{",
"$",
"sql",
"=",
"\"LOCK TABLES \"",
";",
"if",
"(",
"$",
"table",
"===",
"NULL",
")",
"{",
"$",
"sql",
".=",
"self",
"::",
"tableName",
"(",
")",
".",
"\" $blockType\"",
";",
"}",
"else",
"{",
"$",
"tmpSql",
"=",
"''",
";",
"foreach",
"(",
"(",
"is_array",
"(",
"$",
"table",
")",
"?",
"$",
"table",
":",
"[",
"$",
"table",
"]",
")",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"tmpSql",
".=",
"empty",
"(",
"$",
"tmpSql",
")",
"?",
"''",
":",
"', '",
";",
"$",
"tmpSql",
".=",
"\"$value\"",
";",
"$",
"tmpSql",
".=",
"is_string",
"(",
"$",
"key",
")",
"?",
"\" $key\"",
":",
"''",
";",
"$",
"tmpSql",
".=",
"\" $blockType\"",
";",
"}",
"$",
"sql",
".=",
"$",
"tmpSql",
";",
"}",
"// die(Yii::$app->db->createCommand($sql)->rawSql);",
"Yii",
"::",
"$",
"app",
"->",
"db",
"->",
"createCommand",
"(",
"$",
"sql",
")",
"->",
"query",
"(",
")",
";",
"}"
] | Lock DB tables
@param null|string|array $table Examples:
'table_name'
or 'table_name tn'
or ['table_name_1 tn1', 'table_name_2', 'tn3'=>'table_name_3']
@param string $blockType 'WRITE'|'READ' | [
"Lock",
"DB",
"tables"
] | f6633c08ccccb7eb5ac000dfae0db26cb2e0a76a | https://github.com/xZ1mEFx/yii2-base/blob/f6633c08ccccb7eb5ac000dfae0db26cb2e0a76a/db/ActiveRecord.php#L22-L39 | train |
phpffcms/ffcms-core | src/Debug/Manager.php | Manager.renderOut | public function renderOut()
{
foreach (Error::all() as $file => $error) {
foreach ($error as $line) {
$this->addMessage('Template error: ' . $line . '(' . $file . ')', 'error');
}
}
return $this->render->render();
} | php | public function renderOut()
{
foreach (Error::all() as $file => $error) {
foreach ($error as $line) {
$this->addMessage('Template error: ' . $line . '(' . $file . ')', 'error');
}
}
return $this->render->render();
} | [
"public",
"function",
"renderOut",
"(",
")",
"{",
"foreach",
"(",
"Error",
"::",
"all",
"(",
")",
"as",
"$",
"file",
"=>",
"$",
"error",
")",
"{",
"foreach",
"(",
"$",
"error",
"as",
"$",
"line",
")",
"{",
"$",
"this",
"->",
"addMessage",
"(",
"'Template error: '",
".",
"$",
"line",
".",
"'('",
".",
"$",
"file",
".",
"')'",
",",
"'error'",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"render",
"->",
"render",
"(",
")",
";",
"}"
] | Render debug bar code
@return string | [
"Render",
"debug",
"bar",
"code"
] | 44a309553ef9f115ccfcfd71f2ac6e381c612082 | https://github.com/phpffcms/ffcms-core/blob/44a309553ef9f115ccfcfd71f2ac6e381c612082/src/Debug/Manager.php#L48-L56 | train |
phpffcms/ffcms-core | src/Debug/Manager.php | Manager.addException | public function addException($e)
{
if ($e instanceof \Exception) {
try {
$this->bar->getCollector('exceptions')->addException($e);
} catch (\Exception $ie) {
} // mute exceptions there
}
} | php | public function addException($e)
{
if ($e instanceof \Exception) {
try {
$this->bar->getCollector('exceptions')->addException($e);
} catch (\Exception $ie) {
} // mute exceptions there
}
} | [
"public",
"function",
"addException",
"(",
"$",
"e",
")",
"{",
"if",
"(",
"$",
"e",
"instanceof",
"\\",
"Exception",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"bar",
"->",
"getCollector",
"(",
"'exceptions'",
")",
"->",
"addException",
"(",
"$",
"e",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"ie",
")",
"{",
"}",
"// mute exceptions there",
"}",
"}"
] | Add exception into debug bar and stop execute
@param \Exception $e | [
"Add",
"exception",
"into",
"debug",
"bar",
"and",
"stop",
"execute"
] | 44a309553ef9f115ccfcfd71f2ac6e381c612082 | https://github.com/phpffcms/ffcms-core/blob/44a309553ef9f115ccfcfd71f2ac6e381c612082/src/Debug/Manager.php#L62-L70 | train |
phpffcms/ffcms-core | src/Debug/Manager.php | Manager.addMessage | public function addMessage($m, $type = 'info')
{
if (!Any::isStr($m) || !Any::isStr($type)) {
return;
}
$m = App::$Security->secureHtml($m);
try {
$mCollector = $this->bar->getCollector('messages');
if (method_exists($mCollector, $type)) {
$this->bar->getCollector('messages')->{$type}($m);
}
} catch (\Exception $e) {
} // mute exceptions there
} | php | public function addMessage($m, $type = 'info')
{
if (!Any::isStr($m) || !Any::isStr($type)) {
return;
}
$m = App::$Security->secureHtml($m);
try {
$mCollector = $this->bar->getCollector('messages');
if (method_exists($mCollector, $type)) {
$this->bar->getCollector('messages')->{$type}($m);
}
} catch (\Exception $e) {
} // mute exceptions there
} | [
"public",
"function",
"addMessage",
"(",
"$",
"m",
",",
"$",
"type",
"=",
"'info'",
")",
"{",
"if",
"(",
"!",
"Any",
"::",
"isStr",
"(",
"$",
"m",
")",
"||",
"!",
"Any",
"::",
"isStr",
"(",
"$",
"type",
")",
")",
"{",
"return",
";",
"}",
"$",
"m",
"=",
"App",
"::",
"$",
"Security",
"->",
"secureHtml",
"(",
"$",
"m",
")",
";",
"try",
"{",
"$",
"mCollector",
"=",
"$",
"this",
"->",
"bar",
"->",
"getCollector",
"(",
"'messages'",
")",
";",
"if",
"(",
"method_exists",
"(",
"$",
"mCollector",
",",
"$",
"type",
")",
")",
"{",
"$",
"this",
"->",
"bar",
"->",
"getCollector",
"(",
"'messages'",
")",
"->",
"{",
"$",
"type",
"}",
"(",
"$",
"m",
")",
";",
"}",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"}",
"// mute exceptions there",
"}"
] | Add message into debug bar
@param string $m
@param string $type | [
"Add",
"message",
"into",
"debug",
"bar"
] | 44a309553ef9f115ccfcfd71f2ac6e381c612082 | https://github.com/phpffcms/ffcms-core/blob/44a309553ef9f115ccfcfd71f2ac6e381c612082/src/Debug/Manager.php#L77-L92 | train |
vpg/titon.utility | src/Titon/Utility/Converter.php | Converter.autobox | public static function autobox($value) {
if (is_numeric($value)) {
if (strpos($value, '.') !== false) {
return (float) $value;
} else {
return (int) $value;
}
} else if (is_bool($value)) {
return (bool) $value;
} else if ($value === 'true' || $value === 'false') {
return ($value === 'true');
}
return (string) $value;
} | php | public static function autobox($value) {
if (is_numeric($value)) {
if (strpos($value, '.') !== false) {
return (float) $value;
} else {
return (int) $value;
}
} else if (is_bool($value)) {
return (bool) $value;
} else if ($value === 'true' || $value === 'false') {
return ($value === 'true');
}
return (string) $value;
} | [
"public",
"static",
"function",
"autobox",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"is_numeric",
"(",
"$",
"value",
")",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"value",
",",
"'.'",
")",
"!==",
"false",
")",
"{",
"return",
"(",
"float",
")",
"$",
"value",
";",
"}",
"else",
"{",
"return",
"(",
"int",
")",
"$",
"value",
";",
"}",
"}",
"else",
"if",
"(",
"is_bool",
"(",
"$",
"value",
")",
")",
"{",
"return",
"(",
"bool",
")",
"$",
"value",
";",
"}",
"else",
"if",
"(",
"$",
"value",
"===",
"'true'",
"||",
"$",
"value",
"===",
"'false'",
")",
"{",
"return",
"(",
"$",
"value",
"===",
"'true'",
")",
";",
"}",
"return",
"(",
"string",
")",
"$",
"value",
";",
"}"
] | Autobox a value by type casting it.
@param mixed $value
@return mixed | [
"Autobox",
"a",
"value",
"by",
"type",
"casting",
"it",
"."
] | 8a77eb9e7b8baacf41cc25487289779d8319cd3a | https://github.com/vpg/titon.utility/blob/8a77eb9e7b8baacf41cc25487289779d8319cd3a/src/Titon/Utility/Converter.php#L43-L59 | train |
vpg/titon.utility | src/Titon/Utility/Converter.php | Converter.isJson | public static function isJson($data) {
if (!is_string($data) || empty($data)) {
return false;
}
$json = @json_decode($data, true);
return (json_last_error() === JSON_ERROR_NONE && $json !== null);
} | php | public static function isJson($data) {
if (!is_string($data) || empty($data)) {
return false;
}
$json = @json_decode($data, true);
return (json_last_error() === JSON_ERROR_NONE && $json !== null);
} | [
"public",
"static",
"function",
"isJson",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"data",
")",
"||",
"empty",
"(",
"$",
"data",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"json",
"=",
"@",
"json_decode",
"(",
"$",
"data",
",",
"true",
")",
";",
"return",
"(",
"json_last_error",
"(",
")",
"===",
"JSON_ERROR_NONE",
"&&",
"$",
"json",
"!==",
"null",
")",
";",
"}"
] | Check to see if data passed is a JSON object.
@param mixed $data
@return bool | [
"Check",
"to",
"see",
"if",
"data",
"passed",
"is",
"a",
"JSON",
"object",
"."
] | 8a77eb9e7b8baacf41cc25487289779d8319cd3a | https://github.com/vpg/titon.utility/blob/8a77eb9e7b8baacf41cc25487289779d8319cd3a/src/Titon/Utility/Converter.php#L125-L133 | train |
vpg/titon.utility | src/Titon/Utility/Converter.php | Converter.isSerialized | public static function isSerialized($data) {
if (!is_string($data) || empty($data)) {
return false;
}
return (@unserialize($data) !== false);
} | php | public static function isSerialized($data) {
if (!is_string($data) || empty($data)) {
return false;
}
return (@unserialize($data) !== false);
} | [
"public",
"static",
"function",
"isSerialized",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"data",
")",
"||",
"empty",
"(",
"$",
"data",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"(",
"@",
"unserialize",
"(",
"$",
"data",
")",
"!==",
"false",
")",
";",
"}"
] | Check to see if data passed has been serialized.
@param mixed $data
@return bool | [
"Check",
"to",
"see",
"if",
"data",
"passed",
"has",
"been",
"serialized",
"."
] | 8a77eb9e7b8baacf41cc25487289779d8319cd3a | https://github.com/vpg/titon.utility/blob/8a77eb9e7b8baacf41cc25487289779d8319cd3a/src/Titon/Utility/Converter.php#L151-L157 | train |
vpg/titon.utility | src/Titon/Utility/Converter.php | Converter.isXml | public static function isXml($data) {
// Do manually checks on the string since HHVM blows up
if (!is_string($data) || substr($data, 0, 5) !== '<?xml') {
return false;
}
return (@simplexml_load_string($data) instanceof SimpleXMLElement);
} | php | public static function isXml($data) {
// Do manually checks on the string since HHVM blows up
if (!is_string($data) || substr($data, 0, 5) !== '<?xml') {
return false;
}
return (@simplexml_load_string($data) instanceof SimpleXMLElement);
} | [
"public",
"static",
"function",
"isXml",
"(",
"$",
"data",
")",
"{",
"// Do manually checks on the string since HHVM blows up",
"if",
"(",
"!",
"is_string",
"(",
"$",
"data",
")",
"||",
"substr",
"(",
"$",
"data",
",",
"0",
",",
"5",
")",
"!==",
"'<?xml'",
")",
"{",
"return",
"false",
";",
"}",
"return",
"(",
"@",
"simplexml_load_string",
"(",
"$",
"data",
")",
"instanceof",
"SimpleXMLElement",
")",
";",
"}"
] | Check to see if data passed is an XML document.
@param mixed $data
@return bool | [
"Check",
"to",
"see",
"if",
"data",
"passed",
"is",
"an",
"XML",
"document",
"."
] | 8a77eb9e7b8baacf41cc25487289779d8319cd3a | https://github.com/vpg/titon.utility/blob/8a77eb9e7b8baacf41cc25487289779d8319cd3a/src/Titon/Utility/Converter.php#L165-L172 | train |
jenskooij/cloudcontrol | src/components/cms/BaseRouting.php | BaseRouting.route | public function route()
{
$this->dashboardRouting($this->relativeCmsUri);
$this->logOffRouting($this->request, $this->relativeCmsUri);
$this->apiRouting($this->relativeCmsUri);
$this->documentRouting($this->userRights, $this->relativeCmsUri);
$this->valuelistsRouting($this->userRights, $this->relativeCmsUri);
$this->sitemapRouting($this->userRights, $this->relativeCmsUri);
$this->redirectRouting($this->userRights, $this->relativeCmsUri);
$this->imageRouting($this->userRights, $this->relativeCmsUri);
$this->filesRouting($this->userRights, $this->relativeCmsUri);
$this->configurationRouting($this->userRights, $this->relativeCmsUri);
$this->searchRouting($this->relativeCmsUri);
} | php | public function route()
{
$this->dashboardRouting($this->relativeCmsUri);
$this->logOffRouting($this->request, $this->relativeCmsUri);
$this->apiRouting($this->relativeCmsUri);
$this->documentRouting($this->userRights, $this->relativeCmsUri);
$this->valuelistsRouting($this->userRights, $this->relativeCmsUri);
$this->sitemapRouting($this->userRights, $this->relativeCmsUri);
$this->redirectRouting($this->userRights, $this->relativeCmsUri);
$this->imageRouting($this->userRights, $this->relativeCmsUri);
$this->filesRouting($this->userRights, $this->relativeCmsUri);
$this->configurationRouting($this->userRights, $this->relativeCmsUri);
$this->searchRouting($this->relativeCmsUri);
} | [
"public",
"function",
"route",
"(",
")",
"{",
"$",
"this",
"->",
"dashboardRouting",
"(",
"$",
"this",
"->",
"relativeCmsUri",
")",
";",
"$",
"this",
"->",
"logOffRouting",
"(",
"$",
"this",
"->",
"request",
",",
"$",
"this",
"->",
"relativeCmsUri",
")",
";",
"$",
"this",
"->",
"apiRouting",
"(",
"$",
"this",
"->",
"relativeCmsUri",
")",
";",
"$",
"this",
"->",
"documentRouting",
"(",
"$",
"this",
"->",
"userRights",
",",
"$",
"this",
"->",
"relativeCmsUri",
")",
";",
"$",
"this",
"->",
"valuelistsRouting",
"(",
"$",
"this",
"->",
"userRights",
",",
"$",
"this",
"->",
"relativeCmsUri",
")",
";",
"$",
"this",
"->",
"sitemapRouting",
"(",
"$",
"this",
"->",
"userRights",
",",
"$",
"this",
"->",
"relativeCmsUri",
")",
";",
"$",
"this",
"->",
"redirectRouting",
"(",
"$",
"this",
"->",
"userRights",
",",
"$",
"this",
"->",
"relativeCmsUri",
")",
";",
"$",
"this",
"->",
"imageRouting",
"(",
"$",
"this",
"->",
"userRights",
",",
"$",
"this",
"->",
"relativeCmsUri",
")",
";",
"$",
"this",
"->",
"filesRouting",
"(",
"$",
"this",
"->",
"userRights",
",",
"$",
"this",
"->",
"relativeCmsUri",
")",
";",
"$",
"this",
"->",
"configurationRouting",
"(",
"$",
"this",
"->",
"userRights",
",",
"$",
"this",
"->",
"relativeCmsUri",
")",
";",
"$",
"this",
"->",
"searchRouting",
"(",
"$",
"this",
"->",
"relativeCmsUri",
")",
";",
"}"
] | Call the different routing methods
@throws \Exception | [
"Call",
"the",
"different",
"routing",
"methods"
] | 76e5d9ac8f9c50d06d39a995d13cc03742536548 | https://github.com/jenskooij/cloudcontrol/blob/76e5d9ac8f9c50d06d39a995d13cc03742536548/src/components/cms/BaseRouting.php#L58-L71 | train |
Mandarin-Medien/MMCmfContentBundle | Templating/TemplateManager.php | TemplateManager.getTemplate | public function getTemplate(TemplatableNodeInterface $node)
{
$template = $node->getTemplate();
if (!$template) {
$meta = $this->manager->getClassMetadata(get_class($node));
if (!empty($this->templates[$meta->name]) && count($this->templates[$meta->name]) > 0)
$template = reset($this->templates[$meta->name]);
else {
$name = trim(str_replace($meta->namespace, '', $meta->name), '\\');
$bundleName = $this->getBundleNameFromEntity($meta->namespace, $this->container->get('kernel')->getBundles());
$template = $this->getDefaultTemplate($name, $bundleName);
}
}
return $template;
} | php | public function getTemplate(TemplatableNodeInterface $node)
{
$template = $node->getTemplate();
if (!$template) {
$meta = $this->manager->getClassMetadata(get_class($node));
if (!empty($this->templates[$meta->name]) && count($this->templates[$meta->name]) > 0)
$template = reset($this->templates[$meta->name]);
else {
$name = trim(str_replace($meta->namespace, '', $meta->name), '\\');
$bundleName = $this->getBundleNameFromEntity($meta->namespace, $this->container->get('kernel')->getBundles());
$template = $this->getDefaultTemplate($name, $bundleName);
}
}
return $template;
} | [
"public",
"function",
"getTemplate",
"(",
"TemplatableNodeInterface",
"$",
"node",
")",
"{",
"$",
"template",
"=",
"$",
"node",
"->",
"getTemplate",
"(",
")",
";",
"if",
"(",
"!",
"$",
"template",
")",
"{",
"$",
"meta",
"=",
"$",
"this",
"->",
"manager",
"->",
"getClassMetadata",
"(",
"get_class",
"(",
"$",
"node",
")",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"templates",
"[",
"$",
"meta",
"->",
"name",
"]",
")",
"&&",
"count",
"(",
"$",
"this",
"->",
"templates",
"[",
"$",
"meta",
"->",
"name",
"]",
")",
">",
"0",
")",
"$",
"template",
"=",
"reset",
"(",
"$",
"this",
"->",
"templates",
"[",
"$",
"meta",
"->",
"name",
"]",
")",
";",
"else",
"{",
"$",
"name",
"=",
"trim",
"(",
"str_replace",
"(",
"$",
"meta",
"->",
"namespace",
",",
"''",
",",
"$",
"meta",
"->",
"name",
")",
",",
"'\\\\'",
")",
";",
"$",
"bundleName",
"=",
"$",
"this",
"->",
"getBundleNameFromEntity",
"(",
"$",
"meta",
"->",
"namespace",
",",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'kernel'",
")",
"->",
"getBundles",
"(",
")",
")",
";",
"$",
"template",
"=",
"$",
"this",
"->",
"getDefaultTemplate",
"(",
"$",
"name",
",",
"$",
"bundleName",
")",
";",
"}",
"}",
"return",
"$",
"template",
";",
"}"
] | get the assigned template of the given TemplatableNodeInterface
handles the template selection if no template is assigned
@param TemplatableNodeInterface $node
@return mixed|string | [
"get",
"the",
"assigned",
"template",
"of",
"the",
"given",
"TemplatableNodeInterface",
"handles",
"the",
"template",
"selection",
"if",
"no",
"template",
"is",
"assigned"
] | 503ab31cef3ce068f767de5b72f833526355b726 | https://github.com/Mandarin-Medien/MMCmfContentBundle/blob/503ab31cef3ce068f767de5b72f833526355b726/Templating/TemplateManager.php#L84-L105 | train |
Mandarin-Medien/MMCmfContentBundle | Templating/TemplateManager.php | TemplateManager.getBundleNameFromEntity | protected static function getBundleNameFromEntity($entityNamespace, $bundles)
{
$dataBaseNamespace = substr($entityNamespace, 0, strpos($entityNamespace, '\\Entity'));
foreach ($bundles as $type => $bundle) {
$bundleRefClass = new \ReflectionClass($bundle);
if ($bundleRefClass->getNamespaceName() === $dataBaseNamespace) {
return $type;
}
}
return null;
} | php | protected static function getBundleNameFromEntity($entityNamespace, $bundles)
{
$dataBaseNamespace = substr($entityNamespace, 0, strpos($entityNamespace, '\\Entity'));
foreach ($bundles as $type => $bundle) {
$bundleRefClass = new \ReflectionClass($bundle);
if ($bundleRefClass->getNamespaceName() === $dataBaseNamespace) {
return $type;
}
}
return null;
} | [
"protected",
"static",
"function",
"getBundleNameFromEntity",
"(",
"$",
"entityNamespace",
",",
"$",
"bundles",
")",
"{",
"$",
"dataBaseNamespace",
"=",
"substr",
"(",
"$",
"entityNamespace",
",",
"0",
",",
"strpos",
"(",
"$",
"entityNamespace",
",",
"'\\\\Entity'",
")",
")",
";",
"foreach",
"(",
"$",
"bundles",
"as",
"$",
"type",
"=>",
"$",
"bundle",
")",
"{",
"$",
"bundleRefClass",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"bundle",
")",
";",
"if",
"(",
"$",
"bundleRefClass",
"->",
"getNamespaceName",
"(",
")",
"===",
"$",
"dataBaseNamespace",
")",
"{",
"return",
"$",
"type",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Get the bundle name from an Entity namespace
@param $entityNamespace
@param $bundles
@return string|null | [
"Get",
"the",
"bundle",
"name",
"from",
"an",
"Entity",
"namespace"
] | 503ab31cef3ce068f767de5b72f833526355b726 | https://github.com/Mandarin-Medien/MMCmfContentBundle/blob/503ab31cef3ce068f767de5b72f833526355b726/Templating/TemplateManager.php#L114-L126 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.