repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
sequence | docstring
stringlengths 3
47.2k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 91
247
| partition
stringclasses 1
value |
---|---|---|---|---|---|---|---|---|---|---|---|
agentmedia/phine-core | src/Core/Logic/Logging/LogEvaluator.php | LogEvaluator.LastContentLog | static function LastContentLog(Content $content)
{
$tblLogContent = LogContent::Schema()->Table();
$tblLogItem = LogItem::Schema()->Table();
$sql = Access::SqlBuilder();
$orderBy = $sql->OrderList($sql->OrderDesc($tblLogItem->Field('Changed')));
$joinCond = $sql->Equals($tblLogContent->Field('LogItem'), $tblLogItem->Field('ID'));
$where = $sql->Equals($tblLogContent->Field('Content'), $sql->Value($content->GetID()));
return LogItem::Schema()->First($where, $orderBy, null, $sql->Join($tblLogContent), JoinType::Inner(), $joinCond);
} | php | static function LastContentLog(Content $content)
{
$tblLogContent = LogContent::Schema()->Table();
$tblLogItem = LogItem::Schema()->Table();
$sql = Access::SqlBuilder();
$orderBy = $sql->OrderList($sql->OrderDesc($tblLogItem->Field('Changed')));
$joinCond = $sql->Equals($tblLogContent->Field('LogItem'), $tblLogItem->Field('ID'));
$where = $sql->Equals($tblLogContent->Field('Content'), $sql->Value($content->GetID()));
return LogItem::Schema()->First($where, $orderBy, null, $sql->Join($tblLogContent), JoinType::Inner(), $joinCond);
} | [
"static",
"function",
"LastContentLog",
"(",
"Content",
"$",
"content",
")",
"{",
"$",
"tblLogContent",
"=",
"LogContent",
"::",
"Schema",
"(",
")",
"->",
"Table",
"(",
")",
";",
"$",
"tblLogItem",
"=",
"LogItem",
"::",
"Schema",
"(",
")",
"->",
"Table",
"(",
")",
";",
"$",
"sql",
"=",
"Access",
"::",
"SqlBuilder",
"(",
")",
";",
"$",
"orderBy",
"=",
"$",
"sql",
"->",
"OrderList",
"(",
"$",
"sql",
"->",
"OrderDesc",
"(",
"$",
"tblLogItem",
"->",
"Field",
"(",
"'Changed'",
")",
")",
")",
";",
"$",
"joinCond",
"=",
"$",
"sql",
"->",
"Equals",
"(",
"$",
"tblLogContent",
"->",
"Field",
"(",
"'LogItem'",
")",
",",
"$",
"tblLogItem",
"->",
"Field",
"(",
"'ID'",
")",
")",
";",
"$",
"where",
"=",
"$",
"sql",
"->",
"Equals",
"(",
"$",
"tblLogContent",
"->",
"Field",
"(",
"'Content'",
")",
",",
"$",
"sql",
"->",
"Value",
"(",
"$",
"content",
"->",
"GetID",
"(",
")",
")",
")",
";",
"return",
"LogItem",
"::",
"Schema",
"(",
")",
"->",
"First",
"(",
"$",
"where",
",",
"$",
"orderBy",
",",
"null",
",",
"$",
"sql",
"->",
"Join",
"(",
"$",
"tblLogContent",
")",
",",
"JoinType",
"::",
"Inner",
"(",
")",
",",
"$",
"joinCond",
")",
";",
"}"
] | The last log item that is directly related to the content
@param Content $content The content
@return LogItem Returns the log item | [
"The",
"last",
"log",
"item",
"that",
"is",
"directly",
"related",
"to",
"the",
"content"
] | 38c1be8d03ebffae950d00a96da3c612aff67832 | https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Logic/Logging/LogEvaluator.php#L185-L194 | train |
agentmedia/phine-core | src/Core/Logic/Logging/LogEvaluator.php | LogEvaluator.LastLayoutLog | static function LastLayoutLog(Layout $layout)
{
$tblLogLayout = LogLayout::Schema()->Table();
$tblLogItem = LogItem::Schema()->Table();
$sql = Access::SqlBuilder();
$orderBy = $sql->OrderList($sql->OrderDesc($tblLogItem->Field('Changed')));
$joinCond = $sql->Equals($tblLogLayout->Field('LogItem'), $tblLogItem->Field('ID'));
$where = $sql->Equals($tblLogLayout->Field('Layout'), $sql->Value($layout->GetID()));
return LogItem::Schema()->First($where, $orderBy, null, $sql->Join($tblLogLayout), JoinType::Inner(), $joinCond);
} | php | static function LastLayoutLog(Layout $layout)
{
$tblLogLayout = LogLayout::Schema()->Table();
$tblLogItem = LogItem::Schema()->Table();
$sql = Access::SqlBuilder();
$orderBy = $sql->OrderList($sql->OrderDesc($tblLogItem->Field('Changed')));
$joinCond = $sql->Equals($tblLogLayout->Field('LogItem'), $tblLogItem->Field('ID'));
$where = $sql->Equals($tblLogLayout->Field('Layout'), $sql->Value($layout->GetID()));
return LogItem::Schema()->First($where, $orderBy, null, $sql->Join($tblLogLayout), JoinType::Inner(), $joinCond);
} | [
"static",
"function",
"LastLayoutLog",
"(",
"Layout",
"$",
"layout",
")",
"{",
"$",
"tblLogLayout",
"=",
"LogLayout",
"::",
"Schema",
"(",
")",
"->",
"Table",
"(",
")",
";",
"$",
"tblLogItem",
"=",
"LogItem",
"::",
"Schema",
"(",
")",
"->",
"Table",
"(",
")",
";",
"$",
"sql",
"=",
"Access",
"::",
"SqlBuilder",
"(",
")",
";",
"$",
"orderBy",
"=",
"$",
"sql",
"->",
"OrderList",
"(",
"$",
"sql",
"->",
"OrderDesc",
"(",
"$",
"tblLogItem",
"->",
"Field",
"(",
"'Changed'",
")",
")",
")",
";",
"$",
"joinCond",
"=",
"$",
"sql",
"->",
"Equals",
"(",
"$",
"tblLogLayout",
"->",
"Field",
"(",
"'LogItem'",
")",
",",
"$",
"tblLogItem",
"->",
"Field",
"(",
"'ID'",
")",
")",
";",
"$",
"where",
"=",
"$",
"sql",
"->",
"Equals",
"(",
"$",
"tblLogLayout",
"->",
"Field",
"(",
"'Layout'",
")",
",",
"$",
"sql",
"->",
"Value",
"(",
"$",
"layout",
"->",
"GetID",
"(",
")",
")",
")",
";",
"return",
"LogItem",
"::",
"Schema",
"(",
")",
"->",
"First",
"(",
"$",
"where",
",",
"$",
"orderBy",
",",
"null",
",",
"$",
"sql",
"->",
"Join",
"(",
"$",
"tblLogLayout",
")",
",",
"JoinType",
"::",
"Inner",
"(",
")",
",",
"$",
"joinCond",
")",
";",
"}"
] | The last log item that is directly related to the layout
@param Layout $layout The layout
@return LogItem Returns the log item | [
"The",
"last",
"log",
"item",
"that",
"is",
"directly",
"related",
"to",
"the",
"layout"
] | 38c1be8d03ebffae950d00a96da3c612aff67832 | https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Logic/Logging/LogEvaluator.php#L201-L210 | train |
agentmedia/phine-core | src/Core/Logic/Logging/LogEvaluator.php | LogEvaluator.LastAreaLog | static function LastAreaLog(Area $area)
{
$tblLogArea = LogArea::Schema()->Table();
$tblLogItem = LogItem::Schema()->Table();
$sql = Access::SqlBuilder();
$orderBy = $sql->OrderList($sql->OrderDesc($tblLogItem->Field('Changed')));
$joinCond = $sql->Equals($tblLogArea->Field('LogItem'), $tblLogItem->Field('ID'));
$where = $sql->Equals($tblLogArea->Field('Area'), $sql->Value($area->GetID()));
return LogItem::Schema()->First($where, $orderBy, null, $sql->Join($tblLogArea), JoinType::Inner(), $joinCond);
} | php | static function LastAreaLog(Area $area)
{
$tblLogArea = LogArea::Schema()->Table();
$tblLogItem = LogItem::Schema()->Table();
$sql = Access::SqlBuilder();
$orderBy = $sql->OrderList($sql->OrderDesc($tblLogItem->Field('Changed')));
$joinCond = $sql->Equals($tblLogArea->Field('LogItem'), $tblLogItem->Field('ID'));
$where = $sql->Equals($tblLogArea->Field('Area'), $sql->Value($area->GetID()));
return LogItem::Schema()->First($where, $orderBy, null, $sql->Join($tblLogArea), JoinType::Inner(), $joinCond);
} | [
"static",
"function",
"LastAreaLog",
"(",
"Area",
"$",
"area",
")",
"{",
"$",
"tblLogArea",
"=",
"LogArea",
"::",
"Schema",
"(",
")",
"->",
"Table",
"(",
")",
";",
"$",
"tblLogItem",
"=",
"LogItem",
"::",
"Schema",
"(",
")",
"->",
"Table",
"(",
")",
";",
"$",
"sql",
"=",
"Access",
"::",
"SqlBuilder",
"(",
")",
";",
"$",
"orderBy",
"=",
"$",
"sql",
"->",
"OrderList",
"(",
"$",
"sql",
"->",
"OrderDesc",
"(",
"$",
"tblLogItem",
"->",
"Field",
"(",
"'Changed'",
")",
")",
")",
";",
"$",
"joinCond",
"=",
"$",
"sql",
"->",
"Equals",
"(",
"$",
"tblLogArea",
"->",
"Field",
"(",
"'LogItem'",
")",
",",
"$",
"tblLogItem",
"->",
"Field",
"(",
"'ID'",
")",
")",
";",
"$",
"where",
"=",
"$",
"sql",
"->",
"Equals",
"(",
"$",
"tblLogArea",
"->",
"Field",
"(",
"'Area'",
")",
",",
"$",
"sql",
"->",
"Value",
"(",
"$",
"area",
"->",
"GetID",
"(",
")",
")",
")",
";",
"return",
"LogItem",
"::",
"Schema",
"(",
")",
"->",
"First",
"(",
"$",
"where",
",",
"$",
"orderBy",
",",
"null",
",",
"$",
"sql",
"->",
"Join",
"(",
"$",
"tblLogArea",
")",
",",
"JoinType",
"::",
"Inner",
"(",
")",
",",
"$",
"joinCond",
")",
";",
"}"
] | The last log item that is directly related to the area
@param Area $area The area
@return LogItem Returns the log item | [
"The",
"last",
"log",
"item",
"that",
"is",
"directly",
"related",
"to",
"the",
"area"
] | 38c1be8d03ebffae950d00a96da3c612aff67832 | https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Logic/Logging/LogEvaluator.php#L217-L226 | train |
agentmedia/phine-core | src/Core/Logic/Logging/LogEvaluator.php | LogEvaluator.LastContainerLog | static function LastContainerLog(Container $container)
{
$tblLogContainer = LogContainer::Schema()->Table();
$tblLogItem = LogItem::Schema()->Table();
$sql = Access::SqlBuilder();
$orderBy = $sql->OrderList($sql->OrderDesc($tblLogItem->Field('Changed')));
$joinCond = $sql->Equals($tblLogContainer->Field('LogItem'), $tblLogItem->Field('ID'));
$where = $sql->Equals($tblLogContainer->Field('Container'), $sql->Value($container->GetID()));
return LogItem::Schema()->First($where, $orderBy, null, $sql->Join($tblLogContainer), JoinType::Inner(), $joinCond);
} | php | static function LastContainerLog(Container $container)
{
$tblLogContainer = LogContainer::Schema()->Table();
$tblLogItem = LogItem::Schema()->Table();
$sql = Access::SqlBuilder();
$orderBy = $sql->OrderList($sql->OrderDesc($tblLogItem->Field('Changed')));
$joinCond = $sql->Equals($tblLogContainer->Field('LogItem'), $tblLogItem->Field('ID'));
$where = $sql->Equals($tblLogContainer->Field('Container'), $sql->Value($container->GetID()));
return LogItem::Schema()->First($where, $orderBy, null, $sql->Join($tblLogContainer), JoinType::Inner(), $joinCond);
} | [
"static",
"function",
"LastContainerLog",
"(",
"Container",
"$",
"container",
")",
"{",
"$",
"tblLogContainer",
"=",
"LogContainer",
"::",
"Schema",
"(",
")",
"->",
"Table",
"(",
")",
";",
"$",
"tblLogItem",
"=",
"LogItem",
"::",
"Schema",
"(",
")",
"->",
"Table",
"(",
")",
";",
"$",
"sql",
"=",
"Access",
"::",
"SqlBuilder",
"(",
")",
";",
"$",
"orderBy",
"=",
"$",
"sql",
"->",
"OrderList",
"(",
"$",
"sql",
"->",
"OrderDesc",
"(",
"$",
"tblLogItem",
"->",
"Field",
"(",
"'Changed'",
")",
")",
")",
";",
"$",
"joinCond",
"=",
"$",
"sql",
"->",
"Equals",
"(",
"$",
"tblLogContainer",
"->",
"Field",
"(",
"'LogItem'",
")",
",",
"$",
"tblLogItem",
"->",
"Field",
"(",
"'ID'",
")",
")",
";",
"$",
"where",
"=",
"$",
"sql",
"->",
"Equals",
"(",
"$",
"tblLogContainer",
"->",
"Field",
"(",
"'Container'",
")",
",",
"$",
"sql",
"->",
"Value",
"(",
"$",
"container",
"->",
"GetID",
"(",
")",
")",
")",
";",
"return",
"LogItem",
"::",
"Schema",
"(",
")",
"->",
"First",
"(",
"$",
"where",
",",
"$",
"orderBy",
",",
"null",
",",
"$",
"sql",
"->",
"Join",
"(",
"$",
"tblLogContainer",
")",
",",
"JoinType",
"::",
"Inner",
"(",
")",
",",
"$",
"joinCond",
")",
";",
"}"
] | The last log item that is directly related to the container
@param Container $container The container
@return LogItem Returns the log item | [
"The",
"last",
"log",
"item",
"that",
"is",
"directly",
"related",
"to",
"the",
"container"
] | 38c1be8d03ebffae950d00a96da3c612aff67832 | https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Logic/Logging/LogEvaluator.php#L233-L242 | train |
agentmedia/phine-core | src/Core/Logic/Logging/LogEvaluator.php | LogEvaluator.LastTemplateLog | static function LastTemplateLog($moduleType, $template)
{
$tblLogTemplate = \App\Phine\Database\Core\LogTemplate::Schema()->Table();
$tblLogItem = LogItem::Schema()->Table();
$sql = Access::SqlBuilder();
$orderBy = $sql->OrderList($sql->OrderDesc($tblLogItem->Field('Changed')));
$joinCond = $sql->Equals($tblLogTemplate->Field('LogItem'), $tblLogItem->Field('ID'));
$where = $sql->Equals($tblLogTemplate->Field('Template'), $sql->Value($template))
->And_($sql->Equals($tblLogTemplate->Field('ModuleType'), $moduleType));
return LogItem::Schema()->First($where, $orderBy, null, $sql->Join($tblLogTemplate), JoinType::Inner(), $joinCond);
} | php | static function LastTemplateLog($moduleType, $template)
{
$tblLogTemplate = \App\Phine\Database\Core\LogTemplate::Schema()->Table();
$tblLogItem = LogItem::Schema()->Table();
$sql = Access::SqlBuilder();
$orderBy = $sql->OrderList($sql->OrderDesc($tblLogItem->Field('Changed')));
$joinCond = $sql->Equals($tblLogTemplate->Field('LogItem'), $tblLogItem->Field('ID'));
$where = $sql->Equals($tblLogTemplate->Field('Template'), $sql->Value($template))
->And_($sql->Equals($tblLogTemplate->Field('ModuleType'), $moduleType));
return LogItem::Schema()->First($where, $orderBy, null, $sql->Join($tblLogTemplate), JoinType::Inner(), $joinCond);
} | [
"static",
"function",
"LastTemplateLog",
"(",
"$",
"moduleType",
",",
"$",
"template",
")",
"{",
"$",
"tblLogTemplate",
"=",
"\\",
"App",
"\\",
"Phine",
"\\",
"Database",
"\\",
"Core",
"\\",
"LogTemplate",
"::",
"Schema",
"(",
")",
"->",
"Table",
"(",
")",
";",
"$",
"tblLogItem",
"=",
"LogItem",
"::",
"Schema",
"(",
")",
"->",
"Table",
"(",
")",
";",
"$",
"sql",
"=",
"Access",
"::",
"SqlBuilder",
"(",
")",
";",
"$",
"orderBy",
"=",
"$",
"sql",
"->",
"OrderList",
"(",
"$",
"sql",
"->",
"OrderDesc",
"(",
"$",
"tblLogItem",
"->",
"Field",
"(",
"'Changed'",
")",
")",
")",
";",
"$",
"joinCond",
"=",
"$",
"sql",
"->",
"Equals",
"(",
"$",
"tblLogTemplate",
"->",
"Field",
"(",
"'LogItem'",
")",
",",
"$",
"tblLogItem",
"->",
"Field",
"(",
"'ID'",
")",
")",
";",
"$",
"where",
"=",
"$",
"sql",
"->",
"Equals",
"(",
"$",
"tblLogTemplate",
"->",
"Field",
"(",
"'Template'",
")",
",",
"$",
"sql",
"->",
"Value",
"(",
"$",
"template",
")",
")",
"->",
"And_",
"(",
"$",
"sql",
"->",
"Equals",
"(",
"$",
"tblLogTemplate",
"->",
"Field",
"(",
"'ModuleType'",
")",
",",
"$",
"moduleType",
")",
")",
";",
"return",
"LogItem",
"::",
"Schema",
"(",
")",
"->",
"First",
"(",
"$",
"where",
",",
"$",
"orderBy",
",",
"null",
",",
"$",
"sql",
"->",
"Join",
"(",
"$",
"tblLogTemplate",
")",
",",
"JoinType",
"::",
"Inner",
"(",
")",
",",
"$",
"joinCond",
")",
";",
"}"
] | The last log item that is directly related to the template
@param Content $content The content
@return LogItem Returns the log item | [
"The",
"last",
"log",
"item",
"that",
"is",
"directly",
"related",
"to",
"the",
"template"
] | 38c1be8d03ebffae950d00a96da3c612aff67832 | https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Logic/Logging/LogEvaluator.php#L249-L259 | train |
makinacorpus/drupal-ulink | src/EntityLinkGenerator.php | EntityLinkGenerator.getDrupalEntityPath | private function getDrupalEntityPath($type, $entity)
{
$uri = entity_uri($type, $entity);
if (!$uri) {
throw new \InvalidArgumentException(sprintf("%s: entity type is not supported yet"));
}
return $uri['path'];
} | php | private function getDrupalEntityPath($type, $entity)
{
$uri = entity_uri($type, $entity);
if (!$uri) {
throw new \InvalidArgumentException(sprintf("%s: entity type is not supported yet"));
}
return $uri['path'];
} | [
"private",
"function",
"getDrupalEntityPath",
"(",
"$",
"type",
",",
"$",
"entity",
")",
"{",
"$",
"uri",
"=",
"entity_uri",
"(",
"$",
"type",
",",
"$",
"entity",
")",
";",
"if",
"(",
"!",
"$",
"uri",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"\"%s: entity type is not supported yet\"",
")",
")",
";",
"}",
"return",
"$",
"uri",
"[",
"'path'",
"]",
";",
"}"
] | Uses drupal 7 API to generate the entity URL
@param string $type
@param mixed $entity
@return string | [
"Uses",
"drupal",
"7",
"API",
"to",
"generate",
"the",
"entity",
"URL"
] | 4e1e54b979d72934a6fc0242aae3f12abebf41d0 | https://github.com/makinacorpus/drupal-ulink/blob/4e1e54b979d72934a6fc0242aae3f12abebf41d0/src/EntityLinkGenerator.php#L84-L93 | train |
makinacorpus/drupal-ulink | src/EntityLinkGenerator.php | EntityLinkGenerator.getEntityPath | public function getEntityPath($type, $id)
{
// Allow other modules to interact
$event = new EntityGetPathEvent($type, $id);
$this->eventDispatcher->dispatch(EntityGetPathEvent::EVENT_GET_PATH, $event);
if ($path = $event->getPath()) {
return $path;
}
// In most cases, this will be used for nodes only, so just set the
// node URL.
// It will avoid nasty bugs, since the 'text' core module does sanitize
// (and call check_markup()) during field load if there are any circular
// links dependencies between two nodes, it triggers an finite loop.
// This will also make the whole faster.
// @todo If node does not exists, no error will be triggered.
if ('node' === $type) {
return 'node/' . $id;
}
$entity = $this->entityManager->getStorage($type)->load($id);
if (!$entity) {
throw new \InvalidArgumentException(sprintf("entity of type %s with identifier %s does not exist", $type, $id));
}
if (!$entity instanceof EntityInterface) {
return $this->getDrupalEntityPath($type, $entity);
} else {
return $entity->url();
}
} | php | public function getEntityPath($type, $id)
{
// Allow other modules to interact
$event = new EntityGetPathEvent($type, $id);
$this->eventDispatcher->dispatch(EntityGetPathEvent::EVENT_GET_PATH, $event);
if ($path = $event->getPath()) {
return $path;
}
// In most cases, this will be used for nodes only, so just set the
// node URL.
// It will avoid nasty bugs, since the 'text' core module does sanitize
// (and call check_markup()) during field load if there are any circular
// links dependencies between two nodes, it triggers an finite loop.
// This will also make the whole faster.
// @todo If node does not exists, no error will be triggered.
if ('node' === $type) {
return 'node/' . $id;
}
$entity = $this->entityManager->getStorage($type)->load($id);
if (!$entity) {
throw new \InvalidArgumentException(sprintf("entity of type %s with identifier %s does not exist", $type, $id));
}
if (!$entity instanceof EntityInterface) {
return $this->getDrupalEntityPath($type, $entity);
} else {
return $entity->url();
}
} | [
"public",
"function",
"getEntityPath",
"(",
"$",
"type",
",",
"$",
"id",
")",
"{",
"// Allow other modules to interact",
"$",
"event",
"=",
"new",
"EntityGetPathEvent",
"(",
"$",
"type",
",",
"$",
"id",
")",
";",
"$",
"this",
"->",
"eventDispatcher",
"->",
"dispatch",
"(",
"EntityGetPathEvent",
"::",
"EVENT_GET_PATH",
",",
"$",
"event",
")",
";",
"if",
"(",
"$",
"path",
"=",
"$",
"event",
"->",
"getPath",
"(",
")",
")",
"{",
"return",
"$",
"path",
";",
"}",
"// In most cases, this will be used for nodes only, so just set the",
"// node URL.",
"// It will avoid nasty bugs, since the 'text' core module does sanitize",
"// (and call check_markup()) during field load if there are any circular",
"// links dependencies between two nodes, it triggers an finite loop.",
"// This will also make the whole faster.",
"// @todo If node does not exists, no error will be triggered.",
"if",
"(",
"'node'",
"===",
"$",
"type",
")",
"{",
"return",
"'node/'",
".",
"$",
"id",
";",
"}",
"$",
"entity",
"=",
"$",
"this",
"->",
"entityManager",
"->",
"getStorage",
"(",
"$",
"type",
")",
"->",
"load",
"(",
"$",
"id",
")",
";",
"if",
"(",
"!",
"$",
"entity",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"\"entity of type %s with identifier %s does not exist\"",
",",
"$",
"type",
",",
"$",
"id",
")",
")",
";",
"}",
"if",
"(",
"!",
"$",
"entity",
"instanceof",
"EntityInterface",
")",
"{",
"return",
"$",
"this",
"->",
"getDrupalEntityPath",
"(",
"$",
"type",
",",
"$",
"entity",
")",
";",
"}",
"else",
"{",
"return",
"$",
"entity",
"->",
"url",
"(",
")",
";",
"}",
"}"
] | Get entity internal path
@param string $type
Entity type
@param int|string $id
Entity identifier
@return string
The Drupal internal path | [
"Get",
"entity",
"internal",
"path"
] | 4e1e54b979d72934a6fc0242aae3f12abebf41d0 | https://github.com/makinacorpus/drupal-ulink/blob/4e1e54b979d72934a6fc0242aae3f12abebf41d0/src/EntityLinkGenerator.php#L106-L136 | train |
makinacorpus/drupal-ulink | src/EntityLinkGenerator.php | EntityLinkGenerator.getEntityPathFromURI | public function getEntityPathFromURI($uri)
{
if ($parts = $this->decomposeURI($uri)) {
return $this->getEntityPath($parts['type'], $parts['id']);
}
throw new \InvalidArgumentException(sprintf("%s: invalid entity URI scheme or malformed URI", $uri));
} | php | public function getEntityPathFromURI($uri)
{
if ($parts = $this->decomposeURI($uri)) {
return $this->getEntityPath($parts['type'], $parts['id']);
}
throw new \InvalidArgumentException(sprintf("%s: invalid entity URI scheme or malformed URI", $uri));
} | [
"public",
"function",
"getEntityPathFromURI",
"(",
"$",
"uri",
")",
"{",
"if",
"(",
"$",
"parts",
"=",
"$",
"this",
"->",
"decomposeURI",
"(",
"$",
"uri",
")",
")",
"{",
"return",
"$",
"this",
"->",
"getEntityPath",
"(",
"$",
"parts",
"[",
"'type'",
"]",
",",
"$",
"parts",
"[",
"'id'",
"]",
")",
";",
"}",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"\"%s: invalid entity URI scheme or malformed URI\"",
",",
"$",
"uri",
")",
")",
";",
"}"
] | Get entity internal path from internal URI
@param string $uri
Must match one of the supported schemes
@throws \InvalidArgumentException | [
"Get",
"entity",
"internal",
"path",
"from",
"internal",
"URI"
] | 4e1e54b979d72934a6fc0242aae3f12abebf41d0 | https://github.com/makinacorpus/drupal-ulink/blob/4e1e54b979d72934a6fc0242aae3f12abebf41d0/src/EntityLinkGenerator.php#L146-L153 | train |
makinacorpus/drupal-ulink | src/EntityLinkGenerator.php | EntityLinkGenerator.decomposeURI | public function decomposeURI($uri, &$type = null)
{
$elements = [];
if (!self::URIIsCandidate($uri)) {
return $elements;
}
foreach ($this->getURIPatterns() as $name => $pattern) {
if (preg_match($pattern, $uri, $matches)) {
$type = $name;
$elements = [
'type' => $matches['type'],
'id' => $matches['id'],
];
break;
}
}
return $elements;
} | php | public function decomposeURI($uri, &$type = null)
{
$elements = [];
if (!self::URIIsCandidate($uri)) {
return $elements;
}
foreach ($this->getURIPatterns() as $name => $pattern) {
if (preg_match($pattern, $uri, $matches)) {
$type = $name;
$elements = [
'type' => $matches['type'],
'id' => $matches['id'],
];
break;
}
}
return $elements;
} | [
"public",
"function",
"decomposeURI",
"(",
"$",
"uri",
",",
"&",
"$",
"type",
"=",
"null",
")",
"{",
"$",
"elements",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"self",
"::",
"URIIsCandidate",
"(",
"$",
"uri",
")",
")",
"{",
"return",
"$",
"elements",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"getURIPatterns",
"(",
")",
"as",
"$",
"name",
"=>",
"$",
"pattern",
")",
"{",
"if",
"(",
"preg_match",
"(",
"$",
"pattern",
",",
"$",
"uri",
",",
"$",
"matches",
")",
")",
"{",
"$",
"type",
"=",
"$",
"name",
";",
"$",
"elements",
"=",
"[",
"'type'",
"=>",
"$",
"matches",
"[",
"'type'",
"]",
",",
"'id'",
"=>",
"$",
"matches",
"[",
"'id'",
"]",
",",
"]",
";",
"break",
";",
"}",
"}",
"return",
"$",
"elements",
";",
"}"
] | Extract entity type and id from the given URI.
@param string $uri
@param string $type
The type of the URI will be passed on to you through this argument.
@return string[] | [
"Extract",
"entity",
"type",
"and",
"id",
"from",
"the",
"given",
"URI",
"."
] | 4e1e54b979d72934a6fc0242aae3f12abebf41d0 | https://github.com/makinacorpus/drupal-ulink/blob/4e1e54b979d72934a6fc0242aae3f12abebf41d0/src/EntityLinkGenerator.php#L164-L184 | train |
makinacorpus/drupal-ulink | src/EntityLinkGenerator.php | EntityLinkGenerator.formatURI | public function formatURI($type, $id, $uriType = self::SCHEME_TYPE)
{
switch ($uriType) {
case self::SCHEME_TYPE:
return 'entity://' . $type . '/' . $id;
case self::STACHE_TYPE:
return '{{' . $type . '/' . $id . '}}';
}
throw new \InvalidArgumentException(sprintf("%s: invalid URI type", $uriType));
} | php | public function formatURI($type, $id, $uriType = self::SCHEME_TYPE)
{
switch ($uriType) {
case self::SCHEME_TYPE:
return 'entity://' . $type . '/' . $id;
case self::STACHE_TYPE:
return '{{' . $type . '/' . $id . '}}';
}
throw new \InvalidArgumentException(sprintf("%s: invalid URI type", $uriType));
} | [
"public",
"function",
"formatURI",
"(",
"$",
"type",
",",
"$",
"id",
",",
"$",
"uriType",
"=",
"self",
"::",
"SCHEME_TYPE",
")",
"{",
"switch",
"(",
"$",
"uriType",
")",
"{",
"case",
"self",
"::",
"SCHEME_TYPE",
":",
"return",
"'entity://'",
".",
"$",
"type",
".",
"'/'",
".",
"$",
"id",
";",
"case",
"self",
"::",
"STACHE_TYPE",
":",
"return",
"'{{'",
".",
"$",
"type",
".",
"'/'",
".",
"$",
"id",
".",
"'}}'",
";",
"}",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"\"%s: invalid URI type\"",
",",
"$",
"uriType",
")",
")",
";",
"}"
] | Format an URI.
@param string Entity type
@param integer Entity identifier
@param string Type of the URI
@return string | [
"Format",
"an",
"URI",
"."
] | 4e1e54b979d72934a6fc0242aae3f12abebf41d0 | https://github.com/makinacorpus/drupal-ulink/blob/4e1e54b979d72934a6fc0242aae3f12abebf41d0/src/EntityLinkGenerator.php#L195-L204 | train |
makinacorpus/drupal-ulink | src/EntityLinkGenerator.php | EntityLinkGenerator.replaceAllInText | public function replaceAllInText($text)
{
$uriInfo = [];
// Collects all µlink URIs present in the text and stores them
// in an array keyed by their offset.
foreach ($this->getURIPatterns() as $pattern) {
$matches = [];
if (preg_match_all($pattern, $text, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE)) {
foreach ($matches as $match) {
list($uri, $offset) = $match[0];
$uriInfo[$offset] = [
'uri' => $uri,
'type' => $match['type'][0],
'id' => $match['id'][0],
];
}
}
}
// Sorts collected URIs by descending offset to start replacements
// by the end of the text, ensuring in this way that the next offsets
// will stay valid after each replacement.
krsort($uriInfo);
// Dispatches an event to allow some alterations of URIs information
// before transform them in standard URLs.
$event = new EntityLinkFilterEvent($uriInfo);
$this->eventDispatcher->dispatch(EntityLinkFilterEvent::EVENT_BEFORE_FILTER, $event);
// Replaces µlink URIs by standard URLs.
foreach ($event->getURIInfo() as $offset => $info) {
// Something inserted a new entry!?
// Ok, just ignore it.
if (!isset($uriInfo[$offset])) {
continue;
}
// Something altered the original URI!?
// Ok, just retrieve the text's version for the next.
if ($info['uri'] !== $uriInfo[$offset]['uri']) {
$info['uri'] = $uriInfo[$offset]['uri'];
}
try {
$uri = url($this->getEntityPath($info['type'], $info['id']));
} catch (\Exception $e) {
$uri = '#'; // Silent fail for frontend
}
$text = substr_replace($text, $uri, $offset, strlen($info['uri']));
}
return $text;
} | php | public function replaceAllInText($text)
{
$uriInfo = [];
// Collects all µlink URIs present in the text and stores them
// in an array keyed by their offset.
foreach ($this->getURIPatterns() as $pattern) {
$matches = [];
if (preg_match_all($pattern, $text, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE)) {
foreach ($matches as $match) {
list($uri, $offset) = $match[0];
$uriInfo[$offset] = [
'uri' => $uri,
'type' => $match['type'][0],
'id' => $match['id'][0],
];
}
}
}
// Sorts collected URIs by descending offset to start replacements
// by the end of the text, ensuring in this way that the next offsets
// will stay valid after each replacement.
krsort($uriInfo);
// Dispatches an event to allow some alterations of URIs information
// before transform them in standard URLs.
$event = new EntityLinkFilterEvent($uriInfo);
$this->eventDispatcher->dispatch(EntityLinkFilterEvent::EVENT_BEFORE_FILTER, $event);
// Replaces µlink URIs by standard URLs.
foreach ($event->getURIInfo() as $offset => $info) {
// Something inserted a new entry!?
// Ok, just ignore it.
if (!isset($uriInfo[$offset])) {
continue;
}
// Something altered the original URI!?
// Ok, just retrieve the text's version for the next.
if ($info['uri'] !== $uriInfo[$offset]['uri']) {
$info['uri'] = $uriInfo[$offset]['uri'];
}
try {
$uri = url($this->getEntityPath($info['type'], $info['id']));
} catch (\Exception $e) {
$uri = '#'; // Silent fail for frontend
}
$text = substr_replace($text, $uri, $offset, strlen($info['uri']));
}
return $text;
} | [
"public",
"function",
"replaceAllInText",
"(",
"$",
"text",
")",
"{",
"$",
"uriInfo",
"=",
"[",
"]",
";",
"// Collects all µlink URIs present in the text and stores them",
"// in an array keyed by their offset.",
"foreach",
"(",
"$",
"this",
"->",
"getURIPatterns",
"(",
")",
"as",
"$",
"pattern",
")",
"{",
"$",
"matches",
"=",
"[",
"]",
";",
"if",
"(",
"preg_match_all",
"(",
"$",
"pattern",
",",
"$",
"text",
",",
"$",
"matches",
",",
"PREG_SET_ORDER",
"|",
"PREG_OFFSET_CAPTURE",
")",
")",
"{",
"foreach",
"(",
"$",
"matches",
"as",
"$",
"match",
")",
"{",
"list",
"(",
"$",
"uri",
",",
"$",
"offset",
")",
"=",
"$",
"match",
"[",
"0",
"]",
";",
"$",
"uriInfo",
"[",
"$",
"offset",
"]",
"=",
"[",
"'uri'",
"=>",
"$",
"uri",
",",
"'type'",
"=>",
"$",
"match",
"[",
"'type'",
"]",
"[",
"0",
"]",
",",
"'id'",
"=>",
"$",
"match",
"[",
"'id'",
"]",
"[",
"0",
"]",
",",
"]",
";",
"}",
"}",
"}",
"// Sorts collected URIs by descending offset to start replacements",
"// by the end of the text, ensuring in this way that the next offsets",
"// will stay valid after each replacement.",
"krsort",
"(",
"$",
"uriInfo",
")",
";",
"// Dispatches an event to allow some alterations of URIs information",
"// before transform them in standard URLs.",
"$",
"event",
"=",
"new",
"EntityLinkFilterEvent",
"(",
"$",
"uriInfo",
")",
";",
"$",
"this",
"->",
"eventDispatcher",
"->",
"dispatch",
"(",
"EntityLinkFilterEvent",
"::",
"EVENT_BEFORE_FILTER",
",",
"$",
"event",
")",
";",
"// Replaces µlink URIs by standard URLs.",
"foreach",
"(",
"$",
"event",
"->",
"getURIInfo",
"(",
")",
"as",
"$",
"offset",
"=>",
"$",
"info",
")",
"{",
"// Something inserted a new entry!?",
"// Ok, just ignore it.",
"if",
"(",
"!",
"isset",
"(",
"$",
"uriInfo",
"[",
"$",
"offset",
"]",
")",
")",
"{",
"continue",
";",
"}",
"// Something altered the original URI!?",
"// Ok, just retrieve the text's version for the next.",
"if",
"(",
"$",
"info",
"[",
"'uri'",
"]",
"!==",
"$",
"uriInfo",
"[",
"$",
"offset",
"]",
"[",
"'uri'",
"]",
")",
"{",
"$",
"info",
"[",
"'uri'",
"]",
"=",
"$",
"uriInfo",
"[",
"$",
"offset",
"]",
"[",
"'uri'",
"]",
";",
"}",
"try",
"{",
"$",
"uri",
"=",
"url",
"(",
"$",
"this",
"->",
"getEntityPath",
"(",
"$",
"info",
"[",
"'type'",
"]",
",",
"$",
"info",
"[",
"'id'",
"]",
")",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"uri",
"=",
"'#'",
";",
"// Silent fail for frontend",
"}",
"$",
"text",
"=",
"substr_replace",
"(",
"$",
"text",
",",
"$",
"uri",
",",
"$",
"offset",
",",
"strlen",
"(",
"$",
"info",
"[",
"'uri'",
"]",
")",
")",
";",
"}",
"return",
"$",
"text",
";",
"}"
] | Replace all occurences of entity URIs in text by the generated URLs.
@param string $text
@return string | [
"Replace",
"all",
"occurences",
"of",
"entity",
"URIs",
"in",
"text",
"by",
"the",
"generated",
"URLs",
"."
] | 4e1e54b979d72934a6fc0242aae3f12abebf41d0 | https://github.com/makinacorpus/drupal-ulink/blob/4e1e54b979d72934a6fc0242aae3f12abebf41d0/src/EntityLinkGenerator.php#L213-L268 | train |
PenoaksDev/Milky-Framework | src/Milky/Annotations/FileCacheReader.php | FileCacheReader.saveCacheFile | private function saveCacheFile($path, $data)
{
if (!is_writable($this->dir)) {
throw new \InvalidArgumentException(sprintf('The directory "%s" is not writable. Both, the webserver and the console user need access. You can manage access rights for multiple users with "chmod +a". If your system does not support this, check out the acl package.', $this->dir));
}
$tempfile = tempnam($this->dir, uniqid('', true));
if (false === $tempfile) {
throw new \RuntimeException(sprintf('Unable to create tempfile in directory: %s', $this->dir));
}
$written = file_put_contents($tempfile, '<?php return unserialize('.var_export(serialize($data), true).');');
if (false === $written) {
throw new \RuntimeException(sprintf('Unable to write cached file to: %s', $tempfile));
}
@chmod($tempfile, 0666 & (~$this->umask));
if (false === rename($tempfile, $path)) {
@unlink($tempfile);
throw new \RuntimeException(sprintf('Unable to rename %s to %s', $tempfile, $path));
}
} | php | private function saveCacheFile($path, $data)
{
if (!is_writable($this->dir)) {
throw new \InvalidArgumentException(sprintf('The directory "%s" is not writable. Both, the webserver and the console user need access. You can manage access rights for multiple users with "chmod +a". If your system does not support this, check out the acl package.', $this->dir));
}
$tempfile = tempnam($this->dir, uniqid('', true));
if (false === $tempfile) {
throw new \RuntimeException(sprintf('Unable to create tempfile in directory: %s', $this->dir));
}
$written = file_put_contents($tempfile, '<?php return unserialize('.var_export(serialize($data), true).');');
if (false === $written) {
throw new \RuntimeException(sprintf('Unable to write cached file to: %s', $tempfile));
}
@chmod($tempfile, 0666 & (~$this->umask));
if (false === rename($tempfile, $path)) {
@unlink($tempfile);
throw new \RuntimeException(sprintf('Unable to rename %s to %s', $tempfile, $path));
}
} | [
"private",
"function",
"saveCacheFile",
"(",
"$",
"path",
",",
"$",
"data",
")",
"{",
"if",
"(",
"!",
"is_writable",
"(",
"$",
"this",
"->",
"dir",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'The directory \"%s\" is not writable. Both, the webserver and the console user need access. You can manage access rights for multiple users with \"chmod +a\". If your system does not support this, check out the acl package.'",
",",
"$",
"this",
"->",
"dir",
")",
")",
";",
"}",
"$",
"tempfile",
"=",
"tempnam",
"(",
"$",
"this",
"->",
"dir",
",",
"uniqid",
"(",
"''",
",",
"true",
")",
")",
";",
"if",
"(",
"false",
"===",
"$",
"tempfile",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"'Unable to create tempfile in directory: %s'",
",",
"$",
"this",
"->",
"dir",
")",
")",
";",
"}",
"$",
"written",
"=",
"file_put_contents",
"(",
"$",
"tempfile",
",",
"'<?php return unserialize('",
".",
"var_export",
"(",
"serialize",
"(",
"$",
"data",
")",
",",
"true",
")",
".",
"');'",
")",
";",
"if",
"(",
"false",
"===",
"$",
"written",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"'Unable to write cached file to: %s'",
",",
"$",
"tempfile",
")",
")",
";",
"}",
"@",
"chmod",
"(",
"$",
"tempfile",
",",
"0666",
"&",
"(",
"~",
"$",
"this",
"->",
"umask",
")",
")",
";",
"if",
"(",
"false",
"===",
"rename",
"(",
"$",
"tempfile",
",",
"$",
"path",
")",
")",
"{",
"@",
"unlink",
"(",
"$",
"tempfile",
")",
";",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"'Unable to rename %s to %s'",
",",
"$",
"tempfile",
",",
"$",
"path",
")",
")",
";",
"}",
"}"
] | Saves the cache file.
@param string $path
@param mixed $data
@return void | [
"Saves",
"the",
"cache",
"file",
"."
] | 8afd7156610a70371aa5b1df50b8a212bf7b142c | https://github.com/PenoaksDev/Milky-Framework/blob/8afd7156610a70371aa5b1df50b8a212bf7b142c/src/Milky/Annotations/FileCacheReader.php#L186-L210 | train |
Revys/revy | src/App/RevyBase.php | RevyBase.getLanguage | public static function getLanguage()
{
if (! self::$language) {
self::$language = Language::findByCode(App::getLocale());
}
if (! self::$language) {
abort(404, 'Language could not be found');
}
return self::$language;
} | php | public static function getLanguage()
{
if (! self::$language) {
self::$language = Language::findByCode(App::getLocale());
}
if (! self::$language) {
abort(404, 'Language could not be found');
}
return self::$language;
} | [
"public",
"static",
"function",
"getLanguage",
"(",
")",
"{",
"if",
"(",
"!",
"self",
"::",
"$",
"language",
")",
"{",
"self",
"::",
"$",
"language",
"=",
"Language",
"::",
"findByCode",
"(",
"App",
"::",
"getLocale",
"(",
")",
")",
";",
"}",
"if",
"(",
"!",
"self",
"::",
"$",
"language",
")",
"{",
"abort",
"(",
"404",
",",
"'Language could not be found'",
")",
";",
"}",
"return",
"self",
"::",
"$",
"language",
";",
"}"
] | Get application Language instance
@return Language | [
"Get",
"application",
"Language",
"instance"
] | b2c13f5f7e88eec2681b4ec8a0385e18c28fbfd1 | https://github.com/Revys/revy/blob/b2c13f5f7e88eec2681b4ec8a0385e18c28fbfd1/src/App/RevyBase.php#L28-L39 | train |
Revys/revy | src/App/RevyBase.php | RevyBase.setLanguage | public static function setLanguage($language)
{
if (! ($language instanceof Language)) {
$language = Language::findByCode($language);
}
if (! $language) {
return false;
}
App::setLocale($language->code);
request()->setDefaultLocale($language->code);
self::$language = $language;
return $language;
} | php | public static function setLanguage($language)
{
if (! ($language instanceof Language)) {
$language = Language::findByCode($language);
}
if (! $language) {
return false;
}
App::setLocale($language->code);
request()->setDefaultLocale($language->code);
self::$language = $language;
return $language;
} | [
"public",
"static",
"function",
"setLanguage",
"(",
"$",
"language",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"language",
"instanceof",
"Language",
")",
")",
"{",
"$",
"language",
"=",
"Language",
"::",
"findByCode",
"(",
"$",
"language",
")",
";",
"}",
"if",
"(",
"!",
"$",
"language",
")",
"{",
"return",
"false",
";",
"}",
"App",
"::",
"setLocale",
"(",
"$",
"language",
"->",
"code",
")",
";",
"request",
"(",
")",
"->",
"setDefaultLocale",
"(",
"$",
"language",
"->",
"code",
")",
";",
"self",
"::",
"$",
"language",
"=",
"$",
"language",
";",
"return",
"$",
"language",
";",
"}"
] | Set application Language instance
@return Language | [
"Set",
"application",
"Language",
"instance"
] | b2c13f5f7e88eec2681b4ec8a0385e18c28fbfd1 | https://github.com/Revys/revy/blob/b2c13f5f7e88eec2681b4ec8a0385e18c28fbfd1/src/App/RevyBase.php#L45-L60 | train |
ciims/ciims-modules-dashboard | controllers/SettingsController.php | SettingsController.actionTheme | public function actionTheme()
{
$theme = Cii::getConfig('theme', 'default');
if (!file_exists(Yii::getPathOfAlias('base.themes.' . $theme) . DS . 'Theme.php'))
throw new CHttpException(400, Yii::t('Dashboard.main', 'The requested theme type is not set. Please set a theme before attempting to change theme settings'));
Yii::import('base.themes.' . $theme . '.Theme');
try {
$model = new Theme();
} catch(Exception $e) {
throw new CHttpException(400, Yii::t('Dashboard.main', 'The requested theme type is not set. Please set a theme before attempting to change theme settings'));
}
$this->render('settings', array(
'model' => $model
));
} | php | public function actionTheme()
{
$theme = Cii::getConfig('theme', 'default');
if (!file_exists(Yii::getPathOfAlias('base.themes.' . $theme) . DS . 'Theme.php'))
throw new CHttpException(400, Yii::t('Dashboard.main', 'The requested theme type is not set. Please set a theme before attempting to change theme settings'));
Yii::import('base.themes.' . $theme . '.Theme');
try {
$model = new Theme();
} catch(Exception $e) {
throw new CHttpException(400, Yii::t('Dashboard.main', 'The requested theme type is not set. Please set a theme before attempting to change theme settings'));
}
$this->render('settings', array(
'model' => $model
));
} | [
"public",
"function",
"actionTheme",
"(",
")",
"{",
"$",
"theme",
"=",
"Cii",
"::",
"getConfig",
"(",
"'theme'",
",",
"'default'",
")",
";",
"if",
"(",
"!",
"file_exists",
"(",
"Yii",
"::",
"getPathOfAlias",
"(",
"'base.themes.'",
".",
"$",
"theme",
")",
".",
"DS",
".",
"'Theme.php'",
")",
")",
"throw",
"new",
"CHttpException",
"(",
"400",
",",
"Yii",
"::",
"t",
"(",
"'Dashboard.main'",
",",
"'The requested theme type is not set. Please set a theme before attempting to change theme settings'",
")",
")",
";",
"Yii",
"::",
"import",
"(",
"'base.themes.'",
".",
"$",
"theme",
".",
"'.Theme'",
")",
";",
"try",
"{",
"$",
"model",
"=",
"new",
"Theme",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"CHttpException",
"(",
"400",
",",
"Yii",
"::",
"t",
"(",
"'Dashboard.main'",
",",
"'The requested theme type is not set. Please set a theme before attempting to change theme settings'",
")",
")",
";",
"}",
"$",
"this",
"->",
"render",
"(",
"'settings'",
",",
"array",
"(",
"'model'",
"=>",
"$",
"model",
")",
")",
";",
"}"
] | Provides control for Theme management
@param string $type The type we want to display | [
"Provides",
"control",
"for",
"Theme",
"management"
] | 94b89239e9ee34ac3b9c398e8d1ba67a08c68c11 | https://github.com/ciims/ciims-modules-dashboard/blob/94b89239e9ee34ac3b9c398e8d1ba67a08c68c11/controllers/SettingsController.php#L86-L104 | train |
atk14/ApiDataFetcher | src/api_data_fetcher.php | ApiDataFetcher.get | function get($action,$params = array(),$options = array()){
$options["method"] = "GET";
return $this->_doRequest($action,$params,$options);
} | php | function get($action,$params = array(),$options = array()){
$options["method"] = "GET";
return $this->_doRequest($action,$params,$options);
} | [
"function",
"get",
"(",
"$",
"action",
",",
"$",
"params",
"=",
"array",
"(",
")",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"options",
"[",
"\"method\"",
"]",
"=",
"\"GET\"",
";",
"return",
"$",
"this",
"->",
"_doRequest",
"(",
"$",
"action",
",",
"$",
"params",
",",
"$",
"options",
")",
";",
"}"
] | Performs HTTP GET call
$api_data_fetcher->get("articles/detail",array("id" => 123));
$api_data_fetcher->get("articles/index",array("offset" => 10));
$api_data_fetcher->get("articles",array("offset" => 10)); // stejne jako "articles/index"
$api_data_fetcher->get("articles/index",array("offset" => 10),array("cache" => 60)); | [
"Performs",
"HTTP",
"GET",
"call"
] | 6ccc6c819f8c4c2e1ab33cf4bf105ae18cb3acde | https://github.com/atk14/ApiDataFetcher/blob/6ccc6c819f8c4c2e1ab33cf4bf105ae18cb3acde/src/api_data_fetcher.php#L141-L144 | train |
atk14/ApiDataFetcher | src/api_data_fetcher.php | ApiDataFetcher.post | function post($action,$params = array(),$options = array()){
$options["method"] = "POST";
return $this->_doRequest($action,$params,$options);
} | php | function post($action,$params = array(),$options = array()){
$options["method"] = "POST";
return $this->_doRequest($action,$params,$options);
} | [
"function",
"post",
"(",
"$",
"action",
",",
"$",
"params",
"=",
"array",
"(",
")",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"options",
"[",
"\"method\"",
"]",
"=",
"\"POST\"",
";",
"return",
"$",
"this",
"->",
"_doRequest",
"(",
"$",
"action",
",",
"$",
"params",
",",
"$",
"options",
")",
";",
"}"
] | Performs HTTP POST call
$api_data_fetcher->post("articles/create_new",array(
"title" => "Very Nice Article"
)); | [
"Performs",
"HTTP",
"POST",
"call"
] | 6ccc6c819f8c4c2e1ab33cf4bf105ae18cb3acde | https://github.com/atk14/ApiDataFetcher/blob/6ccc6c819f8c4c2e1ab33cf4bf105ae18cb3acde/src/api_data_fetcher.php#L153-L156 | train |
atk14/ApiDataFetcher | src/api_data_fetcher.php | ApiDataFetcher.put | function put($action,$params = array(),$options = array()){
$options["method"] = "PUT";
return $this->_doRequest($action,$params,$options);
} | php | function put($action,$params = array(),$options = array()){
$options["method"] = "PUT";
return $this->_doRequest($action,$params,$options);
} | [
"function",
"put",
"(",
"$",
"action",
",",
"$",
"params",
"=",
"array",
"(",
")",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"options",
"[",
"\"method\"",
"]",
"=",
"\"PUT\"",
";",
"return",
"$",
"this",
"->",
"_doRequest",
"(",
"$",
"action",
",",
"$",
"params",
",",
"$",
"options",
")",
";",
"}"
] | Performs HTTP PUT call | [
"Performs",
"HTTP",
"PUT",
"call"
] | 6ccc6c819f8c4c2e1ab33cf4bf105ae18cb3acde | https://github.com/atk14/ApiDataFetcher/blob/6ccc6c819f8c4c2e1ab33cf4bf105ae18cb3acde/src/api_data_fetcher.php#L161-L164 | train |
atk14/ApiDataFetcher | src/api_data_fetcher.php | ApiDataFetcher.delete | function delete($action,$params = array(),$options = array()){
$options["method"] = "DELETE";
return $this->_doRequest($action,$params,$options);
} | php | function delete($action,$params = array(),$options = array()){
$options["method"] = "DELETE";
return $this->_doRequest($action,$params,$options);
} | [
"function",
"delete",
"(",
"$",
"action",
",",
"$",
"params",
"=",
"array",
"(",
")",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"options",
"[",
"\"method\"",
"]",
"=",
"\"DELETE\"",
";",
"return",
"$",
"this",
"->",
"_doRequest",
"(",
"$",
"action",
",",
"$",
"params",
",",
"$",
"options",
")",
";",
"}"
] | Performs HTTP DELETE call | [
"Performs",
"HTTP",
"DELETE",
"call"
] | 6ccc6c819f8c4c2e1ab33cf4bf105ae18cb3acde | https://github.com/atk14/ApiDataFetcher/blob/6ccc6c819f8c4c2e1ab33cf4bf105ae18cb3acde/src/api_data_fetcher.php#L169-L172 | train |
atk14/ApiDataFetcher | src/api_data_fetcher.php | ApiDataFetcher.postFile | function postFile($action,$file,$params = array(),$options = array()){
if(is_string($file)){
$file = array("path" => $file);
}
$file += array(
"path" => "", // "/path/to/file/photo.jpg"
"postname" => null, // "image"
"name" => null, // "photo.jpg"
"mime_type" => null, // "image/jpeg"
);
if(!$file["name"]){
$file["name"] = preg_replace('/^.*\//','',$file["path"]); // "/params/to/image.jpg" -> "image.jpg"
}
if(is_null($file["mime_type"])){
$file["mime_type"] = Files::DetermineFileType($file["path"]);
}
$options["method"] = "POST";
$options["file"] = $file;
return $this->_doRequest($action,$params,$options);
} | php | function postFile($action,$file,$params = array(),$options = array()){
if(is_string($file)){
$file = array("path" => $file);
}
$file += array(
"path" => "", // "/path/to/file/photo.jpg"
"postname" => null, // "image"
"name" => null, // "photo.jpg"
"mime_type" => null, // "image/jpeg"
);
if(!$file["name"]){
$file["name"] = preg_replace('/^.*\//','',$file["path"]); // "/params/to/image.jpg" -> "image.jpg"
}
if(is_null($file["mime_type"])){
$file["mime_type"] = Files::DetermineFileType($file["path"]);
}
$options["method"] = "POST";
$options["file"] = $file;
return $this->_doRequest($action,$params,$options);
} | [
"function",
"postFile",
"(",
"$",
"action",
",",
"$",
"file",
",",
"$",
"params",
"=",
"array",
"(",
")",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"file",
")",
")",
"{",
"$",
"file",
"=",
"array",
"(",
"\"path\"",
"=>",
"$",
"file",
")",
";",
"}",
"$",
"file",
"+=",
"array",
"(",
"\"path\"",
"=>",
"\"\"",
",",
"// \"/path/to/file/photo.jpg\"",
"\"postname\"",
"=>",
"null",
",",
"// \"image\"",
"\"name\"",
"=>",
"null",
",",
"// \"photo.jpg\"",
"\"mime_type\"",
"=>",
"null",
",",
"// \"image/jpeg\"",
")",
";",
"if",
"(",
"!",
"$",
"file",
"[",
"\"name\"",
"]",
")",
"{",
"$",
"file",
"[",
"\"name\"",
"]",
"=",
"preg_replace",
"(",
"'/^.*\\//'",
",",
"''",
",",
"$",
"file",
"[",
"\"path\"",
"]",
")",
";",
"// \"/params/to/image.jpg\" -> \"image.jpg\"",
"}",
"if",
"(",
"is_null",
"(",
"$",
"file",
"[",
"\"mime_type\"",
"]",
")",
")",
"{",
"$",
"file",
"[",
"\"mime_type\"",
"]",
"=",
"Files",
"::",
"DetermineFileType",
"(",
"$",
"file",
"[",
"\"path\"",
"]",
")",
";",
"}",
"$",
"options",
"[",
"\"method\"",
"]",
"=",
"\"POST\"",
";",
"$",
"options",
"[",
"\"file\"",
"]",
"=",
"$",
"file",
";",
"return",
"$",
"this",
"->",
"_doRequest",
"(",
"$",
"action",
",",
"$",
"params",
",",
"$",
"options",
")",
";",
"}"
] | Sends a single file into the specific action
$api_data_fetcher->postFile("images/create_new","/path/to/file.jpg");
$api_data_fetcher->postFile(
"images/create_new", // action name
array("path" => "/path/to/file.jpg", "name" => "earth.jpg", "mime_type" => "image/jpeg"), // file definition
array("title" => "Image of Earth", "description" => "...") // other parameters
);
$api_data_fetcher->postFile("images/create_new","/path/to/file.jpg",array("title" => "Image of Earth", "description" => "...")); | [
"Sends",
"a",
"single",
"file",
"into",
"the",
"specific",
"action"
] | 6ccc6c819f8c4c2e1ab33cf4bf105ae18cb3acde | https://github.com/atk14/ApiDataFetcher/blob/6ccc6c819f8c4c2e1ab33cf4bf105ae18cb3acde/src/api_data_fetcher.php#L187-L211 | train |
atk14/ApiDataFetcher | src/api_data_fetcher.php | ApiDataFetcher.postRawData | function postRawData($action,$content,$params = array(),$options = array()){
$options += array(
"mime_type" => "application/data"
);
$options["method"] = "POST";
$options["raw_post_data"] = $content;
return $this->_doRequest($action,$params,$options);
} | php | function postRawData($action,$content,$params = array(),$options = array()){
$options += array(
"mime_type" => "application/data"
);
$options["method"] = "POST";
$options["raw_post_data"] = $content;
return $this->_doRequest($action,$params,$options);
} | [
"function",
"postRawData",
"(",
"$",
"action",
",",
"$",
"content",
",",
"$",
"params",
"=",
"array",
"(",
")",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"options",
"+=",
"array",
"(",
"\"mime_type\"",
"=>",
"\"application/data\"",
")",
";",
"$",
"options",
"[",
"\"method\"",
"]",
"=",
"\"POST\"",
";",
"$",
"options",
"[",
"\"raw_post_data\"",
"]",
"=",
"$",
"content",
";",
"return",
"$",
"this",
"->",
"_doRequest",
"(",
"$",
"action",
",",
"$",
"params",
",",
"$",
"options",
")",
";",
"}"
] | Sends raw data to the specific action
$raw_data = json_encode($data);
$api_data_fetcher->postRawData("articles/edit",$raw_data,array("id" => 123),array("mime_type" => "application/json")); | [
"Sends",
"raw",
"data",
"to",
"the",
"specific",
"action"
] | 6ccc6c819f8c4c2e1ab33cf4bf105ae18cb3acde | https://github.com/atk14/ApiDataFetcher/blob/6ccc6c819f8c4c2e1ab33cf4bf105ae18cb3acde/src/api_data_fetcher.php#L219-L228 | train |
atk14/ApiDataFetcher | src/api_data_fetcher.php | ApiDataFetcher.postJson | function postJson($action,$json,$options = array()){
if(!is_string($json)){
$json = json_encode($json);
}
$options += array(
"mime_type" => "application/json",
"params" => array(),
);
$params = $options["params"];
unset($options["params"]);
return $this->postRawData($action,$json,$params,$options);
} | php | function postJson($action,$json,$options = array()){
if(!is_string($json)){
$json = json_encode($json);
}
$options += array(
"mime_type" => "application/json",
"params" => array(),
);
$params = $options["params"];
unset($options["params"]);
return $this->postRawData($action,$json,$params,$options);
} | [
"function",
"postJson",
"(",
"$",
"action",
",",
"$",
"json",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"json",
")",
")",
"{",
"$",
"json",
"=",
"json_encode",
"(",
"$",
"json",
")",
";",
"}",
"$",
"options",
"+=",
"array",
"(",
"\"mime_type\"",
"=>",
"\"application/json\"",
",",
"\"params\"",
"=>",
"array",
"(",
")",
",",
")",
";",
"$",
"params",
"=",
"$",
"options",
"[",
"\"params\"",
"]",
";",
"unset",
"(",
"$",
"options",
"[",
"\"params\"",
"]",
")",
";",
"return",
"$",
"this",
"->",
"postRawData",
"(",
"$",
"action",
",",
"$",
"json",
",",
"$",
"params",
",",
"$",
"options",
")",
";",
"}"
] | Sends JSON to the specific action
$api_data_fetcher->postJson('action','{"a":"b","c":"d"}');
// array will be automatically encoded into a JSON
$api_data_fetcher->postJson('action',["a" => "b", "c" => "d"]);
// URL params can be a part of the action
$api_data_fetcher->postJson('action/?url_param=value',["a" => "b", "c" => "d"]);
// or passed in option
$api_data_fetcher->postJson('action',["a" => "b", "c" => "d"],["params" => ["url_param" => "value"]]); | [
"Sends",
"JSON",
"to",
"the",
"specific",
"action"
] | 6ccc6c819f8c4c2e1ab33cf4bf105ae18cb3acde | https://github.com/atk14/ApiDataFetcher/blob/6ccc6c819f8c4c2e1ab33cf4bf105ae18cb3acde/src/api_data_fetcher.php#L243-L254 | train |
ScaraMVC/Framework | src/Scara/Config/Configuration.php | Configuration.get | public function get($key, $configFile = '')
{
$config = $this->load((empty($configFile)) ? $this->_configFile : $configFile);
return $this->sift($config, explode('.', $key));
} | php | public function get($key, $configFile = '')
{
$config = $this->load((empty($configFile)) ? $this->_configFile : $configFile);
return $this->sift($config, explode('.', $key));
} | [
"public",
"function",
"get",
"(",
"$",
"key",
",",
"$",
"configFile",
"=",
"''",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"load",
"(",
"(",
"empty",
"(",
"$",
"configFile",
")",
")",
"?",
"$",
"this",
"->",
"_configFile",
":",
"$",
"configFile",
")",
";",
"return",
"$",
"this",
"->",
"sift",
"(",
"$",
"config",
",",
"explode",
"(",
"'.'",
",",
"$",
"key",
")",
")",
";",
"}"
] | Gets the config value.
@param string $key - The config item's key
@param string $configFile - Optional if you want to load a specific config file
@return mixed | [
"Gets",
"the",
"config",
"value",
"."
] | 199b08b45fadf5dae14ac4732af03b36e15bbef2 | https://github.com/ScaraMVC/Framework/blob/199b08b45fadf5dae14ac4732af03b36e15bbef2/src/Scara/Config/Configuration.php#L39-L44 | train |
ScaraMVC/Framework | src/Scara/Config/Configuration.php | Configuration.load | private function load($file, $dir = '')
{
$path = config_path().'/'.$dir;
$handle = opendir($path);
$ignore = ['.', '..'];
while ($f = readdir($handle)) {
if (!in_array($f, $ignore)) {
if (is_dir($path.$f)) {
if (file_exists($path.$f.'/'.$file.'.php')) {
return $this->load($file, $f);
}
} else {
$filename = explode('.', $f)[0];
if ($filename == $file) {
return require $path.'/'.$f;
}
}
}
}
closedir($handle);
return false;
} | php | private function load($file, $dir = '')
{
$path = config_path().'/'.$dir;
$handle = opendir($path);
$ignore = ['.', '..'];
while ($f = readdir($handle)) {
if (!in_array($f, $ignore)) {
if (is_dir($path.$f)) {
if (file_exists($path.$f.'/'.$file.'.php')) {
return $this->load($file, $f);
}
} else {
$filename = explode('.', $f)[0];
if ($filename == $file) {
return require $path.'/'.$f;
}
}
}
}
closedir($handle);
return false;
} | [
"private",
"function",
"load",
"(",
"$",
"file",
",",
"$",
"dir",
"=",
"''",
")",
"{",
"$",
"path",
"=",
"config_path",
"(",
")",
".",
"'/'",
".",
"$",
"dir",
";",
"$",
"handle",
"=",
"opendir",
"(",
"$",
"path",
")",
";",
"$",
"ignore",
"=",
"[",
"'.'",
",",
"'..'",
"]",
";",
"while",
"(",
"$",
"f",
"=",
"readdir",
"(",
"$",
"handle",
")",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"f",
",",
"$",
"ignore",
")",
")",
"{",
"if",
"(",
"is_dir",
"(",
"$",
"path",
".",
"$",
"f",
")",
")",
"{",
"if",
"(",
"file_exists",
"(",
"$",
"path",
".",
"$",
"f",
".",
"'/'",
".",
"$",
"file",
".",
"'.php'",
")",
")",
"{",
"return",
"$",
"this",
"->",
"load",
"(",
"$",
"file",
",",
"$",
"f",
")",
";",
"}",
"}",
"else",
"{",
"$",
"filename",
"=",
"explode",
"(",
"'.'",
",",
"$",
"f",
")",
"[",
"0",
"]",
";",
"if",
"(",
"$",
"filename",
"==",
"$",
"file",
")",
"{",
"return",
"require",
"$",
"path",
".",
"'/'",
".",
"$",
"f",
";",
"}",
"}",
"}",
"}",
"closedir",
"(",
"$",
"handle",
")",
";",
"return",
"false",
";",
"}"
] | Loads a configuration script.
@param string $file - The name of the config file to load
@param string $dir - The sub directory to load into
@return mixed | [
"Loads",
"a",
"configuration",
"script",
"."
] | 199b08b45fadf5dae14ac4732af03b36e15bbef2 | https://github.com/ScaraMVC/Framework/blob/199b08b45fadf5dae14ac4732af03b36e15bbef2/src/Scara/Config/Configuration.php#L54-L76 | train |
Polosa/shade-framework-core | app/ControllerDispatcher.php | ControllerDispatcher.bindService | public function bindService($controllerName, $methodName, $argumentName, $serviceName)
{
$this->bindings[$controllerName][$methodName][$argumentName] = $serviceName;
return $this;
} | php | public function bindService($controllerName, $methodName, $argumentName, $serviceName)
{
$this->bindings[$controllerName][$methodName][$argumentName] = $serviceName;
return $this;
} | [
"public",
"function",
"bindService",
"(",
"$",
"controllerName",
",",
"$",
"methodName",
",",
"$",
"argumentName",
",",
"$",
"serviceName",
")",
"{",
"$",
"this",
"->",
"bindings",
"[",
"$",
"controllerName",
"]",
"[",
"$",
"methodName",
"]",
"[",
"$",
"argumentName",
"]",
"=",
"$",
"serviceName",
";",
"return",
"$",
"this",
";",
"}"
] | Bind Service to method argument
@param string $controllerName Controller class name
@param string $methodName Method name
@param string $argumentName Argument name
@param string $serviceName Registered Service name
@return ControllerDispatcher | [
"Bind",
"Service",
"to",
"method",
"argument"
] | d735d3e8e0616fb9cf4ffc25b8425762ed07940f | https://github.com/Polosa/shade-framework-core/blob/d735d3e8e0616fb9cf4ffc25b8425762ed07940f/app/ControllerDispatcher.php#L172-L176 | train |
Polosa/shade-framework-core | app/ControllerDispatcher.php | ControllerDispatcher.setArgumentValue | public function setArgumentValue($controllerName, $methodName, $argumentName, $value)
{
$this->argumentBindings[$controllerName][$methodName][$argumentName] = $value;
return $this;
} | php | public function setArgumentValue($controllerName, $methodName, $argumentName, $value)
{
$this->argumentBindings[$controllerName][$methodName][$argumentName] = $value;
return $this;
} | [
"public",
"function",
"setArgumentValue",
"(",
"$",
"controllerName",
",",
"$",
"methodName",
",",
"$",
"argumentName",
",",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"argumentBindings",
"[",
"$",
"controllerName",
"]",
"[",
"$",
"methodName",
"]",
"[",
"$",
"argumentName",
"]",
"=",
"$",
"value",
";",
"return",
"$",
"this",
";",
"}"
] | Set value of method argument
@param string $controllerName Controller class name
@param string $methodName Method name
@param string $argumentName Argument name
@param string $value Value
@return ControllerDispatcher | [
"Set",
"value",
"of",
"method",
"argument"
] | d735d3e8e0616fb9cf4ffc25b8425762ed07940f | https://github.com/Polosa/shade-framework-core/blob/d735d3e8e0616fb9cf4ffc25b8425762ed07940f/app/ControllerDispatcher.php#L188-L192 | train |
Polosa/shade-framework-core | app/ControllerDispatcher.php | ControllerDispatcher.getMethodArguments | protected function getMethodArguments($controllerClass, $methodName)
{
$actionArguments = array();
$reflectionAction = new \ReflectionMethod($controllerClass, $methodName);
$actionParametersReflections = $reflectionAction->getParameters();
foreach ($actionParametersReflections as $actionParameterReflection) {
$parameterName = $actionParameterReflection->getName();
if (
!empty($this->bindings[$controllerClass][$methodName])
&& array_key_exists($parameterName, $this->bindings[$controllerClass][$methodName])
) {
$parameterValue = $this->serviceContainer->getService($this->bindings[$controllerClass][$methodName][$parameterName]);
$actionArguments[$parameterName] = $parameterValue;
} elseif (
!empty($this->argumentBindings[$controllerClass][$methodName])
&& array_key_exists($parameterName, $this->argumentBindings[$controllerClass][$methodName])
) {
$actionArguments[$parameterName] = $this->argumentBindings[$controllerClass][$methodName][$parameterName];
} elseif ($actionParameterReflection->isOptional()) {
$actionArguments[$parameterName] = $actionParameterReflection->getDefaultValue();
} else {
throw new Exception("No value provided for parameter '{$parameterName}' of '{$controllerClass}::{$methodName}'");
}
}
return $actionArguments;
} | php | protected function getMethodArguments($controllerClass, $methodName)
{
$actionArguments = array();
$reflectionAction = new \ReflectionMethod($controllerClass, $methodName);
$actionParametersReflections = $reflectionAction->getParameters();
foreach ($actionParametersReflections as $actionParameterReflection) {
$parameterName = $actionParameterReflection->getName();
if (
!empty($this->bindings[$controllerClass][$methodName])
&& array_key_exists($parameterName, $this->bindings[$controllerClass][$methodName])
) {
$parameterValue = $this->serviceContainer->getService($this->bindings[$controllerClass][$methodName][$parameterName]);
$actionArguments[$parameterName] = $parameterValue;
} elseif (
!empty($this->argumentBindings[$controllerClass][$methodName])
&& array_key_exists($parameterName, $this->argumentBindings[$controllerClass][$methodName])
) {
$actionArguments[$parameterName] = $this->argumentBindings[$controllerClass][$methodName][$parameterName];
} elseif ($actionParameterReflection->isOptional()) {
$actionArguments[$parameterName] = $actionParameterReflection->getDefaultValue();
} else {
throw new Exception("No value provided for parameter '{$parameterName}' of '{$controllerClass}::{$methodName}'");
}
}
return $actionArguments;
} | [
"protected",
"function",
"getMethodArguments",
"(",
"$",
"controllerClass",
",",
"$",
"methodName",
")",
"{",
"$",
"actionArguments",
"=",
"array",
"(",
")",
";",
"$",
"reflectionAction",
"=",
"new",
"\\",
"ReflectionMethod",
"(",
"$",
"controllerClass",
",",
"$",
"methodName",
")",
";",
"$",
"actionParametersReflections",
"=",
"$",
"reflectionAction",
"->",
"getParameters",
"(",
")",
";",
"foreach",
"(",
"$",
"actionParametersReflections",
"as",
"$",
"actionParameterReflection",
")",
"{",
"$",
"parameterName",
"=",
"$",
"actionParameterReflection",
"->",
"getName",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"bindings",
"[",
"$",
"controllerClass",
"]",
"[",
"$",
"methodName",
"]",
")",
"&&",
"array_key_exists",
"(",
"$",
"parameterName",
",",
"$",
"this",
"->",
"bindings",
"[",
"$",
"controllerClass",
"]",
"[",
"$",
"methodName",
"]",
")",
")",
"{",
"$",
"parameterValue",
"=",
"$",
"this",
"->",
"serviceContainer",
"->",
"getService",
"(",
"$",
"this",
"->",
"bindings",
"[",
"$",
"controllerClass",
"]",
"[",
"$",
"methodName",
"]",
"[",
"$",
"parameterName",
"]",
")",
";",
"$",
"actionArguments",
"[",
"$",
"parameterName",
"]",
"=",
"$",
"parameterValue",
";",
"}",
"elseif",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"argumentBindings",
"[",
"$",
"controllerClass",
"]",
"[",
"$",
"methodName",
"]",
")",
"&&",
"array_key_exists",
"(",
"$",
"parameterName",
",",
"$",
"this",
"->",
"argumentBindings",
"[",
"$",
"controllerClass",
"]",
"[",
"$",
"methodName",
"]",
")",
")",
"{",
"$",
"actionArguments",
"[",
"$",
"parameterName",
"]",
"=",
"$",
"this",
"->",
"argumentBindings",
"[",
"$",
"controllerClass",
"]",
"[",
"$",
"methodName",
"]",
"[",
"$",
"parameterName",
"]",
";",
"}",
"elseif",
"(",
"$",
"actionParameterReflection",
"->",
"isOptional",
"(",
")",
")",
"{",
"$",
"actionArguments",
"[",
"$",
"parameterName",
"]",
"=",
"$",
"actionParameterReflection",
"->",
"getDefaultValue",
"(",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"Exception",
"(",
"\"No value provided for parameter '{$parameterName}' of '{$controllerClass}::{$methodName}'\"",
")",
";",
"}",
"}",
"return",
"$",
"actionArguments",
";",
"}"
] | Get arguments of Controller's Action or constructor
@param string $controllerClass Controller class name
@param string $methodName Method name
@throws Exception
@return array | [
"Get",
"arguments",
"of",
"Controller",
"s",
"Action",
"or",
"constructor"
] | d735d3e8e0616fb9cf4ffc25b8425762ed07940f | https://github.com/Polosa/shade-framework-core/blob/d735d3e8e0616fb9cf4ffc25b8425762ed07940f/app/ControllerDispatcher.php#L222-L248 | train |
eltrino/PHPUnit_MockAnnotations | src/Eltrino/PHPUnit/MockAnnotations/MockPropertyAnnotationProcessor.php | MockPropertyAnnotationProcessor.process | public function process(\ReflectionProperty $property, TestCase $test)
{
/** @var \ReflectionProperty $property */
$propertyDocComment = $property->getDocComment();
if (preg_match(self::REGEX_MOCK, $propertyDocComment, $matches)) {
$isPrivate = $property->isPrivate();
if ($isPrivate) {
$property->setAccessible(true);
}
$mock = $this->mockObjectFactory->create($matches[1]);
$property->setValue($test, $mock);
if ($isPrivate) {
$property->setAccessible(false);
}
}
} | php | public function process(\ReflectionProperty $property, TestCase $test)
{
/** @var \ReflectionProperty $property */
$propertyDocComment = $property->getDocComment();
if (preg_match(self::REGEX_MOCK, $propertyDocComment, $matches)) {
$isPrivate = $property->isPrivate();
if ($isPrivate) {
$property->setAccessible(true);
}
$mock = $this->mockObjectFactory->create($matches[1]);
$property->setValue($test, $mock);
if ($isPrivate) {
$property->setAccessible(false);
}
}
} | [
"public",
"function",
"process",
"(",
"\\",
"ReflectionProperty",
"$",
"property",
",",
"TestCase",
"$",
"test",
")",
"{",
"/** @var \\ReflectionProperty $property */",
"$",
"propertyDocComment",
"=",
"$",
"property",
"->",
"getDocComment",
"(",
")",
";",
"if",
"(",
"preg_match",
"(",
"self",
"::",
"REGEX_MOCK",
",",
"$",
"propertyDocComment",
",",
"$",
"matches",
")",
")",
"{",
"$",
"isPrivate",
"=",
"$",
"property",
"->",
"isPrivate",
"(",
")",
";",
"if",
"(",
"$",
"isPrivate",
")",
"{",
"$",
"property",
"->",
"setAccessible",
"(",
"true",
")",
";",
"}",
"$",
"mock",
"=",
"$",
"this",
"->",
"mockObjectFactory",
"->",
"create",
"(",
"$",
"matches",
"[",
"1",
"]",
")",
";",
"$",
"property",
"->",
"setValue",
"(",
"$",
"test",
",",
"$",
"mock",
")",
";",
"if",
"(",
"$",
"isPrivate",
")",
"{",
"$",
"property",
"->",
"setAccessible",
"(",
"false",
")",
";",
"}",
"}",
"}"
] | Property processing
Generate and assign mock object to property if it has @Mock annoitation
@param \ReflectionProperty $property
@param TestCase $test
@return void | [
"Property",
"processing",
"Generate",
"and",
"assign",
"mock",
"object",
"to",
"property",
"if",
"it",
"has"
] | 1a06ed59ea0702359848fc01e958f4f92abb503a | https://github.com/eltrino/PHPUnit_MockAnnotations/blob/1a06ed59ea0702359848fc01e958f4f92abb503a/src/Eltrino/PHPUnit/MockAnnotations/MockPropertyAnnotationProcessor.php#L28-L43 | train |
ARCANESOFT/Media | src/Seeds/PermissionsTableSeeder.php | PermissionsTableSeeder.getMediasPermissions | private function getMediasPermissions()
{
return [
[
'name' => 'Medias - List all medias',
'description' => 'Allow to list all the medias.',
'slug' => MediasPolicy::PERMISSION_LIST,
],
[
'name' => 'Medias - View a media',
'description' => 'Allow to display a media.',
'slug' => MediasPolicy::PERMISSION_SHOW,
],
[
'name' => 'Medias - Download a media',
'description' => 'Allow to download a media.',
'slug' => MediasPolicy::PERMISSION_CREATE,
],
[
'name' => 'Medias - Update a media',
'description' => 'Allow to update a media.',
'slug' => MediasPolicy::PERMISSION_UPDATE,
],
[
'name' => 'Medias - Delete a media',
'description' => 'Allow to delete a media.',
'slug' => MediasPolicy::PERMISSION_DELETE,
],
];
} | php | private function getMediasPermissions()
{
return [
[
'name' => 'Medias - List all medias',
'description' => 'Allow to list all the medias.',
'slug' => MediasPolicy::PERMISSION_LIST,
],
[
'name' => 'Medias - View a media',
'description' => 'Allow to display a media.',
'slug' => MediasPolicy::PERMISSION_SHOW,
],
[
'name' => 'Medias - Download a media',
'description' => 'Allow to download a media.',
'slug' => MediasPolicy::PERMISSION_CREATE,
],
[
'name' => 'Medias - Update a media',
'description' => 'Allow to update a media.',
'slug' => MediasPolicy::PERMISSION_UPDATE,
],
[
'name' => 'Medias - Delete a media',
'description' => 'Allow to delete a media.',
'slug' => MediasPolicy::PERMISSION_DELETE,
],
];
} | [
"private",
"function",
"getMediasPermissions",
"(",
")",
"{",
"return",
"[",
"[",
"'name'",
"=>",
"'Medias - List all medias'",
",",
"'description'",
"=>",
"'Allow to list all the medias.'",
",",
"'slug'",
"=>",
"MediasPolicy",
"::",
"PERMISSION_LIST",
",",
"]",
",",
"[",
"'name'",
"=>",
"'Medias - View a media'",
",",
"'description'",
"=>",
"'Allow to display a media.'",
",",
"'slug'",
"=>",
"MediasPolicy",
"::",
"PERMISSION_SHOW",
",",
"]",
",",
"[",
"'name'",
"=>",
"'Medias - Download a media'",
",",
"'description'",
"=>",
"'Allow to download a media.'",
",",
"'slug'",
"=>",
"MediasPolicy",
"::",
"PERMISSION_CREATE",
",",
"]",
",",
"[",
"'name'",
"=>",
"'Medias - Update a media'",
",",
"'description'",
"=>",
"'Allow to update a media.'",
",",
"'slug'",
"=>",
"MediasPolicy",
"::",
"PERMISSION_UPDATE",
",",
"]",
",",
"[",
"'name'",
"=>",
"'Medias - Delete a media'",
",",
"'description'",
"=>",
"'Allow to delete a media.'",
",",
"'slug'",
"=>",
"MediasPolicy",
"::",
"PERMISSION_DELETE",
",",
"]",
",",
"]",
";",
"}"
] | Get the Medias permissions.
@return array | [
"Get",
"the",
"Medias",
"permissions",
"."
] | e98aad52f94e6587fcbf79c56f7bf7072929bfc9 | https://github.com/ARCANESOFT/Media/blob/e98aad52f94e6587fcbf79c56f7bf7072929bfc9/src/Seeds/PermissionsTableSeeder.php#L48-L77 | train |
donatj/mddom | src/AbstractElement.php | AbstractElement.exportMarkdown | public function exportMarkdown( $fragmentLevel = 0 ) {
$output = "";
if( $this instanceof BlockElementInterface || $this->getPreviousSibling() instanceof BlockElementInterface ) {
$output .= "\n\n";
}
$output .= ltrim($this->generateMarkdown($fragmentLevel), "\n");
return $output;
} | php | public function exportMarkdown( $fragmentLevel = 0 ) {
$output = "";
if( $this instanceof BlockElementInterface || $this->getPreviousSibling() instanceof BlockElementInterface ) {
$output .= "\n\n";
}
$output .= ltrim($this->generateMarkdown($fragmentLevel), "\n");
return $output;
} | [
"public",
"function",
"exportMarkdown",
"(",
"$",
"fragmentLevel",
"=",
"0",
")",
"{",
"$",
"output",
"=",
"\"\"",
";",
"if",
"(",
"$",
"this",
"instanceof",
"BlockElementInterface",
"||",
"$",
"this",
"->",
"getPreviousSibling",
"(",
")",
"instanceof",
"BlockElementInterface",
")",
"{",
"$",
"output",
".=",
"\"\\n\\n\"",
";",
"}",
"$",
"output",
".=",
"ltrim",
"(",
"$",
"this",
"->",
"generateMarkdown",
"(",
"$",
"fragmentLevel",
")",
",",
"\"\\n\"",
")",
";",
"return",
"$",
"output",
";",
"}"
] | Convert the DOM to Markdown
@param int $fragmentLevel Private use - recursion depth counter
@return string Markdown | [
"Convert",
"the",
"DOM",
"to",
"Markdown"
] | c6b66a4f5dfeaec9aeefe07c05d667d5bac70f8d | https://github.com/donatj/mddom/blob/c6b66a4f5dfeaec9aeefe07c05d667d5bac70f8d/src/AbstractElement.php#L17-L26 | train |
hiqdev/minii-console | src/Application.php | Application.handleRequest | public function handleRequest($request)
{
list ($route, $params) = $request->resolve();
$this->requestedRoute = $route;
$result = $this->runAction($route, $params);
if ($result instanceof Response) {
return $result;
} else {
$response = $this->getResponse();
$response->exitStatus = $result;
return $response;
}
} | php | public function handleRequest($request)
{
list ($route, $params) = $request->resolve();
$this->requestedRoute = $route;
$result = $this->runAction($route, $params);
if ($result instanceof Response) {
return $result;
} else {
$response = $this->getResponse();
$response->exitStatus = $result;
return $response;
}
} | [
"public",
"function",
"handleRequest",
"(",
"$",
"request",
")",
"{",
"list",
"(",
"$",
"route",
",",
"$",
"params",
")",
"=",
"$",
"request",
"->",
"resolve",
"(",
")",
";",
"$",
"this",
"->",
"requestedRoute",
"=",
"$",
"route",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"runAction",
"(",
"$",
"route",
",",
"$",
"params",
")",
";",
"if",
"(",
"$",
"result",
"instanceof",
"Response",
")",
"{",
"return",
"$",
"result",
";",
"}",
"else",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"getResponse",
"(",
")",
";",
"$",
"response",
"->",
"exitStatus",
"=",
"$",
"result",
";",
"return",
"$",
"response",
";",
"}",
"}"
] | Handles the specified request.
@param Request $request the request to be handled
@return Response the resulting response | [
"Handles",
"the",
"specified",
"request",
"."
] | 1da3c1a3b53588265c35330fc161b07665ab14d9 | https://github.com/hiqdev/minii-console/blob/1da3c1a3b53588265c35330fc161b07665ab14d9/src/Application.php#L139-L152 | train |
kambalabs/KmbPuppet | src/KmbPuppet/Service/Group.php | Group.getAllByNode | public function getAllByNode(PuppetDbModel\NodeInterface $node)
{
$environment = $this->environmentService->getByNode($node);
$revision = $environment->getCurrentRevision();
$groups[$environment->getNormalizedName()] = $revision->getGroupsMatchingHostname($node->getName());
while ($environment->hasParent()) {
$parent = $environment->getParent();
$groups[$parent->getNormalizedName()] = $parent->getCurrentRevision()->getGroupsMatchingHostname($node->getName());
$environment = $parent;
}
return $groups;
} | php | public function getAllByNode(PuppetDbModel\NodeInterface $node)
{
$environment = $this->environmentService->getByNode($node);
$revision = $environment->getCurrentRevision();
$groups[$environment->getNormalizedName()] = $revision->getGroupsMatchingHostname($node->getName());
while ($environment->hasParent()) {
$parent = $environment->getParent();
$groups[$parent->getNormalizedName()] = $parent->getCurrentRevision()->getGroupsMatchingHostname($node->getName());
$environment = $parent;
}
return $groups;
} | [
"public",
"function",
"getAllByNode",
"(",
"PuppetDbModel",
"\\",
"NodeInterface",
"$",
"node",
")",
"{",
"$",
"environment",
"=",
"$",
"this",
"->",
"environmentService",
"->",
"getByNode",
"(",
"$",
"node",
")",
";",
"$",
"revision",
"=",
"$",
"environment",
"->",
"getCurrentRevision",
"(",
")",
";",
"$",
"groups",
"[",
"$",
"environment",
"->",
"getNormalizedName",
"(",
")",
"]",
"=",
"$",
"revision",
"->",
"getGroupsMatchingHostname",
"(",
"$",
"node",
"->",
"getName",
"(",
")",
")",
";",
"while",
"(",
"$",
"environment",
"->",
"hasParent",
"(",
")",
")",
"{",
"$",
"parent",
"=",
"$",
"environment",
"->",
"getParent",
"(",
")",
";",
"$",
"groups",
"[",
"$",
"parent",
"->",
"getNormalizedName",
"(",
")",
"]",
"=",
"$",
"parent",
"->",
"getCurrentRevision",
"(",
")",
"->",
"getGroupsMatchingHostname",
"(",
"$",
"node",
"->",
"getName",
"(",
")",
")",
";",
"$",
"environment",
"=",
"$",
"parent",
";",
"}",
"return",
"$",
"groups",
";",
"}"
] | Get all groups assigned to specified node group by environment name.
@param PuppetDbModel\NodeInterface $node
@return \KmbDomain\Model\GroupInterface[] | [
"Get",
"all",
"groups",
"assigned",
"to",
"specified",
"node",
"group",
"by",
"environment",
"name",
"."
] | b97a0d2077085df4933c6b3cda9e41468bf7ffca | https://github.com/kambalabs/KmbPuppet/blob/b97a0d2077085df4933c6b3cda9e41468bf7ffca/src/KmbPuppet/Service/Group.php#L36-L47 | train |
squareproton/Bond | src/Bond/Di/ContainerFromAnnotations.php | ContainerFromAnnotations.getResources | private function getResources()
{
$resources = [];
foreach( $this->getClassAnnotations() as $annotation ) {
// is this a resource
if( 0 === strpos($annotation, "resource") ) {
$resources[] = explode(' ', $annotation)[1];
}
}
return $resources;
} | php | private function getResources()
{
$resources = [];
foreach( $this->getClassAnnotations() as $annotation ) {
// is this a resource
if( 0 === strpos($annotation, "resource") ) {
$resources[] = explode(' ', $annotation)[1];
}
}
return $resources;
} | [
"private",
"function",
"getResources",
"(",
")",
"{",
"$",
"resources",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"getClassAnnotations",
"(",
")",
"as",
"$",
"annotation",
")",
"{",
"// is this a resource",
"if",
"(",
"0",
"===",
"strpos",
"(",
"$",
"annotation",
",",
"\"resource\"",
")",
")",
"{",
"$",
"resources",
"[",
"]",
"=",
"explode",
"(",
"' '",
",",
"$",
"annotation",
")",
"[",
"1",
"]",
";",
"}",
"}",
"return",
"$",
"resources",
";",
"}"
] | list of files to load as configuration.
should be set to empty list if none needed | [
"list",
"of",
"files",
"to",
"load",
"as",
"configuration",
".",
"should",
"be",
"set",
"to",
"empty",
"list",
"if",
"none",
"needed"
] | a04ad9dd1a35adeaec98237716c2a41ce02b4f1a | https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Di/ContainerFromAnnotations.php#L57-L72 | train |
jenskooij/cloudcontrol | src/storage/storage/ImagesStorage.php | ImagesStorage.deleteImageByName | public function deleteImageByName($filename)
{
$destinationPath = $this->getDestinationPath();
$images = $this->getImages();
foreach ($images as $key => $image) {
if ($image->file == $filename) {
foreach ($image->set as $imageSetFilename) {
$destination = $destinationPath . '/' . $imageSetFilename;
if (file_exists($destination)) {
unlink($destination);
}
}
unset($images[$key]);
}
}
$images = array_values($images);
$this->repository->images = $images;
$this->save();
} | php | public function deleteImageByName($filename)
{
$destinationPath = $this->getDestinationPath();
$images = $this->getImages();
foreach ($images as $key => $image) {
if ($image->file == $filename) {
foreach ($image->set as $imageSetFilename) {
$destination = $destinationPath . '/' . $imageSetFilename;
if (file_exists($destination)) {
unlink($destination);
}
}
unset($images[$key]);
}
}
$images = array_values($images);
$this->repository->images = $images;
$this->save();
} | [
"public",
"function",
"deleteImageByName",
"(",
"$",
"filename",
")",
"{",
"$",
"destinationPath",
"=",
"$",
"this",
"->",
"getDestinationPath",
"(",
")",
";",
"$",
"images",
"=",
"$",
"this",
"->",
"getImages",
"(",
")",
";",
"foreach",
"(",
"$",
"images",
"as",
"$",
"key",
"=>",
"$",
"image",
")",
"{",
"if",
"(",
"$",
"image",
"->",
"file",
"==",
"$",
"filename",
")",
"{",
"foreach",
"(",
"$",
"image",
"->",
"set",
"as",
"$",
"imageSetFilename",
")",
"{",
"$",
"destination",
"=",
"$",
"destinationPath",
".",
"'/'",
".",
"$",
"imageSetFilename",
";",
"if",
"(",
"file_exists",
"(",
"$",
"destination",
")",
")",
"{",
"unlink",
"(",
"$",
"destination",
")",
";",
"}",
"}",
"unset",
"(",
"$",
"images",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}",
"$",
"images",
"=",
"array_values",
"(",
"$",
"images",
")",
";",
"$",
"this",
"->",
"repository",
"->",
"images",
"=",
"$",
"images",
";",
"$",
"this",
"->",
"save",
"(",
")",
";",
"}"
] | Delete image by name
@param $filename | [
"Delete",
"image",
"by",
"name"
] | 76e5d9ac8f9c50d06d39a995d13cc03742536548 | https://github.com/jenskooij/cloudcontrol/blob/76e5d9ac8f9c50d06d39a995d13cc03742536548/src/storage/storage/ImagesStorage.php#L81-L101 | train |
miknatr/grace-dbal | lib/Grace/DBAL/ConnectionAbstract/ConnectionAbstract.php | ConnectionAbstract.generateNewId | public function generateNewId($table)
{
if (!isset($this->idCounterByTable[$table])) {
$this->idCounterByTable[$table] = $this->getSQLBuilder()->select($table)->field('id')->orderDesc('id')->limit(0, 1)->fetchResult();
}
for ($i = 0; $i < 50; $i++) {
$this->idCounterByTable[$table]++;
if ($this->getCache()) {
$key = 'grace_id_gen_' . $table . '_' . strval($this->idCounterByTable[$table]);
$isBusy = $this->getCache()->get($key);
if ($isBusy === null) {
$this->getCache()->set($key, '1', 60);
return $this->idCounterByTable[$table];
}
} else {
return $this->idCounterByTable[$table];
}
}
throw new \OutOfBoundsException('Maximum number of cycles to generate new id has reached');
} | php | public function generateNewId($table)
{
if (!isset($this->idCounterByTable[$table])) {
$this->idCounterByTable[$table] = $this->getSQLBuilder()->select($table)->field('id')->orderDesc('id')->limit(0, 1)->fetchResult();
}
for ($i = 0; $i < 50; $i++) {
$this->idCounterByTable[$table]++;
if ($this->getCache()) {
$key = 'grace_id_gen_' . $table . '_' . strval($this->idCounterByTable[$table]);
$isBusy = $this->getCache()->get($key);
if ($isBusy === null) {
$this->getCache()->set($key, '1', 60);
return $this->idCounterByTable[$table];
}
} else {
return $this->idCounterByTable[$table];
}
}
throw new \OutOfBoundsException('Maximum number of cycles to generate new id has reached');
} | [
"public",
"function",
"generateNewId",
"(",
"$",
"table",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"idCounterByTable",
"[",
"$",
"table",
"]",
")",
")",
"{",
"$",
"this",
"->",
"idCounterByTable",
"[",
"$",
"table",
"]",
"=",
"$",
"this",
"->",
"getSQLBuilder",
"(",
")",
"->",
"select",
"(",
"$",
"table",
")",
"->",
"field",
"(",
"'id'",
")",
"->",
"orderDesc",
"(",
"'id'",
")",
"->",
"limit",
"(",
"0",
",",
"1",
")",
"->",
"fetchResult",
"(",
")",
";",
"}",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"50",
";",
"$",
"i",
"++",
")",
"{",
"$",
"this",
"->",
"idCounterByTable",
"[",
"$",
"table",
"]",
"++",
";",
"if",
"(",
"$",
"this",
"->",
"getCache",
"(",
")",
")",
"{",
"$",
"key",
"=",
"'grace_id_gen_'",
".",
"$",
"table",
".",
"'_'",
".",
"strval",
"(",
"$",
"this",
"->",
"idCounterByTable",
"[",
"$",
"table",
"]",
")",
";",
"$",
"isBusy",
"=",
"$",
"this",
"->",
"getCache",
"(",
")",
"->",
"get",
"(",
"$",
"key",
")",
";",
"if",
"(",
"$",
"isBusy",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"getCache",
"(",
")",
"->",
"set",
"(",
"$",
"key",
",",
"'1'",
",",
"60",
")",
";",
"return",
"$",
"this",
"->",
"idCounterByTable",
"[",
"$",
"table",
"]",
";",
"}",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"idCounterByTable",
"[",
"$",
"table",
"]",
";",
"}",
"}",
"throw",
"new",
"\\",
"OutOfBoundsException",
"(",
"'Maximum number of cycles to generate new id has reached'",
")",
";",
"}"
] | Generate new id for insert
@param string $table
@throws \OutOfBoundsException
@return mixed | [
"Generate",
"new",
"id",
"for",
"insert"
] | b05e03040568631dc6c77477c0eaed6e60db4ba2 | https://github.com/miknatr/grace-dbal/blob/b05e03040568631dc6c77477c0eaed6e60db4ba2/lib/Grace/DBAL/ConnectionAbstract/ConnectionAbstract.php#L338-L361 | train |
itcreator/custom-cmf | Module/User/src/Cmf/User/Controller/UserController.php | UserController.readAction | public function readAction()
{
$result = parent::readAction();
if (!is_array($result)) {
return $result;
}
$em = $this->getEntityManager();
$status = $this->getFieldsConfig()->getConfigItem('status');
$statuses = $status['dataSource']->getData();
$entity = $em->find($this->entityName, Application::getRequest()->get('id'));
$status = $entity->getStatus();
return array_merge($result, ['status' => isset($statuses[$status]) ? $statuses[$status] : '']);
} | php | public function readAction()
{
$result = parent::readAction();
if (!is_array($result)) {
return $result;
}
$em = $this->getEntityManager();
$status = $this->getFieldsConfig()->getConfigItem('status');
$statuses = $status['dataSource']->getData();
$entity = $em->find($this->entityName, Application::getRequest()->get('id'));
$status = $entity->getStatus();
return array_merge($result, ['status' => isset($statuses[$status]) ? $statuses[$status] : '']);
} | [
"public",
"function",
"readAction",
"(",
")",
"{",
"$",
"result",
"=",
"parent",
"::",
"readAction",
"(",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"result",
")",
")",
"{",
"return",
"$",
"result",
";",
"}",
"$",
"em",
"=",
"$",
"this",
"->",
"getEntityManager",
"(",
")",
";",
"$",
"status",
"=",
"$",
"this",
"->",
"getFieldsConfig",
"(",
")",
"->",
"getConfigItem",
"(",
"'status'",
")",
";",
"$",
"statuses",
"=",
"$",
"status",
"[",
"'dataSource'",
"]",
"->",
"getData",
"(",
")",
";",
"$",
"entity",
"=",
"$",
"em",
"->",
"find",
"(",
"$",
"this",
"->",
"entityName",
",",
"Application",
"::",
"getRequest",
"(",
")",
"->",
"get",
"(",
"'id'",
")",
")",
";",
"$",
"status",
"=",
"$",
"entity",
"->",
"getStatus",
"(",
")",
";",
"return",
"array_merge",
"(",
"$",
"result",
",",
"[",
"'status'",
"=>",
"isset",
"(",
"$",
"statuses",
"[",
"$",
"status",
"]",
")",
"?",
"$",
"statuses",
"[",
"$",
"status",
"]",
":",
"''",
"]",
")",
";",
"}"
] | View user page
@return array|Forward | [
"View",
"user",
"page"
] | 42fc0535dfa0f641856f06673f6ab596b2020c40 | https://github.com/itcreator/custom-cmf/blob/42fc0535dfa0f641856f06673f6ab596b2020c40/Module/User/src/Cmf/User/Controller/UserController.php#L61-L76 | train |
nails/module-blog | blog/models/blog_post_model.php | NAILS_Blog_post_model.usePreviewTables | public function usePreviewTables($bEnabled)
{
if (!empty($bEnabled)) {
$this->isPreviewMode = true;
$this->table = NAILS_DB_PREFIX . 'blog_post_preview';
$this->tableAlias = 'bp';
$this->tableCat = NAILS_DB_PREFIX . 'blog_post_preview_category';
$this->tableCatPrefix = 'bpc';
$this->tableTag = NAILS_DB_PREFIX . 'blog_post_preview_tag';
$this->tableTagPrefix = 'bpt';
$this->tableImg = NAILS_DB_PREFIX . 'blog_post_preview_image';
$this->tableImgPrefix = 'bpi';
} else {
$this->isPreviewMode = false;
$this->table = NAILS_DB_PREFIX . 'blog_post';
$this->tableAlias = 'bp';
$this->tableCat = NAILS_DB_PREFIX . 'blog_post_category';
$this->tableCatPrefix = 'bpc';
$this->tableTag = NAILS_DB_PREFIX . 'blog_post_tag';
$this->tableTagPrefix = 'bpt';
$this->tableImg = NAILS_DB_PREFIX . 'blog_post_image';
$this->tableImgPrefix = 'bpi';
}
} | php | public function usePreviewTables($bEnabled)
{
if (!empty($bEnabled)) {
$this->isPreviewMode = true;
$this->table = NAILS_DB_PREFIX . 'blog_post_preview';
$this->tableAlias = 'bp';
$this->tableCat = NAILS_DB_PREFIX . 'blog_post_preview_category';
$this->tableCatPrefix = 'bpc';
$this->tableTag = NAILS_DB_PREFIX . 'blog_post_preview_tag';
$this->tableTagPrefix = 'bpt';
$this->tableImg = NAILS_DB_PREFIX . 'blog_post_preview_image';
$this->tableImgPrefix = 'bpi';
} else {
$this->isPreviewMode = false;
$this->table = NAILS_DB_PREFIX . 'blog_post';
$this->tableAlias = 'bp';
$this->tableCat = NAILS_DB_PREFIX . 'blog_post_category';
$this->tableCatPrefix = 'bpc';
$this->tableTag = NAILS_DB_PREFIX . 'blog_post_tag';
$this->tableTagPrefix = 'bpt';
$this->tableImg = NAILS_DB_PREFIX . 'blog_post_image';
$this->tableImgPrefix = 'bpi';
}
} | [
"public",
"function",
"usePreviewTables",
"(",
"$",
"bEnabled",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"bEnabled",
")",
")",
"{",
"$",
"this",
"->",
"isPreviewMode",
"=",
"true",
";",
"$",
"this",
"->",
"table",
"=",
"NAILS_DB_PREFIX",
".",
"'blog_post_preview'",
";",
"$",
"this",
"->",
"tableAlias",
"=",
"'bp'",
";",
"$",
"this",
"->",
"tableCat",
"=",
"NAILS_DB_PREFIX",
".",
"'blog_post_preview_category'",
";",
"$",
"this",
"->",
"tableCatPrefix",
"=",
"'bpc'",
";",
"$",
"this",
"->",
"tableTag",
"=",
"NAILS_DB_PREFIX",
".",
"'blog_post_preview_tag'",
";",
"$",
"this",
"->",
"tableTagPrefix",
"=",
"'bpt'",
";",
"$",
"this",
"->",
"tableImg",
"=",
"NAILS_DB_PREFIX",
".",
"'blog_post_preview_image'",
";",
"$",
"this",
"->",
"tableImgPrefix",
"=",
"'bpi'",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"isPreviewMode",
"=",
"false",
";",
"$",
"this",
"->",
"table",
"=",
"NAILS_DB_PREFIX",
".",
"'blog_post'",
";",
"$",
"this",
"->",
"tableAlias",
"=",
"'bp'",
";",
"$",
"this",
"->",
"tableCat",
"=",
"NAILS_DB_PREFIX",
".",
"'blog_post_category'",
";",
"$",
"this",
"->",
"tableCatPrefix",
"=",
"'bpc'",
";",
"$",
"this",
"->",
"tableTag",
"=",
"NAILS_DB_PREFIX",
".",
"'blog_post_tag'",
";",
"$",
"this",
"->",
"tableTagPrefix",
"=",
"'bpt'",
";",
"$",
"this",
"->",
"tableImg",
"=",
"NAILS_DB_PREFIX",
".",
"'blog_post_image'",
";",
"$",
"this",
"->",
"tableImgPrefix",
"=",
"'bpi'",
";",
"}",
"}"
] | Sets the table names to use, either the normal tables, or the preview tables.
@param boolean $bEnabled Whether to use the preview tables or not
@return void | [
"Sets",
"the",
"table",
"names",
"to",
"use",
"either",
"the",
"normal",
"tables",
"or",
"the",
"preview",
"tables",
"."
] | 7b369c5209f4343fff7c7e2a22c237d5a95c8c24 | https://github.com/nails/module-blog/blob/7b369c5209f4343fff7c7e2a22c237d5a95c8c24/blog/models/blog_post_model.php#L57-L91 | train |
nails/module-blog | blog/models/blog_post_model.php | NAILS_Blog_post_model.validateSlug | private function validateSlug($sSlug, $sTitle, $iId = null)
{
/**
* Slugs don't matter in preview mode
*/
if ($this->isPreviewMode) {
return 'slug';
}
// --------------------------------------------------------------------------
/**
* Handle the slug
* If a slug has been provided, check it is unique, if one hasn't then
* generate one.
*/
if (empty($sSlug)) {
$sSlug = $this->generateSlug($sTitle);
} else {
$oDb = Factory::service('Database');
if (!empty($iId)) {
$oDb->where('id !=', $iId);
}
$oDb->where('slug', $sSlug);
if ($oDb->count_all_results($this->table)) {
$this->setError('Slug "' . $sSlug . '" is already in use by another post.');
return false;
}
}
// If a the slug is a reserved word then bail out
if (array_search($sSlug, $this->reservedWords) !== false) {
$this->setError('Slug "' . $sSlug . '" is a reserved word and cannot be used.');
return false;
}
return $sSlug;
} | php | private function validateSlug($sSlug, $sTitle, $iId = null)
{
/**
* Slugs don't matter in preview mode
*/
if ($this->isPreviewMode) {
return 'slug';
}
// --------------------------------------------------------------------------
/**
* Handle the slug
* If a slug has been provided, check it is unique, if one hasn't then
* generate one.
*/
if (empty($sSlug)) {
$sSlug = $this->generateSlug($sTitle);
} else {
$oDb = Factory::service('Database');
if (!empty($iId)) {
$oDb->where('id !=', $iId);
}
$oDb->where('slug', $sSlug);
if ($oDb->count_all_results($this->table)) {
$this->setError('Slug "' . $sSlug . '" is already in use by another post.');
return false;
}
}
// If a the slug is a reserved word then bail out
if (array_search($sSlug, $this->reservedWords) !== false) {
$this->setError('Slug "' . $sSlug . '" is a reserved word and cannot be used.');
return false;
}
return $sSlug;
} | [
"private",
"function",
"validateSlug",
"(",
"$",
"sSlug",
",",
"$",
"sTitle",
",",
"$",
"iId",
"=",
"null",
")",
"{",
"/**\n * Slugs don't matter in preview mode\n */",
"if",
"(",
"$",
"this",
"->",
"isPreviewMode",
")",
"{",
"return",
"'slug'",
";",
"}",
"// --------------------------------------------------------------------------",
"/**\n * Handle the slug\n * If a slug has been provided, check it is unique, if one hasn't then\n * generate one.\n */",
"if",
"(",
"empty",
"(",
"$",
"sSlug",
")",
")",
"{",
"$",
"sSlug",
"=",
"$",
"this",
"->",
"generateSlug",
"(",
"$",
"sTitle",
")",
";",
"}",
"else",
"{",
"$",
"oDb",
"=",
"Factory",
"::",
"service",
"(",
"'Database'",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"iId",
")",
")",
"{",
"$",
"oDb",
"->",
"where",
"(",
"'id !='",
",",
"$",
"iId",
")",
";",
"}",
"$",
"oDb",
"->",
"where",
"(",
"'slug'",
",",
"$",
"sSlug",
")",
";",
"if",
"(",
"$",
"oDb",
"->",
"count_all_results",
"(",
"$",
"this",
"->",
"table",
")",
")",
"{",
"$",
"this",
"->",
"setError",
"(",
"'Slug \"'",
".",
"$",
"sSlug",
".",
"'\" is already in use by another post.'",
")",
";",
"return",
"false",
";",
"}",
"}",
"// If a the slug is a reserved word then bail out",
"if",
"(",
"array_search",
"(",
"$",
"sSlug",
",",
"$",
"this",
"->",
"reservedWords",
")",
"!==",
"false",
")",
"{",
"$",
"this",
"->",
"setError",
"(",
"'Slug \"'",
".",
"$",
"sSlug",
".",
"'\" is a reserved word and cannot be used.'",
")",
";",
"return",
"false",
";",
"}",
"return",
"$",
"sSlug",
";",
"}"
] | Validates a slug, if supplied, generates one from the title, if not
@param string $sSlug The slug to test
@param string $sTitle The title to generate a slug from if no slug available
@param integer $siId The ID of the post to ignore from a comparison, if any
@return string | [
"Validates",
"a",
"slug",
"if",
"supplied",
"generates",
"one",
"from",
"the",
"title",
"if",
"not"
] | 7b369c5209f4343fff7c7e2a22c237d5a95c8c24 | https://github.com/nails/module-blog/blob/7b369c5209f4343fff7c7e2a22c237d5a95c8c24/blog/models/blog_post_model.php#L568-L611 | train |
nails/module-blog | blog/models/blog_post_model.php | NAILS_Blog_post_model.getById | public function getById($id, $data = null)
{
$data = $this->includeEverything($data);
return parent::getById($id, $data);
} | php | public function getById($id, $data = null)
{
$data = $this->includeEverything($data);
return parent::getById($id, $data);
} | [
"public",
"function",
"getById",
"(",
"$",
"id",
",",
"$",
"data",
"=",
"null",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"includeEverything",
"(",
"$",
"data",
")",
";",
"return",
"parent",
"::",
"getById",
"(",
"$",
"id",
",",
"$",
"data",
")",
";",
"}"
] | Fetch a pst by it's ID
@param int $id The ID of the object to fetch
@param mixed $data Any data to pass to getCountCommon()
@return stdClass | [
"Fetch",
"a",
"pst",
"by",
"it",
"s",
"ID"
] | 7b369c5209f4343fff7c7e2a22c237d5a95c8c24 | https://github.com/nails/module-blog/blob/7b369c5209f4343fff7c7e2a22c237d5a95c8c24/blog/models/blog_post_model.php#L775-L779 | train |
nails/module-blog | blog/models/blog_post_model.php | NAILS_Blog_post_model.getBySlug | public function getBySlug($id, $data = null)
{
$data = $this->includeEverything($data);
return parent::getBySlug($id, $data);
} | php | public function getBySlug($id, $data = null)
{
$data = $this->includeEverything($data);
return parent::getBySlug($id, $data);
} | [
"public",
"function",
"getBySlug",
"(",
"$",
"id",
",",
"$",
"data",
"=",
"null",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"includeEverything",
"(",
"$",
"data",
")",
";",
"return",
"parent",
"::",
"getBySlug",
"(",
"$",
"id",
",",
"$",
"data",
")",
";",
"}"
] | Fetch a post by it's slug
@param int $slug The slug of the object to fetch
@param mixed $data Any data to pass to getCountCommon()
@return stdClass | [
"Fetch",
"a",
"post",
"by",
"it",
"s",
"slug"
] | 7b369c5209f4343fff7c7e2a22c237d5a95c8c24 | https://github.com/nails/module-blog/blob/7b369c5209f4343fff7c7e2a22c237d5a95c8c24/blog/models/blog_post_model.php#L791-L795 | train |
nails/module-blog | blog/models/blog_post_model.php | NAILS_Blog_post_model.getCountCommon | protected function getCountCommon($data = [])
{
$oDb = Factory::service('Database');
$oDb->select(
[
$this->tableAlias . '.id',
$this->tableAlias . '.blog_id',
'b.label blog_label',
$this->tableAlias . '.slug',
$this->tableAlias . '.title',
$this->tableAlias . '.image_id',
$this->tableAlias . '.excerpt',
$this->tableAlias . '.seo_title',
$this->tableAlias . '.seo_description',
$this->tableAlias . '.seo_keywords',
$this->tableAlias . '.is_published',
$this->tableAlias . '.is_deleted',
$this->tableAlias . '.created',
$this->tableAlias . '.created_by',
$this->tableAlias . '.modified',
$this->tableAlias . '.modified_by',
$this->tableAlias . '.published',
$this->tableAlias . '.comments_enabled',
$this->tableAlias . '.comments_expire',
$this->tableAlias . '.type',
$this->tableAlias . '.audio_url',
$this->tableAlias . '.video_url',
'u.first_name',
'u.last_name',
'ue.email',
'u.profile_img',
'u.gender',
]
);
$oDb->join(NAILS_DB_PREFIX . 'blog b', $this->tableAlias . '.blog_id = b.id', 'LEFT');
$oDb->join(NAILS_DB_PREFIX . 'user u', $this->tableAlias . '.modified_by = u.id', 'LEFT');
$oDb->join(NAILS_DB_PREFIX . 'user_email ue', 'ue.user_id = u.id AND ue.is_primary = 1', 'LEFT');
// --------------------------------------------------------------------------
if (!empty($data['include_body'])) {
$oDb->select($this->tableAlias . '.body');
}
// --------------------------------------------------------------------------
if (!empty($data['keywords'])) {
if (empty($data['or_like'])) {
$data['or_like'] = [];
}
$data['or_like'][] = [
'column' => $this->tableAlias . '.title',
'value' => $data['keywords'],
];
$data['or_like'][] = [
'column' => $this->tableAlias . '.excerpt',
'value' => $data['keywords'],
];
$data['or_like'][] = [
'column' => $this->tableAlias . '.body',
'value' => $data['keywords'],
];
$data['or_like'][] = [
'column' => $this->tableAlias . '.seo_description',
'value' => $data['keywords'],
];
$data['or_like'][] = [
'column' => $this->tableAlias . '.seo_keywords',
'value' => $data['keywords'],
];
}
// --------------------------------------------------------------------------
parent::getCountCommon($data);
} | php | protected function getCountCommon($data = [])
{
$oDb = Factory::service('Database');
$oDb->select(
[
$this->tableAlias . '.id',
$this->tableAlias . '.blog_id',
'b.label blog_label',
$this->tableAlias . '.slug',
$this->tableAlias . '.title',
$this->tableAlias . '.image_id',
$this->tableAlias . '.excerpt',
$this->tableAlias . '.seo_title',
$this->tableAlias . '.seo_description',
$this->tableAlias . '.seo_keywords',
$this->tableAlias . '.is_published',
$this->tableAlias . '.is_deleted',
$this->tableAlias . '.created',
$this->tableAlias . '.created_by',
$this->tableAlias . '.modified',
$this->tableAlias . '.modified_by',
$this->tableAlias . '.published',
$this->tableAlias . '.comments_enabled',
$this->tableAlias . '.comments_expire',
$this->tableAlias . '.type',
$this->tableAlias . '.audio_url',
$this->tableAlias . '.video_url',
'u.first_name',
'u.last_name',
'ue.email',
'u.profile_img',
'u.gender',
]
);
$oDb->join(NAILS_DB_PREFIX . 'blog b', $this->tableAlias . '.blog_id = b.id', 'LEFT');
$oDb->join(NAILS_DB_PREFIX . 'user u', $this->tableAlias . '.modified_by = u.id', 'LEFT');
$oDb->join(NAILS_DB_PREFIX . 'user_email ue', 'ue.user_id = u.id AND ue.is_primary = 1', 'LEFT');
// --------------------------------------------------------------------------
if (!empty($data['include_body'])) {
$oDb->select($this->tableAlias . '.body');
}
// --------------------------------------------------------------------------
if (!empty($data['keywords'])) {
if (empty($data['or_like'])) {
$data['or_like'] = [];
}
$data['or_like'][] = [
'column' => $this->tableAlias . '.title',
'value' => $data['keywords'],
];
$data['or_like'][] = [
'column' => $this->tableAlias . '.excerpt',
'value' => $data['keywords'],
];
$data['or_like'][] = [
'column' => $this->tableAlias . '.body',
'value' => $data['keywords'],
];
$data['or_like'][] = [
'column' => $this->tableAlias . '.seo_description',
'value' => $data['keywords'],
];
$data['or_like'][] = [
'column' => $this->tableAlias . '.seo_keywords',
'value' => $data['keywords'],
];
}
// --------------------------------------------------------------------------
parent::getCountCommon($data);
} | [
"protected",
"function",
"getCountCommon",
"(",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"$",
"oDb",
"=",
"Factory",
"::",
"service",
"(",
"'Database'",
")",
";",
"$",
"oDb",
"->",
"select",
"(",
"[",
"$",
"this",
"->",
"tableAlias",
".",
"'.id'",
",",
"$",
"this",
"->",
"tableAlias",
".",
"'.blog_id'",
",",
"'b.label blog_label'",
",",
"$",
"this",
"->",
"tableAlias",
".",
"'.slug'",
",",
"$",
"this",
"->",
"tableAlias",
".",
"'.title'",
",",
"$",
"this",
"->",
"tableAlias",
".",
"'.image_id'",
",",
"$",
"this",
"->",
"tableAlias",
".",
"'.excerpt'",
",",
"$",
"this",
"->",
"tableAlias",
".",
"'.seo_title'",
",",
"$",
"this",
"->",
"tableAlias",
".",
"'.seo_description'",
",",
"$",
"this",
"->",
"tableAlias",
".",
"'.seo_keywords'",
",",
"$",
"this",
"->",
"tableAlias",
".",
"'.is_published'",
",",
"$",
"this",
"->",
"tableAlias",
".",
"'.is_deleted'",
",",
"$",
"this",
"->",
"tableAlias",
".",
"'.created'",
",",
"$",
"this",
"->",
"tableAlias",
".",
"'.created_by'",
",",
"$",
"this",
"->",
"tableAlias",
".",
"'.modified'",
",",
"$",
"this",
"->",
"tableAlias",
".",
"'.modified_by'",
",",
"$",
"this",
"->",
"tableAlias",
".",
"'.published'",
",",
"$",
"this",
"->",
"tableAlias",
".",
"'.comments_enabled'",
",",
"$",
"this",
"->",
"tableAlias",
".",
"'.comments_expire'",
",",
"$",
"this",
"->",
"tableAlias",
".",
"'.type'",
",",
"$",
"this",
"->",
"tableAlias",
".",
"'.audio_url'",
",",
"$",
"this",
"->",
"tableAlias",
".",
"'.video_url'",
",",
"'u.first_name'",
",",
"'u.last_name'",
",",
"'ue.email'",
",",
"'u.profile_img'",
",",
"'u.gender'",
",",
"]",
")",
";",
"$",
"oDb",
"->",
"join",
"(",
"NAILS_DB_PREFIX",
".",
"'blog b'",
",",
"$",
"this",
"->",
"tableAlias",
".",
"'.blog_id = b.id'",
",",
"'LEFT'",
")",
";",
"$",
"oDb",
"->",
"join",
"(",
"NAILS_DB_PREFIX",
".",
"'user u'",
",",
"$",
"this",
"->",
"tableAlias",
".",
"'.modified_by = u.id'",
",",
"'LEFT'",
")",
";",
"$",
"oDb",
"->",
"join",
"(",
"NAILS_DB_PREFIX",
".",
"'user_email ue'",
",",
"'ue.user_id = u.id AND ue.is_primary = 1'",
",",
"'LEFT'",
")",
";",
"// --------------------------------------------------------------------------",
"if",
"(",
"!",
"empty",
"(",
"$",
"data",
"[",
"'include_body'",
"]",
")",
")",
"{",
"$",
"oDb",
"->",
"select",
"(",
"$",
"this",
"->",
"tableAlias",
".",
"'.body'",
")",
";",
"}",
"// --------------------------------------------------------------------------",
"if",
"(",
"!",
"empty",
"(",
"$",
"data",
"[",
"'keywords'",
"]",
")",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"data",
"[",
"'or_like'",
"]",
")",
")",
"{",
"$",
"data",
"[",
"'or_like'",
"]",
"=",
"[",
"]",
";",
"}",
"$",
"data",
"[",
"'or_like'",
"]",
"[",
"]",
"=",
"[",
"'column'",
"=>",
"$",
"this",
"->",
"tableAlias",
".",
"'.title'",
",",
"'value'",
"=>",
"$",
"data",
"[",
"'keywords'",
"]",
",",
"]",
";",
"$",
"data",
"[",
"'or_like'",
"]",
"[",
"]",
"=",
"[",
"'column'",
"=>",
"$",
"this",
"->",
"tableAlias",
".",
"'.excerpt'",
",",
"'value'",
"=>",
"$",
"data",
"[",
"'keywords'",
"]",
",",
"]",
";",
"$",
"data",
"[",
"'or_like'",
"]",
"[",
"]",
"=",
"[",
"'column'",
"=>",
"$",
"this",
"->",
"tableAlias",
".",
"'.body'",
",",
"'value'",
"=>",
"$",
"data",
"[",
"'keywords'",
"]",
",",
"]",
";",
"$",
"data",
"[",
"'or_like'",
"]",
"[",
"]",
"=",
"[",
"'column'",
"=>",
"$",
"this",
"->",
"tableAlias",
".",
"'.seo_description'",
",",
"'value'",
"=>",
"$",
"data",
"[",
"'keywords'",
"]",
",",
"]",
";",
"$",
"data",
"[",
"'or_like'",
"]",
"[",
"]",
"=",
"[",
"'column'",
"=>",
"$",
"this",
"->",
"tableAlias",
".",
"'.seo_keywords'",
",",
"'value'",
"=>",
"$",
"data",
"[",
"'keywords'",
"]",
",",
"]",
";",
"}",
"// --------------------------------------------------------------------------",
"parent",
"::",
"getCountCommon",
"(",
"$",
"data",
")",
";",
"}"
] | Applies common conditionals
This method applies the conditionals which are common across the get_*()
methods and the count() method.
@param array $data Data passed from the calling method
@return void | [
"Applies",
"common",
"conditionals"
] | 7b369c5209f4343fff7c7e2a22c237d5a95c8c24 | https://github.com/nails/module-blog/blob/7b369c5209f4343fff7c7e2a22c237d5a95c8c24/blog/models/blog_post_model.php#L830-L909 | train |
nails/module-blog | blog/models/blog_post_model.php | NAILS_Blog_post_model.includeEverything | protected function includeEverything($data)
{
if (is_null($data)) {
$data = [];
}
if (!isset($data['include_body'])) {
$data['include_body'] = true;
}
if (!isset($data['include_categories'])) {
$data['include_categories'] = true;
}
if (!isset($data['include_tags'])) {
$data['include_tags'] = true;
}
if (!isset($data['include_associations'])) {
$data['include_associations'] = true;
}
if (!isset($data['include_gallery'])) {
$data['include_gallery'] = true;
}
if (!isset($data['include_siblings'])) {
$data['include_siblings'] = true;
}
// --------------------------------------------------------------------------
return $data;
} | php | protected function includeEverything($data)
{
if (is_null($data)) {
$data = [];
}
if (!isset($data['include_body'])) {
$data['include_body'] = true;
}
if (!isset($data['include_categories'])) {
$data['include_categories'] = true;
}
if (!isset($data['include_tags'])) {
$data['include_tags'] = true;
}
if (!isset($data['include_associations'])) {
$data['include_associations'] = true;
}
if (!isset($data['include_gallery'])) {
$data['include_gallery'] = true;
}
if (!isset($data['include_siblings'])) {
$data['include_siblings'] = true;
}
// --------------------------------------------------------------------------
return $data;
} | [
"protected",
"function",
"includeEverything",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"data",
")",
")",
"{",
"$",
"data",
"=",
"[",
"]",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"data",
"[",
"'include_body'",
"]",
")",
")",
"{",
"$",
"data",
"[",
"'include_body'",
"]",
"=",
"true",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"data",
"[",
"'include_categories'",
"]",
")",
")",
"{",
"$",
"data",
"[",
"'include_categories'",
"]",
"=",
"true",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"data",
"[",
"'include_tags'",
"]",
")",
")",
"{",
"$",
"data",
"[",
"'include_tags'",
"]",
"=",
"true",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"data",
"[",
"'include_associations'",
"]",
")",
")",
"{",
"$",
"data",
"[",
"'include_associations'",
"]",
"=",
"true",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"data",
"[",
"'include_gallery'",
"]",
")",
")",
"{",
"$",
"data",
"[",
"'include_gallery'",
"]",
"=",
"true",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"data",
"[",
"'include_siblings'",
"]",
")",
")",
"{",
"$",
"data",
"[",
"'include_siblings'",
"]",
"=",
"true",
";",
"}",
"// --------------------------------------------------------------------------",
"return",
"$",
"data",
";",
"}"
] | Sets the data array to include everything
This method is called by the getBy*() methods and, if not already set,
will alter the $data array so that all the include_* parameters are set.
@param string $data Data passed from the calling method
@return void | [
"Sets",
"the",
"data",
"array",
"to",
"include",
"everything"
] | 7b369c5209f4343fff7c7e2a22c237d5a95c8c24 | https://github.com/nails/module-blog/blob/7b369c5209f4343fff7c7e2a22c237d5a95c8c24/blog/models/blog_post_model.php#L923-L963 | train |
nails/module-blog | blog/models/blog_post_model.php | NAILS_Blog_post_model.getWithCategory | public function getWithCategory($categoryIdSlug, $page = null, $perPage = null, $data = null, $includeDeleted = false)
{
$oDb = Factory::service('Database');
// Join the $this->tableCat table so we can WHERE on it.
$oDb->join(
$this->tableCat . ' ' . $this->tableCatPrefix,
$this->tableCatPrefix . '.post_id = ' . $this->tableAlias . '.id'
);
$oDb->join(
NAILS_DB_PREFIX . 'blog_category bc',
'bc.id = ' . $this->tableCatPrefix . '.category_id'
);
// Set the where
if (is_null($data)) {
$data = ['where' => []];
}
if (!isset($data['where'])) {
$data['where'] = [];
}
if (is_numeric($categoryIdSlug)) {
$data['where'][] = ['column' => 'bc.id', 'value' => (int) $categoryIdSlug];
} else {
$data['where'][] = ['column' => 'bc.slug', 'value' => $categoryIdSlug];
}
$oDb->group_by($this->tableAlias . '.id');
return $this->getAll($page, $perPage, $data, $includeDeleted);
} | php | public function getWithCategory($categoryIdSlug, $page = null, $perPage = null, $data = null, $includeDeleted = false)
{
$oDb = Factory::service('Database');
// Join the $this->tableCat table so we can WHERE on it.
$oDb->join(
$this->tableCat . ' ' . $this->tableCatPrefix,
$this->tableCatPrefix . '.post_id = ' . $this->tableAlias . '.id'
);
$oDb->join(
NAILS_DB_PREFIX . 'blog_category bc',
'bc.id = ' . $this->tableCatPrefix . '.category_id'
);
// Set the where
if (is_null($data)) {
$data = ['where' => []];
}
if (!isset($data['where'])) {
$data['where'] = [];
}
if (is_numeric($categoryIdSlug)) {
$data['where'][] = ['column' => 'bc.id', 'value' => (int) $categoryIdSlug];
} else {
$data['where'][] = ['column' => 'bc.slug', 'value' => $categoryIdSlug];
}
$oDb->group_by($this->tableAlias . '.id');
return $this->getAll($page, $perPage, $data, $includeDeleted);
} | [
"public",
"function",
"getWithCategory",
"(",
"$",
"categoryIdSlug",
",",
"$",
"page",
"=",
"null",
",",
"$",
"perPage",
"=",
"null",
",",
"$",
"data",
"=",
"null",
",",
"$",
"includeDeleted",
"=",
"false",
")",
"{",
"$",
"oDb",
"=",
"Factory",
"::",
"service",
"(",
"'Database'",
")",
";",
"// Join the $this->tableCat table so we can WHERE on it.",
"$",
"oDb",
"->",
"join",
"(",
"$",
"this",
"->",
"tableCat",
".",
"' '",
".",
"$",
"this",
"->",
"tableCatPrefix",
",",
"$",
"this",
"->",
"tableCatPrefix",
".",
"'.post_id = '",
".",
"$",
"this",
"->",
"tableAlias",
".",
"'.id'",
")",
";",
"$",
"oDb",
"->",
"join",
"(",
"NAILS_DB_PREFIX",
".",
"'blog_category bc'",
",",
"'bc.id = '",
".",
"$",
"this",
"->",
"tableCatPrefix",
".",
"'.category_id'",
")",
";",
"// Set the where",
"if",
"(",
"is_null",
"(",
"$",
"data",
")",
")",
"{",
"$",
"data",
"=",
"[",
"'where'",
"=>",
"[",
"]",
"]",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"data",
"[",
"'where'",
"]",
")",
")",
"{",
"$",
"data",
"[",
"'where'",
"]",
"=",
"[",
"]",
";",
"}",
"if",
"(",
"is_numeric",
"(",
"$",
"categoryIdSlug",
")",
")",
"{",
"$",
"data",
"[",
"'where'",
"]",
"[",
"]",
"=",
"[",
"'column'",
"=>",
"'bc.id'",
",",
"'value'",
"=>",
"(",
"int",
")",
"$",
"categoryIdSlug",
"]",
";",
"}",
"else",
"{",
"$",
"data",
"[",
"'where'",
"]",
"[",
"]",
"=",
"[",
"'column'",
"=>",
"'bc.slug'",
",",
"'value'",
"=>",
"$",
"categoryIdSlug",
"]",
";",
"}",
"$",
"oDb",
"->",
"group_by",
"(",
"$",
"this",
"->",
"tableAlias",
".",
"'.id'",
")",
";",
"return",
"$",
"this",
"->",
"getAll",
"(",
"$",
"page",
",",
"$",
"perPage",
",",
"$",
"data",
",",
"$",
"includeDeleted",
")",
";",
"}"
] | Gets posts which are in a particular category
@param mixed $categoryIdSlug The category's ID or slug
@param int $page The page to render
@param int $perPage The number of posts per page
@param array $data Data to pass to getCountCommon()
@param boolean $includeDeleted Whether to include deleted posts in the result
@return array | [
"Gets",
"posts",
"which",
"are",
"in",
"a",
"particular",
"category"
] | 7b369c5209f4343fff7c7e2a22c237d5a95c8c24 | https://github.com/nails/module-blog/blob/7b369c5209f4343fff7c7e2a22c237d5a95c8c24/blog/models/blog_post_model.php#L1028-L1060 | train |
nails/module-blog | blog/models/blog_post_model.php | NAILS_Blog_post_model.countWithCategory | public function countWithCategory($categoryIdSlug, $data = null, $includeDeleted = false)
{
$oDb = Factory::service('Database');
// Join the $this->tableCat table so we can WHERE on it.
$oDb->join(
$this->tableCat . ' ' . $this->tableCatPrefix,
$this->tableCatPrefix . '.post_id = ' . $this->tableAlias . '.id'
);
$oDb->join(
NAILS_DB_PREFIX . 'blog_category bc',
'bc.id = ' . $this->tableCatPrefix . '.category_id'
);
// Set the where
if (is_null($data)) {
$data = ['where' => []];
}
if (is_numeric($categoryIdSlug)) {
$data['where'][] = ['column' => 'bc.id', 'value' => (int) $categoryIdSlug];
} else {
$data['where'][] = ['column' => 'bc.slug', 'value' => $categoryIdSlug];
}
return $this->countAll($data, $includeDeleted);
} | php | public function countWithCategory($categoryIdSlug, $data = null, $includeDeleted = false)
{
$oDb = Factory::service('Database');
// Join the $this->tableCat table so we can WHERE on it.
$oDb->join(
$this->tableCat . ' ' . $this->tableCatPrefix,
$this->tableCatPrefix . '.post_id = ' . $this->tableAlias . '.id'
);
$oDb->join(
NAILS_DB_PREFIX . 'blog_category bc',
'bc.id = ' . $this->tableCatPrefix . '.category_id'
);
// Set the where
if (is_null($data)) {
$data = ['where' => []];
}
if (is_numeric($categoryIdSlug)) {
$data['where'][] = ['column' => 'bc.id', 'value' => (int) $categoryIdSlug];
} else {
$data['where'][] = ['column' => 'bc.slug', 'value' => $categoryIdSlug];
}
return $this->countAll($data, $includeDeleted);
} | [
"public",
"function",
"countWithCategory",
"(",
"$",
"categoryIdSlug",
",",
"$",
"data",
"=",
"null",
",",
"$",
"includeDeleted",
"=",
"false",
")",
"{",
"$",
"oDb",
"=",
"Factory",
"::",
"service",
"(",
"'Database'",
")",
";",
"// Join the $this->tableCat table so we can WHERE on it.",
"$",
"oDb",
"->",
"join",
"(",
"$",
"this",
"->",
"tableCat",
".",
"' '",
".",
"$",
"this",
"->",
"tableCatPrefix",
",",
"$",
"this",
"->",
"tableCatPrefix",
".",
"'.post_id = '",
".",
"$",
"this",
"->",
"tableAlias",
".",
"'.id'",
")",
";",
"$",
"oDb",
"->",
"join",
"(",
"NAILS_DB_PREFIX",
".",
"'blog_category bc'",
",",
"'bc.id = '",
".",
"$",
"this",
"->",
"tableCatPrefix",
".",
"'.category_id'",
")",
";",
"// Set the where",
"if",
"(",
"is_null",
"(",
"$",
"data",
")",
")",
"{",
"$",
"data",
"=",
"[",
"'where'",
"=>",
"[",
"]",
"]",
";",
"}",
"if",
"(",
"is_numeric",
"(",
"$",
"categoryIdSlug",
")",
")",
"{",
"$",
"data",
"[",
"'where'",
"]",
"[",
"]",
"=",
"[",
"'column'",
"=>",
"'bc.id'",
",",
"'value'",
"=>",
"(",
"int",
")",
"$",
"categoryIdSlug",
"]",
";",
"}",
"else",
"{",
"$",
"data",
"[",
"'where'",
"]",
"[",
"]",
"=",
"[",
"'column'",
"=>",
"'bc.slug'",
",",
"'value'",
"=>",
"$",
"categoryIdSlug",
"]",
";",
"}",
"return",
"$",
"this",
"->",
"countAll",
"(",
"$",
"data",
",",
"$",
"includeDeleted",
")",
";",
"}"
] | Count the number of posts in a particular category
@param mixed $categoryIdSlug The category's ID or slug
@param array $data Data to pass to getCountCommon()
@param boolean $includeDeleted Whether to include deleted posts in the result
@return int | [
"Count",
"the",
"number",
"of",
"posts",
"in",
"a",
"particular",
"category"
] | 7b369c5209f4343fff7c7e2a22c237d5a95c8c24 | https://github.com/nails/module-blog/blob/7b369c5209f4343fff7c7e2a22c237d5a95c8c24/blog/models/blog_post_model.php#L1073-L1099 | train |
nails/module-blog | blog/models/blog_post_model.php | NAILS_Blog_post_model.getWithTag | public function getWithTag($tagIdSlug, $page = null, $perPage = null, $data = null, $includeDeleted = false)
{
$oDb = Factory::service('Database');
// Join the $this->tableTag table so we can WHERE on it.
$oDb->join(
$this->tableTag . ' ' . $this->tableTagPrefix,
$this->tableTagPrefix . '.post_id = ' . $this->tableAlias . '.id'
);
$oDb->join(
NAILS_DB_PREFIX . 'blog_tag bt',
'bt.id = ' . $this->tableTagPrefix . '.tag_id'
);
// Set the where
if (is_null($data)) {
$data = ['where' => []];
}
if (is_numeric($tagIdSlug)) {
$data['where'][] = ['column' => 'bt.id', 'value' => (int) $tagIdSlug];
} else {
$data['where'][] = ['column' => 'bt.slug', 'value' => $tagIdSlug];
}
$oDb->group_by($this->tableAlias . '.id');
return $this->getAll($page, $perPage, $data, $includeDeleted);
} | php | public function getWithTag($tagIdSlug, $page = null, $perPage = null, $data = null, $includeDeleted = false)
{
$oDb = Factory::service('Database');
// Join the $this->tableTag table so we can WHERE on it.
$oDb->join(
$this->tableTag . ' ' . $this->tableTagPrefix,
$this->tableTagPrefix . '.post_id = ' . $this->tableAlias . '.id'
);
$oDb->join(
NAILS_DB_PREFIX . 'blog_tag bt',
'bt.id = ' . $this->tableTagPrefix . '.tag_id'
);
// Set the where
if (is_null($data)) {
$data = ['where' => []];
}
if (is_numeric($tagIdSlug)) {
$data['where'][] = ['column' => 'bt.id', 'value' => (int) $tagIdSlug];
} else {
$data['where'][] = ['column' => 'bt.slug', 'value' => $tagIdSlug];
}
$oDb->group_by($this->tableAlias . '.id');
return $this->getAll($page, $perPage, $data, $includeDeleted);
} | [
"public",
"function",
"getWithTag",
"(",
"$",
"tagIdSlug",
",",
"$",
"page",
"=",
"null",
",",
"$",
"perPage",
"=",
"null",
",",
"$",
"data",
"=",
"null",
",",
"$",
"includeDeleted",
"=",
"false",
")",
"{",
"$",
"oDb",
"=",
"Factory",
"::",
"service",
"(",
"'Database'",
")",
";",
"// Join the $this->tableTag table so we can WHERE on it.",
"$",
"oDb",
"->",
"join",
"(",
"$",
"this",
"->",
"tableTag",
".",
"' '",
".",
"$",
"this",
"->",
"tableTagPrefix",
",",
"$",
"this",
"->",
"tableTagPrefix",
".",
"'.post_id = '",
".",
"$",
"this",
"->",
"tableAlias",
".",
"'.id'",
")",
";",
"$",
"oDb",
"->",
"join",
"(",
"NAILS_DB_PREFIX",
".",
"'blog_tag bt'",
",",
"'bt.id = '",
".",
"$",
"this",
"->",
"tableTagPrefix",
".",
"'.tag_id'",
")",
";",
"// Set the where",
"if",
"(",
"is_null",
"(",
"$",
"data",
")",
")",
"{",
"$",
"data",
"=",
"[",
"'where'",
"=>",
"[",
"]",
"]",
";",
"}",
"if",
"(",
"is_numeric",
"(",
"$",
"tagIdSlug",
")",
")",
"{",
"$",
"data",
"[",
"'where'",
"]",
"[",
"]",
"=",
"[",
"'column'",
"=>",
"'bt.id'",
",",
"'value'",
"=>",
"(",
"int",
")",
"$",
"tagIdSlug",
"]",
";",
"}",
"else",
"{",
"$",
"data",
"[",
"'where'",
"]",
"[",
"]",
"=",
"[",
"'column'",
"=>",
"'bt.slug'",
",",
"'value'",
"=>",
"$",
"tagIdSlug",
"]",
";",
"}",
"$",
"oDb",
"->",
"group_by",
"(",
"$",
"this",
"->",
"tableAlias",
".",
"'.id'",
")",
";",
"return",
"$",
"this",
"->",
"getAll",
"(",
"$",
"page",
",",
"$",
"perPage",
",",
"$",
"data",
",",
"$",
"includeDeleted",
")",
";",
"}"
] | Gets posts which are in a particular tag
@param mixed $tagIdSlug The tag's ID or slug
@param int $page The page to render
@param int $perPage The number of posts per page
@param array $data Data to pass to getCountCommon()
@param boolean $includeDeleted Whether to include deleted posts in the result
@return array | [
"Gets",
"posts",
"which",
"are",
"in",
"a",
"particular",
"tag"
] | 7b369c5209f4343fff7c7e2a22c237d5a95c8c24 | https://github.com/nails/module-blog/blob/7b369c5209f4343fff7c7e2a22c237d5a95c8c24/blog/models/blog_post_model.php#L1114-L1142 | train |
nails/module-blog | blog/models/blog_post_model.php | NAILS_Blog_post_model.countWithTag | public function countWithTag($tagIdSlug, $data = null, $includeDeleted = false)
{
$oDb = Factory::service('Database');
// Join the $this->tableTag table so we can WHERE on it.
$oDb->join(
$this->tableTag . ' ' . $this->tableTagPrefix,
$this->tableTagPrefix . '.post_id = ' . $this->tableAlias . '.id'
);
$oDb->join(
NAILS_DB_PREFIX . 'blog_tag bt',
'bt.id = ' . $this->tableTagPrefix . '.tag_id'
);
// Set the where
if (is_null($data)) {
$data = ['where' => []];
}
if (is_numeric($tagIdSlug)) {
$data['where'][] = ['column' => 'bt.id', 'value' => (int) $tagIdSlug];
} else {
$data['where'][] = ['column' => 'bt.slug', 'value' => $tagIdSlug];
}
return $this->countAll($data, $includeDeleted);
} | php | public function countWithTag($tagIdSlug, $data = null, $includeDeleted = false)
{
$oDb = Factory::service('Database');
// Join the $this->tableTag table so we can WHERE on it.
$oDb->join(
$this->tableTag . ' ' . $this->tableTagPrefix,
$this->tableTagPrefix . '.post_id = ' . $this->tableAlias . '.id'
);
$oDb->join(
NAILS_DB_PREFIX . 'blog_tag bt',
'bt.id = ' . $this->tableTagPrefix . '.tag_id'
);
// Set the where
if (is_null($data)) {
$data = ['where' => []];
}
if (is_numeric($tagIdSlug)) {
$data['where'][] = ['column' => 'bt.id', 'value' => (int) $tagIdSlug];
} else {
$data['where'][] = ['column' => 'bt.slug', 'value' => $tagIdSlug];
}
return $this->countAll($data, $includeDeleted);
} | [
"public",
"function",
"countWithTag",
"(",
"$",
"tagIdSlug",
",",
"$",
"data",
"=",
"null",
",",
"$",
"includeDeleted",
"=",
"false",
")",
"{",
"$",
"oDb",
"=",
"Factory",
"::",
"service",
"(",
"'Database'",
")",
";",
"// Join the $this->tableTag table so we can WHERE on it.",
"$",
"oDb",
"->",
"join",
"(",
"$",
"this",
"->",
"tableTag",
".",
"' '",
".",
"$",
"this",
"->",
"tableTagPrefix",
",",
"$",
"this",
"->",
"tableTagPrefix",
".",
"'.post_id = '",
".",
"$",
"this",
"->",
"tableAlias",
".",
"'.id'",
")",
";",
"$",
"oDb",
"->",
"join",
"(",
"NAILS_DB_PREFIX",
".",
"'blog_tag bt'",
",",
"'bt.id = '",
".",
"$",
"this",
"->",
"tableTagPrefix",
".",
"'.tag_id'",
")",
";",
"// Set the where",
"if",
"(",
"is_null",
"(",
"$",
"data",
")",
")",
"{",
"$",
"data",
"=",
"[",
"'where'",
"=>",
"[",
"]",
"]",
";",
"}",
"if",
"(",
"is_numeric",
"(",
"$",
"tagIdSlug",
")",
")",
"{",
"$",
"data",
"[",
"'where'",
"]",
"[",
"]",
"=",
"[",
"'column'",
"=>",
"'bt.id'",
",",
"'value'",
"=>",
"(",
"int",
")",
"$",
"tagIdSlug",
"]",
";",
"}",
"else",
"{",
"$",
"data",
"[",
"'where'",
"]",
"[",
"]",
"=",
"[",
"'column'",
"=>",
"'bt.slug'",
",",
"'value'",
"=>",
"$",
"tagIdSlug",
"]",
";",
"}",
"return",
"$",
"this",
"->",
"countAll",
"(",
"$",
"data",
",",
"$",
"includeDeleted",
")",
";",
"}"
] | Count the number of posts in a particular tag
@param mixed $tagIdSlug The tag's ID or slug
@param array $data Data to pass to getCountCommon()
@param boolean $includeDeleted Whether to include deleted posts in the result
@return int | [
"Count",
"the",
"number",
"of",
"posts",
"in",
"a",
"particular",
"tag"
] | 7b369c5209f4343fff7c7e2a22c237d5a95c8c24 | https://github.com/nails/module-blog/blob/7b369c5209f4343fff7c7e2a22c237d5a95c8c24/blog/models/blog_post_model.php#L1155-L1185 | train |
nails/module-blog | blog/models/blog_post_model.php | NAILS_Blog_post_model.getWithAssociation | public function getWithAssociation($associationIndex, $associatedId)
{
$oConfig = Factory::service('Config');
$oConfig->load('blog/blog');
$associations = $oConfig->item('blog_post_associations');
if (!isset($associations[$associationIndex])) {
return [];
}
$oDb = Factory::service('Database');
$oDb->select('post_id');
$oDb->where('associated_id', $associatedId);
$posts = $oDb->get($associations[$associationIndex]->target)->result();
$ids = [];
foreach ($posts as $post) {
$ids[] = $post->post_id;
}
if (empty($ids)) {
// No IDs? No posts.
return [];
}
$oDb->where_in($this->tableAlias . '.id', $ids);
return $this->getAll();
} | php | public function getWithAssociation($associationIndex, $associatedId)
{
$oConfig = Factory::service('Config');
$oConfig->load('blog/blog');
$associations = $oConfig->item('blog_post_associations');
if (!isset($associations[$associationIndex])) {
return [];
}
$oDb = Factory::service('Database');
$oDb->select('post_id');
$oDb->where('associated_id', $associatedId);
$posts = $oDb->get($associations[$associationIndex]->target)->result();
$ids = [];
foreach ($posts as $post) {
$ids[] = $post->post_id;
}
if (empty($ids)) {
// No IDs? No posts.
return [];
}
$oDb->where_in($this->tableAlias . '.id', $ids);
return $this->getAll();
} | [
"public",
"function",
"getWithAssociation",
"(",
"$",
"associationIndex",
",",
"$",
"associatedId",
")",
"{",
"$",
"oConfig",
"=",
"Factory",
"::",
"service",
"(",
"'Config'",
")",
";",
"$",
"oConfig",
"->",
"load",
"(",
"'blog/blog'",
")",
";",
"$",
"associations",
"=",
"$",
"oConfig",
"->",
"item",
"(",
"'blog_post_associations'",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"associations",
"[",
"$",
"associationIndex",
"]",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"oDb",
"=",
"Factory",
"::",
"service",
"(",
"'Database'",
")",
";",
"$",
"oDb",
"->",
"select",
"(",
"'post_id'",
")",
";",
"$",
"oDb",
"->",
"where",
"(",
"'associated_id'",
",",
"$",
"associatedId",
")",
";",
"$",
"posts",
"=",
"$",
"oDb",
"->",
"get",
"(",
"$",
"associations",
"[",
"$",
"associationIndex",
"]",
"->",
"target",
")",
"->",
"result",
"(",
")",
";",
"$",
"ids",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"posts",
"as",
"$",
"post",
")",
"{",
"$",
"ids",
"[",
"]",
"=",
"$",
"post",
"->",
"post_id",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"ids",
")",
")",
"{",
"// No IDs? No posts.",
"return",
"[",
"]",
";",
"}",
"$",
"oDb",
"->",
"where_in",
"(",
"$",
"this",
"->",
"tableAlias",
".",
"'.id'",
",",
"$",
"ids",
")",
";",
"return",
"$",
"this",
"->",
"getAll",
"(",
")",
";",
"}"
] | Get posts with a particular association
@param int $associationIndex The association's index
@param int $associatedId The Id of the item to be associated with
@return array | [
"Get",
"posts",
"with",
"a",
"particular",
"association"
] | 7b369c5209f4343fff7c7e2a22c237d5a95c8c24 | https://github.com/nails/module-blog/blob/7b369c5209f4343fff7c7e2a22c237d5a95c8c24/blog/models/blog_post_model.php#L1209-L1238 | train |
nails/module-blog | blog/models/blog_post_model.php | NAILS_Blog_post_model.addHit | public function addHit($id, $data = [])
{
if (!$id) {
$this->setError('Post ID is required.');
return false;
}
// --------------------------------------------------------------------------
$oDate = Factory::factory('DateTime');
$hitData = [];
$hitData['post_id'] = $id;
$hitData['user_id'] = empty($data['user_id']) ? null : $data['user_id'];
$hitData['ip_address'] = $this->input->ipAddress();
$hitData['created'] = $oDate->format('Y-m-d H:i:s');
$hitData['referrer'] = empty($data['referrer']) ? null : prep_url(trim($data['referrer']));
if ($hitData['user_id'] && isAdmin($hitData['user_id'])) {
$this->setError('Administrators cannot affect the post\'s popularity.');
return false;
}
// --------------------------------------------------------------------------
/**
* Registered a hit on this post in the past 5 minutes? Try to prevent abuse
* of the popularity system.
*/
$oDb = Factory::service('Database');
$oDb->where('post_id', $hitData['post_id']);
$oDb->where('user_id', $hitData['user_id']);
$oDb->where('ip_address', $hitData['ip_address']);
$oDb->where('created > "' . $oDate->sub(new \DateInterval('PT5M'))->format('Y-m-d H:i:s') . '"');
if ($oDb->count_all_results($this->tableHit)) {
$this->setError('Hit timeout in effect.');
return false;
}
// --------------------------------------------------------------------------
$oDb->set($hitData);
if ($oDb->insert($this->tableHit)) {
return true;
} else {
$this->setError('Failed to add hit.');
return false;
}
} | php | public function addHit($id, $data = [])
{
if (!$id) {
$this->setError('Post ID is required.');
return false;
}
// --------------------------------------------------------------------------
$oDate = Factory::factory('DateTime');
$hitData = [];
$hitData['post_id'] = $id;
$hitData['user_id'] = empty($data['user_id']) ? null : $data['user_id'];
$hitData['ip_address'] = $this->input->ipAddress();
$hitData['created'] = $oDate->format('Y-m-d H:i:s');
$hitData['referrer'] = empty($data['referrer']) ? null : prep_url(trim($data['referrer']));
if ($hitData['user_id'] && isAdmin($hitData['user_id'])) {
$this->setError('Administrators cannot affect the post\'s popularity.');
return false;
}
// --------------------------------------------------------------------------
/**
* Registered a hit on this post in the past 5 minutes? Try to prevent abuse
* of the popularity system.
*/
$oDb = Factory::service('Database');
$oDb->where('post_id', $hitData['post_id']);
$oDb->where('user_id', $hitData['user_id']);
$oDb->where('ip_address', $hitData['ip_address']);
$oDb->where('created > "' . $oDate->sub(new \DateInterval('PT5M'))->format('Y-m-d H:i:s') . '"');
if ($oDb->count_all_results($this->tableHit)) {
$this->setError('Hit timeout in effect.');
return false;
}
// --------------------------------------------------------------------------
$oDb->set($hitData);
if ($oDb->insert($this->tableHit)) {
return true;
} else {
$this->setError('Failed to add hit.');
return false;
}
} | [
"public",
"function",
"addHit",
"(",
"$",
"id",
",",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"$",
"id",
")",
"{",
"$",
"this",
"->",
"setError",
"(",
"'Post ID is required.'",
")",
";",
"return",
"false",
";",
"}",
"// --------------------------------------------------------------------------",
"$",
"oDate",
"=",
"Factory",
"::",
"factory",
"(",
"'DateTime'",
")",
";",
"$",
"hitData",
"=",
"[",
"]",
";",
"$",
"hitData",
"[",
"'post_id'",
"]",
"=",
"$",
"id",
";",
"$",
"hitData",
"[",
"'user_id'",
"]",
"=",
"empty",
"(",
"$",
"data",
"[",
"'user_id'",
"]",
")",
"?",
"null",
":",
"$",
"data",
"[",
"'user_id'",
"]",
";",
"$",
"hitData",
"[",
"'ip_address'",
"]",
"=",
"$",
"this",
"->",
"input",
"->",
"ipAddress",
"(",
")",
";",
"$",
"hitData",
"[",
"'created'",
"]",
"=",
"$",
"oDate",
"->",
"format",
"(",
"'Y-m-d H:i:s'",
")",
";",
"$",
"hitData",
"[",
"'referrer'",
"]",
"=",
"empty",
"(",
"$",
"data",
"[",
"'referrer'",
"]",
")",
"?",
"null",
":",
"prep_url",
"(",
"trim",
"(",
"$",
"data",
"[",
"'referrer'",
"]",
")",
")",
";",
"if",
"(",
"$",
"hitData",
"[",
"'user_id'",
"]",
"&&",
"isAdmin",
"(",
"$",
"hitData",
"[",
"'user_id'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"setError",
"(",
"'Administrators cannot affect the post\\'s popularity.'",
")",
";",
"return",
"false",
";",
"}",
"// --------------------------------------------------------------------------",
"/**\n * Registered a hit on this post in the past 5 minutes? Try to prevent abuse\n * of the popularity system.\n */",
"$",
"oDb",
"=",
"Factory",
"::",
"service",
"(",
"'Database'",
")",
";",
"$",
"oDb",
"->",
"where",
"(",
"'post_id'",
",",
"$",
"hitData",
"[",
"'post_id'",
"]",
")",
";",
"$",
"oDb",
"->",
"where",
"(",
"'user_id'",
",",
"$",
"hitData",
"[",
"'user_id'",
"]",
")",
";",
"$",
"oDb",
"->",
"where",
"(",
"'ip_address'",
",",
"$",
"hitData",
"[",
"'ip_address'",
"]",
")",
";",
"$",
"oDb",
"->",
"where",
"(",
"'created > \"'",
".",
"$",
"oDate",
"->",
"sub",
"(",
"new",
"\\",
"DateInterval",
"(",
"'PT5M'",
")",
")",
"->",
"format",
"(",
"'Y-m-d H:i:s'",
")",
".",
"'\"'",
")",
";",
"if",
"(",
"$",
"oDb",
"->",
"count_all_results",
"(",
"$",
"this",
"->",
"tableHit",
")",
")",
"{",
"$",
"this",
"->",
"setError",
"(",
"'Hit timeout in effect.'",
")",
";",
"return",
"false",
";",
"}",
"// --------------------------------------------------------------------------",
"$",
"oDb",
"->",
"set",
"(",
"$",
"hitData",
")",
";",
"if",
"(",
"$",
"oDb",
"->",
"insert",
"(",
"$",
"this",
"->",
"tableHit",
")",
")",
"{",
"return",
"true",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"setError",
"(",
"'Failed to add hit.'",
")",
";",
"return",
"false",
";",
"}",
"}"
] | Add a hit to a post
@param int $id The post's ID
@param array $data Details about the hit | [
"Add",
"a",
"hit",
"to",
"a",
"post"
] | 7b369c5209f4343fff7c7e2a22c237d5a95c8c24 | https://github.com/nails/module-blog/blob/7b369c5209f4343fff7c7e2a22c237d5a95c8c24/blog/models/blog_post_model.php#L1248-L1298 | train |
nails/module-blog | blog/models/blog_post_model.php | NAILS_Blog_post_model.getTypes | public function getTypes()
{
$oDb = Factory::service('Database');
$oResult = $oDb->query('SHOW COLUMNS FROM `' . $this->table . '` LIKE "type"')->row();
$sTypes = $oResult->Type;
$sTypes = preg_replace('/enum\((.*)\)/', '$1', $sTypes);
$sTypes = str_replace("'", '', $sTypes);
$aTypes = explode(',', $sTypes);
$aOut = [];
foreach ($aTypes as $sType) {
$aOut[$sType] = ucwords(strtolower($sType));
}
return $aOut;
} | php | public function getTypes()
{
$oDb = Factory::service('Database');
$oResult = $oDb->query('SHOW COLUMNS FROM `' . $this->table . '` LIKE "type"')->row();
$sTypes = $oResult->Type;
$sTypes = preg_replace('/enum\((.*)\)/', '$1', $sTypes);
$sTypes = str_replace("'", '', $sTypes);
$aTypes = explode(',', $sTypes);
$aOut = [];
foreach ($aTypes as $sType) {
$aOut[$sType] = ucwords(strtolower($sType));
}
return $aOut;
} | [
"public",
"function",
"getTypes",
"(",
")",
"{",
"$",
"oDb",
"=",
"Factory",
"::",
"service",
"(",
"'Database'",
")",
";",
"$",
"oResult",
"=",
"$",
"oDb",
"->",
"query",
"(",
"'SHOW COLUMNS FROM `'",
".",
"$",
"this",
"->",
"table",
".",
"'` LIKE \"type\"'",
")",
"->",
"row",
"(",
")",
";",
"$",
"sTypes",
"=",
"$",
"oResult",
"->",
"Type",
";",
"$",
"sTypes",
"=",
"preg_replace",
"(",
"'/enum\\((.*)\\)/'",
",",
"'$1'",
",",
"$",
"sTypes",
")",
";",
"$",
"sTypes",
"=",
"str_replace",
"(",
"\"'\"",
",",
"''",
",",
"$",
"sTypes",
")",
";",
"$",
"aTypes",
"=",
"explode",
"(",
"','",
",",
"$",
"sTypes",
")",
";",
"$",
"aOut",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"aTypes",
"as",
"$",
"sType",
")",
"{",
"$",
"aOut",
"[",
"$",
"sType",
"]",
"=",
"ucwords",
"(",
"strtolower",
"(",
"$",
"sType",
")",
")",
";",
"}",
"return",
"$",
"aOut",
";",
"}"
] | Parses the `type` column and returns an array of potential post types
@return array | [
"Parses",
"the",
"type",
"column",
"and",
"returns",
"an",
"array",
"of",
"potential",
"post",
"types"
] | 7b369c5209f4343fff7c7e2a22c237d5a95c8c24 | https://github.com/nails/module-blog/blob/7b369c5209f4343fff7c7e2a22c237d5a95c8c24/blog/models/blog_post_model.php#L1306-L1322 | train |
nails/module-blog | blog/models/blog_post_model.php | NAILS_Blog_post_model.formatUrl | public function formatUrl($slug, $blogId)
{
$this->load->model('blog/blog_model');
return $this->blog_model->getBlogUrl($blogId) . '/' . $slug;
} | php | public function formatUrl($slug, $blogId)
{
$this->load->model('blog/blog_model');
return $this->blog_model->getBlogUrl($blogId) . '/' . $slug;
} | [
"public",
"function",
"formatUrl",
"(",
"$",
"slug",
",",
"$",
"blogId",
")",
"{",
"$",
"this",
"->",
"load",
"->",
"model",
"(",
"'blog/blog_model'",
")",
";",
"return",
"$",
"this",
"->",
"blog_model",
"->",
"getBlogUrl",
"(",
"$",
"blogId",
")",
".",
"'/'",
".",
"$",
"slug",
";",
"}"
] | Format a posts's URL
@param string $slug The post's slug
@param int $blogId The blog's ID
@return string | [
"Format",
"a",
"posts",
"s",
"URL"
] | 7b369c5209f4343fff7c7e2a22c237d5a95c8c24 | https://github.com/nails/module-blog/blob/7b369c5209f4343fff7c7e2a22c237d5a95c8c24/blog/models/blog_post_model.php#L1334-L1338 | train |
nails/module-blog | blog/models/blog_post_model.php | NAILS_Blog_post_model.extractYoutubeId | public function extractYoutubeId($sUrl)
{
preg_match('/^https?\:\/\/www\.youtube\.com\/watch\?v=([a-zA-Z0-9_\-]+)$/', $sUrl, $aMatches);
if (!empty($aMatches[1])) {
return $aMatches[1];
} else {
preg_match('/^https?\:\/\/youtu\.be\/([a-zA-Z0-9_\-]+)$/', $sUrl, $aMatches);
if (!empty($aMatches[1])) {
return $aMatches[1];
}
}
return null;
} | php | public function extractYoutubeId($sUrl)
{
preg_match('/^https?\:\/\/www\.youtube\.com\/watch\?v=([a-zA-Z0-9_\-]+)$/', $sUrl, $aMatches);
if (!empty($aMatches[1])) {
return $aMatches[1];
} else {
preg_match('/^https?\:\/\/youtu\.be\/([a-zA-Z0-9_\-]+)$/', $sUrl, $aMatches);
if (!empty($aMatches[1])) {
return $aMatches[1];
}
}
return null;
} | [
"public",
"function",
"extractYoutubeId",
"(",
"$",
"sUrl",
")",
"{",
"preg_match",
"(",
"'/^https?\\:\\/\\/www\\.youtube\\.com\\/watch\\?v=([a-zA-Z0-9_\\-]+)$/'",
",",
"$",
"sUrl",
",",
"$",
"aMatches",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"aMatches",
"[",
"1",
"]",
")",
")",
"{",
"return",
"$",
"aMatches",
"[",
"1",
"]",
";",
"}",
"else",
"{",
"preg_match",
"(",
"'/^https?\\:\\/\\/youtu\\.be\\/([a-zA-Z0-9_\\-]+)$/'",
",",
"$",
"sUrl",
",",
"$",
"aMatches",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"aMatches",
"[",
"1",
"]",
")",
")",
"{",
"return",
"$",
"aMatches",
"[",
"1",
"]",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Extracts the ID from a YouTube URL
@param string $sUrl The YouTube URL
@return string | [
"Extracts",
"the",
"ID",
"from",
"a",
"YouTube",
"URL"
] | 7b369c5209f4343fff7c7e2a22c237d5a95c8c24 | https://github.com/nails/module-blog/blob/7b369c5209f4343fff7c7e2a22c237d5a95c8c24/blog/models/blog_post_model.php#L1447-L1466 | train |
erenmustafaozdal/laravel-modules-base | src/Services/MailService.php | MailService.queue | public function queue()
{
$from = $this->fromEmail;
$to = $this->toEmail;
$name = $this->toName;
$subject = $this->subject;
$this->beauty->queue($this->view, $this->datas, function($message) use($from,$to,$name,$subject)
{
$message->from($from)
->to($to, $name)
->subject($subject);
});
} | php | public function queue()
{
$from = $this->fromEmail;
$to = $this->toEmail;
$name = $this->toName;
$subject = $this->subject;
$this->beauty->queue($this->view, $this->datas, function($message) use($from,$to,$name,$subject)
{
$message->from($from)
->to($to, $name)
->subject($subject);
});
} | [
"public",
"function",
"queue",
"(",
")",
"{",
"$",
"from",
"=",
"$",
"this",
"->",
"fromEmail",
";",
"$",
"to",
"=",
"$",
"this",
"->",
"toEmail",
";",
"$",
"name",
"=",
"$",
"this",
"->",
"toName",
";",
"$",
"subject",
"=",
"$",
"this",
"->",
"subject",
";",
"$",
"this",
"->",
"beauty",
"->",
"queue",
"(",
"$",
"this",
"->",
"view",
",",
"$",
"this",
"->",
"datas",
",",
"function",
"(",
"$",
"message",
")",
"use",
"(",
"$",
"from",
",",
"$",
"to",
",",
"$",
"name",
",",
"$",
"subject",
")",
"{",
"$",
"message",
"->",
"from",
"(",
"$",
"from",
")",
"->",
"to",
"(",
"$",
"to",
",",
"$",
"name",
")",
"->",
"subject",
"(",
"$",
"subject",
")",
";",
"}",
")",
";",
"}"
] | send queue mail | [
"send",
"queue",
"mail"
] | c26600543817642926bcf16ada84009e00d784e0 | https://github.com/erenmustafaozdal/laravel-modules-base/blob/c26600543817642926bcf16ada84009e00d784e0/src/Services/MailService.php#L73-L85 | train |
erenmustafaozdal/laravel-modules-base | src/Services/MailService.php | MailService.handlerOptions | public function handlerOptions()
{
$this->fromEmail = config('mail.from.address');
$this->toEmail = config('laravel-modules-base.developer_mail');
$this->toName = config('laravel-modules-base.developer_name');
$this->subject = trans('laravel-modules-base::admin.email.error.subject');
$this->view = 'laravel-modules-base::emails.error';
} | php | public function handlerOptions()
{
$this->fromEmail = config('mail.from.address');
$this->toEmail = config('laravel-modules-base.developer_mail');
$this->toName = config('laravel-modules-base.developer_name');
$this->subject = trans('laravel-modules-base::admin.email.error.subject');
$this->view = 'laravel-modules-base::emails.error';
} | [
"public",
"function",
"handlerOptions",
"(",
")",
"{",
"$",
"this",
"->",
"fromEmail",
"=",
"config",
"(",
"'mail.from.address'",
")",
";",
"$",
"this",
"->",
"toEmail",
"=",
"config",
"(",
"'laravel-modules-base.developer_mail'",
")",
";",
"$",
"this",
"->",
"toName",
"=",
"config",
"(",
"'laravel-modules-base.developer_name'",
")",
";",
"$",
"this",
"->",
"subject",
"=",
"trans",
"(",
"'laravel-modules-base::admin.email.error.subject'",
")",
";",
"$",
"this",
"->",
"view",
"=",
"'laravel-modules-base::emails.error'",
";",
"}"
] | exception handler set options | [
"exception",
"handler",
"set",
"options"
] | c26600543817642926bcf16ada84009e00d784e0 | https://github.com/erenmustafaozdal/laravel-modules-base/blob/c26600543817642926bcf16ada84009e00d784e0/src/Services/MailService.php#L107-L114 | train |
Vectrex/vxPHP | src/File/UploadedFile.php | UploadedFile.move | public function move(FilesystemFolder $destination) {
if($this->alreadyUploaded) {
return parent::move($destination);
}
$oldpath = $this->folder->getPath() . $this->filename;
$filename = self::sanitizeFilename($this->originalName, $destination);
$newpath = $destination->getPath() . $filename;
// ensure that only uploaded files are handled
if(is_uploaded_file($oldpath)) {
// move uploaded file
if(@move_uploaded_file($oldpath, $newpath)) {
// flag completed upload
$this->alreadyUploaded = TRUE;
// set new folder reference
$this->folder = $destination;
// set new filename
$this->filename = $filename;
// re-read fileinfo
$this->fileInfo = new \SplFileInfo($newpath);
// set cached instance
self::$instances[$newpath] = $this;
// @todo: check necessity of chmod
@chmod($newpath, 0666 & ~umask());
}
else {
throw new FilesystemFileException(sprintf("Could not move uploaded file '%s' to '%s'.", $this->originalName, $newpath), FilesystemFileException::FILE_RENAME_FAILED);
}
}
else {
throw new FilesystemFileException(sprintf("File '%s' was not identified as uploaded file.", $oldpath));
}
return $this;
} | php | public function move(FilesystemFolder $destination) {
if($this->alreadyUploaded) {
return parent::move($destination);
}
$oldpath = $this->folder->getPath() . $this->filename;
$filename = self::sanitizeFilename($this->originalName, $destination);
$newpath = $destination->getPath() . $filename;
// ensure that only uploaded files are handled
if(is_uploaded_file($oldpath)) {
// move uploaded file
if(@move_uploaded_file($oldpath, $newpath)) {
// flag completed upload
$this->alreadyUploaded = TRUE;
// set new folder reference
$this->folder = $destination;
// set new filename
$this->filename = $filename;
// re-read fileinfo
$this->fileInfo = new \SplFileInfo($newpath);
// set cached instance
self::$instances[$newpath] = $this;
// @todo: check necessity of chmod
@chmod($newpath, 0666 & ~umask());
}
else {
throw new FilesystemFileException(sprintf("Could not move uploaded file '%s' to '%s'.", $this->originalName, $newpath), FilesystemFileException::FILE_RENAME_FAILED);
}
}
else {
throw new FilesystemFileException(sprintf("File '%s' was not identified as uploaded file.", $oldpath));
}
return $this;
} | [
"public",
"function",
"move",
"(",
"FilesystemFolder",
"$",
"destination",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"alreadyUploaded",
")",
"{",
"return",
"parent",
"::",
"move",
"(",
"$",
"destination",
")",
";",
"}",
"$",
"oldpath",
"=",
"$",
"this",
"->",
"folder",
"->",
"getPath",
"(",
")",
".",
"$",
"this",
"->",
"filename",
";",
"$",
"filename",
"=",
"self",
"::",
"sanitizeFilename",
"(",
"$",
"this",
"->",
"originalName",
",",
"$",
"destination",
")",
";",
"$",
"newpath",
"=",
"$",
"destination",
"->",
"getPath",
"(",
")",
".",
"$",
"filename",
";",
"// ensure that only uploaded files are handled",
"if",
"(",
"is_uploaded_file",
"(",
"$",
"oldpath",
")",
")",
"{",
"// move uploaded file",
"if",
"(",
"@",
"move_uploaded_file",
"(",
"$",
"oldpath",
",",
"$",
"newpath",
")",
")",
"{",
"// flag completed upload",
"$",
"this",
"->",
"alreadyUploaded",
"=",
"TRUE",
";",
"// set new folder reference",
"$",
"this",
"->",
"folder",
"=",
"$",
"destination",
";",
"// set new filename",
"$",
"this",
"->",
"filename",
"=",
"$",
"filename",
";",
"// re-read fileinfo",
"$",
"this",
"->",
"fileInfo",
"=",
"new",
"\\",
"SplFileInfo",
"(",
"$",
"newpath",
")",
";",
"// set cached instance",
"self",
"::",
"$",
"instances",
"[",
"$",
"newpath",
"]",
"=",
"$",
"this",
";",
"// @todo: check necessity of chmod",
"@",
"chmod",
"(",
"$",
"newpath",
",",
"0666",
"&",
"~",
"umask",
"(",
")",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"FilesystemFileException",
"(",
"sprintf",
"(",
"\"Could not move uploaded file '%s' to '%s'.\"",
",",
"$",
"this",
"->",
"originalName",
",",
"$",
"newpath",
")",
",",
"FilesystemFileException",
"::",
"FILE_RENAME_FAILED",
")",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"FilesystemFileException",
"(",
"sprintf",
"(",
"\"File '%s' was not identified as uploaded file.\"",
",",
"$",
"oldpath",
")",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | performs an initial move of an uploaded file
from its temporary folder to a destination folder
and renames it to the original filename
once completed a flag is set and subsequent
moves are redirected to the parent method
(non-PHPdoc)
@see \vxPHP\File\FilesystemFile::move() | [
"performs",
"an",
"initial",
"move",
"of",
"an",
"uploaded",
"file",
"from",
"its",
"temporary",
"folder",
"to",
"a",
"destination",
"folder",
"and",
"renames",
"it",
"to",
"the",
"original",
"filename",
"once",
"completed",
"a",
"flag",
"is",
"set",
"and",
"subsequent",
"moves",
"are",
"redirected",
"to",
"the",
"parent",
"method"
] | 295c21b00e7ef6085efcdf5b64fabb28d499b5a6 | https://github.com/Vectrex/vxPHP/blob/295c21b00e7ef6085efcdf5b64fabb28d499b5a6/src/File/UploadedFile.php#L87-L143 | train |
danielgp/common-lib | source/MySQLiByDanielGPstructures.php | MySQLiByDanielGPstructures.getFieldNameForDisplay | protected function getFieldNameForDisplay($details)
{
$tableUniqueId = $details['TABLE_SCHEMA'] . '.' . $details['TABLE_NAME'];
if ($details['COLUMN_COMMENT'] != '') {
return $details['COLUMN_COMMENT'];
} elseif (isset($this->advCache['tableStructureLocales'][$tableUniqueId][$details['COLUMN_NAME']])) {
return $this->advCache['tableStructureLocales'][$tableUniqueId][$details['COLUMN_NAME']];
}
return $details['COLUMN_NAME'];
} | php | protected function getFieldNameForDisplay($details)
{
$tableUniqueId = $details['TABLE_SCHEMA'] . '.' . $details['TABLE_NAME'];
if ($details['COLUMN_COMMENT'] != '') {
return $details['COLUMN_COMMENT'];
} elseif (isset($this->advCache['tableStructureLocales'][$tableUniqueId][$details['COLUMN_NAME']])) {
return $this->advCache['tableStructureLocales'][$tableUniqueId][$details['COLUMN_NAME']];
}
return $details['COLUMN_NAME'];
} | [
"protected",
"function",
"getFieldNameForDisplay",
"(",
"$",
"details",
")",
"{",
"$",
"tableUniqueId",
"=",
"$",
"details",
"[",
"'TABLE_SCHEMA'",
"]",
".",
"'.'",
".",
"$",
"details",
"[",
"'TABLE_NAME'",
"]",
";",
"if",
"(",
"$",
"details",
"[",
"'COLUMN_COMMENT'",
"]",
"!=",
"''",
")",
"{",
"return",
"$",
"details",
"[",
"'COLUMN_COMMENT'",
"]",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"this",
"->",
"advCache",
"[",
"'tableStructureLocales'",
"]",
"[",
"$",
"tableUniqueId",
"]",
"[",
"$",
"details",
"[",
"'COLUMN_NAME'",
"]",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"advCache",
"[",
"'tableStructureLocales'",
"]",
"[",
"$",
"tableUniqueId",
"]",
"[",
"$",
"details",
"[",
"'COLUMN_NAME'",
"]",
"]",
";",
"}",
"return",
"$",
"details",
"[",
"'COLUMN_NAME'",
"]",
";",
"}"
] | Returns the name of a field for displaying
@param array $details
@return string | [
"Returns",
"the",
"name",
"of",
"a",
"field",
"for",
"displaying"
] | 627b99b4408414c7cd21a6c8016f6468dc9216b2 | https://github.com/danielgp/common-lib/blob/627b99b4408414c7cd21a6c8016f6468dc9216b2/source/MySQLiByDanielGPstructures.php#L67-L76 | train |
danielgp/common-lib | source/MySQLiByDanielGPstructures.php | MySQLiByDanielGPstructures.getFieldOutputTextFK | protected function getFieldOutputTextFK($foreignKeysArray, $value, $iar)
{
$query = $this->sQueryGenericSelectKeyValue([
'`' . $value['COLUMN_NAME'] . '`',
$foreignKeysArray[$value['COLUMN_NAME']][2],
$foreignKeysArray[$value['COLUMN_NAME']][0]
]);
$inAdtnl = ['size' => 1];
if ($value['IS_NULLABLE'] == 'YES') {
$inAdtnl = array_merge($inAdtnl, ['include_null']);
}
if ($iar !== []) {
$inAdtnl = array_merge($inAdtnl, $iar);
}
$slct = [
'Options' => $this->setMySQLquery2Server($query, 'array_key_value')['result'],
'Value' => $this->getFieldValue($value),
];
return $this->setArrayToSelect($slct['Options'], $slct['Value'], $value['COLUMN_NAME'], $inAdtnl);
} | php | protected function getFieldOutputTextFK($foreignKeysArray, $value, $iar)
{
$query = $this->sQueryGenericSelectKeyValue([
'`' . $value['COLUMN_NAME'] . '`',
$foreignKeysArray[$value['COLUMN_NAME']][2],
$foreignKeysArray[$value['COLUMN_NAME']][0]
]);
$inAdtnl = ['size' => 1];
if ($value['IS_NULLABLE'] == 'YES') {
$inAdtnl = array_merge($inAdtnl, ['include_null']);
}
if ($iar !== []) {
$inAdtnl = array_merge($inAdtnl, $iar);
}
$slct = [
'Options' => $this->setMySQLquery2Server($query, 'array_key_value')['result'],
'Value' => $this->getFieldValue($value),
];
return $this->setArrayToSelect($slct['Options'], $slct['Value'], $value['COLUMN_NAME'], $inAdtnl);
} | [
"protected",
"function",
"getFieldOutputTextFK",
"(",
"$",
"foreignKeysArray",
",",
"$",
"value",
",",
"$",
"iar",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"sQueryGenericSelectKeyValue",
"(",
"[",
"'`'",
".",
"$",
"value",
"[",
"'COLUMN_NAME'",
"]",
".",
"'`'",
",",
"$",
"foreignKeysArray",
"[",
"$",
"value",
"[",
"'COLUMN_NAME'",
"]",
"]",
"[",
"2",
"]",
",",
"$",
"foreignKeysArray",
"[",
"$",
"value",
"[",
"'COLUMN_NAME'",
"]",
"]",
"[",
"0",
"]",
"]",
")",
";",
"$",
"inAdtnl",
"=",
"[",
"'size'",
"=>",
"1",
"]",
";",
"if",
"(",
"$",
"value",
"[",
"'IS_NULLABLE'",
"]",
"==",
"'YES'",
")",
"{",
"$",
"inAdtnl",
"=",
"array_merge",
"(",
"$",
"inAdtnl",
",",
"[",
"'include_null'",
"]",
")",
";",
"}",
"if",
"(",
"$",
"iar",
"!==",
"[",
"]",
")",
"{",
"$",
"inAdtnl",
"=",
"array_merge",
"(",
"$",
"inAdtnl",
",",
"$",
"iar",
")",
";",
"}",
"$",
"slct",
"=",
"[",
"'Options'",
"=>",
"$",
"this",
"->",
"setMySQLquery2Server",
"(",
"$",
"query",
",",
"'array_key_value'",
")",
"[",
"'result'",
"]",
",",
"'Value'",
"=>",
"$",
"this",
"->",
"getFieldValue",
"(",
"$",
"value",
")",
",",
"]",
";",
"return",
"$",
"this",
"->",
"setArrayToSelect",
"(",
"$",
"slct",
"[",
"'Options'",
"]",
",",
"$",
"slct",
"[",
"'Value'",
"]",
",",
"$",
"value",
"[",
"'COLUMN_NAME'",
"]",
",",
"$",
"inAdtnl",
")",
";",
"}"
] | Prepares the output of text fields defined w. FKs
@param array $foreignKeysArray
@param array $value
@param array $iar
@return string | [
"Prepares",
"the",
"output",
"of",
"text",
"fields",
"defined",
"w",
".",
"FKs"
] | 627b99b4408414c7cd21a6c8016f6468dc9216b2 | https://github.com/danielgp/common-lib/blob/627b99b4408414c7cd21a6c8016f6468dc9216b2/source/MySQLiByDanielGPstructures.php#L86-L105 | train |
danielgp/common-lib | source/MySQLiByDanielGPstructures.php | MySQLiByDanielGPstructures.getRowDataFromTable | protected function getRowDataFromTable($tableName, $filtersArray)
{
$query = $this->sQueryRowsFromTable([$tableName, $this->setArrayToFilterValues($filtersArray)]);
$rawData = $this->setMySQLquery2Server($query, 'array_pairs_key_value')['result'];
if (!is_null($rawData)) {
$this->initializeSprGlbAndSession();
foreach ($rawData as $key => $value) {
$vToSet = str_replace(['\\\\"', '\\"', "\\\\'", "\\'"], ['"', '"', "'", "'"], $value);
$this->tCmnRequest->request->set($key, $vToSet);
}
}
} | php | protected function getRowDataFromTable($tableName, $filtersArray)
{
$query = $this->sQueryRowsFromTable([$tableName, $this->setArrayToFilterValues($filtersArray)]);
$rawData = $this->setMySQLquery2Server($query, 'array_pairs_key_value')['result'];
if (!is_null($rawData)) {
$this->initializeSprGlbAndSession();
foreach ($rawData as $key => $value) {
$vToSet = str_replace(['\\\\"', '\\"', "\\\\'", "\\'"], ['"', '"', "'", "'"], $value);
$this->tCmnRequest->request->set($key, $vToSet);
}
}
} | [
"protected",
"function",
"getRowDataFromTable",
"(",
"$",
"tableName",
",",
"$",
"filtersArray",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"sQueryRowsFromTable",
"(",
"[",
"$",
"tableName",
",",
"$",
"this",
"->",
"setArrayToFilterValues",
"(",
"$",
"filtersArray",
")",
"]",
")",
";",
"$",
"rawData",
"=",
"$",
"this",
"->",
"setMySQLquery2Server",
"(",
"$",
"query",
",",
"'array_pairs_key_value'",
")",
"[",
"'result'",
"]",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"rawData",
")",
")",
"{",
"$",
"this",
"->",
"initializeSprGlbAndSession",
"(",
")",
";",
"foreach",
"(",
"$",
"rawData",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"vToSet",
"=",
"str_replace",
"(",
"[",
"'\\\\\\\\\"'",
",",
"'\\\\\"'",
",",
"\"\\\\\\\\'\"",
",",
"\"\\\\'\"",
"]",
",",
"[",
"'\"'",
",",
"'\"'",
",",
"\"'\"",
",",
"\"'\"",
"]",
",",
"$",
"value",
")",
";",
"$",
"this",
"->",
"tCmnRequest",
"->",
"request",
"->",
"set",
"(",
"$",
"key",
",",
"$",
"vToSet",
")",
";",
"}",
"}",
"}"
] | Reads data from table into REQUEST super global
@param string $tableName
@param array $filtersArray | [
"Reads",
"data",
"from",
"table",
"into",
"REQUEST",
"super",
"global"
] | 627b99b4408414c7cd21a6c8016f6468dc9216b2 | https://github.com/danielgp/common-lib/blob/627b99b4408414c7cd21a6c8016f6468dc9216b2/source/MySQLiByDanielGPstructures.php#L279-L290 | train |
danielgp/common-lib | source/MySQLiByDanielGPstructures.php | MySQLiByDanielGPstructures.setArrayToFilterValues | private function setArrayToFilterValues($entryArray, $referenceTable = '')
{
$filters = [];
$refTable = $this->correctTableWithQuotesAsFieldPrefix($referenceTable);
foreach ($entryArray as $key => $value) {
if (is_array($value)) {
$filters[] = $this->setArrayLineArrayToFilter($key, $value, $refTable);
} elseif (!in_array($value, ['', '%%'])) {
$filters[] = $this->setArrayLineToFilter($key, $value);
}
}
return implode(' AND ', array_diff($filters, ['']));
} | php | private function setArrayToFilterValues($entryArray, $referenceTable = '')
{
$filters = [];
$refTable = $this->correctTableWithQuotesAsFieldPrefix($referenceTable);
foreach ($entryArray as $key => $value) {
if (is_array($value)) {
$filters[] = $this->setArrayLineArrayToFilter($key, $value, $refTable);
} elseif (!in_array($value, ['', '%%'])) {
$filters[] = $this->setArrayLineToFilter($key, $value);
}
}
return implode(' AND ', array_diff($filters, ['']));
} | [
"private",
"function",
"setArrayToFilterValues",
"(",
"$",
"entryArray",
",",
"$",
"referenceTable",
"=",
"''",
")",
"{",
"$",
"filters",
"=",
"[",
"]",
";",
"$",
"refTable",
"=",
"$",
"this",
"->",
"correctTableWithQuotesAsFieldPrefix",
"(",
"$",
"referenceTable",
")",
";",
"foreach",
"(",
"$",
"entryArray",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"filters",
"[",
"]",
"=",
"$",
"this",
"->",
"setArrayLineArrayToFilter",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"refTable",
")",
";",
"}",
"elseif",
"(",
"!",
"in_array",
"(",
"$",
"value",
",",
"[",
"''",
",",
"'%%'",
"]",
")",
")",
"{",
"$",
"filters",
"[",
"]",
"=",
"$",
"this",
"->",
"setArrayLineToFilter",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"}",
"return",
"implode",
"(",
"' AND '",
",",
"array_diff",
"(",
"$",
"filters",
",",
"[",
"''",
"]",
")",
")",
";",
"}"
] | Transforms an array into usable filters
@param array $entryArray
@param string $referenceTable
@return string | [
"Transforms",
"an",
"array",
"into",
"usable",
"filters"
] | 627b99b4408414c7cd21a6c8016f6468dc9216b2 | https://github.com/danielgp/common-lib/blob/627b99b4408414c7cd21a6c8016f6468dc9216b2/source/MySQLiByDanielGPstructures.php#L299-L311 | train |
t3v/t3v_core | Classes/Utility/StringUtility.php | StringUtility.asciify | public static function asciify(string $input, string $language = 'en', bool $removeUnsupported = true): string {
$output = S::toAscii($input, $language, $removeUnsupported);
return $output;
} | php | public static function asciify(string $input, string $language = 'en', bool $removeUnsupported = true): string {
$output = S::toAscii($input, $language, $removeUnsupported);
return $output;
} | [
"public",
"static",
"function",
"asciify",
"(",
"string",
"$",
"input",
",",
"string",
"$",
"language",
"=",
"'en'",
",",
"bool",
"$",
"removeUnsupported",
"=",
"true",
")",
":",
"string",
"{",
"$",
"output",
"=",
"S",
"::",
"toAscii",
"(",
"$",
"input",
",",
"$",
"language",
",",
"$",
"removeUnsupported",
")",
";",
"return",
"$",
"output",
";",
"}"
] | Returns an ASCII version of the input.
@param string $input The input
@param string $language The optional language, defaults to `en`
@param bool $removeUnsupported Remove unsupported characters , defaults to `true`
@return string The asciified input | [
"Returns",
"an",
"ASCII",
"version",
"of",
"the",
"input",
"."
] | 8c04b7688cc2773f11fcc87fda3f7cd53d80a980 | https://github.com/t3v/t3v_core/blob/8c04b7688cc2773f11fcc87fda3f7cd53d80a980/Classes/Utility/StringUtility.php#L20-L24 | train |
t3v/t3v_core | Classes/Utility/StringUtility.php | StringUtility.camelize | public static function camelize(string $input, string $separator = '_', bool $capitalizeFirstCharacter = false): string {
$output = $input;
if (ctype_upper($output)) {
$output = mb_strtolower($output);
}
if (strpos($output, $separator) || strpos($output, ' ')) {
$output = mb_strtolower($input);
$output = str_replace(' ', '', ucwords(str_replace($separator, ' ', $output)));
}
if ($output[0] && !$capitalizeFirstCharacter) {
$output[0] = mb_strtolower($output[0]);
}
return $output;
} | php | public static function camelize(string $input, string $separator = '_', bool $capitalizeFirstCharacter = false): string {
$output = $input;
if (ctype_upper($output)) {
$output = mb_strtolower($output);
}
if (strpos($output, $separator) || strpos($output, ' ')) {
$output = mb_strtolower($input);
$output = str_replace(' ', '', ucwords(str_replace($separator, ' ', $output)));
}
if ($output[0] && !$capitalizeFirstCharacter) {
$output[0] = mb_strtolower($output[0]);
}
return $output;
} | [
"public",
"static",
"function",
"camelize",
"(",
"string",
"$",
"input",
",",
"string",
"$",
"separator",
"=",
"'_'",
",",
"bool",
"$",
"capitalizeFirstCharacter",
"=",
"false",
")",
":",
"string",
"{",
"$",
"output",
"=",
"$",
"input",
";",
"if",
"(",
"ctype_upper",
"(",
"$",
"output",
")",
")",
"{",
"$",
"output",
"=",
"mb_strtolower",
"(",
"$",
"output",
")",
";",
"}",
"if",
"(",
"strpos",
"(",
"$",
"output",
",",
"$",
"separator",
")",
"||",
"strpos",
"(",
"$",
"output",
",",
"' '",
")",
")",
"{",
"$",
"output",
"=",
"mb_strtolower",
"(",
"$",
"input",
")",
";",
"$",
"output",
"=",
"str_replace",
"(",
"' '",
",",
"''",
",",
"ucwords",
"(",
"str_replace",
"(",
"$",
"separator",
",",
"' '",
",",
"$",
"output",
")",
")",
")",
";",
"}",
"if",
"(",
"$",
"output",
"[",
"0",
"]",
"&&",
"!",
"$",
"capitalizeFirstCharacter",
")",
"{",
"$",
"output",
"[",
"0",
"]",
"=",
"mb_strtolower",
"(",
"$",
"output",
"[",
"0",
"]",
")",
";",
"}",
"return",
"$",
"output",
";",
"}"
] | Camelizes an input.
@param string $input The input
@param string $separator The optional separator, defaults to `_`
@param bool $capitalizeFirstCharacter If the first character should be capitalized, defaults to `false`
@return string The camelized input | [
"Camelizes",
"an",
"input",
"."
] | 8c04b7688cc2773f11fcc87fda3f7cd53d80a980 | https://github.com/t3v/t3v_core/blob/8c04b7688cc2773f11fcc87fda3f7cd53d80a980/Classes/Utility/StringUtility.php#L34-L51 | train |
phpffcms/ffcms-core | src/Helper/Security.php | Security.secureHtml | public function secureHtml($data): ?string
{
return (Any::isArray($data) ? $this->purifier->purifyArray($data) : $this->purifier->purify($data));
} | php | public function secureHtml($data): ?string
{
return (Any::isArray($data) ? $this->purifier->purifyArray($data) : $this->purifier->purify($data));
} | [
"public",
"function",
"secureHtml",
"(",
"$",
"data",
")",
":",
"?",
"string",
"{",
"return",
"(",
"Any",
"::",
"isArray",
"(",
"$",
"data",
")",
"?",
"$",
"this",
"->",
"purifier",
"->",
"purifyArray",
"(",
"$",
"data",
")",
":",
"$",
"this",
"->",
"purifier",
"->",
"purify",
"(",
"$",
"data",
")",
")",
";",
"}"
] | Secure html code
@param string|array $data
@return string | [
"Secure",
"html",
"code"
] | 44a309553ef9f115ccfcfd71f2ac6e381c612082 | https://github.com/phpffcms/ffcms-core/blob/44a309553ef9f115ccfcfd71f2ac6e381c612082/src/Helper/Security.php#L40-L43 | train |
phpffcms/ffcms-core | src/Helper/Security.php | Security.strip_tags | public function strip_tags($html, $escapeQuotes = true)
{
// recursive usage
if (Any::isArray($html)) {
foreach ($html as $key=>$value) {
$html[$key] = $this->strip_tags($value, $escapeQuotes);
}
return $html;
}
$text = strip_tags($html);
if ($escapeQuotes) {
$text = $this->escapeQuotes($text);
}
return $text;
} | php | public function strip_tags($html, $escapeQuotes = true)
{
// recursive usage
if (Any::isArray($html)) {
foreach ($html as $key=>$value) {
$html[$key] = $this->strip_tags($value, $escapeQuotes);
}
return $html;
}
$text = strip_tags($html);
if ($escapeQuotes) {
$text = $this->escapeQuotes($text);
}
return $text;
} | [
"public",
"function",
"strip_tags",
"(",
"$",
"html",
",",
"$",
"escapeQuotes",
"=",
"true",
")",
"{",
"// recursive usage",
"if",
"(",
"Any",
"::",
"isArray",
"(",
"$",
"html",
")",
")",
"{",
"foreach",
"(",
"$",
"html",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"html",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"strip_tags",
"(",
"$",
"value",
",",
"$",
"escapeQuotes",
")",
";",
"}",
"return",
"$",
"html",
";",
"}",
"$",
"text",
"=",
"strip_tags",
"(",
"$",
"html",
")",
";",
"if",
"(",
"$",
"escapeQuotes",
")",
"{",
"$",
"text",
"=",
"$",
"this",
"->",
"escapeQuotes",
"(",
"$",
"text",
")",
";",
"}",
"return",
"$",
"text",
";",
"}"
] | String html tags and escape quotes
@param string|array $html
@param boolean $escapeQuotes
@return string|array|null | [
"String",
"html",
"tags",
"and",
"escape",
"quotes"
] | 44a309553ef9f115ccfcfd71f2ac6e381c612082 | https://github.com/phpffcms/ffcms-core/blob/44a309553ef9f115ccfcfd71f2ac6e381c612082/src/Helper/Security.php#L51-L67 | train |
phpffcms/ffcms-core | src/Helper/Security.php | Security.strip_php_tags | public function strip_php_tags($data)
{
if (is_array($data)) {
foreach ($data as $key=>$value) {
$data[$key] = $this->strip_php_tags($value);
}
return $data;
}
return addslashes(htmlspecialchars(strip_tags($data)));
} | php | public function strip_php_tags($data)
{
if (is_array($data)) {
foreach ($data as $key=>$value) {
$data[$key] = $this->strip_php_tags($value);
}
return $data;
}
return addslashes(htmlspecialchars(strip_tags($data)));
} | [
"public",
"function",
"strip_php_tags",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"data",
")",
")",
"{",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"data",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"strip_php_tags",
"(",
"$",
"value",
")",
";",
"}",
"return",
"$",
"data",
";",
"}",
"return",
"addslashes",
"(",
"htmlspecialchars",
"(",
"strip_tags",
"(",
"$",
"data",
")",
")",
")",
";",
"}"
] | Strip php tags and notations in string.
@param array|string $data
@return array|null|string | [
"Strip",
"php",
"tags",
"and",
"notations",
"in",
"string",
"."
] | 44a309553ef9f115ccfcfd71f2ac6e381c612082 | https://github.com/phpffcms/ffcms-core/blob/44a309553ef9f115ccfcfd71f2ac6e381c612082/src/Helper/Security.php#L74-L83 | train |
sil-project/VarietyBundle | src/Entity/Genus.php | Genus.setFamily | public function setFamily(\Librinfo\VarietiesBundle\Entity\Family $family = null)
{
$this->family = $family;
return $this;
} | php | public function setFamily(\Librinfo\VarietiesBundle\Entity\Family $family = null)
{
$this->family = $family;
return $this;
} | [
"public",
"function",
"setFamily",
"(",
"\\",
"Librinfo",
"\\",
"VarietiesBundle",
"\\",
"Entity",
"\\",
"Family",
"$",
"family",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"family",
"=",
"$",
"family",
";",
"return",
"$",
"this",
";",
"}"
] | Set family.
@param \Librinfo\VarietiesBundle\Entity\Family $family
@return Genus | [
"Set",
"family",
"."
] | e9508ce13a4bb277d10bdcd925fdb84bc01f453f | https://github.com/sil-project/VarietyBundle/blob/e9508ce13a4bb277d10bdcd925fdb84bc01f453f/src/Entity/Genus.php#L129-L134 | train |
sil-project/VarietyBundle | src/Entity/Genus.php | Genus.addSpeciese | public function addSpeciese(\Librinfo\VarietiesBundle\Entity\Species $species)
{
$species->setGenus($this);
$this->specieses->add($species);
return $this;
} | php | public function addSpeciese(\Librinfo\VarietiesBundle\Entity\Species $species)
{
$species->setGenus($this);
$this->specieses->add($species);
return $this;
} | [
"public",
"function",
"addSpeciese",
"(",
"\\",
"Librinfo",
"\\",
"VarietiesBundle",
"\\",
"Entity",
"\\",
"Species",
"$",
"species",
")",
"{",
"$",
"species",
"->",
"setGenus",
"(",
"$",
"this",
")",
";",
"$",
"this",
"->",
"specieses",
"->",
"add",
"(",
"$",
"species",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Alias for addSpecies.
@param \Librinfo\VarietiesBundle\Entity\Species $species
@return \Librinfo\VarietiesBundle\Entity\Genus | [
"Alias",
"for",
"addSpecies",
"."
] | e9508ce13a4bb277d10bdcd925fdb84bc01f453f | https://github.com/sil-project/VarietyBundle/blob/e9508ce13a4bb277d10bdcd925fdb84bc01f453f/src/Entity/Genus.php#L153-L159 | train |
sil-project/VarietyBundle | src/Entity/Genus.php | Genus.removeSpecies | public function removeSpecies(\Librinfo\VarietiesBundle\Entity\Species $species)
{
return $this->specieses->removeElement($species);
} | php | public function removeSpecies(\Librinfo\VarietiesBundle\Entity\Species $species)
{
return $this->specieses->removeElement($species);
} | [
"public",
"function",
"removeSpecies",
"(",
"\\",
"Librinfo",
"\\",
"VarietiesBundle",
"\\",
"Entity",
"\\",
"Species",
"$",
"species",
")",
"{",
"return",
"$",
"this",
"->",
"specieses",
"->",
"removeElement",
"(",
"$",
"species",
")",
";",
"}"
] | Remove speciese.
@param \Librinfo\VarietiesBundle\Entity\Species $species
@return bool tRUE if this collection contained the specified element, FALSE otherwise | [
"Remove",
"speciese",
"."
] | e9508ce13a4bb277d10bdcd925fdb84bc01f453f | https://github.com/sil-project/VarietyBundle/blob/e9508ce13a4bb277d10bdcd925fdb84bc01f453f/src/Entity/Genus.php#L183-L186 | train |
PenoaksDev/Milky-Framework | src/Milky/Http/Routing/RouteDependencyResolverTrait.php | RouteDependencyResolverTrait.resolveClassMethodDependencies | protected function resolveClassMethodDependencies( array $parameters, $instance, $method )
{
if ( !method_exists( $instance, $method ) )
return $parameters;
return $this->resolveMethodDependencies( $parameters, new ReflectionMethod( $instance, $method ) );
} | php | protected function resolveClassMethodDependencies( array $parameters, $instance, $method )
{
if ( !method_exists( $instance, $method ) )
return $parameters;
return $this->resolveMethodDependencies( $parameters, new ReflectionMethod( $instance, $method ) );
} | [
"protected",
"function",
"resolveClassMethodDependencies",
"(",
"array",
"$",
"parameters",
",",
"$",
"instance",
",",
"$",
"method",
")",
"{",
"if",
"(",
"!",
"method_exists",
"(",
"$",
"instance",
",",
"$",
"method",
")",
")",
"return",
"$",
"parameters",
";",
"return",
"$",
"this",
"->",
"resolveMethodDependencies",
"(",
"$",
"parameters",
",",
"new",
"ReflectionMethod",
"(",
"$",
"instance",
",",
"$",
"method",
")",
")",
";",
"}"
] | Resolve the object method's type-hinted dependencies.
@param array $parameters
@param object $instance
@param string $method
@return array | [
"Resolve",
"the",
"object",
"method",
"s",
"type",
"-",
"hinted",
"dependencies",
"."
] | 8afd7156610a70371aa5b1df50b8a212bf7b142c | https://github.com/PenoaksDev/Milky-Framework/blob/8afd7156610a70371aa5b1df50b8a212bf7b142c/src/Milky/Http/Routing/RouteDependencyResolverTrait.php#L34-L40 | train |
Wedeto/HTTP | src/Cookie.php | Cookie.setURL | public function setURL(URL $url)
{
$this->domain = $url->host;
$this->path = $url->path;
$this->secure = $url->secure;
return $this;
} | php | public function setURL(URL $url)
{
$this->domain = $url->host;
$this->path = $url->path;
$this->secure = $url->secure;
return $this;
} | [
"public",
"function",
"setURL",
"(",
"URL",
"$",
"url",
")",
"{",
"$",
"this",
"->",
"domain",
"=",
"$",
"url",
"->",
"host",
";",
"$",
"this",
"->",
"path",
"=",
"$",
"url",
"->",
"path",
";",
"$",
"this",
"->",
"secure",
"=",
"$",
"url",
"->",
"secure",
";",
"return",
"$",
"this",
";",
"}"
] | Set the domain and path using a URL
@param Wedeto\HTTP\URL The URI to use as the cookie domain | [
"Set",
"the",
"domain",
"and",
"path",
"using",
"a",
"URL"
] | 7318eff1b81a3c103c4263466d09b7f3593b70b9 | https://github.com/Wedeto/HTTP/blob/7318eff1b81a3c103c4263466d09b7f3593b70b9/src/Cookie.php#L174-L180 | train |
Wedeto/HTTP | src/Cookie.php | Cookie.setExpiresIn | public function setExpiresIn(DateInterval $interval)
{
$this->expires = new DateTime();
$this->expires->add($interval);
return $this;
} | php | public function setExpiresIn(DateInterval $interval)
{
$this->expires = new DateTime();
$this->expires->add($interval);
return $this;
} | [
"public",
"function",
"setExpiresIn",
"(",
"DateInterval",
"$",
"interval",
")",
"{",
"$",
"this",
"->",
"expires",
"=",
"new",
"DateTime",
"(",
")",
";",
"$",
"this",
"->",
"expires",
"->",
"add",
"(",
"$",
"interval",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Set expiry date by a DateInterval, relative to the current time
@param DateInterval $interval After how much time the cookie should expire
@return Wedeto\HTTP\Cookie Provides fluent interface | [
"Set",
"expiry",
"date",
"by",
"a",
"DateInterval",
"relative",
"to",
"the",
"current",
"time"
] | 7318eff1b81a3c103c4263466d09b7f3593b70b9 | https://github.com/Wedeto/HTTP/blob/7318eff1b81a3c103c4263466d09b7f3593b70b9/src/Cookie.php#L214-L219 | train |
squareproton/Bond | src/Bond/Normality/Builder/EntityChild.php | EntityChild.getClassExtends | protected function getClassExtends()
{
$parentPlaceholderClass = sprintf(
"\\%s\\%s",
$this->options['entityPlaceholder'],
$this->pgClass->getParent()->getEntityName()
);
$this->class->addExtends($parentPlaceholderClass);
} | php | protected function getClassExtends()
{
$parentPlaceholderClass = sprintf(
"\\%s\\%s",
$this->options['entityPlaceholder'],
$this->pgClass->getParent()->getEntityName()
);
$this->class->addExtends($parentPlaceholderClass);
} | [
"protected",
"function",
"getClassExtends",
"(",
")",
"{",
"$",
"parentPlaceholderClass",
"=",
"sprintf",
"(",
"\"\\\\%s\\\\%s\"",
",",
"$",
"this",
"->",
"options",
"[",
"'entityPlaceholder'",
"]",
",",
"$",
"this",
"->",
"pgClass",
"->",
"getParent",
"(",
")",
"->",
"getEntityName",
"(",
")",
")",
";",
"$",
"this",
"->",
"class",
"->",
"addExtends",
"(",
"$",
"parentPlaceholderClass",
")",
";",
"}"
] | Get class extends | [
"Get",
"class",
"extends"
] | a04ad9dd1a35adeaec98237716c2a41ce02b4f1a | https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Normality/Builder/EntityChild.php#L34-L42 | train |
duncan3dc/serial | src/Php.php | Php.encode | public static function encode($array)
{
$array = static::asArray($array);
if (is_array($array) && count($array) < 1) {
return "";
}
try {
$string = serialize($array);
} catch (\Exception $e) {
throw new PhpException("Serialize Error: " . $e->getMessage());
}
return $string;
} | php | public static function encode($array)
{
$array = static::asArray($array);
if (is_array($array) && count($array) < 1) {
return "";
}
try {
$string = serialize($array);
} catch (\Exception $e) {
throw new PhpException("Serialize Error: " . $e->getMessage());
}
return $string;
} | [
"public",
"static",
"function",
"encode",
"(",
"$",
"array",
")",
"{",
"$",
"array",
"=",
"static",
"::",
"asArray",
"(",
"$",
"array",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"array",
")",
"&&",
"count",
"(",
"$",
"array",
")",
"<",
"1",
")",
"{",
"return",
"\"\"",
";",
"}",
"try",
"{",
"$",
"string",
"=",
"serialize",
"(",
"$",
"array",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"PhpException",
"(",
"\"Serialize Error: \"",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"return",
"$",
"string",
";",
"}"
] | Convert an array to a php serialized string.
{@inheritDoc} | [
"Convert",
"an",
"array",
"to",
"a",
"php",
"serialized",
"string",
"."
] | 2e40127a0a364ee1bd6f655b0f5b5d4a035a5716 | https://github.com/duncan3dc/serial/blob/2e40127a0a364ee1bd6f655b0f5b5d4a035a5716/src/Php.php#L15-L30 | train |
duncan3dc/serial | src/Php.php | Php.decode | public static function decode($string)
{
if (!$string) {
return new ArrayObject();
}
try {
$array = unserialize($string);
} catch (\Exception $e) {
throw new PhpException("Serialize Error: " . $e->getMessage());
}
if (!is_array($array)) {
$array = [];
}
return ArrayObject::make($array);
} | php | public static function decode($string)
{
if (!$string) {
return new ArrayObject();
}
try {
$array = unserialize($string);
} catch (\Exception $e) {
throw new PhpException("Serialize Error: " . $e->getMessage());
}
if (!is_array($array)) {
$array = [];
}
return ArrayObject::make($array);
} | [
"public",
"static",
"function",
"decode",
"(",
"$",
"string",
")",
"{",
"if",
"(",
"!",
"$",
"string",
")",
"{",
"return",
"new",
"ArrayObject",
"(",
")",
";",
"}",
"try",
"{",
"$",
"array",
"=",
"unserialize",
"(",
"$",
"string",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"PhpException",
"(",
"\"Serialize Error: \"",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"if",
"(",
"!",
"is_array",
"(",
"$",
"array",
")",
")",
"{",
"$",
"array",
"=",
"[",
"]",
";",
"}",
"return",
"ArrayObject",
"::",
"make",
"(",
"$",
"array",
")",
";",
"}"
] | Convert a php serialized string to an array.
{@inheritDoc} | [
"Convert",
"a",
"php",
"serialized",
"string",
"to",
"an",
"array",
"."
] | 2e40127a0a364ee1bd6f655b0f5b5d4a035a5716 | https://github.com/duncan3dc/serial/blob/2e40127a0a364ee1bd6f655b0f5b5d4a035a5716/src/Php.php#L38-L55 | train |
agentmedia/phine-core | src/Core/Logic/Routing/BackendRouter.php | BackendRouter.ModuleUrl | static function ModuleUrl(BackendModule $module, array $args = array())
{
$allArgs = array('module'=> ClassFinder::ModuleType($module)) + $args;
return 'index.php?' . http_build_query($allArgs);
} | php | static function ModuleUrl(BackendModule $module, array $args = array())
{
$allArgs = array('module'=> ClassFinder::ModuleType($module)) + $args;
return 'index.php?' . http_build_query($allArgs);
} | [
"static",
"function",
"ModuleUrl",
"(",
"BackendModule",
"$",
"module",
",",
"array",
"$",
"args",
"=",
"array",
"(",
")",
")",
"{",
"$",
"allArgs",
"=",
"array",
"(",
"'module'",
"=>",
"ClassFinder",
"::",
"ModuleType",
"(",
"$",
"module",
")",
")",
"+",
"$",
"args",
";",
"return",
"'index.php?'",
".",
"http_build_query",
"(",
"$",
"allArgs",
")",
";",
"}"
] | Gets the url for a module
@param BackendModule $module The module
@param array $args
@return string | [
"Gets",
"the",
"url",
"for",
"a",
"module"
] | 38c1be8d03ebffae950d00a96da3c612aff67832 | https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Logic/Routing/BackendRouter.php#L21-L25 | train |
agentmedia/phine-core | src/Core/Logic/Routing/BackendRouter.php | BackendRouter.AjaxUrl | static function AjaxUrl(ModuleBase $module, array $args = array())
{
$allArgs = array('module'=> ClassFinder::ModuleType($module)) + $args;
$guard = new UserGuard();
$user = $guard->GetUser();
if (!$user)
{
throw new \Exception('Security breach on ajax url: no backend user logged in');
}
$allArgs['__backendUser'] = $user->GetID();
return 'ajax.php?' . http_build_query($allArgs);
} | php | static function AjaxUrl(ModuleBase $module, array $args = array())
{
$allArgs = array('module'=> ClassFinder::ModuleType($module)) + $args;
$guard = new UserGuard();
$user = $guard->GetUser();
if (!$user)
{
throw new \Exception('Security breach on ajax url: no backend user logged in');
}
$allArgs['__backendUser'] = $user->GetID();
return 'ajax.php?' . http_build_query($allArgs);
} | [
"static",
"function",
"AjaxUrl",
"(",
"ModuleBase",
"$",
"module",
",",
"array",
"$",
"args",
"=",
"array",
"(",
")",
")",
"{",
"$",
"allArgs",
"=",
"array",
"(",
"'module'",
"=>",
"ClassFinder",
"::",
"ModuleType",
"(",
"$",
"module",
")",
")",
"+",
"$",
"args",
";",
"$",
"guard",
"=",
"new",
"UserGuard",
"(",
")",
";",
"$",
"user",
"=",
"$",
"guard",
"->",
"GetUser",
"(",
")",
";",
"if",
"(",
"!",
"$",
"user",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Security breach on ajax url: no backend user logged in'",
")",
";",
"}",
"$",
"allArgs",
"[",
"'__backendUser'",
"]",
"=",
"$",
"user",
"->",
"GetID",
"(",
")",
";",
"return",
"'ajax.php?'",
".",
"http_build_query",
"(",
"$",
"allArgs",
")",
";",
"}"
] | Returns the url to ab ajax module whose content is rendered as is
@param ModuleBase $module The module
@param array $args The url parameters
@return string Returns the ajax url | [
"Returns",
"the",
"url",
"to",
"ab",
"ajax",
"module",
"whose",
"content",
"is",
"rendered",
"as",
"is"
] | 38c1be8d03ebffae950d00a96da3c612aff67832 | https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Logic/Routing/BackendRouter.php#L33-L44 | train |
agentmedia/phine-core | src/Core/Logic/Routing/BackendRouter.php | BackendRouter.ContentTreeUrl | static function ContentTreeUrl(Content $content)
{
$args = array();
$pageContent = $content->GetPageContent();
if ($pageContent)
{
$args['page'] = $pageContent->GetPage()->GetID();
$args['area'] = $pageContent->GetArea()->GetID();
return self::ModuleUrl(new \Phine\Bundles\Core\Modules\Backend\PageContentTree, $args);
}
$layoutContent = $content->GetLayoutContent();
if ($layoutContent)
{
$args['area'] = $layoutContent->GetArea()->GetID();
return self::ModuleUrl(new \Phine\Bundles\Core\Modules\Backend\LayoutContentTree, $args);
}
$containerContent = $content->GetContainerContent();
if($containerContent)
{
$args['container'] = $containerContent->GetContainer()->GetID();
return self::ModuleUrl(new \Phine\Bundles\Core\Modules\Backend\ContainerContentTree, $args);
}
} | php | static function ContentTreeUrl(Content $content)
{
$args = array();
$pageContent = $content->GetPageContent();
if ($pageContent)
{
$args['page'] = $pageContent->GetPage()->GetID();
$args['area'] = $pageContent->GetArea()->GetID();
return self::ModuleUrl(new \Phine\Bundles\Core\Modules\Backend\PageContentTree, $args);
}
$layoutContent = $content->GetLayoutContent();
if ($layoutContent)
{
$args['area'] = $layoutContent->GetArea()->GetID();
return self::ModuleUrl(new \Phine\Bundles\Core\Modules\Backend\LayoutContentTree, $args);
}
$containerContent = $content->GetContainerContent();
if($containerContent)
{
$args['container'] = $containerContent->GetContainer()->GetID();
return self::ModuleUrl(new \Phine\Bundles\Core\Modules\Backend\ContainerContentTree, $args);
}
} | [
"static",
"function",
"ContentTreeUrl",
"(",
"Content",
"$",
"content",
")",
"{",
"$",
"args",
"=",
"array",
"(",
")",
";",
"$",
"pageContent",
"=",
"$",
"content",
"->",
"GetPageContent",
"(",
")",
";",
"if",
"(",
"$",
"pageContent",
")",
"{",
"$",
"args",
"[",
"'page'",
"]",
"=",
"$",
"pageContent",
"->",
"GetPage",
"(",
")",
"->",
"GetID",
"(",
")",
";",
"$",
"args",
"[",
"'area'",
"]",
"=",
"$",
"pageContent",
"->",
"GetArea",
"(",
")",
"->",
"GetID",
"(",
")",
";",
"return",
"self",
"::",
"ModuleUrl",
"(",
"new",
"\\",
"Phine",
"\\",
"Bundles",
"\\",
"Core",
"\\",
"Modules",
"\\",
"Backend",
"\\",
"PageContentTree",
",",
"$",
"args",
")",
";",
"}",
"$",
"layoutContent",
"=",
"$",
"content",
"->",
"GetLayoutContent",
"(",
")",
";",
"if",
"(",
"$",
"layoutContent",
")",
"{",
"$",
"args",
"[",
"'area'",
"]",
"=",
"$",
"layoutContent",
"->",
"GetArea",
"(",
")",
"->",
"GetID",
"(",
")",
";",
"return",
"self",
"::",
"ModuleUrl",
"(",
"new",
"\\",
"Phine",
"\\",
"Bundles",
"\\",
"Core",
"\\",
"Modules",
"\\",
"Backend",
"\\",
"LayoutContentTree",
",",
"$",
"args",
")",
";",
"}",
"$",
"containerContent",
"=",
"$",
"content",
"->",
"GetContainerContent",
"(",
")",
";",
"if",
"(",
"$",
"containerContent",
")",
"{",
"$",
"args",
"[",
"'container'",
"]",
"=",
"$",
"containerContent",
"->",
"GetContainer",
"(",
")",
"->",
"GetID",
"(",
")",
";",
"return",
"self",
"::",
"ModuleUrl",
"(",
"new",
"\\",
"Phine",
"\\",
"Bundles",
"\\",
"Core",
"\\",
"Modules",
"\\",
"Backend",
"\\",
"ContainerContentTree",
",",
"$",
"args",
")",
";",
"}",
"}"
] | Gets the url of the content tree for a content element
@param Content $content
@return string | [
"Gets",
"the",
"url",
"of",
"the",
"content",
"tree",
"for",
"a",
"content",
"element"
] | 38c1be8d03ebffae950d00a96da3c612aff67832 | https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Logic/Routing/BackendRouter.php#L61-L83 | train |
bytic/orm | src/Traits/Relations/HasRelationsRecordsTrait.php | HasRelationsRecordsTrait.setRelation | public function setRelation($relation, $value)
{
$this->checkInitRelations();
$this->relations[$relation] = $value;
return $this;
} | php | public function setRelation($relation, $value)
{
$this->checkInitRelations();
$this->relations[$relation] = $value;
return $this;
} | [
"public",
"function",
"setRelation",
"(",
"$",
"relation",
",",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"checkInitRelations",
"(",
")",
";",
"$",
"this",
"->",
"relations",
"[",
"$",
"relation",
"]",
"=",
"$",
"value",
";",
"return",
"$",
"this",
";",
"}"
] | Set the specific relationship in the model.
@param string $relation
@param mixed $value
@return $this
@throws \Exception | [
"Set",
"the",
"specific",
"relationship",
"in",
"the",
"model",
"."
] | 8d9a79b47761af0bfd9b8d1d28c83221dcac0de0 | https://github.com/bytic/orm/blob/8d9a79b47761af0bfd9b8d1d28c83221dcac0de0/src/Traits/Relations/HasRelationsRecordsTrait.php#L233-L239 | train |
libreworks/caridea-dao | src/Doctrine2.php | Doctrine2.doExecute | protected function doExecute(\Closure $cb)
{
try {
return $cb($this->manager);
} catch (\Exception $e) {
throw Exception\Translator\Doctrine::translate($e);
}
} | php | protected function doExecute(\Closure $cb)
{
try {
return $cb($this->manager);
} catch (\Exception $e) {
throw Exception\Translator\Doctrine::translate($e);
}
} | [
"protected",
"function",
"doExecute",
"(",
"\\",
"Closure",
"$",
"cb",
")",
"{",
"try",
"{",
"return",
"$",
"cb",
"(",
"$",
"this",
"->",
"manager",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"Exception",
"\\",
"Translator",
"\\",
"Doctrine",
"::",
"translate",
"(",
"$",
"e",
")",
";",
"}",
"}"
] | Executes something in the context of the entityManager.
Exceptions are caught and translated.
@param Closure $cb The closure to execute, takes the entityManager
@return mixed whatever the function returns, this method also returns
@throws \Caridea\Dao\Exception If a database problem occurs
@see \Caridea\Dao\Exception\Translator\Doctrine | [
"Executes",
"something",
"in",
"the",
"context",
"of",
"the",
"entityManager",
"."
] | 22c2fc81f63050ad23f7b0c40e430ff026e1e767 | https://github.com/libreworks/caridea-dao/blob/22c2fc81f63050ad23f7b0c40e430ff026e1e767/src/Doctrine2.php#L71-L78 | train |
libreworks/caridea-dao | src/Doctrine2.php | Doctrine2.doExecuteInRepository | protected function doExecuteInRepository(\Closure $cb)
{
try {
return $cb($this->repository);
} catch (\Exception $e) {
throw Exception\Translator\Doctrine::translate($e);
}
} | php | protected function doExecuteInRepository(\Closure $cb)
{
try {
return $cb($this->repository);
} catch (\Exception $e) {
throw Exception\Translator\Doctrine::translate($e);
}
} | [
"protected",
"function",
"doExecuteInRepository",
"(",
"\\",
"Closure",
"$",
"cb",
")",
"{",
"try",
"{",
"return",
"$",
"cb",
"(",
"$",
"this",
"->",
"repository",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"Exception",
"\\",
"Translator",
"\\",
"Doctrine",
"::",
"translate",
"(",
"$",
"e",
")",
";",
"}",
"}"
] | Executes something in the context of the entityRepository.
Exceptions are caught and translated.
@param Closure $cb The closure to execute, takes the entityRepository
@return mixed whatever the function returns, this method also returns
@throws \Caridea\Dao\Exception If a database problem occurs
@see \Caridea\Dao\Exception\Translator\Doctrine | [
"Executes",
"something",
"in",
"the",
"context",
"of",
"the",
"entityRepository",
"."
] | 22c2fc81f63050ad23f7b0c40e430ff026e1e767 | https://github.com/libreworks/caridea-dao/blob/22c2fc81f63050ad23f7b0c40e430ff026e1e767/src/Doctrine2.php#L90-L97 | train |
TuumPHP/View | src/Section.php | Section.saveAs | public function saveAs($name)
{
$this->section_data[$name] = ob_get_clean();
$this->ob_level--;
if ($this->ob_level) {
echo $this->section_data[$name];
}
} | php | public function saveAs($name)
{
$this->section_data[$name] = ob_get_clean();
$this->ob_level--;
if ($this->ob_level) {
echo $this->section_data[$name];
}
} | [
"public",
"function",
"saveAs",
"(",
"$",
"name",
")",
"{",
"$",
"this",
"->",
"section_data",
"[",
"$",
"name",
"]",
"=",
"ob_get_clean",
"(",
")",
";",
"$",
"this",
"->",
"ob_level",
"--",
";",
"if",
"(",
"$",
"this",
"->",
"ob_level",
")",
"{",
"echo",
"$",
"this",
"->",
"section_data",
"[",
"$",
"name",
"]",
";",
"}",
"}"
] | end capture with name.
@param $name | [
"end",
"capture",
"with",
"name",
"."
] | b82b20d7b8ee66b2bdbe4eb0d95fabd9bafe4b21 | https://github.com/TuumPHP/View/blob/b82b20d7b8ee66b2bdbe4eb0d95fabd9bafe4b21/src/Section.php#L35-L42 | train |
zarathustra323/modlr-data | src/Zarathustra/ModlrData/Metadata/Cache/CacheWarmer.php | CacheWarmer.warm | public function warm()
{
$warmed = [];
if (false === $this->mf->hasCache()) {
return $warmed;
}
$this->clear();
foreach ($this->mf->getAllTypeNames() as $type) {
$metadata = $this->mf->getMetadataForType($type);
$warmed[] = $type;
}
return $warmed;
} | php | public function warm()
{
$warmed = [];
if (false === $this->mf->hasCache()) {
return $warmed;
}
$this->clear();
foreach ($this->mf->getAllTypeNames() as $type) {
$metadata = $this->mf->getMetadataForType($type);
$warmed[] = $type;
}
return $warmed;
} | [
"public",
"function",
"warm",
"(",
")",
"{",
"$",
"warmed",
"=",
"[",
"]",
";",
"if",
"(",
"false",
"===",
"$",
"this",
"->",
"mf",
"->",
"hasCache",
"(",
")",
")",
"{",
"return",
"$",
"warmed",
";",
"}",
"$",
"this",
"->",
"clear",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"mf",
"->",
"getAllTypeNames",
"(",
")",
"as",
"$",
"type",
")",
"{",
"$",
"metadata",
"=",
"$",
"this",
"->",
"mf",
"->",
"getMetadataForType",
"(",
"$",
"type",
")",
";",
"$",
"warmed",
"[",
"]",
"=",
"$",
"type",
";",
"}",
"return",
"$",
"warmed",
";",
"}"
] | Warms up all metadata objects into the cache.
@return array | [
"Warms",
"up",
"all",
"metadata",
"objects",
"into",
"the",
"cache",
"."
] | 7c2c767216055f75abf8cf22e2200f11998ed24e | https://github.com/zarathustra323/modlr-data/blob/7c2c767216055f75abf8cf22e2200f11998ed24e/src/Zarathustra/ModlrData/Metadata/Cache/CacheWarmer.php#L37-L50 | train |
zarathustra323/modlr-data | src/Zarathustra/ModlrData/Metadata/Cache/CacheWarmer.php | CacheWarmer.clear | public function clear()
{
$cleared = [];
if (false === $this->mf->hasCache()) {
return $cleared;
}
$this->mf->enableCache(false);
foreach ($this->mf->getAllTypeNames() as $type) {
$metadata = $this->mf->getMetadataForType($type);
$this->mf->getCache()->evictMetadataFromCache($metadata);
$cleared[] = $type;
}
$this->mf->enableCache(true);
$this->mf->clearMemory();
return $cleared;
} | php | public function clear()
{
$cleared = [];
if (false === $this->mf->hasCache()) {
return $cleared;
}
$this->mf->enableCache(false);
foreach ($this->mf->getAllTypeNames() as $type) {
$metadata = $this->mf->getMetadataForType($type);
$this->mf->getCache()->evictMetadataFromCache($metadata);
$cleared[] = $type;
}
$this->mf->enableCache(true);
$this->mf->clearMemory();
return $cleared;
} | [
"public",
"function",
"clear",
"(",
")",
"{",
"$",
"cleared",
"=",
"[",
"]",
";",
"if",
"(",
"false",
"===",
"$",
"this",
"->",
"mf",
"->",
"hasCache",
"(",
")",
")",
"{",
"return",
"$",
"cleared",
";",
"}",
"$",
"this",
"->",
"mf",
"->",
"enableCache",
"(",
"false",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"mf",
"->",
"getAllTypeNames",
"(",
")",
"as",
"$",
"type",
")",
"{",
"$",
"metadata",
"=",
"$",
"this",
"->",
"mf",
"->",
"getMetadataForType",
"(",
"$",
"type",
")",
";",
"$",
"this",
"->",
"mf",
"->",
"getCache",
"(",
")",
"->",
"evictMetadataFromCache",
"(",
"$",
"metadata",
")",
";",
"$",
"cleared",
"[",
"]",
"=",
"$",
"type",
";",
"}",
"$",
"this",
"->",
"mf",
"->",
"enableCache",
"(",
"true",
")",
";",
"$",
"this",
"->",
"mf",
"->",
"clearMemory",
"(",
")",
";",
"return",
"$",
"cleared",
";",
"}"
] | Clears all metadata objects from the cache.
@return self | [
"Clears",
"all",
"metadata",
"objects",
"from",
"the",
"cache",
"."
] | 7c2c767216055f75abf8cf22e2200f11998ed24e | https://github.com/zarathustra323/modlr-data/blob/7c2c767216055f75abf8cf22e2200f11998ed24e/src/Zarathustra/ModlrData/Metadata/Cache/CacheWarmer.php#L57-L73 | train |
Hnto/nuki | src/Models/Data/File.php | File.setName | public function setName($name = false) {
if ($name === false || empty($name)) {
$this->name = \Nuki\Handlers\Core\Assist::randomString();
return;
}
$this->name = $name;
} | php | public function setName($name = false) {
if ($name === false || empty($name)) {
$this->name = \Nuki\Handlers\Core\Assist::randomString();
return;
}
$this->name = $name;
} | [
"public",
"function",
"setName",
"(",
"$",
"name",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"name",
"===",
"false",
"||",
"empty",
"(",
"$",
"name",
")",
")",
"{",
"$",
"this",
"->",
"name",
"=",
"\\",
"Nuki",
"\\",
"Handlers",
"\\",
"Core",
"\\",
"Assist",
"::",
"randomString",
"(",
")",
";",
"return",
";",
"}",
"$",
"this",
"->",
"name",
"=",
"$",
"name",
";",
"}"
] | Set file name
if name not give, it will be generated
@param string|bool $name
@return void | [
"Set",
"file",
"name",
"if",
"name",
"not",
"give",
"it",
"will",
"be",
"generated"
] | c3fb16244e8d611c335a88e3b9c9ee7d81fafc0c | https://github.com/Hnto/nuki/blob/c3fb16244e8d611c335a88e3b9c9ee7d81fafc0c/src/Models/Data/File.php#L80-L87 | train |
Talesoft/tale-framework | src/Tale/Cache/Adapter/File.php | File.init | protected function init()
{
$this->prependOptions([
'path' => './cache',
'formatAliases' => [],
'format' => 'json'
]);
$this->_path = $this->getOption('path');
$this->_formatFactory = new Factory(__NAMESPACE__.'\\File\\FormatBase', [
'json' => __NAMESPACE__.'\\File\\Format\\Json',
'serialize' => __NAMESPACE__.'\\File\\Format\\Serialize',
'export' => __NAMESPACE__.'\\File\\Format\\Export'
]);
$this->_formatFactory->registerAliases($this->getOption('formatAliases'));
$this->_format = $this->_formatFactory->createInstance($this->getOption('format'));
$this->_lifeTimePath = implode('', [$this->_path, '/.life-times', $this->_format->getExtension()]);
$this->_lifeTimes = [];
if (file_exists($this->_lifeTimePath))
$this->_lifeTimes = $this->_format->load($this->_lifeTimePath);
} | php | protected function init()
{
$this->prependOptions([
'path' => './cache',
'formatAliases' => [],
'format' => 'json'
]);
$this->_path = $this->getOption('path');
$this->_formatFactory = new Factory(__NAMESPACE__.'\\File\\FormatBase', [
'json' => __NAMESPACE__.'\\File\\Format\\Json',
'serialize' => __NAMESPACE__.'\\File\\Format\\Serialize',
'export' => __NAMESPACE__.'\\File\\Format\\Export'
]);
$this->_formatFactory->registerAliases($this->getOption('formatAliases'));
$this->_format = $this->_formatFactory->createInstance($this->getOption('format'));
$this->_lifeTimePath = implode('', [$this->_path, '/.life-times', $this->_format->getExtension()]);
$this->_lifeTimes = [];
if (file_exists($this->_lifeTimePath))
$this->_lifeTimes = $this->_format->load($this->_lifeTimePath);
} | [
"protected",
"function",
"init",
"(",
")",
"{",
"$",
"this",
"->",
"prependOptions",
"(",
"[",
"'path'",
"=>",
"'./cache'",
",",
"'formatAliases'",
"=>",
"[",
"]",
",",
"'format'",
"=>",
"'json'",
"]",
")",
";",
"$",
"this",
"->",
"_path",
"=",
"$",
"this",
"->",
"getOption",
"(",
"'path'",
")",
";",
"$",
"this",
"->",
"_formatFactory",
"=",
"new",
"Factory",
"(",
"__NAMESPACE__",
".",
"'\\\\File\\\\FormatBase'",
",",
"[",
"'json'",
"=>",
"__NAMESPACE__",
".",
"'\\\\File\\\\Format\\\\Json'",
",",
"'serialize'",
"=>",
"__NAMESPACE__",
".",
"'\\\\File\\\\Format\\\\Serialize'",
",",
"'export'",
"=>",
"__NAMESPACE__",
".",
"'\\\\File\\\\Format\\\\Export'",
"]",
")",
";",
"$",
"this",
"->",
"_formatFactory",
"->",
"registerAliases",
"(",
"$",
"this",
"->",
"getOption",
"(",
"'formatAliases'",
")",
")",
";",
"$",
"this",
"->",
"_format",
"=",
"$",
"this",
"->",
"_formatFactory",
"->",
"createInstance",
"(",
"$",
"this",
"->",
"getOption",
"(",
"'format'",
")",
")",
";",
"$",
"this",
"->",
"_lifeTimePath",
"=",
"implode",
"(",
"''",
",",
"[",
"$",
"this",
"->",
"_path",
",",
"'/.life-times'",
",",
"$",
"this",
"->",
"_format",
"->",
"getExtension",
"(",
")",
"]",
")",
";",
"$",
"this",
"->",
"_lifeTimes",
"=",
"[",
"]",
";",
"if",
"(",
"file_exists",
"(",
"$",
"this",
"->",
"_lifeTimePath",
")",
")",
"$",
"this",
"->",
"_lifeTimes",
"=",
"$",
"this",
"->",
"_format",
"->",
"load",
"(",
"$",
"this",
"->",
"_lifeTimePath",
")",
";",
"}"
] | Initializes the file cache adapter | [
"Initializes",
"the",
"file",
"cache",
"adapter"
] | 739a7011c6dad409a51c4bcfbcf4b4ffbc8cba49 | https://github.com/Talesoft/tale-framework/blob/739a7011c6dad409a51c4bcfbcf4b4ffbc8cba49/src/Tale/Cache/Adapter/File.php#L50-L74 | train |
Talesoft/tale-framework | src/Tale/Cache/Adapter/File.php | File.exists | public function exists($key)
{
$path = $this->getKeyPath($key);
if (!file_exists($path) || empty($this->_lifeTimes[$key]))
return false;
if (time() - filemtime($path) > $this->_lifeTimes[$key])
return false;
return true;
} | php | public function exists($key)
{
$path = $this->getKeyPath($key);
if (!file_exists($path) || empty($this->_lifeTimes[$key]))
return false;
if (time() - filemtime($path) > $this->_lifeTimes[$key])
return false;
return true;
} | [
"public",
"function",
"exists",
"(",
"$",
"key",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"getKeyPath",
"(",
"$",
"key",
")",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"path",
")",
"||",
"empty",
"(",
"$",
"this",
"->",
"_lifeTimes",
"[",
"$",
"key",
"]",
")",
")",
"return",
"false",
";",
"if",
"(",
"time",
"(",
")",
"-",
"filemtime",
"(",
"$",
"path",
")",
">",
"$",
"this",
"->",
"_lifeTimes",
"[",
"$",
"key",
"]",
")",
"return",
"false",
";",
"return",
"true",
";",
"}"
] | Checks if the given cache key has an existing cache file that didn't exceed the given life-time
@param $key string The key that needs to be checked
@return bool | [
"Checks",
"if",
"the",
"given",
"cache",
"key",
"has",
"an",
"existing",
"cache",
"file",
"that",
"didn",
"t",
"exceed",
"the",
"given",
"life",
"-",
"time"
] | 739a7011c6dad409a51c4bcfbcf4b4ffbc8cba49 | https://github.com/Talesoft/tale-framework/blob/739a7011c6dad409a51c4bcfbcf4b4ffbc8cba49/src/Tale/Cache/Adapter/File.php#L111-L123 | train |
Talesoft/tale-framework | src/Tale/Cache/Adapter/File.php | File.set | public function set($key, $value, $lifeTime)
{
$path = $this->getKeyPath($key);
$dir = dirname($path);
if (!is_dir($dir))
mkdir($dir, 0777, true);
$this->_lifeTimes[$key] = intval($lifeTime);
//Save the life times
$this->_format->save($this->_lifeTimePath, $this->_lifeTimes);
//Save the cache content
$this->_format->save($path, $value);
return $this;
} | php | public function set($key, $value, $lifeTime)
{
$path = $this->getKeyPath($key);
$dir = dirname($path);
if (!is_dir($dir))
mkdir($dir, 0777, true);
$this->_lifeTimes[$key] = intval($lifeTime);
//Save the life times
$this->_format->save($this->_lifeTimePath, $this->_lifeTimes);
//Save the cache content
$this->_format->save($path, $value);
return $this;
} | [
"public",
"function",
"set",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"lifeTime",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"getKeyPath",
"(",
"$",
"key",
")",
";",
"$",
"dir",
"=",
"dirname",
"(",
"$",
"path",
")",
";",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"dir",
")",
")",
"mkdir",
"(",
"$",
"dir",
",",
"0777",
",",
"true",
")",
";",
"$",
"this",
"->",
"_lifeTimes",
"[",
"$",
"key",
"]",
"=",
"intval",
"(",
"$",
"lifeTime",
")",
";",
"//Save the life times",
"$",
"this",
"->",
"_format",
"->",
"save",
"(",
"$",
"this",
"->",
"_lifeTimePath",
",",
"$",
"this",
"->",
"_lifeTimes",
")",
";",
"//Save the cache content",
"$",
"this",
"->",
"_format",
"->",
"save",
"(",
"$",
"path",
",",
"$",
"value",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Sets the value of an cache item to the given value
@param $key string The key that needs to be checked
@param $value mixed The value that needs to be cached
@param $lifeTime int The life-time of the cache item in seconds
@return $this | [
"Sets",
"the",
"value",
"of",
"an",
"cache",
"item",
"to",
"the",
"given",
"value"
] | 739a7011c6dad409a51c4bcfbcf4b4ffbc8cba49 | https://github.com/Talesoft/tale-framework/blob/739a7011c6dad409a51c4bcfbcf4b4ffbc8cba49/src/Tale/Cache/Adapter/File.php#L147-L165 | train |
koolkode/view-express | src/DecoratedTemplate.php | DecoratedTemplate.renderBlock | public function renderBlock(OutputBuffer $out, $name)
{
if(array_key_exists($name, $this->blocks))
{
$pblock = $this->outerContext->set('@block', $name);
$pout = $this->outerContext->set('@out', $out);
$pthis = $this->outerContext->set('@this', $this);
try
{
$this->blocks[$name]($out);
return;
}
finally
{
$this->outerContext->set('@block', $pblock);
$this->outerContext->set('@out', $pout);
$this->outerContext->set('@this', $pthis);
}
}
return parent::renderBlock($out, $name);
} | php | public function renderBlock(OutputBuffer $out, $name)
{
if(array_key_exists($name, $this->blocks))
{
$pblock = $this->outerContext->set('@block', $name);
$pout = $this->outerContext->set('@out', $out);
$pthis = $this->outerContext->set('@this', $this);
try
{
$this->blocks[$name]($out);
return;
}
finally
{
$this->outerContext->set('@block', $pblock);
$this->outerContext->set('@out', $pout);
$this->outerContext->set('@this', $pthis);
}
}
return parent::renderBlock($out, $name);
} | [
"public",
"function",
"renderBlock",
"(",
"OutputBuffer",
"$",
"out",
",",
"$",
"name",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"blocks",
")",
")",
"{",
"$",
"pblock",
"=",
"$",
"this",
"->",
"outerContext",
"->",
"set",
"(",
"'@block'",
",",
"$",
"name",
")",
";",
"$",
"pout",
"=",
"$",
"this",
"->",
"outerContext",
"->",
"set",
"(",
"'@out'",
",",
"$",
"out",
")",
";",
"$",
"pthis",
"=",
"$",
"this",
"->",
"outerContext",
"->",
"set",
"(",
"'@this'",
",",
"$",
"this",
")",
";",
"try",
"{",
"$",
"this",
"->",
"blocks",
"[",
"$",
"name",
"]",
"(",
"$",
"out",
")",
";",
"return",
";",
"}",
"finally",
"{",
"$",
"this",
"->",
"outerContext",
"->",
"set",
"(",
"'@block'",
",",
"$",
"pblock",
")",
";",
"$",
"this",
"->",
"outerContext",
"->",
"set",
"(",
"'@out'",
",",
"$",
"pout",
")",
";",
"$",
"this",
"->",
"outerContext",
"->",
"set",
"(",
"'@this'",
",",
"$",
"pthis",
")",
";",
"}",
"}",
"return",
"parent",
"::",
"renderBlock",
"(",
"$",
"out",
",",
"$",
"name",
")",
";",
"}"
] | Render contents of block taking blocks from the decorator into consideration.
@param OutputBuffer $out
@param string $name The name of the block to be rendered. | [
"Render",
"contents",
"of",
"block",
"taking",
"blocks",
"from",
"the",
"decorator",
"into",
"consideration",
"."
] | a8ebe6f373b6bfe8b8818d6264535e8fe063a596 | https://github.com/koolkode/view-express/blob/a8ebe6f373b6bfe8b8818d6264535e8fe063a596/src/DecoratedTemplate.php#L117-L140 | train |
koolkode/view-express | src/DecoratedTemplate.php | DecoratedTemplate.renderParentBlock | public function renderParentBlock(OutputBuffer $out, $name)
{
$method = 'block_' . $name;
if(method_exists($this, $method))
{
return $this->$method($out);
}
return parent::renderParentBlock($out, $name);
} | php | public function renderParentBlock(OutputBuffer $out, $name)
{
$method = 'block_' . $name;
if(method_exists($this, $method))
{
return $this->$method($out);
}
return parent::renderParentBlock($out, $name);
} | [
"public",
"function",
"renderParentBlock",
"(",
"OutputBuffer",
"$",
"out",
",",
"$",
"name",
")",
"{",
"$",
"method",
"=",
"'block_'",
".",
"$",
"name",
";",
"if",
"(",
"method_exists",
"(",
"$",
"this",
",",
"$",
"method",
")",
")",
"{",
"return",
"$",
"this",
"->",
"$",
"method",
"(",
"$",
"out",
")",
";",
"}",
"return",
"parent",
"::",
"renderParentBlock",
"(",
"$",
"out",
",",
"$",
"name",
")",
";",
"}"
] | Render contents of a block in the parent view taking block from the decorator into consideration.
@param OutputBuffer $out
@param string $name The name of the block to be rendered. | [
"Render",
"contents",
"of",
"a",
"block",
"in",
"the",
"parent",
"view",
"taking",
"block",
"from",
"the",
"decorator",
"into",
"consideration",
"."
] | a8ebe6f373b6bfe8b8818d6264535e8fe063a596 | https://github.com/koolkode/view-express/blob/a8ebe6f373b6bfe8b8818d6264535e8fe063a596/src/DecoratedTemplate.php#L148-L158 | train |
Torann/skosh-generator | src/Config.php | Config.load | private function load($env = 'local', $file = 'config')
{
$path = BASE_PATH . ($file === '.env' ? '' : '/config');
// File paths
$configPath = "{$path}/{$file}.yml";
$envConfigPath = "{$path}/{$file}_{$env}.yml";
if (!file_exists($configPath)) {
throw new \Exception("Config file not found at \"{$configPath}\".");
}
$data = file_get_contents($configPath);
if ($data === false) {
throw new \Exception("Unable to load configuration from: {$configPath}");
}
$yaml = new Parser();
// Load config
$config = $yaml->parse($data);
$this->config = $config ? $config : [];
// Load environment specific config
if (file_exists($envConfigPath)) {
$data = file_get_contents($envConfigPath);
if ($data) {
$config = $yaml->parse($data);
$config = $config ? $config : [];
// Merge config values
$this->config = array_merge($this->config, $config);
}
}
} | php | private function load($env = 'local', $file = 'config')
{
$path = BASE_PATH . ($file === '.env' ? '' : '/config');
// File paths
$configPath = "{$path}/{$file}.yml";
$envConfigPath = "{$path}/{$file}_{$env}.yml";
if (!file_exists($configPath)) {
throw new \Exception("Config file not found at \"{$configPath}\".");
}
$data = file_get_contents($configPath);
if ($data === false) {
throw new \Exception("Unable to load configuration from: {$configPath}");
}
$yaml = new Parser();
// Load config
$config = $yaml->parse($data);
$this->config = $config ? $config : [];
// Load environment specific config
if (file_exists($envConfigPath)) {
$data = file_get_contents($envConfigPath);
if ($data) {
$config = $yaml->parse($data);
$config = $config ? $config : [];
// Merge config values
$this->config = array_merge($this->config, $config);
}
}
} | [
"private",
"function",
"load",
"(",
"$",
"env",
"=",
"'local'",
",",
"$",
"file",
"=",
"'config'",
")",
"{",
"$",
"path",
"=",
"BASE_PATH",
".",
"(",
"$",
"file",
"===",
"'.env'",
"?",
"''",
":",
"'/config'",
")",
";",
"// File paths",
"$",
"configPath",
"=",
"\"{$path}/{$file}.yml\"",
";",
"$",
"envConfigPath",
"=",
"\"{$path}/{$file}_{$env}.yml\"",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"configPath",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Config file not found at \\\"{$configPath}\\\".\"",
")",
";",
"}",
"$",
"data",
"=",
"file_get_contents",
"(",
"$",
"configPath",
")",
";",
"if",
"(",
"$",
"data",
"===",
"false",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Unable to load configuration from: {$configPath}\"",
")",
";",
"}",
"$",
"yaml",
"=",
"new",
"Parser",
"(",
")",
";",
"// Load config",
"$",
"config",
"=",
"$",
"yaml",
"->",
"parse",
"(",
"$",
"data",
")",
";",
"$",
"this",
"->",
"config",
"=",
"$",
"config",
"?",
"$",
"config",
":",
"[",
"]",
";",
"// Load environment specific config",
"if",
"(",
"file_exists",
"(",
"$",
"envConfigPath",
")",
")",
"{",
"$",
"data",
"=",
"file_get_contents",
"(",
"$",
"envConfigPath",
")",
";",
"if",
"(",
"$",
"data",
")",
"{",
"$",
"config",
"=",
"$",
"yaml",
"->",
"parse",
"(",
"$",
"data",
")",
";",
"$",
"config",
"=",
"$",
"config",
"?",
"$",
"config",
":",
"[",
"]",
";",
"// Merge config values",
"$",
"this",
"->",
"config",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"config",
",",
"$",
"config",
")",
";",
"}",
"}",
"}"
] | Loads and parses the config file
@param string $env Environment
@param string $file Config filename
@return void
@throws \Exception | [
"Loads",
"and",
"parses",
"the",
"config",
"file"
] | ea60e037d92398d7c146eb2349735d5692e3c48c | https://github.com/Torann/skosh-generator/blob/ea60e037d92398d7c146eb2349735d5692e3c48c/src/Config.php#L58-L94 | train |
ekyna/SettingBundle | DependencyInjection/TinymceConfiguration.php | TinymceConfiguration.build | public function build(array $config)
{
$contentCss = [
'/css/admin-helper.css',
'/bundles/ekynacore/css/tinymce-content.css',
'http://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800',
];
if (0 < strlen($config['ui']['google_font_url'])) {
$contentCss[] = $config['ui']['google_font_url'];
}
return [
'theme' => [
'helper' => [
'menubar' => false,
'statusbar' => true,
'resize' => false,
'image_advtab' => true,
'relative_urls' => false,
'entity_encoding' => 'raw',
'plugins' => [
"autoresize advlist autolink lists link image charmap print preview hr anchor pagebreak",
"searchreplace wordcount visualblocks visualchars code fullscreen",
"insertdatetime media nonbreaking save table contextmenu directionality",
"emoticons paste textcolor template",
],
'toolbar1' => "undo redo | styleselect | link image media",
'toolbar2' => "bold italic forecolor backcolor | alignleft aligncenter " .
"alignright alignjustify | bullist numlist outdent indent",
'external_plugins' => [
'filemanager' => "/bundles/ekynafilemanager/js/tinymce.plugin.js",
],
'content_css' => $contentCss,
],
],
];
} | php | public function build(array $config)
{
$contentCss = [
'/css/admin-helper.css',
'/bundles/ekynacore/css/tinymce-content.css',
'http://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800',
];
if (0 < strlen($config['ui']['google_font_url'])) {
$contentCss[] = $config['ui']['google_font_url'];
}
return [
'theme' => [
'helper' => [
'menubar' => false,
'statusbar' => true,
'resize' => false,
'image_advtab' => true,
'relative_urls' => false,
'entity_encoding' => 'raw',
'plugins' => [
"autoresize advlist autolink lists link image charmap print preview hr anchor pagebreak",
"searchreplace wordcount visualblocks visualchars code fullscreen",
"insertdatetime media nonbreaking save table contextmenu directionality",
"emoticons paste textcolor template",
],
'toolbar1' => "undo redo | styleselect | link image media",
'toolbar2' => "bold italic forecolor backcolor | alignleft aligncenter " .
"alignright alignjustify | bullist numlist outdent indent",
'external_plugins' => [
'filemanager' => "/bundles/ekynafilemanager/js/tinymce.plugin.js",
],
'content_css' => $contentCss,
],
],
];
} | [
"public",
"function",
"build",
"(",
"array",
"$",
"config",
")",
"{",
"$",
"contentCss",
"=",
"[",
"'/css/admin-helper.css'",
",",
"'/bundles/ekynacore/css/tinymce-content.css'",
",",
"'http://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800'",
",",
"]",
";",
"if",
"(",
"0",
"<",
"strlen",
"(",
"$",
"config",
"[",
"'ui'",
"]",
"[",
"'google_font_url'",
"]",
")",
")",
"{",
"$",
"contentCss",
"[",
"]",
"=",
"$",
"config",
"[",
"'ui'",
"]",
"[",
"'google_font_url'",
"]",
";",
"}",
"return",
"[",
"'theme'",
"=>",
"[",
"'helper'",
"=>",
"[",
"'menubar'",
"=>",
"false",
",",
"'statusbar'",
"=>",
"true",
",",
"'resize'",
"=>",
"false",
",",
"'image_advtab'",
"=>",
"true",
",",
"'relative_urls'",
"=>",
"false",
",",
"'entity_encoding'",
"=>",
"'raw'",
",",
"'plugins'",
"=>",
"[",
"\"autoresize advlist autolink lists link image charmap print preview hr anchor pagebreak\"",
",",
"\"searchreplace wordcount visualblocks visualchars code fullscreen\"",
",",
"\"insertdatetime media nonbreaking save table contextmenu directionality\"",
",",
"\"emoticons paste textcolor template\"",
",",
"]",
",",
"'toolbar1'",
"=>",
"\"undo redo | styleselect | link image media\"",
",",
"'toolbar2'",
"=>",
"\"bold italic forecolor backcolor | alignleft aligncenter \"",
".",
"\"alignright alignjustify | bullist numlist outdent indent\"",
",",
"'external_plugins'",
"=>",
"[",
"'filemanager'",
"=>",
"\"/bundles/ekynafilemanager/js/tinymce.plugin.js\"",
",",
"]",
",",
"'content_css'",
"=>",
"$",
"contentCss",
",",
"]",
",",
"]",
",",
"]",
";",
"}"
] | Builds the tinymce configuration.
@param array $config
@return array | [
"Builds",
"the",
"tinymce",
"configuration",
"."
] | df58f83eb3a01ef56cd76ea73639322c581e75c1 | https://github.com/ekyna/SettingBundle/blob/df58f83eb3a01ef56cd76ea73639322c581e75c1/DependencyInjection/TinymceConfiguration.php#L18-L55 | train |
eskirex/session | src/Traits/SessionTrait.php | SessionTrait.changeCurrentId | protected function changeCurrentId($newId)
{
if (!preg_match('/^[-,a-zA-Z0-9]{1,128}$/', $newId)) {
throw new InvalidArgumentException('Invalid Session ID String');
}
if (session_id($newId) === false) {
throw new SessionRuntimeException('session_id Failed');
}
return true;
} | php | protected function changeCurrentId($newId)
{
if (!preg_match('/^[-,a-zA-Z0-9]{1,128}$/', $newId)) {
throw new InvalidArgumentException('Invalid Session ID String');
}
if (session_id($newId) === false) {
throw new SessionRuntimeException('session_id Failed');
}
return true;
} | [
"protected",
"function",
"changeCurrentId",
"(",
"$",
"newId",
")",
"{",
"if",
"(",
"!",
"preg_match",
"(",
"'/^[-,a-zA-Z0-9]{1,128}$/'",
",",
"$",
"newId",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Invalid Session ID String'",
")",
";",
"}",
"if",
"(",
"session_id",
"(",
"$",
"newId",
")",
"===",
"false",
")",
"{",
"throw",
"new",
"SessionRuntimeException",
"(",
"'session_id Failed'",
")",
";",
"}",
"return",
"true",
";",
"}"
] | Set session id
@param $newId
@return bool
@throws InvalidArgumentException
@throws SessionRuntimeException | [
"Set",
"session",
"id"
] | 3da2ca8c83d3c124b16fee2ad45c8e967c87cd63 | https://github.com/eskirex/session/blob/3da2ca8c83d3c124b16fee2ad45c8e967c87cd63/src/Traits/SessionTrait.php#L170-L181 | train |
betasyntax/Betasyntax-Framework-Core | src/Betasyntax/Session.php | Session.getInstance | public static function getInstance()
{
if (!isset(self::$instance)) {
self::$instance = new self;
}
self::$instance->startSession();
return self::$instance;
} | php | public static function getInstance()
{
if (!isset(self::$instance)) {
self::$instance = new self;
}
self::$instance->startSession();
return self::$instance;
} | [
"public",
"static",
"function",
"getInstance",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"instance",
")",
")",
"{",
"self",
"::",
"$",
"instance",
"=",
"new",
"self",
";",
"}",
"self",
"::",
"$",
"instance",
"->",
"startSession",
"(",
")",
";",
"return",
"self",
"::",
"$",
"instance",
";",
"}"
] | Returns THE instance of 'Session'.
The session is automatically initialized if it wasn't.
@return object | [
"Returns",
"THE",
"instance",
"of",
"Session",
".",
"The",
"session",
"is",
"automatically",
"initialized",
"if",
"it",
"wasn",
"t",
"."
] | 2d135ec1f7dd98e6ef21512a069ac2595f1eb78e | https://github.com/betasyntax/Betasyntax-Framework-Core/blob/2d135ec1f7dd98e6ef21512a069ac2595f1eb78e/src/Betasyntax/Session.php#L25-L32 | train |
betasyntax/Betasyntax-Framework-Core | src/Betasyntax/Session.php | Session.destroy | public function destroy()
{
if ($this->sessionState == self::SESSION_STARTED) {
$_SESSION=array();
$this->sessionState = !session_destroy();
unset($_SESSION);
return !$this->sessionState;
}
return FALSE;
} | php | public function destroy()
{
if ($this->sessionState == self::SESSION_STARTED) {
$_SESSION=array();
$this->sessionState = !session_destroy();
unset($_SESSION);
return !$this->sessionState;
}
return FALSE;
} | [
"public",
"function",
"destroy",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"sessionState",
"==",
"self",
"::",
"SESSION_STARTED",
")",
"{",
"$",
"_SESSION",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"sessionState",
"=",
"!",
"session_destroy",
"(",
")",
";",
"unset",
"(",
"$",
"_SESSION",
")",
";",
"return",
"!",
"$",
"this",
"->",
"sessionState",
";",
"}",
"return",
"FALSE",
";",
"}"
] | Destroys the current session.
@return bool TRUE is session has been deleted, else FALSE. | [
"Destroys",
"the",
"current",
"session",
"."
] | 2d135ec1f7dd98e6ef21512a069ac2595f1eb78e | https://github.com/betasyntax/Betasyntax-Framework-Core/blob/2d135ec1f7dd98e6ef21512a069ac2595f1eb78e/src/Betasyntax/Session.php#L92-L101 | train |
squareproton/Bond | src/Bond/Entity/Sort.php | Sort.generateByPropertyClosure | public static function generateByPropertyClosure( $property, $direction = SORT_ASC )
{
if( $direction === SORT_DESC ) {
$aLTb = 1;
$aGTb = -1;
} else {
$aLTb = -1;
$aGTb = 1;
}
return function ( \Bond\Entity\Base $a, \Bond\Entity\Base $b ) use ( $property, $aLTb, $aGTb ) {
$propertyA = $a->get($property);
$propertyB = $b->get($property);
if( $propertyA === $propertyB ) {
return 0;
}
return ( $propertyA < $propertyB ) ? $aLTb : $aGTb;
};
} | php | public static function generateByPropertyClosure( $property, $direction = SORT_ASC )
{
if( $direction === SORT_DESC ) {
$aLTb = 1;
$aGTb = -1;
} else {
$aLTb = -1;
$aGTb = 1;
}
return function ( \Bond\Entity\Base $a, \Bond\Entity\Base $b ) use ( $property, $aLTb, $aGTb ) {
$propertyA = $a->get($property);
$propertyB = $b->get($property);
if( $propertyA === $propertyB ) {
return 0;
}
return ( $propertyA < $propertyB ) ? $aLTb : $aGTb;
};
} | [
"public",
"static",
"function",
"generateByPropertyClosure",
"(",
"$",
"property",
",",
"$",
"direction",
"=",
"SORT_ASC",
")",
"{",
"if",
"(",
"$",
"direction",
"===",
"SORT_DESC",
")",
"{",
"$",
"aLTb",
"=",
"1",
";",
"$",
"aGTb",
"=",
"-",
"1",
";",
"}",
"else",
"{",
"$",
"aLTb",
"=",
"-",
"1",
";",
"$",
"aGTb",
"=",
"1",
";",
"}",
"return",
"function",
"(",
"\\",
"Bond",
"\\",
"Entity",
"\\",
"Base",
"$",
"a",
",",
"\\",
"Bond",
"\\",
"Entity",
"\\",
"Base",
"$",
"b",
")",
"use",
"(",
"$",
"property",
",",
"$",
"aLTb",
",",
"$",
"aGTb",
")",
"{",
"$",
"propertyA",
"=",
"$",
"a",
"->",
"get",
"(",
"$",
"property",
")",
";",
"$",
"propertyB",
"=",
"$",
"b",
"->",
"get",
"(",
"$",
"property",
")",
";",
"if",
"(",
"$",
"propertyA",
"===",
"$",
"propertyB",
")",
"{",
"return",
"0",
";",
"}",
"return",
"(",
"$",
"propertyA",
"<",
"$",
"propertyB",
")",
"?",
"$",
"aLTb",
":",
"$",
"aGTb",
";",
"}",
";",
"}"
] | Generate a sort by property callback
@param string $property property to sort by | [
"Generate",
"a",
"sort",
"by",
"property",
"callback"
] | a04ad9dd1a35adeaec98237716c2a41ce02b4f1a | https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Entity/Sort.php#L19-L39 | train |
agentmedia/phine-core | src/Core/Snippets/BackendRights/PageRights.php | PageRights.Save | function Save()
{
$this->contentRights->Save();
if (!$this->rights)
{
$this->rights = new BackendPageRights();
}
$this->rights->SetCreateIn($this->Value('CreateIn'));
$this->rights->SetEdit($this->Value('Edit'));
$this->rights->SetMove($this->Value('Move'));
$this->rights->SetRemove($this->Value('Remove'));
$this->rights->SetContentRights($this->contentRights->Rights());
$this->rights->Save();
} | php | function Save()
{
$this->contentRights->Save();
if (!$this->rights)
{
$this->rights = new BackendPageRights();
}
$this->rights->SetCreateIn($this->Value('CreateIn'));
$this->rights->SetEdit($this->Value('Edit'));
$this->rights->SetMove($this->Value('Move'));
$this->rights->SetRemove($this->Value('Remove'));
$this->rights->SetContentRights($this->contentRights->Rights());
$this->rights->Save();
} | [
"function",
"Save",
"(",
")",
"{",
"$",
"this",
"->",
"contentRights",
"->",
"Save",
"(",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"rights",
")",
"{",
"$",
"this",
"->",
"rights",
"=",
"new",
"BackendPageRights",
"(",
")",
";",
"}",
"$",
"this",
"->",
"rights",
"->",
"SetCreateIn",
"(",
"$",
"this",
"->",
"Value",
"(",
"'CreateIn'",
")",
")",
";",
"$",
"this",
"->",
"rights",
"->",
"SetEdit",
"(",
"$",
"this",
"->",
"Value",
"(",
"'Edit'",
")",
")",
";",
"$",
"this",
"->",
"rights",
"->",
"SetMove",
"(",
"$",
"this",
"->",
"Value",
"(",
"'Move'",
")",
")",
";",
"$",
"this",
"->",
"rights",
"->",
"SetRemove",
"(",
"$",
"this",
"->",
"Value",
"(",
"'Remove'",
")",
")",
";",
"$",
"this",
"->",
"rights",
"->",
"SetContentRights",
"(",
"$",
"this",
"->",
"contentRights",
"->",
"Rights",
"(",
")",
")",
";",
"$",
"this",
"->",
"rights",
"->",
"Save",
"(",
")",
";",
"}"
] | Saves the page rights | [
"Saves",
"the",
"page",
"rights"
] | 38c1be8d03ebffae950d00a96da3c612aff67832 | https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Snippets/BackendRights/PageRights.php#L49-L62 | train |
AppVerk/Components | Form/Handler/AbstractFormHandler.php | AbstractFormHandler.getErrorsFromForm | protected function getErrorsFromForm(FormInterface $form)
{
$errors = [];
/** @var FormError $error */
if($form->getErrors()->count() === 0 && $form->isRoot() && !$form->isValid()){
$errors["_self"] = "Empty post data";
}
foreach ($form->getErrors() as $error) {
$key = $error->getOrigin()->getName();
$errors[($form->isRoot()) ? "_self" : $key] = $error->getMessage();
}
foreach ($form->all() as $childForm) {
if ($childForm instanceof FormInterface) {
if ($childErrors = $this->getErrorsFromForm($childForm)) {
unset($errors["_self"]);
$errors = array_merge_recursive($errors, $childErrors);
}
}
}
return $errors;
} | php | protected function getErrorsFromForm(FormInterface $form)
{
$errors = [];
/** @var FormError $error */
if($form->getErrors()->count() === 0 && $form->isRoot() && !$form->isValid()){
$errors["_self"] = "Empty post data";
}
foreach ($form->getErrors() as $error) {
$key = $error->getOrigin()->getName();
$errors[($form->isRoot()) ? "_self" : $key] = $error->getMessage();
}
foreach ($form->all() as $childForm) {
if ($childForm instanceof FormInterface) {
if ($childErrors = $this->getErrorsFromForm($childForm)) {
unset($errors["_self"]);
$errors = array_merge_recursive($errors, $childErrors);
}
}
}
return $errors;
} | [
"protected",
"function",
"getErrorsFromForm",
"(",
"FormInterface",
"$",
"form",
")",
"{",
"$",
"errors",
"=",
"[",
"]",
";",
"/** @var FormError $error */",
"if",
"(",
"$",
"form",
"->",
"getErrors",
"(",
")",
"->",
"count",
"(",
")",
"===",
"0",
"&&",
"$",
"form",
"->",
"isRoot",
"(",
")",
"&&",
"!",
"$",
"form",
"->",
"isValid",
"(",
")",
")",
"{",
"$",
"errors",
"[",
"\"_self\"",
"]",
"=",
"\"Empty post data\"",
";",
"}",
"foreach",
"(",
"$",
"form",
"->",
"getErrors",
"(",
")",
"as",
"$",
"error",
")",
"{",
"$",
"key",
"=",
"$",
"error",
"->",
"getOrigin",
"(",
")",
"->",
"getName",
"(",
")",
";",
"$",
"errors",
"[",
"(",
"$",
"form",
"->",
"isRoot",
"(",
")",
")",
"?",
"\"_self\"",
":",
"$",
"key",
"]",
"=",
"$",
"error",
"->",
"getMessage",
"(",
")",
";",
"}",
"foreach",
"(",
"$",
"form",
"->",
"all",
"(",
")",
"as",
"$",
"childForm",
")",
"{",
"if",
"(",
"$",
"childForm",
"instanceof",
"FormInterface",
")",
"{",
"if",
"(",
"$",
"childErrors",
"=",
"$",
"this",
"->",
"getErrorsFromForm",
"(",
"$",
"childForm",
")",
")",
"{",
"unset",
"(",
"$",
"errors",
"[",
"\"_self\"",
"]",
")",
";",
"$",
"errors",
"=",
"array_merge_recursive",
"(",
"$",
"errors",
",",
"$",
"childErrors",
")",
";",
"}",
"}",
"}",
"return",
"$",
"errors",
";",
"}"
] | Build inheritance form errors
@param FormInterface $form
@return array | [
"Build",
"inheritance",
"form",
"errors"
] | 979e613388e5ea8a5858455c34ed22035635277e | https://github.com/AppVerk/Components/blob/979e613388e5ea8a5858455c34ed22035635277e/Form/Handler/AbstractFormHandler.php#L96-L120 | train |
koolkode/config | src/ConfigurationSource.php | ConfigurationSource.loadConfiguration | public function loadConfiguration(ConfigurationLoader $loader, array $params = [])
{
try
{
$data = $loader->findLoader($this->source)->load($this->source, $params);
return new Configuration($this->createBase($data));
}
catch(\Exception $e)
{
throw new ConfigurationLoadingException(sprintf('Unable to load config from source "%s"', $this->source->getPathname()), 0, $e);
}
} | php | public function loadConfiguration(ConfigurationLoader $loader, array $params = [])
{
try
{
$data = $loader->findLoader($this->source)->load($this->source, $params);
return new Configuration($this->createBase($data));
}
catch(\Exception $e)
{
throw new ConfigurationLoadingException(sprintf('Unable to load config from source "%s"', $this->source->getPathname()), 0, $e);
}
} | [
"public",
"function",
"loadConfiguration",
"(",
"ConfigurationLoader",
"$",
"loader",
",",
"array",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"try",
"{",
"$",
"data",
"=",
"$",
"loader",
"->",
"findLoader",
"(",
"$",
"this",
"->",
"source",
")",
"->",
"load",
"(",
"$",
"this",
"->",
"source",
",",
"$",
"params",
")",
";",
"return",
"new",
"Configuration",
"(",
"$",
"this",
"->",
"createBase",
"(",
"$",
"data",
")",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"ConfigurationLoadingException",
"(",
"sprintf",
"(",
"'Unable to load config from source \"%s\"'",
",",
"$",
"this",
"->",
"source",
"->",
"getPathname",
"(",
")",
")",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"}"
] | Load configuration data from the source.
@param ConfigurationLoader $loader
@param array<string, mixed> $params
@return Configuration
@throws ConfigurationLoadingException | [
"Load",
"configuration",
"data",
"from",
"the",
"source",
"."
] | ad97d80f6e4ae5f8925839488abf2d9bfcb6d7f6 | https://github.com/koolkode/config/blob/ad97d80f6e4ae5f8925839488abf2d9bfcb6d7f6/src/ConfigurationSource.php#L69-L81 | train |
spress/spress-core | ContentManager/Permalink/PermalinkGenerator.php | PermalinkGenerator.getPermalink | public function getPermalink(ItemInterface $item)
{
if ($item->getPath(ItemInterface::SNAPSHOT_PATH_RELATIVE_AFTER_CONVERT) === '') {
return new Permalink('', '');
}
$placeholders = $this->getPlacehoders($item);
$permalinkStyle = $this->getPermalinkAttribute($item);
$noHtmlExtension = $this->getNoHtmlExtensionAttribute($item);
if ($item->isBinary() === true) {
$urlTemplate = $this::PERMALINK_NONE;
$path = $this->generatePath($urlTemplate, $placeholders);
$urlPath = $this->generateUrlPath($urlTemplate, $placeholders);
return new Permalink($path, $urlPath);
}
switch ($permalinkStyle) {
case 'none':
$urlTemplate = $this::PERMALINK_NONE;
break;
case 'ordinal':
if ($this->isItemWithDate($item) === true) {
$urlTemplate = $this::PERMALINK_ORDINAL;
if ($this->isCustomCollection($item)) {
$urlTemplate = '/:collection'.$urlTemplate;
}
} else {
$urlTemplate = $this::PERMALINK_NONE;
}
break;
case 'pretty':
$noHtmlExtension = true;
case 'date':
if ($this->isItemWithDate($item) === true) {
$urlTemplate = $this::PERMALINK_DATE;
if ($this->isCustomCollection($item)) {
$urlTemplate = '/:collection'.$urlTemplate;
}
} else {
$urlTemplate = $this::PERMALINK_NONE;
}
break;
default:
if ($this->templateNeedsDate($permalinkStyle) === false || $this->isItemWithDate($item) === true) {
$urlTemplate = $permalinkStyle;
} else {
$urlTemplate = $this::PERMALINK_NONE;
}
break;
}
if ($noHtmlExtension && $placeholders[':extension'] === 'html') {
if ($placeholders[':basename'] === 'index') {
$placeholders[':basename'] = '';
}
$urlTemplate = str_replace(['.:extension', ':extension'], '', $urlTemplate);
$pathTemplate = $urlTemplate.'/index.html';
} else {
$pathTemplate = $urlTemplate;
}
$path = $this->generatePath($pathTemplate, $placeholders);
$urlPath = $this->generateUrlPath($urlTemplate, $placeholders);
return new Permalink($path, $urlPath);
} | php | public function getPermalink(ItemInterface $item)
{
if ($item->getPath(ItemInterface::SNAPSHOT_PATH_RELATIVE_AFTER_CONVERT) === '') {
return new Permalink('', '');
}
$placeholders = $this->getPlacehoders($item);
$permalinkStyle = $this->getPermalinkAttribute($item);
$noHtmlExtension = $this->getNoHtmlExtensionAttribute($item);
if ($item->isBinary() === true) {
$urlTemplate = $this::PERMALINK_NONE;
$path = $this->generatePath($urlTemplate, $placeholders);
$urlPath = $this->generateUrlPath($urlTemplate, $placeholders);
return new Permalink($path, $urlPath);
}
switch ($permalinkStyle) {
case 'none':
$urlTemplate = $this::PERMALINK_NONE;
break;
case 'ordinal':
if ($this->isItemWithDate($item) === true) {
$urlTemplate = $this::PERMALINK_ORDINAL;
if ($this->isCustomCollection($item)) {
$urlTemplate = '/:collection'.$urlTemplate;
}
} else {
$urlTemplate = $this::PERMALINK_NONE;
}
break;
case 'pretty':
$noHtmlExtension = true;
case 'date':
if ($this->isItemWithDate($item) === true) {
$urlTemplate = $this::PERMALINK_DATE;
if ($this->isCustomCollection($item)) {
$urlTemplate = '/:collection'.$urlTemplate;
}
} else {
$urlTemplate = $this::PERMALINK_NONE;
}
break;
default:
if ($this->templateNeedsDate($permalinkStyle) === false || $this->isItemWithDate($item) === true) {
$urlTemplate = $permalinkStyle;
} else {
$urlTemplate = $this::PERMALINK_NONE;
}
break;
}
if ($noHtmlExtension && $placeholders[':extension'] === 'html') {
if ($placeholders[':basename'] === 'index') {
$placeholders[':basename'] = '';
}
$urlTemplate = str_replace(['.:extension', ':extension'], '', $urlTemplate);
$pathTemplate = $urlTemplate.'/index.html';
} else {
$pathTemplate = $urlTemplate;
}
$path = $this->generatePath($pathTemplate, $placeholders);
$urlPath = $this->generateUrlPath($urlTemplate, $placeholders);
return new Permalink($path, $urlPath);
} | [
"public",
"function",
"getPermalink",
"(",
"ItemInterface",
"$",
"item",
")",
"{",
"if",
"(",
"$",
"item",
"->",
"getPath",
"(",
"ItemInterface",
"::",
"SNAPSHOT_PATH_RELATIVE_AFTER_CONVERT",
")",
"===",
"''",
")",
"{",
"return",
"new",
"Permalink",
"(",
"''",
",",
"''",
")",
";",
"}",
"$",
"placeholders",
"=",
"$",
"this",
"->",
"getPlacehoders",
"(",
"$",
"item",
")",
";",
"$",
"permalinkStyle",
"=",
"$",
"this",
"->",
"getPermalinkAttribute",
"(",
"$",
"item",
")",
";",
"$",
"noHtmlExtension",
"=",
"$",
"this",
"->",
"getNoHtmlExtensionAttribute",
"(",
"$",
"item",
")",
";",
"if",
"(",
"$",
"item",
"->",
"isBinary",
"(",
")",
"===",
"true",
")",
"{",
"$",
"urlTemplate",
"=",
"$",
"this",
"::",
"PERMALINK_NONE",
";",
"$",
"path",
"=",
"$",
"this",
"->",
"generatePath",
"(",
"$",
"urlTemplate",
",",
"$",
"placeholders",
")",
";",
"$",
"urlPath",
"=",
"$",
"this",
"->",
"generateUrlPath",
"(",
"$",
"urlTemplate",
",",
"$",
"placeholders",
")",
";",
"return",
"new",
"Permalink",
"(",
"$",
"path",
",",
"$",
"urlPath",
")",
";",
"}",
"switch",
"(",
"$",
"permalinkStyle",
")",
"{",
"case",
"'none'",
":",
"$",
"urlTemplate",
"=",
"$",
"this",
"::",
"PERMALINK_NONE",
";",
"break",
";",
"case",
"'ordinal'",
":",
"if",
"(",
"$",
"this",
"->",
"isItemWithDate",
"(",
"$",
"item",
")",
"===",
"true",
")",
"{",
"$",
"urlTemplate",
"=",
"$",
"this",
"::",
"PERMALINK_ORDINAL",
";",
"if",
"(",
"$",
"this",
"->",
"isCustomCollection",
"(",
"$",
"item",
")",
")",
"{",
"$",
"urlTemplate",
"=",
"'/:collection'",
".",
"$",
"urlTemplate",
";",
"}",
"}",
"else",
"{",
"$",
"urlTemplate",
"=",
"$",
"this",
"::",
"PERMALINK_NONE",
";",
"}",
"break",
";",
"case",
"'pretty'",
":",
"$",
"noHtmlExtension",
"=",
"true",
";",
"case",
"'date'",
":",
"if",
"(",
"$",
"this",
"->",
"isItemWithDate",
"(",
"$",
"item",
")",
"===",
"true",
")",
"{",
"$",
"urlTemplate",
"=",
"$",
"this",
"::",
"PERMALINK_DATE",
";",
"if",
"(",
"$",
"this",
"->",
"isCustomCollection",
"(",
"$",
"item",
")",
")",
"{",
"$",
"urlTemplate",
"=",
"'/:collection'",
".",
"$",
"urlTemplate",
";",
"}",
"}",
"else",
"{",
"$",
"urlTemplate",
"=",
"$",
"this",
"::",
"PERMALINK_NONE",
";",
"}",
"break",
";",
"default",
":",
"if",
"(",
"$",
"this",
"->",
"templateNeedsDate",
"(",
"$",
"permalinkStyle",
")",
"===",
"false",
"||",
"$",
"this",
"->",
"isItemWithDate",
"(",
"$",
"item",
")",
"===",
"true",
")",
"{",
"$",
"urlTemplate",
"=",
"$",
"permalinkStyle",
";",
"}",
"else",
"{",
"$",
"urlTemplate",
"=",
"$",
"this",
"::",
"PERMALINK_NONE",
";",
"}",
"break",
";",
"}",
"if",
"(",
"$",
"noHtmlExtension",
"&&",
"$",
"placeholders",
"[",
"':extension'",
"]",
"===",
"'html'",
")",
"{",
"if",
"(",
"$",
"placeholders",
"[",
"':basename'",
"]",
"===",
"'index'",
")",
"{",
"$",
"placeholders",
"[",
"':basename'",
"]",
"=",
"''",
";",
"}",
"$",
"urlTemplate",
"=",
"str_replace",
"(",
"[",
"'.:extension'",
",",
"':extension'",
"]",
",",
"''",
",",
"$",
"urlTemplate",
")",
";",
"$",
"pathTemplate",
"=",
"$",
"urlTemplate",
".",
"'/index.html'",
";",
"}",
"else",
"{",
"$",
"pathTemplate",
"=",
"$",
"urlTemplate",
";",
"}",
"$",
"path",
"=",
"$",
"this",
"->",
"generatePath",
"(",
"$",
"pathTemplate",
",",
"$",
"placeholders",
")",
";",
"$",
"urlPath",
"=",
"$",
"this",
"->",
"generateUrlPath",
"(",
"$",
"urlTemplate",
",",
"$",
"placeholders",
")",
";",
"return",
"new",
"Permalink",
"(",
"$",
"path",
",",
"$",
"urlPath",
")",
";",
"}"
] | Gets a permalink. This method uses the SNAPSHOT_PATH_RELATIVE_AFTER_CONVERT of Item path.
For binary items URL path and path point to SNAPSHOT_PATH_RELATIVE.
Item's attributes with special meaning:
- title: title of the item.
- title_path: title extracted from the date filename pattern.
- preserve_path_title: if true "title_path" instead of "title" will be used with ":title" placeholder.
- date: date of item.
- categories: categories for the item
- permalink: permalink sytle.
- collection: the name of the item's collection.
@param \Yosymfony\Spress\Core\DataSource\ItemInterface $item
@return \Yosymfony\Spress\Core\ContentManager\Permalink\PermalinkInterface | [
"Gets",
"a",
"permalink",
".",
"This",
"method",
"uses",
"the",
"SNAPSHOT_PATH_RELATIVE_AFTER_CONVERT",
"of",
"Item",
"path",
"."
] | a61008c4cde3ba990e7faa164462171b019a60bf | https://github.com/spress/spress-core/blob/a61008c4cde3ba990e7faa164462171b019a60bf/ContentManager/Permalink/PermalinkGenerator.php#L107-L177 | train |
DoSomething/mb-stat-tracker | src/StatHat.php | StatHat.reportCount | public function reportCount($count) {
$statName = $this->prefix . $this->statNames;
if ($this->isProduction) {
stathat_ez_count($this->ezkey, $statName, $count);
}
} | php | public function reportCount($count) {
$statName = $this->prefix . $this->statNames;
if ($this->isProduction) {
stathat_ez_count($this->ezkey, $statName, $count);
}
} | [
"public",
"function",
"reportCount",
"(",
"$",
"count",
")",
"{",
"$",
"statName",
"=",
"$",
"this",
"->",
"prefix",
".",
"$",
"this",
"->",
"statNames",
";",
"if",
"(",
"$",
"this",
"->",
"isProduction",
")",
"{",
"stathat_ez_count",
"(",
"$",
"this",
"->",
"ezkey",
",",
"$",
"statName",
",",
"$",
"count",
")",
";",
"}",
"}"
] | Reports a count to the StatHat API.
@param int $count
The count to report. | [
"Reports",
"a",
"count",
"to",
"the",
"StatHat",
"API",
"."
] | 14a8caef9128661e77492d61a09c06dd5a7ca611 | https://github.com/DoSomething/mb-stat-tracker/blob/14a8caef9128661e77492d61a09c06dd5a7ca611/src/StatHat.php#L86-L91 | train |
DoSomething/mb-stat-tracker | src/StatHat.php | StatHat.reportValue | public function reportValue($value) {
$statName = $this->prefix . $this->statNames;
if ($this->isProduction) {
stathat_ez_value($this->ezkey, $statName, $value);
}
} | php | public function reportValue($value) {
$statName = $this->prefix . $this->statNames;
if ($this->isProduction) {
stathat_ez_value($this->ezkey, $statName, $value);
}
} | [
"public",
"function",
"reportValue",
"(",
"$",
"value",
")",
"{",
"$",
"statName",
"=",
"$",
"this",
"->",
"prefix",
".",
"$",
"this",
"->",
"statNames",
";",
"if",
"(",
"$",
"this",
"->",
"isProduction",
")",
"{",
"stathat_ez_value",
"(",
"$",
"this",
"->",
"ezkey",
",",
"$",
"statName",
",",
"$",
"value",
")",
";",
"}",
"}"
] | Reports a value to the StatHat API.
@param int $value
The value to report. | [
"Reports",
"a",
"value",
"to",
"the",
"StatHat",
"API",
"."
] | 14a8caef9128661e77492d61a09c06dd5a7ca611 | https://github.com/DoSomething/mb-stat-tracker/blob/14a8caef9128661e77492d61a09c06dd5a7ca611/src/StatHat.php#L99-L104 | train |
Wedeto/Util | src/Hook.php | Hook.subscribe | public static function subscribe(string $hook, callable $callback, int $precedence = 0)
{
$parts = explode(".", $hook);
if (count($parts) < 2)
throw new InvalidArgumentException("Hook name must consist of at least two parts");
if ($hook === Hook::SHUTDOWN_HOOK)
self::registerShutdownHook();
// Make sure the callback is appropriate
if (is_object($callback))
$callback = [$callback, '__invoke'];
$refl = is_array($callback) ? new \ReflectionMethod($callback[0], $callback[1]) : new \ReflectionFunction($callback);
$params = $refl->getParameters();
if (count($params) !== 1)
throw new InvalidArgumentException("Hook must accept exactly one argument of type Dictionary");
if ($params[0]->getType() === null || $params[0]->getType()->__toString() !== Dictionary::class)
throw new InvalidArgumentException("Hook must accept exactly one argument of type Dictionary");
$ref = ++self::$sequence;
self::$hooks[$hook][] = ['precedence' => $precedence, 'callback' => $callback, 'ref' => $ref];
usort(
self::$hooks[$hook],
function (array $l, array $r) {
if ($l['precedence'] !== $r['precedence'])
return $l['precedence'] - $r['precedence'];
return $l['ref'] - $r['ref'];
}
);
return $ref;
} | php | public static function subscribe(string $hook, callable $callback, int $precedence = 0)
{
$parts = explode(".", $hook);
if (count($parts) < 2)
throw new InvalidArgumentException("Hook name must consist of at least two parts");
if ($hook === Hook::SHUTDOWN_HOOK)
self::registerShutdownHook();
// Make sure the callback is appropriate
if (is_object($callback))
$callback = [$callback, '__invoke'];
$refl = is_array($callback) ? new \ReflectionMethod($callback[0], $callback[1]) : new \ReflectionFunction($callback);
$params = $refl->getParameters();
if (count($params) !== 1)
throw new InvalidArgumentException("Hook must accept exactly one argument of type Dictionary");
if ($params[0]->getType() === null || $params[0]->getType()->__toString() !== Dictionary::class)
throw new InvalidArgumentException("Hook must accept exactly one argument of type Dictionary");
$ref = ++self::$sequence;
self::$hooks[$hook][] = ['precedence' => $precedence, 'callback' => $callback, 'ref' => $ref];
usort(
self::$hooks[$hook],
function (array $l, array $r) {
if ($l['precedence'] !== $r['precedence'])
return $l['precedence'] - $r['precedence'];
return $l['ref'] - $r['ref'];
}
);
return $ref;
} | [
"public",
"static",
"function",
"subscribe",
"(",
"string",
"$",
"hook",
",",
"callable",
"$",
"callback",
",",
"int",
"$",
"precedence",
"=",
"0",
")",
"{",
"$",
"parts",
"=",
"explode",
"(",
"\".\"",
",",
"$",
"hook",
")",
";",
"if",
"(",
"count",
"(",
"$",
"parts",
")",
"<",
"2",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Hook name must consist of at least two parts\"",
")",
";",
"if",
"(",
"$",
"hook",
"===",
"Hook",
"::",
"SHUTDOWN_HOOK",
")",
"self",
"::",
"registerShutdownHook",
"(",
")",
";",
"// Make sure the callback is appropriate",
"if",
"(",
"is_object",
"(",
"$",
"callback",
")",
")",
"$",
"callback",
"=",
"[",
"$",
"callback",
",",
"'__invoke'",
"]",
";",
"$",
"refl",
"=",
"is_array",
"(",
"$",
"callback",
")",
"?",
"new",
"\\",
"ReflectionMethod",
"(",
"$",
"callback",
"[",
"0",
"]",
",",
"$",
"callback",
"[",
"1",
"]",
")",
":",
"new",
"\\",
"ReflectionFunction",
"(",
"$",
"callback",
")",
";",
"$",
"params",
"=",
"$",
"refl",
"->",
"getParameters",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"params",
")",
"!==",
"1",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Hook must accept exactly one argument of type Dictionary\"",
")",
";",
"if",
"(",
"$",
"params",
"[",
"0",
"]",
"->",
"getType",
"(",
")",
"===",
"null",
"||",
"$",
"params",
"[",
"0",
"]",
"->",
"getType",
"(",
")",
"->",
"__toString",
"(",
")",
"!==",
"Dictionary",
"::",
"class",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Hook must accept exactly one argument of type Dictionary\"",
")",
";",
"$",
"ref",
"=",
"++",
"self",
"::",
"$",
"sequence",
";",
"self",
"::",
"$",
"hooks",
"[",
"$",
"hook",
"]",
"[",
"]",
"=",
"[",
"'precedence'",
"=>",
"$",
"precedence",
",",
"'callback'",
"=>",
"$",
"callback",
",",
"'ref'",
"=>",
"$",
"ref",
"]",
";",
"usort",
"(",
"self",
"::",
"$",
"hooks",
"[",
"$",
"hook",
"]",
",",
"function",
"(",
"array",
"$",
"l",
",",
"array",
"$",
"r",
")",
"{",
"if",
"(",
"$",
"l",
"[",
"'precedence'",
"]",
"!==",
"$",
"r",
"[",
"'precedence'",
"]",
")",
"return",
"$",
"l",
"[",
"'precedence'",
"]",
"-",
"$",
"r",
"[",
"'precedence'",
"]",
";",
"return",
"$",
"l",
"[",
"'ref'",
"]",
"-",
"$",
"r",
"[",
"'ref'",
"]",
";",
"}",
")",
";",
"return",
"$",
"ref",
";",
"}"
] | Subscribe to a hook.
@param string $hook The hook to hook into. Must contain of at least 2
parts separated by dots: vendor.hookname
@param callable $callback The callback that will be called when the hook
is executed. The function should have the
following signature: function (Dictionary $params);
@param int $precedence The lower this number, the sooner it will be
called, the higher the later. Default is 0.
Subscribers with equal precedence will be called
in the order they were registered.
@return int The hook reference number. Can be used to unsubscribe | [
"Subscribe",
"to",
"a",
"hook",
"."
] | 0e080251bbaa8e7d91ae8d02eb79c029c976744a | https://github.com/Wedeto/Util/blob/0e080251bbaa8e7d91ae8d02eb79c029c976744a/src/Hook.php#L98-L131 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.