repository_name
stringlengths 5
67
| func_path_in_repository
stringlengths 4
234
| func_name
stringlengths 0
314
| whole_func_string
stringlengths 52
3.87M
| language
stringclasses 6
values | func_code_string
stringlengths 52
3.87M
| func_code_tokens
listlengths 15
672k
| func_documentation_string
stringlengths 1
47.2k
| func_documentation_tokens
listlengths 1
3.92k
| split_name
stringclasses 1
value | func_code_url
stringlengths 85
339
|
---|---|---|---|---|---|---|---|---|---|---|
4devs/ElfinderPhpConnector | Driver/PhotatoesDriver.php | PhotatoesDriver.getGallery | private function getGallery(Response $response, $target = '')
{
if ($target && $gallery = $this->manager->getGallery(basename($target))) {
$response->setCwd($this->prepareGallery($gallery));
$images = $gallery->getImages(true);
foreach ($images as $img) {
$this->addImages(
$response,
$img,
$this->driverOptions['rootName'].DIRECTORY_SEPARATOR.basename($target)
);
}
}
} | php | private function getGallery(Response $response, $target = '')
{
if ($target && $gallery = $this->manager->getGallery(basename($target))) {
$response->setCwd($this->prepareGallery($gallery));
$images = $gallery->getImages(true);
foreach ($images as $img) {
$this->addImages(
$response,
$img,
$this->driverOptions['rootName'].DIRECTORY_SEPARATOR.basename($target)
);
}
}
} | [
"private",
"function",
"getGallery",
"(",
"Response",
"$",
"response",
",",
"$",
"target",
"=",
"''",
")",
"{",
"if",
"(",
"$",
"target",
"&&",
"$",
"gallery",
"=",
"$",
"this",
"->",
"manager",
"->",
"getGallery",
"(",
"basename",
"(",
"$",
"target",
")",
")",
")",
"{",
"$",
"response",
"->",
"setCwd",
"(",
"$",
"this",
"->",
"prepareGallery",
"(",
"$",
"gallery",
")",
")",
";",
"$",
"images",
"=",
"$",
"gallery",
"->",
"getImages",
"(",
"true",
")",
";",
"foreach",
"(",
"$",
"images",
"as",
"$",
"img",
")",
"{",
"$",
"this",
"->",
"addImages",
"(",
"$",
"response",
",",
"$",
"img",
",",
"$",
"this",
"->",
"driverOptions",
"[",
"'rootName'",
"]",
".",
"DIRECTORY_SEPARATOR",
".",
"basename",
"(",
"$",
"target",
")",
")",
";",
"}",
"}",
"}"
]
| get Gallery.
@param Response $response
@param string $target | [
"get",
"Gallery",
"."
]
| train | https://github.com/4devs/ElfinderPhpConnector/blob/510e295dcafeaa0f796986ad87b3ed5f6b0d9338/Driver/PhotatoesDriver.php#L177-L190 |
4devs/ElfinderPhpConnector | Driver/PhotatoesDriver.php | PhotatoesDriver.prepareGallery | private function prepareGallery(Gallery $gallery)
{
$time = $gallery->getUpdatedAt() ? $gallery->getUpdatedAt()->getTimestamp() : time();
$file = new FileInfo($gallery->getName(), $this->driverId, $time, $this->driverOptions['rootName']);
$file->setHash(
$this->getDriverId().'_'.FileInfo::encode(
$this->driverOptions['rootName'].DIRECTORY_SEPARATOR.$gallery->getId()
)
);
return $file;
} | php | private function prepareGallery(Gallery $gallery)
{
$time = $gallery->getUpdatedAt() ? $gallery->getUpdatedAt()->getTimestamp() : time();
$file = new FileInfo($gallery->getName(), $this->driverId, $time, $this->driverOptions['rootName']);
$file->setHash(
$this->getDriverId().'_'.FileInfo::encode(
$this->driverOptions['rootName'].DIRECTORY_SEPARATOR.$gallery->getId()
)
);
return $file;
} | [
"private",
"function",
"prepareGallery",
"(",
"Gallery",
"$",
"gallery",
")",
"{",
"$",
"time",
"=",
"$",
"gallery",
"->",
"getUpdatedAt",
"(",
")",
"?",
"$",
"gallery",
"->",
"getUpdatedAt",
"(",
")",
"->",
"getTimestamp",
"(",
")",
":",
"time",
"(",
")",
";",
"$",
"file",
"=",
"new",
"FileInfo",
"(",
"$",
"gallery",
"->",
"getName",
"(",
")",
",",
"$",
"this",
"->",
"driverId",
",",
"$",
"time",
",",
"$",
"this",
"->",
"driverOptions",
"[",
"'rootName'",
"]",
")",
";",
"$",
"file",
"->",
"setHash",
"(",
"$",
"this",
"->",
"getDriverId",
"(",
")",
".",
"'_'",
".",
"FileInfo",
"::",
"encode",
"(",
"$",
"this",
"->",
"driverOptions",
"[",
"'rootName'",
"]",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"gallery",
"->",
"getId",
"(",
")",
")",
")",
";",
"return",
"$",
"file",
";",
"}"
]
| prepare Gallery.
@param Gallery $gallery
@return FileInfo | [
"prepare",
"Gallery",
"."
]
| train | https://github.com/4devs/ElfinderPhpConnector/blob/510e295dcafeaa0f796986ad87b3ed5f6b0d9338/Driver/PhotatoesDriver.php#L199-L210 |
4devs/ElfinderPhpConnector | Driver/PhotatoesDriver.php | PhotatoesDriver.addImages | private function addImages(Response $response, Image $image, $galleryId)
{
foreach ($this->driverOptions['imagesSize'] as $imageSize) {
$this->addImage($response, $image, $galleryId, $imageSize);
}
return $this;
} | php | private function addImages(Response $response, Image $image, $galleryId)
{
foreach ($this->driverOptions['imagesSize'] as $imageSize) {
$this->addImage($response, $image, $galleryId, $imageSize);
}
return $this;
} | [
"private",
"function",
"addImages",
"(",
"Response",
"$",
"response",
",",
"Image",
"$",
"image",
",",
"$",
"galleryId",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"driverOptions",
"[",
"'imagesSize'",
"]",
"as",
"$",
"imageSize",
")",
"{",
"$",
"this",
"->",
"addImage",
"(",
"$",
"response",
",",
"$",
"image",
",",
"$",
"galleryId",
",",
"$",
"imageSize",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| @param Response $response
@param Image $image
@param string $galleryId
@return $this | [
"@param",
"Response",
"$response",
"@param",
"Image",
"$image",
"@param",
"string",
"$galleryId"
]
| train | https://github.com/4devs/ElfinderPhpConnector/blob/510e295dcafeaa0f796986ad87b3ed5f6b0d9338/Driver/PhotatoesDriver.php#L219-L226 |
4devs/ElfinderPhpConnector | Driver/PhotatoesDriver.php | PhotatoesDriver.addImage | private function addImage(Response $response, Image $image, $galleryId, $imageSize)
{
if ($image->get($imageSize)) {
$href = $image->get($imageSize)->getHref();
$file = new FileInfo(
$image->getTitle().'('.$imageSize.')',
$this->getDriverId(),
$image->getUpdateAt()->getTimestamp(),
$galleryId
);
$file->setMime('image/jpeg');
$file->setTmb($image->get($this->driverOptions['thumbSize'])->getHref());
$file->setUrl($href);
$file->setPath($href);
$response->addFile($file);
}
} | php | private function addImage(Response $response, Image $image, $galleryId, $imageSize)
{
if ($image->get($imageSize)) {
$href = $image->get($imageSize)->getHref();
$file = new FileInfo(
$image->getTitle().'('.$imageSize.')',
$this->getDriverId(),
$image->getUpdateAt()->getTimestamp(),
$galleryId
);
$file->setMime('image/jpeg');
$file->setTmb($image->get($this->driverOptions['thumbSize'])->getHref());
$file->setUrl($href);
$file->setPath($href);
$response->addFile($file);
}
} | [
"private",
"function",
"addImage",
"(",
"Response",
"$",
"response",
",",
"Image",
"$",
"image",
",",
"$",
"galleryId",
",",
"$",
"imageSize",
")",
"{",
"if",
"(",
"$",
"image",
"->",
"get",
"(",
"$",
"imageSize",
")",
")",
"{",
"$",
"href",
"=",
"$",
"image",
"->",
"get",
"(",
"$",
"imageSize",
")",
"->",
"getHref",
"(",
")",
";",
"$",
"file",
"=",
"new",
"FileInfo",
"(",
"$",
"image",
"->",
"getTitle",
"(",
")",
".",
"'('",
".",
"$",
"imageSize",
".",
"')'",
",",
"$",
"this",
"->",
"getDriverId",
"(",
")",
",",
"$",
"image",
"->",
"getUpdateAt",
"(",
")",
"->",
"getTimestamp",
"(",
")",
",",
"$",
"galleryId",
")",
";",
"$",
"file",
"->",
"setMime",
"(",
"'image/jpeg'",
")",
";",
"$",
"file",
"->",
"setTmb",
"(",
"$",
"image",
"->",
"get",
"(",
"$",
"this",
"->",
"driverOptions",
"[",
"'thumbSize'",
"]",
")",
"->",
"getHref",
"(",
")",
")",
";",
"$",
"file",
"->",
"setUrl",
"(",
"$",
"href",
")",
";",
"$",
"file",
"->",
"setPath",
"(",
"$",
"href",
")",
";",
"$",
"response",
"->",
"addFile",
"(",
"$",
"file",
")",
";",
"}",
"}"
]
| add Image.
@param Response $response
@param Image $image
@param string $galleryId
@param string $imageSize | [
"add",
"Image",
"."
]
| train | https://github.com/4devs/ElfinderPhpConnector/blob/510e295dcafeaa0f796986ad87b3ed5f6b0d9338/Driver/PhotatoesDriver.php#L236-L252 |
activecollab/templateengine | src/TemplateEngine.php | TemplateEngine.fetch | public function fetch($template, array $data = [])
{
try {
ob_start();
$this->display($template, $data);
return ob_get_clean();
} catch (Exception $e) {
ob_end_clean();
throw $e;
}
} | php | public function fetch($template, array $data = [])
{
try {
ob_start();
$this->display($template, $data);
return ob_get_clean();
} catch (Exception $e) {
ob_end_clean();
throw $e;
}
} | [
"public",
"function",
"fetch",
"(",
"$",
"template",
",",
"array",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"try",
"{",
"ob_start",
"(",
")",
";",
"$",
"this",
"->",
"display",
"(",
"$",
"template",
",",
"$",
"data",
")",
";",
"return",
"ob_get_clean",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"ob_end_clean",
"(",
")",
";",
"throw",
"$",
"e",
";",
"}",
"}"
]
| {@inheritdoc} | [
"{"
]
| train | https://github.com/activecollab/templateengine/blob/eff2de29428b9d649c6f6d8ba5eb52b46c6f27e8/src/TemplateEngine.php#L40-L52 |
activecollab/templateengine | src/TemplateEngine.php | TemplateEngine.& | public function &setTemplatesPath($templates_path)
{
$templates_path = rtrim($templates_path, '/');
if (!is_dir($templates_path)) {
throw new InvalidArgumentException("Templates path '$templates_path' does not exist");
}
$this->templates_path = rtrim($templates_path, '/');
return $this;
} | php | public function &setTemplatesPath($templates_path)
{
$templates_path = rtrim($templates_path, '/');
if (!is_dir($templates_path)) {
throw new InvalidArgumentException("Templates path '$templates_path' does not exist");
}
$this->templates_path = rtrim($templates_path, '/');
return $this;
} | [
"public",
"function",
"&",
"setTemplatesPath",
"(",
"$",
"templates_path",
")",
"{",
"$",
"templates_path",
"=",
"rtrim",
"(",
"$",
"templates_path",
",",
"'/'",
")",
";",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"templates_path",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Templates path '$templates_path' does not exist\"",
")",
";",
"}",
"$",
"this",
"->",
"templates_path",
"=",
"rtrim",
"(",
"$",
"templates_path",
",",
"'/'",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| {@inheritdoc} | [
"{"
]
| train | https://github.com/activecollab/templateengine/blob/eff2de29428b9d649c6f6d8ba5eb52b46c6f27e8/src/TemplateEngine.php#L105-L116 |
activecollab/templateengine | src/TemplateEngine.php | TemplateEngine.getTemplatePath | public function getTemplatePath($template)
{
$template_path = $this->templates_path . '/' . ltrim($template, '/');
if (strpos($template_path, './')) {
$template_path = realpath($template_path);
if (empty($template_path) || $this->templates_path != mb_substr($template_path, 0, mb_strlen($this->templates_path))) {
throw new RuntimeException("Template '$template' does not exist");
}
}
if (!is_file($template_path)) {
throw new RuntimeException("Template '$template' does not exist");
}
return $template_path;
} | php | public function getTemplatePath($template)
{
$template_path = $this->templates_path . '/' . ltrim($template, '/');
if (strpos($template_path, './')) {
$template_path = realpath($template_path);
if (empty($template_path) || $this->templates_path != mb_substr($template_path, 0, mb_strlen($this->templates_path))) {
throw new RuntimeException("Template '$template' does not exist");
}
}
if (!is_file($template_path)) {
throw new RuntimeException("Template '$template' does not exist");
}
return $template_path;
} | [
"public",
"function",
"getTemplatePath",
"(",
"$",
"template",
")",
"{",
"$",
"template_path",
"=",
"$",
"this",
"->",
"templates_path",
".",
"'/'",
".",
"ltrim",
"(",
"$",
"template",
",",
"'/'",
")",
";",
"if",
"(",
"strpos",
"(",
"$",
"template_path",
",",
"'./'",
")",
")",
"{",
"$",
"template_path",
"=",
"realpath",
"(",
"$",
"template_path",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"template_path",
")",
"||",
"$",
"this",
"->",
"templates_path",
"!=",
"mb_substr",
"(",
"$",
"template_path",
",",
"0",
",",
"mb_strlen",
"(",
"$",
"this",
"->",
"templates_path",
")",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Template '$template' does not exist\"",
")",
";",
"}",
"}",
"if",
"(",
"!",
"is_file",
"(",
"$",
"template_path",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Template '$template' does not exist\"",
")",
";",
"}",
"return",
"$",
"template_path",
";",
"}"
]
| {@inheritdoc} | [
"{"
]
| train | https://github.com/activecollab/templateengine/blob/eff2de29428b9d649c6f6d8ba5eb52b46c6f27e8/src/TemplateEngine.php#L121-L138 |
qcubed/orm | src/Query/QQ.php | QQ.getVirtualAlias | static public function getVirtualAlias($strName)
{
$strName = trim($strName);
$strName = str_replace(" ", "_", $strName);
$strName = strtolower($strName);
return $strName;
} | php | static public function getVirtualAlias($strName)
{
$strName = trim($strName);
$strName = str_replace(" ", "_", $strName);
$strName = strtolower($strName);
return $strName;
} | [
"static",
"public",
"function",
"getVirtualAlias",
"(",
"$",
"strName",
")",
"{",
"$",
"strName",
"=",
"trim",
"(",
"$",
"strName",
")",
";",
"$",
"strName",
"=",
"str_replace",
"(",
"\" \"",
",",
"\"_\"",
",",
"$",
"strName",
")",
";",
"$",
"strName",
"=",
"strtolower",
"(",
"$",
"strName",
")",
";",
"return",
"$",
"strName",
";",
"}"
]
| Converts a virtual attribute name to an alias used in the query. The name is converted to an identifier
that will work on any SQL database. In the query itself, the name
will have two underscores in front of the alias name to prevent conflicts with column names.
@param $strName
@return mixed|string | [
"Converts",
"a",
"virtual",
"attribute",
"name",
"to",
"an",
"alias",
"used",
"in",
"the",
"query",
".",
"The",
"name",
"is",
"converted",
"to",
"an",
"identifier",
"that",
"will",
"work",
"on",
"any",
"SQL",
"database",
".",
"In",
"the",
"query",
"itself",
"the",
"name",
"will",
"have",
"two",
"underscores",
"in",
"front",
"of",
"the",
"alias",
"name",
"to",
"prevent",
"conflicts",
"with",
"column",
"names",
"."
]
| train | https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Query/QQ.php#L261-L267 |
qcubed/orm | src/Query/QQ.php | QQ.clause | static public function clause(/* parameterized list of Clause\Base objects */)
{
$objClauseArray = array();
foreach (func_get_args() as $objClause) {
if ($objClause) {
if (!($objClause instanceof Clause\ClauseInterface)) {
throw new Caller('Non-Clause object was passed in to QQ::Clause');
} else {
array_push($objClauseArray, $objClause);
}
}
}
return $objClauseArray;
} | php | static public function clause(/* parameterized list of Clause\Base objects */)
{
$objClauseArray = array();
foreach (func_get_args() as $objClause) {
if ($objClause) {
if (!($objClause instanceof Clause\ClauseInterface)) {
throw new Caller('Non-Clause object was passed in to QQ::Clause');
} else {
array_push($objClauseArray, $objClause);
}
}
}
return $objClauseArray;
} | [
"static",
"public",
"function",
"clause",
"(",
"/* parameterized list of Clause\\Base objects */",
")",
"{",
"$",
"objClauseArray",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"func_get_args",
"(",
")",
"as",
"$",
"objClause",
")",
"{",
"if",
"(",
"$",
"objClause",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"objClause",
"instanceof",
"Clause",
"\\",
"ClauseInterface",
")",
")",
"{",
"throw",
"new",
"Caller",
"(",
"'Non-Clause object was passed in to QQ::Clause'",
")",
";",
"}",
"else",
"{",
"array_push",
"(",
"$",
"objClauseArray",
",",
"$",
"objClause",
")",
";",
"}",
"}",
"}",
"return",
"$",
"objClauseArray",
";",
"}"
]
| /////////////////////// | [
"///////////////////////"
]
| train | https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Query/QQ.php#L273-L288 |
qcubed/orm | src/Query/QQ.php | QQ.extractSelectClause | public static function extractSelectClause($objClauses)
{
if ($objClauses instanceof Clause\Select) {
return $objClauses;
}
if (is_array($objClauses)) {
$hasSelects = false;
$objSelect = QQ::select();
foreach ($objClauses as $objClause) {
if ($objClause instanceof Clause\Select) {
$hasSelects = true;
$objSelect->merge($objClause);
}
}
if (!$hasSelects) {
return null;
}
return $objSelect;
}
return null;
} | php | public static function extractSelectClause($objClauses)
{
if ($objClauses instanceof Clause\Select) {
return $objClauses;
}
if (is_array($objClauses)) {
$hasSelects = false;
$objSelect = QQ::select();
foreach ($objClauses as $objClause) {
if ($objClause instanceof Clause\Select) {
$hasSelects = true;
$objSelect->merge($objClause);
}
}
if (!$hasSelects) {
return null;
}
return $objSelect;
}
return null;
} | [
"public",
"static",
"function",
"extractSelectClause",
"(",
"$",
"objClauses",
")",
"{",
"if",
"(",
"$",
"objClauses",
"instanceof",
"Clause",
"\\",
"Select",
")",
"{",
"return",
"$",
"objClauses",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"objClauses",
")",
")",
"{",
"$",
"hasSelects",
"=",
"false",
";",
"$",
"objSelect",
"=",
"QQ",
"::",
"select",
"(",
")",
";",
"foreach",
"(",
"$",
"objClauses",
"as",
"$",
"objClause",
")",
"{",
"if",
"(",
"$",
"objClause",
"instanceof",
"Clause",
"\\",
"Select",
")",
"{",
"$",
"hasSelects",
"=",
"true",
";",
"$",
"objSelect",
"->",
"merge",
"(",
"$",
"objClause",
")",
";",
"}",
"}",
"if",
"(",
"!",
"$",
"hasSelects",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"objSelect",
";",
"}",
"return",
"null",
";",
"}"
]
| Searches for all the Clause\Select clauses and merges them into one clause and returns that clause.
Returns null if none found.
@param Clause\Base[]|Clause\Base|null $objClauses Clause\Base object or array of Clause\Base objects
@return Clause\Select Clause\Select clause containing all the nodes from all the Clause\Select clauses from $objClauses,
or null if $objClauses contains no Clause\Select clauses | [
"Searches",
"for",
"all",
"the",
"Clause",
"\\",
"Select",
"clauses",
"and",
"merges",
"them",
"into",
"one",
"clause",
"and",
"returns",
"that",
"clause",
".",
"Returns",
"null",
"if",
"none",
"found",
"."
]
| train | https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Query/QQ.php#L380-L401 |
qcubed/orm | src/Query/QQ.php | QQ.func | static public function func($strName, $param1/** ... */)
{
$args = func_get_args();
$strFunc = array_shift($args);
return new Node\FunctionNode($strFunc, $args);
} | php | static public function func($strName, $param1/** ... */)
{
$args = func_get_args();
$strFunc = array_shift($args);
return new Node\FunctionNode($strFunc, $args);
} | [
"static",
"public",
"function",
"func",
"(",
"$",
"strName",
",",
"$",
"param1",
"/** ... */",
")",
"{",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"$",
"strFunc",
"=",
"array_shift",
"(",
"$",
"args",
")",
";",
"return",
"new",
"Node",
"\\",
"FunctionNode",
"(",
"$",
"strFunc",
",",
"$",
"args",
")",
";",
"}"
]
| Apply an arbitrary scalar function using the given parameters. See below for functions that let you apply
common SQL functions. The list below only includes sql operations that are generic to all supported versions
of SQL. However, you can call Func directly with any named function that works in your current SQL version,
knowing that it might not be cross platform compatible if you ever change SQL engines.
@param string $strName The function name, like ABS or POWER
@param Node\NodeBase|mixed $param1 The function parameter. Can be a qq node or a number.
@return Node\FunctionNode The resulting wrapper node | [
"Apply",
"an",
"arbitrary",
"scalar",
"function",
"using",
"the",
"given",
"parameters",
".",
"See",
"below",
"for",
"functions",
"that",
"let",
"you",
"apply",
"common",
"SQL",
"functions",
".",
"The",
"list",
"below",
"only",
"includes",
"sql",
"operations",
"that",
"are",
"generic",
"to",
"all",
"supported",
"versions",
"of",
"SQL",
".",
"However",
"you",
"can",
"call",
"Func",
"directly",
"with",
"any",
"named",
"function",
"that",
"works",
"in",
"your",
"current",
"SQL",
"version",
"knowing",
"that",
"it",
"might",
"not",
"be",
"cross",
"platform",
"compatible",
"if",
"you",
"ever",
"change",
"SQL",
"engines",
"."
]
| train | https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Query/QQ.php#L438-L443 |
qcubed/orm | src/Query/QQ.php | QQ.mathOp | static public function mathOp($strOperation, $param1/** ... */)
{
$args = func_get_args();
$strFunc = array_shift($args);
return new Node\Math($strFunc, $args);
} | php | static public function mathOp($strOperation, $param1/** ... */)
{
$args = func_get_args();
$strFunc = array_shift($args);
return new Node\Math($strFunc, $args);
} | [
"static",
"public",
"function",
"mathOp",
"(",
"$",
"strOperation",
",",
"$",
"param1",
"/** ... */",
")",
"{",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"$",
"strFunc",
"=",
"array_shift",
"(",
"$",
"args",
")",
";",
"return",
"new",
"Node",
"\\",
"Math",
"(",
"$",
"strFunc",
",",
"$",
"args",
")",
";",
"}"
]
| Apply an arbitrary math operation to 2 or more operands. Operands can be scalar values, or column nodes.
@param string $strOperation The operation symbol, like + or *
@param Node\NodeBase|mixed $param1 The first parameter
@return Node\Math The resulting wrapper node | [
"Apply",
"an",
"arbitrary",
"math",
"operation",
"to",
"2",
"or",
"more",
"operands",
".",
"Operands",
"can",
"be",
"scalar",
"values",
"or",
"column",
"nodes",
"."
]
| train | https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Query/QQ.php#L524-L529 |
CPSB/Validation-helper | src/FormServiceProvider.php | FormServiceProvider.registerBladeDirectives | protected function registerBladeDirectives()
{
Blade::directive('form', function ($expression) {
$expression = $this->addParenthesis($expression);
return "<?php app('Activisme_BE')->model{$expression}; ?>";
});
Blade::directive('input', function ($expression) {
$expression = $this->addParenthesis($expression);
return "<?php echo app('Activisme_BE')->input{$expression}; ?>";
});
Blade::directive('text', function ($expression) {
$expression = $this->addParenthesis($expression);
return "<?php echo app('Activisme_BE')->text{$expression}; ?>";
});
Blade::directive('checkbox', function ($expression) {
$expression = $this->addParenthesis($expression);
return "<?php echo app('Activisme_BE')->checkbox{$expression}; ?>";
});
Blade::directive('radio', function ($expression) {
$expression = $this->addParenthesis($expression);
return "<?php echo app('Activisme_BE')->radio{$expression}; ?>";
});
Blade::directive('options', function ($expression) {
$expression = $this->addParenthesis($expression);
return "<?php echo app('Activisme_BE')->options{$expression}; ?>";
});
Blade::directive('error', function ($expression) {
$expression = $this->addParenthesis($expression);
return "<?php echo app('Activisme_BE')->error{$expression}; ?>";
});
} | php | protected function registerBladeDirectives()
{
Blade::directive('form', function ($expression) {
$expression = $this->addParenthesis($expression);
return "<?php app('Activisme_BE')->model{$expression}; ?>";
});
Blade::directive('input', function ($expression) {
$expression = $this->addParenthesis($expression);
return "<?php echo app('Activisme_BE')->input{$expression}; ?>";
});
Blade::directive('text', function ($expression) {
$expression = $this->addParenthesis($expression);
return "<?php echo app('Activisme_BE')->text{$expression}; ?>";
});
Blade::directive('checkbox', function ($expression) {
$expression = $this->addParenthesis($expression);
return "<?php echo app('Activisme_BE')->checkbox{$expression}; ?>";
});
Blade::directive('radio', function ($expression) {
$expression = $this->addParenthesis($expression);
return "<?php echo app('Activisme_BE')->radio{$expression}; ?>";
});
Blade::directive('options', function ($expression) {
$expression = $this->addParenthesis($expression);
return "<?php echo app('Activisme_BE')->options{$expression}; ?>";
});
Blade::directive('error', function ($expression) {
$expression = $this->addParenthesis($expression);
return "<?php echo app('Activisme_BE')->error{$expression}; ?>";
});
} | [
"protected",
"function",
"registerBladeDirectives",
"(",
")",
"{",
"Blade",
"::",
"directive",
"(",
"'form'",
",",
"function",
"(",
"$",
"expression",
")",
"{",
"$",
"expression",
"=",
"$",
"this",
"->",
"addParenthesis",
"(",
"$",
"expression",
")",
";",
"return",
"\"<?php app('Activisme_BE')->model{$expression}; ?>\"",
";",
"}",
")",
";",
"Blade",
"::",
"directive",
"(",
"'input'",
",",
"function",
"(",
"$",
"expression",
")",
"{",
"$",
"expression",
"=",
"$",
"this",
"->",
"addParenthesis",
"(",
"$",
"expression",
")",
";",
"return",
"\"<?php echo app('Activisme_BE')->input{$expression}; ?>\"",
";",
"}",
")",
";",
"Blade",
"::",
"directive",
"(",
"'text'",
",",
"function",
"(",
"$",
"expression",
")",
"{",
"$",
"expression",
"=",
"$",
"this",
"->",
"addParenthesis",
"(",
"$",
"expression",
")",
";",
"return",
"\"<?php echo app('Activisme_BE')->text{$expression}; ?>\"",
";",
"}",
")",
";",
"Blade",
"::",
"directive",
"(",
"'checkbox'",
",",
"function",
"(",
"$",
"expression",
")",
"{",
"$",
"expression",
"=",
"$",
"this",
"->",
"addParenthesis",
"(",
"$",
"expression",
")",
";",
"return",
"\"<?php echo app('Activisme_BE')->checkbox{$expression}; ?>\"",
";",
"}",
")",
";",
"Blade",
"::",
"directive",
"(",
"'radio'",
",",
"function",
"(",
"$",
"expression",
")",
"{",
"$",
"expression",
"=",
"$",
"this",
"->",
"addParenthesis",
"(",
"$",
"expression",
")",
";",
"return",
"\"<?php echo app('Activisme_BE')->radio{$expression}; ?>\"",
";",
"}",
")",
";",
"Blade",
"::",
"directive",
"(",
"'options'",
",",
"function",
"(",
"$",
"expression",
")",
"{",
"$",
"expression",
"=",
"$",
"this",
"->",
"addParenthesis",
"(",
"$",
"expression",
")",
";",
"return",
"\"<?php echo app('Activisme_BE')->options{$expression}; ?>\"",
";",
"}",
")",
";",
"Blade",
"::",
"directive",
"(",
"'error'",
",",
"function",
"(",
"$",
"expression",
")",
"{",
"$",
"expression",
"=",
"$",
"this",
"->",
"addParenthesis",
"(",
"$",
"expression",
")",
";",
"return",
"\"<?php echo app('Activisme_BE')->error{$expression}; ?>\"",
";",
"}",
")",
";",
"}"
]
| Register blade directives.
@return void | [
"Register",
"blade",
"directives",
"."
]
| train | https://github.com/CPSB/Validation-helper/blob/adb91cb42b7e3c1f88be059a8b4f86de5aba64cc/src/FormServiceProvider.php#L75-L111 |
yoanm/symfony-jsonrpc-http-server-doc | src/Finder/NormalizedDocFinder.php | NormalizedDocFinder.findFor | public function findFor(string $filename, $host) : array
{
foreach ($this->normalizedDocProviderList as $provider) {
if (true === $provider->supports($filename, $host)) {
return $provider->getDoc($host);
}
}
throw new \Exception(sprintf('No documentation provider found for "%s"/"%s"', $filename, $host));
} | php | public function findFor(string $filename, $host) : array
{
foreach ($this->normalizedDocProviderList as $provider) {
if (true === $provider->supports($filename, $host)) {
return $provider->getDoc($host);
}
}
throw new \Exception(sprintf('No documentation provider found for "%s"/"%s"', $filename, $host));
} | [
"public",
"function",
"findFor",
"(",
"string",
"$",
"filename",
",",
"$",
"host",
")",
":",
"array",
"{",
"foreach",
"(",
"$",
"this",
"->",
"normalizedDocProviderList",
"as",
"$",
"provider",
")",
"{",
"if",
"(",
"true",
"===",
"$",
"provider",
"->",
"supports",
"(",
"$",
"filename",
",",
"$",
"host",
")",
")",
"{",
"return",
"$",
"provider",
"->",
"getDoc",
"(",
"$",
"host",
")",
";",
"}",
"}",
"throw",
"new",
"\\",
"Exception",
"(",
"sprintf",
"(",
"'No documentation provider found for \"%s\"/\"%s\"'",
",",
"$",
"filename",
",",
"$",
"host",
")",
")",
";",
"}"
]
| @param string $filename
@param string|null $host
@return array
@throws \Exception In case no provider found | [
"@param",
"string",
"$filename",
"@param",
"string|null",
"$host"
]
| train | https://github.com/yoanm/symfony-jsonrpc-http-server-doc/blob/7a59862f74fef29d0e2ad017188977419503ad94/src/Finder/NormalizedDocFinder.php#L30-L39 |
webforge-labs/psc-cms | lib/PHPWord/PHPWord/Style/Cell.php | PHPWord_Style_Cell.setStyleValue | public function setStyleValue($key, $value) {
if($key == '_borderSize') {
$this->setBorderSize($value);
} elseif($key == '_borderColor') {
$this->setBorderColor($value);
} else {
$this->$key = $value;
}
} | php | public function setStyleValue($key, $value) {
if($key == '_borderSize') {
$this->setBorderSize($value);
} elseif($key == '_borderColor') {
$this->setBorderColor($value);
} else {
$this->$key = $value;
}
} | [
"public",
"function",
"setStyleValue",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"key",
"==",
"'_borderSize'",
")",
"{",
"$",
"this",
"->",
"setBorderSize",
"(",
"$",
"value",
")",
";",
"}",
"elseif",
"(",
"$",
"key",
"==",
"'_borderColor'",
")",
"{",
"$",
"this",
"->",
"setBorderColor",
"(",
"$",
"value",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"$",
"key",
"=",
"$",
"value",
";",
"}",
"}"
]
| Set style value
@var string $key
@var mixed $value | [
"Set",
"style",
"value"
]
| train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/PHPWord/PHPWord/Style/Cell.php#L150-L158 |
sparwelt/imgix-lib | src/ImgixService.php | ImgixService.generateUrl | public function generateUrl($originalUrl, $filtersOrConfigurationKey = [], array $extraFilters = [])
{
$filters = $this->prepareFilterParams($filtersOrConfigurationKey, $extraFilters);
return $this->urlGenerator->generateUrl($originalUrl, $filters);
} | php | public function generateUrl($originalUrl, $filtersOrConfigurationKey = [], array $extraFilters = [])
{
$filters = $this->prepareFilterParams($filtersOrConfigurationKey, $extraFilters);
return $this->urlGenerator->generateUrl($originalUrl, $filters);
} | [
"public",
"function",
"generateUrl",
"(",
"$",
"originalUrl",
",",
"$",
"filtersOrConfigurationKey",
"=",
"[",
"]",
",",
"array",
"$",
"extraFilters",
"=",
"[",
"]",
")",
"{",
"$",
"filters",
"=",
"$",
"this",
"->",
"prepareFilterParams",
"(",
"$",
"filtersOrConfigurationKey",
",",
"$",
"extraFilters",
")",
";",
"return",
"$",
"this",
"->",
"urlGenerator",
"->",
"generateUrl",
"(",
"$",
"originalUrl",
",",
"$",
"filters",
")",
";",
"}"
]
| @param string $originalUrl
@param array|string $filtersOrConfigurationKey
@param array $extraFilters
@return string
@throws \Sparwelt\ImgixLib\Exception\ResolutionException | [
"@param",
"string",
"$originalUrl",
"@param",
"array|string",
"$filtersOrConfigurationKey",
"@param",
"array",
"$extraFilters"
]
| train | https://github.com/sparwelt/imgix-lib/blob/330e1db2bed71bc283e5a2da6246528f240939ec/src/ImgixService.php#L62-L67 |
sparwelt/imgix-lib | src/ImgixService.php | ImgixService.generateAttributeValue | public function generateAttributeValue($originalUrl, $filtersOrConfigurationKey = [], array $extraFilters = [])
{
$filters = $this->prepareFilterParams($filtersOrConfigurationKey, $extraFilters);
return $this->attributeGenerator->generateAttributeValue($originalUrl, $filters);
} | php | public function generateAttributeValue($originalUrl, $filtersOrConfigurationKey = [], array $extraFilters = [])
{
$filters = $this->prepareFilterParams($filtersOrConfigurationKey, $extraFilters);
return $this->attributeGenerator->generateAttributeValue($originalUrl, $filters);
} | [
"public",
"function",
"generateAttributeValue",
"(",
"$",
"originalUrl",
",",
"$",
"filtersOrConfigurationKey",
"=",
"[",
"]",
",",
"array",
"$",
"extraFilters",
"=",
"[",
"]",
")",
"{",
"$",
"filters",
"=",
"$",
"this",
"->",
"prepareFilterParams",
"(",
"$",
"filtersOrConfigurationKey",
",",
"$",
"extraFilters",
")",
";",
"return",
"$",
"this",
"->",
"attributeGenerator",
"->",
"generateAttributeValue",
"(",
"$",
"originalUrl",
",",
"$",
"filters",
")",
";",
"}"
]
| @param string $originalUrl
@param array|string $filtersOrConfigurationKey
@param array $extraFilters
@return string
@throws \Sparwelt\ImgixLib\Exception\ResolutionException | [
"@param",
"string",
"$originalUrl",
"@param",
"array|string",
"$filtersOrConfigurationKey",
"@param",
"array",
"$extraFilters"
]
| train | https://github.com/sparwelt/imgix-lib/blob/330e1db2bed71bc283e5a2da6246528f240939ec/src/ImgixService.php#L77-L82 |
sparwelt/imgix-lib | src/ImgixService.php | ImgixService.generateImage | public function generateImage($originalUrl, $attributesFiltersOrConfigurationKey = [], array $extraFilters = [])
{
$attributesFilters = $this->prepareFilterParams($attributesFiltersOrConfigurationKey, $extraFilters);
return $this->imageGenerator->generateImage($originalUrl, $attributesFilters);
} | php | public function generateImage($originalUrl, $attributesFiltersOrConfigurationKey = [], array $extraFilters = [])
{
$attributesFilters = $this->prepareFilterParams($attributesFiltersOrConfigurationKey, $extraFilters);
return $this->imageGenerator->generateImage($originalUrl, $attributesFilters);
} | [
"public",
"function",
"generateImage",
"(",
"$",
"originalUrl",
",",
"$",
"attributesFiltersOrConfigurationKey",
"=",
"[",
"]",
",",
"array",
"$",
"extraFilters",
"=",
"[",
"]",
")",
"{",
"$",
"attributesFilters",
"=",
"$",
"this",
"->",
"prepareFilterParams",
"(",
"$",
"attributesFiltersOrConfigurationKey",
",",
"$",
"extraFilters",
")",
";",
"return",
"$",
"this",
"->",
"imageGenerator",
"->",
"generateImage",
"(",
"$",
"originalUrl",
",",
"$",
"attributesFilters",
")",
";",
"}"
]
| @param string $originalUrl
@param array $attributesFiltersOrConfigurationKey
@param array $extraFilters
@return string | [
"@param",
"string",
"$originalUrl",
"@param",
"array",
"$attributesFiltersOrConfigurationKey",
"@param",
"array",
"$extraFilters"
]
| train | https://github.com/sparwelt/imgix-lib/blob/330e1db2bed71bc283e5a2da6246528f240939ec/src/ImgixService.php#L91-L96 |
sparwelt/imgix-lib | src/ImgixService.php | ImgixService.transformHtml | public function transformHtml($html, $attributesFiltersOrConfigurationKey = [], array $extraFilters = [])
{
$attributesFilters = $this->prepareFilterParams($attributesFiltersOrConfigurationKey, $extraFilters);
return $this->htmlTransformer->transformHtml($html, $attributesFilters);
} | php | public function transformHtml($html, $attributesFiltersOrConfigurationKey = [], array $extraFilters = [])
{
$attributesFilters = $this->prepareFilterParams($attributesFiltersOrConfigurationKey, $extraFilters);
return $this->htmlTransformer->transformHtml($html, $attributesFilters);
} | [
"public",
"function",
"transformHtml",
"(",
"$",
"html",
",",
"$",
"attributesFiltersOrConfigurationKey",
"=",
"[",
"]",
",",
"array",
"$",
"extraFilters",
"=",
"[",
"]",
")",
"{",
"$",
"attributesFilters",
"=",
"$",
"this",
"->",
"prepareFilterParams",
"(",
"$",
"attributesFiltersOrConfigurationKey",
",",
"$",
"extraFilters",
")",
";",
"return",
"$",
"this",
"->",
"htmlTransformer",
"->",
"transformHtml",
"(",
"$",
"html",
",",
"$",
"attributesFilters",
")",
";",
"}"
]
| @param string $html
@param array $attributesFiltersOrConfigurationKey
@param array $extraFilters
@return string | [
"@param",
"string",
"$html",
"@param",
"array",
"$attributesFiltersOrConfigurationKey",
"@param",
"array",
"$extraFilters"
]
| train | https://github.com/sparwelt/imgix-lib/blob/330e1db2bed71bc283e5a2da6246528f240939ec/src/ImgixService.php#L105-L110 |
sparwelt/imgix-lib | src/ImgixService.php | ImgixService.prepareFilterParams | private function prepareFilterParams($filtersOrConfigurationKey, array $extraFilters = [])
{
if (is_array($filtersOrConfigurationKey)) {
return array_merge($filtersOrConfigurationKey, $extraFilters);
}
if (false !== strpos($filtersOrConfigurationKey, '.')) {
list($configurationKey, $attribute) = explode('.', $filtersOrConfigurationKey);
} else {
$configurationKey = $filtersOrConfigurationKey;
$attribute = null;
}
if (!isset($this->filtersConfigurations[$configurationKey])) {
throw new ConfigurationException(sprintf('Unable to find filter configuration "%s"', $configurationKey));
}
if (null !== $attribute) {
if (!isset($this->filtersConfigurations[$configurationKey][$attribute])) {
throw new ConfigurationException(sprintf('Unable to find attribute "%s" in filter configuration "%s"', $attribute, $configurationKey));
}
return is_array($this->filtersConfigurations[$configurationKey][$attribute])
? array_merge($this->filtersConfigurations[$configurationKey][$attribute], $extraFilters)
: $this->filtersConfigurations[$configurationKey][$attribute]
;
}
return is_array($this->filtersConfigurations[$configurationKey])
? array_merge($this->filtersConfigurations[$configurationKey], $extraFilters)
: $this->filtersConfigurations[$configurationKey]
;
} | php | private function prepareFilterParams($filtersOrConfigurationKey, array $extraFilters = [])
{
if (is_array($filtersOrConfigurationKey)) {
return array_merge($filtersOrConfigurationKey, $extraFilters);
}
if (false !== strpos($filtersOrConfigurationKey, '.')) {
list($configurationKey, $attribute) = explode('.', $filtersOrConfigurationKey);
} else {
$configurationKey = $filtersOrConfigurationKey;
$attribute = null;
}
if (!isset($this->filtersConfigurations[$configurationKey])) {
throw new ConfigurationException(sprintf('Unable to find filter configuration "%s"', $configurationKey));
}
if (null !== $attribute) {
if (!isset($this->filtersConfigurations[$configurationKey][$attribute])) {
throw new ConfigurationException(sprintf('Unable to find attribute "%s" in filter configuration "%s"', $attribute, $configurationKey));
}
return is_array($this->filtersConfigurations[$configurationKey][$attribute])
? array_merge($this->filtersConfigurations[$configurationKey][$attribute], $extraFilters)
: $this->filtersConfigurations[$configurationKey][$attribute]
;
}
return is_array($this->filtersConfigurations[$configurationKey])
? array_merge($this->filtersConfigurations[$configurationKey], $extraFilters)
: $this->filtersConfigurations[$configurationKey]
;
} | [
"private",
"function",
"prepareFilterParams",
"(",
"$",
"filtersOrConfigurationKey",
",",
"array",
"$",
"extraFilters",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"filtersOrConfigurationKey",
")",
")",
"{",
"return",
"array_merge",
"(",
"$",
"filtersOrConfigurationKey",
",",
"$",
"extraFilters",
")",
";",
"}",
"if",
"(",
"false",
"!==",
"strpos",
"(",
"$",
"filtersOrConfigurationKey",
",",
"'.'",
")",
")",
"{",
"list",
"(",
"$",
"configurationKey",
",",
"$",
"attribute",
")",
"=",
"explode",
"(",
"'.'",
",",
"$",
"filtersOrConfigurationKey",
")",
";",
"}",
"else",
"{",
"$",
"configurationKey",
"=",
"$",
"filtersOrConfigurationKey",
";",
"$",
"attribute",
"=",
"null",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"filtersConfigurations",
"[",
"$",
"configurationKey",
"]",
")",
")",
"{",
"throw",
"new",
"ConfigurationException",
"(",
"sprintf",
"(",
"'Unable to find filter configuration \"%s\"'",
",",
"$",
"configurationKey",
")",
")",
";",
"}",
"if",
"(",
"null",
"!==",
"$",
"attribute",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"filtersConfigurations",
"[",
"$",
"configurationKey",
"]",
"[",
"$",
"attribute",
"]",
")",
")",
"{",
"throw",
"new",
"ConfigurationException",
"(",
"sprintf",
"(",
"'Unable to find attribute \"%s\" in filter configuration \"%s\"'",
",",
"$",
"attribute",
",",
"$",
"configurationKey",
")",
")",
";",
"}",
"return",
"is_array",
"(",
"$",
"this",
"->",
"filtersConfigurations",
"[",
"$",
"configurationKey",
"]",
"[",
"$",
"attribute",
"]",
")",
"?",
"array_merge",
"(",
"$",
"this",
"->",
"filtersConfigurations",
"[",
"$",
"configurationKey",
"]",
"[",
"$",
"attribute",
"]",
",",
"$",
"extraFilters",
")",
":",
"$",
"this",
"->",
"filtersConfigurations",
"[",
"$",
"configurationKey",
"]",
"[",
"$",
"attribute",
"]",
";",
"}",
"return",
"is_array",
"(",
"$",
"this",
"->",
"filtersConfigurations",
"[",
"$",
"configurationKey",
"]",
")",
"?",
"array_merge",
"(",
"$",
"this",
"->",
"filtersConfigurations",
"[",
"$",
"configurationKey",
"]",
",",
"$",
"extraFilters",
")",
":",
"$",
"this",
"->",
"filtersConfigurations",
"[",
"$",
"configurationKey",
"]",
";",
"}"
]
| @param array|string $filtersOrConfigurationKey
@param array $extraFilters
@return array | [
"@param",
"array|string",
"$filtersOrConfigurationKey",
"@param",
"array",
"$extraFilters"
]
| train | https://github.com/sparwelt/imgix-lib/blob/330e1db2bed71bc283e5a2da6246528f240939ec/src/ImgixService.php#L118-L150 |
ruvents/ruwork-upload-bundle | DependencyInjection/Configuration.php | Configuration.getConfigTreeBuilder | public function getConfigTreeBuilder()
{
// @formatter:off
return (new TreeBuilder())
->root('ruwork_upload')
->children()
->scalarNode('public_dir')
->cannotBeEmpty()
->defaultValue('%kernel.project_dir%/public')
->validate()
->always(function ($value) {
return rtrim($value, '/');
})
->end()
->end()
->scalarNode('uploads_dir')
->cannotBeEmpty()
->defaultValue('uploads')
->validate()
->always(function ($value) {
return trim($value, '/');
})
->end()
->end()
->end()
->end();
// @formatter:on
} | php | public function getConfigTreeBuilder()
{
// @formatter:off
return (new TreeBuilder())
->root('ruwork_upload')
->children()
->scalarNode('public_dir')
->cannotBeEmpty()
->defaultValue('%kernel.project_dir%/public')
->validate()
->always(function ($value) {
return rtrim($value, '/');
})
->end()
->end()
->scalarNode('uploads_dir')
->cannotBeEmpty()
->defaultValue('uploads')
->validate()
->always(function ($value) {
return trim($value, '/');
})
->end()
->end()
->end()
->end();
// @formatter:on
} | [
"public",
"function",
"getConfigTreeBuilder",
"(",
")",
"{",
"// @formatter:off",
"return",
"(",
"new",
"TreeBuilder",
"(",
")",
")",
"->",
"root",
"(",
"'ruwork_upload'",
")",
"->",
"children",
"(",
")",
"->",
"scalarNode",
"(",
"'public_dir'",
")",
"->",
"cannotBeEmpty",
"(",
")",
"->",
"defaultValue",
"(",
"'%kernel.project_dir%/public'",
")",
"->",
"validate",
"(",
")",
"->",
"always",
"(",
"function",
"(",
"$",
"value",
")",
"{",
"return",
"rtrim",
"(",
"$",
"value",
",",
"'/'",
")",
";",
"}",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
"->",
"scalarNode",
"(",
"'uploads_dir'",
")",
"->",
"cannotBeEmpty",
"(",
")",
"->",
"defaultValue",
"(",
"'uploads'",
")",
"->",
"validate",
"(",
")",
"->",
"always",
"(",
"function",
"(",
"$",
"value",
")",
"{",
"return",
"trim",
"(",
"$",
"value",
",",
"'/'",
")",
";",
"}",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
";",
"// @formatter:on",
"}"
]
| {@inheritdoc} | [
"{"
]
| train | https://github.com/ruvents/ruwork-upload-bundle/blob/8ad09cc2dce6ab389105c440d791346696da43af/DependencyInjection/Configuration.php#L15-L42 |
LeadPages/php_auth_package | src/Auth/LeadpagesLogin.php | LeadpagesLogin.getUser | public function getUser($username, $password)
{
$authHash = $this->hashUserNameAndPassword($username, $password);
$body = json_encode(['clientType' => 'wp-plugin']);
try {
$response = $this->client->post(
$this->loginurl, [
'headers' => ['Authorization' => 'Basic ' . $authHash],
'verify' => $this->certFile,
'body' => $body //wp-plugin value makes session not expire
]);
$this->response = $response->getBody();
} catch (ClientException $e) {
$response = [
'code' => $e->getCode(),
'response' => $e->getMessage(),
'error' => true
];
$this->response = json_encode($response);
} catch (ConnectException $e) {
$message = 'Can not connect to Leadpages Server:';
$response = $this->parseException($e, $message);
$this->response = $response;
}
return $this;
} | php | public function getUser($username, $password)
{
$authHash = $this->hashUserNameAndPassword($username, $password);
$body = json_encode(['clientType' => 'wp-plugin']);
try {
$response = $this->client->post(
$this->loginurl, [
'headers' => ['Authorization' => 'Basic ' . $authHash],
'verify' => $this->certFile,
'body' => $body //wp-plugin value makes session not expire
]);
$this->response = $response->getBody();
} catch (ClientException $e) {
$response = [
'code' => $e->getCode(),
'response' => $e->getMessage(),
'error' => true
];
$this->response = json_encode($response);
} catch (ConnectException $e) {
$message = 'Can not connect to Leadpages Server:';
$response = $this->parseException($e, $message);
$this->response = $response;
}
return $this;
} | [
"public",
"function",
"getUser",
"(",
"$",
"username",
",",
"$",
"password",
")",
"{",
"$",
"authHash",
"=",
"$",
"this",
"->",
"hashUserNameAndPassword",
"(",
"$",
"username",
",",
"$",
"password",
")",
";",
"$",
"body",
"=",
"json_encode",
"(",
"[",
"'clientType'",
"=>",
"'wp-plugin'",
"]",
")",
";",
"try",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"client",
"->",
"post",
"(",
"$",
"this",
"->",
"loginurl",
",",
"[",
"'headers'",
"=>",
"[",
"'Authorization'",
"=>",
"'Basic '",
".",
"$",
"authHash",
"]",
",",
"'verify'",
"=>",
"$",
"this",
"->",
"certFile",
",",
"'body'",
"=>",
"$",
"body",
"//wp-plugin value makes session not expire",
"]",
")",
";",
"$",
"this",
"->",
"response",
"=",
"$",
"response",
"->",
"getBody",
"(",
")",
";",
"}",
"catch",
"(",
"ClientException",
"$",
"e",
")",
"{",
"$",
"response",
"=",
"[",
"'code'",
"=>",
"$",
"e",
"->",
"getCode",
"(",
")",
",",
"'response'",
"=>",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"'error'",
"=>",
"true",
"]",
";",
"$",
"this",
"->",
"response",
"=",
"json_encode",
"(",
"$",
"response",
")",
";",
"}",
"catch",
"(",
"ConnectException",
"$",
"e",
")",
"{",
"$",
"message",
"=",
"'Can not connect to Leadpages Server:'",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"parseException",
"(",
"$",
"e",
",",
"$",
"message",
")",
";",
"$",
"this",
"->",
"response",
"=",
"$",
"response",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| get user information
@param string $username
@param string $password
@return array|\GuzzleHttp\Message\FutureResponse|\GuzzleHttp\Message\ResponseInterface|\GuzzleHttp\Ring\Future\FutureInterface|null | [
"get",
"user",
"information"
]
| train | https://github.com/LeadPages/php_auth_package/blob/0294a053ce3d1a13a58fea85b0a14ffc98cf5893/src/Auth/LeadpagesLogin.php#L52-L81 |
LeadPages/php_auth_package | src/Auth/LeadpagesLogin.php | LeadpagesLogin.createApiKey | public function createApiKey()
{
if (!isset($this->token)) {
return false;
}
$authHeader = 'LP-Security-Token';
if (stripos($this->token, 'lp ') === 0) {
$authHeader = 'Authorization';
}
try {
$response = $this->client->post($this->keyUrl, [
'headers' => [
$authHeader => $this->token,
'Content-Type' => 'application/json',
],
'verify' => $this->certFile,
'body' => json_encode(['label' => 'wordpress-plugin']),
]);
$body = json_decode($response->getBody(), true);
$value = false;
if (array_key_exists('value', $body)) {
$value = $body['value'];
}
} catch (ClientException $e) {
// token is bad
$value = false;
} catch (ConnectException $e) {
$value = false;
}
return $value;
} | php | public function createApiKey()
{
if (!isset($this->token)) {
return false;
}
$authHeader = 'LP-Security-Token';
if (stripos($this->token, 'lp ') === 0) {
$authHeader = 'Authorization';
}
try {
$response = $this->client->post($this->keyUrl, [
'headers' => [
$authHeader => $this->token,
'Content-Type' => 'application/json',
],
'verify' => $this->certFile,
'body' => json_encode(['label' => 'wordpress-plugin']),
]);
$body = json_decode($response->getBody(), true);
$value = false;
if (array_key_exists('value', $body)) {
$value = $body['value'];
}
} catch (ClientException $e) {
// token is bad
$value = false;
} catch (ConnectException $e) {
$value = false;
}
return $value;
} | [
"public",
"function",
"createApiKey",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"token",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"authHeader",
"=",
"'LP-Security-Token'",
";",
"if",
"(",
"stripos",
"(",
"$",
"this",
"->",
"token",
",",
"'lp '",
")",
"===",
"0",
")",
"{",
"$",
"authHeader",
"=",
"'Authorization'",
";",
"}",
"try",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"client",
"->",
"post",
"(",
"$",
"this",
"->",
"keyUrl",
",",
"[",
"'headers'",
"=>",
"[",
"$",
"authHeader",
"=>",
"$",
"this",
"->",
"token",
",",
"'Content-Type'",
"=>",
"'application/json'",
",",
"]",
",",
"'verify'",
"=>",
"$",
"this",
"->",
"certFile",
",",
"'body'",
"=>",
"json_encode",
"(",
"[",
"'label'",
"=>",
"'wordpress-plugin'",
"]",
")",
",",
"]",
")",
";",
"$",
"body",
"=",
"json_decode",
"(",
"$",
"response",
"->",
"getBody",
"(",
")",
",",
"true",
")",
";",
"$",
"value",
"=",
"false",
";",
"if",
"(",
"array_key_exists",
"(",
"'value'",
",",
"$",
"body",
")",
")",
"{",
"$",
"value",
"=",
"$",
"body",
"[",
"'value'",
"]",
";",
"}",
"}",
"catch",
"(",
"ClientException",
"$",
"e",
")",
"{",
"// token is bad",
"$",
"value",
"=",
"false",
";",
"}",
"catch",
"(",
"ConnectException",
"$",
"e",
")",
"{",
"$",
"value",
"=",
"false",
";",
"}",
"return",
"$",
"value",
";",
"}"
]
| Create an API key for account
@return string|boolean JSON encode key or false | [
"Create",
"an",
"API",
"key",
"for",
"account"
]
| train | https://github.com/LeadPages/php_auth_package/blob/0294a053ce3d1a13a58fea85b0a14ffc98cf5893/src/Auth/LeadpagesLogin.php#L88-L125 |
LeadPages/php_auth_package | src/Auth/LeadpagesLogin.php | LeadpagesLogin.parseResponse | public function parseResponse($deleteTokenOnFail = false)
{
$responseArray = json_decode($this->response, true);
if (isset($responseArray['error']) && $responseArray['error']) {
// token should be unset assumed to be no longer valid
unset($this->token);
// delete token from data store if param is passed
if ($deleteTokenOnFail) {
$this->deleteToken();
}
return $this->response;
}
$this->token = $responseArray['securityToken'];
return 'success';
} | php | public function parseResponse($deleteTokenOnFail = false)
{
$responseArray = json_decode($this->response, true);
if (isset($responseArray['error']) && $responseArray['error']) {
// token should be unset assumed to be no longer valid
unset($this->token);
// delete token from data store if param is passed
if ($deleteTokenOnFail) {
$this->deleteToken();
}
return $this->response;
}
$this->token = $responseArray['securityToken'];
return 'success';
} | [
"public",
"function",
"parseResponse",
"(",
"$",
"deleteTokenOnFail",
"=",
"false",
")",
"{",
"$",
"responseArray",
"=",
"json_decode",
"(",
"$",
"this",
"->",
"response",
",",
"true",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"responseArray",
"[",
"'error'",
"]",
")",
"&&",
"$",
"responseArray",
"[",
"'error'",
"]",
")",
"{",
"// token should be unset assumed to be no longer valid",
"unset",
"(",
"$",
"this",
"->",
"token",
")",
";",
"// delete token from data store if param is passed",
"if",
"(",
"$",
"deleteTokenOnFail",
")",
"{",
"$",
"this",
"->",
"deleteToken",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"response",
";",
"}",
"$",
"this",
"->",
"token",
"=",
"$",
"responseArray",
"[",
"'securityToken'",
"]",
";",
"return",
"'success'",
";",
"}"
]
| Parse response for call to Leadpages Login. If response does
not contain a error we will return a response with
HttpResponseCode and Message
@param bool $deleteTokenOnFail
@return string json encoded response for client to handle | [
"Parse",
"response",
"for",
"call",
"to",
"Leadpages",
"Login",
".",
"If",
"response",
"does",
"not",
"contain",
"a",
"error",
"we",
"will",
"return",
"a",
"response",
"with",
"HttpResponseCode",
"and",
"Message"
]
| train | https://github.com/LeadPages/php_auth_package/blob/0294a053ce3d1a13a58fea85b0a14ffc98cf5893/src/Auth/LeadpagesLogin.php#L135-L149 |
tigris-php/telegram-bot-api | src/Types/Updates/Update.php | Update.detectType | protected static function detectType(array $data)
{
foreach ([
self::TYPE_MESSAGE,
self::TYPE_EDITED_MESSAGE,
self::TYPE_CHANNEL_POST,
self::TYPE_EDITED_CHANNEL_POST,
self::TYPE_INLINE_QUERY,
self::TYPE_CHOSEN_INLINE_RESULT,
self::TYPE_CALLBACK_QUERY,
] as $type) {
if (isset($data[$type])) {
return $type;
}
}
return static::TYPE_UNKNOWN;
} | php | protected static function detectType(array $data)
{
foreach ([
self::TYPE_MESSAGE,
self::TYPE_EDITED_MESSAGE,
self::TYPE_CHANNEL_POST,
self::TYPE_EDITED_CHANNEL_POST,
self::TYPE_INLINE_QUERY,
self::TYPE_CHOSEN_INLINE_RESULT,
self::TYPE_CALLBACK_QUERY,
] as $type) {
if (isset($data[$type])) {
return $type;
}
}
return static::TYPE_UNKNOWN;
} | [
"protected",
"static",
"function",
"detectType",
"(",
"array",
"$",
"data",
")",
"{",
"foreach",
"(",
"[",
"self",
"::",
"TYPE_MESSAGE",
",",
"self",
"::",
"TYPE_EDITED_MESSAGE",
",",
"self",
"::",
"TYPE_CHANNEL_POST",
",",
"self",
"::",
"TYPE_EDITED_CHANNEL_POST",
",",
"self",
"::",
"TYPE_INLINE_QUERY",
",",
"self",
"::",
"TYPE_CHOSEN_INLINE_RESULT",
",",
"self",
"::",
"TYPE_CALLBACK_QUERY",
",",
"]",
"as",
"$",
"type",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"$",
"type",
"]",
")",
")",
"{",
"return",
"$",
"type",
";",
"}",
"}",
"return",
"static",
"::",
"TYPE_UNKNOWN",
";",
"}"
]
| Detects update type
@param $data
@return string | [
"Detects",
"update",
"type"
]
| train | https://github.com/tigris-php/telegram-bot-api/blob/7350c81d571387005d58079d8c654ee44504cdcf/src/Types/Updates/Update.php#L66-L82 |
ClanCats/Core | src/classes/CCRequest.php | CCRequest.perform | public function perform()
{
// set the input
if ( !is_null( $this->input ) )
{
CCIn::instance( $this->input );
} else {
CCIn::instance( CCServer::instance() );
}
// set current request
static::$_current =& $this;
// route is invalid show 404
if ( !$this->route instanceof CCRoute )
{
$this->route = CCRouter::resolve( '#404' );
}
/*
* call wake events
* if one event returns an response all other calls will be skipped also events!
*/
foreach( CCRouter::events_matching( 'wake', $this->route->uri ) as $callback )
{
if ( ( $return = CCContainer::call( $callback ) ) instanceof CCResponse )
{
$this->response = $return; return $this;
}
}
/*
* a closure
*/
if ( !is_array( $this->route->callback ) && is_callable( $this->route->callback ) )
{
// execute and capture the output
ob_start();
// run the closure
$return = call_user_func_array( $this->route->callback, $this->route->params );
// catch the output
$output = ob_get_clean();
// do we got a response?
if ( !$return instanceof CCResponse )
{
// if not create one with the captured output
$return = CCResponse::create( $output );
}
}
/*
* a callback
*/
elseif ( is_callable( $this->route->callback ) )
{
// execute the callback and get the return
$return = call_user_func_array( $this->route->callback, array( $this->route->action, $this->route->params ) );
// do we got a response?
if ( !$return instanceof CCResponse )
{
// if not create one with the return as string
$return = CCResponse::create( (string) $return );
}
}
/*
* 404 error if nothing
*/
else
{
$return = CCResponse::error( 404 );
}
// set the response
$this->response = $return;
/*
* call sleep events
* if one event returns an response all other calls will be skipped also events!
*/
foreach( CCRouter::events_matching( 'sleep', $this->route->uri ) as $callback )
{
if ( $return = CCContainer::call( $callback, $this->response ) instanceof CCResponse )
{
$this->response = $return; return $this;
}
}
return $this;
} | php | public function perform()
{
// set the input
if ( !is_null( $this->input ) )
{
CCIn::instance( $this->input );
} else {
CCIn::instance( CCServer::instance() );
}
// set current request
static::$_current =& $this;
// route is invalid show 404
if ( !$this->route instanceof CCRoute )
{
$this->route = CCRouter::resolve( '#404' );
}
/*
* call wake events
* if one event returns an response all other calls will be skipped also events!
*/
foreach( CCRouter::events_matching( 'wake', $this->route->uri ) as $callback )
{
if ( ( $return = CCContainer::call( $callback ) ) instanceof CCResponse )
{
$this->response = $return; return $this;
}
}
/*
* a closure
*/
if ( !is_array( $this->route->callback ) && is_callable( $this->route->callback ) )
{
// execute and capture the output
ob_start();
// run the closure
$return = call_user_func_array( $this->route->callback, $this->route->params );
// catch the output
$output = ob_get_clean();
// do we got a response?
if ( !$return instanceof CCResponse )
{
// if not create one with the captured output
$return = CCResponse::create( $output );
}
}
/*
* a callback
*/
elseif ( is_callable( $this->route->callback ) )
{
// execute the callback and get the return
$return = call_user_func_array( $this->route->callback, array( $this->route->action, $this->route->params ) );
// do we got a response?
if ( !$return instanceof CCResponse )
{
// if not create one with the return as string
$return = CCResponse::create( (string) $return );
}
}
/*
* 404 error if nothing
*/
else
{
$return = CCResponse::error( 404 );
}
// set the response
$this->response = $return;
/*
* call sleep events
* if one event returns an response all other calls will be skipped also events!
*/
foreach( CCRouter::events_matching( 'sleep', $this->route->uri ) as $callback )
{
if ( $return = CCContainer::call( $callback, $this->response ) instanceof CCResponse )
{
$this->response = $return; return $this;
}
}
return $this;
} | [
"public",
"function",
"perform",
"(",
")",
"{",
"// set the input",
"if",
"(",
"!",
"is_null",
"(",
"$",
"this",
"->",
"input",
")",
")",
"{",
"CCIn",
"::",
"instance",
"(",
"$",
"this",
"->",
"input",
")",
";",
"}",
"else",
"{",
"CCIn",
"::",
"instance",
"(",
"CCServer",
"::",
"instance",
"(",
")",
")",
";",
"}",
"// set current request",
"static",
"::",
"$",
"_current",
"=",
"&",
"$",
"this",
";",
"// route is invalid show 404",
"if",
"(",
"!",
"$",
"this",
"->",
"route",
"instanceof",
"CCRoute",
")",
"{",
"$",
"this",
"->",
"route",
"=",
"CCRouter",
"::",
"resolve",
"(",
"'#404'",
")",
";",
"}",
"/*\n\t\t * call wake events\n\t\t * if one event returns an response all other calls will be skipped also events!\n\t\t */",
"foreach",
"(",
"CCRouter",
"::",
"events_matching",
"(",
"'wake'",
",",
"$",
"this",
"->",
"route",
"->",
"uri",
")",
"as",
"$",
"callback",
")",
"{",
"if",
"(",
"(",
"$",
"return",
"=",
"CCContainer",
"::",
"call",
"(",
"$",
"callback",
")",
")",
"instanceof",
"CCResponse",
")",
"{",
"$",
"this",
"->",
"response",
"=",
"$",
"return",
";",
"return",
"$",
"this",
";",
"}",
"}",
"/*\n\t\t * a closure\n\t\t */",
"if",
"(",
"!",
"is_array",
"(",
"$",
"this",
"->",
"route",
"->",
"callback",
")",
"&&",
"is_callable",
"(",
"$",
"this",
"->",
"route",
"->",
"callback",
")",
")",
"{",
"// execute and capture the output",
"ob_start",
"(",
")",
";",
"// run the closure ",
"$",
"return",
"=",
"call_user_func_array",
"(",
"$",
"this",
"->",
"route",
"->",
"callback",
",",
"$",
"this",
"->",
"route",
"->",
"params",
")",
";",
"// catch the output",
"$",
"output",
"=",
"ob_get_clean",
"(",
")",
";",
"// do we got a response?",
"if",
"(",
"!",
"$",
"return",
"instanceof",
"CCResponse",
")",
"{",
"// if not create one with the captured output",
"$",
"return",
"=",
"CCResponse",
"::",
"create",
"(",
"$",
"output",
")",
";",
"}",
"}",
"/*\n\t\t * a callback\n\t\t */",
"elseif",
"(",
"is_callable",
"(",
"$",
"this",
"->",
"route",
"->",
"callback",
")",
")",
"{",
"// execute the callback and get the return",
"$",
"return",
"=",
"call_user_func_array",
"(",
"$",
"this",
"->",
"route",
"->",
"callback",
",",
"array",
"(",
"$",
"this",
"->",
"route",
"->",
"action",
",",
"$",
"this",
"->",
"route",
"->",
"params",
")",
")",
";",
"// do we got a response?",
"if",
"(",
"!",
"$",
"return",
"instanceof",
"CCResponse",
")",
"{",
"// if not create one with the return as string",
"$",
"return",
"=",
"CCResponse",
"::",
"create",
"(",
"(",
"string",
")",
"$",
"return",
")",
";",
"}",
"}",
"/*\n\t\t * 404 error if nothing\n\t\t */",
"else",
"{",
"$",
"return",
"=",
"CCResponse",
"::",
"error",
"(",
"404",
")",
";",
"}",
"// set the response",
"$",
"this",
"->",
"response",
"=",
"$",
"return",
";",
"/*\n\t\t * call sleep events\n\t\t * if one event returns an response all other calls will be skipped also events!\n\t\t */",
"foreach",
"(",
"CCRouter",
"::",
"events_matching",
"(",
"'sleep'",
",",
"$",
"this",
"->",
"route",
"->",
"uri",
")",
"as",
"$",
"callback",
")",
"{",
"if",
"(",
"$",
"return",
"=",
"CCContainer",
"::",
"call",
"(",
"$",
"callback",
",",
"$",
"this",
"->",
"response",
")",
"instanceof",
"CCResponse",
")",
"{",
"$",
"this",
"->",
"response",
"=",
"$",
"return",
";",
"return",
"$",
"this",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
]
| Execute the Request
@param array $action
@param array $params
@return self | [
"Execute",
"the",
"Request"
]
| train | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCRequest.php#L110-L199 |
VincentChalnot/SidusAdminBundle | Routing/AdminRouteLoader.php | AdminRouteLoader.load | public function load($resource, $type = null): RouteCollection
{
if (true === $this->loaded) {
throw new \RuntimeException('Do not add the "sidus_admin" loader twice');
}
$routes = new RouteCollection();
foreach ($this->adminRegistry->getAdmins() as $admin) {
foreach ($admin->getActions() as $action) {
$routes->add($action->getRouteName(), $action->getRoute());
}
}
$this->loaded = true;
return $routes;
} | php | public function load($resource, $type = null): RouteCollection
{
if (true === $this->loaded) {
throw new \RuntimeException('Do not add the "sidus_admin" loader twice');
}
$routes = new RouteCollection();
foreach ($this->adminRegistry->getAdmins() as $admin) {
foreach ($admin->getActions() as $action) {
$routes->add($action->getRouteName(), $action->getRoute());
}
}
$this->loaded = true;
return $routes;
} | [
"public",
"function",
"load",
"(",
"$",
"resource",
",",
"$",
"type",
"=",
"null",
")",
":",
"RouteCollection",
"{",
"if",
"(",
"true",
"===",
"$",
"this",
"->",
"loaded",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Do not add the \"sidus_admin\" loader twice'",
")",
";",
"}",
"$",
"routes",
"=",
"new",
"RouteCollection",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"adminRegistry",
"->",
"getAdmins",
"(",
")",
"as",
"$",
"admin",
")",
"{",
"foreach",
"(",
"$",
"admin",
"->",
"getActions",
"(",
")",
"as",
"$",
"action",
")",
"{",
"$",
"routes",
"->",
"add",
"(",
"$",
"action",
"->",
"getRouteName",
"(",
")",
",",
"$",
"action",
"->",
"getRoute",
"(",
")",
")",
";",
"}",
"}",
"$",
"this",
"->",
"loaded",
"=",
"true",
";",
"return",
"$",
"routes",
";",
"}"
]
| @param mixed $resource
@param null $type
@throws \RuntimeException
@return RouteCollection | [
"@param",
"mixed",
"$resource",
"@param",
"null",
"$type"
]
| train | https://github.com/VincentChalnot/SidusAdminBundle/blob/3366f3f1525435860cf275ed2f1f0b58cf6eea18/Routing/AdminRouteLoader.php#L46-L63 |
PortaText/php-sdk | src/PortaText/Command/Api/CreditCards.php | CreditCards.cardInfo | public function cardInfo($number, $expirationDate, $code)
{
$this->setArgument('card_number', $number);
$this->setArgument('card_expiration_date', $expirationDate);
return $this->setArgument('card_code', $code);
} | php | public function cardInfo($number, $expirationDate, $code)
{
$this->setArgument('card_number', $number);
$this->setArgument('card_expiration_date', $expirationDate);
return $this->setArgument('card_code', $code);
} | [
"public",
"function",
"cardInfo",
"(",
"$",
"number",
",",
"$",
"expirationDate",
",",
"$",
"code",
")",
"{",
"$",
"this",
"->",
"setArgument",
"(",
"'card_number'",
",",
"$",
"number",
")",
";",
"$",
"this",
"->",
"setArgument",
"(",
"'card_expiration_date'",
",",
"$",
"expirationDate",
")",
";",
"return",
"$",
"this",
"->",
"setArgument",
"(",
"'card_code'",
",",
"$",
"code",
")",
";",
"}"
]
| Set card information.
@param string $number The card number.
@param string $expirationDate In format: YYYY-MM.
@param string $code The card security code.
@return PortaText\Command\ICommand | [
"Set",
"card",
"information",
"."
]
| train | https://github.com/PortaText/php-sdk/blob/dbe04ef043db5b251953f9de57aa4d0f1785dfcc/src/PortaText/Command/Api/CreditCards.php#L55-L60 |
PortaText/php-sdk | src/PortaText/Command/Api/CreditCards.php | CreditCards.address | public function address($streetAddress, $city, $state, $zip, $country)
{
$this->setArgument('address', $streetAddress);
$this->setArgument('city', $city);
$this->setArgument('state', $state);
$this->setArgument('zip', $zip);
return $this->setArgument('country', $country);
} | php | public function address($streetAddress, $city, $state, $zip, $country)
{
$this->setArgument('address', $streetAddress);
$this->setArgument('city', $city);
$this->setArgument('state', $state);
$this->setArgument('zip', $zip);
return $this->setArgument('country', $country);
} | [
"public",
"function",
"address",
"(",
"$",
"streetAddress",
",",
"$",
"city",
",",
"$",
"state",
",",
"$",
"zip",
",",
"$",
"country",
")",
"{",
"$",
"this",
"->",
"setArgument",
"(",
"'address'",
",",
"$",
"streetAddress",
")",
";",
"$",
"this",
"->",
"setArgument",
"(",
"'city'",
",",
"$",
"city",
")",
";",
"$",
"this",
"->",
"setArgument",
"(",
"'state'",
",",
"$",
"state",
")",
";",
"$",
"this",
"->",
"setArgument",
"(",
"'zip'",
",",
"$",
"zip",
")",
";",
"return",
"$",
"this",
"->",
"setArgument",
"(",
"'country'",
",",
"$",
"country",
")",
";",
"}"
]
| Set card billing address.
@param string $streetAddress The full street address.
@param string $city The city name.
@param string $state The state name.
@param string $zip The ZIP code.
@param string $country The country name.
@return PortaText\Command\ICommand | [
"Set",
"card",
"billing",
"address",
"."
]
| train | https://github.com/PortaText/php-sdk/blob/dbe04ef043db5b251953f9de57aa4d0f1785dfcc/src/PortaText/Command/Api/CreditCards.php#L73-L80 |
PortaText/php-sdk | src/PortaText/Command/Api/CreditCards.php | CreditCards.getEndpoint | protected function getEndpoint($method)
{
$endpoint = "credit_cards";
$cardId = $this->getArgument("id");
if (!is_null($cardId)) {
$endpoint .= "/$cardId";
$this->delArgument("id");
}
return $endpoint;
} | php | protected function getEndpoint($method)
{
$endpoint = "credit_cards";
$cardId = $this->getArgument("id");
if (!is_null($cardId)) {
$endpoint .= "/$cardId";
$this->delArgument("id");
}
return $endpoint;
} | [
"protected",
"function",
"getEndpoint",
"(",
"$",
"method",
")",
"{",
"$",
"endpoint",
"=",
"\"credit_cards\"",
";",
"$",
"cardId",
"=",
"$",
"this",
"->",
"getArgument",
"(",
"\"id\"",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"cardId",
")",
")",
"{",
"$",
"endpoint",
".=",
"\"/$cardId\"",
";",
"$",
"this",
"->",
"delArgument",
"(",
"\"id\"",
")",
";",
"}",
"return",
"$",
"endpoint",
";",
"}"
]
| Returns a string with the endpoint for the given command.
@param string $method Method for this command.
@return string | [
"Returns",
"a",
"string",
"with",
"the",
"endpoint",
"for",
"the",
"given",
"command",
"."
]
| train | https://github.com/PortaText/php-sdk/blob/dbe04ef043db5b251953f9de57aa4d0f1785dfcc/src/PortaText/Command/Api/CreditCards.php#L89-L98 |
dms-org/package.blog | src/Infrastructure/Persistence/BlogAuthorMapper.php | BlogAuthorMapper.define | protected function define(MapperDefinition $map)
{
$map->type(BlogAuthor::class);
$map->toTable('authors');
$map->idToPrimaryKey('id');
$map->property(BlogAuthor::NAME)->to('name')->asVarchar(255);
$map->property(BlogAuthor::ROLE)->to('role')->asVarchar(255);
$map->property(BlogAuthor::SLUG)->to('slug')->unique()->asVarchar(255);
$map->embedded(BlogAuthor::BIO)
->using(new HtmlMapper('bio'));
$map->relation(BlogAuthor::ARTICLES)
->to(BlogArticle::class)
->toMany()
->identifying()
->withBidirectionalRelation(BlogArticle::AUTHOR)
->withParentIdAs($map->getOrm()->getNamespace() . 'author_id');
MetadataMapper::mapMetadataToJsonColumn($map, 'metadata');
} | php | protected function define(MapperDefinition $map)
{
$map->type(BlogAuthor::class);
$map->toTable('authors');
$map->idToPrimaryKey('id');
$map->property(BlogAuthor::NAME)->to('name')->asVarchar(255);
$map->property(BlogAuthor::ROLE)->to('role')->asVarchar(255);
$map->property(BlogAuthor::SLUG)->to('slug')->unique()->asVarchar(255);
$map->embedded(BlogAuthor::BIO)
->using(new HtmlMapper('bio'));
$map->relation(BlogAuthor::ARTICLES)
->to(BlogArticle::class)
->toMany()
->identifying()
->withBidirectionalRelation(BlogArticle::AUTHOR)
->withParentIdAs($map->getOrm()->getNamespace() . 'author_id');
MetadataMapper::mapMetadataToJsonColumn($map, 'metadata');
} | [
"protected",
"function",
"define",
"(",
"MapperDefinition",
"$",
"map",
")",
"{",
"$",
"map",
"->",
"type",
"(",
"BlogAuthor",
"::",
"class",
")",
";",
"$",
"map",
"->",
"toTable",
"(",
"'authors'",
")",
";",
"$",
"map",
"->",
"idToPrimaryKey",
"(",
"'id'",
")",
";",
"$",
"map",
"->",
"property",
"(",
"BlogAuthor",
"::",
"NAME",
")",
"->",
"to",
"(",
"'name'",
")",
"->",
"asVarchar",
"(",
"255",
")",
";",
"$",
"map",
"->",
"property",
"(",
"BlogAuthor",
"::",
"ROLE",
")",
"->",
"to",
"(",
"'role'",
")",
"->",
"asVarchar",
"(",
"255",
")",
";",
"$",
"map",
"->",
"property",
"(",
"BlogAuthor",
"::",
"SLUG",
")",
"->",
"to",
"(",
"'slug'",
")",
"->",
"unique",
"(",
")",
"->",
"asVarchar",
"(",
"255",
")",
";",
"$",
"map",
"->",
"embedded",
"(",
"BlogAuthor",
"::",
"BIO",
")",
"->",
"using",
"(",
"new",
"HtmlMapper",
"(",
"'bio'",
")",
")",
";",
"$",
"map",
"->",
"relation",
"(",
"BlogAuthor",
"::",
"ARTICLES",
")",
"->",
"to",
"(",
"BlogArticle",
"::",
"class",
")",
"->",
"toMany",
"(",
")",
"->",
"identifying",
"(",
")",
"->",
"withBidirectionalRelation",
"(",
"BlogArticle",
"::",
"AUTHOR",
")",
"->",
"withParentIdAs",
"(",
"$",
"map",
"->",
"getOrm",
"(",
")",
"->",
"getNamespace",
"(",
")",
".",
"'author_id'",
")",
";",
"MetadataMapper",
"::",
"mapMetadataToJsonColumn",
"(",
"$",
"map",
",",
"'metadata'",
")",
";",
"}"
]
| Defines the entity mapper
@param MapperDefinition $map
@return void | [
"Defines",
"the",
"entity",
"mapper"
]
| train | https://github.com/dms-org/package.blog/blob/1500f6fad20d81289a0dfa617fc1c54699f01e16/src/Infrastructure/Persistence/BlogAuthorMapper.php#L24-L49 |
spiral-modules/auth | source/Auth/Operators/HttpOperator.php | HttpOperator.fetchToken | public function fetchToken(Request $request)
{
$header = $request->getHeaderLine('Authorization');
list($username, $password) = self::parseHeader($header);
if (empty($username) || empty($password)) {
return null;
}
//Direct authentication
try {
$user = $this->authenticator->getUser($username, $password);
} catch (CredentialsException $e) {
return null;
}
return new AuthToken('http-auth', $user->primaryKey(), $this);
} | php | public function fetchToken(Request $request)
{
$header = $request->getHeaderLine('Authorization');
list($username, $password) = self::parseHeader($header);
if (empty($username) || empty($password)) {
return null;
}
//Direct authentication
try {
$user = $this->authenticator->getUser($username, $password);
} catch (CredentialsException $e) {
return null;
}
return new AuthToken('http-auth', $user->primaryKey(), $this);
} | [
"public",
"function",
"fetchToken",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"header",
"=",
"$",
"request",
"->",
"getHeaderLine",
"(",
"'Authorization'",
")",
";",
"list",
"(",
"$",
"username",
",",
"$",
"password",
")",
"=",
"self",
"::",
"parseHeader",
"(",
"$",
"header",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"username",
")",
"||",
"empty",
"(",
"$",
"password",
")",
")",
"{",
"return",
"null",
";",
"}",
"//Direct authentication",
"try",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"authenticator",
"->",
"getUser",
"(",
"$",
"username",
",",
"$",
"password",
")",
";",
"}",
"catch",
"(",
"CredentialsException",
"$",
"e",
")",
"{",
"return",
"null",
";",
"}",
"return",
"new",
"AuthToken",
"(",
"'http-auth'",
",",
"$",
"user",
"->",
"primaryKey",
"(",
")",
",",
"$",
"this",
")",
";",
"}"
]
| {@inheritdoc} | [
"{"
]
| train | https://github.com/spiral-modules/auth/blob/24e2070028f7257e8192914556963a4794428a99/source/Auth/Operators/HttpOperator.php#L59-L76 |
vi-kon/laravel-auth | src/ViKon/Auth/Helper/FormRequestRouteAuthorizer.php | FormRequestRouteAuthorizer.authorize | public function authorize(Router $router)
{
/** @noinspection PhpUndefinedFieldInspection */
return $this->container->make(RouterAuth::class)->hasAccess($router->current()->getName()) !== false;
} | php | public function authorize(Router $router)
{
/** @noinspection PhpUndefinedFieldInspection */
return $this->container->make(RouterAuth::class)->hasAccess($router->current()->getName()) !== false;
} | [
"public",
"function",
"authorize",
"(",
"Router",
"$",
"router",
")",
"{",
"/** @noinspection PhpUndefinedFieldInspection */",
"return",
"$",
"this",
"->",
"container",
"->",
"make",
"(",
"RouterAuth",
"::",
"class",
")",
"->",
"hasAccess",
"(",
"$",
"router",
"->",
"current",
"(",
")",
"->",
"getName",
"(",
")",
")",
"!==",
"false",
";",
"}"
]
| {@inheritDoc} | [
"{"
]
| train | https://github.com/vi-kon/laravel-auth/blob/501c20128f43347a2ca271a53435297f9ef7f567/src/ViKon/Auth/Helper/FormRequestRouteAuthorizer.php#L20-L24 |
periaptio/empress-generator | src/Commands/GeneratorCommand.php | GeneratorCommand.handle | public function handle()
{
if ($this->argument('tables')) {
$tables = explode(',', $this->argument('tables'));
} elseif ($this->option('tables')) {
$tables = explode(',', $this->option('tables'));
} else {
$tables = DB::getDoctrineConnection()->getSchemaManager()->listTableNames();
}
$this->tables = $this->removeExcludedTables($tables);
$this->type = $this->getType();
} | php | public function handle()
{
if ($this->argument('tables')) {
$tables = explode(',', $this->argument('tables'));
} elseif ($this->option('tables')) {
$tables = explode(',', $this->option('tables'));
} else {
$tables = DB::getDoctrineConnection()->getSchemaManager()->listTableNames();
}
$this->tables = $this->removeExcludedTables($tables);
$this->type = $this->getType();
} | [
"public",
"function",
"handle",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"argument",
"(",
"'tables'",
")",
")",
"{",
"$",
"tables",
"=",
"explode",
"(",
"','",
",",
"$",
"this",
"->",
"argument",
"(",
"'tables'",
")",
")",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"option",
"(",
"'tables'",
")",
")",
"{",
"$",
"tables",
"=",
"explode",
"(",
"','",
",",
"$",
"this",
"->",
"option",
"(",
"'tables'",
")",
")",
";",
"}",
"else",
"{",
"$",
"tables",
"=",
"DB",
"::",
"getDoctrineConnection",
"(",
")",
"->",
"getSchemaManager",
"(",
")",
"->",
"listTableNames",
"(",
")",
";",
"}",
"$",
"this",
"->",
"tables",
"=",
"$",
"this",
"->",
"removeExcludedTables",
"(",
"$",
"tables",
")",
";",
"$",
"this",
"->",
"type",
"=",
"$",
"this",
"->",
"getType",
"(",
")",
";",
"}"
]
| Execute the command.
@return void | [
"Execute",
"the",
"command",
"."
]
| train | https://github.com/periaptio/empress-generator/blob/749fb4b12755819e9c97377ebfb446ee0822168a/src/Commands/GeneratorCommand.php#L54-L67 |
periaptio/empress-generator | src/Commands/GeneratorCommand.php | GeneratorCommand.getConfigData | public function getConfigData()
{
$viewConfigPath = config('generator.path_view', base_path('resources/views/'));
$viewBasePath = base_path('resources/views/');
if ($viewBasePath === $viewConfigPath) {
$viewPath = '';
} else {
$trans = array('/' => '.', $viewBasePath => '');
$viewPath = strtr($viewConfigPath, $trans);
}
$routePrefix = config('generator.route_prefix', '');
// check route prefix end with '.'
if (strlen($routePrefix) > 0 && $routePrefix[strlen($routePrefix) - 1] !== '.') {
$routePrefix .= '.';
}
return [
'BASE_CONTROLLER' => config('generator.base_controller', 'App\Http\Controllers\Controller'),
'BASE_NAME' => config('generator.base_name', 'App\Http\Request\Request'),
'NAMESPACE_MODEL' => config('generator.namespace_model', 'App\Models'),
'NAMESPACE_MODEL_EXTEND' => config('generator.model_extend_class', 'Illuminate\Database\Eloquent\Model'),
'NAMESPACE_CONTROLLER' => config('generator.namespace_controller', 'App\Http\Controllers'),
'NAMESPACE_REQUEST' => config('generator.namespace_request', 'App\Http\Requests'),
'NAMESPACE_REPOSITORY' => config('generator.namespace_repository', 'App\Repositories'),
'NAMESPACE_SERVICE' => config('generator.namespace_service', 'App\Services'),
'MAIN_LAYOUT' => config('generator.main_layout', 'app'),
'VIEW_PATH' => $viewPath,
'ROUTE_PREFIX' => $routePrefix,
];
} | php | public function getConfigData()
{
$viewConfigPath = config('generator.path_view', base_path('resources/views/'));
$viewBasePath = base_path('resources/views/');
if ($viewBasePath === $viewConfigPath) {
$viewPath = '';
} else {
$trans = array('/' => '.', $viewBasePath => '');
$viewPath = strtr($viewConfigPath, $trans);
}
$routePrefix = config('generator.route_prefix', '');
// check route prefix end with '.'
if (strlen($routePrefix) > 0 && $routePrefix[strlen($routePrefix) - 1] !== '.') {
$routePrefix .= '.';
}
return [
'BASE_CONTROLLER' => config('generator.base_controller', 'App\Http\Controllers\Controller'),
'BASE_NAME' => config('generator.base_name', 'App\Http\Request\Request'),
'NAMESPACE_MODEL' => config('generator.namespace_model', 'App\Models'),
'NAMESPACE_MODEL_EXTEND' => config('generator.model_extend_class', 'Illuminate\Database\Eloquent\Model'),
'NAMESPACE_CONTROLLER' => config('generator.namespace_controller', 'App\Http\Controllers'),
'NAMESPACE_REQUEST' => config('generator.namespace_request', 'App\Http\Requests'),
'NAMESPACE_REPOSITORY' => config('generator.namespace_repository', 'App\Repositories'),
'NAMESPACE_SERVICE' => config('generator.namespace_service', 'App\Services'),
'MAIN_LAYOUT' => config('generator.main_layout', 'app'),
'VIEW_PATH' => $viewPath,
'ROUTE_PREFIX' => $routePrefix,
];
} | [
"public",
"function",
"getConfigData",
"(",
")",
"{",
"$",
"viewConfigPath",
"=",
"config",
"(",
"'generator.path_view'",
",",
"base_path",
"(",
"'resources/views/'",
")",
")",
";",
"$",
"viewBasePath",
"=",
"base_path",
"(",
"'resources/views/'",
")",
";",
"if",
"(",
"$",
"viewBasePath",
"===",
"$",
"viewConfigPath",
")",
"{",
"$",
"viewPath",
"=",
"''",
";",
"}",
"else",
"{",
"$",
"trans",
"=",
"array",
"(",
"'/'",
"=>",
"'.'",
",",
"$",
"viewBasePath",
"=>",
"''",
")",
";",
"$",
"viewPath",
"=",
"strtr",
"(",
"$",
"viewConfigPath",
",",
"$",
"trans",
")",
";",
"}",
"$",
"routePrefix",
"=",
"config",
"(",
"'generator.route_prefix'",
",",
"''",
")",
";",
"// check route prefix end with '.'",
"if",
"(",
"strlen",
"(",
"$",
"routePrefix",
")",
">",
"0",
"&&",
"$",
"routePrefix",
"[",
"strlen",
"(",
"$",
"routePrefix",
")",
"-",
"1",
"]",
"!==",
"'.'",
")",
"{",
"$",
"routePrefix",
".=",
"'.'",
";",
"}",
"return",
"[",
"'BASE_CONTROLLER'",
"=>",
"config",
"(",
"'generator.base_controller'",
",",
"'App\\Http\\Controllers\\Controller'",
")",
",",
"'BASE_NAME'",
"=>",
"config",
"(",
"'generator.base_name'",
",",
"'App\\Http\\Request\\Request'",
")",
",",
"'NAMESPACE_MODEL'",
"=>",
"config",
"(",
"'generator.namespace_model'",
",",
"'App\\Models'",
")",
",",
"'NAMESPACE_MODEL_EXTEND'",
"=>",
"config",
"(",
"'generator.model_extend_class'",
",",
"'Illuminate\\Database\\Eloquent\\Model'",
")",
",",
"'NAMESPACE_CONTROLLER'",
"=>",
"config",
"(",
"'generator.namespace_controller'",
",",
"'App\\Http\\Controllers'",
")",
",",
"'NAMESPACE_REQUEST'",
"=>",
"config",
"(",
"'generator.namespace_request'",
",",
"'App\\Http\\Requests'",
")",
",",
"'NAMESPACE_REPOSITORY'",
"=>",
"config",
"(",
"'generator.namespace_repository'",
",",
"'App\\Repositories'",
")",
",",
"'NAMESPACE_SERVICE'",
"=>",
"config",
"(",
"'generator.namespace_service'",
",",
"'App\\Services'",
")",
",",
"'MAIN_LAYOUT'",
"=>",
"config",
"(",
"'generator.main_layout'",
",",
"'app'",
")",
",",
"'VIEW_PATH'",
"=>",
"$",
"viewPath",
",",
"'ROUTE_PREFIX'",
"=>",
"$",
"routePrefix",
",",
"]",
";",
"}"
]
| get config data from config/generator.php
@return array | [
"get",
"config",
"data",
"from",
"config",
"/",
"generator",
".",
"php"
]
| train | https://github.com/periaptio/empress-generator/blob/749fb4b12755819e9c97377ebfb446ee0822168a/src/Commands/GeneratorCommand.php#L104-L145 |
danrevah/shortify-punit | src/Stub/WhenChainCase.php | WhenChainCase.createChainArrayOfReturnValues | private function createChainArrayOfReturnValues($action, $response)
{
// Pop first method
$methods = $this->methods;
$firstMethod = array_pop($methods);
$lastValue = $response;
$mockClassType = get_class($this->mockClass);
if ( ! $this->mockClass instanceof MockInterface) {
throw self::generateException('Class is not implementing MockInterface.');
}
$mockClassInstanceId = $this->mockClass->getShortifyPunitInstanceId();
foreach($methods as $currentMethod)
{
$fakeClass = new MockClassOnTheFly();
// extracting methods before the current method into an array
$chainedMethodsBefore = $this->extractChainedMethodsBefore(
array_reverse($this->methods),
$currentMethod
);
// adding to the ShortifyPunit chained method response
$this->addChainedMethodResponse(
$chainedMethodsBefore,
$currentMethod,
$action,
$lastValue,
$mockClassInstanceId
);
$currentMethodName = key($currentMethod);
// closure for MockOnTheFly chained methods
$fakeClass->$currentMethodName = function() use (
$mockClassInstanceId,
$mockClassType,
$chainedMethodsBefore,
$currentMethod
) {
return ShortifyPunit::createChainResponse(
$mockClassInstanceId,
$mockClassType,
$chainedMethodsBefore,
$currentMethod,
func_get_args()
);
};
$lastValue = $fakeClass;
// except from the last method all other chained method `returns` a calls so set the action for the next loop
$action = MockAction::RETURNS;
}
$whenCase = new WhenCase($mockClassType, $this->mockClass->getShortifyPunitInstanceId(), key($firstMethod));
$whenCase->setMethod(current($firstMethod), $action, $lastValue);
} | php | private function createChainArrayOfReturnValues($action, $response)
{
// Pop first method
$methods = $this->methods;
$firstMethod = array_pop($methods);
$lastValue = $response;
$mockClassType = get_class($this->mockClass);
if ( ! $this->mockClass instanceof MockInterface) {
throw self::generateException('Class is not implementing MockInterface.');
}
$mockClassInstanceId = $this->mockClass->getShortifyPunitInstanceId();
foreach($methods as $currentMethod)
{
$fakeClass = new MockClassOnTheFly();
// extracting methods before the current method into an array
$chainedMethodsBefore = $this->extractChainedMethodsBefore(
array_reverse($this->methods),
$currentMethod
);
// adding to the ShortifyPunit chained method response
$this->addChainedMethodResponse(
$chainedMethodsBefore,
$currentMethod,
$action,
$lastValue,
$mockClassInstanceId
);
$currentMethodName = key($currentMethod);
// closure for MockOnTheFly chained methods
$fakeClass->$currentMethodName = function() use (
$mockClassInstanceId,
$mockClassType,
$chainedMethodsBefore,
$currentMethod
) {
return ShortifyPunit::createChainResponse(
$mockClassInstanceId,
$mockClassType,
$chainedMethodsBefore,
$currentMethod,
func_get_args()
);
};
$lastValue = $fakeClass;
// except from the last method all other chained method `returns` a calls so set the action for the next loop
$action = MockAction::RETURNS;
}
$whenCase = new WhenCase($mockClassType, $this->mockClass->getShortifyPunitInstanceId(), key($firstMethod));
$whenCase->setMethod(current($firstMethod), $action, $lastValue);
} | [
"private",
"function",
"createChainArrayOfReturnValues",
"(",
"$",
"action",
",",
"$",
"response",
")",
"{",
"// Pop first method",
"$",
"methods",
"=",
"$",
"this",
"->",
"methods",
";",
"$",
"firstMethod",
"=",
"array_pop",
"(",
"$",
"methods",
")",
";",
"$",
"lastValue",
"=",
"$",
"response",
";",
"$",
"mockClassType",
"=",
"get_class",
"(",
"$",
"this",
"->",
"mockClass",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"mockClass",
"instanceof",
"MockInterface",
")",
"{",
"throw",
"self",
"::",
"generateException",
"(",
"'Class is not implementing MockInterface.'",
")",
";",
"}",
"$",
"mockClassInstanceId",
"=",
"$",
"this",
"->",
"mockClass",
"->",
"getShortifyPunitInstanceId",
"(",
")",
";",
"foreach",
"(",
"$",
"methods",
"as",
"$",
"currentMethod",
")",
"{",
"$",
"fakeClass",
"=",
"new",
"MockClassOnTheFly",
"(",
")",
";",
"// extracting methods before the current method into an array",
"$",
"chainedMethodsBefore",
"=",
"$",
"this",
"->",
"extractChainedMethodsBefore",
"(",
"array_reverse",
"(",
"$",
"this",
"->",
"methods",
")",
",",
"$",
"currentMethod",
")",
";",
"// adding to the ShortifyPunit chained method response",
"$",
"this",
"->",
"addChainedMethodResponse",
"(",
"$",
"chainedMethodsBefore",
",",
"$",
"currentMethod",
",",
"$",
"action",
",",
"$",
"lastValue",
",",
"$",
"mockClassInstanceId",
")",
";",
"$",
"currentMethodName",
"=",
"key",
"(",
"$",
"currentMethod",
")",
";",
"// closure for MockOnTheFly chained methods",
"$",
"fakeClass",
"->",
"$",
"currentMethodName",
"=",
"function",
"(",
")",
"use",
"(",
"$",
"mockClassInstanceId",
",",
"$",
"mockClassType",
",",
"$",
"chainedMethodsBefore",
",",
"$",
"currentMethod",
")",
"{",
"return",
"ShortifyPunit",
"::",
"createChainResponse",
"(",
"$",
"mockClassInstanceId",
",",
"$",
"mockClassType",
",",
"$",
"chainedMethodsBefore",
",",
"$",
"currentMethod",
",",
"func_get_args",
"(",
")",
")",
";",
"}",
";",
"$",
"lastValue",
"=",
"$",
"fakeClass",
";",
"// except from the last method all other chained method `returns` a calls so set the action for the next loop",
"$",
"action",
"=",
"MockAction",
"::",
"RETURNS",
";",
"}",
"$",
"whenCase",
"=",
"new",
"WhenCase",
"(",
"$",
"mockClassType",
",",
"$",
"this",
"->",
"mockClass",
"->",
"getShortifyPunitInstanceId",
"(",
")",
",",
"key",
"(",
"$",
"firstMethod",
")",
")",
";",
"$",
"whenCase",
"->",
"setMethod",
"(",
"current",
"(",
"$",
"firstMethod",
")",
",",
"$",
"action",
",",
"$",
"lastValue",
")",
";",
"}"
]
| Creating a chain array of return values
@param $action
@param $response | [
"Creating",
"a",
"chain",
"array",
"of",
"return",
"values"
]
| train | https://github.com/danrevah/shortify-punit/blob/cedd08f31de8e7409a07d2630701ef4e924cc5f0/src/Stub/WhenChainCase.php#L59-L122 |
danrevah/shortify-punit | src/Stub/WhenChainCase.php | WhenChainCase.addChainedMethodResponse | private function addChainedMethodResponse($chainedMethodsBefore, $currentMethod, $action, $lastValue, $mockClassInstanceId)
{
$response = [];
$rResponse = &$response;
$currentMethodName = key($currentMethod);
foreach ($chainedMethodsBefore as $chainedMethod)
{
$chainedMethodName = key($chainedMethod);
$chainedMethodArgs = $chainedMethod[$chainedMethodName];
$serializedChainedMethodArgs = serialize($chainedMethodArgs);
$rResponse[$chainedMethodName][$serializedChainedMethodArgs] = [];
$rResponse = &$rResponse[$chainedMethodName][$serializedChainedMethodArgs];
}
$rResponse[$currentMethodName][serialize(current($currentMethod))] = ['response' => ['action' => $action, 'value' => $lastValue, 'counter' => 0]];
ShortifyPunit::addChainedResponse(array(get_class($this->mockClass) => [$mockClassInstanceId => $response]));
} | php | private function addChainedMethodResponse($chainedMethodsBefore, $currentMethod, $action, $lastValue, $mockClassInstanceId)
{
$response = [];
$rResponse = &$response;
$currentMethodName = key($currentMethod);
foreach ($chainedMethodsBefore as $chainedMethod)
{
$chainedMethodName = key($chainedMethod);
$chainedMethodArgs = $chainedMethod[$chainedMethodName];
$serializedChainedMethodArgs = serialize($chainedMethodArgs);
$rResponse[$chainedMethodName][$serializedChainedMethodArgs] = [];
$rResponse = &$rResponse[$chainedMethodName][$serializedChainedMethodArgs];
}
$rResponse[$currentMethodName][serialize(current($currentMethod))] = ['response' => ['action' => $action, 'value' => $lastValue, 'counter' => 0]];
ShortifyPunit::addChainedResponse(array(get_class($this->mockClass) => [$mockClassInstanceId => $response]));
} | [
"private",
"function",
"addChainedMethodResponse",
"(",
"$",
"chainedMethodsBefore",
",",
"$",
"currentMethod",
",",
"$",
"action",
",",
"$",
"lastValue",
",",
"$",
"mockClassInstanceId",
")",
"{",
"$",
"response",
"=",
"[",
"]",
";",
"$",
"rResponse",
"=",
"&",
"$",
"response",
";",
"$",
"currentMethodName",
"=",
"key",
"(",
"$",
"currentMethod",
")",
";",
"foreach",
"(",
"$",
"chainedMethodsBefore",
"as",
"$",
"chainedMethod",
")",
"{",
"$",
"chainedMethodName",
"=",
"key",
"(",
"$",
"chainedMethod",
")",
";",
"$",
"chainedMethodArgs",
"=",
"$",
"chainedMethod",
"[",
"$",
"chainedMethodName",
"]",
";",
"$",
"serializedChainedMethodArgs",
"=",
"serialize",
"(",
"$",
"chainedMethodArgs",
")",
";",
"$",
"rResponse",
"[",
"$",
"chainedMethodName",
"]",
"[",
"$",
"serializedChainedMethodArgs",
"]",
"=",
"[",
"]",
";",
"$",
"rResponse",
"=",
"&",
"$",
"rResponse",
"[",
"$",
"chainedMethodName",
"]",
"[",
"$",
"serializedChainedMethodArgs",
"]",
";",
"}",
"$",
"rResponse",
"[",
"$",
"currentMethodName",
"]",
"[",
"serialize",
"(",
"current",
"(",
"$",
"currentMethod",
")",
")",
"]",
"=",
"[",
"'response'",
"=>",
"[",
"'action'",
"=>",
"$",
"action",
",",
"'value'",
"=>",
"$",
"lastValue",
",",
"'counter'",
"=>",
"0",
"]",
"]",
";",
"ShortifyPunit",
"::",
"addChainedResponse",
"(",
"array",
"(",
"get_class",
"(",
"$",
"this",
"->",
"mockClass",
")",
"=>",
"[",
"$",
"mockClassInstanceId",
"=>",
"$",
"response",
"]",
")",
")",
";",
"}"
]
| Adding chained method responses into ShortifyPunit::ReturnValues
@param $chainedMethodsBefore
@param $currentMethod
@param $action
@param $lastValue
@param $mockClassInstanceId | [
"Adding",
"chained",
"method",
"responses",
"into",
"ShortifyPunit",
"::",
"ReturnValues"
]
| train | https://github.com/danrevah/shortify-punit/blob/cedd08f31de8e7409a07d2630701ef4e924cc5f0/src/Stub/WhenChainCase.php#L133-L153 |
danrevah/shortify-punit | src/Stub/WhenChainCase.php | WhenChainCase.extractChainedMethodsBefore | private function extractChainedMethodsBefore($methods, $currentMethod)
{
$chainedMethodsBefore = [];
$currentMethodName = key($currentMethod);
foreach ($methods as $method)
{
$methodName = key($method);
if ($methodName == $currentMethodName) {
break;
}
$chainedMethodsBefore[] = $method;
}
return $chainedMethodsBefore;
} | php | private function extractChainedMethodsBefore($methods, $currentMethod)
{
$chainedMethodsBefore = [];
$currentMethodName = key($currentMethod);
foreach ($methods as $method)
{
$methodName = key($method);
if ($methodName == $currentMethodName) {
break;
}
$chainedMethodsBefore[] = $method;
}
return $chainedMethodsBefore;
} | [
"private",
"function",
"extractChainedMethodsBefore",
"(",
"$",
"methods",
",",
"$",
"currentMethod",
")",
"{",
"$",
"chainedMethodsBefore",
"=",
"[",
"]",
";",
"$",
"currentMethodName",
"=",
"key",
"(",
"$",
"currentMethod",
")",
";",
"foreach",
"(",
"$",
"methods",
"as",
"$",
"method",
")",
"{",
"$",
"methodName",
"=",
"key",
"(",
"$",
"method",
")",
";",
"if",
"(",
"$",
"methodName",
"==",
"$",
"currentMethodName",
")",
"{",
"break",
";",
"}",
"$",
"chainedMethodsBefore",
"[",
"]",
"=",
"$",
"method",
";",
"}",
"return",
"$",
"chainedMethodsBefore",
";",
"}"
]
| Extracting chained methods before current method into an array
@param $methods
@param $currentMethod
@return array | [
"Extracting",
"chained",
"methods",
"before",
"current",
"method",
"into",
"an",
"array"
]
| train | https://github.com/danrevah/shortify-punit/blob/cedd08f31de8e7409a07d2630701ef4e924cc5f0/src/Stub/WhenChainCase.php#L162-L179 |
redaigbaria/oauth2 | src/Grant/ClientCredentialsGrant.php | ClientCredentialsGrant.completeFlow | public function completeFlow()
{
// Get the required params
$clientId = $this->server->getRequest()->request->get('client_id', $this->server->getRequest()->getUser());
if (is_null($clientId)) {
throw new Exception\InvalidRequestException('client_id');
}
$clientSecret = $this->server->getRequest()->request->get('client_secret',
$this->server->getRequest()->getPassword());
if (is_null($clientSecret)) {
throw new Exception\InvalidRequestException('client_secret');
}
// Validate client ID and client secret
$client = $this->server->getClientStorage()->get(
$clientId,
$clientSecret,
null,
$this->getIdentifier()
);
if (($client instanceof ClientEntity) === false) {
$this->server->getEventEmitter()->emit(new Event\ClientAuthenticationFailedEvent($this->server->getRequest()));
throw new Exception\InvalidClientException();
}
// Validate any scopes that are in the request
$scopeParam = $this->server->getRequest()->request->get('scope', '');
$scopes = $this->validateScopes($scopeParam, $client);
// Create a new session
$session = new SessionEntity($this->server);
$session->setOwner('client', $client->getId());
$session->associateClient($client);
// Generate an access token
$accessToken = new AccessTokenEntity($this->server);
$accessToken->setId(SecureKey::generate());
$accessToken->setExpireTime($this->getAccessTokenTTL() + time());
// Associate scopes with the session and access token
foreach ($scopes as $scope) {
$session->associateScope($scope);
}
foreach ($session->getScopes() as $scope) {
$accessToken->associateScope($scope);
}
// Save everything
$session->save();
$accessToken->setSession($session);
$accessToken->save();
$this->server->getTokenType()->setSession($session);
$this->server->getTokenType()->setParam('access_token', $accessToken->getId());
$this->server->getTokenType()->setParam('expires_in', $this->getAccessTokenTTL());
return $this->server->getTokenType()->generateResponse();
} | php | public function completeFlow()
{
// Get the required params
$clientId = $this->server->getRequest()->request->get('client_id', $this->server->getRequest()->getUser());
if (is_null($clientId)) {
throw new Exception\InvalidRequestException('client_id');
}
$clientSecret = $this->server->getRequest()->request->get('client_secret',
$this->server->getRequest()->getPassword());
if (is_null($clientSecret)) {
throw new Exception\InvalidRequestException('client_secret');
}
// Validate client ID and client secret
$client = $this->server->getClientStorage()->get(
$clientId,
$clientSecret,
null,
$this->getIdentifier()
);
if (($client instanceof ClientEntity) === false) {
$this->server->getEventEmitter()->emit(new Event\ClientAuthenticationFailedEvent($this->server->getRequest()));
throw new Exception\InvalidClientException();
}
// Validate any scopes that are in the request
$scopeParam = $this->server->getRequest()->request->get('scope', '');
$scopes = $this->validateScopes($scopeParam, $client);
// Create a new session
$session = new SessionEntity($this->server);
$session->setOwner('client', $client->getId());
$session->associateClient($client);
// Generate an access token
$accessToken = new AccessTokenEntity($this->server);
$accessToken->setId(SecureKey::generate());
$accessToken->setExpireTime($this->getAccessTokenTTL() + time());
// Associate scopes with the session and access token
foreach ($scopes as $scope) {
$session->associateScope($scope);
}
foreach ($session->getScopes() as $scope) {
$accessToken->associateScope($scope);
}
// Save everything
$session->save();
$accessToken->setSession($session);
$accessToken->save();
$this->server->getTokenType()->setSession($session);
$this->server->getTokenType()->setParam('access_token', $accessToken->getId());
$this->server->getTokenType()->setParam('expires_in', $this->getAccessTokenTTL());
return $this->server->getTokenType()->generateResponse();
} | [
"public",
"function",
"completeFlow",
"(",
")",
"{",
"// Get the required params",
"$",
"clientId",
"=",
"$",
"this",
"->",
"server",
"->",
"getRequest",
"(",
")",
"->",
"request",
"->",
"get",
"(",
"'client_id'",
",",
"$",
"this",
"->",
"server",
"->",
"getRequest",
"(",
")",
"->",
"getUser",
"(",
")",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"clientId",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"InvalidRequestException",
"(",
"'client_id'",
")",
";",
"}",
"$",
"clientSecret",
"=",
"$",
"this",
"->",
"server",
"->",
"getRequest",
"(",
")",
"->",
"request",
"->",
"get",
"(",
"'client_secret'",
",",
"$",
"this",
"->",
"server",
"->",
"getRequest",
"(",
")",
"->",
"getPassword",
"(",
")",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"clientSecret",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"InvalidRequestException",
"(",
"'client_secret'",
")",
";",
"}",
"// Validate client ID and client secret",
"$",
"client",
"=",
"$",
"this",
"->",
"server",
"->",
"getClientStorage",
"(",
")",
"->",
"get",
"(",
"$",
"clientId",
",",
"$",
"clientSecret",
",",
"null",
",",
"$",
"this",
"->",
"getIdentifier",
"(",
")",
")",
";",
"if",
"(",
"(",
"$",
"client",
"instanceof",
"ClientEntity",
")",
"===",
"false",
")",
"{",
"$",
"this",
"->",
"server",
"->",
"getEventEmitter",
"(",
")",
"->",
"emit",
"(",
"new",
"Event",
"\\",
"ClientAuthenticationFailedEvent",
"(",
"$",
"this",
"->",
"server",
"->",
"getRequest",
"(",
")",
")",
")",
";",
"throw",
"new",
"Exception",
"\\",
"InvalidClientException",
"(",
")",
";",
"}",
"// Validate any scopes that are in the request",
"$",
"scopeParam",
"=",
"$",
"this",
"->",
"server",
"->",
"getRequest",
"(",
")",
"->",
"request",
"->",
"get",
"(",
"'scope'",
",",
"''",
")",
";",
"$",
"scopes",
"=",
"$",
"this",
"->",
"validateScopes",
"(",
"$",
"scopeParam",
",",
"$",
"client",
")",
";",
"// Create a new session",
"$",
"session",
"=",
"new",
"SessionEntity",
"(",
"$",
"this",
"->",
"server",
")",
";",
"$",
"session",
"->",
"setOwner",
"(",
"'client'",
",",
"$",
"client",
"->",
"getId",
"(",
")",
")",
";",
"$",
"session",
"->",
"associateClient",
"(",
"$",
"client",
")",
";",
"// Generate an access token",
"$",
"accessToken",
"=",
"new",
"AccessTokenEntity",
"(",
"$",
"this",
"->",
"server",
")",
";",
"$",
"accessToken",
"->",
"setId",
"(",
"SecureKey",
"::",
"generate",
"(",
")",
")",
";",
"$",
"accessToken",
"->",
"setExpireTime",
"(",
"$",
"this",
"->",
"getAccessTokenTTL",
"(",
")",
"+",
"time",
"(",
")",
")",
";",
"// Associate scopes with the session and access token",
"foreach",
"(",
"$",
"scopes",
"as",
"$",
"scope",
")",
"{",
"$",
"session",
"->",
"associateScope",
"(",
"$",
"scope",
")",
";",
"}",
"foreach",
"(",
"$",
"session",
"->",
"getScopes",
"(",
")",
"as",
"$",
"scope",
")",
"{",
"$",
"accessToken",
"->",
"associateScope",
"(",
"$",
"scope",
")",
";",
"}",
"// Save everything",
"$",
"session",
"->",
"save",
"(",
")",
";",
"$",
"accessToken",
"->",
"setSession",
"(",
"$",
"session",
")",
";",
"$",
"accessToken",
"->",
"save",
"(",
")",
";",
"$",
"this",
"->",
"server",
"->",
"getTokenType",
"(",
")",
"->",
"setSession",
"(",
"$",
"session",
")",
";",
"$",
"this",
"->",
"server",
"->",
"getTokenType",
"(",
")",
"->",
"setParam",
"(",
"'access_token'",
",",
"$",
"accessToken",
"->",
"getId",
"(",
")",
")",
";",
"$",
"this",
"->",
"server",
"->",
"getTokenType",
"(",
")",
"->",
"setParam",
"(",
"'expires_in'",
",",
"$",
"this",
"->",
"getAccessTokenTTL",
"(",
")",
")",
";",
"return",
"$",
"this",
"->",
"server",
"->",
"getTokenType",
"(",
")",
"->",
"generateResponse",
"(",
")",
";",
"}"
]
| Complete the client credentials grant
@return array
@throws | [
"Complete",
"the",
"client",
"credentials",
"grant"
]
| train | https://github.com/redaigbaria/oauth2/blob/54cca4aaaff6a095cbf1c8010f2fe2cc7de4e45a/src/Grant/ClientCredentialsGrant.php#L61-L121 |
teneleven/GeolocatorBundle | Form/DataTransformer/StringToGeocodedTransformer.php | StringToGeocodedTransformer.reverseTransform | public function reverseTransform($value)
{
if (!$value) {
return null;
}
try {
$result = $this->geocoder->geocode($value);
} catch (NoResult $e) {
throw new TransformationFailedException(sprintf('%s could not be geolocated', $value));
}
if (!$firstResult = $result->first()) {
return null;
}
return $firstResult->getCoordinates();
} | php | public function reverseTransform($value)
{
if (!$value) {
return null;
}
try {
$result = $this->geocoder->geocode($value);
} catch (NoResult $e) {
throw new TransformationFailedException(sprintf('%s could not be geolocated', $value));
}
if (!$firstResult = $result->first()) {
return null;
}
return $firstResult->getCoordinates();
} | [
"public",
"function",
"reverseTransform",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"$",
"value",
")",
"{",
"return",
"null",
";",
"}",
"try",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"geocoder",
"->",
"geocode",
"(",
"$",
"value",
")",
";",
"}",
"catch",
"(",
"NoResult",
"$",
"e",
")",
"{",
"throw",
"new",
"TransformationFailedException",
"(",
"sprintf",
"(",
"'%s could not be geolocated'",
",",
"$",
"value",
")",
")",
";",
"}",
"if",
"(",
"!",
"$",
"firstResult",
"=",
"$",
"result",
"->",
"first",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"firstResult",
"->",
"getCoordinates",
"(",
")",
";",
"}"
]
| {@inheritdoc} | [
"{"
]
| train | https://github.com/teneleven/GeolocatorBundle/blob/4ead8e783a91577f2a67aa302b79641d4b9e99ad/Form/DataTransformer/StringToGeocodedTransformer.php#L52-L69 |
ClanCats/Core | src/classes/CCCrypter.php | CCCrypter.encode | public static function encode( $data, $salt = null ) {
if ( is_null( $salt ) ) {
$salt = static::$default_salt;
}
return base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($salt), $data, MCRYPT_MODE_CBC, md5(md5($salt))));
} | php | public static function encode( $data, $salt = null ) {
if ( is_null( $salt ) ) {
$salt = static::$default_salt;
}
return base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($salt), $data, MCRYPT_MODE_CBC, md5(md5($salt))));
} | [
"public",
"static",
"function",
"encode",
"(",
"$",
"data",
",",
"$",
"salt",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"salt",
")",
")",
"{",
"$",
"salt",
"=",
"static",
"::",
"$",
"default_salt",
";",
"}",
"return",
"base64_encode",
"(",
"mcrypt_encrypt",
"(",
"MCRYPT_RIJNDAEL_256",
",",
"md5",
"(",
"$",
"salt",
")",
",",
"$",
"data",
",",
"MCRYPT_MODE_CBC",
",",
"md5",
"(",
"md5",
"(",
"$",
"salt",
")",
")",
")",
")",
";",
"}"
]
| Encode data
@param string $data
@param string $salt
@return string | [
"Encode",
"data"
]
| train | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCCrypter.php#L35-L42 |
ClanCats/Core | src/classes/CCCrypter.php | CCCrypter.decode | public static function decode( $data, $salt = null ) {
if ( is_null( $salt ) ) {
$salt = static::$default_salt;
}
return rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($salt), base64_decode($data), MCRYPT_MODE_CBC, md5(md5($salt))), "\0");
} | php | public static function decode( $data, $salt = null ) {
if ( is_null( $salt ) ) {
$salt = static::$default_salt;
}
return rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($salt), base64_decode($data), MCRYPT_MODE_CBC, md5(md5($salt))), "\0");
} | [
"public",
"static",
"function",
"decode",
"(",
"$",
"data",
",",
"$",
"salt",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"salt",
")",
")",
"{",
"$",
"salt",
"=",
"static",
"::",
"$",
"default_salt",
";",
"}",
"return",
"rtrim",
"(",
"mcrypt_decrypt",
"(",
"MCRYPT_RIJNDAEL_256",
",",
"md5",
"(",
"$",
"salt",
")",
",",
"base64_decode",
"(",
"$",
"data",
")",
",",
"MCRYPT_MODE_CBC",
",",
"md5",
"(",
"md5",
"(",
"$",
"salt",
")",
")",
")",
",",
"\"\\0\"",
")",
";",
"}"
]
| Decde data
@param string $data
@param string $salt | [
"Decde",
"data"
]
| train | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCCrypter.php#L50-L57 |
yuncms/framework | src/rest/controllers/UploaderController.php | UploaderController.actionImage | public function actionImage()
{
$model = new UploaderImageForm();
$model->load(Yii::$app->getRequest()->getBodyParams(), '');
if ($model->save() != false) {
Yii::$app->getResponse()->setStatusCode(201);
return $model;
} elseif (!$model->hasErrors()) {
throw new ServerErrorHttpException('Failed to create the object for unknown reason.');
}
return $model;
} | php | public function actionImage()
{
$model = new UploaderImageForm();
$model->load(Yii::$app->getRequest()->getBodyParams(), '');
if ($model->save() != false) {
Yii::$app->getResponse()->setStatusCode(201);
return $model;
} elseif (!$model->hasErrors()) {
throw new ServerErrorHttpException('Failed to create the object for unknown reason.');
}
return $model;
} | [
"public",
"function",
"actionImage",
"(",
")",
"{",
"$",
"model",
"=",
"new",
"UploaderImageForm",
"(",
")",
";",
"$",
"model",
"->",
"load",
"(",
"Yii",
"::",
"$",
"app",
"->",
"getRequest",
"(",
")",
"->",
"getBodyParams",
"(",
")",
",",
"''",
")",
";",
"if",
"(",
"$",
"model",
"->",
"save",
"(",
")",
"!=",
"false",
")",
"{",
"Yii",
"::",
"$",
"app",
"->",
"getResponse",
"(",
")",
"->",
"setStatusCode",
"(",
"201",
")",
";",
"return",
"$",
"model",
";",
"}",
"elseif",
"(",
"!",
"$",
"model",
"->",
"hasErrors",
"(",
")",
")",
"{",
"throw",
"new",
"ServerErrorHttpException",
"(",
"'Failed to create the object for unknown reason.'",
")",
";",
"}",
"return",
"$",
"model",
";",
"}"
]
| 图片上传
@return UploaderImageForm
@throws ServerErrorHttpException
@throws \yii\base\InvalidConfigException
@throws \Exception | [
"图片上传"
]
| train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/rest/controllers/UploaderController.php#L32-L43 |
yuncms/framework | src/rest/controllers/UploaderController.php | UploaderController.actionAudio | public function actionAudio()
{
$model = new UploaderAudioForm();
$model->load(Yii::$app->getRequest()->getBodyParams(), '');
if ($model->save() != false) {
Yii::$app->getResponse()->setStatusCode(201);
return $model;
} elseif (!$model->hasErrors()) {
throw new ServerErrorHttpException('Failed to create the object for unknown reason.');
}
return $model;
} | php | public function actionAudio()
{
$model = new UploaderAudioForm();
$model->load(Yii::$app->getRequest()->getBodyParams(), '');
if ($model->save() != false) {
Yii::$app->getResponse()->setStatusCode(201);
return $model;
} elseif (!$model->hasErrors()) {
throw new ServerErrorHttpException('Failed to create the object for unknown reason.');
}
return $model;
} | [
"public",
"function",
"actionAudio",
"(",
")",
"{",
"$",
"model",
"=",
"new",
"UploaderAudioForm",
"(",
")",
";",
"$",
"model",
"->",
"load",
"(",
"Yii",
"::",
"$",
"app",
"->",
"getRequest",
"(",
")",
"->",
"getBodyParams",
"(",
")",
",",
"''",
")",
";",
"if",
"(",
"$",
"model",
"->",
"save",
"(",
")",
"!=",
"false",
")",
"{",
"Yii",
"::",
"$",
"app",
"->",
"getResponse",
"(",
")",
"->",
"setStatusCode",
"(",
"201",
")",
";",
"return",
"$",
"model",
";",
"}",
"elseif",
"(",
"!",
"$",
"model",
"->",
"hasErrors",
"(",
")",
")",
"{",
"throw",
"new",
"ServerErrorHttpException",
"(",
"'Failed to create the object for unknown reason.'",
")",
";",
"}",
"return",
"$",
"model",
";",
"}"
]
| 语音上传
@return UploaderAudioForm
@throws ServerErrorHttpException
@throws \yii\base\InvalidConfigException
@throws \Exception | [
"语音上传"
]
| train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/rest/controllers/UploaderController.php#L52-L63 |
yuncms/framework | src/rest/controllers/UploaderController.php | UploaderController.actionFile | public function actionFile()
{
$model = new UploaderFileForm();
$model->load(Yii::$app->getRequest()->getBodyParams(), '');
if ($model->save() != false) {
Yii::$app->getResponse()->setStatusCode(201);
return $model;
} elseif (!$model->hasErrors()) {
throw new ServerErrorHttpException('Failed to create the object for unknown reason.');
}
return $model;
} | php | public function actionFile()
{
$model = new UploaderFileForm();
$model->load(Yii::$app->getRequest()->getBodyParams(), '');
if ($model->save() != false) {
Yii::$app->getResponse()->setStatusCode(201);
return $model;
} elseif (!$model->hasErrors()) {
throw new ServerErrorHttpException('Failed to create the object for unknown reason.');
}
return $model;
} | [
"public",
"function",
"actionFile",
"(",
")",
"{",
"$",
"model",
"=",
"new",
"UploaderFileForm",
"(",
")",
";",
"$",
"model",
"->",
"load",
"(",
"Yii",
"::",
"$",
"app",
"->",
"getRequest",
"(",
")",
"->",
"getBodyParams",
"(",
")",
",",
"''",
")",
";",
"if",
"(",
"$",
"model",
"->",
"save",
"(",
")",
"!=",
"false",
")",
"{",
"Yii",
"::",
"$",
"app",
"->",
"getResponse",
"(",
")",
"->",
"setStatusCode",
"(",
"201",
")",
";",
"return",
"$",
"model",
";",
"}",
"elseif",
"(",
"!",
"$",
"model",
"->",
"hasErrors",
"(",
")",
")",
"{",
"throw",
"new",
"ServerErrorHttpException",
"(",
"'Failed to create the object for unknown reason.'",
")",
";",
"}",
"return",
"$",
"model",
";",
"}"
]
| 文件上传
@return UploaderFileForm
@throws ServerErrorHttpException
@throws \yii\base\InvalidConfigException
@throws \Exception | [
"文件上传"
]
| train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/rest/controllers/UploaderController.php#L72-L83 |
joomlatools/joomlatools-platform-legacy | code/base/tree.php | JTree.addChild | public function addChild(&$node, $setCurrent = false)
{
JLog::add('JTree::addChild() is deprecated.', JLog::WARNING, 'deprecated');
$this->_current->addChild($node);
if ($setCurrent)
{
$this->_current = &$node;
}
} | php | public function addChild(&$node, $setCurrent = false)
{
JLog::add('JTree::addChild() is deprecated.', JLog::WARNING, 'deprecated');
$this->_current->addChild($node);
if ($setCurrent)
{
$this->_current = &$node;
}
} | [
"public",
"function",
"addChild",
"(",
"&",
"$",
"node",
",",
"$",
"setCurrent",
"=",
"false",
")",
"{",
"JLog",
"::",
"add",
"(",
"'JTree::addChild() is deprecated.'",
",",
"JLog",
"::",
"WARNING",
",",
"'deprecated'",
")",
";",
"$",
"this",
"->",
"_current",
"->",
"addChild",
"(",
"$",
"node",
")",
";",
"if",
"(",
"$",
"setCurrent",
")",
"{",
"$",
"this",
"->",
"_current",
"=",
"&",
"$",
"node",
";",
"}",
"}"
]
| Method to add a child
@param array &$node The node to process
@param boolean $setCurrent True to set as current working node
@return mixed
@since 11.1 | [
"Method",
"to",
"add",
"a",
"child"
]
| train | https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/base/tree.php#L60-L70 |
joomlatools/joomlatools-platform-legacy | code/base/tree.php | JTree.getParent | public function getParent()
{
JLog::add('JTree::getParent() is deprecated.', JLog::WARNING, 'deprecated');
$this->_current = &$this->_current->getParent();
} | php | public function getParent()
{
JLog::add('JTree::getParent() is deprecated.', JLog::WARNING, 'deprecated');
$this->_current = &$this->_current->getParent();
} | [
"public",
"function",
"getParent",
"(",
")",
"{",
"JLog",
"::",
"add",
"(",
"'JTree::getParent() is deprecated.'",
",",
"JLog",
"::",
"WARNING",
",",
"'deprecated'",
")",
";",
"$",
"this",
"->",
"_current",
"=",
"&",
"$",
"this",
"->",
"_current",
"->",
"getParent",
"(",
")",
";",
"}"
]
| Method to get the parent
@return void
@since 11.1 | [
"Method",
"to",
"get",
"the",
"parent"
]
| train | https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/base/tree.php#L79-L84 |
CakeCMS/Core | src/Helper/Manager.php | Manager.addNamespace | public function addNamespace($name)
{
if (!Arr::in($name, self::$_namespace)) {
self::$_namespace[] = $name;
return true;
}
return false;
} | php | public function addNamespace($name)
{
if (!Arr::in($name, self::$_namespace)) {
self::$_namespace[] = $name;
return true;
}
return false;
} | [
"public",
"function",
"addNamespace",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"Arr",
"::",
"in",
"(",
"$",
"name",
",",
"self",
"::",
"$",
"_namespace",
")",
")",
"{",
"self",
"::",
"$",
"_namespace",
"[",
"]",
"=",
"$",
"name",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
]
| Add new helper group namespace.
@param string $name
@return bool | [
"Add",
"new",
"helper",
"group",
"namespace",
"."
]
| train | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Helper/Manager.php#L71-L79 |
CakeCMS/Core | src/Helper/Manager.php | Manager.offsetGet | public function offsetGet($id)
{
$id = Str::low($id);
if (!Arr::key($id, self::$_loaded)) {
$className = $this->_getClassName($id);
$this->_register($id, $className);
}
return parent::offsetGet($id);
} | php | public function offsetGet($id)
{
$id = Str::low($id);
if (!Arr::key($id, self::$_loaded)) {
$className = $this->_getClassName($id);
$this->_register($id, $className);
}
return parent::offsetGet($id);
} | [
"public",
"function",
"offsetGet",
"(",
"$",
"id",
")",
"{",
"$",
"id",
"=",
"Str",
"::",
"low",
"(",
"$",
"id",
")",
";",
"if",
"(",
"!",
"Arr",
"::",
"key",
"(",
"$",
"id",
",",
"self",
"::",
"$",
"_loaded",
")",
")",
"{",
"$",
"className",
"=",
"$",
"this",
"->",
"_getClassName",
"(",
"$",
"id",
")",
";",
"$",
"this",
"->",
"_register",
"(",
"$",
"id",
",",
"$",
"className",
")",
";",
"}",
"return",
"parent",
"::",
"offsetGet",
"(",
"$",
"id",
")",
";",
"}"
]
| Gets a parameter or an object.
@param string $id
@return mixed | [
"Gets",
"a",
"parameter",
"or",
"an",
"object",
"."
]
| train | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Helper/Manager.php#L87-L96 |
CakeCMS/Core | src/Helper/Manager.php | Manager._register | protected function _register($id, $className)
{
$id = (string) $id;
if (class_exists($className)) {
self::$_loaded[$id] = $className;
$this[$id] = function () use ($className) {
return new $className();
};
} else {
throw new Exception("Helper \"{{$className}}\" not found!");
}
} | php | protected function _register($id, $className)
{
$id = (string) $id;
if (class_exists($className)) {
self::$_loaded[$id] = $className;
$this[$id] = function () use ($className) {
return new $className();
};
} else {
throw new Exception("Helper \"{{$className}}\" not found!");
}
} | [
"protected",
"function",
"_register",
"(",
"$",
"id",
",",
"$",
"className",
")",
"{",
"$",
"id",
"=",
"(",
"string",
")",
"$",
"id",
";",
"if",
"(",
"class_exists",
"(",
"$",
"className",
")",
")",
"{",
"self",
"::",
"$",
"_loaded",
"[",
"$",
"id",
"]",
"=",
"$",
"className",
";",
"$",
"this",
"[",
"$",
"id",
"]",
"=",
"function",
"(",
")",
"use",
"(",
"$",
"className",
")",
"{",
"return",
"new",
"$",
"className",
"(",
")",
";",
"}",
";",
"}",
"else",
"{",
"throw",
"new",
"Exception",
"(",
"\"Helper \\\"{{$className}}\\\" not found!\"",
")",
";",
"}",
"}"
]
| Register helper class.
@param string $id
@param $className | [
"Register",
"helper",
"class",
"."
]
| train | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Helper/Manager.php#L104-L115 |
CakeCMS/Core | src/Helper/Manager.php | Manager._getClassName | protected function _getClassName($class)
{
$class = Str::low($class);
list ($plugin, $className) = pluginSplit($class);
$return = self::HELPER_SUFFIX . '\\' . Inflector::camelize($className) . self::HELPER_SUFFIX;
if ($plugin !== null) {
return Inflector::camelize($plugin) . '\\' . $return;
}
return Configure::read('App.namespace') . '\\' . $return;
} | php | protected function _getClassName($class)
{
$class = Str::low($class);
list ($plugin, $className) = pluginSplit($class);
$return = self::HELPER_SUFFIX . '\\' . Inflector::camelize($className) . self::HELPER_SUFFIX;
if ($plugin !== null) {
return Inflector::camelize($plugin) . '\\' . $return;
}
return Configure::read('App.namespace') . '\\' . $return;
} | [
"protected",
"function",
"_getClassName",
"(",
"$",
"class",
")",
"{",
"$",
"class",
"=",
"Str",
"::",
"low",
"(",
"$",
"class",
")",
";",
"list",
"(",
"$",
"plugin",
",",
"$",
"className",
")",
"=",
"pluginSplit",
"(",
"$",
"class",
")",
";",
"$",
"return",
"=",
"self",
"::",
"HELPER_SUFFIX",
".",
"'\\\\'",
".",
"Inflector",
"::",
"camelize",
"(",
"$",
"className",
")",
".",
"self",
"::",
"HELPER_SUFFIX",
";",
"if",
"(",
"$",
"plugin",
"!==",
"null",
")",
"{",
"return",
"Inflector",
"::",
"camelize",
"(",
"$",
"plugin",
")",
".",
"'\\\\'",
".",
"$",
"return",
";",
"}",
"return",
"Configure",
"::",
"read",
"(",
"'App.namespace'",
")",
".",
"'\\\\'",
".",
"$",
"return",
";",
"}"
]
| Get current helper class name.
@param string $class
@return string | [
"Get",
"current",
"helper",
"class",
"name",
"."
]
| train | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Helper/Manager.php#L123-L133 |
afrittella/back-project | src/app/Traits/Sluggable.php | Sluggable.createSlug | public function createSlug($value, $id = 0)
{
$slug = str_slug($value);
$relatedSlugs = $this->getRelatedSlugs($slug, $id);
if (!$relatedSlugs->contains('slug', $slug)) {
return $slug;
}
$completed = false;
$i = 1;
while ($completed == false) {
$newSlug = $slug .'-'.$i;
if (!$relatedSlugs->contains('slug', $newSlug)) {
return $newSlug;
}
$i++;
}
return $slug;
} | php | public function createSlug($value, $id = 0)
{
$slug = str_slug($value);
$relatedSlugs = $this->getRelatedSlugs($slug, $id);
if (!$relatedSlugs->contains('slug', $slug)) {
return $slug;
}
$completed = false;
$i = 1;
while ($completed == false) {
$newSlug = $slug .'-'.$i;
if (!$relatedSlugs->contains('slug', $newSlug)) {
return $newSlug;
}
$i++;
}
return $slug;
} | [
"public",
"function",
"createSlug",
"(",
"$",
"value",
",",
"$",
"id",
"=",
"0",
")",
"{",
"$",
"slug",
"=",
"str_slug",
"(",
"$",
"value",
")",
";",
"$",
"relatedSlugs",
"=",
"$",
"this",
"->",
"getRelatedSlugs",
"(",
"$",
"slug",
",",
"$",
"id",
")",
";",
"if",
"(",
"!",
"$",
"relatedSlugs",
"->",
"contains",
"(",
"'slug'",
",",
"$",
"slug",
")",
")",
"{",
"return",
"$",
"slug",
";",
"}",
"$",
"completed",
"=",
"false",
";",
"$",
"i",
"=",
"1",
";",
"while",
"(",
"$",
"completed",
"==",
"false",
")",
"{",
"$",
"newSlug",
"=",
"$",
"slug",
".",
"'-'",
".",
"$",
"i",
";",
"if",
"(",
"!",
"$",
"relatedSlugs",
"->",
"contains",
"(",
"'slug'",
",",
"$",
"newSlug",
")",
")",
"{",
"return",
"$",
"newSlug",
";",
"}",
"$",
"i",
"++",
";",
"}",
"return",
"$",
"slug",
";",
"}"
]
| Create a unique slug
@param $value
@param $id
@return string | [
"Create",
"a",
"unique",
"slug"
]
| train | https://github.com/afrittella/back-project/blob/e1aa2e3ee03d453033f75a4b16f073c60b5f32d1/src/app/Traits/Sluggable.php#L12-L34 |
afrittella/back-project | src/app/Traits/Sluggable.php | Sluggable.getRelatedSlugs | protected function getRelatedSlugs($slug, $id = 0)
{
return $this->select('slug')->where('slug', 'like', $slug.'%')->where('id', '<>', $id)->get();
} | php | protected function getRelatedSlugs($slug, $id = 0)
{
return $this->select('slug')->where('slug', 'like', $slug.'%')->where('id', '<>', $id)->get();
} | [
"protected",
"function",
"getRelatedSlugs",
"(",
"$",
"slug",
",",
"$",
"id",
"=",
"0",
")",
"{",
"return",
"$",
"this",
"->",
"select",
"(",
"'slug'",
")",
"->",
"where",
"(",
"'slug'",
",",
"'like'",
",",
"$",
"slug",
".",
"'%'",
")",
"->",
"where",
"(",
"'id'",
",",
"'<>'",
",",
"$",
"id",
")",
"->",
"get",
"(",
")",
";",
"}"
]
| Get similar slugs
@param $slug
@param $id
@return mixed | [
"Get",
"similar",
"slugs"
]
| train | https://github.com/afrittella/back-project/blob/e1aa2e3ee03d453033f75a4b16f073c60b5f32d1/src/app/Traits/Sluggable.php#L42-L45 |
webforge-labs/psc-cms | lib/Psc/Doctrine/GenericCollectionSynchronizer.php | GenericCollectionSynchronizer.computeCUDSets | public function computeCUDSets(ArrayCollection $fromCollection, ArrayCollection $toCollection, $compareFunction = NULL, $uniqueHashFunction = NULL) {
if (!isset($compareFunction)) {
$compareFunction = ArrayCollection::COMPARE_OBJECTS;
}
return $fromCollection->computeCUDSets($toCollection, $compareFunction, $uniqueHashFunction);
} | php | public function computeCUDSets(ArrayCollection $fromCollection, ArrayCollection $toCollection, $compareFunction = NULL, $uniqueHashFunction = NULL) {
if (!isset($compareFunction)) {
$compareFunction = ArrayCollection::COMPARE_OBJECTS;
}
return $fromCollection->computeCUDSets($toCollection, $compareFunction, $uniqueHashFunction);
} | [
"public",
"function",
"computeCUDSets",
"(",
"ArrayCollection",
"$",
"fromCollection",
",",
"ArrayCollection",
"$",
"toCollection",
",",
"$",
"compareFunction",
"=",
"NULL",
",",
"$",
"uniqueHashFunction",
"=",
"NULL",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"compareFunction",
")",
")",
"{",
"$",
"compareFunction",
"=",
"ArrayCollection",
"::",
"COMPARE_OBJECTS",
";",
"}",
"return",
"$",
"fromCollection",
"->",
"computeCUDSets",
"(",
"$",
"toCollection",
",",
"$",
"compareFunction",
",",
"$",
"uniqueHashFunction",
")",
";",
"}"
]
| Berechnet die Updates / Inserts / Deletes zwischen den beiden Collections
wird keine $compareFunction angegeben, werden die Elemente der Collection als Objekte behandelt
wird keine $uniqueHashFunction angegeben werden diese mit spl_object_hash() gehashed
@return list($inserts, $updates, $deletes) | [
"Berechnet",
"die",
"Updates",
"/",
"Inserts",
"/",
"Deletes",
"zwischen",
"den",
"beiden",
"Collections"
]
| train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Doctrine/GenericCollectionSynchronizer.php#L90-L96 |
yuncms/framework | src/admin/controllers/UserController.php | UserController.actionUpdateProfile | public function actionUpdateProfile($id)
{
Url::remember('', 'actions-redirect');
$model = $this->findModel($id);
$profile = $model->profile;
if ($profile == null) {
$profile = Yii::createObject(UserProfile::class);
$profile->link('user', $model);
}
if (Yii::$app->request->isAjax && $profile->load(Yii::$app->request->post())) {
Yii::$app->response->format = Response::FORMAT_JSON;
return ActiveForm::validate($profile);
}
if ($profile->load(Yii::$app->request->post()) && $profile->save()) {
Yii::$app->getSession()->setFlash('success', Yii::t('yuncms', 'Profile details have been updated'));
return $this->refresh();
}
return $this->render('_profile', [
'model' => $model,
'profile' => $profile,
]);
} | php | public function actionUpdateProfile($id)
{
Url::remember('', 'actions-redirect');
$model = $this->findModel($id);
$profile = $model->profile;
if ($profile == null) {
$profile = Yii::createObject(UserProfile::class);
$profile->link('user', $model);
}
if (Yii::$app->request->isAjax && $profile->load(Yii::$app->request->post())) {
Yii::$app->response->format = Response::FORMAT_JSON;
return ActiveForm::validate($profile);
}
if ($profile->load(Yii::$app->request->post()) && $profile->save()) {
Yii::$app->getSession()->setFlash('success', Yii::t('yuncms', 'Profile details have been updated'));
return $this->refresh();
}
return $this->render('_profile', [
'model' => $model,
'profile' => $profile,
]);
} | [
"public",
"function",
"actionUpdateProfile",
"(",
"$",
"id",
")",
"{",
"Url",
"::",
"remember",
"(",
"''",
",",
"'actions-redirect'",
")",
";",
"$",
"model",
"=",
"$",
"this",
"->",
"findModel",
"(",
"$",
"id",
")",
";",
"$",
"profile",
"=",
"$",
"model",
"->",
"profile",
";",
"if",
"(",
"$",
"profile",
"==",
"null",
")",
"{",
"$",
"profile",
"=",
"Yii",
"::",
"createObject",
"(",
"UserProfile",
"::",
"class",
")",
";",
"$",
"profile",
"->",
"link",
"(",
"'user'",
",",
"$",
"model",
")",
";",
"}",
"if",
"(",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"isAjax",
"&&",
"$",
"profile",
"->",
"load",
"(",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"post",
"(",
")",
")",
")",
"{",
"Yii",
"::",
"$",
"app",
"->",
"response",
"->",
"format",
"=",
"Response",
"::",
"FORMAT_JSON",
";",
"return",
"ActiveForm",
"::",
"validate",
"(",
"$",
"profile",
")",
";",
"}",
"if",
"(",
"$",
"profile",
"->",
"load",
"(",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"post",
"(",
")",
")",
"&&",
"$",
"profile",
"->",
"save",
"(",
")",
")",
"{",
"Yii",
"::",
"$",
"app",
"->",
"getSession",
"(",
")",
"->",
"setFlash",
"(",
"'success'",
",",
"Yii",
"::",
"t",
"(",
"'yuncms'",
",",
"'Profile details have been updated'",
")",
")",
";",
"return",
"$",
"this",
"->",
"refresh",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"render",
"(",
"'_profile'",
",",
"[",
"'model'",
"=>",
"$",
"model",
",",
"'profile'",
"=>",
"$",
"profile",
",",
"]",
")",
";",
"}"
]
| Updates an existing profile.
@param int $id
@return mixed
@throws NotFoundHttpException
@throws \yii\base\InvalidConfigException | [
"Updates",
"an",
"existing",
"profile",
"."
]
| train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/admin/controllers/UserController.php#L135-L157 |
slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseUserRole.php | BaseUserRole.setUserId | public function setUserId($v)
{
if ($v !== null && is_numeric($v)) {
$v = (int) $v;
}
if ($this->user_id !== $v) {
$this->user_id = $v;
$this->modifiedColumns[] = UserRolePeer::USER_ID;
}
if ($this->aUser !== null && $this->aUser->getId() !== $v) {
$this->aUser = null;
}
return $this;
} | php | public function setUserId($v)
{
if ($v !== null && is_numeric($v)) {
$v = (int) $v;
}
if ($this->user_id !== $v) {
$this->user_id = $v;
$this->modifiedColumns[] = UserRolePeer::USER_ID;
}
if ($this->aUser !== null && $this->aUser->getId() !== $v) {
$this->aUser = null;
}
return $this;
} | [
"public",
"function",
"setUserId",
"(",
"$",
"v",
")",
"{",
"if",
"(",
"$",
"v",
"!==",
"null",
"&&",
"is_numeric",
"(",
"$",
"v",
")",
")",
"{",
"$",
"v",
"=",
"(",
"int",
")",
"$",
"v",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"user_id",
"!==",
"$",
"v",
")",
"{",
"$",
"this",
"->",
"user_id",
"=",
"$",
"v",
";",
"$",
"this",
"->",
"modifiedColumns",
"[",
"]",
"=",
"UserRolePeer",
"::",
"USER_ID",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"aUser",
"!==",
"null",
"&&",
"$",
"this",
"->",
"aUser",
"->",
"getId",
"(",
")",
"!==",
"$",
"v",
")",
"{",
"$",
"this",
"->",
"aUser",
"=",
"null",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Set the value of [user_id] column.
@param int $v new value
@return UserRole The current object (for fluent API support) | [
"Set",
"the",
"value",
"of",
"[",
"user_id",
"]",
"column",
"."
]
| train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUserRole.php#L113-L130 |
slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseUserRole.php | BaseUserRole.setRoleId | public function setRoleId($v)
{
if ($v !== null && is_numeric($v)) {
$v = (int) $v;
}
if ($this->role_id !== $v) {
$this->role_id = $v;
$this->modifiedColumns[] = UserRolePeer::ROLE_ID;
}
if ($this->aRole !== null && $this->aRole->getId() !== $v) {
$this->aRole = null;
}
return $this;
} | php | public function setRoleId($v)
{
if ($v !== null && is_numeric($v)) {
$v = (int) $v;
}
if ($this->role_id !== $v) {
$this->role_id = $v;
$this->modifiedColumns[] = UserRolePeer::ROLE_ID;
}
if ($this->aRole !== null && $this->aRole->getId() !== $v) {
$this->aRole = null;
}
return $this;
} | [
"public",
"function",
"setRoleId",
"(",
"$",
"v",
")",
"{",
"if",
"(",
"$",
"v",
"!==",
"null",
"&&",
"is_numeric",
"(",
"$",
"v",
")",
")",
"{",
"$",
"v",
"=",
"(",
"int",
")",
"$",
"v",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"role_id",
"!==",
"$",
"v",
")",
"{",
"$",
"this",
"->",
"role_id",
"=",
"$",
"v",
";",
"$",
"this",
"->",
"modifiedColumns",
"[",
"]",
"=",
"UserRolePeer",
"::",
"ROLE_ID",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"aRole",
"!==",
"null",
"&&",
"$",
"this",
"->",
"aRole",
"->",
"getId",
"(",
")",
"!==",
"$",
"v",
")",
"{",
"$",
"this",
"->",
"aRole",
"=",
"null",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Set the value of [role_id] column.
@param int $v new value
@return UserRole The current object (for fluent API support) | [
"Set",
"the",
"value",
"of",
"[",
"role_id",
"]",
"column",
"."
]
| train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUserRole.php#L138-L155 |
slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseUserRole.php | BaseUserRole.hydrate | public function hydrate($row, $startcol = 0, $rehydrate = false)
{
try {
$this->user_id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
$this->role_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
$this->resetModified();
$this->setNew(false);
if ($rehydrate) {
$this->ensureConsistency();
}
$this->postHydrate($row, $startcol, $rehydrate);
return $startcol + 2; // 2 = UserRolePeer::NUM_HYDRATE_COLUMNS.
} catch (Exception $e) {
throw new PropelException("Error populating UserRole object", $e);
}
} | php | public function hydrate($row, $startcol = 0, $rehydrate = false)
{
try {
$this->user_id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
$this->role_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
$this->resetModified();
$this->setNew(false);
if ($rehydrate) {
$this->ensureConsistency();
}
$this->postHydrate($row, $startcol, $rehydrate);
return $startcol + 2; // 2 = UserRolePeer::NUM_HYDRATE_COLUMNS.
} catch (Exception $e) {
throw new PropelException("Error populating UserRole object", $e);
}
} | [
"public",
"function",
"hydrate",
"(",
"$",
"row",
",",
"$",
"startcol",
"=",
"0",
",",
"$",
"rehydrate",
"=",
"false",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"user_id",
"=",
"(",
"$",
"row",
"[",
"$",
"startcol",
"+",
"0",
"]",
"!==",
"null",
")",
"?",
"(",
"int",
")",
"$",
"row",
"[",
"$",
"startcol",
"+",
"0",
"]",
":",
"null",
";",
"$",
"this",
"->",
"role_id",
"=",
"(",
"$",
"row",
"[",
"$",
"startcol",
"+",
"1",
"]",
"!==",
"null",
")",
"?",
"(",
"int",
")",
"$",
"row",
"[",
"$",
"startcol",
"+",
"1",
"]",
":",
"null",
";",
"$",
"this",
"->",
"resetModified",
"(",
")",
";",
"$",
"this",
"->",
"setNew",
"(",
"false",
")",
";",
"if",
"(",
"$",
"rehydrate",
")",
"{",
"$",
"this",
"->",
"ensureConsistency",
"(",
")",
";",
"}",
"$",
"this",
"->",
"postHydrate",
"(",
"$",
"row",
",",
"$",
"startcol",
",",
"$",
"rehydrate",
")",
";",
"return",
"$",
"startcol",
"+",
"2",
";",
"// 2 = UserRolePeer::NUM_HYDRATE_COLUMNS.",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"PropelException",
"(",
"\"Error populating UserRole object\"",
",",
"$",
"e",
")",
";",
"}",
"}"
]
| Hydrates (populates) the object variables with values from the database resultset.
An offset (0-based "start column") is specified so that objects can be hydrated
with a subset of the columns in the resultset rows. This is needed, for example,
for results of JOIN queries where the resultset row includes columns from two or
more tables.
@param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
@param int $startcol 0-based offset column which indicates which resultset column to start with.
@param boolean $rehydrate Whether this object is being re-hydrated from the database.
@return int next starting column
@throws PropelException - Any caught Exception will be rewrapped as a PropelException. | [
"Hydrates",
"(",
"populates",
")",
"the",
"object",
"variables",
"with",
"values",
"from",
"the",
"database",
"resultset",
"."
]
| train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUserRole.php#L185-L205 |
slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseUserRole.php | BaseUserRole.doInsert | protected function doInsert(PropelPDO $con)
{
$modifiedColumns = array();
$index = 0;
// check the columns in natural order for more readable SQL queries
if ($this->isColumnModified(UserRolePeer::USER_ID)) {
$modifiedColumns[':p' . $index++] = '`user_id`';
}
if ($this->isColumnModified(UserRolePeer::ROLE_ID)) {
$modifiedColumns[':p' . $index++] = '`role_id`';
}
$sql = sprintf(
'INSERT INTO `user_role` (%s) VALUES (%s)',
implode(', ', $modifiedColumns),
implode(', ', array_keys($modifiedColumns))
);
try {
$stmt = $con->prepare($sql);
foreach ($modifiedColumns as $identifier => $columnName) {
switch ($columnName) {
case '`user_id`':
$stmt->bindValue($identifier, $this->user_id, PDO::PARAM_INT);
break;
case '`role_id`':
$stmt->bindValue($identifier, $this->role_id, PDO::PARAM_INT);
break;
}
}
$stmt->execute();
} catch (Exception $e) {
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
}
$this->setNew(false);
} | php | protected function doInsert(PropelPDO $con)
{
$modifiedColumns = array();
$index = 0;
// check the columns in natural order for more readable SQL queries
if ($this->isColumnModified(UserRolePeer::USER_ID)) {
$modifiedColumns[':p' . $index++] = '`user_id`';
}
if ($this->isColumnModified(UserRolePeer::ROLE_ID)) {
$modifiedColumns[':p' . $index++] = '`role_id`';
}
$sql = sprintf(
'INSERT INTO `user_role` (%s) VALUES (%s)',
implode(', ', $modifiedColumns),
implode(', ', array_keys($modifiedColumns))
);
try {
$stmt = $con->prepare($sql);
foreach ($modifiedColumns as $identifier => $columnName) {
switch ($columnName) {
case '`user_id`':
$stmt->bindValue($identifier, $this->user_id, PDO::PARAM_INT);
break;
case '`role_id`':
$stmt->bindValue($identifier, $this->role_id, PDO::PARAM_INT);
break;
}
}
$stmt->execute();
} catch (Exception $e) {
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
}
$this->setNew(false);
} | [
"protected",
"function",
"doInsert",
"(",
"PropelPDO",
"$",
"con",
")",
"{",
"$",
"modifiedColumns",
"=",
"array",
"(",
")",
";",
"$",
"index",
"=",
"0",
";",
"// check the columns in natural order for more readable SQL queries",
"if",
"(",
"$",
"this",
"->",
"isColumnModified",
"(",
"UserRolePeer",
"::",
"USER_ID",
")",
")",
"{",
"$",
"modifiedColumns",
"[",
"':p'",
".",
"$",
"index",
"++",
"]",
"=",
"'`user_id`'",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"isColumnModified",
"(",
"UserRolePeer",
"::",
"ROLE_ID",
")",
")",
"{",
"$",
"modifiedColumns",
"[",
"':p'",
".",
"$",
"index",
"++",
"]",
"=",
"'`role_id`'",
";",
"}",
"$",
"sql",
"=",
"sprintf",
"(",
"'INSERT INTO `user_role` (%s) VALUES (%s)'",
",",
"implode",
"(",
"', '",
",",
"$",
"modifiedColumns",
")",
",",
"implode",
"(",
"', '",
",",
"array_keys",
"(",
"$",
"modifiedColumns",
")",
")",
")",
";",
"try",
"{",
"$",
"stmt",
"=",
"$",
"con",
"->",
"prepare",
"(",
"$",
"sql",
")",
";",
"foreach",
"(",
"$",
"modifiedColumns",
"as",
"$",
"identifier",
"=>",
"$",
"columnName",
")",
"{",
"switch",
"(",
"$",
"columnName",
")",
"{",
"case",
"'`user_id`'",
":",
"$",
"stmt",
"->",
"bindValue",
"(",
"$",
"identifier",
",",
"$",
"this",
"->",
"user_id",
",",
"PDO",
"::",
"PARAM_INT",
")",
";",
"break",
";",
"case",
"'`role_id`'",
":",
"$",
"stmt",
"->",
"bindValue",
"(",
"$",
"identifier",
",",
"$",
"this",
"->",
"role_id",
",",
"PDO",
"::",
"PARAM_INT",
")",
";",
"break",
";",
"}",
"}",
"$",
"stmt",
"->",
"execute",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"Propel",
"::",
"log",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"Propel",
"::",
"LOG_ERR",
")",
";",
"throw",
"new",
"PropelException",
"(",
"sprintf",
"(",
"'Unable to execute INSERT statement [%s]'",
",",
"$",
"sql",
")",
",",
"$",
"e",
")",
";",
"}",
"$",
"this",
"->",
"setNew",
"(",
"false",
")",
";",
"}"
]
| Insert the row in the database.
@param PropelPDO $con
@throws PropelException
@see doSave() | [
"Insert",
"the",
"row",
"in",
"the",
"database",
"."
]
| train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUserRole.php#L428-L467 |
slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseUserRole.php | BaseUserRole.doValidate | protected function doValidate($columns = null)
{
if (!$this->alreadyInValidation) {
$this->alreadyInValidation = true;
$retval = null;
$failureMap = array();
// We call the validate method on the following object(s) if they
// were passed to this object by their corresponding set
// method. This object relates to these object(s) by a
// foreign key reference.
if ($this->aUser !== null) {
if (!$this->aUser->validate($columns)) {
$failureMap = array_merge($failureMap, $this->aUser->getValidationFailures());
}
}
if ($this->aRole !== null) {
if (!$this->aRole->validate($columns)) {
$failureMap = array_merge($failureMap, $this->aRole->getValidationFailures());
}
}
if (($retval = UserRolePeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
$this->alreadyInValidation = false;
}
return (!empty($failureMap) ? $failureMap : true);
} | php | protected function doValidate($columns = null)
{
if (!$this->alreadyInValidation) {
$this->alreadyInValidation = true;
$retval = null;
$failureMap = array();
// We call the validate method on the following object(s) if they
// were passed to this object by their corresponding set
// method. This object relates to these object(s) by a
// foreign key reference.
if ($this->aUser !== null) {
if (!$this->aUser->validate($columns)) {
$failureMap = array_merge($failureMap, $this->aUser->getValidationFailures());
}
}
if ($this->aRole !== null) {
if (!$this->aRole->validate($columns)) {
$failureMap = array_merge($failureMap, $this->aRole->getValidationFailures());
}
}
if (($retval = UserRolePeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
$this->alreadyInValidation = false;
}
return (!empty($failureMap) ? $failureMap : true);
} | [
"protected",
"function",
"doValidate",
"(",
"$",
"columns",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"alreadyInValidation",
")",
"{",
"$",
"this",
"->",
"alreadyInValidation",
"=",
"true",
";",
"$",
"retval",
"=",
"null",
";",
"$",
"failureMap",
"=",
"array",
"(",
")",
";",
"// We call the validate method on the following object(s) if they",
"// were passed to this object by their corresponding set",
"// method. This object relates to these object(s) by a",
"// foreign key reference.",
"if",
"(",
"$",
"this",
"->",
"aUser",
"!==",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"aUser",
"->",
"validate",
"(",
"$",
"columns",
")",
")",
"{",
"$",
"failureMap",
"=",
"array_merge",
"(",
"$",
"failureMap",
",",
"$",
"this",
"->",
"aUser",
"->",
"getValidationFailures",
"(",
")",
")",
";",
"}",
"}",
"if",
"(",
"$",
"this",
"->",
"aRole",
"!==",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"aRole",
"->",
"validate",
"(",
"$",
"columns",
")",
")",
"{",
"$",
"failureMap",
"=",
"array_merge",
"(",
"$",
"failureMap",
",",
"$",
"this",
"->",
"aRole",
"->",
"getValidationFailures",
"(",
")",
")",
";",
"}",
"}",
"if",
"(",
"(",
"$",
"retval",
"=",
"UserRolePeer",
"::",
"doValidate",
"(",
"$",
"this",
",",
"$",
"columns",
")",
")",
"!==",
"true",
")",
"{",
"$",
"failureMap",
"=",
"array_merge",
"(",
"$",
"failureMap",
",",
"$",
"retval",
")",
";",
"}",
"$",
"this",
"->",
"alreadyInValidation",
"=",
"false",
";",
"}",
"return",
"(",
"!",
"empty",
"(",
"$",
"failureMap",
")",
"?",
"$",
"failureMap",
":",
"true",
")",
";",
"}"
]
| This function performs the validation work for complex object models.
In addition to checking the current object, all related objects will
also be validated. If all pass then <code>true</code> is returned; otherwise
an aggregated array of ValidationFailed objects will be returned.
@param array $columns Array of column names to validate.
@return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objects otherwise. | [
"This",
"function",
"performs",
"the",
"validation",
"work",
"for",
"complex",
"object",
"models",
"."
]
| train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUserRole.php#L536-L573 |
slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseUserRole.php | BaseUserRole.toArray | public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
{
if (isset($alreadyDumpedObjects['UserRole'][serialize($this->getPrimaryKey())])) {
return '*RECURSION*';
}
$alreadyDumpedObjects['UserRole'][serialize($this->getPrimaryKey())] = true;
$keys = UserRolePeer::getFieldNames($keyType);
$result = array(
$keys[0] => $this->getUserId(),
$keys[1] => $this->getRoleId(),
);
$virtualColumns = $this->virtualColumns;
foreach ($virtualColumns as $key => $virtualColumn) {
$result[$key] = $virtualColumn;
}
if ($includeForeignObjects) {
if (null !== $this->aUser) {
$result['User'] = $this->aUser->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
if (null !== $this->aRole) {
$result['Role'] = $this->aRole->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
}
return $result;
} | php | public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
{
if (isset($alreadyDumpedObjects['UserRole'][serialize($this->getPrimaryKey())])) {
return '*RECURSION*';
}
$alreadyDumpedObjects['UserRole'][serialize($this->getPrimaryKey())] = true;
$keys = UserRolePeer::getFieldNames($keyType);
$result = array(
$keys[0] => $this->getUserId(),
$keys[1] => $this->getRoleId(),
);
$virtualColumns = $this->virtualColumns;
foreach ($virtualColumns as $key => $virtualColumn) {
$result[$key] = $virtualColumn;
}
if ($includeForeignObjects) {
if (null !== $this->aUser) {
$result['User'] = $this->aUser->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
if (null !== $this->aRole) {
$result['Role'] = $this->aRole->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
}
return $result;
} | [
"public",
"function",
"toArray",
"(",
"$",
"keyType",
"=",
"BasePeer",
"::",
"TYPE_PHPNAME",
",",
"$",
"includeLazyLoadColumns",
"=",
"true",
",",
"$",
"alreadyDumpedObjects",
"=",
"array",
"(",
")",
",",
"$",
"includeForeignObjects",
"=",
"false",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"alreadyDumpedObjects",
"[",
"'UserRole'",
"]",
"[",
"serialize",
"(",
"$",
"this",
"->",
"getPrimaryKey",
"(",
")",
")",
"]",
")",
")",
"{",
"return",
"'*RECURSION*'",
";",
"}",
"$",
"alreadyDumpedObjects",
"[",
"'UserRole'",
"]",
"[",
"serialize",
"(",
"$",
"this",
"->",
"getPrimaryKey",
"(",
")",
")",
"]",
"=",
"true",
";",
"$",
"keys",
"=",
"UserRolePeer",
"::",
"getFieldNames",
"(",
"$",
"keyType",
")",
";",
"$",
"result",
"=",
"array",
"(",
"$",
"keys",
"[",
"0",
"]",
"=>",
"$",
"this",
"->",
"getUserId",
"(",
")",
",",
"$",
"keys",
"[",
"1",
"]",
"=>",
"$",
"this",
"->",
"getRoleId",
"(",
")",
",",
")",
";",
"$",
"virtualColumns",
"=",
"$",
"this",
"->",
"virtualColumns",
";",
"foreach",
"(",
"$",
"virtualColumns",
"as",
"$",
"key",
"=>",
"$",
"virtualColumn",
")",
"{",
"$",
"result",
"[",
"$",
"key",
"]",
"=",
"$",
"virtualColumn",
";",
"}",
"if",
"(",
"$",
"includeForeignObjects",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"aUser",
")",
"{",
"$",
"result",
"[",
"'User'",
"]",
"=",
"$",
"this",
"->",
"aUser",
"->",
"toArray",
"(",
"$",
"keyType",
",",
"$",
"includeLazyLoadColumns",
",",
"$",
"alreadyDumpedObjects",
",",
"true",
")",
";",
"}",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"aRole",
")",
"{",
"$",
"result",
"[",
"'Role'",
"]",
"=",
"$",
"this",
"->",
"aRole",
"->",
"toArray",
"(",
"$",
"keyType",
",",
"$",
"includeLazyLoadColumns",
",",
"$",
"alreadyDumpedObjects",
",",
"true",
")",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
]
| Exports the object as an array.
You can specify the key type of the array by passing one of the class
type constants.
@param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
Defaults to BasePeer::TYPE_PHPNAME.
@param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
@param array $alreadyDumpedObjects List of objects to skip to avoid recursion
@param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
@return array an associative array containing the field names (as keys) and field values | [
"Exports",
"the",
"object",
"as",
"an",
"array",
"."
]
| train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUserRole.php#L630-L656 |
slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseUserRole.php | BaseUserRole.setByPosition | public function setByPosition($pos, $value)
{
switch ($pos) {
case 0:
$this->setUserId($value);
break;
case 1:
$this->setRoleId($value);
break;
} // switch()
} | php | public function setByPosition($pos, $value)
{
switch ($pos) {
case 0:
$this->setUserId($value);
break;
case 1:
$this->setRoleId($value);
break;
} // switch()
} | [
"public",
"function",
"setByPosition",
"(",
"$",
"pos",
",",
"$",
"value",
")",
"{",
"switch",
"(",
"$",
"pos",
")",
"{",
"case",
"0",
":",
"$",
"this",
"->",
"setUserId",
"(",
"$",
"value",
")",
";",
"break",
";",
"case",
"1",
":",
"$",
"this",
"->",
"setRoleId",
"(",
"$",
"value",
")",
";",
"break",
";",
"}",
"// switch()",
"}"
]
| Sets a field from the object by Position as specified in the xml schema.
Zero-based.
@param int $pos position in xml schema
@param mixed $value field value
@return void | [
"Sets",
"a",
"field",
"from",
"the",
"object",
"by",
"Position",
"as",
"specified",
"in",
"the",
"xml",
"schema",
".",
"Zero",
"-",
"based",
"."
]
| train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUserRole.php#L684-L694 |
slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseUserRole.php | BaseUserRole.fromArray | public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
{
$keys = UserRolePeer::getFieldNames($keyType);
if (array_key_exists($keys[0], $arr)) $this->setUserId($arr[$keys[0]]);
if (array_key_exists($keys[1], $arr)) $this->setRoleId($arr[$keys[1]]);
} | php | public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
{
$keys = UserRolePeer::getFieldNames($keyType);
if (array_key_exists($keys[0], $arr)) $this->setUserId($arr[$keys[0]]);
if (array_key_exists($keys[1], $arr)) $this->setRoleId($arr[$keys[1]]);
} | [
"public",
"function",
"fromArray",
"(",
"$",
"arr",
",",
"$",
"keyType",
"=",
"BasePeer",
"::",
"TYPE_PHPNAME",
")",
"{",
"$",
"keys",
"=",
"UserRolePeer",
"::",
"getFieldNames",
"(",
"$",
"keyType",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"keys",
"[",
"0",
"]",
",",
"$",
"arr",
")",
")",
"$",
"this",
"->",
"setUserId",
"(",
"$",
"arr",
"[",
"$",
"keys",
"[",
"0",
"]",
"]",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"keys",
"[",
"1",
"]",
",",
"$",
"arr",
")",
")",
"$",
"this",
"->",
"setRoleId",
"(",
"$",
"arr",
"[",
"$",
"keys",
"[",
"1",
"]",
"]",
")",
";",
"}"
]
| Populates the object using an array.
This is particularly useful when populating an object from one of the
request arrays (e.g. $_POST). This method goes through the column
names, checking to see whether a matching key exists in populated
array. If so the setByName() method is called for that column.
You can specify the key type of the array by additionally passing one
of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
The default key type is the column's BasePeer::TYPE_PHPNAME
@param array $arr An array to populate the object from.
@param string $keyType The type of keys the array uses.
@return void | [
"Populates",
"the",
"object",
"using",
"an",
"array",
"."
]
| train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUserRole.php#L713-L719 |
slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseUserRole.php | BaseUserRole.buildCriteria | public function buildCriteria()
{
$criteria = new Criteria(UserRolePeer::DATABASE_NAME);
if ($this->isColumnModified(UserRolePeer::USER_ID)) $criteria->add(UserRolePeer::USER_ID, $this->user_id);
if ($this->isColumnModified(UserRolePeer::ROLE_ID)) $criteria->add(UserRolePeer::ROLE_ID, $this->role_id);
return $criteria;
} | php | public function buildCriteria()
{
$criteria = new Criteria(UserRolePeer::DATABASE_NAME);
if ($this->isColumnModified(UserRolePeer::USER_ID)) $criteria->add(UserRolePeer::USER_ID, $this->user_id);
if ($this->isColumnModified(UserRolePeer::ROLE_ID)) $criteria->add(UserRolePeer::ROLE_ID, $this->role_id);
return $criteria;
} | [
"public",
"function",
"buildCriteria",
"(",
")",
"{",
"$",
"criteria",
"=",
"new",
"Criteria",
"(",
"UserRolePeer",
"::",
"DATABASE_NAME",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isColumnModified",
"(",
"UserRolePeer",
"::",
"USER_ID",
")",
")",
"$",
"criteria",
"->",
"add",
"(",
"UserRolePeer",
"::",
"USER_ID",
",",
"$",
"this",
"->",
"user_id",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isColumnModified",
"(",
"UserRolePeer",
"::",
"ROLE_ID",
")",
")",
"$",
"criteria",
"->",
"add",
"(",
"UserRolePeer",
"::",
"ROLE_ID",
",",
"$",
"this",
"->",
"role_id",
")",
";",
"return",
"$",
"criteria",
";",
"}"
]
| Build a Criteria object containing the values of all modified columns in this object.
@return Criteria The Criteria object containing all modified values. | [
"Build",
"a",
"Criteria",
"object",
"containing",
"the",
"values",
"of",
"all",
"modified",
"columns",
"in",
"this",
"object",
"."
]
| train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUserRole.php#L726-L734 |
slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseUserRole.php | BaseUserRole.buildPkeyCriteria | public function buildPkeyCriteria()
{
$criteria = new Criteria(UserRolePeer::DATABASE_NAME);
$criteria->add(UserRolePeer::USER_ID, $this->user_id);
$criteria->add(UserRolePeer::ROLE_ID, $this->role_id);
return $criteria;
} | php | public function buildPkeyCriteria()
{
$criteria = new Criteria(UserRolePeer::DATABASE_NAME);
$criteria->add(UserRolePeer::USER_ID, $this->user_id);
$criteria->add(UserRolePeer::ROLE_ID, $this->role_id);
return $criteria;
} | [
"public",
"function",
"buildPkeyCriteria",
"(",
")",
"{",
"$",
"criteria",
"=",
"new",
"Criteria",
"(",
"UserRolePeer",
"::",
"DATABASE_NAME",
")",
";",
"$",
"criteria",
"->",
"add",
"(",
"UserRolePeer",
"::",
"USER_ID",
",",
"$",
"this",
"->",
"user_id",
")",
";",
"$",
"criteria",
"->",
"add",
"(",
"UserRolePeer",
"::",
"ROLE_ID",
",",
"$",
"this",
"->",
"role_id",
")",
";",
"return",
"$",
"criteria",
";",
"}"
]
| Builds a Criteria object containing the primary key for this object.
Unlike buildCriteria() this method includes the primary key values regardless
of whether or not they have been modified.
@return Criteria The Criteria object containing value(s) for primary key(s). | [
"Builds",
"a",
"Criteria",
"object",
"containing",
"the",
"primary",
"key",
"for",
"this",
"object",
"."
]
| train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUserRole.php#L744-L751 |
slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseUserRole.php | BaseUserRole.copyInto | public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
{
$copyObj->setUserId($this->getUserId());
$copyObj->setRoleId($this->getRoleId());
if ($deepCopy && !$this->startCopy) {
// important: temporarily setNew(false) because this affects the behavior of
// the getter/setter methods for fkey referrer objects.
$copyObj->setNew(false);
// store object hash to prevent cycle
$this->startCopy = true;
//unflag object copy
$this->startCopy = false;
} // if ($deepCopy)
if ($makeNew) {
$copyObj->setNew(true);
}
} | php | public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
{
$copyObj->setUserId($this->getUserId());
$copyObj->setRoleId($this->getRoleId());
if ($deepCopy && !$this->startCopy) {
// important: temporarily setNew(false) because this affects the behavior of
// the getter/setter methods for fkey referrer objects.
$copyObj->setNew(false);
// store object hash to prevent cycle
$this->startCopy = true;
//unflag object copy
$this->startCopy = false;
} // if ($deepCopy)
if ($makeNew) {
$copyObj->setNew(true);
}
} | [
"public",
"function",
"copyInto",
"(",
"$",
"copyObj",
",",
"$",
"deepCopy",
"=",
"false",
",",
"$",
"makeNew",
"=",
"true",
")",
"{",
"$",
"copyObj",
"->",
"setUserId",
"(",
"$",
"this",
"->",
"getUserId",
"(",
")",
")",
";",
"$",
"copyObj",
"->",
"setRoleId",
"(",
"$",
"this",
"->",
"getRoleId",
"(",
")",
")",
";",
"if",
"(",
"$",
"deepCopy",
"&&",
"!",
"$",
"this",
"->",
"startCopy",
")",
"{",
"// important: temporarily setNew(false) because this affects the behavior of",
"// the getter/setter methods for fkey referrer objects.",
"$",
"copyObj",
"->",
"setNew",
"(",
"false",
")",
";",
"// store object hash to prevent cycle",
"$",
"this",
"->",
"startCopy",
"=",
"true",
";",
"//unflag object copy",
"$",
"this",
"->",
"startCopy",
"=",
"false",
";",
"}",
"// if ($deepCopy)",
"if",
"(",
"$",
"makeNew",
")",
"{",
"$",
"copyObj",
"->",
"setNew",
"(",
"true",
")",
";",
"}",
"}"
]
| Sets contents of passed object to values from current object.
If desired, this method can also make copies of all associated (fkey referrers)
objects.
@param object $copyObj An object of UserRole (or compatible) type.
@param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
@param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
@throws PropelException | [
"Sets",
"contents",
"of",
"passed",
"object",
"to",
"values",
"from",
"current",
"object",
"."
]
| train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUserRole.php#L800-L819 |
slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseUserRole.php | BaseUserRole.setUser | public function setUser(User $v = null)
{
if ($v === null) {
$this->setUserId(NULL);
} else {
$this->setUserId($v->getId());
}
$this->aUser = $v;
// Add binding for other direction of this n:n relationship.
// If this object has already been added to the User object, it will not be re-added.
if ($v !== null) {
$v->addUserRole($this);
}
return $this;
} | php | public function setUser(User $v = null)
{
if ($v === null) {
$this->setUserId(NULL);
} else {
$this->setUserId($v->getId());
}
$this->aUser = $v;
// Add binding for other direction of this n:n relationship.
// If this object has already been added to the User object, it will not be re-added.
if ($v !== null) {
$v->addUserRole($this);
}
return $this;
} | [
"public",
"function",
"setUser",
"(",
"User",
"$",
"v",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"v",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"setUserId",
"(",
"NULL",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"setUserId",
"(",
"$",
"v",
"->",
"getId",
"(",
")",
")",
";",
"}",
"$",
"this",
"->",
"aUser",
"=",
"$",
"v",
";",
"// Add binding for other direction of this n:n relationship.",
"// If this object has already been added to the User object, it will not be re-added.",
"if",
"(",
"$",
"v",
"!==",
"null",
")",
"{",
"$",
"v",
"->",
"addUserRole",
"(",
"$",
"this",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Declares an association between this object and a User object.
@param User $v
@return UserRole The current object (for fluent API support)
@throws PropelException | [
"Declares",
"an",
"association",
"between",
"this",
"object",
"and",
"a",
"User",
"object",
"."
]
| train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUserRole.php#L868-L886 |
slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseUserRole.php | BaseUserRole.getUser | public function getUser(PropelPDO $con = null, $doQuery = true)
{
if ($this->aUser === null && ($this->user_id !== null) && $doQuery) {
$this->aUser = UserQuery::create()->findPk($this->user_id, $con);
/* The following can be used additionally to
guarantee the related object contains a reference
to this object. This level of coupling may, however, be
undesirable since it could result in an only partially populated collection
in the referenced object.
$this->aUser->addUserRoles($this);
*/
}
return $this->aUser;
} | php | public function getUser(PropelPDO $con = null, $doQuery = true)
{
if ($this->aUser === null && ($this->user_id !== null) && $doQuery) {
$this->aUser = UserQuery::create()->findPk($this->user_id, $con);
/* The following can be used additionally to
guarantee the related object contains a reference
to this object. This level of coupling may, however, be
undesirable since it could result in an only partially populated collection
in the referenced object.
$this->aUser->addUserRoles($this);
*/
}
return $this->aUser;
} | [
"public",
"function",
"getUser",
"(",
"PropelPDO",
"$",
"con",
"=",
"null",
",",
"$",
"doQuery",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"aUser",
"===",
"null",
"&&",
"(",
"$",
"this",
"->",
"user_id",
"!==",
"null",
")",
"&&",
"$",
"doQuery",
")",
"{",
"$",
"this",
"->",
"aUser",
"=",
"UserQuery",
"::",
"create",
"(",
")",
"->",
"findPk",
"(",
"$",
"this",
"->",
"user_id",
",",
"$",
"con",
")",
";",
"/* The following can be used additionally to\n guarantee the related object contains a reference\n to this object. This level of coupling may, however, be\n undesirable since it could result in an only partially populated collection\n in the referenced object.\n $this->aUser->addUserRoles($this);\n */",
"}",
"return",
"$",
"this",
"->",
"aUser",
";",
"}"
]
| Get the associated User object
@param PropelPDO $con Optional Connection object.
@param $doQuery Executes a query to get the object if required
@return User The associated User object.
@throws PropelException | [
"Get",
"the",
"associated",
"User",
"object"
]
| train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUserRole.php#L897-L911 |
slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseUserRole.php | BaseUserRole.setRole | public function setRole(Role $v = null)
{
if ($v === null) {
$this->setRoleId(NULL);
} else {
$this->setRoleId($v->getId());
}
$this->aRole = $v;
// Add binding for other direction of this n:n relationship.
// If this object has already been added to the Role object, it will not be re-added.
if ($v !== null) {
$v->addUserRole($this);
}
return $this;
} | php | public function setRole(Role $v = null)
{
if ($v === null) {
$this->setRoleId(NULL);
} else {
$this->setRoleId($v->getId());
}
$this->aRole = $v;
// Add binding for other direction of this n:n relationship.
// If this object has already been added to the Role object, it will not be re-added.
if ($v !== null) {
$v->addUserRole($this);
}
return $this;
} | [
"public",
"function",
"setRole",
"(",
"Role",
"$",
"v",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"v",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"setRoleId",
"(",
"NULL",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"setRoleId",
"(",
"$",
"v",
"->",
"getId",
"(",
")",
")",
";",
"}",
"$",
"this",
"->",
"aRole",
"=",
"$",
"v",
";",
"// Add binding for other direction of this n:n relationship.",
"// If this object has already been added to the Role object, it will not be re-added.",
"if",
"(",
"$",
"v",
"!==",
"null",
")",
"{",
"$",
"v",
"->",
"addUserRole",
"(",
"$",
"this",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Declares an association between this object and a Role object.
@param Role $v
@return UserRole The current object (for fluent API support)
@throws PropelException | [
"Declares",
"an",
"association",
"between",
"this",
"object",
"and",
"a",
"Role",
"object",
"."
]
| train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUserRole.php#L920-L938 |
slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseUserRole.php | BaseUserRole.getRole | public function getRole(PropelPDO $con = null, $doQuery = true)
{
if ($this->aRole === null && ($this->role_id !== null) && $doQuery) {
$this->aRole = RoleQuery::create()->findPk($this->role_id, $con);
/* The following can be used additionally to
guarantee the related object contains a reference
to this object. This level of coupling may, however, be
undesirable since it could result in an only partially populated collection
in the referenced object.
$this->aRole->addUserRoles($this);
*/
}
return $this->aRole;
} | php | public function getRole(PropelPDO $con = null, $doQuery = true)
{
if ($this->aRole === null && ($this->role_id !== null) && $doQuery) {
$this->aRole = RoleQuery::create()->findPk($this->role_id, $con);
/* The following can be used additionally to
guarantee the related object contains a reference
to this object. This level of coupling may, however, be
undesirable since it could result in an only partially populated collection
in the referenced object.
$this->aRole->addUserRoles($this);
*/
}
return $this->aRole;
} | [
"public",
"function",
"getRole",
"(",
"PropelPDO",
"$",
"con",
"=",
"null",
",",
"$",
"doQuery",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"aRole",
"===",
"null",
"&&",
"(",
"$",
"this",
"->",
"role_id",
"!==",
"null",
")",
"&&",
"$",
"doQuery",
")",
"{",
"$",
"this",
"->",
"aRole",
"=",
"RoleQuery",
"::",
"create",
"(",
")",
"->",
"findPk",
"(",
"$",
"this",
"->",
"role_id",
",",
"$",
"con",
")",
";",
"/* The following can be used additionally to\n guarantee the related object contains a reference\n to this object. This level of coupling may, however, be\n undesirable since it could result in an only partially populated collection\n in the referenced object.\n $this->aRole->addUserRoles($this);\n */",
"}",
"return",
"$",
"this",
"->",
"aRole",
";",
"}"
]
| Get the associated Role object
@param PropelPDO $con Optional Connection object.
@param $doQuery Executes a query to get the object if required
@return Role The associated Role object.
@throws PropelException | [
"Get",
"the",
"associated",
"Role",
"object"
]
| train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUserRole.php#L949-L963 |
slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseUserRole.php | BaseUserRole.clear | public function clear()
{
$this->user_id = null;
$this->role_id = null;
$this->alreadyInSave = false;
$this->alreadyInValidation = false;
$this->alreadyInClearAllReferencesDeep = false;
$this->clearAllReferences();
$this->resetModified();
$this->setNew(true);
$this->setDeleted(false);
} | php | public function clear()
{
$this->user_id = null;
$this->role_id = null;
$this->alreadyInSave = false;
$this->alreadyInValidation = false;
$this->alreadyInClearAllReferencesDeep = false;
$this->clearAllReferences();
$this->resetModified();
$this->setNew(true);
$this->setDeleted(false);
} | [
"public",
"function",
"clear",
"(",
")",
"{",
"$",
"this",
"->",
"user_id",
"=",
"null",
";",
"$",
"this",
"->",
"role_id",
"=",
"null",
";",
"$",
"this",
"->",
"alreadyInSave",
"=",
"false",
";",
"$",
"this",
"->",
"alreadyInValidation",
"=",
"false",
";",
"$",
"this",
"->",
"alreadyInClearAllReferencesDeep",
"=",
"false",
";",
"$",
"this",
"->",
"clearAllReferences",
"(",
")",
";",
"$",
"this",
"->",
"resetModified",
"(",
")",
";",
"$",
"this",
"->",
"setNew",
"(",
"true",
")",
";",
"$",
"this",
"->",
"setDeleted",
"(",
"false",
")",
";",
"}"
]
| Clears the current object and sets all attributes to their default values | [
"Clears",
"the",
"current",
"object",
"and",
"sets",
"all",
"attributes",
"to",
"their",
"default",
"values"
]
| train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUserRole.php#L968-L979 |
slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseUserRole.php | BaseUserRole.clearAllReferences | public function clearAllReferences($deep = false)
{
if ($deep && !$this->alreadyInClearAllReferencesDeep) {
$this->alreadyInClearAllReferencesDeep = true;
if ($this->aUser instanceof Persistent) {
$this->aUser->clearAllReferences($deep);
}
if ($this->aRole instanceof Persistent) {
$this->aRole->clearAllReferences($deep);
}
$this->alreadyInClearAllReferencesDeep = false;
} // if ($deep)
$this->aUser = null;
$this->aRole = null;
} | php | public function clearAllReferences($deep = false)
{
if ($deep && !$this->alreadyInClearAllReferencesDeep) {
$this->alreadyInClearAllReferencesDeep = true;
if ($this->aUser instanceof Persistent) {
$this->aUser->clearAllReferences($deep);
}
if ($this->aRole instanceof Persistent) {
$this->aRole->clearAllReferences($deep);
}
$this->alreadyInClearAllReferencesDeep = false;
} // if ($deep)
$this->aUser = null;
$this->aRole = null;
} | [
"public",
"function",
"clearAllReferences",
"(",
"$",
"deep",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"deep",
"&&",
"!",
"$",
"this",
"->",
"alreadyInClearAllReferencesDeep",
")",
"{",
"$",
"this",
"->",
"alreadyInClearAllReferencesDeep",
"=",
"true",
";",
"if",
"(",
"$",
"this",
"->",
"aUser",
"instanceof",
"Persistent",
")",
"{",
"$",
"this",
"->",
"aUser",
"->",
"clearAllReferences",
"(",
"$",
"deep",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"aRole",
"instanceof",
"Persistent",
")",
"{",
"$",
"this",
"->",
"aRole",
"->",
"clearAllReferences",
"(",
"$",
"deep",
")",
";",
"}",
"$",
"this",
"->",
"alreadyInClearAllReferencesDeep",
"=",
"false",
";",
"}",
"// if ($deep)",
"$",
"this",
"->",
"aUser",
"=",
"null",
";",
"$",
"this",
"->",
"aRole",
"=",
"null",
";",
"}"
]
| Resets all references to other model objects or collections of model objects.
This method is a user-space workaround for PHP's inability to garbage collect
objects with circular references (even in PHP 5.3). This is currently necessary
when using Propel in certain daemon or large-volume/high-memory operations.
@param boolean $deep Whether to also clear the references on all referrer objects. | [
"Resets",
"all",
"references",
"to",
"other",
"model",
"objects",
"or",
"collections",
"of",
"model",
"objects",
"."
]
| train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUserRole.php#L990-L1006 |
dashifen/wordpress-php7-plugin-boilerplate | src/Controller/ControllerTraits/PostTypesTrait.php | PostTypesTrait.getPostType | final public function getPostType(int $index): string {
$types = $this->getPostTypes();
if (!isset($types[$index])) {
throw new ControllerException("Unknown type.",
ControllerException::UNKNOWN_TYPE);
}
return $types[$index];
} | php | final public function getPostType(int $index): string {
$types = $this->getPostTypes();
if (!isset($types[$index])) {
throw new ControllerException("Unknown type.",
ControllerException::UNKNOWN_TYPE);
}
return $types[$index];
} | [
"final",
"public",
"function",
"getPostType",
"(",
"int",
"$",
"index",
")",
":",
"string",
"{",
"$",
"types",
"=",
"$",
"this",
"->",
"getPostTypes",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"types",
"[",
"$",
"index",
"]",
")",
")",
"{",
"throw",
"new",
"ControllerException",
"(",
"\"Unknown type.\"",
",",
"ControllerException",
"::",
"UNKNOWN_TYPE",
")",
";",
"}",
"return",
"$",
"types",
"[",
"$",
"index",
"]",
";",
"}"
]
| given an $index, returns that post type from the array returned by
getPostTypes().
@param int $index
@return string
@throws ControllerException | [
"given",
"an",
"$index",
"returns",
"that",
"post",
"type",
"from",
"the",
"array",
"returned",
"by",
"getPostTypes",
"()",
"."
]
| train | https://github.com/dashifen/wordpress-php7-plugin-boilerplate/blob/c7875deb403d311efca72dc3c8beb566972a56cb/src/Controller/ControllerTraits/PostTypesTrait.php#L25-L33 |
dashifen/wordpress-php7-plugin-boilerplate | src/Controller/ControllerTraits/PostTypesTrait.php | PostTypesTrait.initPostTypesTrait | final protected function initPostTypesTrait() {
add_action("init", function () {
$postTypes = $this->getPostTypes();
foreach ($postTypes as $postType) {
$this->registerPostType($postType);
}
});
} | php | final protected function initPostTypesTrait() {
add_action("init", function () {
$postTypes = $this->getPostTypes();
foreach ($postTypes as $postType) {
$this->registerPostType($postType);
}
});
} | [
"final",
"protected",
"function",
"initPostTypesTrait",
"(",
")",
"{",
"add_action",
"(",
"\"init\"",
",",
"function",
"(",
")",
"{",
"$",
"postTypes",
"=",
"$",
"this",
"->",
"getPostTypes",
"(",
")",
";",
"foreach",
"(",
"$",
"postTypes",
"as",
"$",
"postType",
")",
"{",
"$",
"this",
"->",
"registerPostType",
"(",
"$",
"postType",
")",
";",
"}",
"}",
")",
";",
"}"
]
| Called automatically when the plugins are loaded, this method
registers our post types for the users of this boilerplate.
@return void | [
"Called",
"automatically",
"when",
"the",
"plugins",
"are",
"loaded",
"this",
"method",
"registers",
"our",
"post",
"types",
"for",
"the",
"users",
"of",
"this",
"boilerplate",
"."
]
| train | https://github.com/dashifen/wordpress-php7-plugin-boilerplate/blob/c7875deb403d311efca72dc3c8beb566972a56cb/src/Controller/ControllerTraits/PostTypesTrait.php#L82-L89 |
dashifen/wordpress-php7-plugin-boilerplate | src/Controller/ControllerTraits/PostTypesTrait.php | PostTypesTrait.registerPostType | final public function registerPostType(string $postType): void {
// we make this a public method because we use it in our
// initialization method below but frequently from the activation
// action of the plugin itself so that we can flush permalinks
// based on our new types.
$args = $this->getPostTypeArgs($postType);
$args["labels"] = $this->getPostTypeLabels($postType);
$args["rewrite"] = $this->getPostTypeRewrite($postType);
unset($args["label"], $args["register_meta_box_cb"]);
register_post_type($postType, $args);
} | php | final public function registerPostType(string $postType): void {
// we make this a public method because we use it in our
// initialization method below but frequently from the activation
// action of the plugin itself so that we can flush permalinks
// based on our new types.
$args = $this->getPostTypeArgs($postType);
$args["labels"] = $this->getPostTypeLabels($postType);
$args["rewrite"] = $this->getPostTypeRewrite($postType);
unset($args["label"], $args["register_meta_box_cb"]);
register_post_type($postType, $args);
} | [
"final",
"public",
"function",
"registerPostType",
"(",
"string",
"$",
"postType",
")",
":",
"void",
"{",
"// we make this a public method because we use it in our",
"// initialization method below but frequently from the activation",
"// action of the plugin itself so that we can flush permalinks",
"// based on our new types.",
"$",
"args",
"=",
"$",
"this",
"->",
"getPostTypeArgs",
"(",
"$",
"postType",
")",
";",
"$",
"args",
"[",
"\"labels\"",
"]",
"=",
"$",
"this",
"->",
"getPostTypeLabels",
"(",
"$",
"postType",
")",
";",
"$",
"args",
"[",
"\"rewrite\"",
"]",
"=",
"$",
"this",
"->",
"getPostTypeRewrite",
"(",
"$",
"postType",
")",
";",
"unset",
"(",
"$",
"args",
"[",
"\"label\"",
"]",
",",
"$",
"args",
"[",
"\"register_meta_box_cb\"",
"]",
")",
";",
"register_post_type",
"(",
"$",
"postType",
",",
"$",
"args",
")",
";",
"}"
]
| @param string $postType
@return void | [
"@param",
"string",
"$postType"
]
| train | https://github.com/dashifen/wordpress-php7-plugin-boilerplate/blob/c7875deb403d311efca72dc3c8beb566972a56cb/src/Controller/ControllerTraits/PostTypesTrait.php#L96-L109 |
danrevah/shortify-punit | src/Stub/WhenCase.php | WhenCase.setMethod | public function setMethod($args, $action, $returns)
{
ShortifyPunit::setWhenMockResponse(
$this->className,
$this->instanceId,
$this->method,
$args,
$action,
$returns
);
} | php | public function setMethod($args, $action, $returns)
{
ShortifyPunit::setWhenMockResponse(
$this->className,
$this->instanceId,
$this->method,
$args,
$action,
$returns
);
} | [
"public",
"function",
"setMethod",
"(",
"$",
"args",
",",
"$",
"action",
",",
"$",
"returns",
")",
"{",
"ShortifyPunit",
"::",
"setWhenMockResponse",
"(",
"$",
"this",
"->",
"className",
",",
"$",
"this",
"->",
"instanceId",
",",
"$",
"this",
"->",
"method",
",",
"$",
"args",
",",
"$",
"action",
",",
"$",
"returns",
")",
";",
"}"
]
| @desc Setting up the mock response in the ShortifyPunit Return Values array
@param $args
@param $action
@param $returns | [
"@desc",
"Setting",
"up",
"the",
"mock",
"response",
"in",
"the",
"ShortifyPunit",
"Return",
"Values",
"array"
]
| train | https://github.com/danrevah/shortify-punit/blob/cedd08f31de8e7409a07d2630701ef4e924cc5f0/src/Stub/WhenCase.php#L46-L56 |
anime-db/app-bundle | src/Event/Listener/Package.php | Package.onUpdated | public function onUpdated(UpdatedEvent $event)
{
if ($event->getPackage()->getType() == self::PLUGIN_TYPE) {
$this->addPackage($event->getPackage());
}
} | php | public function onUpdated(UpdatedEvent $event)
{
if ($event->getPackage()->getType() == self::PLUGIN_TYPE) {
$this->addPackage($event->getPackage());
}
} | [
"public",
"function",
"onUpdated",
"(",
"UpdatedEvent",
"$",
"event",
")",
"{",
"if",
"(",
"$",
"event",
"->",
"getPackage",
"(",
")",
"->",
"getType",
"(",
")",
"==",
"self",
"::",
"PLUGIN_TYPE",
")",
"{",
"$",
"this",
"->",
"addPackage",
"(",
"$",
"event",
"->",
"getPackage",
"(",
")",
")",
";",
"}",
"}"
]
| Update plugin data.
@param UpdatedEvent $event | [
"Update",
"plugin",
"data",
"."
]
| train | https://github.com/anime-db/app-bundle/blob/ca3b342081719d41ba018792a75970cbb1f1fe22/src/Event/Listener/Package.php#L85-L90 |
anime-db/app-bundle | src/Event/Listener/Package.php | Package.onInstalled | public function onInstalled(InstalledEvent $event)
{
if ($event->getPackage()->getType() == self::PLUGIN_TYPE) {
$this->addPackage($event->getPackage());
}
} | php | public function onInstalled(InstalledEvent $event)
{
if ($event->getPackage()->getType() == self::PLUGIN_TYPE) {
$this->addPackage($event->getPackage());
}
} | [
"public",
"function",
"onInstalled",
"(",
"InstalledEvent",
"$",
"event",
")",
"{",
"if",
"(",
"$",
"event",
"->",
"getPackage",
"(",
")",
"->",
"getType",
"(",
")",
"==",
"self",
"::",
"PLUGIN_TYPE",
")",
"{",
"$",
"this",
"->",
"addPackage",
"(",
"$",
"event",
"->",
"getPackage",
"(",
")",
")",
";",
"}",
"}"
]
| Registr plugin.
@param InstalledEvent $event | [
"Registr",
"plugin",
"."
]
| train | https://github.com/anime-db/app-bundle/blob/ca3b342081719d41ba018792a75970cbb1f1fe22/src/Event/Listener/Package.php#L97-L102 |
anime-db/app-bundle | src/Event/Listener/Package.php | Package.addPackage | protected function addPackage(ComposerPackage $package)
{
$plugin = $this->rep->find($package->getName());
// create new plugin if not exists
if (!$plugin) {
$plugin = new Plugin();
$plugin->setName($package->getName());
}
list($vendor, $package) = explode('/', $plugin->getName());
try {
$data = $this->client->getPlugin($vendor, $package);
$plugin->setTitle($data['title'])->setDescription($data['description']);
if ($data['logo']) {
$this->downloader->entity($data['logo'], $plugin, true);
}
} catch (\Exception $e) {
// is not a critical error
}
$this->em->persist($plugin);
$this->em->flush();
} | php | protected function addPackage(ComposerPackage $package)
{
$plugin = $this->rep->find($package->getName());
// create new plugin if not exists
if (!$plugin) {
$plugin = new Plugin();
$plugin->setName($package->getName());
}
list($vendor, $package) = explode('/', $plugin->getName());
try {
$data = $this->client->getPlugin($vendor, $package);
$plugin->setTitle($data['title'])->setDescription($data['description']);
if ($data['logo']) {
$this->downloader->entity($data['logo'], $plugin, true);
}
} catch (\Exception $e) {
// is not a critical error
}
$this->em->persist($plugin);
$this->em->flush();
} | [
"protected",
"function",
"addPackage",
"(",
"ComposerPackage",
"$",
"package",
")",
"{",
"$",
"plugin",
"=",
"$",
"this",
"->",
"rep",
"->",
"find",
"(",
"$",
"package",
"->",
"getName",
"(",
")",
")",
";",
"// create new plugin if not exists",
"if",
"(",
"!",
"$",
"plugin",
")",
"{",
"$",
"plugin",
"=",
"new",
"Plugin",
"(",
")",
";",
"$",
"plugin",
"->",
"setName",
"(",
"$",
"package",
"->",
"getName",
"(",
")",
")",
";",
"}",
"list",
"(",
"$",
"vendor",
",",
"$",
"package",
")",
"=",
"explode",
"(",
"'/'",
",",
"$",
"plugin",
"->",
"getName",
"(",
")",
")",
";",
"try",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"client",
"->",
"getPlugin",
"(",
"$",
"vendor",
",",
"$",
"package",
")",
";",
"$",
"plugin",
"->",
"setTitle",
"(",
"$",
"data",
"[",
"'title'",
"]",
")",
"->",
"setDescription",
"(",
"$",
"data",
"[",
"'description'",
"]",
")",
";",
"if",
"(",
"$",
"data",
"[",
"'logo'",
"]",
")",
"{",
"$",
"this",
"->",
"downloader",
"->",
"entity",
"(",
"$",
"data",
"[",
"'logo'",
"]",
",",
"$",
"plugin",
",",
"true",
")",
";",
"}",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"// is not a critical error",
"}",
"$",
"this",
"->",
"em",
"->",
"persist",
"(",
"$",
"plugin",
")",
";",
"$",
"this",
"->",
"em",
"->",
"flush",
"(",
")",
";",
"}"
]
| Add plugin from package.
@param ComposerPackage $package | [
"Add",
"plugin",
"from",
"package",
"."
]
| train | https://github.com/anime-db/app-bundle/blob/ca3b342081719d41ba018792a75970cbb1f1fe22/src/Event/Listener/Package.php#L109-L133 |
anime-db/app-bundle | src/Event/Listener/Package.php | Package.onRemoved | public function onRemoved(RemovedEvent $event)
{
if ($event->getPackage()->getType() == self::PLUGIN_TYPE) {
$plugin = $this->rep->find($event->getPackage()->getName());
if ($plugin) {
$this->em->remove($plugin);
$this->em->flush();
}
}
} | php | public function onRemoved(RemovedEvent $event)
{
if ($event->getPackage()->getType() == self::PLUGIN_TYPE) {
$plugin = $this->rep->find($event->getPackage()->getName());
if ($plugin) {
$this->em->remove($plugin);
$this->em->flush();
}
}
} | [
"public",
"function",
"onRemoved",
"(",
"RemovedEvent",
"$",
"event",
")",
"{",
"if",
"(",
"$",
"event",
"->",
"getPackage",
"(",
")",
"->",
"getType",
"(",
")",
"==",
"self",
"::",
"PLUGIN_TYPE",
")",
"{",
"$",
"plugin",
"=",
"$",
"this",
"->",
"rep",
"->",
"find",
"(",
"$",
"event",
"->",
"getPackage",
"(",
")",
"->",
"getName",
"(",
")",
")",
";",
"if",
"(",
"$",
"plugin",
")",
"{",
"$",
"this",
"->",
"em",
"->",
"remove",
"(",
"$",
"plugin",
")",
";",
"$",
"this",
"->",
"em",
"->",
"flush",
"(",
")",
";",
"}",
"}",
"}"
]
| Unregistr plugin.
@param RemovedEvent $event | [
"Unregistr",
"plugin",
"."
]
| train | https://github.com/anime-db/app-bundle/blob/ca3b342081719d41ba018792a75970cbb1f1fe22/src/Event/Listener/Package.php#L140-L150 |
anime-db/app-bundle | src/Event/Listener/Package.php | Package.onInstalledConfigureShmop | public function onInstalledConfigureShmop(InstalledEvent $event)
{
// use Shmop as driver for Cache Time Keeper
if ($event->getPackage()->getName() == self::PACKAGE_SHMOP) {
$this->parameters->set('cache_time_keeper.driver', 'cache_time_keeper.driver.multi');
$this->parameters->set('cache_time_keeper.driver.multi.fast', 'cache_time_keeper.driver.shmop');
}
} | php | public function onInstalledConfigureShmop(InstalledEvent $event)
{
// use Shmop as driver for Cache Time Keeper
if ($event->getPackage()->getName() == self::PACKAGE_SHMOP) {
$this->parameters->set('cache_time_keeper.driver', 'cache_time_keeper.driver.multi');
$this->parameters->set('cache_time_keeper.driver.multi.fast', 'cache_time_keeper.driver.shmop');
}
} | [
"public",
"function",
"onInstalledConfigureShmop",
"(",
"InstalledEvent",
"$",
"event",
")",
"{",
"// use Shmop as driver for Cache Time Keeper",
"if",
"(",
"$",
"event",
"->",
"getPackage",
"(",
")",
"->",
"getName",
"(",
")",
"==",
"self",
"::",
"PACKAGE_SHMOP",
")",
"{",
"$",
"this",
"->",
"parameters",
"->",
"set",
"(",
"'cache_time_keeper.driver'",
",",
"'cache_time_keeper.driver.multi'",
")",
";",
"$",
"this",
"->",
"parameters",
"->",
"set",
"(",
"'cache_time_keeper.driver.multi.fast'",
",",
"'cache_time_keeper.driver.shmop'",
")",
";",
"}",
"}"
]
| Configure shmop.
@param InstalledEvent $event | [
"Configure",
"shmop",
"."
]
| train | https://github.com/anime-db/app-bundle/blob/ca3b342081719d41ba018792a75970cbb1f1fe22/src/Event/Listener/Package.php#L157-L164 |
anime-db/app-bundle | src/Event/Listener/Package.php | Package.onRemovedShmop | public function onRemovedShmop(RemovedEvent $event)
{
if ($event->getPackage()->getName() == self::PACKAGE_SHMOP) {
$this->parameters->set('cache_time_keeper.driver', 'cache_time_keeper.driver.file');
}
} | php | public function onRemovedShmop(RemovedEvent $event)
{
if ($event->getPackage()->getName() == self::PACKAGE_SHMOP) {
$this->parameters->set('cache_time_keeper.driver', 'cache_time_keeper.driver.file');
}
} | [
"public",
"function",
"onRemovedShmop",
"(",
"RemovedEvent",
"$",
"event",
")",
"{",
"if",
"(",
"$",
"event",
"->",
"getPackage",
"(",
")",
"->",
"getName",
"(",
")",
"==",
"self",
"::",
"PACKAGE_SHMOP",
")",
"{",
"$",
"this",
"->",
"parameters",
"->",
"set",
"(",
"'cache_time_keeper.driver'",
",",
"'cache_time_keeper.driver.file'",
")",
";",
"}",
"}"
]
| Restore config on removed shmop.
@param RemovedEvent $event | [
"Restore",
"config",
"on",
"removed",
"shmop",
"."
]
| train | https://github.com/anime-db/app-bundle/blob/ca3b342081719d41ba018792a75970cbb1f1fe22/src/Event/Listener/Package.php#L171-L176 |
SAREhub/PHP_Commons | src/SAREhub/Commons/Misc/SimpleSemafor.php | SimpleSemafor.lock | public function lock()
{
if (!$this->isLocked()) {
$file = fopen($this->getFilePath(), 'w');
if ($file) {
fwrite($file, getmypid());
fclose($file);
return true;
}
}
return false;
} | php | public function lock()
{
if (!$this->isLocked()) {
$file = fopen($this->getFilePath(), 'w');
if ($file) {
fwrite($file, getmypid());
fclose($file);
return true;
}
}
return false;
} | [
"public",
"function",
"lock",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isLocked",
"(",
")",
")",
"{",
"$",
"file",
"=",
"fopen",
"(",
"$",
"this",
"->",
"getFilePath",
"(",
")",
",",
"'w'",
")",
";",
"if",
"(",
"$",
"file",
")",
"{",
"fwrite",
"(",
"$",
"file",
",",
"getmypid",
"(",
")",
")",
";",
"fclose",
"(",
"$",
"file",
")",
";",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
]
| Try create semafor file
@return bool When successful locked | [
"Try",
"create",
"semafor",
"file"
]
| train | https://github.com/SAREhub/PHP_Commons/blob/4e1769ab6411a584112df1151dcc90e6b82fe2bb/src/SAREhub/Commons/Misc/SimpleSemafor.php#L23-L34 |
mmieluch/laravel-serve-custom-ini | src/ServeCommand.php | ServeCommand.fire | public function fire()
{
chdir($this->laravel->publicPath());
$host = $this->input->getOption('host');
$port = $this->input->getOption('port');
$base = ProcessUtils::escapeArgument($this->laravel->basePath());
$binary = ProcessUtils::escapeArgument((new PhpExecutableFinder)->find(true));
$this->info("Laravel development server started on http://{$host}:{$port}/");
if (defined('HHVM_VERSION')) {
if (version_compare(HHVM_VERSION, '3.8.0') >= 0) {
passthru("{$binary} -m server -v Server.Type=proxygen -v Server.SourceRoot={$base}/ -v Server.IP={$host} -v Server.Port={$port} -v Server.DefaultDocument=server.php -v Server.ErrorDocument404=server.php");
} else {
throw new Exception("HHVM's built-in server requires HHVM >= 3.8.0.");
}
} else {
$command = $this->buildCommand($binary, $host, $port, $base);
$this->info('Command to execute: ' . $command, 'v');
passthru($command);
}
} | php | public function fire()
{
chdir($this->laravel->publicPath());
$host = $this->input->getOption('host');
$port = $this->input->getOption('port');
$base = ProcessUtils::escapeArgument($this->laravel->basePath());
$binary = ProcessUtils::escapeArgument((new PhpExecutableFinder)->find(true));
$this->info("Laravel development server started on http://{$host}:{$port}/");
if (defined('HHVM_VERSION')) {
if (version_compare(HHVM_VERSION, '3.8.0') >= 0) {
passthru("{$binary} -m server -v Server.Type=proxygen -v Server.SourceRoot={$base}/ -v Server.IP={$host} -v Server.Port={$port} -v Server.DefaultDocument=server.php -v Server.ErrorDocument404=server.php");
} else {
throw new Exception("HHVM's built-in server requires HHVM >= 3.8.0.");
}
} else {
$command = $this->buildCommand($binary, $host, $port, $base);
$this->info('Command to execute: ' . $command, 'v');
passthru($command);
}
} | [
"public",
"function",
"fire",
"(",
")",
"{",
"chdir",
"(",
"$",
"this",
"->",
"laravel",
"->",
"publicPath",
"(",
")",
")",
";",
"$",
"host",
"=",
"$",
"this",
"->",
"input",
"->",
"getOption",
"(",
"'host'",
")",
";",
"$",
"port",
"=",
"$",
"this",
"->",
"input",
"->",
"getOption",
"(",
"'port'",
")",
";",
"$",
"base",
"=",
"ProcessUtils",
"::",
"escapeArgument",
"(",
"$",
"this",
"->",
"laravel",
"->",
"basePath",
"(",
")",
")",
";",
"$",
"binary",
"=",
"ProcessUtils",
"::",
"escapeArgument",
"(",
"(",
"new",
"PhpExecutableFinder",
")",
"->",
"find",
"(",
"true",
")",
")",
";",
"$",
"this",
"->",
"info",
"(",
"\"Laravel development server started on http://{$host}:{$port}/\"",
")",
";",
"if",
"(",
"defined",
"(",
"'HHVM_VERSION'",
")",
")",
"{",
"if",
"(",
"version_compare",
"(",
"HHVM_VERSION",
",",
"'3.8.0'",
")",
">=",
"0",
")",
"{",
"passthru",
"(",
"\"{$binary} -m server -v Server.Type=proxygen -v Server.SourceRoot={$base}/ -v Server.IP={$host} -v Server.Port={$port} -v Server.DefaultDocument=server.php -v Server.ErrorDocument404=server.php\"",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"Exception",
"(",
"\"HHVM's built-in server requires HHVM >= 3.8.0.\"",
")",
";",
"}",
"}",
"else",
"{",
"$",
"command",
"=",
"$",
"this",
"->",
"buildCommand",
"(",
"$",
"binary",
",",
"$",
"host",
",",
"$",
"port",
",",
"$",
"base",
")",
";",
"$",
"this",
"->",
"info",
"(",
"'Command to execute: '",
".",
"$",
"command",
",",
"'v'",
")",
";",
"passthru",
"(",
"$",
"command",
")",
";",
"}",
"}"
]
| Execute the console command.
@return void
@throws \Exception | [
"Execute",
"the",
"console",
"command",
"."
]
| train | https://github.com/mmieluch/laravel-serve-custom-ini/blob/38e547b8496a6123fe63be0901a07fd798537ad7/src/ServeCommand.php#L41-L68 |
mmieluch/laravel-serve-custom-ini | src/ServeCommand.php | ServeCommand.buildCommand | protected function buildCommand($binary, $host, $port, $base)
{
$binary = $this->handleCustomIni($binary);
$base = str_replace("'", '', $base);
$command = "{$binary} -S {$host}:{$port} {$base}/server.php";
return $command;
} | php | protected function buildCommand($binary, $host, $port, $base)
{
$binary = $this->handleCustomIni($binary);
$base = str_replace("'", '', $base);
$command = "{$binary} -S {$host}:{$port} {$base}/server.php";
return $command;
} | [
"protected",
"function",
"buildCommand",
"(",
"$",
"binary",
",",
"$",
"host",
",",
"$",
"port",
",",
"$",
"base",
")",
"{",
"$",
"binary",
"=",
"$",
"this",
"->",
"handleCustomIni",
"(",
"$",
"binary",
")",
";",
"$",
"base",
"=",
"str_replace",
"(",
"\"'\"",
",",
"''",
",",
"$",
"base",
")",
";",
"$",
"command",
"=",
"\"{$binary} -S {$host}:{$port} {$base}/server.php\"",
";",
"return",
"$",
"command",
";",
"}"
]
| Returns a command to pass through to shell.
@param string $binary Usually full path to the PHP executable
@param string $host Hostname
@param int $port
@param string $base Full path to Laravel project root
@return string | [
"Returns",
"a",
"command",
"to",
"pass",
"through",
"to",
"shell",
"."
]
| train | https://github.com/mmieluch/laravel-serve-custom-ini/blob/38e547b8496a6123fe63be0901a07fd798537ad7/src/ServeCommand.php#L80-L89 |
mmieluch/laravel-serve-custom-ini | src/ServeCommand.php | ServeCommand.handleCustomIni | protected function handleCustomIni($command)
{
// If --ini parameter was not specified, just return the command
// is at has been constructed.
if (!$this->option('ini')) {
return $command;
}
// Additional parameter will not work when escaped with single quotes.
$command = str_replace("'", '', $command);
// Determine the path
$iniPath = ($this->option('ini-path') === $this->defaultIniPath)
? $this->laravel->basePath() . '/' . $this->defaultIniPath
: $this->option('ini-path');
$iniPath = realpath($iniPath);
$this->info('Loading custom configuration file: ' . $iniPath, 'v');
if (!file_exists($iniPath)) {
$this->warn(sprintf(
'File %s does not exist. Custom configuration will not be loaded.',
$iniPath
));
}
// Append PHP parameter with a path to the configuration file.
$command .= ' -c ' . $iniPath;
return $command;
} | php | protected function handleCustomIni($command)
{
// If --ini parameter was not specified, just return the command
// is at has been constructed.
if (!$this->option('ini')) {
return $command;
}
// Additional parameter will not work when escaped with single quotes.
$command = str_replace("'", '', $command);
// Determine the path
$iniPath = ($this->option('ini-path') === $this->defaultIniPath)
? $this->laravel->basePath() . '/' . $this->defaultIniPath
: $this->option('ini-path');
$iniPath = realpath($iniPath);
$this->info('Loading custom configuration file: ' . $iniPath, 'v');
if (!file_exists($iniPath)) {
$this->warn(sprintf(
'File %s does not exist. Custom configuration will not be loaded.',
$iniPath
));
}
// Append PHP parameter with a path to the configuration file.
$command .= ' -c ' . $iniPath;
return $command;
} | [
"protected",
"function",
"handleCustomIni",
"(",
"$",
"command",
")",
"{",
"// If --ini parameter was not specified, just return the command",
"// is at has been constructed.",
"if",
"(",
"!",
"$",
"this",
"->",
"option",
"(",
"'ini'",
")",
")",
"{",
"return",
"$",
"command",
";",
"}",
"// Additional parameter will not work when escaped with single quotes.",
"$",
"command",
"=",
"str_replace",
"(",
"\"'\"",
",",
"''",
",",
"$",
"command",
")",
";",
"// Determine the path",
"$",
"iniPath",
"=",
"(",
"$",
"this",
"->",
"option",
"(",
"'ini-path'",
")",
"===",
"$",
"this",
"->",
"defaultIniPath",
")",
"?",
"$",
"this",
"->",
"laravel",
"->",
"basePath",
"(",
")",
".",
"'/'",
".",
"$",
"this",
"->",
"defaultIniPath",
":",
"$",
"this",
"->",
"option",
"(",
"'ini-path'",
")",
";",
"$",
"iniPath",
"=",
"realpath",
"(",
"$",
"iniPath",
")",
";",
"$",
"this",
"->",
"info",
"(",
"'Loading custom configuration file: '",
".",
"$",
"iniPath",
",",
"'v'",
")",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"iniPath",
")",
")",
"{",
"$",
"this",
"->",
"warn",
"(",
"sprintf",
"(",
"'File %s does not exist. Custom configuration will not be loaded.'",
",",
"$",
"iniPath",
")",
")",
";",
"}",
"// Append PHP parameter with a path to the configuration file.",
"$",
"command",
".=",
"' -c '",
".",
"$",
"iniPath",
";",
"return",
"$",
"command",
";",
"}"
]
| Adds parameter telling PHP built-in server to respect a custom
php.ini file.
@param string $command Command built up to this point.
@return string | [
"Adds",
"parameter",
"telling",
"PHP",
"built",
"-",
"in",
"server",
"to",
"respect",
"a",
"custom",
"php",
".",
"ini",
"file",
"."
]
| train | https://github.com/mmieluch/laravel-serve-custom-ini/blob/38e547b8496a6123fe63be0901a07fd798537ad7/src/ServeCommand.php#L99-L130 |
mmieluch/laravel-serve-custom-ini | src/ServeCommand.php | ServeCommand.getOptions | protected function getOptions()
{
return [
['host', null, InputOption::VALUE_OPTIONAL, 'The host address to serve the application on.', 'localhost'],
['port', null, InputOption::VALUE_OPTIONAL, 'The port to serve the application on.', 8000],
['ini', null, InputOption::VALUE_NONE, 'Whether to load custom php.ini'],
['ini-path', null, InputOption::VALUE_OPTIONAL, 'Path to custom php.ini file', $this->defaultIniPath],
];
} | php | protected function getOptions()
{
return [
['host', null, InputOption::VALUE_OPTIONAL, 'The host address to serve the application on.', 'localhost'],
['port', null, InputOption::VALUE_OPTIONAL, 'The port to serve the application on.', 8000],
['ini', null, InputOption::VALUE_NONE, 'Whether to load custom php.ini'],
['ini-path', null, InputOption::VALUE_OPTIONAL, 'Path to custom php.ini file', $this->defaultIniPath],
];
} | [
"protected",
"function",
"getOptions",
"(",
")",
"{",
"return",
"[",
"[",
"'host'",
",",
"null",
",",
"InputOption",
"::",
"VALUE_OPTIONAL",
",",
"'The host address to serve the application on.'",
",",
"'localhost'",
"]",
",",
"[",
"'port'",
",",
"null",
",",
"InputOption",
"::",
"VALUE_OPTIONAL",
",",
"'The port to serve the application on.'",
",",
"8000",
"]",
",",
"[",
"'ini'",
",",
"null",
",",
"InputOption",
"::",
"VALUE_NONE",
",",
"'Whether to load custom php.ini'",
"]",
",",
"[",
"'ini-path'",
",",
"null",
",",
"InputOption",
"::",
"VALUE_OPTIONAL",
",",
"'Path to custom php.ini file'",
",",
"$",
"this",
"->",
"defaultIniPath",
"]",
",",
"]",
";",
"}"
]
| Get the console command options.
@return array | [
"Get",
"the",
"console",
"command",
"options",
"."
]
| train | https://github.com/mmieluch/laravel-serve-custom-ini/blob/38e547b8496a6123fe63be0901a07fd798537ad7/src/ServeCommand.php#L137-L148 |
webforge-labs/psc-cms | lib/Psc/UI/Component/Base.php | Base.isBlock | protected function isBlock($componentContent = NULL) {
return $componentContent instanceof \Psc\HTML\Tag &&
$componentContent->getTag() === 'div' ||
$componentContent->getTag() === 'fieldset'
;
} | php | protected function isBlock($componentContent = NULL) {
return $componentContent instanceof \Psc\HTML\Tag &&
$componentContent->getTag() === 'div' ||
$componentContent->getTag() === 'fieldset'
;
} | [
"protected",
"function",
"isBlock",
"(",
"$",
"componentContent",
"=",
"NULL",
")",
"{",
"return",
"$",
"componentContent",
"instanceof",
"\\",
"Psc",
"\\",
"HTML",
"\\",
"Tag",
"&&",
"$",
"componentContent",
"->",
"getTag",
"(",
")",
"===",
"'div'",
"||",
"$",
"componentContent",
"->",
"getTag",
"(",
")",
"===",
"'fieldset'",
";",
"}"
]
| gibt dies TRUE zurück wird z. B. in wrapHTML() kein Umbruch vor dem Hint gemacht
@return bool | [
"gibt",
"dies",
"TRUE",
"zurück",
"wird",
"z",
".",
"B",
".",
"in",
"wrapHTML",
"()",
"kein",
"Umbruch",
"vor",
"dem",
"Hint",
"gemacht"
]
| train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/UI/Component/Base.php#L144-L149 |
yuncms/framework | src/user/migrations/m180223_102734Create_user_table.php | m180223_102734Create_user_table.safeUp | public function safeUp()
{
$tableOptions = null;
if ($this->db->driverName === 'mysql') {
// http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
$tableOptions = 'CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE=InnoDB AUTO_INCREMENT=10000000';
}
$this->createTable($this->tableName, [
'id' => $this->primaryKey()->unsigned()->comment('ID'),
'username' => $this->string(50)->notNull()->unique()->comment('Username'),
'email' => $this->string(64)->unique()->comment('Email'),
'mobile' => $this->string(11)->unique()->comment('Mobile'),
'nickname' => $this->string()->notNull()->comment('Nickname'),
'auth_key' => $this->string(100)->notNull()->comment('Auth Key'),
'password_hash' => $this->string(100)->notNull()->comment('Password Hash'),
'access_token' => $this->string(100)->notNull()->comment('Access Token'),
'avatar' => $this->boolean()->defaultValue(false)->comment('Avatar'),
'unconfirmed_email' => $this->string(150)->comment('Unconfirmed Email'),
'unconfirmed_mobile' => $this->string(11)->comment('Unconfirmed Mobile'),
'registration_ip' => $this->string()->comment('Registration Ip'),
'identified' => $this->boolean()->defaultValue(false)->comment('Identified'),//是否经过实名认证
'balance' => $this->decimal(12, 2)->defaultValue(0),//可提现余额
'transfer_balance' => $this->decimal(12, 2)->defaultValue(0),//未结算余额
'flags' => $this->integer()->defaultValue(0)->comment('Flags'),
'email_confirmed_at' => $this->unixTimestamp()->comment('Email Confirmed At'),
'mobile_confirmed_at' => $this->unixTimestamp()->comment('Mobile Confirmed At'),
'blocked_at' => $this->unixTimestamp()->comment('Blocked At'),
'created_at' => $this->unixTimestamp()->notNull()->comment('Created At'),
'updated_at' => $this->unixTimestamp()->notNull()->comment('Updated At'),
], $tableOptions);
} | php | public function safeUp()
{
$tableOptions = null;
if ($this->db->driverName === 'mysql') {
// http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
$tableOptions = 'CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE=InnoDB AUTO_INCREMENT=10000000';
}
$this->createTable($this->tableName, [
'id' => $this->primaryKey()->unsigned()->comment('ID'),
'username' => $this->string(50)->notNull()->unique()->comment('Username'),
'email' => $this->string(64)->unique()->comment('Email'),
'mobile' => $this->string(11)->unique()->comment('Mobile'),
'nickname' => $this->string()->notNull()->comment('Nickname'),
'auth_key' => $this->string(100)->notNull()->comment('Auth Key'),
'password_hash' => $this->string(100)->notNull()->comment('Password Hash'),
'access_token' => $this->string(100)->notNull()->comment('Access Token'),
'avatar' => $this->boolean()->defaultValue(false)->comment('Avatar'),
'unconfirmed_email' => $this->string(150)->comment('Unconfirmed Email'),
'unconfirmed_mobile' => $this->string(11)->comment('Unconfirmed Mobile'),
'registration_ip' => $this->string()->comment('Registration Ip'),
'identified' => $this->boolean()->defaultValue(false)->comment('Identified'),//是否经过实名认证
'balance' => $this->decimal(12, 2)->defaultValue(0),//可提现余额
'transfer_balance' => $this->decimal(12, 2)->defaultValue(0),//未结算余额
'flags' => $this->integer()->defaultValue(0)->comment('Flags'),
'email_confirmed_at' => $this->unixTimestamp()->comment('Email Confirmed At'),
'mobile_confirmed_at' => $this->unixTimestamp()->comment('Mobile Confirmed At'),
'blocked_at' => $this->unixTimestamp()->comment('Blocked At'),
'created_at' => $this->unixTimestamp()->notNull()->comment('Created At'),
'updated_at' => $this->unixTimestamp()->notNull()->comment('Updated At'),
], $tableOptions);
} | [
"public",
"function",
"safeUp",
"(",
")",
"{",
"$",
"tableOptions",
"=",
"null",
";",
"if",
"(",
"$",
"this",
"->",
"db",
"->",
"driverName",
"===",
"'mysql'",
")",
"{",
"// http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci",
"$",
"tableOptions",
"=",
"'CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE=InnoDB AUTO_INCREMENT=10000000'",
";",
"}",
"$",
"this",
"->",
"createTable",
"(",
"$",
"this",
"->",
"tableName",
",",
"[",
"'id'",
"=>",
"$",
"this",
"->",
"primaryKey",
"(",
")",
"->",
"unsigned",
"(",
")",
"->",
"comment",
"(",
"'ID'",
")",
",",
"'username'",
"=>",
"$",
"this",
"->",
"string",
"(",
"50",
")",
"->",
"notNull",
"(",
")",
"->",
"unique",
"(",
")",
"->",
"comment",
"(",
"'Username'",
")",
",",
"'email'",
"=>",
"$",
"this",
"->",
"string",
"(",
"64",
")",
"->",
"unique",
"(",
")",
"->",
"comment",
"(",
"'Email'",
")",
",",
"'mobile'",
"=>",
"$",
"this",
"->",
"string",
"(",
"11",
")",
"->",
"unique",
"(",
")",
"->",
"comment",
"(",
"'Mobile'",
")",
",",
"'nickname'",
"=>",
"$",
"this",
"->",
"string",
"(",
")",
"->",
"notNull",
"(",
")",
"->",
"comment",
"(",
"'Nickname'",
")",
",",
"'auth_key'",
"=>",
"$",
"this",
"->",
"string",
"(",
"100",
")",
"->",
"notNull",
"(",
")",
"->",
"comment",
"(",
"'Auth Key'",
")",
",",
"'password_hash'",
"=>",
"$",
"this",
"->",
"string",
"(",
"100",
")",
"->",
"notNull",
"(",
")",
"->",
"comment",
"(",
"'Password Hash'",
")",
",",
"'access_token'",
"=>",
"$",
"this",
"->",
"string",
"(",
"100",
")",
"->",
"notNull",
"(",
")",
"->",
"comment",
"(",
"'Access Token'",
")",
",",
"'avatar'",
"=>",
"$",
"this",
"->",
"boolean",
"(",
")",
"->",
"defaultValue",
"(",
"false",
")",
"->",
"comment",
"(",
"'Avatar'",
")",
",",
"'unconfirmed_email'",
"=>",
"$",
"this",
"->",
"string",
"(",
"150",
")",
"->",
"comment",
"(",
"'Unconfirmed Email'",
")",
",",
"'unconfirmed_mobile'",
"=>",
"$",
"this",
"->",
"string",
"(",
"11",
")",
"->",
"comment",
"(",
"'Unconfirmed Mobile'",
")",
",",
"'registration_ip'",
"=>",
"$",
"this",
"->",
"string",
"(",
")",
"->",
"comment",
"(",
"'Registration Ip'",
")",
",",
"'identified'",
"=>",
"$",
"this",
"->",
"boolean",
"(",
")",
"->",
"defaultValue",
"(",
"false",
")",
"->",
"comment",
"(",
"'Identified'",
")",
",",
"//是否经过实名认证",
"'balance'",
"=>",
"$",
"this",
"->",
"decimal",
"(",
"12",
",",
"2",
")",
"->",
"defaultValue",
"(",
"0",
")",
",",
"//可提现余额",
"'transfer_balance'",
"=>",
"$",
"this",
"->",
"decimal",
"(",
"12",
",",
"2",
")",
"->",
"defaultValue",
"(",
"0",
")",
",",
"//未结算余额",
"'flags'",
"=>",
"$",
"this",
"->",
"integer",
"(",
")",
"->",
"defaultValue",
"(",
"0",
")",
"->",
"comment",
"(",
"'Flags'",
")",
",",
"'email_confirmed_at'",
"=>",
"$",
"this",
"->",
"unixTimestamp",
"(",
")",
"->",
"comment",
"(",
"'Email Confirmed At'",
")",
",",
"'mobile_confirmed_at'",
"=>",
"$",
"this",
"->",
"unixTimestamp",
"(",
")",
"->",
"comment",
"(",
"'Mobile Confirmed At'",
")",
",",
"'blocked_at'",
"=>",
"$",
"this",
"->",
"unixTimestamp",
"(",
")",
"->",
"comment",
"(",
"'Blocked At'",
")",
",",
"'created_at'",
"=>",
"$",
"this",
"->",
"unixTimestamp",
"(",
")",
"->",
"notNull",
"(",
")",
"->",
"comment",
"(",
"'Created At'",
")",
",",
"'updated_at'",
"=>",
"$",
"this",
"->",
"unixTimestamp",
"(",
")",
"->",
"notNull",
"(",
")",
"->",
"comment",
"(",
"'Updated At'",
")",
",",
"]",
",",
"$",
"tableOptions",
")",
";",
"}"
]
| {@inheritdoc} | [
"{"
]
| train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/user/migrations/m180223_102734Create_user_table.php#L12-L43 |
webtown-php/KunstmaanExtensionBundle | src/User/UserEditService.php | UserEditService.getChoices | public function getChoices($username = null, $email = null, $or = false, $limit = null)
{
$qb = $this->getRepository()->createQueryBuilder('u');
$qb->orderBy('u.username');
$method = $or ? 'orWhere' : 'andWhere';
if ($username) {
$qb->$method('u.username LIKE :username');
$qb->setParameter('username', '%' . $username . '%');
}
if ($email) {
$qb->$method('u.email LIKE :email');
$qb->setParameter('email', '%' . $email . '%');
}
if ($limit) {
$qb->setMaxResults($limit);
}
return $qb->getQuery()->getResult();
} | php | public function getChoices($username = null, $email = null, $or = false, $limit = null)
{
$qb = $this->getRepository()->createQueryBuilder('u');
$qb->orderBy('u.username');
$method = $or ? 'orWhere' : 'andWhere';
if ($username) {
$qb->$method('u.username LIKE :username');
$qb->setParameter('username', '%' . $username . '%');
}
if ($email) {
$qb->$method('u.email LIKE :email');
$qb->setParameter('email', '%' . $email . '%');
}
if ($limit) {
$qb->setMaxResults($limit);
}
return $qb->getQuery()->getResult();
} | [
"public",
"function",
"getChoices",
"(",
"$",
"username",
"=",
"null",
",",
"$",
"email",
"=",
"null",
",",
"$",
"or",
"=",
"false",
",",
"$",
"limit",
"=",
"null",
")",
"{",
"$",
"qb",
"=",
"$",
"this",
"->",
"getRepository",
"(",
")",
"->",
"createQueryBuilder",
"(",
"'u'",
")",
";",
"$",
"qb",
"->",
"orderBy",
"(",
"'u.username'",
")",
";",
"$",
"method",
"=",
"$",
"or",
"?",
"'orWhere'",
":",
"'andWhere'",
";",
"if",
"(",
"$",
"username",
")",
"{",
"$",
"qb",
"->",
"$",
"method",
"(",
"'u.username LIKE :username'",
")",
";",
"$",
"qb",
"->",
"setParameter",
"(",
"'username'",
",",
"'%'",
".",
"$",
"username",
".",
"'%'",
")",
";",
"}",
"if",
"(",
"$",
"email",
")",
"{",
"$",
"qb",
"->",
"$",
"method",
"(",
"'u.email LIKE :email'",
")",
";",
"$",
"qb",
"->",
"setParameter",
"(",
"'email'",
",",
"'%'",
".",
"$",
"email",
".",
"'%'",
")",
";",
"}",
"if",
"(",
"$",
"limit",
")",
"{",
"$",
"qb",
"->",
"setMaxResults",
"(",
"$",
"limit",
")",
";",
"}",
"return",
"$",
"qb",
"->",
"getQuery",
"(",
")",
"->",
"getResult",
"(",
")",
";",
"}"
]
| Find user choices
@param string $username
@param string $email
@param bool $or combine search params with OR
@param int $limit Limit the number of results
@return array | [
"Find",
"user",
"choices"
]
| train | https://github.com/webtown-php/KunstmaanExtensionBundle/blob/86c656c131295fe1f3f7694fd4da1e5e454076b9/src/User/UserEditService.php#L67-L85 |
webtown-php/KunstmaanExtensionBundle | src/User/UserEditService.php | UserEditService.getChoicesAsEmailUsername | public function getChoicesAsEmailUsername(array &$choices)
{
$ret = [];
foreach ($choices as $item) {
$ret[] = sprintf('%s (%s)', $item->getEmail(), $item->getUsername());
}
return $ret;
} | php | public function getChoicesAsEmailUsername(array &$choices)
{
$ret = [];
foreach ($choices as $item) {
$ret[] = sprintf('%s (%s)', $item->getEmail(), $item->getUsername());
}
return $ret;
} | [
"public",
"function",
"getChoicesAsEmailUsername",
"(",
"array",
"&",
"$",
"choices",
")",
"{",
"$",
"ret",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"choices",
"as",
"$",
"item",
")",
"{",
"$",
"ret",
"[",
"]",
"=",
"sprintf",
"(",
"'%s (%s)'",
",",
"$",
"item",
"->",
"getEmail",
"(",
")",
",",
"$",
"item",
"->",
"getUsername",
"(",
")",
")",
";",
"}",
"return",
"$",
"ret",
";",
"}"
]
| Get selector choices as combined username+email
@param User[] $choices
@return string[] | [
"Get",
"selector",
"choices",
"as",
"combined",
"username",
"+",
"email"
]
| train | https://github.com/webtown-php/KunstmaanExtensionBundle/blob/86c656c131295fe1f3f7694fd4da1e5e454076b9/src/User/UserEditService.php#L94-L102 |
webtown-php/KunstmaanExtensionBundle | src/User/UserEditService.php | UserEditService.getChoicesAsSeparateEmailUsername | public function getChoicesAsSeparateEmailUsername(array &$choices)
{
$ret = [];
foreach ($choices as $item) {
$ret[] = $item->getEmail();
$ret[] = $item->getUsername();
}
return $ret;
} | php | public function getChoicesAsSeparateEmailUsername(array &$choices)
{
$ret = [];
foreach ($choices as $item) {
$ret[] = $item->getEmail();
$ret[] = $item->getUsername();
}
return $ret;
} | [
"public",
"function",
"getChoicesAsSeparateEmailUsername",
"(",
"array",
"&",
"$",
"choices",
")",
"{",
"$",
"ret",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"choices",
"as",
"$",
"item",
")",
"{",
"$",
"ret",
"[",
"]",
"=",
"$",
"item",
"->",
"getEmail",
"(",
")",
";",
"$",
"ret",
"[",
"]",
"=",
"$",
"item",
"->",
"getUsername",
"(",
")",
";",
"}",
"return",
"$",
"ret",
";",
"}"
]
| User choices is separate usernames/email for autocomplete
@param User[] $choices
@return string[] | [
"User",
"choices",
"is",
"separate",
"usernames",
"/",
"email",
"for",
"autocomplete"
]
| train | https://github.com/webtown-php/KunstmaanExtensionBundle/blob/86c656c131295fe1f3f7694fd4da1e5e454076b9/src/User/UserEditService.php#L111-L120 |
webtown-php/KunstmaanExtensionBundle | src/User/UserEditService.php | UserEditService.updateUser | public function updateUser(User $user, UserUpdater $up)
{
$up->updateUser($user, $this->getEncoder());
$em = $this->getRegistry()->getManager();
$em->persist($user);
$em->flush();
} | php | public function updateUser(User $user, UserUpdater $up)
{
$up->updateUser($user, $this->getEncoder());
$em = $this->getRegistry()->getManager();
$em->persist($user);
$em->flush();
} | [
"public",
"function",
"updateUser",
"(",
"User",
"$",
"user",
",",
"UserUpdater",
"$",
"up",
")",
"{",
"$",
"up",
"->",
"updateUser",
"(",
"$",
"user",
",",
"$",
"this",
"->",
"getEncoder",
"(",
")",
")",
";",
"$",
"em",
"=",
"$",
"this",
"->",
"getRegistry",
"(",
")",
"->",
"getManager",
"(",
")",
";",
"$",
"em",
"->",
"persist",
"(",
"$",
"user",
")",
";",
"$",
"em",
"->",
"flush",
"(",
")",
";",
"}"
]
| Update user details
@param User $user
@param UserUpdater $up | [
"Update",
"user",
"details"
]
| train | https://github.com/webtown-php/KunstmaanExtensionBundle/blob/86c656c131295fe1f3f7694fd4da1e5e454076b9/src/User/UserEditService.php#L128-L134 |
djgadd/themosis-illuminate | src/Filesystem/FilesystemServiceProvider.php | FilesystemServiceProvider.registerFlysystem | protected function registerFlysystem()
{
$this->registerManager();
$this->app->singleton('filesystem.disk', function ($app) {
return $app['filesystem']->disk($this->getDefaultDriver());
});
} | php | protected function registerFlysystem()
{
$this->registerManager();
$this->app->singleton('filesystem.disk', function ($app) {
return $app['filesystem']->disk($this->getDefaultDriver());
});
} | [
"protected",
"function",
"registerFlysystem",
"(",
")",
"{",
"$",
"this",
"->",
"registerManager",
"(",
")",
";",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"'filesystem.disk'",
",",
"function",
"(",
"$",
"app",
")",
"{",
"return",
"$",
"app",
"[",
"'filesystem'",
"]",
"->",
"disk",
"(",
"$",
"this",
"->",
"getDefaultDriver",
"(",
")",
")",
";",
"}",
")",
";",
"}"
]
| Register the driver based filesystem.
@return void | [
"Register",
"the",
"driver",
"based",
"filesystem",
"."
]
| train | https://github.com/djgadd/themosis-illuminate/blob/13ee4c3413cddd85a2f262ac361f35c81da0c53c/src/Filesystem/FilesystemServiceProvider.php#L39-L46 |
iocaste/microservice-foundation | src/Command/PostUpdate.php | PostUpdate.handle | public function handle()
{
$consoleKernel = app(\Illuminate\Contracts\Console\Kernel::class);
$consoleKernel->call('laradox:transform');
if (app()->environment() !== 'production') {
$consoleKernel->call('ide-helper:generate');
$consoleKernel->call('ide-helper:models', ['-q']);
$consoleKernel->call('ide-helper:meta');
}
if (isset($consoleKernel->all()['data-structure:generate'])) {
$consoleKernel->call('data-structure:generate');
}
} | php | public function handle()
{
$consoleKernel = app(\Illuminate\Contracts\Console\Kernel::class);
$consoleKernel->call('laradox:transform');
if (app()->environment() !== 'production') {
$consoleKernel->call('ide-helper:generate');
$consoleKernel->call('ide-helper:models', ['-q']);
$consoleKernel->call('ide-helper:meta');
}
if (isset($consoleKernel->all()['data-structure:generate'])) {
$consoleKernel->call('data-structure:generate');
}
} | [
"public",
"function",
"handle",
"(",
")",
"{",
"$",
"consoleKernel",
"=",
"app",
"(",
"\\",
"Illuminate",
"\\",
"Contracts",
"\\",
"Console",
"\\",
"Kernel",
"::",
"class",
")",
";",
"$",
"consoleKernel",
"->",
"call",
"(",
"'laradox:transform'",
")",
";",
"if",
"(",
"app",
"(",
")",
"->",
"environment",
"(",
")",
"!==",
"'production'",
")",
"{",
"$",
"consoleKernel",
"->",
"call",
"(",
"'ide-helper:generate'",
")",
";",
"$",
"consoleKernel",
"->",
"call",
"(",
"'ide-helper:models'",
",",
"[",
"'-q'",
"]",
")",
";",
"$",
"consoleKernel",
"->",
"call",
"(",
"'ide-helper:meta'",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"consoleKernel",
"->",
"all",
"(",
")",
"[",
"'data-structure:generate'",
"]",
")",
")",
"{",
"$",
"consoleKernel",
"->",
"call",
"(",
"'data-structure:generate'",
")",
";",
"}",
"}"
]
| Execute the console command.
@return void | [
"Execute",
"the",
"console",
"command",
"."
]
| train | https://github.com/iocaste/microservice-foundation/blob/274a154de4299e8a57314bab972e09f6d8cdae9e/src/Command/PostUpdate.php#L29-L44 |
Double-Opt-in/php-client-api | src/Guzzle/Plugin/AccessTokenCache.php | AccessTokenCache.get | public function get()
{
if ( ! file_exists($this->file))
return array();
$data = unserialize(base64_decode(file_get_contents($this->file)));
return $data ?: array();
} | php | public function get()
{
if ( ! file_exists($this->file))
return array();
$data = unserialize(base64_decode(file_get_contents($this->file)));
return $data ?: array();
} | [
"public",
"function",
"get",
"(",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"this",
"->",
"file",
")",
")",
"return",
"array",
"(",
")",
";",
"$",
"data",
"=",
"unserialize",
"(",
"base64_decode",
"(",
"file_get_contents",
"(",
"$",
"this",
"->",
"file",
")",
")",
")",
";",
"return",
"$",
"data",
"?",
":",
"array",
"(",
")",
";",
"}"
]
| returns the cached access token
@return array | [
"returns",
"the",
"cached",
"access",
"token"
]
| train | https://github.com/Double-Opt-in/php-client-api/blob/2f17da58ec20a408bbd55b2cdd053bc689f995f4/src/Guzzle/Plugin/AccessTokenCache.php#L32-L40 |
Double-Opt-in/php-client-api | src/Guzzle/Plugin/AccessTokenCache.php | AccessTokenCache.put | public function put($accessToken)
{
if ($accessToken === null)
return unlink($this->file);
file_put_contents($this->file, base64_encode(serialize($accessToken)));
return file_exists($this->file);
} | php | public function put($accessToken)
{
if ($accessToken === null)
return unlink($this->file);
file_put_contents($this->file, base64_encode(serialize($accessToken)));
return file_exists($this->file);
} | [
"public",
"function",
"put",
"(",
"$",
"accessToken",
")",
"{",
"if",
"(",
"$",
"accessToken",
"===",
"null",
")",
"return",
"unlink",
"(",
"$",
"this",
"->",
"file",
")",
";",
"file_put_contents",
"(",
"$",
"this",
"->",
"file",
",",
"base64_encode",
"(",
"serialize",
"(",
"$",
"accessToken",
")",
")",
")",
";",
"return",
"file_exists",
"(",
"$",
"this",
"->",
"file",
")",
";",
"}"
]
| store the access token
@param array $accessToken
@return bool | [
"store",
"the",
"access",
"token"
]
| train | https://github.com/Double-Opt-in/php-client-api/blob/2f17da58ec20a408bbd55b2cdd053bc689f995f4/src/Guzzle/Plugin/AccessTokenCache.php#L49-L57 |
ClanCats/Core | src/bundles/Database/Model.php | Model._prepare | protected static function _prepare( $settings, $class )
{
$settings = parent::_prepare( $settings, $class );
// Next step the table name. If not set we use the
// class name appending an 's' in the hope that it
// makes sense like Model_User = users
if ( property_exists( $class, '_table') )
{
$settings['table'] = static::$_table;
}
else
{
$settings['table'] = strtolower( $class );
$settings['table'] = explode( "\\", $settings['table'] );
$last = array_pop( $settings['table'] );
// Often we have these model's in the Model folder, we
// don't want this in the table name so we cut it out.
if ( substr( $last, 0, strlen( 'model_' ) ) == 'model_' )
{
$last = substr( $last, strlen( 'model_' ) );
}
$settings['table'][] = $last;
$settings['table'] = implode( '_', $settings['table'] ).'s';
}
// Next we would like to know the primary key used
// in this model for saving, finding etc.. if not set
// we use the on configured in the main configuration
if ( property_exists( $class, '_primary_key') )
{
$settings['primary_key'] = static::$_primary_key;
}
else
{
$settings['primary_key'] = \ClanCats::$config->get( 'database.default_primary_key', 'id' );
}
// Do we should use a special DB handler?
if ( property_exists( $class, '_handler') )
{
$settings['handler'] = static::$_handler;
}
else
{
$settings['handler'] = null;
}
// The find modifier allows you hijack every find executed
// on your model an pass setting's to the query. This allows
// you for example to defaultly order by something etc.
if ( property_exists( $class, '_find_modifier') )
{
$settings['find_modifier'] = static::$_find_modifier;
}
else
{
$settings['find_modifier'] = null;
}
// Enabling this options will set the created_at
// and modified at property on save
if ( property_exists( $class, '_timestamps') )
{
$settings['timestamps'] = (bool) static::$_timestamps;
}
else
{
$settings['timestamps'] = false;
}
return $settings;
} | php | protected static function _prepare( $settings, $class )
{
$settings = parent::_prepare( $settings, $class );
// Next step the table name. If not set we use the
// class name appending an 's' in the hope that it
// makes sense like Model_User = users
if ( property_exists( $class, '_table') )
{
$settings['table'] = static::$_table;
}
else
{
$settings['table'] = strtolower( $class );
$settings['table'] = explode( "\\", $settings['table'] );
$last = array_pop( $settings['table'] );
// Often we have these model's in the Model folder, we
// don't want this in the table name so we cut it out.
if ( substr( $last, 0, strlen( 'model_' ) ) == 'model_' )
{
$last = substr( $last, strlen( 'model_' ) );
}
$settings['table'][] = $last;
$settings['table'] = implode( '_', $settings['table'] ).'s';
}
// Next we would like to know the primary key used
// in this model for saving, finding etc.. if not set
// we use the on configured in the main configuration
if ( property_exists( $class, '_primary_key') )
{
$settings['primary_key'] = static::$_primary_key;
}
else
{
$settings['primary_key'] = \ClanCats::$config->get( 'database.default_primary_key', 'id' );
}
// Do we should use a special DB handler?
if ( property_exists( $class, '_handler') )
{
$settings['handler'] = static::$_handler;
}
else
{
$settings['handler'] = null;
}
// The find modifier allows you hijack every find executed
// on your model an pass setting's to the query. This allows
// you for example to defaultly order by something etc.
if ( property_exists( $class, '_find_modifier') )
{
$settings['find_modifier'] = static::$_find_modifier;
}
else
{
$settings['find_modifier'] = null;
}
// Enabling this options will set the created_at
// and modified at property on save
if ( property_exists( $class, '_timestamps') )
{
$settings['timestamps'] = (bool) static::$_timestamps;
}
else
{
$settings['timestamps'] = false;
}
return $settings;
} | [
"protected",
"static",
"function",
"_prepare",
"(",
"$",
"settings",
",",
"$",
"class",
")",
"{",
"$",
"settings",
"=",
"parent",
"::",
"_prepare",
"(",
"$",
"settings",
",",
"$",
"class",
")",
";",
"// Next step the table name. If not set we use the ",
"// class name appending an 's' in the hope that it ",
"// makes sense like Model_User = users",
"if",
"(",
"property_exists",
"(",
"$",
"class",
",",
"'_table'",
")",
")",
"{",
"$",
"settings",
"[",
"'table'",
"]",
"=",
"static",
"::",
"$",
"_table",
";",
"}",
"else",
"{",
"$",
"settings",
"[",
"'table'",
"]",
"=",
"strtolower",
"(",
"$",
"class",
")",
";",
"$",
"settings",
"[",
"'table'",
"]",
"=",
"explode",
"(",
"\"\\\\\"",
",",
"$",
"settings",
"[",
"'table'",
"]",
")",
";",
"$",
"last",
"=",
"array_pop",
"(",
"$",
"settings",
"[",
"'table'",
"]",
")",
";",
"// Often we have these model's in the Model folder, we ",
"// don't want this in the table name so we cut it out.",
"if",
"(",
"substr",
"(",
"$",
"last",
",",
"0",
",",
"strlen",
"(",
"'model_'",
")",
")",
"==",
"'model_'",
")",
"{",
"$",
"last",
"=",
"substr",
"(",
"$",
"last",
",",
"strlen",
"(",
"'model_'",
")",
")",
";",
"}",
"$",
"settings",
"[",
"'table'",
"]",
"[",
"]",
"=",
"$",
"last",
";",
"$",
"settings",
"[",
"'table'",
"]",
"=",
"implode",
"(",
"'_'",
",",
"$",
"settings",
"[",
"'table'",
"]",
")",
".",
"'s'",
";",
"}",
"// Next we would like to know the primary key used",
"// in this model for saving, finding etc.. if not set",
"// we use the on configured in the main configuration",
"if",
"(",
"property_exists",
"(",
"$",
"class",
",",
"'_primary_key'",
")",
")",
"{",
"$",
"settings",
"[",
"'primary_key'",
"]",
"=",
"static",
"::",
"$",
"_primary_key",
";",
"}",
"else",
"{",
"$",
"settings",
"[",
"'primary_key'",
"]",
"=",
"\\",
"ClanCats",
"::",
"$",
"config",
"->",
"get",
"(",
"'database.default_primary_key'",
",",
"'id'",
")",
";",
"}",
"// Do we should use a special DB handler?",
"if",
"(",
"property_exists",
"(",
"$",
"class",
",",
"'_handler'",
")",
")",
"{",
"$",
"settings",
"[",
"'handler'",
"]",
"=",
"static",
"::",
"$",
"_handler",
";",
"}",
"else",
"{",
"$",
"settings",
"[",
"'handler'",
"]",
"=",
"null",
";",
"}",
"// The find modifier allows you hijack every find executed",
"// on your model an pass setting's to the query. This allows",
"// you for example to defaultly order by something etc.",
"if",
"(",
"property_exists",
"(",
"$",
"class",
",",
"'_find_modifier'",
")",
")",
"{",
"$",
"settings",
"[",
"'find_modifier'",
"]",
"=",
"static",
"::",
"$",
"_find_modifier",
";",
"}",
"else",
"{",
"$",
"settings",
"[",
"'find_modifier'",
"]",
"=",
"null",
";",
"}",
"// Enabling this options will set the created_at",
"// and modified at property on save",
"if",
"(",
"property_exists",
"(",
"$",
"class",
",",
"'_timestamps'",
")",
")",
"{",
"$",
"settings",
"[",
"'timestamps'",
"]",
"=",
"(",
"bool",
")",
"static",
"::",
"$",
"_timestamps",
";",
"}",
"else",
"{",
"$",
"settings",
"[",
"'timestamps'",
"]",
"=",
"false",
";",
"}",
"return",
"$",
"settings",
";",
"}"
]
| Prepare the model
@param string $settings The model properties
@param string $class The class name.
@return array | [
"Prepare",
"the",
"model"
]
| train | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Database/Model.php#L41-L118 |
ClanCats/Core | src/bundles/Database/Model.php | Model._fetch_handler | public static function _fetch_handler( &$query )
{
// because the model is an object we force the fetch
// arguments to obj so that we can still make use of
// the group by and forward key functions
$query->fetch_arguments = array( 'obj' );
// Run the query and assign the reults
// here we force the fetch arguments to assoc
// without this step model::assign will fail
return static::assign( $query->handler->fetch( $query->build(), $query->handler->builder()->parameters, array( 'assoc' ) ) );
} | php | public static function _fetch_handler( &$query )
{
// because the model is an object we force the fetch
// arguments to obj so that we can still make use of
// the group by and forward key functions
$query->fetch_arguments = array( 'obj' );
// Run the query and assign the reults
// here we force the fetch arguments to assoc
// without this step model::assign will fail
return static::assign( $query->handler->fetch( $query->build(), $query->handler->builder()->parameters, array( 'assoc' ) ) );
} | [
"public",
"static",
"function",
"_fetch_handler",
"(",
"&",
"$",
"query",
")",
"{",
"// because the model is an object we force the fetch",
"// arguments to obj so that we can still make use of",
"// the group by and forward key functions",
"$",
"query",
"->",
"fetch_arguments",
"=",
"array",
"(",
"'obj'",
")",
";",
"// Run the query and assign the reults",
"// here we force the fetch arguments to assoc ",
"// without this step model::assign will fail",
"return",
"static",
"::",
"assign",
"(",
"$",
"query",
"->",
"handler",
"->",
"fetch",
"(",
"$",
"query",
"->",
"build",
"(",
")",
",",
"$",
"query",
"->",
"handler",
"->",
"builder",
"(",
")",
"->",
"parameters",
",",
"array",
"(",
"'assoc'",
")",
")",
")",
";",
"}"
]
| Fetch from the databse and created models out of the reults
@param DB\Query_Select $query
@return array | [
"Fetch",
"from",
"the",
"databse",
"and",
"created",
"models",
"out",
"of",
"the",
"reults"
]
| train | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Database/Model.php#L126-L137 |
ClanCats/Core | src/bundles/Database/Model.php | Model.find | public static function find( $param = null, $param2 = null )
{
$settings = static::_model();
$query = DB::select( $settings['table'] );
// Do we have a find modifier?
if ( !is_null( $settings['find_modifier'] ) )
{
$callbacks = $settings['find_modifier'];
if ( !\CCArr::is_collection( $callbacks ) )
{
$callbacks = array( $callbacks );
}
foreach( $callbacks as $call )
{
if ( is_callable( $call ) )
{
call_user_func_array( $call, array( &$query ) );
}
else
{
throw new ModelException( "Invalid Callback given to find modifiers." );
}
}
}
if ( !is_null( $param ) )
{
// Check if paramert 1 is a valid callback and not a string.
// Strings as function callback are not possible because
// the user might want to search by key like:
// Model::find( 'key', 'type' );
if ( is_callable( $param ) && !is_string( $param ) )
{
call_user_func_array( $param, array( &$query ) );
}
// When no param 2 isset we try to find the record by primary key
elseif ( is_null( $param2 ) )
{
$query->where( $settings['table'].'.'.$settings['primary_key'], $param )
->limit(1);
}
// When param one and two isset we try to find the record by
// the given key and value.
elseif ( !is_null( $param2 ) )
{
$query->where( $param, $param2 )
->limit(1);
}
}
// alway group the result
$query->forward_key( $settings['primary_key'] );
// and we have to fetch assoc
$query->fetch_arguments = array( 'assoc' );
// and assign
return static::assign( $query->run() );
} | php | public static function find( $param = null, $param2 = null )
{
$settings = static::_model();
$query = DB::select( $settings['table'] );
// Do we have a find modifier?
if ( !is_null( $settings['find_modifier'] ) )
{
$callbacks = $settings['find_modifier'];
if ( !\CCArr::is_collection( $callbacks ) )
{
$callbacks = array( $callbacks );
}
foreach( $callbacks as $call )
{
if ( is_callable( $call ) )
{
call_user_func_array( $call, array( &$query ) );
}
else
{
throw new ModelException( "Invalid Callback given to find modifiers." );
}
}
}
if ( !is_null( $param ) )
{
// Check if paramert 1 is a valid callback and not a string.
// Strings as function callback are not possible because
// the user might want to search by key like:
// Model::find( 'key', 'type' );
if ( is_callable( $param ) && !is_string( $param ) )
{
call_user_func_array( $param, array( &$query ) );
}
// When no param 2 isset we try to find the record by primary key
elseif ( is_null( $param2 ) )
{
$query->where( $settings['table'].'.'.$settings['primary_key'], $param )
->limit(1);
}
// When param one and two isset we try to find the record by
// the given key and value.
elseif ( !is_null( $param2 ) )
{
$query->where( $param, $param2 )
->limit(1);
}
}
// alway group the result
$query->forward_key( $settings['primary_key'] );
// and we have to fetch assoc
$query->fetch_arguments = array( 'assoc' );
// and assign
return static::assign( $query->run() );
} | [
"public",
"static",
"function",
"find",
"(",
"$",
"param",
"=",
"null",
",",
"$",
"param2",
"=",
"null",
")",
"{",
"$",
"settings",
"=",
"static",
"::",
"_model",
"(",
")",
";",
"$",
"query",
"=",
"DB",
"::",
"select",
"(",
"$",
"settings",
"[",
"'table'",
"]",
")",
";",
"// Do we have a find modifier?",
"if",
"(",
"!",
"is_null",
"(",
"$",
"settings",
"[",
"'find_modifier'",
"]",
")",
")",
"{",
"$",
"callbacks",
"=",
"$",
"settings",
"[",
"'find_modifier'",
"]",
";",
"if",
"(",
"!",
"\\",
"CCArr",
"::",
"is_collection",
"(",
"$",
"callbacks",
")",
")",
"{",
"$",
"callbacks",
"=",
"array",
"(",
"$",
"callbacks",
")",
";",
"}",
"foreach",
"(",
"$",
"callbacks",
"as",
"$",
"call",
")",
"{",
"if",
"(",
"is_callable",
"(",
"$",
"call",
")",
")",
"{",
"call_user_func_array",
"(",
"$",
"call",
",",
"array",
"(",
"&",
"$",
"query",
")",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"ModelException",
"(",
"\"Invalid Callback given to find modifiers.\"",
")",
";",
"}",
"}",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"param",
")",
")",
"{",
"// Check if paramert 1 is a valid callback and not a string.",
"// Strings as function callback are not possible because",
"// the user might want to search by key like:",
"// Model::find( 'key', 'type' );",
"if",
"(",
"is_callable",
"(",
"$",
"param",
")",
"&&",
"!",
"is_string",
"(",
"$",
"param",
")",
")",
"{",
"call_user_func_array",
"(",
"$",
"param",
",",
"array",
"(",
"&",
"$",
"query",
")",
")",
";",
"}",
"// When no param 2 isset we try to find the record by primary key",
"elseif",
"(",
"is_null",
"(",
"$",
"param2",
")",
")",
"{",
"$",
"query",
"->",
"where",
"(",
"$",
"settings",
"[",
"'table'",
"]",
".",
"'.'",
".",
"$",
"settings",
"[",
"'primary_key'",
"]",
",",
"$",
"param",
")",
"->",
"limit",
"(",
"1",
")",
";",
"}",
"// When param one and two isset we try to find the record by",
"// the given key and value.",
"elseif",
"(",
"!",
"is_null",
"(",
"$",
"param2",
")",
")",
"{",
"$",
"query",
"->",
"where",
"(",
"$",
"param",
",",
"$",
"param2",
")",
"->",
"limit",
"(",
"1",
")",
";",
"}",
"}",
"// alway group the result",
"$",
"query",
"->",
"forward_key",
"(",
"$",
"settings",
"[",
"'primary_key'",
"]",
")",
";",
"// and we have to fetch assoc",
"$",
"query",
"->",
"fetch_arguments",
"=",
"array",
"(",
"'assoc'",
")",
";",
"// and assign",
"return",
"static",
"::",
"assign",
"(",
"$",
"query",
"->",
"run",
"(",
")",
")",
";",
"}"
]
| Model finder
This function allows you direct access to your records.
@param mixed $param
@param mixed $param2
@return CCModel | [
"Model",
"finder",
"This",
"function",
"allows",
"you",
"direct",
"access",
"to",
"your",
"records",
"."
]
| train | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Database/Model.php#L157-L219 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.