id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
list | docstring
stringlengths 3
47.2k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 91
247
|
---|---|---|---|---|---|---|---|---|---|---|---|
17,100 | steeffeen/FancyManiaLinks | FML/Script/Features/Toggle.php | Toggle.setOnlyHide | public function setOnlyHide($onlyHide)
{
$this->onlyHide = (bool)$onlyHide;
if ($this->onlyHide) {
$this->onlyShow = null;
}
return $this;
} | php | public function setOnlyHide($onlyHide)
{
$this->onlyHide = (bool)$onlyHide;
if ($this->onlyHide) {
$this->onlyShow = null;
}
return $this;
} | [
"public",
"function",
"setOnlyHide",
"(",
"$",
"onlyHide",
")",
"{",
"$",
"this",
"->",
"onlyHide",
"=",
"(",
"bool",
")",
"$",
"onlyHide",
";",
"if",
"(",
"$",
"this",
"->",
"onlyHide",
")",
"{",
"$",
"this",
"->",
"onlyShow",
"=",
"null",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Set Hide Only
@api
@param bool $onlyHide If it should only hide the Control but not toggle
@return static | [
"Set",
"Hide",
"Only"
]
| 227b0759306f0a3c75873ba50276e4163a93bfa6 | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Script/Features/Toggle.php#L202-L209 |
17,101 | webforge-labs/psc-cms | lib/Psc/Net/HTTP/RequestHandler.php | RequestHandler.dumpRequest | protected function dumpRequest(Request $request) {
$body = $request->getBody();
$dump = "Body of request is:\n";
if (is_object($body) || is_array($body)) {
$dump .= json_encode($body);
} elseif(is_string($body)) {
$dump .= sprintf('"%s"',$body);
}
return $dump;
} | php | protected function dumpRequest(Request $request) {
$body = $request->getBody();
$dump = "Body of request is:\n";
if (is_object($body) || is_array($body)) {
$dump .= json_encode($body);
} elseif(is_string($body)) {
$dump .= sprintf('"%s"',$body);
}
return $dump;
} | [
"protected",
"function",
"dumpRequest",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"body",
"=",
"$",
"request",
"->",
"getBody",
"(",
")",
";",
"$",
"dump",
"=",
"\"Body of request is:\\n\"",
";",
"if",
"(",
"is_object",
"(",
"$",
"body",
")",
"||",
"is_array",
"(",
"$",
"body",
")",
")",
"{",
"$",
"dump",
".=",
"json_encode",
"(",
"$",
"body",
")",
";",
"}",
"elseif",
"(",
"is_string",
"(",
"$",
"body",
")",
")",
"{",
"$",
"dump",
".=",
"sprintf",
"(",
"'\"%s\"'",
",",
"$",
"body",
")",
";",
"}",
"return",
"$",
"dump",
";",
"}"
]
| returns a importable string representation of the request
@return string | [
"returns",
"a",
"importable",
"string",
"representation",
"of",
"the",
"request"
]
| 467bfa2547e6b4fa487d2d7f35fa6cc618dbc763 | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Net/HTTP/RequestHandler.php#L317-L329 |
17,102 | CakeCMS/Core | src/View/Widget/MaterializeCss/FileWidget.php | FileWidget.render | public function render(array $data, ContextInterface $context)
{
$data += [
'name' => '',
'templateVars' => [],
'escape' => true
];
unset($data['val']);
$title = (Arr::key('title', $data)) ? $data['title'] : $data['name'];
return $this->_templates->format('file', [
'title' => $title,
'name' => $data['name'],
'templateVars' => $data['templateVars'],
'attrs' => $this->_templates->formatAttributes($data, ['name'])
]);
} | php | public function render(array $data, ContextInterface $context)
{
$data += [
'name' => '',
'templateVars' => [],
'escape' => true
];
unset($data['val']);
$title = (Arr::key('title', $data)) ? $data['title'] : $data['name'];
return $this->_templates->format('file', [
'title' => $title,
'name' => $data['name'],
'templateVars' => $data['templateVars'],
'attrs' => $this->_templates->formatAttributes($data, ['name'])
]);
} | [
"public",
"function",
"render",
"(",
"array",
"$",
"data",
",",
"ContextInterface",
"$",
"context",
")",
"{",
"$",
"data",
"+=",
"[",
"'name'",
"=>",
"''",
",",
"'templateVars'",
"=>",
"[",
"]",
",",
"'escape'",
"=>",
"true",
"]",
";",
"unset",
"(",
"$",
"data",
"[",
"'val'",
"]",
")",
";",
"$",
"title",
"=",
"(",
"Arr",
"::",
"key",
"(",
"'title'",
",",
"$",
"data",
")",
")",
"?",
"$",
"data",
"[",
"'title'",
"]",
":",
"$",
"data",
"[",
"'name'",
"]",
";",
"return",
"$",
"this",
"->",
"_templates",
"->",
"format",
"(",
"'file'",
",",
"[",
"'title'",
"=>",
"$",
"title",
",",
"'name'",
"=>",
"$",
"data",
"[",
"'name'",
"]",
",",
"'templateVars'",
"=>",
"$",
"data",
"[",
"'templateVars'",
"]",
",",
"'attrs'",
"=>",
"$",
"this",
"->",
"_templates",
"->",
"formatAttributes",
"(",
"$",
"data",
",",
"[",
"'name'",
"]",
")",
"]",
")",
";",
"}"
]
| Render a file upload form widget.
Data supports the following keys:
- `name` - Set the input name.
- `escape` - Set to false to disable HTML escaping.
All other keys will be converted into HTML attributes.
Unlike other input objects the `val` property will be specifically
ignored.
@param array $data The data to build a file input with.
@param \Cake\View\Form\ContextInterface $context The current form context.
@return string HTML elements. | [
"Render",
"a",
"file",
"upload",
"form",
"widget",
"."
]
| f9cba7aa0043a10e5c35bd45fbad158688a09a96 | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Widget/MaterializeCss/FileWidget.php#L47-L65 |
17,103 | drsdre/yii2-xmlsoccer | models/Team.php | Team.getMatches | public function getMatches()
{
$matches = ArrayHelper::merge($this->homeMatches, $this->awayMatches);
ArrayHelper::multisort($matches, 'date', SORT_ASC);
return $matches;
} | php | public function getMatches()
{
$matches = ArrayHelper::merge($this->homeMatches, $this->awayMatches);
ArrayHelper::multisort($matches, 'date', SORT_ASC);
return $matches;
} | [
"public",
"function",
"getMatches",
"(",
")",
"{",
"$",
"matches",
"=",
"ArrayHelper",
"::",
"merge",
"(",
"$",
"this",
"->",
"homeMatches",
",",
"$",
"this",
"->",
"awayMatches",
")",
";",
"ArrayHelper",
"::",
"multisort",
"(",
"$",
"matches",
",",
"'date'",
",",
"SORT_ASC",
")",
";",
"return",
"$",
"matches",
";",
"}"
]
| Get all matches
@return array | [
"Get",
"all",
"matches"
]
| a746edee6269ed0791bac6c6165a946adc30d994 | https://github.com/drsdre/yii2-xmlsoccer/blob/a746edee6269ed0791bac6c6165a946adc30d994/models/Team.php#L96-L101 |
17,104 | anime-db/app-bundle | src/Controller/NoticeController.php | NoticeController.showAction | public function showAction(Request $request)
{
$em = $this->getDoctrine()->getManager();
/* @var $rep NoticeRepository */
$rep = $em->getRepository('AnimeDbAppBundle:Notice');
$notice = $rep->getFirstShow();
// caching
/* @var $response JsonResponse */
$response = $this->getCacheTimeKeeper()->getResponse([], -1, new JsonResponse());
$response->setEtag(md5($notice ? $notice->getId() : 0));
// response was not modified for this request
if ($response->isNotModified($request)) {
return $response;
}
// shown notice
if (!is_null($notice)) {
$notice->shown();
$em->persist($notice);
$em->flush();
$response->setData([
'notice' => $notice->getId(),
'close' => $this->generateUrl('notice_close', ['id' => $notice->getId()]),
'see_later' => $this->generateUrl('notice_see_later'),
'content' => $this->renderView('AnimeDbAppBundle:Notice:show.html.twig', [
'notice' => $notice,
'link_all' => $request->query->getBoolean('all'),
]),
]);
}
return $response;
} | php | public function showAction(Request $request)
{
$em = $this->getDoctrine()->getManager();
/* @var $rep NoticeRepository */
$rep = $em->getRepository('AnimeDbAppBundle:Notice');
$notice = $rep->getFirstShow();
// caching
/* @var $response JsonResponse */
$response = $this->getCacheTimeKeeper()->getResponse([], -1, new JsonResponse());
$response->setEtag(md5($notice ? $notice->getId() : 0));
// response was not modified for this request
if ($response->isNotModified($request)) {
return $response;
}
// shown notice
if (!is_null($notice)) {
$notice->shown();
$em->persist($notice);
$em->flush();
$response->setData([
'notice' => $notice->getId(),
'close' => $this->generateUrl('notice_close', ['id' => $notice->getId()]),
'see_later' => $this->generateUrl('notice_see_later'),
'content' => $this->renderView('AnimeDbAppBundle:Notice:show.html.twig', [
'notice' => $notice,
'link_all' => $request->query->getBoolean('all'),
]),
]);
}
return $response;
} | [
"public",
"function",
"showAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getManager",
"(",
")",
";",
"/* @var $rep NoticeRepository */",
"$",
"rep",
"=",
"$",
"em",
"->",
"getRepository",
"(",
"'AnimeDbAppBundle:Notice'",
")",
";",
"$",
"notice",
"=",
"$",
"rep",
"->",
"getFirstShow",
"(",
")",
";",
"// caching",
"/* @var $response JsonResponse */",
"$",
"response",
"=",
"$",
"this",
"->",
"getCacheTimeKeeper",
"(",
")",
"->",
"getResponse",
"(",
"[",
"]",
",",
"-",
"1",
",",
"new",
"JsonResponse",
"(",
")",
")",
";",
"$",
"response",
"->",
"setEtag",
"(",
"md5",
"(",
"$",
"notice",
"?",
"$",
"notice",
"->",
"getId",
"(",
")",
":",
"0",
")",
")",
";",
"// response was not modified for this request",
"if",
"(",
"$",
"response",
"->",
"isNotModified",
"(",
"$",
"request",
")",
")",
"{",
"return",
"$",
"response",
";",
"}",
"// shown notice",
"if",
"(",
"!",
"is_null",
"(",
"$",
"notice",
")",
")",
"{",
"$",
"notice",
"->",
"shown",
"(",
")",
";",
"$",
"em",
"->",
"persist",
"(",
"$",
"notice",
")",
";",
"$",
"em",
"->",
"flush",
"(",
")",
";",
"$",
"response",
"->",
"setData",
"(",
"[",
"'notice'",
"=>",
"$",
"notice",
"->",
"getId",
"(",
")",
",",
"'close'",
"=>",
"$",
"this",
"->",
"generateUrl",
"(",
"'notice_close'",
",",
"[",
"'id'",
"=>",
"$",
"notice",
"->",
"getId",
"(",
")",
"]",
")",
",",
"'see_later'",
"=>",
"$",
"this",
"->",
"generateUrl",
"(",
"'notice_see_later'",
")",
",",
"'content'",
"=>",
"$",
"this",
"->",
"renderView",
"(",
"'AnimeDbAppBundle:Notice:show.html.twig'",
",",
"[",
"'notice'",
"=>",
"$",
"notice",
",",
"'link_all'",
"=>",
"$",
"request",
"->",
"query",
"->",
"getBoolean",
"(",
"'all'",
")",
",",
"]",
")",
",",
"]",
")",
";",
"}",
"return",
"$",
"response",
";",
"}"
]
| Show last notice.
@param Request $request
@return JsonResponse | [
"Show",
"last",
"notice",
"."
]
| ca3b342081719d41ba018792a75970cbb1f1fe22 | https://github.com/anime-db/app-bundle/blob/ca3b342081719d41ba018792a75970cbb1f1fe22/src/Controller/NoticeController.php#L25-L59 |
17,105 | flipboxstudio/orm-manager | src/Flipbox/OrmManager/BothRelations/ManyToMany.php | ManyToMany.setConnectedRelationOptions | protected function setConnectedRelationOptions()
{
$pivotTable = $this->defaultOptions['pivot_table'];
$foreignKey = $this->defaultOptions['foreign_key'];
$relatedKey = $this->defaultOptions['related_key'];
if (! $this->db->isTableExists($pivotTable)) {
$question = "Can't find table {$this->text['pivot_table']} in the database as {$this->text['pivot_text']}, choice one!";
$pivotTable = $this->options['pivot_table'] = $this->command->choice(
$question, $this->getTables());
$this->text['pivot_table'] = "[".$this->command->paintString($pivotTable, 'green')."]";
}
if (! $this->db->isFieldExists($pivotTable, $foreignKey)) {
$question = "Can't find field {$this->text['foreign_key']} in the table {$this->text['pivot_table']} as {$this->text['foreign_text']} of table {$this->text['table']}, choice one!";
$this->options['foreign_key'] = $this->command->choice($question, $this->getFields($pivotTable));
}
if (! $this->db->isFieldExists($pivotTable, $relatedKey)) {
$question = "Can't find field {$this->text['related_key']} in the table {$this->text['pivot_table']} as {$this->text['related_text']} of table {$this->text['to_table']}, choice one!";
$this->options['related_key'] = $this->command->choice($question, $this->getFields($pivotTable));
}
} | php | protected function setConnectedRelationOptions()
{
$pivotTable = $this->defaultOptions['pivot_table'];
$foreignKey = $this->defaultOptions['foreign_key'];
$relatedKey = $this->defaultOptions['related_key'];
if (! $this->db->isTableExists($pivotTable)) {
$question = "Can't find table {$this->text['pivot_table']} in the database as {$this->text['pivot_text']}, choice one!";
$pivotTable = $this->options['pivot_table'] = $this->command->choice(
$question, $this->getTables());
$this->text['pivot_table'] = "[".$this->command->paintString($pivotTable, 'green')."]";
}
if (! $this->db->isFieldExists($pivotTable, $foreignKey)) {
$question = "Can't find field {$this->text['foreign_key']} in the table {$this->text['pivot_table']} as {$this->text['foreign_text']} of table {$this->text['table']}, choice one!";
$this->options['foreign_key'] = $this->command->choice($question, $this->getFields($pivotTable));
}
if (! $this->db->isFieldExists($pivotTable, $relatedKey)) {
$question = "Can't find field {$this->text['related_key']} in the table {$this->text['pivot_table']} as {$this->text['related_text']} of table {$this->text['to_table']}, choice one!";
$this->options['related_key'] = $this->command->choice($question, $this->getFields($pivotTable));
}
} | [
"protected",
"function",
"setConnectedRelationOptions",
"(",
")",
"{",
"$",
"pivotTable",
"=",
"$",
"this",
"->",
"defaultOptions",
"[",
"'pivot_table'",
"]",
";",
"$",
"foreignKey",
"=",
"$",
"this",
"->",
"defaultOptions",
"[",
"'foreign_key'",
"]",
";",
"$",
"relatedKey",
"=",
"$",
"this",
"->",
"defaultOptions",
"[",
"'related_key'",
"]",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"db",
"->",
"isTableExists",
"(",
"$",
"pivotTable",
")",
")",
"{",
"$",
"question",
"=",
"\"Can't find table {$this->text['pivot_table']} in the database as {$this->text['pivot_text']}, choice one!\"",
";",
"$",
"pivotTable",
"=",
"$",
"this",
"->",
"options",
"[",
"'pivot_table'",
"]",
"=",
"$",
"this",
"->",
"command",
"->",
"choice",
"(",
"$",
"question",
",",
"$",
"this",
"->",
"getTables",
"(",
")",
")",
";",
"$",
"this",
"->",
"text",
"[",
"'pivot_table'",
"]",
"=",
"\"[\"",
".",
"$",
"this",
"->",
"command",
"->",
"paintString",
"(",
"$",
"pivotTable",
",",
"'green'",
")",
".",
"\"]\"",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"db",
"->",
"isFieldExists",
"(",
"$",
"pivotTable",
",",
"$",
"foreignKey",
")",
")",
"{",
"$",
"question",
"=",
"\"Can't find field {$this->text['foreign_key']} in the table {$this->text['pivot_table']} as {$this->text['foreign_text']} of table {$this->text['table']}, choice one!\"",
";",
"$",
"this",
"->",
"options",
"[",
"'foreign_key'",
"]",
"=",
"$",
"this",
"->",
"command",
"->",
"choice",
"(",
"$",
"question",
",",
"$",
"this",
"->",
"getFields",
"(",
"$",
"pivotTable",
")",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"db",
"->",
"isFieldExists",
"(",
"$",
"pivotTable",
",",
"$",
"relatedKey",
")",
")",
"{",
"$",
"question",
"=",
"\"Can't find field {$this->text['related_key']} in the table {$this->text['pivot_table']} as {$this->text['related_text']} of table {$this->text['to_table']}, choice one!\"",
";",
"$",
"this",
"->",
"options",
"[",
"'related_key'",
"]",
"=",
"$",
"this",
"->",
"command",
"->",
"choice",
"(",
"$",
"question",
",",
"$",
"this",
"->",
"getFields",
"(",
"$",
"pivotTable",
")",
")",
";",
"}",
"}"
]
| get connected db relation options
@return void | [
"get",
"connected",
"db",
"relation",
"options"
]
| 4288426517f53d05177b8729c4ba94c5beca9a98 | https://github.com/flipboxstudio/orm-manager/blob/4288426517f53d05177b8729c4ba94c5beca9a98/src/Flipbox/OrmManager/BothRelations/ManyToMany.php#L63-L86 |
17,106 | limen/php-jobs | src/Contracts/BaseJobset.php | BaseJobset.make | public static function make($attributes = [])
{
$jobset = new static();
// make jobset model
$model = $jobset->makeModel($attributes);
// update local model
$jobset->setModel($model);
// make job models and init job instances
$jobset->makeJobs();
// set jobset try at
$jobsetTryAt = $jobset->getJobsEarliestTryAt();
$jobset->model->setTryAt($jobsetTryAt);
$jobset->model->persist();
return $jobset;
} | php | public static function make($attributes = [])
{
$jobset = new static();
// make jobset model
$model = $jobset->makeModel($attributes);
// update local model
$jobset->setModel($model);
// make job models and init job instances
$jobset->makeJobs();
// set jobset try at
$jobsetTryAt = $jobset->getJobsEarliestTryAt();
$jobset->model->setTryAt($jobsetTryAt);
$jobset->model->persist();
return $jobset;
} | [
"public",
"static",
"function",
"make",
"(",
"$",
"attributes",
"=",
"[",
"]",
")",
"{",
"$",
"jobset",
"=",
"new",
"static",
"(",
")",
";",
"// make jobset model",
"$",
"model",
"=",
"$",
"jobset",
"->",
"makeModel",
"(",
"$",
"attributes",
")",
";",
"// update local model",
"$",
"jobset",
"->",
"setModel",
"(",
"$",
"model",
")",
";",
"// make job models and init job instances",
"$",
"jobset",
"->",
"makeJobs",
"(",
")",
";",
"// set jobset try at",
"$",
"jobsetTryAt",
"=",
"$",
"jobset",
"->",
"getJobsEarliestTryAt",
"(",
")",
";",
"$",
"jobset",
"->",
"model",
"->",
"setTryAt",
"(",
"$",
"jobsetTryAt",
")",
";",
"$",
"jobset",
"->",
"model",
"->",
"persist",
"(",
")",
";",
"return",
"$",
"jobset",
";",
"}"
]
| Make new jobset
@param array $attributes
@return BaseJobset | [
"Make",
"new",
"jobset"
]
| 525f4082b49a7a3e69acb4cea3a622244f1616b9 | https://github.com/limen/php-jobs/blob/525f4082b49a7a3e69acb4cea3a622244f1616b9/src/Contracts/BaseJobset.php#L37-L53 |
17,107 | limen/php-jobs | src/Contracts/BaseJobset.php | BaseJobset.get | public static function get($id)
{
$jobset = new static();
// find jobset model
$model = $jobset->findModel($id);
// update local model
$jobset->setModel($model);
// Init job instances
$jobset->initJobs();
return $jobset;
} | php | public static function get($id)
{
$jobset = new static();
// find jobset model
$model = $jobset->findModel($id);
// update local model
$jobset->setModel($model);
// Init job instances
$jobset->initJobs();
return $jobset;
} | [
"public",
"static",
"function",
"get",
"(",
"$",
"id",
")",
"{",
"$",
"jobset",
"=",
"new",
"static",
"(",
")",
";",
"// find jobset model",
"$",
"model",
"=",
"$",
"jobset",
"->",
"findModel",
"(",
"$",
"id",
")",
";",
"// update local model",
"$",
"jobset",
"->",
"setModel",
"(",
"$",
"model",
")",
";",
"// Init job instances",
"$",
"jobset",
"->",
"initJobs",
"(",
")",
";",
"return",
"$",
"jobset",
";",
"}"
]
| Get an existed jobset
@param $id
@return static | [
"Get",
"an",
"existed",
"jobset"
]
| 525f4082b49a7a3e69acb4cea3a622244f1616b9 | https://github.com/limen/php-jobs/blob/525f4082b49a7a3e69acb4cea3a622244f1616b9/src/Contracts/BaseJobset.php#L61-L73 |
17,108 | limen/php-jobs | src/Contracts/BaseJobset.php | BaseJobset.execute | public function execute()
{
// If the jobset is finished or failed
// the jobset may need to be dispatched
// so we return true
if ($this->isFinished() || $this->isFailed()) {
return true;
}
// Just return false to tell to terminate the process
if (!$this->isInTime()) {
return false;
}
// return false means the jobset is done
// and the process should be terminated
if ($this->isDispatched() || $this->isCanceled()) {
return false;
}
try {
if (!$this->jobs) {
$this->initJobs();
}
$this->doUnorderedJobs();
$this->doOrderedJobs();
$status = $this->getJobsetExecutionStatus();
if ($status === JobsConst::JOB_SET_STATUS_FAILED) {
$this->failed();
} else {
$this->updateStatus($status);
}
} catch (\Exception $e) {
// just throw it
throw $e;
}
return true;
} | php | public function execute()
{
// If the jobset is finished or failed
// the jobset may need to be dispatched
// so we return true
if ($this->isFinished() || $this->isFailed()) {
return true;
}
// Just return false to tell to terminate the process
if (!$this->isInTime()) {
return false;
}
// return false means the jobset is done
// and the process should be terminated
if ($this->isDispatched() || $this->isCanceled()) {
return false;
}
try {
if (!$this->jobs) {
$this->initJobs();
}
$this->doUnorderedJobs();
$this->doOrderedJobs();
$status = $this->getJobsetExecutionStatus();
if ($status === JobsConst::JOB_SET_STATUS_FAILED) {
$this->failed();
} else {
$this->updateStatus($status);
}
} catch (\Exception $e) {
// just throw it
throw $e;
}
return true;
} | [
"public",
"function",
"execute",
"(",
")",
"{",
"// If the jobset is finished or failed",
"// the jobset may need to be dispatched",
"// so we return true",
"if",
"(",
"$",
"this",
"->",
"isFinished",
"(",
")",
"||",
"$",
"this",
"->",
"isFailed",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"// Just return false to tell to terminate the process",
"if",
"(",
"!",
"$",
"this",
"->",
"isInTime",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"// return false means the jobset is done",
"// and the process should be terminated",
"if",
"(",
"$",
"this",
"->",
"isDispatched",
"(",
")",
"||",
"$",
"this",
"->",
"isCanceled",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"try",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"jobs",
")",
"{",
"$",
"this",
"->",
"initJobs",
"(",
")",
";",
"}",
"$",
"this",
"->",
"doUnorderedJobs",
"(",
")",
";",
"$",
"this",
"->",
"doOrderedJobs",
"(",
")",
";",
"$",
"status",
"=",
"$",
"this",
"->",
"getJobsetExecutionStatus",
"(",
")",
";",
"if",
"(",
"$",
"status",
"===",
"JobsConst",
"::",
"JOB_SET_STATUS_FAILED",
")",
"{",
"$",
"this",
"->",
"failed",
"(",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"updateStatus",
"(",
"$",
"status",
")",
";",
"}",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"// just throw it",
"throw",
"$",
"e",
";",
"}",
"return",
"true",
";",
"}"
]
| If return true, the jobset should be dispatched with considering its status
Or the jobset process should be terminated
@return bool
@throws \Exception | [
"If",
"return",
"true",
"the",
"jobset",
"should",
"be",
"dispatched",
"with",
"considering",
"its",
"status",
"Or",
"the",
"jobset",
"process",
"should",
"be",
"terminated"
]
| 525f4082b49a7a3e69acb4cea3a622244f1616b9 | https://github.com/limen/php-jobs/blob/525f4082b49a7a3e69acb4cea3a622244f1616b9/src/Contracts/BaseJobset.php#L206-L244 |
17,109 | limen/php-jobs | src/Contracts/BaseJobset.php | BaseJobset.dispatched | public function dispatched()
{
// Only finished or failed jobset should be dispatched
if ($this->isFinished() || $this->isFailed()) {
$status = $this->isFinished() ?
JobsConst::JOB_SET_STATUS_FINISHED_AND_DISPATCHED : JobsConst::JOB_SET_STATUS_FAILED_AND_DISPATCHED;
return $this->model->updateStatus($status);
}
return false;
} | php | public function dispatched()
{
// Only finished or failed jobset should be dispatched
if ($this->isFinished() || $this->isFailed()) {
$status = $this->isFinished() ?
JobsConst::JOB_SET_STATUS_FINISHED_AND_DISPATCHED : JobsConst::JOB_SET_STATUS_FAILED_AND_DISPATCHED;
return $this->model->updateStatus($status);
}
return false;
} | [
"public",
"function",
"dispatched",
"(",
")",
"{",
"// Only finished or failed jobset should be dispatched",
"if",
"(",
"$",
"this",
"->",
"isFinished",
"(",
")",
"||",
"$",
"this",
"->",
"isFailed",
"(",
")",
")",
"{",
"$",
"status",
"=",
"$",
"this",
"->",
"isFinished",
"(",
")",
"?",
"JobsConst",
"::",
"JOB_SET_STATUS_FINISHED_AND_DISPATCHED",
":",
"JobsConst",
"::",
"JOB_SET_STATUS_FAILED_AND_DISPATCHED",
";",
"return",
"$",
"this",
"->",
"model",
"->",
"updateStatus",
"(",
"$",
"status",
")",
";",
"}",
"return",
"false",
";",
"}"
]
| After successfully notice to commander, we mark the jobset as dispatched here. | [
"After",
"successfully",
"notice",
"to",
"commander",
"we",
"mark",
"the",
"jobset",
"as",
"dispatched",
"here",
"."
]
| 525f4082b49a7a3e69acb4cea3a622244f1616b9 | https://github.com/limen/php-jobs/blob/525f4082b49a7a3e69acb4cea3a622244f1616b9/src/Contracts/BaseJobset.php#L309-L320 |
17,110 | limen/php-jobs | src/Contracts/BaseJobset.php | BaseJobset.getJobsetExecutionStatus | public function getJobsetExecutionStatus()
{
$finished = count($this->jobs) > 0 ? true : false;
$failed = false;
$middle = false;
foreach ($this->jobs as $job) {
if ($job->isFailed()) {
$finished = false;
$middle = false;
$failed = true;
break;
}
$finished = $finished && $job->isFinished();
if (!$job->isFinished() && !$job->isFailed()) {
$middle = true;
}
}
if ($failed) {
return JobsConst::JOB_SET_STATUS_FAILED;
} elseif ($finished) {
return JobsConst::JOB_SET_STATUS_FINISHED;
} elseif ($middle) {
return JobsConst::JOB_SET_STATUS_ONGOING;
} else {
return JobsConst::JOB_SET_STATUS_DEFAULT;
}
} | php | public function getJobsetExecutionStatus()
{
$finished = count($this->jobs) > 0 ? true : false;
$failed = false;
$middle = false;
foreach ($this->jobs as $job) {
if ($job->isFailed()) {
$finished = false;
$middle = false;
$failed = true;
break;
}
$finished = $finished && $job->isFinished();
if (!$job->isFinished() && !$job->isFailed()) {
$middle = true;
}
}
if ($failed) {
return JobsConst::JOB_SET_STATUS_FAILED;
} elseif ($finished) {
return JobsConst::JOB_SET_STATUS_FINISHED;
} elseif ($middle) {
return JobsConst::JOB_SET_STATUS_ONGOING;
} else {
return JobsConst::JOB_SET_STATUS_DEFAULT;
}
} | [
"public",
"function",
"getJobsetExecutionStatus",
"(",
")",
"{",
"$",
"finished",
"=",
"count",
"(",
"$",
"this",
"->",
"jobs",
")",
">",
"0",
"?",
"true",
":",
"false",
";",
"$",
"failed",
"=",
"false",
";",
"$",
"middle",
"=",
"false",
";",
"foreach",
"(",
"$",
"this",
"->",
"jobs",
"as",
"$",
"job",
")",
"{",
"if",
"(",
"$",
"job",
"->",
"isFailed",
"(",
")",
")",
"{",
"$",
"finished",
"=",
"false",
";",
"$",
"middle",
"=",
"false",
";",
"$",
"failed",
"=",
"true",
";",
"break",
";",
"}",
"$",
"finished",
"=",
"$",
"finished",
"&&",
"$",
"job",
"->",
"isFinished",
"(",
")",
";",
"if",
"(",
"!",
"$",
"job",
"->",
"isFinished",
"(",
")",
"&&",
"!",
"$",
"job",
"->",
"isFailed",
"(",
")",
")",
"{",
"$",
"middle",
"=",
"true",
";",
"}",
"}",
"if",
"(",
"$",
"failed",
")",
"{",
"return",
"JobsConst",
"::",
"JOB_SET_STATUS_FAILED",
";",
"}",
"elseif",
"(",
"$",
"finished",
")",
"{",
"return",
"JobsConst",
"::",
"JOB_SET_STATUS_FINISHED",
";",
"}",
"elseif",
"(",
"$",
"middle",
")",
"{",
"return",
"JobsConst",
"::",
"JOB_SET_STATUS_ONGOING",
";",
"}",
"else",
"{",
"return",
"JobsConst",
"::",
"JOB_SET_STATUS_DEFAULT",
";",
"}",
"}"
]
| Get jobset execution status from sub jobs statuses.
At least one job failed, the jobset is failed.
All jobs finished, the jobset is finished.
At least one job has been executed, the jobset is ongoing.
All jobs have not been executed, the jobset is in default status.
@return int | [
"Get",
"jobset",
"execution",
"status",
"from",
"sub",
"jobs",
"statuses",
".",
"At",
"least",
"one",
"job",
"failed",
"the",
"jobset",
"is",
"failed",
".",
"All",
"jobs",
"finished",
"the",
"jobset",
"is",
"finished",
".",
"At",
"least",
"one",
"job",
"has",
"been",
"executed",
"the",
"jobset",
"is",
"ongoing",
".",
"All",
"jobs",
"have",
"not",
"been",
"executed",
"the",
"jobset",
"is",
"in",
"default",
"status",
"."
]
| 525f4082b49a7a3e69acb4cea3a622244f1616b9 | https://github.com/limen/php-jobs/blob/525f4082b49a7a3e69acb4cea3a622244f1616b9/src/Contracts/BaseJobset.php#L341-L369 |
17,111 | limen/php-jobs | src/Contracts/BaseJobset.php | BaseJobset.doOrderedJobs | protected function doOrderedJobs()
{
$jobNames = $this->getOrderedJobNames();
foreach ($jobNames as $jobName) {
$job = $this->getLocalJob($jobName);
if (!$job) {
throw new \Exception("job [$jobName] not exists");
}
$job->execute();
$this->updateLocalJob($job);
if (!$job->isFinished()) {
break;
}
}
} | php | protected function doOrderedJobs()
{
$jobNames = $this->getOrderedJobNames();
foreach ($jobNames as $jobName) {
$job = $this->getLocalJob($jobName);
if (!$job) {
throw new \Exception("job [$jobName] not exists");
}
$job->execute();
$this->updateLocalJob($job);
if (!$job->isFinished()) {
break;
}
}
} | [
"protected",
"function",
"doOrderedJobs",
"(",
")",
"{",
"$",
"jobNames",
"=",
"$",
"this",
"->",
"getOrderedJobNames",
"(",
")",
";",
"foreach",
"(",
"$",
"jobNames",
"as",
"$",
"jobName",
")",
"{",
"$",
"job",
"=",
"$",
"this",
"->",
"getLocalJob",
"(",
"$",
"jobName",
")",
";",
"if",
"(",
"!",
"$",
"job",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"job [$jobName] not exists\"",
")",
";",
"}",
"$",
"job",
"->",
"execute",
"(",
")",
";",
"$",
"this",
"->",
"updateLocalJob",
"(",
"$",
"job",
")",
";",
"if",
"(",
"!",
"$",
"job",
"->",
"isFinished",
"(",
")",
")",
"{",
"break",
";",
"}",
"}",
"}"
]
| Do ordered jobs | [
"Do",
"ordered",
"jobs"
]
| 525f4082b49a7a3e69acb4cea3a622244f1616b9 | https://github.com/limen/php-jobs/blob/525f4082b49a7a3e69acb4cea3a622244f1616b9/src/Contracts/BaseJobset.php#L374-L388 |
17,112 | limen/php-jobs | src/Contracts/BaseJobset.php | BaseJobset.doUnorderedJobs | protected function doUnorderedJobs()
{
$jobNames = $this->getUnorderedJobNames();
foreach ($jobNames as $jobName) {
$job = $this->getLocalJob($jobName);
if (!$job) {
throw new \Exception("job [$jobName] not exists");
}
$job->execute();
$this->updateLocalJob($job);
}
} | php | protected function doUnorderedJobs()
{
$jobNames = $this->getUnorderedJobNames();
foreach ($jobNames as $jobName) {
$job = $this->getLocalJob($jobName);
if (!$job) {
throw new \Exception("job [$jobName] not exists");
}
$job->execute();
$this->updateLocalJob($job);
}
} | [
"protected",
"function",
"doUnorderedJobs",
"(",
")",
"{",
"$",
"jobNames",
"=",
"$",
"this",
"->",
"getUnorderedJobNames",
"(",
")",
";",
"foreach",
"(",
"$",
"jobNames",
"as",
"$",
"jobName",
")",
"{",
"$",
"job",
"=",
"$",
"this",
"->",
"getLocalJob",
"(",
"$",
"jobName",
")",
";",
"if",
"(",
"!",
"$",
"job",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"job [$jobName] not exists\"",
")",
";",
"}",
"$",
"job",
"->",
"execute",
"(",
")",
";",
"$",
"this",
"->",
"updateLocalJob",
"(",
"$",
"job",
")",
";",
"}",
"}"
]
| Do unordered jobs | [
"Do",
"unordered",
"jobs"
]
| 525f4082b49a7a3e69acb4cea3a622244f1616b9 | https://github.com/limen/php-jobs/blob/525f4082b49a7a3e69acb4cea3a622244f1616b9/src/Contracts/BaseJobset.php#L393-L405 |
17,113 | limen/php-jobs | src/Contracts/BaseJobset.php | BaseJobset.getJobsEarliestTryAt | protected function getJobsEarliestTryAt()
{
$tryAt = date('Y-m-d H:i:s');
foreach ($this->jobs as $job) {
if (!$job->isFinished() && Helper::datetimeLT($job->getTryAt(), $tryAt)) {
$tryAt = $job->getTryAt();
}
}
return $tryAt;
} | php | protected function getJobsEarliestTryAt()
{
$tryAt = date('Y-m-d H:i:s');
foreach ($this->jobs as $job) {
if (!$job->isFinished() && Helper::datetimeLT($job->getTryAt(), $tryAt)) {
$tryAt = $job->getTryAt();
}
}
return $tryAt;
} | [
"protected",
"function",
"getJobsEarliestTryAt",
"(",
")",
"{",
"$",
"tryAt",
"=",
"date",
"(",
"'Y-m-d H:i:s'",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"jobs",
"as",
"$",
"job",
")",
"{",
"if",
"(",
"!",
"$",
"job",
"->",
"isFinished",
"(",
")",
"&&",
"Helper",
"::",
"datetimeLT",
"(",
"$",
"job",
"->",
"getTryAt",
"(",
")",
",",
"$",
"tryAt",
")",
")",
"{",
"$",
"tryAt",
"=",
"$",
"job",
"->",
"getTryAt",
"(",
")",
";",
"}",
"}",
"return",
"$",
"tryAt",
";",
"}"
]
| get the earliest job try at time, except the finished jobs
@return false|mixed|string | [
"get",
"the",
"earliest",
"job",
"try",
"at",
"time",
"except",
"the",
"finished",
"jobs"
]
| 525f4082b49a7a3e69acb4cea3a622244f1616b9 | https://github.com/limen/php-jobs/blob/525f4082b49a7a3e69acb4cea3a622244f1616b9/src/Contracts/BaseJobset.php#L412-L423 |
17,114 | traderinteractive/util-string-php | src/Strings.php | Strings.format | public static function format(string $format, string ...$arguments) : string
{
foreach ($arguments as $key => $value) {
$format = str_replace("{{$key}}", (string)$value, $format);
}
return $format;
} | php | public static function format(string $format, string ...$arguments) : string
{
foreach ($arguments as $key => $value) {
$format = str_replace("{{$key}}", (string)$value, $format);
}
return $format;
} | [
"public",
"static",
"function",
"format",
"(",
"string",
"$",
"format",
",",
"string",
"...",
"$",
"arguments",
")",
":",
"string",
"{",
"foreach",
"(",
"$",
"arguments",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"format",
"=",
"str_replace",
"(",
"\"{{$key}}\"",
",",
"(",
"string",
")",
"$",
"value",
",",
"$",
"format",
")",
";",
"}",
"return",
"$",
"format",
";",
"}"
]
| Replaces the format items in a specified string with the string representation of n specified objects.
@param string $format A composit format string
@param mixed $arguments Variable number of items to format.
@return string Returns a copy of format in which the format items have been
replaced by the string representations of arg0, arg1,... argN. | [
"Replaces",
"the",
"format",
"items",
"in",
"a",
"specified",
"string",
"with",
"the",
"string",
"representation",
"of",
"n",
"specified",
"objects",
"."
]
| 5c05605fd836f3a2822065d474e814c8644857b8 | https://github.com/traderinteractive/util-string-php/blob/5c05605fd836f3a2822065d474e814c8644857b8/src/Strings.php#L22-L29 |
17,115 | traderinteractive/util-string-php | src/Strings.php | Strings.ellipsize | public static function ellipsize(string $string, int $maxLength, string $suffix = '...') : string
{
if ($maxLength < 0) {
throw new \InvalidArgumentException('$maxLength is negative');
}
if (strlen($string) <= $maxLength) {
return $string;
}
$trimmedLength = $maxLength - strlen($suffix);
$string = substr($string, 0, max(0, $trimmedLength));
if ($string === '') {
return substr($suffix, 0, $maxLength);
}
return $string . $suffix;
} | php | public static function ellipsize(string $string, int $maxLength, string $suffix = '...') : string
{
if ($maxLength < 0) {
throw new \InvalidArgumentException('$maxLength is negative');
}
if (strlen($string) <= $maxLength) {
return $string;
}
$trimmedLength = $maxLength - strlen($suffix);
$string = substr($string, 0, max(0, $trimmedLength));
if ($string === '') {
return substr($suffix, 0, $maxLength);
}
return $string . $suffix;
} | [
"public",
"static",
"function",
"ellipsize",
"(",
"string",
"$",
"string",
",",
"int",
"$",
"maxLength",
",",
"string",
"$",
"suffix",
"=",
"'...'",
")",
":",
"string",
"{",
"if",
"(",
"$",
"maxLength",
"<",
"0",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'$maxLength is negative'",
")",
";",
"}",
"if",
"(",
"strlen",
"(",
"$",
"string",
")",
"<=",
"$",
"maxLength",
")",
"{",
"return",
"$",
"string",
";",
"}",
"$",
"trimmedLength",
"=",
"$",
"maxLength",
"-",
"strlen",
"(",
"$",
"suffix",
")",
";",
"$",
"string",
"=",
"substr",
"(",
"$",
"string",
",",
"0",
",",
"max",
"(",
"0",
",",
"$",
"trimmedLength",
")",
")",
";",
"if",
"(",
"$",
"string",
"===",
"''",
")",
"{",
"return",
"substr",
"(",
"$",
"suffix",
",",
"0",
",",
"$",
"maxLength",
")",
";",
"}",
"return",
"$",
"string",
".",
"$",
"suffix",
";",
"}"
]
| Truncates the string to the given length, with an ellipsis at the end.
@param string $string The string to shorten.
@param int $maxLength The length to truncate the string to. The result will not be longer than this, but may be
shorter.
@param string $suffix The string to append when truncating. Typically this will be an ellipsis.
@return string The truncated string with the ellipsis included if truncation occured.
@throws \InvalidArgumentException if $maxLength is negative | [
"Truncates",
"the",
"string",
"to",
"the",
"given",
"length",
"with",
"an",
"ellipsis",
"at",
"the",
"end",
"."
]
| 5c05605fd836f3a2822065d474e814c8644857b8 | https://github.com/traderinteractive/util-string-php/blob/5c05605fd836f3a2822065d474e814c8644857b8/src/Strings.php#L75-L93 |
17,116 | trafficgate/shell-command | src/ShellOption.php | ShellOption.enable | public function enable($enable = true)
{
if (! is_bool($enable)) {
throw new InvalidArgumentException("enable must be a boolean. [$enable] given.");
}
$this->enabled = $enable;
return $this;
} | php | public function enable($enable = true)
{
if (! is_bool($enable)) {
throw new InvalidArgumentException("enable must be a boolean. [$enable] given.");
}
$this->enabled = $enable;
return $this;
} | [
"public",
"function",
"enable",
"(",
"$",
"enable",
"=",
"true",
")",
"{",
"if",
"(",
"!",
"is_bool",
"(",
"$",
"enable",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"enable must be a boolean. [$enable] given.\"",
")",
";",
"}",
"$",
"this",
"->",
"enabled",
"=",
"$",
"enable",
";",
"return",
"$",
"this",
";",
"}"
]
| Enable the option.
@param bool|true $enable
@throws InvalidArgumentException
@return $this | [
"Enable",
"the",
"option",
"."
]
| 1a5f3fcf689f33098b192c34839effe309202c0e | https://github.com/trafficgate/shell-command/blob/1a5f3fcf689f33098b192c34839effe309202c0e/src/ShellOption.php#L100-L109 |
17,117 | trafficgate/shell-command | src/ShellOption.php | ShellOption.hasValue | public function hasValue($value)
{
$index = array_search($value, $this->values);
if ($index === false) {
return false;
}
return true;
} | php | public function hasValue($value)
{
$index = array_search($value, $this->values);
if ($index === false) {
return false;
}
return true;
} | [
"public",
"function",
"hasValue",
"(",
"$",
"value",
")",
"{",
"$",
"index",
"=",
"array_search",
"(",
"$",
"value",
",",
"$",
"this",
"->",
"values",
")",
";",
"if",
"(",
"$",
"index",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
]
| Return whether this option has the given value or not.
@param mixed $value
@return bool | [
"Return",
"whether",
"this",
"option",
"has",
"the",
"given",
"value",
"or",
"not",
"."
]
| 1a5f3fcf689f33098b192c34839effe309202c0e | https://github.com/trafficgate/shell-command/blob/1a5f3fcf689f33098b192c34839effe309202c0e/src/ShellOption.php#L150-L159 |
17,118 | trafficgate/shell-command | src/ShellOption.php | ShellOption.addValue | public function addValue($value)
{
$this->assertCanHaveValue();
$this->assertValueIsValid($value);
if ($this->canHaveMultipleValues() && ! $this->hasValue($value)) {
$value = array_merge($this->values, (array) $value);
}
$this->values = (array) $value;
return $this;
} | php | public function addValue($value)
{
$this->assertCanHaveValue();
$this->assertValueIsValid($value);
if ($this->canHaveMultipleValues() && ! $this->hasValue($value)) {
$value = array_merge($this->values, (array) $value);
}
$this->values = (array) $value;
return $this;
} | [
"public",
"function",
"addValue",
"(",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"assertCanHaveValue",
"(",
")",
";",
"$",
"this",
"->",
"assertValueIsValid",
"(",
"$",
"value",
")",
";",
"if",
"(",
"$",
"this",
"->",
"canHaveMultipleValues",
"(",
")",
"&&",
"!",
"$",
"this",
"->",
"hasValue",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"values",
",",
"(",
"array",
")",
"$",
"value",
")",
";",
"}",
"$",
"this",
"->",
"values",
"=",
"(",
"array",
")",
"$",
"value",
";",
"return",
"$",
"this",
";",
"}"
]
| Add a new value to this option.
@param int|string $value
@return $this | [
"Add",
"a",
"new",
"value",
"to",
"this",
"option",
"."
]
| 1a5f3fcf689f33098b192c34839effe309202c0e | https://github.com/trafficgate/shell-command/blob/1a5f3fcf689f33098b192c34839effe309202c0e/src/ShellOption.php#L178-L190 |
17,119 | trafficgate/shell-command | src/ShellOption.php | ShellOption.addValues | public function addValues(array $values = [])
{
$this->assertCanHaveMultipleValues();
foreach ($values as $value) {
$this->addValue($value);
}
return $this;
} | php | public function addValues(array $values = [])
{
$this->assertCanHaveMultipleValues();
foreach ($values as $value) {
$this->addValue($value);
}
return $this;
} | [
"public",
"function",
"addValues",
"(",
"array",
"$",
"values",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"assertCanHaveMultipleValues",
"(",
")",
";",
"foreach",
"(",
"$",
"values",
"as",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"addValue",
"(",
"$",
"value",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Add multiple values to this option.
@param array $values
@return $this | [
"Add",
"multiple",
"values",
"to",
"this",
"option",
"."
]
| 1a5f3fcf689f33098b192c34839effe309202c0e | https://github.com/trafficgate/shell-command/blob/1a5f3fcf689f33098b192c34839effe309202c0e/src/ShellOption.php#L199-L208 |
17,120 | trafficgate/shell-command | src/ShellOption.php | ShellOption.removeValue | public function removeValue($value)
{
if (! $this->canHaveMultipleValues() && ! isset($value)) {
$this->values = [];
$this->enable($enable = false);
return $this;
}
$this->assertValueIsValid($value);
$this->assertCanHaveValue();
if ($this->hasValue($value)) {
$index = array_search($value, $this->values);
unset($this->values[$index]);
$this->values = array_values($this->values);
}
return $this;
} | php | public function removeValue($value)
{
if (! $this->canHaveMultipleValues() && ! isset($value)) {
$this->values = [];
$this->enable($enable = false);
return $this;
}
$this->assertValueIsValid($value);
$this->assertCanHaveValue();
if ($this->hasValue($value)) {
$index = array_search($value, $this->values);
unset($this->values[$index]);
$this->values = array_values($this->values);
}
return $this;
} | [
"public",
"function",
"removeValue",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"canHaveMultipleValues",
"(",
")",
"&&",
"!",
"isset",
"(",
"$",
"value",
")",
")",
"{",
"$",
"this",
"->",
"values",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"enable",
"(",
"$",
"enable",
"=",
"false",
")",
";",
"return",
"$",
"this",
";",
"}",
"$",
"this",
"->",
"assertValueIsValid",
"(",
"$",
"value",
")",
";",
"$",
"this",
"->",
"assertCanHaveValue",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"hasValue",
"(",
"$",
"value",
")",
")",
"{",
"$",
"index",
"=",
"array_search",
"(",
"$",
"value",
",",
"$",
"this",
"->",
"values",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"values",
"[",
"$",
"index",
"]",
")",
";",
"$",
"this",
"->",
"values",
"=",
"array_values",
"(",
"$",
"this",
"->",
"values",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Remove the given value from the option.
@param int|string $value
@return $this | [
"Remove",
"the",
"given",
"value",
"from",
"the",
"option",
"."
]
| 1a5f3fcf689f33098b192c34839effe309202c0e | https://github.com/trafficgate/shell-command/blob/1a5f3fcf689f33098b192c34839effe309202c0e/src/ShellOption.php#L217-L236 |
17,121 | trafficgate/shell-command | src/ShellOption.php | ShellOption.removeValues | public function removeValues(array $values = [])
{
$this->assertCanHaveMultipleValues();
foreach ($values as $value) {
$this->removeValue($value);
}
return $this;
} | php | public function removeValues(array $values = [])
{
$this->assertCanHaveMultipleValues();
foreach ($values as $value) {
$this->removeValue($value);
}
return $this;
} | [
"public",
"function",
"removeValues",
"(",
"array",
"$",
"values",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"assertCanHaveMultipleValues",
"(",
")",
";",
"foreach",
"(",
"$",
"values",
"as",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"removeValue",
"(",
"$",
"value",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Remove the given values from the option.
@param array $values
@return $this | [
"Remove",
"the",
"given",
"values",
"from",
"the",
"option",
"."
]
| 1a5f3fcf689f33098b192c34839effe309202c0e | https://github.com/trafficgate/shell-command/blob/1a5f3fcf689f33098b192c34839effe309202c0e/src/ShellOption.php#L245-L254 |
17,122 | trafficgate/shell-command | src/ShellOption.php | ShellOption.getArray | public function getArray()
{
$options = [];
if ($this->isDisabled() || $this->canHaveValue() && empty($this->values)) {
return $options;
}
foreach ($this->values as $value) {
$options[] = $this->flag();
$options[] = $value;
}
if (empty($options)) {
$options[] = $this->flag();
}
return $options;
} | php | public function getArray()
{
$options = [];
if ($this->isDisabled() || $this->canHaveValue() && empty($this->values)) {
return $options;
}
foreach ($this->values as $value) {
$options[] = $this->flag();
$options[] = $value;
}
if (empty($options)) {
$options[] = $this->flag();
}
return $options;
} | [
"public",
"function",
"getArray",
"(",
")",
"{",
"$",
"options",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"isDisabled",
"(",
")",
"||",
"$",
"this",
"->",
"canHaveValue",
"(",
")",
"&&",
"empty",
"(",
"$",
"this",
"->",
"values",
")",
")",
"{",
"return",
"$",
"options",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"values",
"as",
"$",
"value",
")",
"{",
"$",
"options",
"[",
"]",
"=",
"$",
"this",
"->",
"flag",
"(",
")",
";",
"$",
"options",
"[",
"]",
"=",
"$",
"value",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"options",
")",
")",
"{",
"$",
"options",
"[",
"]",
"=",
"$",
"this",
"->",
"flag",
"(",
")",
";",
"}",
"return",
"$",
"options",
";",
"}"
]
| Get the option and its values as an array.
@return array | [
"Get",
"the",
"option",
"and",
"its",
"values",
"as",
"an",
"array",
"."
]
| 1a5f3fcf689f33098b192c34839effe309202c0e | https://github.com/trafficgate/shell-command/blob/1a5f3fcf689f33098b192c34839effe309202c0e/src/ShellOption.php#L261-L279 |
17,123 | trafficgate/shell-command | src/ShellOption.php | ShellOption.parseFlag | private function parseFlag($flag)
{
$flag = trim($flag);
$pattern = '/^'.// Match start of string
'('.// Start Group
'(?<flag>(?:-\w|--\w[\w-]+))'.// Match Group <flag>
'(?<enable>\+)?'.//Enable option by default (useful for creating special commands)
')'.// End Group
'('.// Start Group
'(?<can_have_value>=)?'.// Match Group <can_have_value>
'(?<can_have_multiple_values>\*)?'.// Match Group <can_have_multiple_values>
'(?<values>'.// Match Group <values>
'(?(<can_have_multiple_values>)'.// If <can_have_multiple_values>
'(\w+,)*\w+|'.// Match multiple comma-separated values
'(?(<can_have_value>)'.// Else if <can_have_value>
'\w+'.// Match only a single value
')'.// End if <can_have_value>
')'.// End if <can_have_multiple_values>
')?'.// End Group <values>
')?'.// End Group
'('.// Start Group
'\s+:\s+'.// [space] followed by ':' followed by [space]
'(?<description>.+)'.// Match Group <description>
')?'.// End Group
'$/'; // Match end of string
$matches = [];
$result = preg_match($pattern, $flag, $matches);
if ($result === 0 || $result === false) {
throw new LogicException("[$flag] is improperly formatted for a shell option.");
}
// Set flag
$parsedFlag['flag'] = null;
if (isset($matches['flag'])) {
$parsedFlag['flag'] = $matches['flag'];
}
// Set enable
$parsedFlag['enable'] = false;
if (! empty($matches['enable'])) {
$parsedFlag['enable'] = true;
}
// Set can have value
$parsedFlag['can_have_value'] = false;
if (! empty($matches['can_have_value'])) {
$parsedFlag['can_have_value'] = true;
}
// Set can have multiple values
$parsedFlag['can_have_multiple_values'] = false;
if (! empty($matches['can_have_multiple_values'])) {
$parsedFlag['can_have_multiple_values'] = true;
}
// Set the values
$parsedFlag['values'] = [];
if (! empty($matches['values']) && $parsedFlag['can_have_value']) {
$parsedFlag['values'] = $matches['values'];
if ($parsedFlag['can_have_multiple_values']) {
$parsedFlag['values'] = explode(',', $matches['values']);
}
}
// Set the description
$parsedFlag['description'] = null;
if (isset($matches['description'])) {
$parsedFlag['description'] = $matches['description'];
}
return $parsedFlag;
} | php | private function parseFlag($flag)
{
$flag = trim($flag);
$pattern = '/^'.// Match start of string
'('.// Start Group
'(?<flag>(?:-\w|--\w[\w-]+))'.// Match Group <flag>
'(?<enable>\+)?'.//Enable option by default (useful for creating special commands)
')'.// End Group
'('.// Start Group
'(?<can_have_value>=)?'.// Match Group <can_have_value>
'(?<can_have_multiple_values>\*)?'.// Match Group <can_have_multiple_values>
'(?<values>'.// Match Group <values>
'(?(<can_have_multiple_values>)'.// If <can_have_multiple_values>
'(\w+,)*\w+|'.// Match multiple comma-separated values
'(?(<can_have_value>)'.// Else if <can_have_value>
'\w+'.// Match only a single value
')'.// End if <can_have_value>
')'.// End if <can_have_multiple_values>
')?'.// End Group <values>
')?'.// End Group
'('.// Start Group
'\s+:\s+'.// [space] followed by ':' followed by [space]
'(?<description>.+)'.// Match Group <description>
')?'.// End Group
'$/'; // Match end of string
$matches = [];
$result = preg_match($pattern, $flag, $matches);
if ($result === 0 || $result === false) {
throw new LogicException("[$flag] is improperly formatted for a shell option.");
}
// Set flag
$parsedFlag['flag'] = null;
if (isset($matches['flag'])) {
$parsedFlag['flag'] = $matches['flag'];
}
// Set enable
$parsedFlag['enable'] = false;
if (! empty($matches['enable'])) {
$parsedFlag['enable'] = true;
}
// Set can have value
$parsedFlag['can_have_value'] = false;
if (! empty($matches['can_have_value'])) {
$parsedFlag['can_have_value'] = true;
}
// Set can have multiple values
$parsedFlag['can_have_multiple_values'] = false;
if (! empty($matches['can_have_multiple_values'])) {
$parsedFlag['can_have_multiple_values'] = true;
}
// Set the values
$parsedFlag['values'] = [];
if (! empty($matches['values']) && $parsedFlag['can_have_value']) {
$parsedFlag['values'] = $matches['values'];
if ($parsedFlag['can_have_multiple_values']) {
$parsedFlag['values'] = explode(',', $matches['values']);
}
}
// Set the description
$parsedFlag['description'] = null;
if (isset($matches['description'])) {
$parsedFlag['description'] = $matches['description'];
}
return $parsedFlag;
} | [
"private",
"function",
"parseFlag",
"(",
"$",
"flag",
")",
"{",
"$",
"flag",
"=",
"trim",
"(",
"$",
"flag",
")",
";",
"$",
"pattern",
"=",
"'/^'",
".",
"// Match start of string",
"'('",
".",
"// Start Group",
"'(?<flag>(?:-\\w|--\\w[\\w-]+))'",
".",
"// Match Group <flag>",
"'(?<enable>\\+)?'",
".",
"//Enable option by default (useful for creating special commands)",
"')'",
".",
"// End Group",
"'('",
".",
"// Start Group",
"'(?<can_have_value>=)?'",
".",
"// Match Group <can_have_value>",
"'(?<can_have_multiple_values>\\*)?'",
".",
"// Match Group <can_have_multiple_values>",
"'(?<values>'",
".",
"// Match Group <values>",
"'(?(<can_have_multiple_values>)'",
".",
"// If <can_have_multiple_values>",
"'(\\w+,)*\\w+|'",
".",
"// Match multiple comma-separated values",
"'(?(<can_have_value>)'",
".",
"// Else if <can_have_value>",
"'\\w+'",
".",
"// Match only a single value",
"')'",
".",
"// End if <can_have_value>",
"')'",
".",
"// End if <can_have_multiple_values>",
"')?'",
".",
"// End Group <values>",
"')?'",
".",
"// End Group",
"'('",
".",
"// Start Group",
"'\\s+:\\s+'",
".",
"// [space] followed by ':' followed by [space]",
"'(?<description>.+)'",
".",
"// Match Group <description>",
"')?'",
".",
"// End Group",
"'$/'",
";",
"// Match end of string",
"$",
"matches",
"=",
"[",
"]",
";",
"$",
"result",
"=",
"preg_match",
"(",
"$",
"pattern",
",",
"$",
"flag",
",",
"$",
"matches",
")",
";",
"if",
"(",
"$",
"result",
"===",
"0",
"||",
"$",
"result",
"===",
"false",
")",
"{",
"throw",
"new",
"LogicException",
"(",
"\"[$flag] is improperly formatted for a shell option.\"",
")",
";",
"}",
"// Set flag",
"$",
"parsedFlag",
"[",
"'flag'",
"]",
"=",
"null",
";",
"if",
"(",
"isset",
"(",
"$",
"matches",
"[",
"'flag'",
"]",
")",
")",
"{",
"$",
"parsedFlag",
"[",
"'flag'",
"]",
"=",
"$",
"matches",
"[",
"'flag'",
"]",
";",
"}",
"// Set enable",
"$",
"parsedFlag",
"[",
"'enable'",
"]",
"=",
"false",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"matches",
"[",
"'enable'",
"]",
")",
")",
"{",
"$",
"parsedFlag",
"[",
"'enable'",
"]",
"=",
"true",
";",
"}",
"// Set can have value",
"$",
"parsedFlag",
"[",
"'can_have_value'",
"]",
"=",
"false",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"matches",
"[",
"'can_have_value'",
"]",
")",
")",
"{",
"$",
"parsedFlag",
"[",
"'can_have_value'",
"]",
"=",
"true",
";",
"}",
"// Set can have multiple values",
"$",
"parsedFlag",
"[",
"'can_have_multiple_values'",
"]",
"=",
"false",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"matches",
"[",
"'can_have_multiple_values'",
"]",
")",
")",
"{",
"$",
"parsedFlag",
"[",
"'can_have_multiple_values'",
"]",
"=",
"true",
";",
"}",
"// Set the values",
"$",
"parsedFlag",
"[",
"'values'",
"]",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"matches",
"[",
"'values'",
"]",
")",
"&&",
"$",
"parsedFlag",
"[",
"'can_have_value'",
"]",
")",
"{",
"$",
"parsedFlag",
"[",
"'values'",
"]",
"=",
"$",
"matches",
"[",
"'values'",
"]",
";",
"if",
"(",
"$",
"parsedFlag",
"[",
"'can_have_multiple_values'",
"]",
")",
"{",
"$",
"parsedFlag",
"[",
"'values'",
"]",
"=",
"explode",
"(",
"','",
",",
"$",
"matches",
"[",
"'values'",
"]",
")",
";",
"}",
"}",
"// Set the description",
"$",
"parsedFlag",
"[",
"'description'",
"]",
"=",
"null",
";",
"if",
"(",
"isset",
"(",
"$",
"matches",
"[",
"'description'",
"]",
")",
")",
"{",
"$",
"parsedFlag",
"[",
"'description'",
"]",
"=",
"$",
"matches",
"[",
"'description'",
"]",
";",
"}",
"return",
"$",
"parsedFlag",
";",
"}"
]
| Parse a given flag.
The flag should be in one of the following formats:
- "-v"
- "--verbose"
- "-a="
- "--address="
- "-a=*"
- "--address=*"
@param string $flag
@return array | [
"Parse",
"a",
"given",
"flag",
"."
]
| 1a5f3fcf689f33098b192c34839effe309202c0e | https://github.com/trafficgate/shell-command/blob/1a5f3fcf689f33098b192c34839effe309202c0e/src/ShellOption.php#L296-L370 |
17,124 | trafficgate/shell-command | src/ShellOption.php | ShellOption.setDescription | private function setDescription($description = null)
{
if (isset($description) && ! is_string($description)) {
throw new InvalidArgumentException("Description must be a string. [$description] given.");
}
$this->description = $description;
} | php | private function setDescription($description = null)
{
if (isset($description) && ! is_string($description)) {
throw new InvalidArgumentException("Description must be a string. [$description] given.");
}
$this->description = $description;
} | [
"private",
"function",
"setDescription",
"(",
"$",
"description",
"=",
"null",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"description",
")",
"&&",
"!",
"is_string",
"(",
"$",
"description",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Description must be a string. [$description] given.\"",
")",
";",
"}",
"$",
"this",
"->",
"description",
"=",
"$",
"description",
";",
"}"
]
| Set the description.
@param string|null $description
@throws InvalidArgumentException | [
"Set",
"the",
"description",
"."
]
| 1a5f3fcf689f33098b192c34839effe309202c0e | https://github.com/trafficgate/shell-command/blob/1a5f3fcf689f33098b192c34839effe309202c0e/src/ShellOption.php#L439-L446 |
17,125 | trafficgate/shell-command | src/ShellOption.php | ShellOption.setValues | private function setValues($values)
{
if (! empty($values)) {
if ($this->canHaveMultipleValues()) {
$this->addValues($values);
} elseif ($this->canHaveValue()) {
$this->addValue($values);
}
}
return $this;
} | php | private function setValues($values)
{
if (! empty($values)) {
if ($this->canHaveMultipleValues()) {
$this->addValues($values);
} elseif ($this->canHaveValue()) {
$this->addValue($values);
}
}
return $this;
} | [
"private",
"function",
"setValues",
"(",
"$",
"values",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"values",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"canHaveMultipleValues",
"(",
")",
")",
"{",
"$",
"this",
"->",
"addValues",
"(",
"$",
"values",
")",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"canHaveValue",
"(",
")",
")",
"{",
"$",
"this",
"->",
"addValue",
"(",
"$",
"values",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
]
| Set the values for this option.
@param array $values
@return $this | [
"Set",
"the",
"values",
"for",
"this",
"option",
"."
]
| 1a5f3fcf689f33098b192c34839effe309202c0e | https://github.com/trafficgate/shell-command/blob/1a5f3fcf689f33098b192c34839effe309202c0e/src/ShellOption.php#L455-L466 |
17,126 | webtorque7/link-field | code/WTTreeDropdownField.php | WTTreeDropdownField.Link | public function Link($action = null) {
$name = $this->name;
if (($pos = stripos($name, '[')) !== false) {
$name = substr($name, 0, $pos);
$action = substr($this->name, $pos + 1, strlen($this->name) - 1 - ($pos + 1)) . 'Tree';
}
return Controller::join_links($this->form->FormAction(), 'field/' . $name, $action);
} | php | public function Link($action = null) {
$name = $this->name;
if (($pos = stripos($name, '[')) !== false) {
$name = substr($name, 0, $pos);
$action = substr($this->name, $pos + 1, strlen($this->name) - 1 - ($pos + 1)) . 'Tree';
}
return Controller::join_links($this->form->FormAction(), 'field/' . $name, $action);
} | [
"public",
"function",
"Link",
"(",
"$",
"action",
"=",
"null",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"name",
";",
"if",
"(",
"(",
"$",
"pos",
"=",
"stripos",
"(",
"$",
"name",
",",
"'['",
")",
")",
"!==",
"false",
")",
"{",
"$",
"name",
"=",
"substr",
"(",
"$",
"name",
",",
"0",
",",
"$",
"pos",
")",
";",
"$",
"action",
"=",
"substr",
"(",
"$",
"this",
"->",
"name",
",",
"$",
"pos",
"+",
"1",
",",
"strlen",
"(",
"$",
"this",
"->",
"name",
")",
"-",
"1",
"-",
"(",
"$",
"pos",
"+",
"1",
")",
")",
".",
"'Tree'",
";",
"}",
"return",
"Controller",
"::",
"join_links",
"(",
"$",
"this",
"->",
"form",
"->",
"FormAction",
"(",
")",
",",
"'field/'",
".",
"$",
"name",
",",
"$",
"action",
")",
";",
"}"
]
| Return a Link to this field | [
"Return",
"a",
"Link",
"to",
"this",
"field"
]
| b846644e1d35676419e71f3127cfc8f150aff081 | https://github.com/webtorque7/link-field/blob/b846644e1d35676419e71f3127cfc8f150aff081/code/WTTreeDropdownField.php#L8-L18 |
17,127 | Sedona-Solutions/sedona-sbo | src/Sedona/SBORuntimeBundle/Datatable/Data/DatatableQuery.php | DatatableQuery.setWhereResultCallback | private function setWhereResultCallback(QueryBuilder $qb)
{
if (!empty($this->callbacks['WhereResult'])) {
foreach ($this->callbacks['WhereResult'] as $callback) {
$callback($qb);
}
}
return $this;
} | php | private function setWhereResultCallback(QueryBuilder $qb)
{
if (!empty($this->callbacks['WhereResult'])) {
foreach ($this->callbacks['WhereResult'] as $callback) {
$callback($qb);
}
}
return $this;
} | [
"private",
"function",
"setWhereResultCallback",
"(",
"QueryBuilder",
"$",
"qb",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"callbacks",
"[",
"'WhereResult'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"callbacks",
"[",
"'WhereResult'",
"]",
"as",
"$",
"callback",
")",
"{",
"$",
"callback",
"(",
"$",
"qb",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
]
| Set where result callback.
@param QueryBuilder $qb
@return $this | [
"Set",
"where",
"result",
"callback",
"."
]
| 8548be4170d191cb1a3e263577aaaab49f04d5ce | https://github.com/Sedona-Solutions/sedona-sbo/blob/8548be4170d191cb1a3e263577aaaab49f04d5ce/src/Sedona/SBORuntimeBundle/Datatable/Data/DatatableQuery.php#L419-L428 |
17,128 | Sedona-Solutions/sedona-sbo | src/Sedona/SBORuntimeBundle/Datatable/Data/DatatableQuery.php | DatatableQuery.setWhereAllCallback | private function setWhereAllCallback(QueryBuilder $qb)
{
if (!empty($this->callbacks['WhereAll'])) {
foreach ($this->callbacks['WhereAll'] as $callback) {
$callback($qb);
}
}
return $this;
} | php | private function setWhereAllCallback(QueryBuilder $qb)
{
if (!empty($this->callbacks['WhereAll'])) {
foreach ($this->callbacks['WhereAll'] as $callback) {
$callback($qb);
}
}
return $this;
} | [
"private",
"function",
"setWhereAllCallback",
"(",
"QueryBuilder",
"$",
"qb",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"callbacks",
"[",
"'WhereAll'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"callbacks",
"[",
"'WhereAll'",
"]",
"as",
"$",
"callback",
")",
"{",
"$",
"callback",
"(",
"$",
"qb",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
]
| Set where all callback.
@param QueryBuilder $qb
@return $this | [
"Set",
"where",
"all",
"callback",
"."
]
| 8548be4170d191cb1a3e263577aaaab49f04d5ce | https://github.com/Sedona-Solutions/sedona-sbo/blob/8548be4170d191cb1a3e263577aaaab49f04d5ce/src/Sedona/SBORuntimeBundle/Datatable/Data/DatatableQuery.php#L437-L446 |
17,129 | Sedona-Solutions/sedona-sbo | src/Sedona/SBORuntimeBundle/Datatable/Data/DatatableQuery.php | DatatableQuery.setSelectFrom | private function setSelectFrom()
{
foreach ($this->selectColumns as $key => $value) {
$this->qb->addSelect($key);
}
$this->qb->from($this->entity, $this->tableName);
return $this;
} | php | private function setSelectFrom()
{
foreach ($this->selectColumns as $key => $value) {
$this->qb->addSelect($key);
}
$this->qb->from($this->entity, $this->tableName);
return $this;
} | [
"private",
"function",
"setSelectFrom",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"selectColumns",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"qb",
"->",
"addSelect",
"(",
"$",
"key",
")",
";",
"}",
"$",
"this",
"->",
"qb",
"->",
"from",
"(",
"$",
"this",
"->",
"entity",
",",
"$",
"this",
"->",
"tableName",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Set select from.
@return $this | [
"Set",
"select",
"from",
"."
]
| 8548be4170d191cb1a3e263577aaaab49f04d5ce | https://github.com/Sedona-Solutions/sedona-sbo/blob/8548be4170d191cb1a3e263577aaaab49f04d5ce/src/Sedona/SBORuntimeBundle/Datatable/Data/DatatableQuery.php#L457-L466 |
17,130 | Sedona-Solutions/sedona-sbo | src/Sedona/SBORuntimeBundle/Datatable/Data/DatatableQuery.php | DatatableQuery.setLeftJoins | private function setLeftJoins(QueryBuilder $qb)
{
foreach ($this->joins as $key => $value) {
$qb->leftJoin($key, $value);
}
return $this;
} | php | private function setLeftJoins(QueryBuilder $qb)
{
foreach ($this->joins as $key => $value) {
$qb->leftJoin($key, $value);
}
return $this;
} | [
"private",
"function",
"setLeftJoins",
"(",
"QueryBuilder",
"$",
"qb",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"joins",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"qb",
"->",
"leftJoin",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Set leftJoins.
@param QueryBuilder $qb
@return $this | [
"Set",
"leftJoins",
"."
]
| 8548be4170d191cb1a3e263577aaaab49f04d5ce | https://github.com/Sedona-Solutions/sedona-sbo/blob/8548be4170d191cb1a3e263577aaaab49f04d5ce/src/Sedona/SBORuntimeBundle/Datatable/Data/DatatableQuery.php#L475-L482 |
17,131 | Sedona-Solutions/sedona-sbo | src/Sedona/SBORuntimeBundle/Datatable/Data/DatatableQuery.php | DatatableQuery.setOrderBy | private function setOrderBy()
{
if (isset($this->requestParams['order']) && count($this->requestParams['order'])) {
$counter = count($this->requestParams['order']);
for ($i = 0; $i < $counter; ++$i) {
$columnIdx = (integer) $this->requestParams['order'][$i]['column'];
$requestColumn = $this->requestParams['columns'][$columnIdx];
if ('true' == $requestColumn['orderable']) {
$this->qb->addOrderBy(
$this->orderColumns[$columnIdx],
$this->requestParams['order'][$i]['dir']
);
}
}
}
return $this;
} | php | private function setOrderBy()
{
if (isset($this->requestParams['order']) && count($this->requestParams['order'])) {
$counter = count($this->requestParams['order']);
for ($i = 0; $i < $counter; ++$i) {
$columnIdx = (integer) $this->requestParams['order'][$i]['column'];
$requestColumn = $this->requestParams['columns'][$columnIdx];
if ('true' == $requestColumn['orderable']) {
$this->qb->addOrderBy(
$this->orderColumns[$columnIdx],
$this->requestParams['order'][$i]['dir']
);
}
}
}
return $this;
} | [
"private",
"function",
"setOrderBy",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"requestParams",
"[",
"'order'",
"]",
")",
"&&",
"count",
"(",
"$",
"this",
"->",
"requestParams",
"[",
"'order'",
"]",
")",
")",
"{",
"$",
"counter",
"=",
"count",
"(",
"$",
"this",
"->",
"requestParams",
"[",
"'order'",
"]",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"counter",
";",
"++",
"$",
"i",
")",
"{",
"$",
"columnIdx",
"=",
"(",
"integer",
")",
"$",
"this",
"->",
"requestParams",
"[",
"'order'",
"]",
"[",
"$",
"i",
"]",
"[",
"'column'",
"]",
";",
"$",
"requestColumn",
"=",
"$",
"this",
"->",
"requestParams",
"[",
"'columns'",
"]",
"[",
"$",
"columnIdx",
"]",
";",
"if",
"(",
"'true'",
"==",
"$",
"requestColumn",
"[",
"'orderable'",
"]",
")",
"{",
"$",
"this",
"->",
"qb",
"->",
"addOrderBy",
"(",
"$",
"this",
"->",
"orderColumns",
"[",
"$",
"columnIdx",
"]",
",",
"$",
"this",
"->",
"requestParams",
"[",
"'order'",
"]",
"[",
"$",
"i",
"]",
"[",
"'dir'",
"]",
")",
";",
"}",
"}",
"}",
"return",
"$",
"this",
";",
"}"
]
| Ordering.
Construct the ORDER BY clause for server-side processing SQL query.
@return $this | [
"Ordering",
".",
"Construct",
"the",
"ORDER",
"BY",
"clause",
"for",
"server",
"-",
"side",
"processing",
"SQL",
"query",
"."
]
| 8548be4170d191cb1a3e263577aaaab49f04d5ce | https://github.com/Sedona-Solutions/sedona-sbo/blob/8548be4170d191cb1a3e263577aaaab49f04d5ce/src/Sedona/SBORuntimeBundle/Datatable/Data/DatatableQuery.php#L623-L642 |
17,132 | Sedona-Solutions/sedona-sbo | src/Sedona/SBORuntimeBundle/Datatable/Data/DatatableQuery.php | DatatableQuery.setLimit | private function setLimit()
{
if (isset($this->requestParams['start']) && -1 != $this->requestParams['length']) {
$this->qb->setFirstResult($this->requestParams['start'])->setMaxResults($this->requestParams['length']);
}
return $this;
} | php | private function setLimit()
{
if (isset($this->requestParams['start']) && -1 != $this->requestParams['length']) {
$this->qb->setFirstResult($this->requestParams['start'])->setMaxResults($this->requestParams['length']);
}
return $this;
} | [
"private",
"function",
"setLimit",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"requestParams",
"[",
"'start'",
"]",
")",
"&&",
"-",
"1",
"!=",
"$",
"this",
"->",
"requestParams",
"[",
"'length'",
"]",
")",
"{",
"$",
"this",
"->",
"qb",
"->",
"setFirstResult",
"(",
"$",
"this",
"->",
"requestParams",
"[",
"'start'",
"]",
")",
"->",
"setMaxResults",
"(",
"$",
"this",
"->",
"requestParams",
"[",
"'length'",
"]",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Paging.
Construct the LIMIT clause for server-side processing SQL query.
@return $this | [
"Paging",
".",
"Construct",
"the",
"LIMIT",
"clause",
"for",
"server",
"-",
"side",
"processing",
"SQL",
"query",
"."
]
| 8548be4170d191cb1a3e263577aaaab49f04d5ce | https://github.com/Sedona-Solutions/sedona-sbo/blob/8548be4170d191cb1a3e263577aaaab49f04d5ce/src/Sedona/SBORuntimeBundle/Datatable/Data/DatatableQuery.php#L650-L657 |
17,133 | Sedona-Solutions/sedona-sbo | src/Sedona/SBORuntimeBundle/Datatable/Data/DatatableQuery.php | DatatableQuery.getCountAllResults | private function getCountAllResults($rootEntityIdentifier)
{
$qb = $this->em->createQueryBuilder();
$qb->select('count(distinct '.$this->tableName.'.'.$rootEntityIdentifier.')');
$qb->from($this->entity, $this->tableName);
$this->setLeftJoins($qb);
$this->setWhereAllCallback($qb);
return (int) $qb->getQuery()->getSingleScalarResult();
} | php | private function getCountAllResults($rootEntityIdentifier)
{
$qb = $this->em->createQueryBuilder();
$qb->select('count(distinct '.$this->tableName.'.'.$rootEntityIdentifier.')');
$qb->from($this->entity, $this->tableName);
$this->setLeftJoins($qb);
$this->setWhereAllCallback($qb);
return (int) $qb->getQuery()->getSingleScalarResult();
} | [
"private",
"function",
"getCountAllResults",
"(",
"$",
"rootEntityIdentifier",
")",
"{",
"$",
"qb",
"=",
"$",
"this",
"->",
"em",
"->",
"createQueryBuilder",
"(",
")",
";",
"$",
"qb",
"->",
"select",
"(",
"'count(distinct '",
".",
"$",
"this",
"->",
"tableName",
".",
"'.'",
".",
"$",
"rootEntityIdentifier",
".",
"')'",
")",
";",
"$",
"qb",
"->",
"from",
"(",
"$",
"this",
"->",
"entity",
",",
"$",
"this",
"->",
"tableName",
")",
";",
"$",
"this",
"->",
"setLeftJoins",
"(",
"$",
"qb",
")",
";",
"$",
"this",
"->",
"setWhereAllCallback",
"(",
"$",
"qb",
")",
";",
"return",
"(",
"int",
")",
"$",
"qb",
"->",
"getQuery",
"(",
")",
"->",
"getSingleScalarResult",
"(",
")",
";",
"}"
]
| Query results before filtering.
@param int $rootEntityIdentifier
@return int | [
"Query",
"results",
"before",
"filtering",
"."
]
| 8548be4170d191cb1a3e263577aaaab49f04d5ce | https://github.com/Sedona-Solutions/sedona-sbo/blob/8548be4170d191cb1a3e263577aaaab49f04d5ce/src/Sedona/SBORuntimeBundle/Datatable/Data/DatatableQuery.php#L670-L680 |
17,134 | Sedona-Solutions/sedona-sbo | src/Sedona/SBORuntimeBundle/Datatable/Data/DatatableQuery.php | DatatableQuery.execute | private function execute()
{
$query = $this->qb->getQuery();
if (true === $this->configs['translation_query_hints']) {
if (true === $this->doctrineExtensions) {
$query->setHint(
\Doctrine\ORM\Query::HINT_CUSTOM_OUTPUT_WALKER,
'Gedmo\\Translatable\\Query\\TreeWalker\\TranslationWalker'
);
$query->setHint(
\Gedmo\Translatable\TranslatableListener::HINT_TRANSLATABLE_LOCALE,
$this->locale
);
$query->setHint(
\Gedmo\Translatable\TranslatableListener::HINT_FALLBACK,
1
);
} else {
throw new \Exception('execute(): "DoctrineExtensions" does not exist.');
}
}
$query->setHydrationMode(Query::HYDRATE_OBJECT);
return $query;
} | php | private function execute()
{
$query = $this->qb->getQuery();
if (true === $this->configs['translation_query_hints']) {
if (true === $this->doctrineExtensions) {
$query->setHint(
\Doctrine\ORM\Query::HINT_CUSTOM_OUTPUT_WALKER,
'Gedmo\\Translatable\\Query\\TreeWalker\\TranslationWalker'
);
$query->setHint(
\Gedmo\Translatable\TranslatableListener::HINT_TRANSLATABLE_LOCALE,
$this->locale
);
$query->setHint(
\Gedmo\Translatable\TranslatableListener::HINT_FALLBACK,
1
);
} else {
throw new \Exception('execute(): "DoctrineExtensions" does not exist.');
}
}
$query->setHydrationMode(Query::HYDRATE_OBJECT);
return $query;
} | [
"private",
"function",
"execute",
"(",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"qb",
"->",
"getQuery",
"(",
")",
";",
"if",
"(",
"true",
"===",
"$",
"this",
"->",
"configs",
"[",
"'translation_query_hints'",
"]",
")",
"{",
"if",
"(",
"true",
"===",
"$",
"this",
"->",
"doctrineExtensions",
")",
"{",
"$",
"query",
"->",
"setHint",
"(",
"\\",
"Doctrine",
"\\",
"ORM",
"\\",
"Query",
"::",
"HINT_CUSTOM_OUTPUT_WALKER",
",",
"'Gedmo\\\\Translatable\\\\Query\\\\TreeWalker\\\\TranslationWalker'",
")",
";",
"$",
"query",
"->",
"setHint",
"(",
"\\",
"Gedmo",
"\\",
"Translatable",
"\\",
"TranslatableListener",
"::",
"HINT_TRANSLATABLE_LOCALE",
",",
"$",
"this",
"->",
"locale",
")",
";",
"$",
"query",
"->",
"setHint",
"(",
"\\",
"Gedmo",
"\\",
"Translatable",
"\\",
"TranslatableListener",
"::",
"HINT_FALLBACK",
",",
"1",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'execute(): \"DoctrineExtensions\" does not exist.'",
")",
";",
"}",
"}",
"$",
"query",
"->",
"setHydrationMode",
"(",
"Query",
"::",
"HYDRATE_OBJECT",
")",
";",
"return",
"$",
"query",
";",
"}"
]
| Constructs a Query instance.
@return Query
@throws \Exception | [
"Constructs",
"a",
"Query",
"instance",
"."
]
| 8548be4170d191cb1a3e263577aaaab49f04d5ce | https://github.com/Sedona-Solutions/sedona-sbo/blob/8548be4170d191cb1a3e263577aaaab49f04d5ce/src/Sedona/SBORuntimeBundle/Datatable/Data/DatatableQuery.php#L709-L737 |
17,135 | Sedona-Solutions/sedona-sbo | src/Sedona/SBORuntimeBundle/Datatable/Data/DatatableQuery.php | DatatableQuery.entityFieldToArray | private function entityFieldToArray(array $data, $entity, $path)
{
$parts = explode('.', $path, 2);
if (count($parts) === 1) {
if ($entity instanceof \Traversable) {
$data = [];
foreach ($entity as $item) {
$id = $this->em->getClassMetadata(get_class($item))->getSingleIdentifierColumnName();
$data[] = [
$id => $this->propertyAccessor->getValue($item, $id),
$parts[0] => $this->propertyAccessor->getValue($item, $parts[0]),
];
}
} else {
if (count($data) === 0) {
$data = [];
$id = $this->em->getClassMetadata(get_class($entity))->getSingleIdentifierColumnName();
$data[$id] = $this->propertyAccessor->getValue($entity, $id);
}
$data[$parts[0]] = $this->propertyAccessor->getValue($entity, $parts[0]);
}
return $data;
} else {
$data[$parts[0]] = $this->entityFieldToArray(
isset($data[$parts[0]]) ? $data[$parts[0]] : [],
$this->propertyAccessor->getValue($entity, $parts[0]),
$parts[1]
);
return $data;
}
} | php | private function entityFieldToArray(array $data, $entity, $path)
{
$parts = explode('.', $path, 2);
if (count($parts) === 1) {
if ($entity instanceof \Traversable) {
$data = [];
foreach ($entity as $item) {
$id = $this->em->getClassMetadata(get_class($item))->getSingleIdentifierColumnName();
$data[] = [
$id => $this->propertyAccessor->getValue($item, $id),
$parts[0] => $this->propertyAccessor->getValue($item, $parts[0]),
];
}
} else {
if (count($data) === 0) {
$data = [];
$id = $this->em->getClassMetadata(get_class($entity))->getSingleIdentifierColumnName();
$data[$id] = $this->propertyAccessor->getValue($entity, $id);
}
$data[$parts[0]] = $this->propertyAccessor->getValue($entity, $parts[0]);
}
return $data;
} else {
$data[$parts[0]] = $this->entityFieldToArray(
isset($data[$parts[0]]) ? $data[$parts[0]] : [],
$this->propertyAccessor->getValue($entity, $parts[0]),
$parts[1]
);
return $data;
}
} | [
"private",
"function",
"entityFieldToArray",
"(",
"array",
"$",
"data",
",",
"$",
"entity",
",",
"$",
"path",
")",
"{",
"$",
"parts",
"=",
"explode",
"(",
"'.'",
",",
"$",
"path",
",",
"2",
")",
";",
"if",
"(",
"count",
"(",
"$",
"parts",
")",
"===",
"1",
")",
"{",
"if",
"(",
"$",
"entity",
"instanceof",
"\\",
"Traversable",
")",
"{",
"$",
"data",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"entity",
"as",
"$",
"item",
")",
"{",
"$",
"id",
"=",
"$",
"this",
"->",
"em",
"->",
"getClassMetadata",
"(",
"get_class",
"(",
"$",
"item",
")",
")",
"->",
"getSingleIdentifierColumnName",
"(",
")",
";",
"$",
"data",
"[",
"]",
"=",
"[",
"$",
"id",
"=>",
"$",
"this",
"->",
"propertyAccessor",
"->",
"getValue",
"(",
"$",
"item",
",",
"$",
"id",
")",
",",
"$",
"parts",
"[",
"0",
"]",
"=>",
"$",
"this",
"->",
"propertyAccessor",
"->",
"getValue",
"(",
"$",
"item",
",",
"$",
"parts",
"[",
"0",
"]",
")",
",",
"]",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"count",
"(",
"$",
"data",
")",
"===",
"0",
")",
"{",
"$",
"data",
"=",
"[",
"]",
";",
"$",
"id",
"=",
"$",
"this",
"->",
"em",
"->",
"getClassMetadata",
"(",
"get_class",
"(",
"$",
"entity",
")",
")",
"->",
"getSingleIdentifierColumnName",
"(",
")",
";",
"$",
"data",
"[",
"$",
"id",
"]",
"=",
"$",
"this",
"->",
"propertyAccessor",
"->",
"getValue",
"(",
"$",
"entity",
",",
"$",
"id",
")",
";",
"}",
"$",
"data",
"[",
"$",
"parts",
"[",
"0",
"]",
"]",
"=",
"$",
"this",
"->",
"propertyAccessor",
"->",
"getValue",
"(",
"$",
"entity",
",",
"$",
"parts",
"[",
"0",
"]",
")",
";",
"}",
"return",
"$",
"data",
";",
"}",
"else",
"{",
"$",
"data",
"[",
"$",
"parts",
"[",
"0",
"]",
"]",
"=",
"$",
"this",
"->",
"entityFieldToArray",
"(",
"isset",
"(",
"$",
"data",
"[",
"$",
"parts",
"[",
"0",
"]",
"]",
")",
"?",
"$",
"data",
"[",
"$",
"parts",
"[",
"0",
"]",
"]",
":",
"[",
"]",
",",
"$",
"this",
"->",
"propertyAccessor",
"->",
"getValue",
"(",
"$",
"entity",
",",
"$",
"parts",
"[",
"0",
"]",
")",
",",
"$",
"parts",
"[",
"1",
"]",
")",
";",
"return",
"$",
"data",
";",
"}",
"}"
]
| Normalizes an entity path into an array.
Each entity of each level will have its id set.
All values are retrieved using a property accessor with magic call activated.
@param array $data
@param object $entity Entity to normalize
@param string $path Path to set in the array
@return array Normalized data | [
"Normalizes",
"an",
"entity",
"path",
"into",
"an",
"array",
".",
"Each",
"entity",
"of",
"each",
"level",
"will",
"have",
"its",
"id",
"set",
".",
"All",
"values",
"are",
"retrieved",
"using",
"a",
"property",
"accessor",
"with",
"magic",
"call",
"activated",
"."
]
| 8548be4170d191cb1a3e263577aaaab49f04d5ce | https://github.com/Sedona-Solutions/sedona-sbo/blob/8548be4170d191cb1a3e263577aaaab49f04d5ce/src/Sedona/SBORuntimeBundle/Datatable/Data/DatatableQuery.php#L754-L790 |
17,136 | Sedona-Solutions/sedona-sbo | src/Sedona/SBORuntimeBundle/Datatable/Data/DatatableQuery.php | DatatableQuery.setIdentifierFromAssociation | private function setIdentifierFromAssociation($association, $key = '', $i = 0, $metadata = null)
{
if (null === $metadata) {
$metadata = $this->metadata;
}
if (is_string($association)) {
$targetEntityClass = $metadata->getAssociationTargetClass($association);
$targetMetadata = $this->getMetadata($targetEntityClass);
$this->selectColumns[$association][] = $this->getIdentifier($targetMetadata);
}
if (is_array($association) && array_key_exists($i, $association)) {
$column = $association[$i];
$count = count($association) - 1;
if (true === $metadata->hasAssociation($column)) {
$targetEntityClass = $metadata->getAssociationTargetClass($column);
$targetMetadata = $this->getMetadata($targetEntityClass);
if ($count == $i) {
$this->selectColumns[$key][] = $this->getIdentifier($targetMetadata);
} else {
++$i;
$this->setIdentifierFromAssociation($association, $key, $i, $targetMetadata);
}
}
}
return $this;
} | php | private function setIdentifierFromAssociation($association, $key = '', $i = 0, $metadata = null)
{
if (null === $metadata) {
$metadata = $this->metadata;
}
if (is_string($association)) {
$targetEntityClass = $metadata->getAssociationTargetClass($association);
$targetMetadata = $this->getMetadata($targetEntityClass);
$this->selectColumns[$association][] = $this->getIdentifier($targetMetadata);
}
if (is_array($association) && array_key_exists($i, $association)) {
$column = $association[$i];
$count = count($association) - 1;
if (true === $metadata->hasAssociation($column)) {
$targetEntityClass = $metadata->getAssociationTargetClass($column);
$targetMetadata = $this->getMetadata($targetEntityClass);
if ($count == $i) {
$this->selectColumns[$key][] = $this->getIdentifier($targetMetadata);
} else {
++$i;
$this->setIdentifierFromAssociation($association, $key, $i, $targetMetadata);
}
}
}
return $this;
} | [
"private",
"function",
"setIdentifierFromAssociation",
"(",
"$",
"association",
",",
"$",
"key",
"=",
"''",
",",
"$",
"i",
"=",
"0",
",",
"$",
"metadata",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"metadata",
")",
"{",
"$",
"metadata",
"=",
"$",
"this",
"->",
"metadata",
";",
"}",
"if",
"(",
"is_string",
"(",
"$",
"association",
")",
")",
"{",
"$",
"targetEntityClass",
"=",
"$",
"metadata",
"->",
"getAssociationTargetClass",
"(",
"$",
"association",
")",
";",
"$",
"targetMetadata",
"=",
"$",
"this",
"->",
"getMetadata",
"(",
"$",
"targetEntityClass",
")",
";",
"$",
"this",
"->",
"selectColumns",
"[",
"$",
"association",
"]",
"[",
"]",
"=",
"$",
"this",
"->",
"getIdentifier",
"(",
"$",
"targetMetadata",
")",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"association",
")",
"&&",
"array_key_exists",
"(",
"$",
"i",
",",
"$",
"association",
")",
")",
"{",
"$",
"column",
"=",
"$",
"association",
"[",
"$",
"i",
"]",
";",
"$",
"count",
"=",
"count",
"(",
"$",
"association",
")",
"-",
"1",
";",
"if",
"(",
"true",
"===",
"$",
"metadata",
"->",
"hasAssociation",
"(",
"$",
"column",
")",
")",
"{",
"$",
"targetEntityClass",
"=",
"$",
"metadata",
"->",
"getAssociationTargetClass",
"(",
"$",
"column",
")",
";",
"$",
"targetMetadata",
"=",
"$",
"this",
"->",
"getMetadata",
"(",
"$",
"targetEntityClass",
")",
";",
"if",
"(",
"$",
"count",
"==",
"$",
"i",
")",
"{",
"$",
"this",
"->",
"selectColumns",
"[",
"$",
"key",
"]",
"[",
"]",
"=",
"$",
"this",
"->",
"getIdentifier",
"(",
"$",
"targetMetadata",
")",
";",
"}",
"else",
"{",
"++",
"$",
"i",
";",
"$",
"this",
"->",
"setIdentifierFromAssociation",
"(",
"$",
"association",
",",
"$",
"key",
",",
"$",
"i",
",",
"$",
"targetMetadata",
")",
";",
"}",
"}",
"}",
"return",
"$",
"this",
";",
"}"
]
| Set identifier from association.
@param string|array $association
@param string $key
@param int $i
@param ClassMetadata|null $metadata
@return $this
@throws \Exception | [
"Set",
"identifier",
"from",
"association",
"."
]
| 8548be4170d191cb1a3e263577aaaab49f04d5ce | https://github.com/Sedona-Solutions/sedona-sbo/blob/8548be4170d191cb1a3e263577aaaab49f04d5ce/src/Sedona/SBORuntimeBundle/Datatable/Data/DatatableQuery.php#L955-L983 |
17,137 | Sedona-Solutions/sedona-sbo | src/Sedona/SBORuntimeBundle/Datatable/Data/DatatableQuery.php | DatatableQuery.isSelectColumn | private function isSelectColumn($data)
{
if (null !== $data && !in_array($data, $this->virtualColumns)) {
return true;
}
return false;
} | php | private function isSelectColumn($data)
{
if (null !== $data && !in_array($data, $this->virtualColumns)) {
return true;
}
return false;
} | [
"private",
"function",
"isSelectColumn",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"data",
"&&",
"!",
"in_array",
"(",
"$",
"data",
",",
"$",
"this",
"->",
"virtualColumns",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
]
| Is select column.
@param string $data
@return bool | [
"Is",
"select",
"column",
"."
]
| 8548be4170d191cb1a3e263577aaaab49f04d5ce | https://github.com/Sedona-Solutions/sedona-sbo/blob/8548be4170d191cb1a3e263577aaaab49f04d5ce/src/Sedona/SBORuntimeBundle/Datatable/Data/DatatableQuery.php#L1004-L1011 |
17,138 | Sedona-Solutions/sedona-sbo | src/Sedona/SBORuntimeBundle/Datatable/Data/DatatableQuery.php | DatatableQuery.isSearchColumn | private function isSearchColumn(AbstractColumn $column)
{
if (false === $this->configs['search_on_non_visible_columns']) {
if (null !== $column->getDql() && true === $column->getSearchable() && true === $column->getVisible()) {
return true;
}
} else {
if (null !== $column->getDql() && true === $column->getSearchable()) {
return true;
}
}
return false;
} | php | private function isSearchColumn(AbstractColumn $column)
{
if (false === $this->configs['search_on_non_visible_columns']) {
if (null !== $column->getDql() && true === $column->getSearchable() && true === $column->getVisible()) {
return true;
}
} else {
if (null !== $column->getDql() && true === $column->getSearchable()) {
return true;
}
}
return false;
} | [
"private",
"function",
"isSearchColumn",
"(",
"AbstractColumn",
"$",
"column",
")",
"{",
"if",
"(",
"false",
"===",
"$",
"this",
"->",
"configs",
"[",
"'search_on_non_visible_columns'",
"]",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"column",
"->",
"getDql",
"(",
")",
"&&",
"true",
"===",
"$",
"column",
"->",
"getSearchable",
"(",
")",
"&&",
"true",
"===",
"$",
"column",
"->",
"getVisible",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"null",
"!==",
"$",
"column",
"->",
"getDql",
"(",
")",
"&&",
"true",
"===",
"$",
"column",
"->",
"getSearchable",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
]
| Is search column.
@param AbstractColumn $column
@return bool | [
"Is",
"search",
"column",
"."
]
| 8548be4170d191cb1a3e263577aaaab49f04d5ce | https://github.com/Sedona-Solutions/sedona-sbo/blob/8548be4170d191cb1a3e263577aaaab49f04d5ce/src/Sedona/SBORuntimeBundle/Datatable/Data/DatatableQuery.php#L1020-L1033 |
17,139 | Sedona-Solutions/sedona-sbo | src/Sedona/SBORuntimeBundle/Datatable/Data/DatatableQuery.php | DatatableQuery.renderImage | private function renderImage($imageName, ImageColumn $column)
{
return $this->twig->render(
'SgDatatablesBundle:Helper:ii_render_image.html.twig',
array(
'image_id' => 'sg_image_'.uniqid(rand(10000, 99999)),
'image_name' => $imageName,
'filter' => $column->getImagineFilter(),
'path' => $column->getRelativePath(),
'holder_url' => $column->getHolderUrl(),
'width' => $column->getHolderWidth(),
'height' => $column->getHolderHeight(),
'enlarge' => $column->getEnlarge(),
)
);
} | php | private function renderImage($imageName, ImageColumn $column)
{
return $this->twig->render(
'SgDatatablesBundle:Helper:ii_render_image.html.twig',
array(
'image_id' => 'sg_image_'.uniqid(rand(10000, 99999)),
'image_name' => $imageName,
'filter' => $column->getImagineFilter(),
'path' => $column->getRelativePath(),
'holder_url' => $column->getHolderUrl(),
'width' => $column->getHolderWidth(),
'height' => $column->getHolderHeight(),
'enlarge' => $column->getEnlarge(),
)
);
} | [
"private",
"function",
"renderImage",
"(",
"$",
"imageName",
",",
"ImageColumn",
"$",
"column",
")",
"{",
"return",
"$",
"this",
"->",
"twig",
"->",
"render",
"(",
"'SgDatatablesBundle:Helper:ii_render_image.html.twig'",
",",
"array",
"(",
"'image_id'",
"=>",
"'sg_image_'",
".",
"uniqid",
"(",
"rand",
"(",
"10000",
",",
"99999",
")",
")",
",",
"'image_name'",
"=>",
"$",
"imageName",
",",
"'filter'",
"=>",
"$",
"column",
"->",
"getImagineFilter",
"(",
")",
",",
"'path'",
"=>",
"$",
"column",
"->",
"getRelativePath",
"(",
")",
",",
"'holder_url'",
"=>",
"$",
"column",
"->",
"getHolderUrl",
"(",
")",
",",
"'width'",
"=>",
"$",
"column",
"->",
"getHolderWidth",
"(",
")",
",",
"'height'",
"=>",
"$",
"column",
"->",
"getHolderHeight",
"(",
")",
",",
"'enlarge'",
"=>",
"$",
"column",
"->",
"getEnlarge",
"(",
")",
",",
")",
")",
";",
"}"
]
| Render image.
@param string $imageName
@param ImageColumn $column
@return string | [
"Render",
"image",
"."
]
| 8548be4170d191cb1a3e263577aaaab49f04d5ce | https://github.com/Sedona-Solutions/sedona-sbo/blob/8548be4170d191cb1a3e263577aaaab49f04d5ce/src/Sedona/SBORuntimeBundle/Datatable/Data/DatatableQuery.php#L1043-L1058 |
17,140 | slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseRole.php | BaseRole.countUserRoles | public function countUserRoles(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
{
$partial = $this->collUserRolesPartial && !$this->isNew();
if (null === $this->collUserRoles || null !== $criteria || $partial) {
if ($this->isNew() && null === $this->collUserRoles) {
return 0;
}
if ($partial && !$criteria) {
return count($this->getUserRoles());
}
$query = UserRoleQuery::create(null, $criteria);
if ($distinct) {
$query->distinct();
}
return $query
->filterByRole($this)
->count($con);
}
return count($this->collUserRoles);
} | php | public function countUserRoles(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
{
$partial = $this->collUserRolesPartial && !$this->isNew();
if (null === $this->collUserRoles || null !== $criteria || $partial) {
if ($this->isNew() && null === $this->collUserRoles) {
return 0;
}
if ($partial && !$criteria) {
return count($this->getUserRoles());
}
$query = UserRoleQuery::create(null, $criteria);
if ($distinct) {
$query->distinct();
}
return $query
->filterByRole($this)
->count($con);
}
return count($this->collUserRoles);
} | [
"public",
"function",
"countUserRoles",
"(",
"Criteria",
"$",
"criteria",
"=",
"null",
",",
"$",
"distinct",
"=",
"false",
",",
"PropelPDO",
"$",
"con",
"=",
"null",
")",
"{",
"$",
"partial",
"=",
"$",
"this",
"->",
"collUserRolesPartial",
"&&",
"!",
"$",
"this",
"->",
"isNew",
"(",
")",
";",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"collUserRoles",
"||",
"null",
"!==",
"$",
"criteria",
"||",
"$",
"partial",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isNew",
"(",
")",
"&&",
"null",
"===",
"$",
"this",
"->",
"collUserRoles",
")",
"{",
"return",
"0",
";",
"}",
"if",
"(",
"$",
"partial",
"&&",
"!",
"$",
"criteria",
")",
"{",
"return",
"count",
"(",
"$",
"this",
"->",
"getUserRoles",
"(",
")",
")",
";",
"}",
"$",
"query",
"=",
"UserRoleQuery",
"::",
"create",
"(",
"null",
",",
"$",
"criteria",
")",
";",
"if",
"(",
"$",
"distinct",
")",
"{",
"$",
"query",
"->",
"distinct",
"(",
")",
";",
"}",
"return",
"$",
"query",
"->",
"filterByRole",
"(",
"$",
"this",
")",
"->",
"count",
"(",
"$",
"con",
")",
";",
"}",
"return",
"count",
"(",
"$",
"this",
"->",
"collUserRoles",
")",
";",
"}"
]
| Returns the number of related UserRole objects.
@param Criteria $criteria
@param boolean $distinct
@param PropelPDO $con
@return int Count of related UserRole objects.
@throws PropelException | [
"Returns",
"the",
"number",
"of",
"related",
"UserRole",
"objects",
"."
]
| 2ba86d96f1f41f9424e2229c4e2b13017e973f89 | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseRole.php#L1066-L1088 |
17,141 | slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseRole.php | BaseRole.addUserRole | public function addUserRole(UserRole $l)
{
if ($this->collUserRoles === null) {
$this->initUserRoles();
$this->collUserRolesPartial = true;
}
if (!in_array($l, $this->collUserRoles->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
$this->doAddUserRole($l);
if ($this->userRolesScheduledForDeletion and $this->userRolesScheduledForDeletion->contains($l)) {
$this->userRolesScheduledForDeletion->remove($this->userRolesScheduledForDeletion->search($l));
}
}
return $this;
} | php | public function addUserRole(UserRole $l)
{
if ($this->collUserRoles === null) {
$this->initUserRoles();
$this->collUserRolesPartial = true;
}
if (!in_array($l, $this->collUserRoles->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
$this->doAddUserRole($l);
if ($this->userRolesScheduledForDeletion and $this->userRolesScheduledForDeletion->contains($l)) {
$this->userRolesScheduledForDeletion->remove($this->userRolesScheduledForDeletion->search($l));
}
}
return $this;
} | [
"public",
"function",
"addUserRole",
"(",
"UserRole",
"$",
"l",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"collUserRoles",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"initUserRoles",
"(",
")",
";",
"$",
"this",
"->",
"collUserRolesPartial",
"=",
"true",
";",
"}",
"if",
"(",
"!",
"in_array",
"(",
"$",
"l",
",",
"$",
"this",
"->",
"collUserRoles",
"->",
"getArrayCopy",
"(",
")",
",",
"true",
")",
")",
"{",
"// only add it if the **same** object is not already associated",
"$",
"this",
"->",
"doAddUserRole",
"(",
"$",
"l",
")",
";",
"if",
"(",
"$",
"this",
"->",
"userRolesScheduledForDeletion",
"and",
"$",
"this",
"->",
"userRolesScheduledForDeletion",
"->",
"contains",
"(",
"$",
"l",
")",
")",
"{",
"$",
"this",
"->",
"userRolesScheduledForDeletion",
"->",
"remove",
"(",
"$",
"this",
"->",
"userRolesScheduledForDeletion",
"->",
"search",
"(",
"$",
"l",
")",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
]
| Method called to associate a UserRole object to this object
through the UserRole foreign key attribute.
@param UserRole $l UserRole
@return Role The current object (for fluent API support) | [
"Method",
"called",
"to",
"associate",
"a",
"UserRole",
"object",
"to",
"this",
"object",
"through",
"the",
"UserRole",
"foreign",
"key",
"attribute",
"."
]
| 2ba86d96f1f41f9424e2229c4e2b13017e973f89 | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseRole.php#L1097-L1113 |
17,142 | slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseRole.php | BaseRole.getUserRolesJoinUser | public function getUserRolesJoinUser($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
{
$query = UserRoleQuery::create(null, $criteria);
$query->joinWith('User', $join_behavior);
return $this->getUserRoles($query, $con);
} | php | public function getUserRolesJoinUser($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
{
$query = UserRoleQuery::create(null, $criteria);
$query->joinWith('User', $join_behavior);
return $this->getUserRoles($query, $con);
} | [
"public",
"function",
"getUserRolesJoinUser",
"(",
"$",
"criteria",
"=",
"null",
",",
"$",
"con",
"=",
"null",
",",
"$",
"join_behavior",
"=",
"Criteria",
"::",
"LEFT_JOIN",
")",
"{",
"$",
"query",
"=",
"UserRoleQuery",
"::",
"create",
"(",
"null",
",",
"$",
"criteria",
")",
";",
"$",
"query",
"->",
"joinWith",
"(",
"'User'",
",",
"$",
"join_behavior",
")",
";",
"return",
"$",
"this",
"->",
"getUserRoles",
"(",
"$",
"query",
",",
"$",
"con",
")",
";",
"}"
]
| If this collection has already been initialized with
an identical criteria, it returns the collection.
Otherwise if this Role is new, it will return
an empty collection; or if this Role has previously
been saved, it will retrieve related UserRoles from storage.
This method is protected by default in order to keep the public
api reasonable. You can provide public methods for those you
actually need in Role.
@param Criteria $criteria optional Criteria object to narrow the query
@param PropelPDO $con optional connection object
@param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
@return PropelObjectCollection|UserRole[] List of UserRole objects | [
"If",
"this",
"collection",
"has",
"already",
"been",
"initialized",
"with",
"an",
"identical",
"criteria",
"it",
"returns",
"the",
"collection",
".",
"Otherwise",
"if",
"this",
"Role",
"is",
"new",
"it",
"will",
"return",
"an",
"empty",
"collection",
";",
"or",
"if",
"this",
"Role",
"has",
"previously",
"been",
"saved",
"it",
"will",
"retrieve",
"related",
"UserRoles",
"from",
"storage",
"."
]
| 2ba86d96f1f41f9424e2229c4e2b13017e973f89 | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseRole.php#L1160-L1166 |
17,143 | SAREhub/PHP_Commons | src/SAREhub/Commons/Zmq/RequestReply/RequestSender.php | RequestSender.sendRequest | public function sendRequest($request, $wait = self::WAIT)
{
$this->getSocket()->send($request, ($wait) ? 0 : \ZMQ::MODE_DONTWAIT);
return $this;
} | php | public function sendRequest($request, $wait = self::WAIT)
{
$this->getSocket()->send($request, ($wait) ? 0 : \ZMQ::MODE_DONTWAIT);
return $this;
} | [
"public",
"function",
"sendRequest",
"(",
"$",
"request",
",",
"$",
"wait",
"=",
"self",
"::",
"WAIT",
")",
"{",
"$",
"this",
"->",
"getSocket",
"(",
")",
"->",
"send",
"(",
"$",
"request",
",",
"(",
"$",
"wait",
")",
"?",
"0",
":",
"\\",
"ZMQ",
"::",
"MODE_DONTWAIT",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Send request via ZMQ socket.
@param string $request Request payload.
@param bool $wait If true that operation would be block.
@return $this
@throws \ZMQSocketException | [
"Send",
"request",
"via",
"ZMQ",
"socket",
"."
]
| 4e1769ab6411a584112df1151dcc90e6b82fe2bb | https://github.com/SAREhub/PHP_Commons/blob/4e1769ab6411a584112df1151dcc90e6b82fe2bb/src/SAREhub/Commons/Zmq/RequestReply/RequestSender.php#L75-L79 |
17,144 | adammbalogh/key-value-store-memory | src/Adapter/MemoryAdapter/ValueTrait.php | ValueTrait.getValue | protected function getValue($key)
{
if (!array_key_exists($key, $this->store)) {
throw new KeyNotFoundException();
}
$getResult = $this->store[$key];
$unserialized = @unserialize($getResult);
if (Util::hasInternalExpireTime($unserialized)) {
$this->handleTtl($key, $unserialized['ts'], $unserialized['s']);
$getResult = $unserialized['v'];
}
return $getResult;
} | php | protected function getValue($key)
{
if (!array_key_exists($key, $this->store)) {
throw new KeyNotFoundException();
}
$getResult = $this->store[$key];
$unserialized = @unserialize($getResult);
if (Util::hasInternalExpireTime($unserialized)) {
$this->handleTtl($key, $unserialized['ts'], $unserialized['s']);
$getResult = $unserialized['v'];
}
return $getResult;
} | [
"protected",
"function",
"getValue",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"store",
")",
")",
"{",
"throw",
"new",
"KeyNotFoundException",
"(",
")",
";",
"}",
"$",
"getResult",
"=",
"$",
"this",
"->",
"store",
"[",
"$",
"key",
"]",
";",
"$",
"unserialized",
"=",
"@",
"unserialize",
"(",
"$",
"getResult",
")",
";",
"if",
"(",
"Util",
"::",
"hasInternalExpireTime",
"(",
"$",
"unserialized",
")",
")",
"{",
"$",
"this",
"->",
"handleTtl",
"(",
"$",
"key",
",",
"$",
"unserialized",
"[",
"'ts'",
"]",
",",
"$",
"unserialized",
"[",
"'s'",
"]",
")",
";",
"$",
"getResult",
"=",
"$",
"unserialized",
"[",
"'v'",
"]",
";",
"}",
"return",
"$",
"getResult",
";",
"}"
]
| Gets value, watches expiring.
@param string $key
@return mixed
@throws KeyNotFoundException | [
"Gets",
"value",
"watches",
"expiring",
"."
]
| 6bafb9037d61911f76343a7aa7270866b1a11995 | https://github.com/adammbalogh/key-value-store-memory/blob/6bafb9037d61911f76343a7aa7270866b1a11995/src/Adapter/MemoryAdapter/ValueTrait.php#L49-L65 |
17,145 | adammbalogh/key-value-store-memory | src/Adapter/MemoryAdapter/ValueTrait.php | ValueTrait.handleTtl | protected function handleTtl($key, $expireSetTs, $expireSec)
{
$ttl = $expireSetTs + $expireSec - time();
if ($ttl <= 0) {
unset($this->store[$key]);
throw new KeyNotFoundException();
}
return $ttl;
} | php | protected function handleTtl($key, $expireSetTs, $expireSec)
{
$ttl = $expireSetTs + $expireSec - time();
if ($ttl <= 0) {
unset($this->store[$key]);
throw new KeyNotFoundException();
}
return $ttl;
} | [
"protected",
"function",
"handleTtl",
"(",
"$",
"key",
",",
"$",
"expireSetTs",
",",
"$",
"expireSec",
")",
"{",
"$",
"ttl",
"=",
"$",
"expireSetTs",
"+",
"$",
"expireSec",
"-",
"time",
"(",
")",
";",
"if",
"(",
"$",
"ttl",
"<=",
"0",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"store",
"[",
"$",
"key",
"]",
")",
";",
"throw",
"new",
"KeyNotFoundException",
"(",
")",
";",
"}",
"return",
"$",
"ttl",
";",
"}"
]
| If ttl is lesser or equals 0 delete key.
@param string $key
@param int $expireSetTs
@param int $expireSec
@return int ttl
@throws KeyNotFoundException | [
"If",
"ttl",
"is",
"lesser",
"or",
"equals",
"0",
"delete",
"key",
"."
]
| 6bafb9037d61911f76343a7aa7270866b1a11995 | https://github.com/adammbalogh/key-value-store-memory/blob/6bafb9037d61911f76343a7aa7270866b1a11995/src/Adapter/MemoryAdapter/ValueTrait.php#L78-L88 |
17,146 | nyeholt/silverstripe-external-content | thirdparty/Zend/Http/Client/Adapter/Proxy.php | Zend_Http_Client_Adapter_Proxy.connectHandshake | protected function connectHandshake($host, $port = 443, $http_ver = '1.1', array &$headers = array())
{
$request = "CONNECT $host:$port HTTP/$http_ver\r\n" .
"Host: " . $this->config['proxy_host'] . "\r\n";
// Add the user-agent header
if (isset($this->config['useragent'])) {
$request .= "User-agent: " . $this->config['useragent'] . "\r\n";
}
// If the proxy-authorization header is set, send it to proxy but remove
// it from headers sent to target host
if (isset($headers['proxy-authorization'])) {
$request .= "Proxy-authorization: " . $headers['proxy-authorization'] . "\r\n";
unset($headers['proxy-authorization']);
}
$request .= "\r\n";
// Send the request
if (! @fwrite($this->socket, $request)) {
require_once 'Zend/Http/Client/Adapter/Exception.php';
throw new Zend_Http_Client_Adapter_Exception("Error writing request to proxy server");
}
// Read response headers only
$response = '';
$gotStatus = false;
while ($line = @fgets($this->socket)) {
$gotStatus = $gotStatus || (strpos($line, 'HTTP') !== false);
if ($gotStatus) {
$response .= $line;
if (!chop($line)) break;
}
}
// Check that the response from the proxy is 200
if (Zend_Http_Response::extractCode($response) != 200) {
require_once 'Zend/Http/Client/Adapter/Exception.php';
throw new Zend_Http_Client_Adapter_Exception("Unable to connect to HTTPS proxy. Server response: " . $response);
}
// If all is good, switch socket to secure mode. We have to fall back
// through the different modes
$modes = array(
STREAM_CRYPTO_METHOD_TLS_CLIENT,
STREAM_CRYPTO_METHOD_SSLv3_CLIENT,
STREAM_CRYPTO_METHOD_SSLv23_CLIENT,
STREAM_CRYPTO_METHOD_SSLv2_CLIENT
);
$success = false;
foreach($modes as $mode) {
$success = stream_socket_enable_crypto($this->socket, true, $mode);
if ($success) break;
}
if (! $success) {
require_once 'Zend/Http/Client/Adapter/Exception.php';
throw new Zend_Http_Client_Adapter_Exception("Unable to connect to" .
" HTTPS server through proxy: could not negotiate secure connection.");
}
} | php | protected function connectHandshake($host, $port = 443, $http_ver = '1.1', array &$headers = array())
{
$request = "CONNECT $host:$port HTTP/$http_ver\r\n" .
"Host: " . $this->config['proxy_host'] . "\r\n";
// Add the user-agent header
if (isset($this->config['useragent'])) {
$request .= "User-agent: " . $this->config['useragent'] . "\r\n";
}
// If the proxy-authorization header is set, send it to proxy but remove
// it from headers sent to target host
if (isset($headers['proxy-authorization'])) {
$request .= "Proxy-authorization: " . $headers['proxy-authorization'] . "\r\n";
unset($headers['proxy-authorization']);
}
$request .= "\r\n";
// Send the request
if (! @fwrite($this->socket, $request)) {
require_once 'Zend/Http/Client/Adapter/Exception.php';
throw new Zend_Http_Client_Adapter_Exception("Error writing request to proxy server");
}
// Read response headers only
$response = '';
$gotStatus = false;
while ($line = @fgets($this->socket)) {
$gotStatus = $gotStatus || (strpos($line, 'HTTP') !== false);
if ($gotStatus) {
$response .= $line;
if (!chop($line)) break;
}
}
// Check that the response from the proxy is 200
if (Zend_Http_Response::extractCode($response) != 200) {
require_once 'Zend/Http/Client/Adapter/Exception.php';
throw new Zend_Http_Client_Adapter_Exception("Unable to connect to HTTPS proxy. Server response: " . $response);
}
// If all is good, switch socket to secure mode. We have to fall back
// through the different modes
$modes = array(
STREAM_CRYPTO_METHOD_TLS_CLIENT,
STREAM_CRYPTO_METHOD_SSLv3_CLIENT,
STREAM_CRYPTO_METHOD_SSLv23_CLIENT,
STREAM_CRYPTO_METHOD_SSLv2_CLIENT
);
$success = false;
foreach($modes as $mode) {
$success = stream_socket_enable_crypto($this->socket, true, $mode);
if ($success) break;
}
if (! $success) {
require_once 'Zend/Http/Client/Adapter/Exception.php';
throw new Zend_Http_Client_Adapter_Exception("Unable to connect to" .
" HTTPS server through proxy: could not negotiate secure connection.");
}
} | [
"protected",
"function",
"connectHandshake",
"(",
"$",
"host",
",",
"$",
"port",
"=",
"443",
",",
"$",
"http_ver",
"=",
"'1.1'",
",",
"array",
"&",
"$",
"headers",
"=",
"array",
"(",
")",
")",
"{",
"$",
"request",
"=",
"\"CONNECT $host:$port HTTP/$http_ver\\r\\n\"",
".",
"\"Host: \"",
".",
"$",
"this",
"->",
"config",
"[",
"'proxy_host'",
"]",
".",
"\"\\r\\n\"",
";",
"// Add the user-agent header",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"config",
"[",
"'useragent'",
"]",
")",
")",
"{",
"$",
"request",
".=",
"\"User-agent: \"",
".",
"$",
"this",
"->",
"config",
"[",
"'useragent'",
"]",
".",
"\"\\r\\n\"",
";",
"}",
"// If the proxy-authorization header is set, send it to proxy but remove",
"// it from headers sent to target host",
"if",
"(",
"isset",
"(",
"$",
"headers",
"[",
"'proxy-authorization'",
"]",
")",
")",
"{",
"$",
"request",
".=",
"\"Proxy-authorization: \"",
".",
"$",
"headers",
"[",
"'proxy-authorization'",
"]",
".",
"\"\\r\\n\"",
";",
"unset",
"(",
"$",
"headers",
"[",
"'proxy-authorization'",
"]",
")",
";",
"}",
"$",
"request",
".=",
"\"\\r\\n\"",
";",
"// Send the request",
"if",
"(",
"!",
"@",
"fwrite",
"(",
"$",
"this",
"->",
"socket",
",",
"$",
"request",
")",
")",
"{",
"require_once",
"'Zend/Http/Client/Adapter/Exception.php'",
";",
"throw",
"new",
"Zend_Http_Client_Adapter_Exception",
"(",
"\"Error writing request to proxy server\"",
")",
";",
"}",
"// Read response headers only",
"$",
"response",
"=",
"''",
";",
"$",
"gotStatus",
"=",
"false",
";",
"while",
"(",
"$",
"line",
"=",
"@",
"fgets",
"(",
"$",
"this",
"->",
"socket",
")",
")",
"{",
"$",
"gotStatus",
"=",
"$",
"gotStatus",
"||",
"(",
"strpos",
"(",
"$",
"line",
",",
"'HTTP'",
")",
"!==",
"false",
")",
";",
"if",
"(",
"$",
"gotStatus",
")",
"{",
"$",
"response",
".=",
"$",
"line",
";",
"if",
"(",
"!",
"chop",
"(",
"$",
"line",
")",
")",
"break",
";",
"}",
"}",
"// Check that the response from the proxy is 200",
"if",
"(",
"Zend_Http_Response",
"::",
"extractCode",
"(",
"$",
"response",
")",
"!=",
"200",
")",
"{",
"require_once",
"'Zend/Http/Client/Adapter/Exception.php'",
";",
"throw",
"new",
"Zend_Http_Client_Adapter_Exception",
"(",
"\"Unable to connect to HTTPS proxy. Server response: \"",
".",
"$",
"response",
")",
";",
"}",
"// If all is good, switch socket to secure mode. We have to fall back",
"// through the different modes ",
"$",
"modes",
"=",
"array",
"(",
"STREAM_CRYPTO_METHOD_TLS_CLIENT",
",",
"STREAM_CRYPTO_METHOD_SSLv3_CLIENT",
",",
"STREAM_CRYPTO_METHOD_SSLv23_CLIENT",
",",
"STREAM_CRYPTO_METHOD_SSLv2_CLIENT",
")",
";",
"$",
"success",
"=",
"false",
";",
"foreach",
"(",
"$",
"modes",
"as",
"$",
"mode",
")",
"{",
"$",
"success",
"=",
"stream_socket_enable_crypto",
"(",
"$",
"this",
"->",
"socket",
",",
"true",
",",
"$",
"mode",
")",
";",
"if",
"(",
"$",
"success",
")",
"break",
";",
"}",
"if",
"(",
"!",
"$",
"success",
")",
"{",
"require_once",
"'Zend/Http/Client/Adapter/Exception.php'",
";",
"throw",
"new",
"Zend_Http_Client_Adapter_Exception",
"(",
"\"Unable to connect to\"",
".",
"\" HTTPS server through proxy: could not negotiate secure connection.\"",
")",
";",
"}",
"}"
]
| Preform handshaking with HTTPS proxy using CONNECT method
@param string $host
@param integer $port
@param string $http_ver
@param array $headers | [
"Preform",
"handshaking",
"with",
"HTTPS",
"proxy",
"using",
"CONNECT",
"method"
]
| 1c6da8c56ef717225ff904e1522aff94ed051601 | https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/thirdparty/Zend/Http/Client/Adapter/Proxy.php#L187-L249 |
17,147 | factorio-item-browser/export-data | src/Entity/LocalisedString.php | LocalisedString.setTranslation | public function setTranslation(string $locale, string $value)
{
if (strlen($value) === 0) {
unset($this->translations[$locale]);
} else {
$this->translations[$locale] = mb_convert_encoding($value, 'UTF-8', 'UTF-8');
}
return $this;
} | php | public function setTranslation(string $locale, string $value)
{
if (strlen($value) === 0) {
unset($this->translations[$locale]);
} else {
$this->translations[$locale] = mb_convert_encoding($value, 'UTF-8', 'UTF-8');
}
return $this;
} | [
"public",
"function",
"setTranslation",
"(",
"string",
"$",
"locale",
",",
"string",
"$",
"value",
")",
"{",
"if",
"(",
"strlen",
"(",
"$",
"value",
")",
"===",
"0",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"translations",
"[",
"$",
"locale",
"]",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"translations",
"[",
"$",
"locale",
"]",
"=",
"mb_convert_encoding",
"(",
"$",
"value",
",",
"'UTF-8'",
",",
"'UTF-8'",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Sets a translation of the localised string.
@param string $locale
@param string $value
@return $this | [
"Sets",
"a",
"translation",
"of",
"the",
"localised",
"string",
"."
]
| 1413b2eed0fbfed0521457ac7ef0d668ac30c212 | https://github.com/factorio-item-browser/export-data/blob/1413b2eed0fbfed0521457ac7ef0d668ac30c212/src/Entity/LocalisedString.php#L30-L38 |
17,148 | webforge-labs/psc-cms | lib/Psc/CMS/ProjectMain.php | ProjectMain.initDoctrinePackage | public function initDoctrinePackage() {
$module = $GLOBALS['env']['container']->getModule('Doctrine');
$this->dc = new DCPackage($module, $module->getEntityManager($this->getConnectionName()));
$this->attachEntityMetaListener(); // ganz wichtig das hier zu machen, weil das sonst das doctrinepackage initialisiert
} | php | public function initDoctrinePackage() {
$module = $GLOBALS['env']['container']->getModule('Doctrine');
$this->dc = new DCPackage($module, $module->getEntityManager($this->getConnectionName()));
$this->attachEntityMetaListener(); // ganz wichtig das hier zu machen, weil das sonst das doctrinepackage initialisiert
} | [
"public",
"function",
"initDoctrinePackage",
"(",
")",
"{",
"$",
"module",
"=",
"$",
"GLOBALS",
"[",
"'env'",
"]",
"[",
"'container'",
"]",
"->",
"getModule",
"(",
"'Doctrine'",
")",
";",
"$",
"this",
"->",
"dc",
"=",
"new",
"DCPackage",
"(",
"$",
"module",
",",
"$",
"module",
"->",
"getEntityManager",
"(",
"$",
"this",
"->",
"getConnectionName",
"(",
")",
")",
")",
";",
"$",
"this",
"->",
"attachEntityMetaListener",
"(",
")",
";",
"// ganz wichtig das hier zu machen, weil das sonst das doctrinepackage initialisiert",
"}"
]
| Erstellt das DCPackage
wird vom getter aufgerufen, damit es immer da ist | [
"Erstellt",
"das",
"DCPackage"
]
| 467bfa2547e6b4fa487d2d7f35fa6cc618dbc763 | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/CMS/ProjectMain.php#L195-L199 |
17,149 | webforge-labs/psc-cms | lib/Psc/CMS/ProjectMain.php | ProjectMain.hydrateEntity | public function hydrateEntity($entityName, $identifier) {
return $this->getDoctrinePackage()->getRepository(
$this->getDoctrinePackage()->getModule()->getEntityName($entityName)
)->hydrate($identifier);
} | php | public function hydrateEntity($entityName, $identifier) {
return $this->getDoctrinePackage()->getRepository(
$this->getDoctrinePackage()->getModule()->getEntityName($entityName)
)->hydrate($identifier);
} | [
"public",
"function",
"hydrateEntity",
"(",
"$",
"entityName",
",",
"$",
"identifier",
")",
"{",
"return",
"$",
"this",
"->",
"getDoctrinePackage",
"(",
")",
"->",
"getRepository",
"(",
"$",
"this",
"->",
"getDoctrinePackage",
"(",
")",
"->",
"getModule",
"(",
")",
"->",
"getEntityName",
"(",
"$",
"entityName",
")",
")",
"->",
"hydrate",
"(",
"$",
"identifier",
")",
";",
"}"
]
| Hydriert ein einzelnes Entity
@param string $entityName kann der FQN oder Shortname sein
@return Psc\CMS\Entity | [
"Hydriert",
"ein",
"einzelnes",
"Entity"
]
| 467bfa2547e6b4fa487d2d7f35fa6cc618dbc763 | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/CMS/ProjectMain.php#L262-L266 |
17,150 | php-rise/rise | src/Dispatcher.php | Dispatcher.dispatch | public function dispatch() {
$handler = current($this->handlers);
if (!$handler) {
return;
}
$this->resolveHandler($handler);
return $this;
} | php | public function dispatch() {
$handler = current($this->handlers);
if (!$handler) {
return;
}
$this->resolveHandler($handler);
return $this;
} | [
"public",
"function",
"dispatch",
"(",
")",
"{",
"$",
"handler",
"=",
"current",
"(",
"$",
"this",
"->",
"handlers",
")",
";",
"if",
"(",
"!",
"$",
"handler",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"resolveHandler",
"(",
"$",
"handler",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Dispatch handlers.
@return self | [
"Dispatch",
"handlers",
"."
]
| cd14ef9956f1b6875b7bcd642545dcef6a9152b7 | https://github.com/php-rise/rise/blob/cd14ef9956f1b6875b7bcd642545dcef6a9152b7/src/Dispatcher.php#L26-L35 |
17,151 | maniaplanet/maniaplanet-ws-sdk | libraries/Maniaplanet/WebServices/TrustCircles.php | TrustCircles.getKarma | function getKarma($circle, $player)
{
if(!$circle)
{
throw new Exception('Invalid circle');
}
if(!$player)
{
throw new Exception('Invalid player');
}
return $this->execute('GET', '/trust/%s/karma/%s/', array($circle, $player));
} | php | function getKarma($circle, $player)
{
if(!$circle)
{
throw new Exception('Invalid circle');
}
if(!$player)
{
throw new Exception('Invalid player');
}
return $this->execute('GET', '/trust/%s/karma/%s/', array($circle, $player));
} | [
"function",
"getKarma",
"(",
"$",
"circle",
",",
"$",
"player",
")",
"{",
"if",
"(",
"!",
"$",
"circle",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Invalid circle'",
")",
";",
"}",
"if",
"(",
"!",
"$",
"player",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Invalid player'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"execute",
"(",
"'GET'",
",",
"'/trust/%s/karma/%s/'",
",",
"array",
"(",
"$",
"circle",
",",
"$",
"player",
")",
")",
";",
"}"
]
| Get how many times a player has been blacklisted and whitelisted within a circle
@param string $circle
@param string $player
@return object Numbers of blacklistings and whitelistings
@throws Exception | [
"Get",
"how",
"many",
"times",
"a",
"player",
"has",
"been",
"blacklisted",
"and",
"whitelisted",
"within",
"a",
"circle"
]
| 027a458388035fe66f2f56ff3ea1f85eff2a5a4e | https://github.com/maniaplanet/maniaplanet-ws-sdk/blob/027a458388035fe66f2f56ff3ea1f85eff2a5a4e/libraries/Maniaplanet/WebServices/TrustCircles.php#L21-L33 |
17,152 | webforge-labs/psc-cms | lib/PHPWord/PHPWord.php | PHPWord.createSection | public function createSection($settings = null) {
$sectionCount = $this->_countSections() + 1;
$section = new PHPWord_Section($sectionCount, $settings);
$this->_sectionCollection[] = $section;
return $section;
} | php | public function createSection($settings = null) {
$sectionCount = $this->_countSections() + 1;
$section = new PHPWord_Section($sectionCount, $settings);
$this->_sectionCollection[] = $section;
return $section;
} | [
"public",
"function",
"createSection",
"(",
"$",
"settings",
"=",
"null",
")",
"{",
"$",
"sectionCount",
"=",
"$",
"this",
"->",
"_countSections",
"(",
")",
"+",
"1",
";",
"$",
"section",
"=",
"new",
"PHPWord_Section",
"(",
"$",
"sectionCount",
",",
"$",
"settings",
")",
";",
"$",
"this",
"->",
"_sectionCollection",
"[",
"]",
"=",
"$",
"section",
";",
"return",
"$",
"section",
";",
"}"
]
| Create a new Section
@param PHPWord_Section_Settings $settings
@return PHPWord_Section | [
"Create",
"a",
"new",
"Section"
]
| 467bfa2547e6b4fa487d2d7f35fa6cc618dbc763 | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/PHPWord/PHPWord.php#L100-L106 |
17,153 | webforge-labs/psc-cms | lib/PHPWord/PHPWord.php | PHPWord.addFontStyle | public function addFontStyle($styleName, $styleFont, $styleParagraph = null) {
PHPWord_Style::addFontStyle($styleName, $styleFont, $styleParagraph);
} | php | public function addFontStyle($styleName, $styleFont, $styleParagraph = null) {
PHPWord_Style::addFontStyle($styleName, $styleFont, $styleParagraph);
} | [
"public",
"function",
"addFontStyle",
"(",
"$",
"styleName",
",",
"$",
"styleFont",
",",
"$",
"styleParagraph",
"=",
"null",
")",
"{",
"PHPWord_Style",
"::",
"addFontStyle",
"(",
"$",
"styleName",
",",
"$",
"styleFont",
",",
"$",
"styleParagraph",
")",
";",
"}"
]
| Adds a font style definition to styles.xml
@param $styleName string
@param $styles array | [
"Adds",
"a",
"font",
"style",
"definition",
"to",
"styles",
".",
"xml"
]
| 467bfa2547e6b4fa487d2d7f35fa6cc618dbc763 | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/PHPWord/PHPWord.php#L157-L159 |
17,154 | webforge-labs/psc-cms | lib/PHPWord/PHPWord.php | PHPWord.addTableStyle | public function addTableStyle($styleName, $styleTable, $styleFirstRow = null) {
PHPWord_Style::addTableStyle($styleName, $styleTable, $styleFirstRow);
} | php | public function addTableStyle($styleName, $styleTable, $styleFirstRow = null) {
PHPWord_Style::addTableStyle($styleName, $styleTable, $styleFirstRow);
} | [
"public",
"function",
"addTableStyle",
"(",
"$",
"styleName",
",",
"$",
"styleTable",
",",
"$",
"styleFirstRow",
"=",
"null",
")",
"{",
"PHPWord_Style",
"::",
"addTableStyle",
"(",
"$",
"styleName",
",",
"$",
"styleTable",
",",
"$",
"styleFirstRow",
")",
";",
"}"
]
| Adds a table style definition to styles.xml
@param $styleName string
@param $styles array | [
"Adds",
"a",
"table",
"style",
"definition",
"to",
"styles",
".",
"xml"
]
| 467bfa2547e6b4fa487d2d7f35fa6cc618dbc763 | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/PHPWord/PHPWord.php#L167-L169 |
17,155 | webforge-labs/psc-cms | lib/PHPWord/PHPWord.php | PHPWord.addTitleStyle | public function addTitleStyle($titleCount, $styleFont, $styleParagraph = null) {
PHPWord_Style::addTitleStyle($titleCount, $styleFont, $styleParagraph);
} | php | public function addTitleStyle($titleCount, $styleFont, $styleParagraph = null) {
PHPWord_Style::addTitleStyle($titleCount, $styleFont, $styleParagraph);
} | [
"public",
"function",
"addTitleStyle",
"(",
"$",
"titleCount",
",",
"$",
"styleFont",
",",
"$",
"styleParagraph",
"=",
"null",
")",
"{",
"PHPWord_Style",
"::",
"addTitleStyle",
"(",
"$",
"titleCount",
",",
"$",
"styleFont",
",",
"$",
"styleParagraph",
")",
";",
"}"
]
| Adds a heading style definition to styles.xml
@param $titleCount int
@param $styles array | [
"Adds",
"a",
"heading",
"style",
"definition",
"to",
"styles",
".",
"xml"
]
| 467bfa2547e6b4fa487d2d7f35fa6cc618dbc763 | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/PHPWord/PHPWord.php#L177-L179 |
17,156 | webforge-labs/psc-cms | lib/PHPWord/PHPWord.php | PHPWord.loadTemplate | public function loadTemplate($strFilename) {
if(file_exists($strFilename)) {
$template = new PHPWord_Template($strFilename);
return $template;
} else {
trigger_error('Template file '.$strFilename.' not found.', E_ERROR);
}
} | php | public function loadTemplate($strFilename) {
if(file_exists($strFilename)) {
$template = new PHPWord_Template($strFilename);
return $template;
} else {
trigger_error('Template file '.$strFilename.' not found.', E_ERROR);
}
} | [
"public",
"function",
"loadTemplate",
"(",
"$",
"strFilename",
")",
"{",
"if",
"(",
"file_exists",
"(",
"$",
"strFilename",
")",
")",
"{",
"$",
"template",
"=",
"new",
"PHPWord_Template",
"(",
"$",
"strFilename",
")",
";",
"return",
"$",
"template",
";",
"}",
"else",
"{",
"trigger_error",
"(",
"'Template file '",
".",
"$",
"strFilename",
".",
"' not found.'",
",",
"E_ERROR",
")",
";",
"}",
"}"
]
| Load a Template File
@param string $strFilename
@return PHPWord_Template | [
"Load",
"a",
"Template",
"File"
]
| 467bfa2547e6b4fa487d2d7f35fa6cc618dbc763 | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/PHPWord/PHPWord.php#L213-L220 |
17,157 | steeffeen/FancyManiaLinks | FML/Script/Features/Menu.php | Menu.addItem | public function addItem(Control $item, Control $control, $isStartElement = false)
{
$menuElement = new MenuElement($item, $control);
$this->addElement($menuElement, $isStartElement);
return $this;
} | php | public function addItem(Control $item, Control $control, $isStartElement = false)
{
$menuElement = new MenuElement($item, $control);
$this->addElement($menuElement, $isStartElement);
return $this;
} | [
"public",
"function",
"addItem",
"(",
"Control",
"$",
"item",
",",
"Control",
"$",
"control",
",",
"$",
"isStartElement",
"=",
"false",
")",
"{",
"$",
"menuElement",
"=",
"new",
"MenuElement",
"(",
"$",
"item",
",",
"$",
"control",
")",
";",
"$",
"this",
"->",
"addElement",
"(",
"$",
"menuElement",
",",
"$",
"isStartElement",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Add a Menu item
@api
@param Control $item Item Control in the Menu bar
@param Control $control Toggled Menu Control
@param bool $isStartElement (optional) Whether the Menu should start with this Element
@return static | [
"Add",
"a",
"Menu",
"item"
]
| 227b0759306f0a3c75873ba50276e4163a93bfa6 | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Script/Features/Menu.php#L70-L75 |
17,158 | steeffeen/FancyManiaLinks | FML/Script/Features/Menu.php | Menu.addElement | public function addElement(MenuElement $menuElement, $isStartElement = false)
{
if (!in_array($menuElement, $this->elements, true)) {
array_push($this->elements, $menuElement);
if ($isStartElement) {
// new start element
$this->setStartElement($menuElement);
} else {
// additional element - set invisible
$menuElement->getControl()
->setVisible(false);
}
}
return $this;
} | php | public function addElement(MenuElement $menuElement, $isStartElement = false)
{
if (!in_array($menuElement, $this->elements, true)) {
array_push($this->elements, $menuElement);
if ($isStartElement) {
// new start element
$this->setStartElement($menuElement);
} else {
// additional element - set invisible
$menuElement->getControl()
->setVisible(false);
}
}
return $this;
} | [
"public",
"function",
"addElement",
"(",
"MenuElement",
"$",
"menuElement",
",",
"$",
"isStartElement",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"menuElement",
",",
"$",
"this",
"->",
"elements",
",",
"true",
")",
")",
"{",
"array_push",
"(",
"$",
"this",
"->",
"elements",
",",
"$",
"menuElement",
")",
";",
"if",
"(",
"$",
"isStartElement",
")",
"{",
"// new start element",
"$",
"this",
"->",
"setStartElement",
"(",
"$",
"menuElement",
")",
";",
"}",
"else",
"{",
"// additional element - set invisible",
"$",
"menuElement",
"->",
"getControl",
"(",
")",
"->",
"setVisible",
"(",
"false",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
]
| Add a Menu Element
@api
@param MenuElement $menuElement Menu Element
@param bool $isStartElement (optional) Whether the Menu should start with this Element
@return static | [
"Add",
"a",
"Menu",
"Element"
]
| 227b0759306f0a3c75873ba50276e4163a93bfa6 | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Script/Features/Menu.php#L85-L99 |
17,159 | steeffeen/FancyManiaLinks | FML/Script/Features/Menu.php | Menu.setStartElement | public function setStartElement(MenuElement $startElement = null)
{
$this->startElement = $startElement;
if ($startElement && !in_array($startElement, $this->elements, true)) {
array_push($this->elements, $startElement);
}
return $this;
} | php | public function setStartElement(MenuElement $startElement = null)
{
$this->startElement = $startElement;
if ($startElement && !in_array($startElement, $this->elements, true)) {
array_push($this->elements, $startElement);
}
return $this;
} | [
"public",
"function",
"setStartElement",
"(",
"MenuElement",
"$",
"startElement",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"startElement",
"=",
"$",
"startElement",
";",
"if",
"(",
"$",
"startElement",
"&&",
"!",
"in_array",
"(",
"$",
"startElement",
",",
"$",
"this",
"->",
"elements",
",",
"true",
")",
")",
"{",
"array_push",
"(",
"$",
"this",
"->",
"elements",
",",
"$",
"startElement",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Set the Element to start with
@api
@param MenuElement $startElement Start Element
@return static | [
"Set",
"the",
"Element",
"to",
"start",
"with"
]
| 227b0759306f0a3c75873ba50276e4163a93bfa6 | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Script/Features/Menu.php#L119-L126 |
17,160 | steeffeen/FancyManiaLinks | FML/Script/Features/Menu.php | Menu.getElementsArrayText | protected function getElementsArrayText()
{
$elements = array();
foreach ($this->elements as $element) {
$elementId = $element->getItem()
->getId();
$elements[$elementId] = $element->getControl()
->getId();
}
return Builder::getArray($elements, true);
} | php | protected function getElementsArrayText()
{
$elements = array();
foreach ($this->elements as $element) {
$elementId = $element->getItem()
->getId();
$elements[$elementId] = $element->getControl()
->getId();
}
return Builder::getArray($elements, true);
} | [
"protected",
"function",
"getElementsArrayText",
"(",
")",
"{",
"$",
"elements",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"elements",
"as",
"$",
"element",
")",
"{",
"$",
"elementId",
"=",
"$",
"element",
"->",
"getItem",
"(",
")",
"->",
"getId",
"(",
")",
";",
"$",
"elements",
"[",
"$",
"elementId",
"]",
"=",
"$",
"element",
"->",
"getControl",
"(",
")",
"->",
"getId",
"(",
")",
";",
"}",
"return",
"Builder",
"::",
"getArray",
"(",
"$",
"elements",
",",
"true",
")",
";",
"}"
]
| Build the array text for the Elements
@return string | [
"Build",
"the",
"array",
"text",
"for",
"the",
"Elements"
]
| 227b0759306f0a3c75873ba50276e4163a93bfa6 | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Script/Features/Menu.php#L172-L182 |
17,161 | benmanu/silverstripe-knowledgebase | code/extensions/FAQRelatedArticlesExtension.php | FAQRelatedArticlesExtension.getTagNameList | public function getTagNameList()
{
$tags = $this->owner->Tags();
$names = [];
foreach ($tags as $tag) {
$names[] = $tag->Name;
}
return implode(', ', $names);
} | php | public function getTagNameList()
{
$tags = $this->owner->Tags();
$names = [];
foreach ($tags as $tag) {
$names[] = $tag->Name;
}
return implode(', ', $names);
} | [
"public",
"function",
"getTagNameList",
"(",
")",
"{",
"$",
"tags",
"=",
"$",
"this",
"->",
"owner",
"->",
"Tags",
"(",
")",
";",
"$",
"names",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"tags",
"as",
"$",
"tag",
")",
"{",
"$",
"names",
"[",
"]",
"=",
"$",
"tag",
"->",
"Name",
";",
"}",
"return",
"implode",
"(",
"', '",
",",
"$",
"names",
")",
";",
"}"
]
| Helper to get a comma separated list of all the associated tags.
@return string | [
"Helper",
"to",
"get",
"a",
"comma",
"separated",
"list",
"of",
"all",
"the",
"associated",
"tags",
"."
]
| db19bfd4836f43da17ab52e8b53e72a11be64210 | https://github.com/benmanu/silverstripe-knowledgebase/blob/db19bfd4836f43da17ab52e8b53e72a11be64210/code/extensions/FAQRelatedArticlesExtension.php#L45-L55 |
17,162 | benmanu/silverstripe-knowledgebase | code/extensions/FAQRelatedArticlesExtension.php | FAQRelatedArticlesExtension.getRelatedFAQs | public function getRelatedFAQs($limit = null)
{
$tags = $this->owner->Tags();
if ($tags->count() == 0) {
return null;
}
// find any FAQ that has one of the same tags
$faqs = FAQ::get()
->innerJoin('FAQ_Tags', '"FAQ"."ID" = "FAQ_Tags"."FAQID"')
->where(sprintf('"FAQ_Tags"."TaxonomyTermID" IN (%s)', implode(',', $tags->column('ID'))))
->exclude('ID', $this->owner->ID);
// limit the faqs if applicable
if ($limit && is_int($limit)) {
$faqs = $faqs->limit($limit);
}
return $faqs;
} | php | public function getRelatedFAQs($limit = null)
{
$tags = $this->owner->Tags();
if ($tags->count() == 0) {
return null;
}
// find any FAQ that has one of the same tags
$faqs = FAQ::get()
->innerJoin('FAQ_Tags', '"FAQ"."ID" = "FAQ_Tags"."FAQID"')
->where(sprintf('"FAQ_Tags"."TaxonomyTermID" IN (%s)', implode(',', $tags->column('ID'))))
->exclude('ID', $this->owner->ID);
// limit the faqs if applicable
if ($limit && is_int($limit)) {
$faqs = $faqs->limit($limit);
}
return $faqs;
} | [
"public",
"function",
"getRelatedFAQs",
"(",
"$",
"limit",
"=",
"null",
")",
"{",
"$",
"tags",
"=",
"$",
"this",
"->",
"owner",
"->",
"Tags",
"(",
")",
";",
"if",
"(",
"$",
"tags",
"->",
"count",
"(",
")",
"==",
"0",
")",
"{",
"return",
"null",
";",
"}",
"// find any FAQ that has one of the same tags",
"$",
"faqs",
"=",
"FAQ",
"::",
"get",
"(",
")",
"->",
"innerJoin",
"(",
"'FAQ_Tags'",
",",
"'\"FAQ\".\"ID\" = \"FAQ_Tags\".\"FAQID\"'",
")",
"->",
"where",
"(",
"sprintf",
"(",
"'\"FAQ_Tags\".\"TaxonomyTermID\" IN (%s)'",
",",
"implode",
"(",
"','",
",",
"$",
"tags",
"->",
"column",
"(",
"'ID'",
")",
")",
")",
")",
"->",
"exclude",
"(",
"'ID'",
",",
"$",
"this",
"->",
"owner",
"->",
"ID",
")",
";",
"// limit the faqs if applicable",
"if",
"(",
"$",
"limit",
"&&",
"is_int",
"(",
"$",
"limit",
")",
")",
"{",
"$",
"faqs",
"=",
"$",
"faqs",
"->",
"limit",
"(",
"$",
"limit",
")",
";",
"}",
"return",
"$",
"faqs",
";",
"}"
]
| Helper to get all the FAQ articles that are tagged with the same
tags.
@return DataList|null | [
"Helper",
"to",
"get",
"all",
"the",
"FAQ",
"articles",
"that",
"are",
"tagged",
"with",
"the",
"same",
"tags",
"."
]
| db19bfd4836f43da17ab52e8b53e72a11be64210 | https://github.com/benmanu/silverstripe-knowledgebase/blob/db19bfd4836f43da17ab52e8b53e72a11be64210/code/extensions/FAQRelatedArticlesExtension.php#L63-L83 |
17,163 | 2amigos/yiifoundation | widgets/Dropdown.php | Dropdown.renderItems | protected function renderItems()
{
$lines = array();
if ($this->type === Enum::DROPDOWN_CONTENT) {
$lines[] = $this->dropdownContent;
}
if ($this->type === Enum::DROPDOWN_LIST) {
foreach ($this->items as $item) {
if (is_string($item)) {
$lines[] = $item;
continue;
}
if (!isset($item['label'])) {
throw new InvalidConfigException("The 'label' option is required.");
}
$label = $this->encodeLabels ? \CHtml::encode($item['label']) : $item['label'];
$options = ArrayHelper::getValue($item, 'options', array());
$linkOptions = ArrayHelper::getValue($item, 'linkOptions', array());
$linkOptions['tabindex'] = '-1';
$content = \CHtml::link($label, ArrayHelper::getValue($item, 'url', '#'), $linkOptions);
$lines[] = \CHtml::tag('li', $options, $content);
}
}
return \CHtml::tag('ul', $this->htmlOptions, implode("\n", $lines));
} | php | protected function renderItems()
{
$lines = array();
if ($this->type === Enum::DROPDOWN_CONTENT) {
$lines[] = $this->dropdownContent;
}
if ($this->type === Enum::DROPDOWN_LIST) {
foreach ($this->items as $item) {
if (is_string($item)) {
$lines[] = $item;
continue;
}
if (!isset($item['label'])) {
throw new InvalidConfigException("The 'label' option is required.");
}
$label = $this->encodeLabels ? \CHtml::encode($item['label']) : $item['label'];
$options = ArrayHelper::getValue($item, 'options', array());
$linkOptions = ArrayHelper::getValue($item, 'linkOptions', array());
$linkOptions['tabindex'] = '-1';
$content = \CHtml::link($label, ArrayHelper::getValue($item, 'url', '#'), $linkOptions);
$lines[] = \CHtml::tag('li', $options, $content);
}
}
return \CHtml::tag('ul', $this->htmlOptions, implode("\n", $lines));
} | [
"protected",
"function",
"renderItems",
"(",
")",
"{",
"$",
"lines",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"type",
"===",
"Enum",
"::",
"DROPDOWN_CONTENT",
")",
"{",
"$",
"lines",
"[",
"]",
"=",
"$",
"this",
"->",
"dropdownContent",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"type",
"===",
"Enum",
"::",
"DROPDOWN_LIST",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"items",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"item",
")",
")",
"{",
"$",
"lines",
"[",
"]",
"=",
"$",
"item",
";",
"continue",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"item",
"[",
"'label'",
"]",
")",
")",
"{",
"throw",
"new",
"InvalidConfigException",
"(",
"\"The 'label' option is required.\"",
")",
";",
"}",
"$",
"label",
"=",
"$",
"this",
"->",
"encodeLabels",
"?",
"\\",
"CHtml",
"::",
"encode",
"(",
"$",
"item",
"[",
"'label'",
"]",
")",
":",
"$",
"item",
"[",
"'label'",
"]",
";",
"$",
"options",
"=",
"ArrayHelper",
"::",
"getValue",
"(",
"$",
"item",
",",
"'options'",
",",
"array",
"(",
")",
")",
";",
"$",
"linkOptions",
"=",
"ArrayHelper",
"::",
"getValue",
"(",
"$",
"item",
",",
"'linkOptions'",
",",
"array",
"(",
")",
")",
";",
"$",
"linkOptions",
"[",
"'tabindex'",
"]",
"=",
"'-1'",
";",
"$",
"content",
"=",
"\\",
"CHtml",
"::",
"link",
"(",
"$",
"label",
",",
"ArrayHelper",
"::",
"getValue",
"(",
"$",
"item",
",",
"'url'",
",",
"'#'",
")",
",",
"$",
"linkOptions",
")",
";",
"$",
"lines",
"[",
"]",
"=",
"\\",
"CHtml",
"::",
"tag",
"(",
"'li'",
",",
"$",
"options",
",",
"$",
"content",
")",
";",
"}",
"}",
"return",
"\\",
"CHtml",
"::",
"tag",
"(",
"'ul'",
",",
"$",
"this",
"->",
"htmlOptions",
",",
"implode",
"(",
"\"\\n\"",
",",
"$",
"lines",
")",
")",
";",
"}"
]
| Renders dropdown items
@return string
@throws InvalidConfigException | [
"Renders",
"dropdown",
"items"
]
| 49bed0d3ca1a9bac9299000e48a2661bdc8f9a29 | https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/widgets/Dropdown.php#L82-L109 |
17,164 | ClanCats/Core | src/bundles/Session/CCSession.php | CCSession.valid_fingerprint | public static function valid_fingerprint( $fingerprint = null, $name = null )
{
return Manager::create( $name )->valid_fingerprint( $fingerprint );
} | php | public static function valid_fingerprint( $fingerprint = null, $name = null )
{
return Manager::create( $name )->valid_fingerprint( $fingerprint );
} | [
"public",
"static",
"function",
"valid_fingerprint",
"(",
"$",
"fingerprint",
"=",
"null",
",",
"$",
"name",
"=",
"null",
")",
"{",
"return",
"Manager",
"::",
"create",
"(",
"$",
"name",
")",
"->",
"valid_fingerprint",
"(",
"$",
"fingerprint",
")",
";",
"}"
]
| Check if the given fingerprint or the default fingerprint
parameter matches the curent session fingerprint.
@param string $manager
@return string | [
"Check",
"if",
"the",
"given",
"fingerprint",
"or",
"the",
"default",
"fingerprint",
"parameter",
"matches",
"the",
"curent",
"session",
"fingerprint",
"."
]
| 9f6ec72c1a439de4b253d0223f1029f7f85b6ef8 | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Session/CCSession.php#L43-L46 |
17,165 | ClanCats/Core | src/bundles/Session/CCSession.php | CCSession.set | public static function set( $key, $value, $manager = null )
{
return Manager::create( $manager )->set( $key, $value );
} | php | public static function set( $key, $value, $manager = null )
{
return Manager::create( $manager )->set( $key, $value );
} | [
"public",
"static",
"function",
"set",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"manager",
"=",
"null",
")",
"{",
"return",
"Manager",
"::",
"create",
"(",
"$",
"manager",
")",
"->",
"set",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}"
]
| Set a value on the session
@param string $key
@param string $value
@param string $manager
@return Session\Manager | [
"Set",
"a",
"value",
"on",
"the",
"session"
]
| 9f6ec72c1a439de4b253d0223f1029f7f85b6ef8 | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Session/CCSession.php#L82-L85 |
17,166 | ClanCats/Core | src/bundles/Session/CCSession.php | CCSession.add | public static function add( $key, $value, $manager = null )
{
return Manager::create( $manager )->add( $key, $value );
} | php | public static function add( $key, $value, $manager = null )
{
return Manager::create( $manager )->add( $key, $value );
} | [
"public",
"static",
"function",
"add",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"manager",
"=",
"null",
")",
"{",
"return",
"Manager",
"::",
"create",
"(",
"$",
"manager",
")",
"->",
"add",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}"
]
| Similar to add but forces the element to be an array
and appends an item.
@param string $key
@param string $value
@param string $manager
@return Session\Manager | [
"Similar",
"to",
"add",
"but",
"forces",
"the",
"element",
"to",
"be",
"an",
"array",
"and",
"appends",
"an",
"item",
"."
]
| 9f6ec72c1a439de4b253d0223f1029f7f85b6ef8 | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Session/CCSession.php#L96-L99 |
17,167 | slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseUserCustomerRelationPeer.php | BaseUserCustomerRelationPeer.doDeleteAll | public static function doDeleteAll(PropelPDO $con = null)
{
if ($con === null) {
$con = Propel::getConnection(UserCustomerRelationPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
}
$affectedRows = 0; // initialize var to track total num of affected rows
try {
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
$affectedRows += BasePeer::doDeleteAll(UserCustomerRelationPeer::TABLE_NAME, $con, UserCustomerRelationPeer::DATABASE_NAME);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
// instances get re-added by the select statement contained therein).
UserCustomerRelationPeer::clearInstancePool();
UserCustomerRelationPeer::clearRelatedInstancePool();
$con->commit();
return $affectedRows;
} catch (Exception $e) {
$con->rollBack();
throw $e;
}
} | php | public static function doDeleteAll(PropelPDO $con = null)
{
if ($con === null) {
$con = Propel::getConnection(UserCustomerRelationPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
}
$affectedRows = 0; // initialize var to track total num of affected rows
try {
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
$affectedRows += BasePeer::doDeleteAll(UserCustomerRelationPeer::TABLE_NAME, $con, UserCustomerRelationPeer::DATABASE_NAME);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
// instances get re-added by the select statement contained therein).
UserCustomerRelationPeer::clearInstancePool();
UserCustomerRelationPeer::clearRelatedInstancePool();
$con->commit();
return $affectedRows;
} catch (Exception $e) {
$con->rollBack();
throw $e;
}
} | [
"public",
"static",
"function",
"doDeleteAll",
"(",
"PropelPDO",
"$",
"con",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"con",
"===",
"null",
")",
"{",
"$",
"con",
"=",
"Propel",
"::",
"getConnection",
"(",
"UserCustomerRelationPeer",
"::",
"DATABASE_NAME",
",",
"Propel",
"::",
"CONNECTION_WRITE",
")",
";",
"}",
"$",
"affectedRows",
"=",
"0",
";",
"// initialize var to track total num of affected rows",
"try",
"{",
"// use transaction because $criteria could contain info",
"// for more than one table or we could emulating ON DELETE CASCADE, etc.",
"$",
"con",
"->",
"beginTransaction",
"(",
")",
";",
"$",
"affectedRows",
"+=",
"BasePeer",
"::",
"doDeleteAll",
"(",
"UserCustomerRelationPeer",
"::",
"TABLE_NAME",
",",
"$",
"con",
",",
"UserCustomerRelationPeer",
"::",
"DATABASE_NAME",
")",
";",
"// Because this db requires some delete cascade/set null emulation, we have to",
"// clear the cached instance *after* the emulation has happened (since",
"// instances get re-added by the select statement contained therein).",
"UserCustomerRelationPeer",
"::",
"clearInstancePool",
"(",
")",
";",
"UserCustomerRelationPeer",
"::",
"clearRelatedInstancePool",
"(",
")",
";",
"$",
"con",
"->",
"commit",
"(",
")",
";",
"return",
"$",
"affectedRows",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"con",
"->",
"rollBack",
"(",
")",
";",
"throw",
"$",
"e",
";",
"}",
"}"
]
| Deletes all rows from the user_customer_relation table.
@param PropelPDO $con the connection to use
@return int The number of affected rows (if supported by underlying database driver).
@throws PropelException | [
"Deletes",
"all",
"rows",
"from",
"the",
"user_customer_relation",
"table",
"."
]
| 2ba86d96f1f41f9424e2229c4e2b13017e973f89 | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseUserCustomerRelationPeer.php#L1225-L1248 |
17,168 | slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseUserCustomerRelationPeer.php | BaseUserCustomerRelationPeer.doDelete | public static function doDelete($values, PropelPDO $con = null)
{
if ($con === null) {
$con = Propel::getConnection(UserCustomerRelationPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
}
if ($values instanceof Criteria) {
// invalidate the cache for all objects of this type, since we have no
// way of knowing (without running a query) what objects should be invalidated
// from the cache based on this Criteria.
UserCustomerRelationPeer::clearInstancePool();
// rename for clarity
$criteria = clone $values;
} elseif ($values instanceof UserCustomerRelation) { // it's a model object
// invalidate the cache for this single object
UserCustomerRelationPeer::removeInstanceFromPool($values);
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(UserCustomerRelationPeer::DATABASE_NAME);
$criteria->add(UserCustomerRelationPeer::ID, (array) $values, Criteria::IN);
// invalidate the cache for this object(s)
foreach ((array) $values as $singleval) {
UserCustomerRelationPeer::removeInstanceFromPool($singleval);
}
}
// Set the correct dbName
$criteria->setDbName(UserCustomerRelationPeer::DATABASE_NAME);
$affectedRows = 0; // initialize var to track total num of affected rows
try {
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
$affectedRows += BasePeer::doDelete($criteria, $con);
UserCustomerRelationPeer::clearRelatedInstancePool();
$con->commit();
return $affectedRows;
} catch (Exception $e) {
$con->rollBack();
throw $e;
}
} | php | public static function doDelete($values, PropelPDO $con = null)
{
if ($con === null) {
$con = Propel::getConnection(UserCustomerRelationPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
}
if ($values instanceof Criteria) {
// invalidate the cache for all objects of this type, since we have no
// way of knowing (without running a query) what objects should be invalidated
// from the cache based on this Criteria.
UserCustomerRelationPeer::clearInstancePool();
// rename for clarity
$criteria = clone $values;
} elseif ($values instanceof UserCustomerRelation) { // it's a model object
// invalidate the cache for this single object
UserCustomerRelationPeer::removeInstanceFromPool($values);
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(UserCustomerRelationPeer::DATABASE_NAME);
$criteria->add(UserCustomerRelationPeer::ID, (array) $values, Criteria::IN);
// invalidate the cache for this object(s)
foreach ((array) $values as $singleval) {
UserCustomerRelationPeer::removeInstanceFromPool($singleval);
}
}
// Set the correct dbName
$criteria->setDbName(UserCustomerRelationPeer::DATABASE_NAME);
$affectedRows = 0; // initialize var to track total num of affected rows
try {
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
$affectedRows += BasePeer::doDelete($criteria, $con);
UserCustomerRelationPeer::clearRelatedInstancePool();
$con->commit();
return $affectedRows;
} catch (Exception $e) {
$con->rollBack();
throw $e;
}
} | [
"public",
"static",
"function",
"doDelete",
"(",
"$",
"values",
",",
"PropelPDO",
"$",
"con",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"con",
"===",
"null",
")",
"{",
"$",
"con",
"=",
"Propel",
"::",
"getConnection",
"(",
"UserCustomerRelationPeer",
"::",
"DATABASE_NAME",
",",
"Propel",
"::",
"CONNECTION_WRITE",
")",
";",
"}",
"if",
"(",
"$",
"values",
"instanceof",
"Criteria",
")",
"{",
"// invalidate the cache for all objects of this type, since we have no",
"// way of knowing (without running a query) what objects should be invalidated",
"// from the cache based on this Criteria.",
"UserCustomerRelationPeer",
"::",
"clearInstancePool",
"(",
")",
";",
"// rename for clarity",
"$",
"criteria",
"=",
"clone",
"$",
"values",
";",
"}",
"elseif",
"(",
"$",
"values",
"instanceof",
"UserCustomerRelation",
")",
"{",
"// it's a model object",
"// invalidate the cache for this single object",
"UserCustomerRelationPeer",
"::",
"removeInstanceFromPool",
"(",
"$",
"values",
")",
";",
"// create criteria based on pk values",
"$",
"criteria",
"=",
"$",
"values",
"->",
"buildPkeyCriteria",
"(",
")",
";",
"}",
"else",
"{",
"// it's a primary key, or an array of pks",
"$",
"criteria",
"=",
"new",
"Criteria",
"(",
"UserCustomerRelationPeer",
"::",
"DATABASE_NAME",
")",
";",
"$",
"criteria",
"->",
"add",
"(",
"UserCustomerRelationPeer",
"::",
"ID",
",",
"(",
"array",
")",
"$",
"values",
",",
"Criteria",
"::",
"IN",
")",
";",
"// invalidate the cache for this object(s)",
"foreach",
"(",
"(",
"array",
")",
"$",
"values",
"as",
"$",
"singleval",
")",
"{",
"UserCustomerRelationPeer",
"::",
"removeInstanceFromPool",
"(",
"$",
"singleval",
")",
";",
"}",
"}",
"// Set the correct dbName",
"$",
"criteria",
"->",
"setDbName",
"(",
"UserCustomerRelationPeer",
"::",
"DATABASE_NAME",
")",
";",
"$",
"affectedRows",
"=",
"0",
";",
"// initialize var to track total num of affected rows",
"try",
"{",
"// use transaction because $criteria could contain info",
"// for more than one table or we could emulating ON DELETE CASCADE, etc.",
"$",
"con",
"->",
"beginTransaction",
"(",
")",
";",
"$",
"affectedRows",
"+=",
"BasePeer",
"::",
"doDelete",
"(",
"$",
"criteria",
",",
"$",
"con",
")",
";",
"UserCustomerRelationPeer",
"::",
"clearRelatedInstancePool",
"(",
")",
";",
"$",
"con",
"->",
"commit",
"(",
")",
";",
"return",
"$",
"affectedRows",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"con",
"->",
"rollBack",
"(",
")",
";",
"throw",
"$",
"e",
";",
"}",
"}"
]
| Performs a DELETE on the database, given a UserCustomerRelation or Criteria object OR a primary key value.
@param mixed $values Criteria or UserCustomerRelation object or primary key or array of primary keys
which is used to create the DELETE statement
@param PropelPDO $con the connection to use
@return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
if supported by native driver or if emulated using Propel.
@throws PropelException Any exceptions caught during processing will be
rethrown wrapped into a PropelException. | [
"Performs",
"a",
"DELETE",
"on",
"the",
"database",
"given",
"a",
"UserCustomerRelation",
"or",
"Criteria",
"object",
"OR",
"a",
"primary",
"key",
"value",
"."
]
| 2ba86d96f1f41f9424e2229c4e2b13017e973f89 | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseUserCustomerRelationPeer.php#L1261-L1307 |
17,169 | slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseUserCustomerRelationPeer.php | BaseUserCustomerRelationPeer.retrieveByPK | public static function retrieveByPK($pk, PropelPDO $con = null)
{
if (null !== ($obj = UserCustomerRelationPeer::getInstanceFromPool((string) $pk))) {
return $obj;
}
if ($con === null) {
$con = Propel::getConnection(UserCustomerRelationPeer::DATABASE_NAME, Propel::CONNECTION_READ);
}
$criteria = new Criteria(UserCustomerRelationPeer::DATABASE_NAME);
$criteria->add(UserCustomerRelationPeer::ID, $pk);
$v = UserCustomerRelationPeer::doSelect($criteria, $con);
return !empty($v) > 0 ? $v[0] : null;
} | php | public static function retrieveByPK($pk, PropelPDO $con = null)
{
if (null !== ($obj = UserCustomerRelationPeer::getInstanceFromPool((string) $pk))) {
return $obj;
}
if ($con === null) {
$con = Propel::getConnection(UserCustomerRelationPeer::DATABASE_NAME, Propel::CONNECTION_READ);
}
$criteria = new Criteria(UserCustomerRelationPeer::DATABASE_NAME);
$criteria->add(UserCustomerRelationPeer::ID, $pk);
$v = UserCustomerRelationPeer::doSelect($criteria, $con);
return !empty($v) > 0 ? $v[0] : null;
} | [
"public",
"static",
"function",
"retrieveByPK",
"(",
"$",
"pk",
",",
"PropelPDO",
"$",
"con",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"!==",
"(",
"$",
"obj",
"=",
"UserCustomerRelationPeer",
"::",
"getInstanceFromPool",
"(",
"(",
"string",
")",
"$",
"pk",
")",
")",
")",
"{",
"return",
"$",
"obj",
";",
"}",
"if",
"(",
"$",
"con",
"===",
"null",
")",
"{",
"$",
"con",
"=",
"Propel",
"::",
"getConnection",
"(",
"UserCustomerRelationPeer",
"::",
"DATABASE_NAME",
",",
"Propel",
"::",
"CONNECTION_READ",
")",
";",
"}",
"$",
"criteria",
"=",
"new",
"Criteria",
"(",
"UserCustomerRelationPeer",
"::",
"DATABASE_NAME",
")",
";",
"$",
"criteria",
"->",
"add",
"(",
"UserCustomerRelationPeer",
"::",
"ID",
",",
"$",
"pk",
")",
";",
"$",
"v",
"=",
"UserCustomerRelationPeer",
"::",
"doSelect",
"(",
"$",
"criteria",
",",
"$",
"con",
")",
";",
"return",
"!",
"empty",
"(",
"$",
"v",
")",
">",
"0",
"?",
"$",
"v",
"[",
"0",
"]",
":",
"null",
";",
"}"
]
| Retrieve a single object by pkey.
@param int $pk the primary key.
@param PropelPDO $con the connection to use
@return UserCustomerRelation | [
"Retrieve",
"a",
"single",
"object",
"by",
"pkey",
"."
]
| 2ba86d96f1f41f9424e2229c4e2b13017e973f89 | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseUserCustomerRelationPeer.php#L1353-L1370 |
17,170 | slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseUserCustomerRelationPeer.php | BaseUserCustomerRelationPeer.retrieveByPKs | public static function retrieveByPKs($pks, PropelPDO $con = null)
{
if ($con === null) {
$con = Propel::getConnection(UserCustomerRelationPeer::DATABASE_NAME, Propel::CONNECTION_READ);
}
$objs = null;
if (empty($pks)) {
$objs = array();
} else {
$criteria = new Criteria(UserCustomerRelationPeer::DATABASE_NAME);
$criteria->add(UserCustomerRelationPeer::ID, $pks, Criteria::IN);
$objs = UserCustomerRelationPeer::doSelect($criteria, $con);
}
return $objs;
} | php | public static function retrieveByPKs($pks, PropelPDO $con = null)
{
if ($con === null) {
$con = Propel::getConnection(UserCustomerRelationPeer::DATABASE_NAME, Propel::CONNECTION_READ);
}
$objs = null;
if (empty($pks)) {
$objs = array();
} else {
$criteria = new Criteria(UserCustomerRelationPeer::DATABASE_NAME);
$criteria->add(UserCustomerRelationPeer::ID, $pks, Criteria::IN);
$objs = UserCustomerRelationPeer::doSelect($criteria, $con);
}
return $objs;
} | [
"public",
"static",
"function",
"retrieveByPKs",
"(",
"$",
"pks",
",",
"PropelPDO",
"$",
"con",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"con",
"===",
"null",
")",
"{",
"$",
"con",
"=",
"Propel",
"::",
"getConnection",
"(",
"UserCustomerRelationPeer",
"::",
"DATABASE_NAME",
",",
"Propel",
"::",
"CONNECTION_READ",
")",
";",
"}",
"$",
"objs",
"=",
"null",
";",
"if",
"(",
"empty",
"(",
"$",
"pks",
")",
")",
"{",
"$",
"objs",
"=",
"array",
"(",
")",
";",
"}",
"else",
"{",
"$",
"criteria",
"=",
"new",
"Criteria",
"(",
"UserCustomerRelationPeer",
"::",
"DATABASE_NAME",
")",
";",
"$",
"criteria",
"->",
"add",
"(",
"UserCustomerRelationPeer",
"::",
"ID",
",",
"$",
"pks",
",",
"Criteria",
"::",
"IN",
")",
";",
"$",
"objs",
"=",
"UserCustomerRelationPeer",
"::",
"doSelect",
"(",
"$",
"criteria",
",",
"$",
"con",
")",
";",
"}",
"return",
"$",
"objs",
";",
"}"
]
| Retrieve multiple objects by pkey.
@param array $pks List of primary keys
@param PropelPDO $con the connection to use
@return UserCustomerRelation[]
@throws PropelException Any exceptions caught during processing will be
rethrown wrapped into a PropelException. | [
"Retrieve",
"multiple",
"objects",
"by",
"pkey",
"."
]
| 2ba86d96f1f41f9424e2229c4e2b13017e973f89 | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseUserCustomerRelationPeer.php#L1381-L1397 |
17,171 | webforge-labs/psc-cms | lib/PHPWord/PHPWord/Section/Settings.php | PHPWord_Section_Settings.setSettingValue | public function setSettingValue($key, $value) {
if($key == '_orientation' && $value == 'landscape') {
$this->setLandscape();
} elseif($key == '_orientation' && is_null($value)) {
$this->setPortrait();
} elseif($key == '_borderSize') {
$this->setBorderSize($value);
} elseif($key == '_borderColor') {
$this->setBorderColor($value);
} else {
$this->$key = $value;
}
} | php | public function setSettingValue($key, $value) {
if($key == '_orientation' && $value == 'landscape') {
$this->setLandscape();
} elseif($key == '_orientation' && is_null($value)) {
$this->setPortrait();
} elseif($key == '_borderSize') {
$this->setBorderSize($value);
} elseif($key == '_borderColor') {
$this->setBorderColor($value);
} else {
$this->$key = $value;
}
} | [
"public",
"function",
"setSettingValue",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"key",
"==",
"'_orientation'",
"&&",
"$",
"value",
"==",
"'landscape'",
")",
"{",
"$",
"this",
"->",
"setLandscape",
"(",
")",
";",
"}",
"elseif",
"(",
"$",
"key",
"==",
"'_orientation'",
"&&",
"is_null",
"(",
"$",
"value",
")",
")",
"{",
"$",
"this",
"->",
"setPortrait",
"(",
")",
";",
"}",
"elseif",
"(",
"$",
"key",
"==",
"'_borderSize'",
")",
"{",
"$",
"this",
"->",
"setBorderSize",
"(",
"$",
"value",
")",
";",
"}",
"elseif",
"(",
"$",
"key",
"==",
"'_borderColor'",
")",
"{",
"$",
"this",
"->",
"setBorderColor",
"(",
"$",
"value",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"$",
"key",
"=",
"$",
"value",
";",
"}",
"}"
]
| Set Setting Value
@param string $key
@param string $value | [
"Set",
"Setting",
"Value"
]
| 467bfa2547e6b4fa487d2d7f35fa6cc618dbc763 | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/PHPWord/PHPWord/Section/Settings.php#L184-L196 |
17,172 | webforge-labs/psc-cms | lib/PHPWord/PHPWord/Section/Settings.php | PHPWord_Section_Settings.setLandscape | public function setLandscape() {
$this->_orientation = 'landscape';
$this->_pageSizeW = $this->_defaultPageSizeH;
$this->_pageSizeH = $this->_defaultPageSizeW;
} | php | public function setLandscape() {
$this->_orientation = 'landscape';
$this->_pageSizeW = $this->_defaultPageSizeH;
$this->_pageSizeH = $this->_defaultPageSizeW;
} | [
"public",
"function",
"setLandscape",
"(",
")",
"{",
"$",
"this",
"->",
"_orientation",
"=",
"'landscape'",
";",
"$",
"this",
"->",
"_pageSizeW",
"=",
"$",
"this",
"->",
"_defaultPageSizeH",
";",
"$",
"this",
"->",
"_pageSizeH",
"=",
"$",
"this",
"->",
"_defaultPageSizeW",
";",
"}"
]
| Set Landscape Orientation | [
"Set",
"Landscape",
"Orientation"
]
| 467bfa2547e6b4fa487d2d7f35fa6cc618dbc763 | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/PHPWord/PHPWord/Section/Settings.php#L277-L281 |
17,173 | webforge-labs/psc-cms | lib/PHPWord/PHPWord/Section/Settings.php | PHPWord_Section_Settings.setPortrait | public function setPortrait() {
$this->_orientation = null;
$this->_pageSizeW = $this->_defaultPageSizeW;
$this->_pageSizeH = $this->_defaultPageSizeH;
} | php | public function setPortrait() {
$this->_orientation = null;
$this->_pageSizeW = $this->_defaultPageSizeW;
$this->_pageSizeH = $this->_defaultPageSizeH;
} | [
"public",
"function",
"setPortrait",
"(",
")",
"{",
"$",
"this",
"->",
"_orientation",
"=",
"null",
";",
"$",
"this",
"->",
"_pageSizeW",
"=",
"$",
"this",
"->",
"_defaultPageSizeW",
";",
"$",
"this",
"->",
"_pageSizeH",
"=",
"$",
"this",
"->",
"_defaultPageSizeH",
";",
"}"
]
| Set Portrait Orientation | [
"Set",
"Portrait",
"Orientation"
]
| 467bfa2547e6b4fa487d2d7f35fa6cc618dbc763 | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/PHPWord/PHPWord/Section/Settings.php#L286-L290 |
17,174 | webforge-labs/psc-cms | lib/PHPWord/PHPWord/Section/Settings.php | PHPWord_Section_Settings.getBorderSize | public function getBorderSize() {
$t = $this->getBorderTopSize();
$l = $this->getBorderLeftSize();
$r = $this->getBorderRightSize();
$b = $this->getBorderBottomSize();
return array($t, $l, $r, $b);
} | php | public function getBorderSize() {
$t = $this->getBorderTopSize();
$l = $this->getBorderLeftSize();
$r = $this->getBorderRightSize();
$b = $this->getBorderBottomSize();
return array($t, $l, $r, $b);
} | [
"public",
"function",
"getBorderSize",
"(",
")",
"{",
"$",
"t",
"=",
"$",
"this",
"->",
"getBorderTopSize",
"(",
")",
";",
"$",
"l",
"=",
"$",
"this",
"->",
"getBorderLeftSize",
"(",
")",
";",
"$",
"r",
"=",
"$",
"this",
"->",
"getBorderRightSize",
"(",
")",
";",
"$",
"b",
"=",
"$",
"this",
"->",
"getBorderBottomSize",
"(",
")",
";",
"return",
"array",
"(",
"$",
"t",
",",
"$",
"l",
",",
"$",
"r",
",",
"$",
"b",
")",
";",
"}"
]
| Get Border Size
@return array | [
"Get",
"Border",
"Size"
]
| 467bfa2547e6b4fa487d2d7f35fa6cc618dbc763 | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/PHPWord/PHPWord/Section/Settings.php#L336-L343 |
17,175 | webforge-labs/psc-cms | lib/PHPWord/PHPWord/Section/Settings.php | PHPWord_Section_Settings.setBorderColor | public function setBorderColor($pValue = null) {
$this->_borderTopColor = $pValue;
$this->_borderLeftColor = $pValue;
$this->_borderRightColor = $pValue;
$this->_borderBottomColor = $pValue;
} | php | public function setBorderColor($pValue = null) {
$this->_borderTopColor = $pValue;
$this->_borderLeftColor = $pValue;
$this->_borderRightColor = $pValue;
$this->_borderBottomColor = $pValue;
} | [
"public",
"function",
"setBorderColor",
"(",
"$",
"pValue",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"_borderTopColor",
"=",
"$",
"pValue",
";",
"$",
"this",
"->",
"_borderLeftColor",
"=",
"$",
"pValue",
";",
"$",
"this",
"->",
"_borderRightColor",
"=",
"$",
"pValue",
";",
"$",
"this",
"->",
"_borderBottomColor",
"=",
"$",
"pValue",
";",
"}"
]
| Set Border Color
@param string $pValue | [
"Set",
"Border",
"Color"
]
| 467bfa2547e6b4fa487d2d7f35fa6cc618dbc763 | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/PHPWord/PHPWord/Section/Settings.php#L350-L355 |
17,176 | webforge-labs/psc-cms | lib/PHPWord/PHPWord/Section/Settings.php | PHPWord_Section_Settings.getBorderColor | public function getBorderColor() {
$t = $this->getBorderTopColor();
$l = $this->getBorderLeftColor();
$r = $this->getBorderRightColor();
$b = $this->getBorderBottomColor();
return array($t, $l, $r, $b);
} | php | public function getBorderColor() {
$t = $this->getBorderTopColor();
$l = $this->getBorderLeftColor();
$r = $this->getBorderRightColor();
$b = $this->getBorderBottomColor();
return array($t, $l, $r, $b);
} | [
"public",
"function",
"getBorderColor",
"(",
")",
"{",
"$",
"t",
"=",
"$",
"this",
"->",
"getBorderTopColor",
"(",
")",
";",
"$",
"l",
"=",
"$",
"this",
"->",
"getBorderLeftColor",
"(",
")",
";",
"$",
"r",
"=",
"$",
"this",
"->",
"getBorderRightColor",
"(",
")",
";",
"$",
"b",
"=",
"$",
"this",
"->",
"getBorderBottomColor",
"(",
")",
";",
"return",
"array",
"(",
"$",
"t",
",",
"$",
"l",
",",
"$",
"r",
",",
"$",
"b",
")",
";",
"}"
]
| Get Border Color
@return array | [
"Get",
"Border",
"Color"
]
| 467bfa2547e6b4fa487d2d7f35fa6cc618dbc763 | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/PHPWord/PHPWord/Section/Settings.php#L362-L369 |
17,177 | miisieq/InfaktClient | src/Infakt/Infakt.php | Infakt.getRepository | public function getRepository(string $className): AbstractObjectRepository
{
$className = 'Infakt\\Repository\\'.substr($className, strrpos($className, '\\') + 1).'Repository';
if (!class_exists($className)) {
throw new LogicException("There is no repository to work with class $className.");
}
return new $className($this);
} | php | public function getRepository(string $className): AbstractObjectRepository
{
$className = 'Infakt\\Repository\\'.substr($className, strrpos($className, '\\') + 1).'Repository';
if (!class_exists($className)) {
throw new LogicException("There is no repository to work with class $className.");
}
return new $className($this);
} | [
"public",
"function",
"getRepository",
"(",
"string",
"$",
"className",
")",
":",
"AbstractObjectRepository",
"{",
"$",
"className",
"=",
"'Infakt\\\\Repository\\\\'",
".",
"substr",
"(",
"$",
"className",
",",
"strrpos",
"(",
"$",
"className",
",",
"'\\\\'",
")",
"+",
"1",
")",
".",
"'Repository'",
";",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"className",
")",
")",
"{",
"throw",
"new",
"LogicException",
"(",
"\"There is no repository to work with class $className.\"",
")",
";",
"}",
"return",
"new",
"$",
"className",
"(",
"$",
"this",
")",
";",
"}"
]
| Return object repository for a specific model class name.
@param $className
@throws LogicException
@return AbstractObjectRepository | [
"Return",
"object",
"repository",
"for",
"a",
"specific",
"model",
"class",
"name",
"."
]
| 5f0ae58c7be32580f3c92c2a7e7a7808d83d4e81 | https://github.com/miisieq/InfaktClient/blob/5f0ae58c7be32580f3c92c2a7e7a7808d83d4e81/src/Infakt/Infakt.php#L53-L62 |
17,178 | miisieq/InfaktClient | src/Infakt/Infakt.php | Infakt.get | public function get(string $query): ResponseInterface
{
return $this->client->request('get', $this->buildQuery($query), ['headers' => $this->getAuthorizationHeader()]);
} | php | public function get(string $query): ResponseInterface
{
return $this->client->request('get', $this->buildQuery($query), ['headers' => $this->getAuthorizationHeader()]);
} | [
"public",
"function",
"get",
"(",
"string",
"$",
"query",
")",
":",
"ResponseInterface",
"{",
"return",
"$",
"this",
"->",
"client",
"->",
"request",
"(",
"'get'",
",",
"$",
"this",
"->",
"buildQuery",
"(",
"$",
"query",
")",
",",
"[",
"'headers'",
"=>",
"$",
"this",
"->",
"getAuthorizationHeader",
"(",
")",
"]",
")",
";",
"}"
]
| Send HTTP GET request.
@param string $query
@return \Psr\Http\Message\ResponseInterface | [
"Send",
"HTTP",
"GET",
"request",
"."
]
| 5f0ae58c7be32580f3c92c2a7e7a7808d83d4e81 | https://github.com/miisieq/InfaktClient/blob/5f0ae58c7be32580f3c92c2a7e7a7808d83d4e81/src/Infakt/Infakt.php#L71-L74 |
17,179 | ARCANEDEV/Sanitizer | src/SanitizerServiceProvider.php | SanitizerServiceProvider.registerSanitizer | private function registerSanitizer()
{
$this->singleton(Contracts\Sanitizer::class, function ($app) {
/** @var \Illuminate\Contracts\Config\Repository $config */
$config = $app['config'];
return new Factory($config->get('sanitizer.filters'));
});
$this->singleton('arcanedev.sanitizer', Contracts\Sanitizer::class);
} | php | private function registerSanitizer()
{
$this->singleton(Contracts\Sanitizer::class, function ($app) {
/** @var \Illuminate\Contracts\Config\Repository $config */
$config = $app['config'];
return new Factory($config->get('sanitizer.filters'));
});
$this->singleton('arcanedev.sanitizer', Contracts\Sanitizer::class);
} | [
"private",
"function",
"registerSanitizer",
"(",
")",
"{",
"$",
"this",
"->",
"singleton",
"(",
"Contracts",
"\\",
"Sanitizer",
"::",
"class",
",",
"function",
"(",
"$",
"app",
")",
"{",
"/** @var \\Illuminate\\Contracts\\Config\\Repository $config */",
"$",
"config",
"=",
"$",
"app",
"[",
"'config'",
"]",
";",
"return",
"new",
"Factory",
"(",
"$",
"config",
"->",
"get",
"(",
"'sanitizer.filters'",
")",
")",
";",
"}",
")",
";",
"$",
"this",
"->",
"singleton",
"(",
"'arcanedev.sanitizer'",
",",
"Contracts",
"\\",
"Sanitizer",
"::",
"class",
")",
";",
"}"
]
| Register Helpers. | [
"Register",
"Helpers",
"."
]
| e21990ce6d881366d52a7f4e5040b07cc3ecca96 | https://github.com/ARCANEDEV/Sanitizer/blob/e21990ce6d881366d52a7f4e5040b07cc3ecca96/src/SanitizerServiceProvider.php#L81-L91 |
17,180 | digitalkaoz/versioneye-php | src/Output/Github.php | Github.hook | public function hook(OutputInterface $output, array $response)
{
$this->printBoolean($output, 'OK', $response['success'], true === $response['success']);
} | php | public function hook(OutputInterface $output, array $response)
{
$this->printBoolean($output, 'OK', $response['success'], true === $response['success']);
} | [
"public",
"function",
"hook",
"(",
"OutputInterface",
"$",
"output",
",",
"array",
"$",
"response",
")",
"{",
"$",
"this",
"->",
"printBoolean",
"(",
"$",
"output",
",",
"'OK'",
",",
"$",
"response",
"[",
"'success'",
"]",
",",
"true",
"===",
"$",
"response",
"[",
"'success'",
"]",
")",
";",
"}"
]
| output for hook api.
@param OutputInterface $output
@param array $response | [
"output",
"for",
"hook",
"api",
"."
]
| 7b8eb9cdc83e01138dda0e709c07e3beb6aad136 | https://github.com/digitalkaoz/versioneye-php/blob/7b8eb9cdc83e01138dda0e709c07e3beb6aad136/src/Output/Github.php#L31-L34 |
17,181 | digitalkaoz/versioneye-php | src/Output/Github.php | Github.delete | public function delete(OutputInterface $output, array $response)
{
$this->printBoolean($output, 'OK', $response['success'], true === $response['success']);
} | php | public function delete(OutputInterface $output, array $response)
{
$this->printBoolean($output, 'OK', $response['success'], true === $response['success']);
} | [
"public",
"function",
"delete",
"(",
"OutputInterface",
"$",
"output",
",",
"array",
"$",
"response",
")",
"{",
"$",
"this",
"->",
"printBoolean",
"(",
"$",
"output",
",",
"'OK'",
",",
"$",
"response",
"[",
"'success'",
"]",
",",
"true",
"===",
"$",
"response",
"[",
"'success'",
"]",
")",
";",
"}"
]
| output for delete api.
@param OutputInterface $output
@param array $response | [
"output",
"for",
"delete",
"api",
"."
]
| 7b8eb9cdc83e01138dda0e709c07e3beb6aad136 | https://github.com/digitalkaoz/versioneye-php/blob/7b8eb9cdc83e01138dda0e709c07e3beb6aad136/src/Output/Github.php#L42-L45 |
17,182 | GrahamDeprecated/CMS-Core | src/Seeds/UsersGroupsTableSeeder.php | UsersGroupsTableSeeder.matchUser | protected function matchUser($email, $group)
{
return Credentials::getUserProvider()->findByLogin($email)->addGroup(Credentials::getGroupProvider()->findByName($group));
} | php | protected function matchUser($email, $group)
{
return Credentials::getUserProvider()->findByLogin($email)->addGroup(Credentials::getGroupProvider()->findByName($group));
} | [
"protected",
"function",
"matchUser",
"(",
"$",
"email",
",",
"$",
"group",
")",
"{",
"return",
"Credentials",
"::",
"getUserProvider",
"(",
")",
"->",
"findByLogin",
"(",
"$",
"email",
")",
"->",
"addGroup",
"(",
"Credentials",
"::",
"getGroupProvider",
"(",
")",
"->",
"findByName",
"(",
"$",
"group",
")",
")",
";",
"}"
]
| Add the user by email to a group.
@param string $email
@param string $group
@return void | [
"Add",
"the",
"user",
"by",
"email",
"to",
"a",
"group",
"."
]
| 5603e2bfa2fac6cf46ca3ed62d21518f2f653675 | https://github.com/GrahamDeprecated/CMS-Core/blob/5603e2bfa2fac6cf46ca3ed62d21518f2f653675/src/Seeds/UsersGroupsTableSeeder.php#L60-L63 |
17,183 | qcubed/orm | src/Codegen/CodegenBase.php | CodegenBase.prefixFromType | public static function prefixFromType($strType)
{
switch ($strType) {
case Type::ARRAY_TYPE:
return "obj";
case Type::BOOLEAN:
return "bln";
case Type::DATE_TIME:
return "dtt";
case Type::FLOAT:
return "flt";
case Type::INTEGER:
return "int";
case Type::OBJECT:
return "obj";
case Type::STRING:
return "str";
}
// Suppressing the IDE warning about no value being return
return "";
} | php | public static function prefixFromType($strType)
{
switch ($strType) {
case Type::ARRAY_TYPE:
return "obj";
case Type::BOOLEAN:
return "bln";
case Type::DATE_TIME:
return "dtt";
case Type::FLOAT:
return "flt";
case Type::INTEGER:
return "int";
case Type::OBJECT:
return "obj";
case Type::STRING:
return "str";
}
// Suppressing the IDE warning about no value being return
return "";
} | [
"public",
"static",
"function",
"prefixFromType",
"(",
"$",
"strType",
")",
"{",
"switch",
"(",
"$",
"strType",
")",
"{",
"case",
"Type",
"::",
"ARRAY_TYPE",
":",
"return",
"\"obj\"",
";",
"case",
"Type",
"::",
"BOOLEAN",
":",
"return",
"\"bln\"",
";",
"case",
"Type",
"::",
"DATE_TIME",
":",
"return",
"\"dtt\"",
";",
"case",
"Type",
"::",
"FLOAT",
":",
"return",
"\"flt\"",
";",
"case",
"Type",
"::",
"INTEGER",
":",
"return",
"\"int\"",
";",
"case",
"Type",
"::",
"OBJECT",
":",
"return",
"\"obj\"",
";",
"case",
"Type",
"::",
"STRING",
":",
"return",
"\"str\"",
";",
"}",
"// Suppressing the IDE warning about no value being return",
"return",
"\"\"",
";",
"}"
]
| Returns prefix for variable according to variable type
@param string $strType The type of variable for which the prefix is needed
@return string The variable prefix
@was QString::PrefixFromType | [
"Returns",
"prefix",
"for",
"variable",
"according",
"to",
"variable",
"type"
]
| f320eba671f20874b1f3809c5293f8c02d5b1204 | https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Codegen/CodegenBase.php#L177-L197 |
17,184 | qcubed/orm | src/Codegen/CodegenBase.php | CodegenBase.getInstalledTemplatePaths | public function getInstalledTemplatePaths()
{
$dir = QCUBED_CONFIG_DIR . '/templates';
$paths = [];
if ($dir !== false) { // does the active directory exist?
foreach (scandir($dir) as $strFileName) {
if (substr($strFileName, -8) == '.inc.php') {
$paths2 = include($dir . '/' . $strFileName);
if ($paths2 && is_array($paths2)) {
$paths = array_merge($paths, $paths2);
}
}
}
}
return $paths;
} | php | public function getInstalledTemplatePaths()
{
$dir = QCUBED_CONFIG_DIR . '/templates';
$paths = [];
if ($dir !== false) { // does the active directory exist?
foreach (scandir($dir) as $strFileName) {
if (substr($strFileName, -8) == '.inc.php') {
$paths2 = include($dir . '/' . $strFileName);
if ($paths2 && is_array($paths2)) {
$paths = array_merge($paths, $paths2);
}
}
}
}
return $paths;
} | [
"public",
"function",
"getInstalledTemplatePaths",
"(",
")",
"{",
"$",
"dir",
"=",
"QCUBED_CONFIG_DIR",
".",
"'/templates'",
";",
"$",
"paths",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"dir",
"!==",
"false",
")",
"{",
"// does the active directory exist?",
"foreach",
"(",
"scandir",
"(",
"$",
"dir",
")",
"as",
"$",
"strFileName",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"strFileName",
",",
"-",
"8",
")",
"==",
"'.inc.php'",
")",
"{",
"$",
"paths2",
"=",
"include",
"(",
"$",
"dir",
".",
"'/'",
".",
"$",
"strFileName",
")",
";",
"if",
"(",
"$",
"paths2",
"&&",
"is_array",
"(",
"$",
"paths2",
")",
")",
"{",
"$",
"paths",
"=",
"array_merge",
"(",
"$",
"paths",
",",
"$",
"paths2",
")",
";",
"}",
"}",
"}",
"}",
"return",
"$",
"paths",
";",
"}"
]
| Return an array of paths to template files. This base class versions searches a config directory for pointers
to template files to use. This allows qcubed repos to inject templates into the codegen process.
This process is similar to how the control registry works. | [
"Return",
"an",
"array",
"of",
"paths",
"to",
"template",
"files",
".",
"This",
"base",
"class",
"versions",
"searches",
"a",
"config",
"directory",
"for",
"pointers",
"to",
"template",
"files",
"to",
"use",
".",
"This",
"allows",
"qcubed",
"repos",
"to",
"inject",
"templates",
"into",
"the",
"codegen",
"process",
"."
]
| f320eba671f20874b1f3809c5293f8c02d5b1204 | https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Codegen/CodegenBase.php#L205-L223 |
17,185 | qcubed/orm | src/Codegen/CodegenBase.php | CodegenBase.getSettingsXml | public static function getSettingsXml()
{
$strCrLf = "\r\n";
$strToReturn = sprintf('<codegen>%s', $strCrLf);
$strToReturn .= sprintf(' <name application="%s"/>%s', Codegen::$ApplicationName, $strCrLf);
$strToReturn .= sprintf(' <render preferredRenderMethod="%s"/>%s', Codegen::$PreferredRenderMethod,
$strCrLf);
$strToReturn .= sprintf(' <dataSources>%s', $strCrLf);
foreach (Codegen::$CodeGenArray as $objCodeGen) {
$strToReturn .= $strCrLf . $objCodeGen->getConfigXml();
}
$strToReturn .= sprintf('%s </dataSources>%s', $strCrLf, $strCrLf);
$strToReturn .= '</codegen>';
return $strToReturn;
} | php | public static function getSettingsXml()
{
$strCrLf = "\r\n";
$strToReturn = sprintf('<codegen>%s', $strCrLf);
$strToReturn .= sprintf(' <name application="%s"/>%s', Codegen::$ApplicationName, $strCrLf);
$strToReturn .= sprintf(' <render preferredRenderMethod="%s"/>%s', Codegen::$PreferredRenderMethod,
$strCrLf);
$strToReturn .= sprintf(' <dataSources>%s', $strCrLf);
foreach (Codegen::$CodeGenArray as $objCodeGen) {
$strToReturn .= $strCrLf . $objCodeGen->getConfigXml();
}
$strToReturn .= sprintf('%s </dataSources>%s', $strCrLf, $strCrLf);
$strToReturn .= '</codegen>';
return $strToReturn;
} | [
"public",
"static",
"function",
"getSettingsXml",
"(",
")",
"{",
"$",
"strCrLf",
"=",
"\"\\r\\n\"",
";",
"$",
"strToReturn",
"=",
"sprintf",
"(",
"'<codegen>%s'",
",",
"$",
"strCrLf",
")",
";",
"$",
"strToReturn",
".=",
"sprintf",
"(",
"'\t<name application=\"%s\"/>%s'",
",",
"Codegen",
"::",
"$",
"ApplicationName",
",",
"$",
"strCrLf",
")",
";",
"$",
"strToReturn",
".=",
"sprintf",
"(",
"'\t<render preferredRenderMethod=\"%s\"/>%s'",
",",
"Codegen",
"::",
"$",
"PreferredRenderMethod",
",",
"$",
"strCrLf",
")",
";",
"$",
"strToReturn",
".=",
"sprintf",
"(",
"'\t<dataSources>%s'",
",",
"$",
"strCrLf",
")",
";",
"foreach",
"(",
"Codegen",
"::",
"$",
"CodeGenArray",
"as",
"$",
"objCodeGen",
")",
"{",
"$",
"strToReturn",
".=",
"$",
"strCrLf",
".",
"$",
"objCodeGen",
"->",
"getConfigXml",
"(",
")",
";",
"}",
"$",
"strToReturn",
".=",
"sprintf",
"(",
"'%s\t</dataSources>%s'",
",",
"$",
"strCrLf",
",",
"$",
"strCrLf",
")",
";",
"$",
"strToReturn",
".=",
"'</codegen>'",
";",
"return",
"$",
"strToReturn",
";",
"}"
]
| Gets the settings in codegen_settings.xml file and returns its text without comments
@return string | [
"Gets",
"the",
"settings",
"in",
"codegen_settings",
".",
"xml",
"file",
"and",
"returns",
"its",
"text",
"without",
"comments"
]
| f320eba671f20874b1f3809c5293f8c02d5b1204 | https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Codegen/CodegenBase.php#L230-L246 |
17,186 | qcubed/orm | src/Codegen/CodegenBase.php | CodegenBase.run | public static function run($strSettingsXmlFilePath)
{
if (!defined('QCUBED_CODE_GENERATING')) {
define('QCUBED_CODE_GENERATING', true);
}
Codegen::$CodeGenArray = array();
Codegen::$SettingsFilePath = $strSettingsXmlFilePath;
if (!file_exists($strSettingsXmlFilePath)) {
Codegen::$RootErrors = 'FATAL ERROR: CodeGen Settings XML File (' . $strSettingsXmlFilePath . ') was not found.';
return;
}
if (!is_file($strSettingsXmlFilePath)) {
Codegen::$RootErrors = 'FATAL ERROR: CodeGen Settings XML File (' . $strSettingsXmlFilePath . ') was not found.';
return;
}
// Try Parsing the Xml Settings File
try {
$errorHandler = new Error\Handler('\\QCubed\\Codegen\\QcubedHandleCodeGenParseError', E_ALL);
Codegen::$SettingsXml = new \SimpleXMLElement(file_get_contents($strSettingsXmlFilePath));
$errorHandler->restore();
} catch (\Exception $objExc) {
Codegen::$RootErrors .= 'FATAL ERROR: Unable to parse CodeGenSettings XML File: ' . $strSettingsXmlFilePath;
Codegen::$RootErrors .= "\r\n";
Codegen::$RootErrors .= $objExc->getMessage();
return;
}
// Application Name
Codegen::$ApplicationName = Codegen::lookupSetting(Codegen::$SettingsXml, 'name', 'application');
// Codegen Defaults
Codegen::$PreferredRenderMethod = Codegen::lookupSetting(Codegen::$SettingsXml, 'formgen',
'preferredRenderMethod');
Codegen::$CreateMethod = Codegen::lookupSetting(Codegen::$SettingsXml, 'formgen', 'createMethod');
Codegen::$DefaultButtonClass = Codegen::lookupSetting(Codegen::$SettingsXml, 'formgen', 'buttonClass');
if (!Codegen::$DefaultButtonClass) {
Codegen::$RootErrors .= "CodeGen Settings XML Fatal Error: buttonClass was not defined\r\n";
return;
}
// Iterate Through DataSources
if (Codegen::$SettingsXml->dataSources->asXML()) {
foreach (Codegen::$SettingsXml->dataSources->children() as $objChildNode) {
switch (dom_import_simplexml($objChildNode)->nodeName) {
case 'database':
Codegen::$CodeGenArray[] = new DatabaseCodeGen($objChildNode);
break;
case 'restService':
Codegen::$CodeGenArray[] = new RestServiceCodeGen($objChildNode);
break;
default:
Codegen::$RootErrors .= sprintf("Invalid Data Source Type in CodeGen Settings XML File (%s): %s\r\n",
$strSettingsXmlFilePath, dom_import_simplexml($objChildNode)->nodeName);
break;
}
}
}
} | php | public static function run($strSettingsXmlFilePath)
{
if (!defined('QCUBED_CODE_GENERATING')) {
define('QCUBED_CODE_GENERATING', true);
}
Codegen::$CodeGenArray = array();
Codegen::$SettingsFilePath = $strSettingsXmlFilePath;
if (!file_exists($strSettingsXmlFilePath)) {
Codegen::$RootErrors = 'FATAL ERROR: CodeGen Settings XML File (' . $strSettingsXmlFilePath . ') was not found.';
return;
}
if (!is_file($strSettingsXmlFilePath)) {
Codegen::$RootErrors = 'FATAL ERROR: CodeGen Settings XML File (' . $strSettingsXmlFilePath . ') was not found.';
return;
}
// Try Parsing the Xml Settings File
try {
$errorHandler = new Error\Handler('\\QCubed\\Codegen\\QcubedHandleCodeGenParseError', E_ALL);
Codegen::$SettingsXml = new \SimpleXMLElement(file_get_contents($strSettingsXmlFilePath));
$errorHandler->restore();
} catch (\Exception $objExc) {
Codegen::$RootErrors .= 'FATAL ERROR: Unable to parse CodeGenSettings XML File: ' . $strSettingsXmlFilePath;
Codegen::$RootErrors .= "\r\n";
Codegen::$RootErrors .= $objExc->getMessage();
return;
}
// Application Name
Codegen::$ApplicationName = Codegen::lookupSetting(Codegen::$SettingsXml, 'name', 'application');
// Codegen Defaults
Codegen::$PreferredRenderMethod = Codegen::lookupSetting(Codegen::$SettingsXml, 'formgen',
'preferredRenderMethod');
Codegen::$CreateMethod = Codegen::lookupSetting(Codegen::$SettingsXml, 'formgen', 'createMethod');
Codegen::$DefaultButtonClass = Codegen::lookupSetting(Codegen::$SettingsXml, 'formgen', 'buttonClass');
if (!Codegen::$DefaultButtonClass) {
Codegen::$RootErrors .= "CodeGen Settings XML Fatal Error: buttonClass was not defined\r\n";
return;
}
// Iterate Through DataSources
if (Codegen::$SettingsXml->dataSources->asXML()) {
foreach (Codegen::$SettingsXml->dataSources->children() as $objChildNode) {
switch (dom_import_simplexml($objChildNode)->nodeName) {
case 'database':
Codegen::$CodeGenArray[] = new DatabaseCodeGen($objChildNode);
break;
case 'restService':
Codegen::$CodeGenArray[] = new RestServiceCodeGen($objChildNode);
break;
default:
Codegen::$RootErrors .= sprintf("Invalid Data Source Type in CodeGen Settings XML File (%s): %s\r\n",
$strSettingsXmlFilePath, dom_import_simplexml($objChildNode)->nodeName);
break;
}
}
}
} | [
"public",
"static",
"function",
"run",
"(",
"$",
"strSettingsXmlFilePath",
")",
"{",
"if",
"(",
"!",
"defined",
"(",
"'QCUBED_CODE_GENERATING'",
")",
")",
"{",
"define",
"(",
"'QCUBED_CODE_GENERATING'",
",",
"true",
")",
";",
"}",
"Codegen",
"::",
"$",
"CodeGenArray",
"=",
"array",
"(",
")",
";",
"Codegen",
"::",
"$",
"SettingsFilePath",
"=",
"$",
"strSettingsXmlFilePath",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"strSettingsXmlFilePath",
")",
")",
"{",
"Codegen",
"::",
"$",
"RootErrors",
"=",
"'FATAL ERROR: CodeGen Settings XML File ('",
".",
"$",
"strSettingsXmlFilePath",
".",
"') was not found.'",
";",
"return",
";",
"}",
"if",
"(",
"!",
"is_file",
"(",
"$",
"strSettingsXmlFilePath",
")",
")",
"{",
"Codegen",
"::",
"$",
"RootErrors",
"=",
"'FATAL ERROR: CodeGen Settings XML File ('",
".",
"$",
"strSettingsXmlFilePath",
".",
"') was not found.'",
";",
"return",
";",
"}",
"// Try Parsing the Xml Settings File",
"try",
"{",
"$",
"errorHandler",
"=",
"new",
"Error",
"\\",
"Handler",
"(",
"'\\\\QCubed\\\\Codegen\\\\QcubedHandleCodeGenParseError'",
",",
"E_ALL",
")",
";",
"Codegen",
"::",
"$",
"SettingsXml",
"=",
"new",
"\\",
"SimpleXMLElement",
"(",
"file_get_contents",
"(",
"$",
"strSettingsXmlFilePath",
")",
")",
";",
"$",
"errorHandler",
"->",
"restore",
"(",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"objExc",
")",
"{",
"Codegen",
"::",
"$",
"RootErrors",
".=",
"'FATAL ERROR: Unable to parse CodeGenSettings XML File: '",
".",
"$",
"strSettingsXmlFilePath",
";",
"Codegen",
"::",
"$",
"RootErrors",
".=",
"\"\\r\\n\"",
";",
"Codegen",
"::",
"$",
"RootErrors",
".=",
"$",
"objExc",
"->",
"getMessage",
"(",
")",
";",
"return",
";",
"}",
"// Application Name",
"Codegen",
"::",
"$",
"ApplicationName",
"=",
"Codegen",
"::",
"lookupSetting",
"(",
"Codegen",
"::",
"$",
"SettingsXml",
",",
"'name'",
",",
"'application'",
")",
";",
"// Codegen Defaults",
"Codegen",
"::",
"$",
"PreferredRenderMethod",
"=",
"Codegen",
"::",
"lookupSetting",
"(",
"Codegen",
"::",
"$",
"SettingsXml",
",",
"'formgen'",
",",
"'preferredRenderMethod'",
")",
";",
"Codegen",
"::",
"$",
"CreateMethod",
"=",
"Codegen",
"::",
"lookupSetting",
"(",
"Codegen",
"::",
"$",
"SettingsXml",
",",
"'formgen'",
",",
"'createMethod'",
")",
";",
"Codegen",
"::",
"$",
"DefaultButtonClass",
"=",
"Codegen",
"::",
"lookupSetting",
"(",
"Codegen",
"::",
"$",
"SettingsXml",
",",
"'formgen'",
",",
"'buttonClass'",
")",
";",
"if",
"(",
"!",
"Codegen",
"::",
"$",
"DefaultButtonClass",
")",
"{",
"Codegen",
"::",
"$",
"RootErrors",
".=",
"\"CodeGen Settings XML Fatal Error: buttonClass was not defined\\r\\n\"",
";",
"return",
";",
"}",
"// Iterate Through DataSources",
"if",
"(",
"Codegen",
"::",
"$",
"SettingsXml",
"->",
"dataSources",
"->",
"asXML",
"(",
")",
")",
"{",
"foreach",
"(",
"Codegen",
"::",
"$",
"SettingsXml",
"->",
"dataSources",
"->",
"children",
"(",
")",
"as",
"$",
"objChildNode",
")",
"{",
"switch",
"(",
"dom_import_simplexml",
"(",
"$",
"objChildNode",
")",
"->",
"nodeName",
")",
"{",
"case",
"'database'",
":",
"Codegen",
"::",
"$",
"CodeGenArray",
"[",
"]",
"=",
"new",
"DatabaseCodeGen",
"(",
"$",
"objChildNode",
")",
";",
"break",
";",
"case",
"'restService'",
":",
"Codegen",
"::",
"$",
"CodeGenArray",
"[",
"]",
"=",
"new",
"RestServiceCodeGen",
"(",
"$",
"objChildNode",
")",
";",
"break",
";",
"default",
":",
"Codegen",
"::",
"$",
"RootErrors",
".=",
"sprintf",
"(",
"\"Invalid Data Source Type in CodeGen Settings XML File (%s): %s\\r\\n\"",
",",
"$",
"strSettingsXmlFilePath",
",",
"dom_import_simplexml",
"(",
"$",
"objChildNode",
")",
"->",
"nodeName",
")",
";",
"break",
";",
"}",
"}",
"}",
"}"
]
| The function which actually performs the steps for code generation
Code generation begins here.
@param string $strSettingsXmlFilePath Path to the settings file | [
"The",
"function",
"which",
"actually",
"performs",
"the",
"steps",
"for",
"code",
"generation",
"Code",
"generation",
"begins",
"here",
"."
]
| f320eba671f20874b1f3809c5293f8c02d5b1204 | https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Codegen/CodegenBase.php#L253-L315 |
17,187 | qcubed/orm | src/Codegen/CodegenBase.php | CodegenBase.getTemplateSettings | protected function getTemplateSettings($strTemplateFilePath, &$strTemplate = null)
{
if ($strTemplate === null) {
$strTemplate = file_get_contents($strTemplateFilePath);
}
$strError = 'Template\'s first line must be <template OverwriteFlag="boolean" TargetDirectory="string" DirectorySuffix="string" TargetFileName="string"/>: ' . $strTemplateFilePath;
// Parse out the first line (which contains path and overwriting information)
$intPosition = strpos($strTemplate, "\n");
if ($intPosition === false) {
throw new \Exception($strError);
}
$strFirstLine = trim(substr($strTemplate, 0, $intPosition));
$objTemplateXml = null;
// Attempt to Parse the First Line as XML
try {
@$objTemplateXml = new \SimpleXMLElement($strFirstLine);
} catch (\Exception $objExc) {
}
if (is_null($objTemplateXml) || (!($objTemplateXml instanceof \SimpleXMLElement))) {
throw new \Exception($strError);
}
$strTemplate = substr($strTemplate, $intPosition + 1);
return $objTemplateXml;
} | php | protected function getTemplateSettings($strTemplateFilePath, &$strTemplate = null)
{
if ($strTemplate === null) {
$strTemplate = file_get_contents($strTemplateFilePath);
}
$strError = 'Template\'s first line must be <template OverwriteFlag="boolean" TargetDirectory="string" DirectorySuffix="string" TargetFileName="string"/>: ' . $strTemplateFilePath;
// Parse out the first line (which contains path and overwriting information)
$intPosition = strpos($strTemplate, "\n");
if ($intPosition === false) {
throw new \Exception($strError);
}
$strFirstLine = trim(substr($strTemplate, 0, $intPosition));
$objTemplateXml = null;
// Attempt to Parse the First Line as XML
try {
@$objTemplateXml = new \SimpleXMLElement($strFirstLine);
} catch (\Exception $objExc) {
}
if (is_null($objTemplateXml) || (!($objTemplateXml instanceof \SimpleXMLElement))) {
throw new \Exception($strError);
}
$strTemplate = substr($strTemplate, $intPosition + 1);
return $objTemplateXml;
} | [
"protected",
"function",
"getTemplateSettings",
"(",
"$",
"strTemplateFilePath",
",",
"&",
"$",
"strTemplate",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"strTemplate",
"===",
"null",
")",
"{",
"$",
"strTemplate",
"=",
"file_get_contents",
"(",
"$",
"strTemplateFilePath",
")",
";",
"}",
"$",
"strError",
"=",
"'Template\\'s first line must be <template OverwriteFlag=\"boolean\" TargetDirectory=\"string\" DirectorySuffix=\"string\" TargetFileName=\"string\"/>: '",
".",
"$",
"strTemplateFilePath",
";",
"// Parse out the first line (which contains path and overwriting information)",
"$",
"intPosition",
"=",
"strpos",
"(",
"$",
"strTemplate",
",",
"\"\\n\"",
")",
";",
"if",
"(",
"$",
"intPosition",
"===",
"false",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"$",
"strError",
")",
";",
"}",
"$",
"strFirstLine",
"=",
"trim",
"(",
"substr",
"(",
"$",
"strTemplate",
",",
"0",
",",
"$",
"intPosition",
")",
")",
";",
"$",
"objTemplateXml",
"=",
"null",
";",
"// Attempt to Parse the First Line as XML",
"try",
"{",
"@",
"$",
"objTemplateXml",
"=",
"new",
"\\",
"SimpleXMLElement",
"(",
"$",
"strFirstLine",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"objExc",
")",
"{",
"}",
"if",
"(",
"is_null",
"(",
"$",
"objTemplateXml",
")",
"||",
"(",
"!",
"(",
"$",
"objTemplateXml",
"instanceof",
"\\",
"SimpleXMLElement",
")",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"$",
"strError",
")",
";",
"}",
"$",
"strTemplate",
"=",
"substr",
"(",
"$",
"strTemplate",
",",
"$",
"intPosition",
"+",
"1",
")",
";",
"return",
"$",
"objTemplateXml",
";",
"}"
]
| Returns the settings of the template file as SimpleXMLElement object
@param null|string $strTemplateFilePath Path to the file
@param null|string $strTemplate Text of the template (if $strTemplateFilePath is null, this field must be string)
@deprecated
@return \SimpleXMLElement
@throws \Exception | [
"Returns",
"the",
"settings",
"of",
"the",
"template",
"file",
"as",
"SimpleXMLElement",
"object"
]
| f320eba671f20874b1f3809c5293f8c02d5b1204 | https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Codegen/CodegenBase.php#L479-L505 |
17,188 | qcubed/orm | src/Codegen/CodegenBase.php | CodegenBase.generateFile | public function generateFile($strModuleSubPath, $strTemplateFilePath, $mixArgumentArray, $blnSave = true)
{
// Setup Debug/Exception Message
if (Codegen::DEBUG_MODE) {
echo("Evaluating $strTemplateFilePath<br/>");
}
// Check to see if the template file exists, and if it does, Load It
if (!file_exists($strTemplateFilePath)) {
throw new Caller('Template File Not Found: ' . $strTemplateFilePath);
}
// Evaluate the Template
// make sure paths are set up to pick up included files from the various directories.
// Must be the reverse of the buildTemplateArray order
$a = array();
foreach (static::$TemplatePaths as $strTemplatePath) {
array_unshift($a, $strTemplatePath . $strModuleSubPath);
}
$strSearchPath = implode(PATH_SEPARATOR, $a) . PATH_SEPARATOR . get_include_path();
$strOldIncludePath = set_include_path($strSearchPath);
if ($strSearchPath != get_include_path()) {
throw new Caller ('Can\'t override include path. Make sure your apache or server settings allow include paths to be overridden. ');
}
$strTemplate = $this->evaluatePHP($strTemplateFilePath, $mixArgumentArray, $templateSettings);
set_include_path($strOldIncludePath);
$blnOverwriteFlag = Type::cast($templateSettings['OverwriteFlag'], Type::BOOLEAN);
$strTargetDirectory = Type::cast($templateSettings['TargetDirectory'], Type::STRING);
$strDirectorySuffix = Type::cast($templateSettings['DirectorySuffix'], Type::STRING);
$strTargetFileName = Type::cast($templateSettings['TargetFileName'], Type::STRING);
if (is_null($blnOverwriteFlag) || is_null($strTargetFileName) || is_null($strTargetDirectory) || is_null($strDirectorySuffix)) {
throw new \Exception('the template settings cannot be null');
}
if ($blnSave && $strTargetDirectory) {
// Figure out the REAL target directory
$strTargetDirectory = $strTargetDirectory . $strDirectorySuffix;
// Create Directory (if needed)
if (!is_dir($strTargetDirectory)) {
if (!Folder::makeDirectory($strTargetDirectory, 0777)) {
throw new \Exception('Unable to mkdir ' . $strTargetDirectory);
}
}
// Save to Disk
$strFilePath = sprintf('%s/%s', $strTargetDirectory, $strTargetFileName);
if ($blnOverwriteFlag || (!file_exists($strFilePath))) {
$intBytesSaved = file_put_contents($strFilePath, $strTemplate);
$this->setGeneratedFilePermissions($strFilePath);
return ($intBytesSaved == strlen($strTemplate));
} else // Becuase we are not supposed to overwrite, we should return "true" by default
{
return true;
}
}
// Why Did We Not Save?
if ($blnSave) {
// We WANT to Save, but QCubed Configuration says that this functionality/feature should no longer be generated
// By definition, we should return "true"
return true;
}
// Running GenerateFile() specifically asking it not to save -- so return the evaluated template instead
return $strTemplate;
} | php | public function generateFile($strModuleSubPath, $strTemplateFilePath, $mixArgumentArray, $blnSave = true)
{
// Setup Debug/Exception Message
if (Codegen::DEBUG_MODE) {
echo("Evaluating $strTemplateFilePath<br/>");
}
// Check to see if the template file exists, and if it does, Load It
if (!file_exists($strTemplateFilePath)) {
throw new Caller('Template File Not Found: ' . $strTemplateFilePath);
}
// Evaluate the Template
// make sure paths are set up to pick up included files from the various directories.
// Must be the reverse of the buildTemplateArray order
$a = array();
foreach (static::$TemplatePaths as $strTemplatePath) {
array_unshift($a, $strTemplatePath . $strModuleSubPath);
}
$strSearchPath = implode(PATH_SEPARATOR, $a) . PATH_SEPARATOR . get_include_path();
$strOldIncludePath = set_include_path($strSearchPath);
if ($strSearchPath != get_include_path()) {
throw new Caller ('Can\'t override include path. Make sure your apache or server settings allow include paths to be overridden. ');
}
$strTemplate = $this->evaluatePHP($strTemplateFilePath, $mixArgumentArray, $templateSettings);
set_include_path($strOldIncludePath);
$blnOverwriteFlag = Type::cast($templateSettings['OverwriteFlag'], Type::BOOLEAN);
$strTargetDirectory = Type::cast($templateSettings['TargetDirectory'], Type::STRING);
$strDirectorySuffix = Type::cast($templateSettings['DirectorySuffix'], Type::STRING);
$strTargetFileName = Type::cast($templateSettings['TargetFileName'], Type::STRING);
if (is_null($blnOverwriteFlag) || is_null($strTargetFileName) || is_null($strTargetDirectory) || is_null($strDirectorySuffix)) {
throw new \Exception('the template settings cannot be null');
}
if ($blnSave && $strTargetDirectory) {
// Figure out the REAL target directory
$strTargetDirectory = $strTargetDirectory . $strDirectorySuffix;
// Create Directory (if needed)
if (!is_dir($strTargetDirectory)) {
if (!Folder::makeDirectory($strTargetDirectory, 0777)) {
throw new \Exception('Unable to mkdir ' . $strTargetDirectory);
}
}
// Save to Disk
$strFilePath = sprintf('%s/%s', $strTargetDirectory, $strTargetFileName);
if ($blnOverwriteFlag || (!file_exists($strFilePath))) {
$intBytesSaved = file_put_contents($strFilePath, $strTemplate);
$this->setGeneratedFilePermissions($strFilePath);
return ($intBytesSaved == strlen($strTemplate));
} else // Becuase we are not supposed to overwrite, we should return "true" by default
{
return true;
}
}
// Why Did We Not Save?
if ($blnSave) {
// We WANT to Save, but QCubed Configuration says that this functionality/feature should no longer be generated
// By definition, we should return "true"
return true;
}
// Running GenerateFile() specifically asking it not to save -- so return the evaluated template instead
return $strTemplate;
} | [
"public",
"function",
"generateFile",
"(",
"$",
"strModuleSubPath",
",",
"$",
"strTemplateFilePath",
",",
"$",
"mixArgumentArray",
",",
"$",
"blnSave",
"=",
"true",
")",
"{",
"// Setup Debug/Exception Message",
"if",
"(",
"Codegen",
"::",
"DEBUG_MODE",
")",
"{",
"echo",
"(",
"\"Evaluating $strTemplateFilePath<br/>\"",
")",
";",
"}",
"// Check to see if the template file exists, and if it does, Load It",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"strTemplateFilePath",
")",
")",
"{",
"throw",
"new",
"Caller",
"(",
"'Template File Not Found: '",
".",
"$",
"strTemplateFilePath",
")",
";",
"}",
"// Evaluate the Template",
"// make sure paths are set up to pick up included files from the various directories.",
"// Must be the reverse of the buildTemplateArray order",
"$",
"a",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"static",
"::",
"$",
"TemplatePaths",
"as",
"$",
"strTemplatePath",
")",
"{",
"array_unshift",
"(",
"$",
"a",
",",
"$",
"strTemplatePath",
".",
"$",
"strModuleSubPath",
")",
";",
"}",
"$",
"strSearchPath",
"=",
"implode",
"(",
"PATH_SEPARATOR",
",",
"$",
"a",
")",
".",
"PATH_SEPARATOR",
".",
"get_include_path",
"(",
")",
";",
"$",
"strOldIncludePath",
"=",
"set_include_path",
"(",
"$",
"strSearchPath",
")",
";",
"if",
"(",
"$",
"strSearchPath",
"!=",
"get_include_path",
"(",
")",
")",
"{",
"throw",
"new",
"Caller",
"(",
"'Can\\'t override include path. Make sure your apache or server settings allow include paths to be overridden. '",
")",
";",
"}",
"$",
"strTemplate",
"=",
"$",
"this",
"->",
"evaluatePHP",
"(",
"$",
"strTemplateFilePath",
",",
"$",
"mixArgumentArray",
",",
"$",
"templateSettings",
")",
";",
"set_include_path",
"(",
"$",
"strOldIncludePath",
")",
";",
"$",
"blnOverwriteFlag",
"=",
"Type",
"::",
"cast",
"(",
"$",
"templateSettings",
"[",
"'OverwriteFlag'",
"]",
",",
"Type",
"::",
"BOOLEAN",
")",
";",
"$",
"strTargetDirectory",
"=",
"Type",
"::",
"cast",
"(",
"$",
"templateSettings",
"[",
"'TargetDirectory'",
"]",
",",
"Type",
"::",
"STRING",
")",
";",
"$",
"strDirectorySuffix",
"=",
"Type",
"::",
"cast",
"(",
"$",
"templateSettings",
"[",
"'DirectorySuffix'",
"]",
",",
"Type",
"::",
"STRING",
")",
";",
"$",
"strTargetFileName",
"=",
"Type",
"::",
"cast",
"(",
"$",
"templateSettings",
"[",
"'TargetFileName'",
"]",
",",
"Type",
"::",
"STRING",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"blnOverwriteFlag",
")",
"||",
"is_null",
"(",
"$",
"strTargetFileName",
")",
"||",
"is_null",
"(",
"$",
"strTargetDirectory",
")",
"||",
"is_null",
"(",
"$",
"strDirectorySuffix",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'the template settings cannot be null'",
")",
";",
"}",
"if",
"(",
"$",
"blnSave",
"&&",
"$",
"strTargetDirectory",
")",
"{",
"// Figure out the REAL target directory",
"$",
"strTargetDirectory",
"=",
"$",
"strTargetDirectory",
".",
"$",
"strDirectorySuffix",
";",
"// Create Directory (if needed)",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"strTargetDirectory",
")",
")",
"{",
"if",
"(",
"!",
"Folder",
"::",
"makeDirectory",
"(",
"$",
"strTargetDirectory",
",",
"0777",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Unable to mkdir '",
".",
"$",
"strTargetDirectory",
")",
";",
"}",
"}",
"// Save to Disk",
"$",
"strFilePath",
"=",
"sprintf",
"(",
"'%s/%s'",
",",
"$",
"strTargetDirectory",
",",
"$",
"strTargetFileName",
")",
";",
"if",
"(",
"$",
"blnOverwriteFlag",
"||",
"(",
"!",
"file_exists",
"(",
"$",
"strFilePath",
")",
")",
")",
"{",
"$",
"intBytesSaved",
"=",
"file_put_contents",
"(",
"$",
"strFilePath",
",",
"$",
"strTemplate",
")",
";",
"$",
"this",
"->",
"setGeneratedFilePermissions",
"(",
"$",
"strFilePath",
")",
";",
"return",
"(",
"$",
"intBytesSaved",
"==",
"strlen",
"(",
"$",
"strTemplate",
")",
")",
";",
"}",
"else",
"// Becuase we are not supposed to overwrite, we should return \"true\" by default",
"{",
"return",
"true",
";",
"}",
"}",
"// Why Did We Not Save?",
"if",
"(",
"$",
"blnSave",
")",
"{",
"// We WANT to Save, but QCubed Configuration says that this functionality/feature should no longer be generated",
"// By definition, we should return \"true\"",
"return",
"true",
";",
"}",
"// Running GenerateFile() specifically asking it not to save -- so return the evaluated template instead",
"return",
"$",
"strTemplate",
";",
"}"
]
| Generates a php code using a template file
@param string $strModuleSubPath
@param string $strTemplateFilePath Path to the template file
@param mixed[] $mixArgumentArray
@param boolean $blnSave whether or not to actually perform the save
@throws Caller
@throws \Exception
@return mixed returns the evaluated template or boolean save success. | [
"Generates",
"a",
"php",
"code",
"using",
"a",
"template",
"file"
]
| f320eba671f20874b1f3809c5293f8c02d5b1204 | https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Codegen/CodegenBase.php#L519-L588 |
17,189 | qcubed/orm | src/Codegen/CodegenBase.php | CodegenBase.evaluatePHP | protected function evaluatePHP($strFilename, $mixArgumentArray, &$templateSettings = null)
{
// Get all the arguments and set them locally
if ($mixArgumentArray) {
foreach ($mixArgumentArray as $strName => $mixValue) {
$$strName = $mixValue;
}
}
global $_TEMPLATE_SETTINGS;
unset($_TEMPLATE_SETTINGS);
$_TEMPLATE_SETTINGS = null;
// Of course, we also need to locally allow "objCodeGen"
$objCodeGen = $this;
// Get Database Escape Identifiers
$strEscapeIdentifierBegin = \QCubed\Database\Service::getDatabase($this->intDatabaseIndex)->EscapeIdentifierBegin;
$strEscapeIdentifierEnd = \QCubed\Database\Service::getDatabase($this->intDatabaseIndex)->EscapeIdentifierEnd;
// Store the Output Buffer locally
$strAlreadyRendered = ob_get_contents();
if (ob_get_level()) {
ob_clean();
}
ob_start();
include($strFilename);
$strTemplate = ob_get_contents();
ob_end_clean();
$templateSettings = $_TEMPLATE_SETTINGS;
unset($_TEMPLATE_SETTINGS);
// Restore the output buffer and return evaluated template
print($strAlreadyRendered);
// Remove all \r from the template (for Win/*nix compatibility)
$strTemplate = str_replace("\r", '', $strTemplate);
return $strTemplate;
} | php | protected function evaluatePHP($strFilename, $mixArgumentArray, &$templateSettings = null)
{
// Get all the arguments and set them locally
if ($mixArgumentArray) {
foreach ($mixArgumentArray as $strName => $mixValue) {
$$strName = $mixValue;
}
}
global $_TEMPLATE_SETTINGS;
unset($_TEMPLATE_SETTINGS);
$_TEMPLATE_SETTINGS = null;
// Of course, we also need to locally allow "objCodeGen"
$objCodeGen = $this;
// Get Database Escape Identifiers
$strEscapeIdentifierBegin = \QCubed\Database\Service::getDatabase($this->intDatabaseIndex)->EscapeIdentifierBegin;
$strEscapeIdentifierEnd = \QCubed\Database\Service::getDatabase($this->intDatabaseIndex)->EscapeIdentifierEnd;
// Store the Output Buffer locally
$strAlreadyRendered = ob_get_contents();
if (ob_get_level()) {
ob_clean();
}
ob_start();
include($strFilename);
$strTemplate = ob_get_contents();
ob_end_clean();
$templateSettings = $_TEMPLATE_SETTINGS;
unset($_TEMPLATE_SETTINGS);
// Restore the output buffer and return evaluated template
print($strAlreadyRendered);
// Remove all \r from the template (for Win/*nix compatibility)
$strTemplate = str_replace("\r", '', $strTemplate);
return $strTemplate;
} | [
"protected",
"function",
"evaluatePHP",
"(",
"$",
"strFilename",
",",
"$",
"mixArgumentArray",
",",
"&",
"$",
"templateSettings",
"=",
"null",
")",
"{",
"// Get all the arguments and set them locally",
"if",
"(",
"$",
"mixArgumentArray",
")",
"{",
"foreach",
"(",
"$",
"mixArgumentArray",
"as",
"$",
"strName",
"=>",
"$",
"mixValue",
")",
"{",
"$",
"$",
"strName",
"=",
"$",
"mixValue",
";",
"}",
"}",
"global",
"$",
"_TEMPLATE_SETTINGS",
";",
"unset",
"(",
"$",
"_TEMPLATE_SETTINGS",
")",
";",
"$",
"_TEMPLATE_SETTINGS",
"=",
"null",
";",
"// Of course, we also need to locally allow \"objCodeGen\"",
"$",
"objCodeGen",
"=",
"$",
"this",
";",
"// Get Database Escape Identifiers",
"$",
"strEscapeIdentifierBegin",
"=",
"\\",
"QCubed",
"\\",
"Database",
"\\",
"Service",
"::",
"getDatabase",
"(",
"$",
"this",
"->",
"intDatabaseIndex",
")",
"->",
"EscapeIdentifierBegin",
";",
"$",
"strEscapeIdentifierEnd",
"=",
"\\",
"QCubed",
"\\",
"Database",
"\\",
"Service",
"::",
"getDatabase",
"(",
"$",
"this",
"->",
"intDatabaseIndex",
")",
"->",
"EscapeIdentifierEnd",
";",
"// Store the Output Buffer locally",
"$",
"strAlreadyRendered",
"=",
"ob_get_contents",
"(",
")",
";",
"if",
"(",
"ob_get_level",
"(",
")",
")",
"{",
"ob_clean",
"(",
")",
";",
"}",
"ob_start",
"(",
")",
";",
"include",
"(",
"$",
"strFilename",
")",
";",
"$",
"strTemplate",
"=",
"ob_get_contents",
"(",
")",
";",
"ob_end_clean",
"(",
")",
";",
"$",
"templateSettings",
"=",
"$",
"_TEMPLATE_SETTINGS",
";",
"unset",
"(",
"$",
"_TEMPLATE_SETTINGS",
")",
";",
"// Restore the output buffer and return evaluated template",
"print",
"(",
"$",
"strAlreadyRendered",
")",
";",
"// Remove all \\r from the template (for Win/*nix compatibility)",
"$",
"strTemplate",
"=",
"str_replace",
"(",
"\"\\r\"",
",",
"''",
",",
"$",
"strTemplate",
")",
";",
"return",
"$",
"strTemplate",
";",
"}"
]
| Returns the evaluated PHP
@param $strFilename
@param $mixArgumentArray
@param null $templateSettings
@return mixed|string | [
"Returns",
"the",
"evaluated",
"PHP"
]
| f320eba671f20874b1f3809c5293f8c02d5b1204 | https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Codegen/CodegenBase.php#L614-L653 |
17,190 | qcubed/orm | src/Codegen/CodegenBase.php | CodegenBase.modelClassName | protected function modelClassName($strTableName)
{
$strTableName = $this->stripPrefixFromTable($strTableName);
return sprintf('%s%s%s',
$this->strClassPrefix,
QString::camelCaseFromUnderscore($strTableName),
$this->strClassSuffix);
} | php | protected function modelClassName($strTableName)
{
$strTableName = $this->stripPrefixFromTable($strTableName);
return sprintf('%s%s%s',
$this->strClassPrefix,
QString::camelCaseFromUnderscore($strTableName),
$this->strClassSuffix);
} | [
"protected",
"function",
"modelClassName",
"(",
"$",
"strTableName",
")",
"{",
"$",
"strTableName",
"=",
"$",
"this",
"->",
"stripPrefixFromTable",
"(",
"$",
"strTableName",
")",
";",
"return",
"sprintf",
"(",
"'%s%s%s'",
",",
"$",
"this",
"->",
"strClassPrefix",
",",
"QString",
"::",
"camelCaseFromUnderscore",
"(",
"$",
"strTableName",
")",
",",
"$",
"this",
"->",
"strClassSuffix",
")",
";",
"}"
]
| Given a table name, returns the name of the class for the corresponding model object.
@param string $strTableName
@return string | [
"Given",
"a",
"table",
"name",
"returns",
"the",
"name",
"of",
"the",
"class",
"for",
"the",
"corresponding",
"model",
"object",
"."
]
| f320eba671f20874b1f3809c5293f8c02d5b1204 | https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Codegen/CodegenBase.php#L669-L676 |
17,191 | qcubed/orm | src/Codegen/CodegenBase.php | CodegenBase.modelVariableName | public function modelVariableName($strTableName)
{
$strTableName = $this->stripPrefixFromTable($strTableName);
return Codegen::prefixFromType(Type::OBJECT) .
QString::camelCaseFromUnderscore($strTableName);
} | php | public function modelVariableName($strTableName)
{
$strTableName = $this->stripPrefixFromTable($strTableName);
return Codegen::prefixFromType(Type::OBJECT) .
QString::camelCaseFromUnderscore($strTableName);
} | [
"public",
"function",
"modelVariableName",
"(",
"$",
"strTableName",
")",
"{",
"$",
"strTableName",
"=",
"$",
"this",
"->",
"stripPrefixFromTable",
"(",
"$",
"strTableName",
")",
";",
"return",
"Codegen",
"::",
"prefixFromType",
"(",
"Type",
"::",
"OBJECT",
")",
".",
"QString",
"::",
"camelCaseFromUnderscore",
"(",
"$",
"strTableName",
")",
";",
"}"
]
| Given a table name, returns a variable name that will be used to represent the corresponding model object.
@param string $strTableName
@return string | [
"Given",
"a",
"table",
"name",
"returns",
"a",
"variable",
"name",
"that",
"will",
"be",
"used",
"to",
"represent",
"the",
"corresponding",
"model",
"object",
"."
]
| f320eba671f20874b1f3809c5293f8c02d5b1204 | https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Codegen/CodegenBase.php#L683-L688 |
17,192 | qcubed/orm | src/Codegen/CodegenBase.php | CodegenBase.modelColumnVariableName | protected function modelColumnVariableName(SqlColumn $objColumn)
{
return Codegen::prefixFromType($objColumn->VariableType) .
QString::camelCaseFromUnderscore($objColumn->Name);
} | php | protected function modelColumnVariableName(SqlColumn $objColumn)
{
return Codegen::prefixFromType($objColumn->VariableType) .
QString::camelCaseFromUnderscore($objColumn->Name);
} | [
"protected",
"function",
"modelColumnVariableName",
"(",
"SqlColumn",
"$",
"objColumn",
")",
"{",
"return",
"Codegen",
"::",
"prefixFromType",
"(",
"$",
"objColumn",
"->",
"VariableType",
")",
".",
"QString",
"::",
"camelCaseFromUnderscore",
"(",
"$",
"objColumn",
"->",
"Name",
")",
";",
"}"
]
| Given a column, returns the name of the variable used to represent the column's value inside
the model object.
@param SqlColumn $objColumn
@return string | [
"Given",
"a",
"column",
"returns",
"the",
"name",
"of",
"the",
"variable",
"used",
"to",
"represent",
"the",
"column",
"s",
"value",
"inside",
"the",
"model",
"object",
"."
]
| f320eba671f20874b1f3809c5293f8c02d5b1204 | https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Codegen/CodegenBase.php#L722-L726 |
17,193 | qcubed/orm | src/Codegen/CodegenBase.php | CodegenBase.modelReferenceColumnName | protected function modelReferenceColumnName($strColumnName)
{
$intNameLength = strlen($strColumnName);
// Does the column name for this reference column end in "_id"?
if (($intNameLength > 3) && (substr($strColumnName, $intNameLength - 3) == "_id")) {
// It ends in "_id" but we don't want to include the "Id" suffix
// in the Variable Name. So remove it.
$strColumnName = substr($strColumnName, 0, $intNameLength - 3);
} else {
// Otherwise, let's add "_object" so that we don't confuse this variable name
// from the variable that was mapped from the physical database
// E.g., if it's a numeric FK, and the column is defined as "person INT",
// there will end up being two variables, one for the Person id integer, and
// one for the Person object itself. We'll add Object to the name of the Person object
// to make this deliniation.
$strColumnName = sprintf("%s_object", $strColumnName);
}
return $strColumnName;
} | php | protected function modelReferenceColumnName($strColumnName)
{
$intNameLength = strlen($strColumnName);
// Does the column name for this reference column end in "_id"?
if (($intNameLength > 3) && (substr($strColumnName, $intNameLength - 3) == "_id")) {
// It ends in "_id" but we don't want to include the "Id" suffix
// in the Variable Name. So remove it.
$strColumnName = substr($strColumnName, 0, $intNameLength - 3);
} else {
// Otherwise, let's add "_object" so that we don't confuse this variable name
// from the variable that was mapped from the physical database
// E.g., if it's a numeric FK, and the column is defined as "person INT",
// there will end up being two variables, one for the Person id integer, and
// one for the Person object itself. We'll add Object to the name of the Person object
// to make this deliniation.
$strColumnName = sprintf("%s_object", $strColumnName);
}
return $strColumnName;
} | [
"protected",
"function",
"modelReferenceColumnName",
"(",
"$",
"strColumnName",
")",
"{",
"$",
"intNameLength",
"=",
"strlen",
"(",
"$",
"strColumnName",
")",
";",
"// Does the column name for this reference column end in \"_id\"?",
"if",
"(",
"(",
"$",
"intNameLength",
">",
"3",
")",
"&&",
"(",
"substr",
"(",
"$",
"strColumnName",
",",
"$",
"intNameLength",
"-",
"3",
")",
"==",
"\"_id\"",
")",
")",
"{",
"// It ends in \"_id\" but we don't want to include the \"Id\" suffix",
"// in the Variable Name. So remove it.",
"$",
"strColumnName",
"=",
"substr",
"(",
"$",
"strColumnName",
",",
"0",
",",
"$",
"intNameLength",
"-",
"3",
")",
";",
"}",
"else",
"{",
"// Otherwise, let's add \"_object\" so that we don't confuse this variable name",
"// from the variable that was mapped from the physical database",
"// E.g., if it's a numeric FK, and the column is defined as \"person INT\",",
"// there will end up being two variables, one for the Person id integer, and",
"// one for the Person object itself. We'll add Object to the name of the Person object",
"// to make this deliniation.",
"$",
"strColumnName",
"=",
"sprintf",
"(",
"\"%s_object\"",
",",
"$",
"strColumnName",
")",
";",
"}",
"return",
"$",
"strColumnName",
";",
"}"
]
| Given the name of a column that is a foreign key to another table, returns a kind of
virtual column name that would refer to the object pointed to. This new name is used to refer to the object
version of the column by json and other encodings, and derivatives
of this name are used to represent a variable and property name that refers to this object that will get stored
in the model.
@param string $strColumnName
@return string | [
"Given",
"the",
"name",
"of",
"a",
"column",
"that",
"is",
"a",
"foreign",
"key",
"to",
"another",
"table",
"returns",
"a",
"kind",
"of",
"virtual",
"column",
"name",
"that",
"would",
"refer",
"to",
"the",
"object",
"pointed",
"to",
".",
"This",
"new",
"name",
"is",
"used",
"to",
"refer",
"to",
"the",
"object",
"version",
"of",
"the",
"column",
"by",
"json",
"and",
"other",
"encodings",
"and",
"derivatives",
"of",
"this",
"name",
"are",
"used",
"to",
"represent",
"a",
"variable",
"and",
"property",
"name",
"that",
"refers",
"to",
"this",
"object",
"that",
"will",
"get",
"stored",
"in",
"the",
"model",
"."
]
| f320eba671f20874b1f3809c5293f8c02d5b1204 | https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Codegen/CodegenBase.php#L760-L780 |
17,194 | qcubed/orm | src/Codegen/CodegenBase.php | CodegenBase.modelReferenceVariableName | protected function modelReferenceVariableName($strColumnName)
{
$strColumnName = $this->modelReferenceColumnName($strColumnName);
return Codegen::prefixFromType(Type::OBJECT) .
QString::camelCaseFromUnderscore($strColumnName);
} | php | protected function modelReferenceVariableName($strColumnName)
{
$strColumnName = $this->modelReferenceColumnName($strColumnName);
return Codegen::prefixFromType(Type::OBJECT) .
QString::camelCaseFromUnderscore($strColumnName);
} | [
"protected",
"function",
"modelReferenceVariableName",
"(",
"$",
"strColumnName",
")",
"{",
"$",
"strColumnName",
"=",
"$",
"this",
"->",
"modelReferenceColumnName",
"(",
"$",
"strColumnName",
")",
";",
"return",
"Codegen",
"::",
"prefixFromType",
"(",
"Type",
"::",
"OBJECT",
")",
".",
"QString",
"::",
"camelCaseFromUnderscore",
"(",
"$",
"strColumnName",
")",
";",
"}"
]
| Given a column name to a foreign key, returns the name of the variable that will represent the foreign object
stored in the model.
@param string $strColumnName
@return string | [
"Given",
"a",
"column",
"name",
"to",
"a",
"foreign",
"key",
"returns",
"the",
"name",
"of",
"the",
"variable",
"that",
"will",
"represent",
"the",
"foreign",
"object",
"stored",
"in",
"the",
"model",
"."
]
| f320eba671f20874b1f3809c5293f8c02d5b1204 | https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Codegen/CodegenBase.php#L789-L794 |
17,195 | qcubed/orm | src/Codegen/CodegenBase.php | CodegenBase.modelConnectorControlName | public static function modelConnectorControlName(ColumnInterface $objColumn)
{
if (($o = $objColumn->Options) && isset ($o['Name'])) { // Did developer default?
return $o['Name'];
}
return QString::wordsFromCamelCase(Codegen::modelConnectorPropertyName($objColumn));
} | php | public static function modelConnectorControlName(ColumnInterface $objColumn)
{
if (($o = $objColumn->Options) && isset ($o['Name'])) { // Did developer default?
return $o['Name'];
}
return QString::wordsFromCamelCase(Codegen::modelConnectorPropertyName($objColumn));
} | [
"public",
"static",
"function",
"modelConnectorControlName",
"(",
"ColumnInterface",
"$",
"objColumn",
")",
"{",
"if",
"(",
"(",
"$",
"o",
"=",
"$",
"objColumn",
"->",
"Options",
")",
"&&",
"isset",
"(",
"$",
"o",
"[",
"'Name'",
"]",
")",
")",
"{",
"// Did developer default?",
"return",
"$",
"o",
"[",
"'Name'",
"]",
";",
"}",
"return",
"QString",
"::",
"wordsFromCamelCase",
"(",
"Codegen",
"::",
"modelConnectorPropertyName",
"(",
"$",
"objColumn",
")",
")",
";",
"}"
]
| Returns the control label name as used in the ModelConnector corresponding to this column or table.
@param ColumnInterface $objColumn
@return string | [
"Returns",
"the",
"control",
"label",
"name",
"as",
"used",
"in",
"the",
"ModelConnector",
"corresponding",
"to",
"this",
"column",
"or",
"table",
"."
]
| f320eba671f20874b1f3809c5293f8c02d5b1204 | https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Codegen/CodegenBase.php#L868-L874 |
17,196 | qcubed/orm | src/Codegen/CodegenBase.php | CodegenBase.modelConnectorPropertyName | public static function modelConnectorPropertyName(ColumnInterface $objColumn)
{
if ($objColumn instanceof SqlColumn) {
if ($objColumn->Reference) {
return $objColumn->Reference->PropertyName;
} else {
return $objColumn->PropertyName;
}
} elseif ($objColumn instanceof ReverseReference) {
if ($objColumn->Unique) {
return ($objColumn->ObjectDescription);
} else {
return ($objColumn->ObjectDescriptionPlural);
}
} elseif ($objColumn instanceof ManyToManyReference) {
return $objColumn->ObjectDescriptionPlural;
} else {
throw new \Exception ('Unknown column type.');
}
} | php | public static function modelConnectorPropertyName(ColumnInterface $objColumn)
{
if ($objColumn instanceof SqlColumn) {
if ($objColumn->Reference) {
return $objColumn->Reference->PropertyName;
} else {
return $objColumn->PropertyName;
}
} elseif ($objColumn instanceof ReverseReference) {
if ($objColumn->Unique) {
return ($objColumn->ObjectDescription);
} else {
return ($objColumn->ObjectDescriptionPlural);
}
} elseif ($objColumn instanceof ManyToManyReference) {
return $objColumn->ObjectDescriptionPlural;
} else {
throw new \Exception ('Unknown column type.');
}
} | [
"public",
"static",
"function",
"modelConnectorPropertyName",
"(",
"ColumnInterface",
"$",
"objColumn",
")",
"{",
"if",
"(",
"$",
"objColumn",
"instanceof",
"SqlColumn",
")",
"{",
"if",
"(",
"$",
"objColumn",
"->",
"Reference",
")",
"{",
"return",
"$",
"objColumn",
"->",
"Reference",
"->",
"PropertyName",
";",
"}",
"else",
"{",
"return",
"$",
"objColumn",
"->",
"PropertyName",
";",
"}",
"}",
"elseif",
"(",
"$",
"objColumn",
"instanceof",
"ReverseReference",
")",
"{",
"if",
"(",
"$",
"objColumn",
"->",
"Unique",
")",
"{",
"return",
"(",
"$",
"objColumn",
"->",
"ObjectDescription",
")",
";",
"}",
"else",
"{",
"return",
"(",
"$",
"objColumn",
"->",
"ObjectDescriptionPlural",
")",
";",
"}",
"}",
"elseif",
"(",
"$",
"objColumn",
"instanceof",
"ManyToManyReference",
")",
"{",
"return",
"$",
"objColumn",
"->",
"ObjectDescriptionPlural",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Unknown column type.'",
")",
";",
"}",
"}"
]
| The property name used in the ModelConnector for the given column, virtual column or table
@param ColumnInterface $objColumn
@return string
@throws \Exception | [
"The",
"property",
"name",
"used",
"in",
"the",
"ModelConnector",
"for",
"the",
"given",
"column",
"virtual",
"column",
"or",
"table"
]
| f320eba671f20874b1f3809c5293f8c02d5b1204 | https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Codegen/CodegenBase.php#L884-L903 |
17,197 | qcubed/orm | src/Codegen/CodegenBase.php | CodegenBase.modelConnectorVariableName | public function modelConnectorVariableName(ColumnInterface $objColumn)
{
$strPropName = static::modelConnectorPropertyName($objColumn);
$objControlHelper = $this->getControlCodeGenerator($objColumn);
return $objControlHelper->varName($strPropName);
} | php | public function modelConnectorVariableName(ColumnInterface $objColumn)
{
$strPropName = static::modelConnectorPropertyName($objColumn);
$objControlHelper = $this->getControlCodeGenerator($objColumn);
return $objControlHelper->varName($strPropName);
} | [
"public",
"function",
"modelConnectorVariableName",
"(",
"ColumnInterface",
"$",
"objColumn",
")",
"{",
"$",
"strPropName",
"=",
"static",
"::",
"modelConnectorPropertyName",
"(",
"$",
"objColumn",
")",
";",
"$",
"objControlHelper",
"=",
"$",
"this",
"->",
"getControlCodeGenerator",
"(",
"$",
"objColumn",
")",
";",
"return",
"$",
"objControlHelper",
"->",
"varName",
"(",
"$",
"strPropName",
")",
";",
"}"
]
| Return a variable name corresponding to the given column, including virtual columns like
ReverseReference and QManyToMany references.
@param ColumnInterface $objColumn
@return string | [
"Return",
"a",
"variable",
"name",
"corresponding",
"to",
"the",
"given",
"column",
"including",
"virtual",
"columns",
"like",
"ReverseReference",
"and",
"QManyToMany",
"references",
"."
]
| f320eba671f20874b1f3809c5293f8c02d5b1204 | https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Codegen/CodegenBase.php#L911-L916 |
17,198 | qcubed/orm | src/Codegen/CodegenBase.php | CodegenBase.modelConnectorLabelVariableName | public function modelConnectorLabelVariableName(ColumnInterface $objColumn)
{
$strPropName = static::modelConnectorPropertyName($objColumn);
return \QCubed\Codegen\Generator\Label::instance()->varName($strPropName);
} | php | public function modelConnectorLabelVariableName(ColumnInterface $objColumn)
{
$strPropName = static::modelConnectorPropertyName($objColumn);
return \QCubed\Codegen\Generator\Label::instance()->varName($strPropName);
} | [
"public",
"function",
"modelConnectorLabelVariableName",
"(",
"ColumnInterface",
"$",
"objColumn",
")",
"{",
"$",
"strPropName",
"=",
"static",
"::",
"modelConnectorPropertyName",
"(",
"$",
"objColumn",
")",
";",
"return",
"\\",
"QCubed",
"\\",
"Codegen",
"\\",
"Generator",
"\\",
"Label",
"::",
"instance",
"(",
")",
"->",
"varName",
"(",
"$",
"strPropName",
")",
";",
"}"
]
| Returns a variable name for the "label" version of a control, which would be the read-only version
of viewing the data in the column.
@param ColumnInterface $objColumn
@return string | [
"Returns",
"a",
"variable",
"name",
"for",
"the",
"label",
"version",
"of",
"a",
"control",
"which",
"would",
"be",
"the",
"read",
"-",
"only",
"version",
"of",
"viewing",
"the",
"data",
"in",
"the",
"column",
"."
]
| f320eba671f20874b1f3809c5293f8c02d5b1204 | https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Codegen/CodegenBase.php#L924-L928 |
17,199 | qcubed/orm | src/Codegen/CodegenBase.php | CodegenBase.dataListControlName | public static function dataListControlName(SqlTable $objTable)
{
if (($o = $objTable->Options) && isset ($o['Name'])) { // Did developer default?
return $o['Name'];
}
return QString::wordsFromCamelCase($objTable->ClassNamePlural);
} | php | public static function dataListControlName(SqlTable $objTable)
{
if (($o = $objTable->Options) && isset ($o['Name'])) { // Did developer default?
return $o['Name'];
}
return QString::wordsFromCamelCase($objTable->ClassNamePlural);
} | [
"public",
"static",
"function",
"dataListControlName",
"(",
"SqlTable",
"$",
"objTable",
")",
"{",
"if",
"(",
"(",
"$",
"o",
"=",
"$",
"objTable",
"->",
"Options",
")",
"&&",
"isset",
"(",
"$",
"o",
"[",
"'Name'",
"]",
")",
")",
"{",
"// Did developer default?",
"return",
"$",
"o",
"[",
"'Name'",
"]",
";",
"}",
"return",
"QString",
"::",
"wordsFromCamelCase",
"(",
"$",
"objTable",
"->",
"ClassNamePlural",
")",
";",
"}"
]
| Returns the control label name as used in the data list panel corresponding to this column.
@param SqlTable $objTable
@return string | [
"Returns",
"the",
"control",
"label",
"name",
"as",
"used",
"in",
"the",
"data",
"list",
"panel",
"corresponding",
"to",
"this",
"column",
"."
]
| f320eba671f20874b1f3809c5293f8c02d5b1204 | https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Codegen/CodegenBase.php#L1011-L1017 |
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.