id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
sequence | docstring
stringlengths 3
47.2k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 91
247
|
---|---|---|---|---|---|---|---|---|---|---|---|
10,700 | samsonos/cms_app_materialtable | src/App.php | App.__async_quantityFieldsRow | public function __async_quantityFieldsRow($structureId, $entityID)
{
$structureFields = null;
// Get all fields of table structure
if ($this->query->className('field')
->join('structurefield')
->cond('StructureID', $structureId)
->exec($structureFields)
) {
$fields = array();
/** @var \samson\cms\CMSField $field Field object */
foreach ($structureFields as $field) {
// Add field to fields collection
$fields[$field->id] = $field;
}
$countOfFields = $this->query->className('material')
->cond('parent_id', $entityID)
->cond('type', 3)
->cond('materialfield.FieldID', array_keys($fields))
->cond('Active', 1)
->join('materialfield')
->group_by('MaterialID')
->count();
return array('status' => 1, 'countOfFields' => $countOfFields);
} else {
return array('status' => 0);
}
} | php | public function __async_quantityFieldsRow($structureId, $entityID)
{
$structureFields = null;
// Get all fields of table structure
if ($this->query->className('field')
->join('structurefield')
->cond('StructureID', $structureId)
->exec($structureFields)
) {
$fields = array();
/** @var \samson\cms\CMSField $field Field object */
foreach ($structureFields as $field) {
// Add field to fields collection
$fields[$field->id] = $field;
}
$countOfFields = $this->query->className('material')
->cond('parent_id', $entityID)
->cond('type', 3)
->cond('materialfield.FieldID', array_keys($fields))
->cond('Active', 1)
->join('materialfield')
->group_by('MaterialID')
->count();
return array('status' => 1, 'countOfFields' => $countOfFields);
} else {
return array('status' => 0);
}
} | [
"public",
"function",
"__async_quantityFieldsRow",
"(",
"$",
"structureId",
",",
"$",
"entityID",
")",
"{",
"$",
"structureFields",
"=",
"null",
";",
"// Get all fields of table structure",
"if",
"(",
"$",
"this",
"->",
"query",
"->",
"className",
"(",
"'field'",
")",
"->",
"join",
"(",
"'structurefield'",
")",
"->",
"cond",
"(",
"'StructureID'",
",",
"$",
"structureId",
")",
"->",
"exec",
"(",
"$",
"structureFields",
")",
")",
"{",
"$",
"fields",
"=",
"array",
"(",
")",
";",
"/** @var \\samson\\cms\\CMSField $field Field object */",
"foreach",
"(",
"$",
"structureFields",
"as",
"$",
"field",
")",
"{",
"// Add field to fields collection",
"$",
"fields",
"[",
"$",
"field",
"->",
"id",
"]",
"=",
"$",
"field",
";",
"}",
"$",
"countOfFields",
"=",
"$",
"this",
"->",
"query",
"->",
"className",
"(",
"'material'",
")",
"->",
"cond",
"(",
"'parent_id'",
",",
"$",
"entityID",
")",
"->",
"cond",
"(",
"'type'",
",",
"3",
")",
"->",
"cond",
"(",
"'materialfield.FieldID'",
",",
"array_keys",
"(",
"$",
"fields",
")",
")",
"->",
"cond",
"(",
"'Active'",
",",
"1",
")",
"->",
"join",
"(",
"'materialfield'",
")",
"->",
"group_by",
"(",
"'MaterialID'",
")",
"->",
"count",
"(",
")",
";",
"return",
"array",
"(",
"'status'",
"=>",
"1",
",",
"'countOfFields'",
"=>",
"$",
"countOfFields",
")",
";",
"}",
"else",
"{",
"return",
"array",
"(",
"'status'",
"=>",
"0",
")",
";",
"}",
"}"
] | Update quantity fields table row
@param int $structureId Current table structure identifier
@param int $entityID Current table entity identifier
@return array AJAX response | [
"Update",
"quantity",
"fields",
"table",
"row"
] | 550fb1916070b6cf8cbd4fa7d61a19ca9a2d090e | https://github.com/samsonos/cms_app_materialtable/blob/550fb1916070b6cf8cbd4fa7d61a19ca9a2d090e/src/App.php#L103-L135 |
10,701 | samsonos/cms_app_materialtable | src/App.php | App.__async_add | public function __async_add($materialId, $structureId, $afterAction, $afterMaterialId, $afterStructureId)
{
/** @var \samson\cms\CMSMaterial $material Current material object */
$material = null;
// If there are no such row yet
if ($this->query->className('\samson\cms\CMSMaterial')->cond('MaterialID', $materialId)->first($material)) {
/** @var array $structures Array of structures of this material */
$structureIds = $this->query->className('structurematerial')->cond('MaterialID', $material->id)->fields('StructureID');
$structures = $this->query->className('structure')->cond('StructureID', $structureIds)->exec();
// If there are some structures
if (!empty($structures)) {
/** @var \samson\cms\Navigation $structure Table structure */
foreach ($structures as $structure) {
// If current material has incoming structure
// TODO: Sometimes array has empty values not object - needs to checked
if (isset($structure->StructureID) && ($structure->StructureID == $structureId)) {
/** @var \samson\social\Core $socialModule Social module object */
$socialModule = m('social');
/** @var \samson\activerecord\user $user User object */
$user = $socialModule->user();
// Get max priority of this structure
$maxPriority = $this->getMaxPriority($materialId, $structureId);
/** @var \samson\cms\CMSMaterial $tableMaterial New table material (table row) */
$tableMaterial = new \samson\cms\CMSMaterial(false);
$tableMaterial->type = 3;
$tableMaterial->Name = $structure->Name;
$tableMaterial->Url = $structure->Name . '-' . md5(date('Y-m-d-h-i-s'));
$tableMaterial->parent_id = $material->MaterialID;
$tableMaterial->Published = 1;
$tableMaterial->Active = 1;
$tableMaterial->priority = $maxPriority+1;
$tableMaterial->UserID = $user->id;
$tableMaterial->Created = date('Y-m-d H:m:s');
$tableMaterial->Modyfied = $tableMaterial->Created;
$tableMaterial->save();
/** @var \samson\cms\CMSNavMaterial $structureMaterial Relation between created table material
* and table structure */
$structureMaterial = new \samson\cms\CMSNavMaterial(false);
$structureMaterial->StructureID = $structureId;
$structureMaterial->MaterialID = $tableMaterial->MaterialID;
$structureMaterial->Active = 1;
$structureMaterial->save();
}
}
$result = $this->__async_table($afterMaterialId, $afterStructureId);
Event::fire('samson.cms.web.materialtable.add', array($material->id, $structureId));
// Set success status and return result
// return array('status' => 1);
return $result;
}
}
// Set fail status and return result
return array('status' => 0);
} | php | public function __async_add($materialId, $structureId, $afterAction, $afterMaterialId, $afterStructureId)
{
/** @var \samson\cms\CMSMaterial $material Current material object */
$material = null;
// If there are no such row yet
if ($this->query->className('\samson\cms\CMSMaterial')->cond('MaterialID', $materialId)->first($material)) {
/** @var array $structures Array of structures of this material */
$structureIds = $this->query->className('structurematerial')->cond('MaterialID', $material->id)->fields('StructureID');
$structures = $this->query->className('structure')->cond('StructureID', $structureIds)->exec();
// If there are some structures
if (!empty($structures)) {
/** @var \samson\cms\Navigation $structure Table structure */
foreach ($structures as $structure) {
// If current material has incoming structure
// TODO: Sometimes array has empty values not object - needs to checked
if (isset($structure->StructureID) && ($structure->StructureID == $structureId)) {
/** @var \samson\social\Core $socialModule Social module object */
$socialModule = m('social');
/** @var \samson\activerecord\user $user User object */
$user = $socialModule->user();
// Get max priority of this structure
$maxPriority = $this->getMaxPriority($materialId, $structureId);
/** @var \samson\cms\CMSMaterial $tableMaterial New table material (table row) */
$tableMaterial = new \samson\cms\CMSMaterial(false);
$tableMaterial->type = 3;
$tableMaterial->Name = $structure->Name;
$tableMaterial->Url = $structure->Name . '-' . md5(date('Y-m-d-h-i-s'));
$tableMaterial->parent_id = $material->MaterialID;
$tableMaterial->Published = 1;
$tableMaterial->Active = 1;
$tableMaterial->priority = $maxPriority+1;
$tableMaterial->UserID = $user->id;
$tableMaterial->Created = date('Y-m-d H:m:s');
$tableMaterial->Modyfied = $tableMaterial->Created;
$tableMaterial->save();
/** @var \samson\cms\CMSNavMaterial $structureMaterial Relation between created table material
* and table structure */
$structureMaterial = new \samson\cms\CMSNavMaterial(false);
$structureMaterial->StructureID = $structureId;
$structureMaterial->MaterialID = $tableMaterial->MaterialID;
$structureMaterial->Active = 1;
$structureMaterial->save();
}
}
$result = $this->__async_table($afterMaterialId, $afterStructureId);
Event::fire('samson.cms.web.materialtable.add', array($material->id, $structureId));
// Set success status and return result
// return array('status' => 1);
return $result;
}
}
// Set fail status and return result
return array('status' => 0);
} | [
"public",
"function",
"__async_add",
"(",
"$",
"materialId",
",",
"$",
"structureId",
",",
"$",
"afterAction",
",",
"$",
"afterMaterialId",
",",
"$",
"afterStructureId",
")",
"{",
"/** @var \\samson\\cms\\CMSMaterial $material Current material object */",
"$",
"material",
"=",
"null",
";",
"// If there are no such row yet",
"if",
"(",
"$",
"this",
"->",
"query",
"->",
"className",
"(",
"'\\samson\\cms\\CMSMaterial'",
")",
"->",
"cond",
"(",
"'MaterialID'",
",",
"$",
"materialId",
")",
"->",
"first",
"(",
"$",
"material",
")",
")",
"{",
"/** @var array $structures Array of structures of this material */",
"$",
"structureIds",
"=",
"$",
"this",
"->",
"query",
"->",
"className",
"(",
"'structurematerial'",
")",
"->",
"cond",
"(",
"'MaterialID'",
",",
"$",
"material",
"->",
"id",
")",
"->",
"fields",
"(",
"'StructureID'",
")",
";",
"$",
"structures",
"=",
"$",
"this",
"->",
"query",
"->",
"className",
"(",
"'structure'",
")",
"->",
"cond",
"(",
"'StructureID'",
",",
"$",
"structureIds",
")",
"->",
"exec",
"(",
")",
";",
"// If there are some structures",
"if",
"(",
"!",
"empty",
"(",
"$",
"structures",
")",
")",
"{",
"/** @var \\samson\\cms\\Navigation $structure Table structure */",
"foreach",
"(",
"$",
"structures",
"as",
"$",
"structure",
")",
"{",
"// If current material has incoming structure",
"// TODO: Sometimes array has empty values not object - needs to checked",
"if",
"(",
"isset",
"(",
"$",
"structure",
"->",
"StructureID",
")",
"&&",
"(",
"$",
"structure",
"->",
"StructureID",
"==",
"$",
"structureId",
")",
")",
"{",
"/** @var \\samson\\social\\Core $socialModule Social module object */",
"$",
"socialModule",
"=",
"m",
"(",
"'social'",
")",
";",
"/** @var \\samson\\activerecord\\user $user User object */",
"$",
"user",
"=",
"$",
"socialModule",
"->",
"user",
"(",
")",
";",
"// Get max priority of this structure",
"$",
"maxPriority",
"=",
"$",
"this",
"->",
"getMaxPriority",
"(",
"$",
"materialId",
",",
"$",
"structureId",
")",
";",
"/** @var \\samson\\cms\\CMSMaterial $tableMaterial New table material (table row) */",
"$",
"tableMaterial",
"=",
"new",
"\\",
"samson",
"\\",
"cms",
"\\",
"CMSMaterial",
"(",
"false",
")",
";",
"$",
"tableMaterial",
"->",
"type",
"=",
"3",
";",
"$",
"tableMaterial",
"->",
"Name",
"=",
"$",
"structure",
"->",
"Name",
";",
"$",
"tableMaterial",
"->",
"Url",
"=",
"$",
"structure",
"->",
"Name",
".",
"'-'",
".",
"md5",
"(",
"date",
"(",
"'Y-m-d-h-i-s'",
")",
")",
";",
"$",
"tableMaterial",
"->",
"parent_id",
"=",
"$",
"material",
"->",
"MaterialID",
";",
"$",
"tableMaterial",
"->",
"Published",
"=",
"1",
";",
"$",
"tableMaterial",
"->",
"Active",
"=",
"1",
";",
"$",
"tableMaterial",
"->",
"priority",
"=",
"$",
"maxPriority",
"+",
"1",
";",
"$",
"tableMaterial",
"->",
"UserID",
"=",
"$",
"user",
"->",
"id",
";",
"$",
"tableMaterial",
"->",
"Created",
"=",
"date",
"(",
"'Y-m-d H:m:s'",
")",
";",
"$",
"tableMaterial",
"->",
"Modyfied",
"=",
"$",
"tableMaterial",
"->",
"Created",
";",
"$",
"tableMaterial",
"->",
"save",
"(",
")",
";",
"/** @var \\samson\\cms\\CMSNavMaterial $structureMaterial Relation between created table material\n * and table structure */",
"$",
"structureMaterial",
"=",
"new",
"\\",
"samson",
"\\",
"cms",
"\\",
"CMSNavMaterial",
"(",
"false",
")",
";",
"$",
"structureMaterial",
"->",
"StructureID",
"=",
"$",
"structureId",
";",
"$",
"structureMaterial",
"->",
"MaterialID",
"=",
"$",
"tableMaterial",
"->",
"MaterialID",
";",
"$",
"structureMaterial",
"->",
"Active",
"=",
"1",
";",
"$",
"structureMaterial",
"->",
"save",
"(",
")",
";",
"}",
"}",
"$",
"result",
"=",
"$",
"this",
"->",
"__async_table",
"(",
"$",
"afterMaterialId",
",",
"$",
"afterStructureId",
")",
";",
"Event",
"::",
"fire",
"(",
"'samson.cms.web.materialtable.add'",
",",
"array",
"(",
"$",
"material",
"->",
"id",
",",
"$",
"structureId",
")",
")",
";",
"// Set success status and return result",
"// return array('status' => 1);",
"return",
"$",
"result",
";",
"}",
"}",
"// Set fail status and return result",
"return",
"array",
"(",
"'status'",
"=>",
"0",
")",
";",
"}"
] | Creating new material table row
@param int $materialId Current material identifier
@param int $structureId Current table structure identifier
@param $afterAction
@param $afterMaterialId
@param $afterStructureId
@return array AJAX response | [
"Creating",
"new",
"material",
"table",
"row"
] | 550fb1916070b6cf8cbd4fa7d61a19ca9a2d090e | https://github.com/samsonos/cms_app_materialtable/blob/550fb1916070b6cf8cbd4fa7d61a19ca9a2d090e/src/App.php#L146-L210 |
10,702 | samsonos/cms_app_materialtable | src/App.php | App.__async_delete | public function __async_delete($id, $afterAction, $afterMaterialId, $afterStructureId)
{
/** @var array $result Async response */
$result = array( 'status' => false );
/** @var \samson\cms\CMSMaterial $material */
$material = null;
// If such material exists
if ($this->query->className('\samson\cms\CMSMaterial')->id($id)->first($material)) {
// Delete this table material with it's all relations to structures and fields
$material->deleteWithRelations();
Event::fire('samson.cms.web.materialtable.delete', array($material->parent_id));
// Set success status
// $result['status'] = true;
$result = $this->__async_table($afterMaterialId, $afterStructureId);
}
// Return result
return $result;
} | php | public function __async_delete($id, $afterAction, $afterMaterialId, $afterStructureId)
{
/** @var array $result Async response */
$result = array( 'status' => false );
/** @var \samson\cms\CMSMaterial $material */
$material = null;
// If such material exists
if ($this->query->className('\samson\cms\CMSMaterial')->id($id)->first($material)) {
// Delete this table material with it's all relations to structures and fields
$material->deleteWithRelations();
Event::fire('samson.cms.web.materialtable.delete', array($material->parent_id));
// Set success status
// $result['status'] = true;
$result = $this->__async_table($afterMaterialId, $afterStructureId);
}
// Return result
return $result;
} | [
"public",
"function",
"__async_delete",
"(",
"$",
"id",
",",
"$",
"afterAction",
",",
"$",
"afterMaterialId",
",",
"$",
"afterStructureId",
")",
"{",
"/** @var array $result Async response */",
"$",
"result",
"=",
"array",
"(",
"'status'",
"=>",
"false",
")",
";",
"/** @var \\samson\\cms\\CMSMaterial $material */",
"$",
"material",
"=",
"null",
";",
"// If such material exists",
"if",
"(",
"$",
"this",
"->",
"query",
"->",
"className",
"(",
"'\\samson\\cms\\CMSMaterial'",
")",
"->",
"id",
"(",
"$",
"id",
")",
"->",
"first",
"(",
"$",
"material",
")",
")",
"{",
"// Delete this table material with it's all relations to structures and fields",
"$",
"material",
"->",
"deleteWithRelations",
"(",
")",
";",
"Event",
"::",
"fire",
"(",
"'samson.cms.web.materialtable.delete'",
",",
"array",
"(",
"$",
"material",
"->",
"parent_id",
")",
")",
";",
"// Set success status",
"// $result['status'] = true;",
"$",
"result",
"=",
"$",
"this",
"->",
"__async_table",
"(",
"$",
"afterMaterialId",
",",
"$",
"afterStructureId",
")",
";",
"}",
"// Return result",
"return",
"$",
"result",
";",
"}"
] | Controller for deleting row from material table
@param string $id Table material identifier
@param $afterAction
@param $afterMaterialId
@param $afterStructureId
@return array Async response array | [
"Controller",
"for",
"deleting",
"row",
"from",
"material",
"table"
] | 550fb1916070b6cf8cbd4fa7d61a19ca9a2d090e | https://github.com/samsonos/cms_app_materialtable/blob/550fb1916070b6cf8cbd4fa7d61a19ca9a2d090e/src/App.php#L220-L241 |
10,703 | samsonos/cms_app_materialtable | src/App.php | App.__async_copy | public function __async_copy($id, $afterAction, $afterMaterialId, $afterStructureId)
{
/** @var array $result Async response */
$result = array( 'status' => false );
/** @var \samson\cms\CMSMaterial $material */
$material = null;
// If such material exists
if ($this->query->className('\samson\cms\CMSMaterial')->id($id)->first($material)) {
// Make copy of this material
/** @var \samson\cms\CMSMaterial $copy Copy of existing material */
$copy = $material->copy();
$copy->save();
// Set success status
$result['status'] = true;
$result = $this->__async_table($afterMaterialId, $afterStructureId);
}
// Return result
return $result;
} | php | public function __async_copy($id, $afterAction, $afterMaterialId, $afterStructureId)
{
/** @var array $result Async response */
$result = array( 'status' => false );
/** @var \samson\cms\CMSMaterial $material */
$material = null;
// If such material exists
if ($this->query->className('\samson\cms\CMSMaterial')->id($id)->first($material)) {
// Make copy of this material
/** @var \samson\cms\CMSMaterial $copy Copy of existing material */
$copy = $material->copy();
$copy->save();
// Set success status
$result['status'] = true;
$result = $this->__async_table($afterMaterialId, $afterStructureId);
}
// Return result
return $result;
} | [
"public",
"function",
"__async_copy",
"(",
"$",
"id",
",",
"$",
"afterAction",
",",
"$",
"afterMaterialId",
",",
"$",
"afterStructureId",
")",
"{",
"/** @var array $result Async response */",
"$",
"result",
"=",
"array",
"(",
"'status'",
"=>",
"false",
")",
";",
"/** @var \\samson\\cms\\CMSMaterial $material */",
"$",
"material",
"=",
"null",
";",
"// If such material exists",
"if",
"(",
"$",
"this",
"->",
"query",
"->",
"className",
"(",
"'\\samson\\cms\\CMSMaterial'",
")",
"->",
"id",
"(",
"$",
"id",
")",
"->",
"first",
"(",
"$",
"material",
")",
")",
"{",
"// Make copy of this material",
"/** @var \\samson\\cms\\CMSMaterial $copy Copy of existing material */",
"$",
"copy",
"=",
"$",
"material",
"->",
"copy",
"(",
")",
";",
"$",
"copy",
"->",
"save",
"(",
")",
";",
"// Set success status",
"$",
"result",
"[",
"'status'",
"]",
"=",
"true",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"__async_table",
"(",
"$",
"afterMaterialId",
",",
"$",
"afterStructureId",
")",
";",
"}",
"// Return result",
"return",
"$",
"result",
";",
"}"
] | Controller for copying row from material table
@param string $id Table material identifier
@param $afterAction
@param $afterMaterialId
@param $afterStructureId
@return array Async response array | [
"Controller",
"for",
"copying",
"row",
"from",
"material",
"table"
] | 550fb1916070b6cf8cbd4fa7d61a19ca9a2d090e | https://github.com/samsonos/cms_app_materialtable/blob/550fb1916070b6cf8cbd4fa7d61a19ca9a2d090e/src/App.php#L251-L272 |
10,704 | samsonos/cms_app_materialtable | src/App.php | App.__async_table | public function __async_table($materialId, $structureId)
{
/** @var array $result Asynchronous response */
$result = array('status' => false);
/** @var \samson\cms\Navigation $structure Current table structure */
$structure = $this->query->className('\samson\cms\Navigation')->cond('StructureID', $structureId)->first();
$material = $this->query->className('\samson\cms\Material')->cond('MaterialID', $materialId)->first();
// If such structure exists
if (isset($structureId)) {
/** @var MaterialTableTabLocalized $tab New tab with updated table */
$tab = new MaterialTable($this, $this->query->className('\samson\cms\CMSMaterial'), $material, $structure);
// Get HTML code of this tab
$content = $tab->content();
// If need change content
Event::fire('samson.cms.web.materialtable.get.table', array($materialId, $structureId, & $content));
// Set success status and generated HTML
$result['status'] = true;
$result['table'] = $content;
}
// Return result of this controller
return $result;
} | php | public function __async_table($materialId, $structureId)
{
/** @var array $result Asynchronous response */
$result = array('status' => false);
/** @var \samson\cms\Navigation $structure Current table structure */
$structure = $this->query->className('\samson\cms\Navigation')->cond('StructureID', $structureId)->first();
$material = $this->query->className('\samson\cms\Material')->cond('MaterialID', $materialId)->first();
// If such structure exists
if (isset($structureId)) {
/** @var MaterialTableTabLocalized $tab New tab with updated table */
$tab = new MaterialTable($this, $this->query->className('\samson\cms\CMSMaterial'), $material, $structure);
// Get HTML code of this tab
$content = $tab->content();
// If need change content
Event::fire('samson.cms.web.materialtable.get.table', array($materialId, $structureId, & $content));
// Set success status and generated HTML
$result['status'] = true;
$result['table'] = $content;
}
// Return result of this controller
return $result;
} | [
"public",
"function",
"__async_table",
"(",
"$",
"materialId",
",",
"$",
"structureId",
")",
"{",
"/** @var array $result Asynchronous response */",
"$",
"result",
"=",
"array",
"(",
"'status'",
"=>",
"false",
")",
";",
"/** @var \\samson\\cms\\Navigation $structure Current table structure */",
"$",
"structure",
"=",
"$",
"this",
"->",
"query",
"->",
"className",
"(",
"'\\samson\\cms\\Navigation'",
")",
"->",
"cond",
"(",
"'StructureID'",
",",
"$",
"structureId",
")",
"->",
"first",
"(",
")",
";",
"$",
"material",
"=",
"$",
"this",
"->",
"query",
"->",
"className",
"(",
"'\\samson\\cms\\Material'",
")",
"->",
"cond",
"(",
"'MaterialID'",
",",
"$",
"materialId",
")",
"->",
"first",
"(",
")",
";",
"// If such structure exists",
"if",
"(",
"isset",
"(",
"$",
"structureId",
")",
")",
"{",
"/** @var MaterialTableTabLocalized $tab New tab with updated table */",
"$",
"tab",
"=",
"new",
"MaterialTable",
"(",
"$",
"this",
",",
"$",
"this",
"->",
"query",
"->",
"className",
"(",
"'\\samson\\cms\\CMSMaterial'",
")",
",",
"$",
"material",
",",
"$",
"structure",
")",
";",
"// Get HTML code of this tab",
"$",
"content",
"=",
"$",
"tab",
"->",
"content",
"(",
")",
";",
"// If need change content",
"Event",
"::",
"fire",
"(",
"'samson.cms.web.materialtable.get.table'",
",",
"array",
"(",
"$",
"materialId",
",",
"$",
"structureId",
",",
"&",
"$",
"content",
")",
")",
";",
"// Set success status and generated HTML",
"$",
"result",
"[",
"'status'",
"]",
"=",
"true",
";",
"$",
"result",
"[",
"'table'",
"]",
"=",
"$",
"content",
";",
"}",
"// Return result of this controller",
"return",
"$",
"result",
";",
"}"
] | Async updating material table
@param int $materialId Current material identifier
@param int $structureId Current table structure identifier
@return array Asynchronous response | [
"Async",
"updating",
"material",
"table"
] | 550fb1916070b6cf8cbd4fa7d61a19ca9a2d090e | https://github.com/samsonos/cms_app_materialtable/blob/550fb1916070b6cf8cbd4fa7d61a19ca9a2d090e/src/App.php#L280-L307 |
10,705 | samsonos/cms_app_materialtable | src/App.php | App.getMaterialTableTable | public function getMaterialTableTable($materialId, $structure, $locale = '')
{
/** @var \samson\cms\CMSMaterial $material Current material object */
$material = null;
// If material was found by identifier
if ($this->query->className('\samson\cms\CMSMaterial')->cond('MaterialID', $materialId)->first($material)) {
/** @var MaterialTableTable $table Current table object */
$table = new MaterialTableTable($material, null, $structure, $locale);
/** @var boolean $all Flag to determine non-localized tab */
$all = false;
/** @var boolean $multilingual Flag to determine localized tab */
$multilingual = false;
// If there is relation between current material and current table structure
if ($this->query->className('\samson\cms\CMSNavMaterial')
->cond('MaterialID', $materialId)
->join('structure')
->cond('StructureID', $structure->StructureID)
->first()
) {
// If table structure has at least one none localized field
if ($this->query->className('structurefield')->cond('StructureID', $structure->StructureID)
->join('field')->cond('field_local', 0)->first()
) {
// Set non-localized flag to true
$all = true;
}
// If table structure has at least one localized field
if ($this->query->className('structurefield')->cond('StructureID', $structure->StructureID)
->join('field')->cond('field_local', 1)->first()
) {
// Set localized flag to true
$multilingual = true;
}
}
// If locale is not set and none localized flag is true
// Or if locale is set and localized flag is true
// Render table to get it's HTML code
//if (($locale == '' && $all) || ($locale != '' && $multilingual)) {
return $this->view('tab_view')
->set($table->render(), 'table')
->set($materialId, 'materialId')
->set($structure->StructureID, 'structureId')
->output();
//}
}
// Return empty string on fail
return '';
} | php | public function getMaterialTableTable($materialId, $structure, $locale = '')
{
/** @var \samson\cms\CMSMaterial $material Current material object */
$material = null;
// If material was found by identifier
if ($this->query->className('\samson\cms\CMSMaterial')->cond('MaterialID', $materialId)->first($material)) {
/** @var MaterialTableTable $table Current table object */
$table = new MaterialTableTable($material, null, $structure, $locale);
/** @var boolean $all Flag to determine non-localized tab */
$all = false;
/** @var boolean $multilingual Flag to determine localized tab */
$multilingual = false;
// If there is relation between current material and current table structure
if ($this->query->className('\samson\cms\CMSNavMaterial')
->cond('MaterialID', $materialId)
->join('structure')
->cond('StructureID', $structure->StructureID)
->first()
) {
// If table structure has at least one none localized field
if ($this->query->className('structurefield')->cond('StructureID', $structure->StructureID)
->join('field')->cond('field_local', 0)->first()
) {
// Set non-localized flag to true
$all = true;
}
// If table structure has at least one localized field
if ($this->query->className('structurefield')->cond('StructureID', $structure->StructureID)
->join('field')->cond('field_local', 1)->first()
) {
// Set localized flag to true
$multilingual = true;
}
}
// If locale is not set and none localized flag is true
// Or if locale is set and localized flag is true
// Render table to get it's HTML code
//if (($locale == '' && $all) || ($locale != '' && $multilingual)) {
return $this->view('tab_view')
->set($table->render(), 'table')
->set($materialId, 'materialId')
->set($structure->StructureID, 'structureId')
->output();
//}
}
// Return empty string on fail
return '';
} | [
"public",
"function",
"getMaterialTableTable",
"(",
"$",
"materialId",
",",
"$",
"structure",
",",
"$",
"locale",
"=",
"''",
")",
"{",
"/** @var \\samson\\cms\\CMSMaterial $material Current material object */",
"$",
"material",
"=",
"null",
";",
"// If material was found by identifier",
"if",
"(",
"$",
"this",
"->",
"query",
"->",
"className",
"(",
"'\\samson\\cms\\CMSMaterial'",
")",
"->",
"cond",
"(",
"'MaterialID'",
",",
"$",
"materialId",
")",
"->",
"first",
"(",
"$",
"material",
")",
")",
"{",
"/** @var MaterialTableTable $table Current table object */",
"$",
"table",
"=",
"new",
"MaterialTableTable",
"(",
"$",
"material",
",",
"null",
",",
"$",
"structure",
",",
"$",
"locale",
")",
";",
"/** @var boolean $all Flag to determine non-localized tab */",
"$",
"all",
"=",
"false",
";",
"/** @var boolean $multilingual Flag to determine localized tab */",
"$",
"multilingual",
"=",
"false",
";",
"// If there is relation between current material and current table structure",
"if",
"(",
"$",
"this",
"->",
"query",
"->",
"className",
"(",
"'\\samson\\cms\\CMSNavMaterial'",
")",
"->",
"cond",
"(",
"'MaterialID'",
",",
"$",
"materialId",
")",
"->",
"join",
"(",
"'structure'",
")",
"->",
"cond",
"(",
"'StructureID'",
",",
"$",
"structure",
"->",
"StructureID",
")",
"->",
"first",
"(",
")",
")",
"{",
"// If table structure has at least one none localized field",
"if",
"(",
"$",
"this",
"->",
"query",
"->",
"className",
"(",
"'structurefield'",
")",
"->",
"cond",
"(",
"'StructureID'",
",",
"$",
"structure",
"->",
"StructureID",
")",
"->",
"join",
"(",
"'field'",
")",
"->",
"cond",
"(",
"'field_local'",
",",
"0",
")",
"->",
"first",
"(",
")",
")",
"{",
"// Set non-localized flag to true",
"$",
"all",
"=",
"true",
";",
"}",
"// If table structure has at least one localized field",
"if",
"(",
"$",
"this",
"->",
"query",
"->",
"className",
"(",
"'structurefield'",
")",
"->",
"cond",
"(",
"'StructureID'",
",",
"$",
"structure",
"->",
"StructureID",
")",
"->",
"join",
"(",
"'field'",
")",
"->",
"cond",
"(",
"'field_local'",
",",
"1",
")",
"->",
"first",
"(",
")",
")",
"{",
"// Set localized flag to true",
"$",
"multilingual",
"=",
"true",
";",
"}",
"}",
"// If locale is not set and none localized flag is true",
"// Or if locale is set and localized flag is true",
"// Render table to get it's HTML code",
"//if (($locale == '' && $all) || ($locale != '' && $multilingual)) {",
"return",
"$",
"this",
"->",
"view",
"(",
"'tab_view'",
")",
"->",
"set",
"(",
"$",
"table",
"->",
"render",
"(",
")",
",",
"'table'",
")",
"->",
"set",
"(",
"$",
"materialId",
",",
"'materialId'",
")",
"->",
"set",
"(",
"$",
"structure",
"->",
"StructureID",
",",
"'structureId'",
")",
"->",
"output",
"(",
")",
";",
"//}",
"}",
"// Return empty string on fail",
"return",
"''",
";",
"}"
] | Function to generate new table
@param int $materialId Current material identifier
@param \samson\cms\Navigation $structure Current table structure
@param string $locale Current locale
@return string Generated table HTML | [
"Function",
"to",
"generate",
"new",
"table"
] | 550fb1916070b6cf8cbd4fa7d61a19ca9a2d090e | https://github.com/samsonos/cms_app_materialtable/blob/550fb1916070b6cf8cbd4fa7d61a19ca9a2d090e/src/App.php#L345-L398 |
10,706 | kuria/enum | src/Enum.php | Enum.hasKey | static function hasKey(string $key): bool
{
self::ensureKeyMapLoaded();
return isset(self::$keyMap[static::class][$key]);
} | php | static function hasKey(string $key): bool
{
self::ensureKeyMapLoaded();
return isset(self::$keyMap[static::class][$key]);
} | [
"static",
"function",
"hasKey",
"(",
"string",
"$",
"key",
")",
":",
"bool",
"{",
"self",
"::",
"ensureKeyMapLoaded",
"(",
")",
";",
"return",
"isset",
"(",
"self",
"::",
"$",
"keyMap",
"[",
"static",
"::",
"class",
"]",
"[",
"$",
"key",
"]",
")",
";",
"}"
] | Check if the given key exists in this enum | [
"Check",
"if",
"the",
"given",
"key",
"exists",
"in",
"this",
"enum"
] | 9d9c1907f8a6910552b50b175398393909028eaa | https://github.com/kuria/enum/blob/9d9c1907f8a6910552b50b175398393909028eaa/src/Enum.php#L65-L70 |
10,707 | kuria/enum | src/Enum.php | Enum.findValue | static function findValue(string $key)
{
return self::hasKey($key)
? self::$keyToValueMap[static::class][$key]
: null;
} | php | static function findValue(string $key)
{
return self::hasKey($key)
? self::$keyToValueMap[static::class][$key]
: null;
} | [
"static",
"function",
"findValue",
"(",
"string",
"$",
"key",
")",
"{",
"return",
"self",
"::",
"hasKey",
"(",
"$",
"key",
")",
"?",
"self",
"::",
"$",
"keyToValueMap",
"[",
"static",
"::",
"class",
"]",
"[",
"$",
"key",
"]",
":",
"null",
";",
"}"
] | Attempt to find a value by its key. Returns NULL on failure. | [
"Attempt",
"to",
"find",
"a",
"value",
"by",
"its",
"key",
".",
"Returns",
"NULL",
"on",
"failure",
"."
] | 9d9c1907f8a6910552b50b175398393909028eaa | https://github.com/kuria/enum/blob/9d9c1907f8a6910552b50b175398393909028eaa/src/Enum.php#L95-L100 |
10,708 | kuria/enum | src/Enum.php | Enum.findKey | static function findKey($value): ?string
{
return self::hasValue($value)
? self::$valueToKeyMap[static::class][$value]
: null;
} | php | static function findKey($value): ?string
{
return self::hasValue($value)
? self::$valueToKeyMap[static::class][$value]
: null;
} | [
"static",
"function",
"findKey",
"(",
"$",
"value",
")",
":",
"?",
"string",
"{",
"return",
"self",
"::",
"hasValue",
"(",
"$",
"value",
")",
"?",
"self",
"::",
"$",
"valueToKeyMap",
"[",
"static",
"::",
"class",
"]",
"[",
"$",
"value",
"]",
":",
"null",
";",
"}"
] | Attempt to find a key by its value. Returns NULL on failure. | [
"Attempt",
"to",
"find",
"a",
"key",
"by",
"its",
"value",
".",
"Returns",
"NULL",
"on",
"failure",
"."
] | 9d9c1907f8a6910552b50b175398393909028eaa | https://github.com/kuria/enum/blob/9d9c1907f8a6910552b50b175398393909028eaa/src/Enum.php#L115-L120 |
10,709 | kuria/enum | src/Enum.php | Enum.ensureKey | static function ensureKey(string $key)
{
if (!self::hasKey($key)) {
throw new InvalidKeyException(sprintf(
'The key "%s" is not defined in enum class "%s", known keys: %s',
$key,
static::class,
implode(', ', self::getKeys())
));
}
} | php | static function ensureKey(string $key)
{
if (!self::hasKey($key)) {
throw new InvalidKeyException(sprintf(
'The key "%s" is not defined in enum class "%s", known keys: %s',
$key,
static::class,
implode(', ', self::getKeys())
));
}
} | [
"static",
"function",
"ensureKey",
"(",
"string",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"self",
"::",
"hasKey",
"(",
"$",
"key",
")",
")",
"{",
"throw",
"new",
"InvalidKeyException",
"(",
"sprintf",
"(",
"'The key \"%s\" is not defined in enum class \"%s\", known keys: %s'",
",",
"$",
"key",
",",
"static",
"::",
"class",
",",
"implode",
"(",
"', '",
",",
"self",
"::",
"getKeys",
"(",
")",
")",
")",
")",
";",
"}",
"}"
] | Ensure that a key exists
@throws InvalidKeyException if there is no such key | [
"Ensure",
"that",
"a",
"key",
"exists"
] | 9d9c1907f8a6910552b50b175398393909028eaa | https://github.com/kuria/enum/blob/9d9c1907f8a6910552b50b175398393909028eaa/src/Enum.php#L207-L217 |
10,710 | kuria/enum | src/Enum.php | Enum.ensureValue | static function ensureValue($value)
{
if (!self::hasValue($value)) {
throw new InvalidValueException(sprintf(
'The value %s is not defined in enum class "%s", known values: %s',
self::dumpValue($value),
static::class,
implode(', ', array_map([static::class, 'dumpValue'], self::getValues()))
));
}
} | php | static function ensureValue($value)
{
if (!self::hasValue($value)) {
throw new InvalidValueException(sprintf(
'The value %s is not defined in enum class "%s", known values: %s',
self::dumpValue($value),
static::class,
implode(', ', array_map([static::class, 'dumpValue'], self::getValues()))
));
}
} | [
"static",
"function",
"ensureValue",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"self",
"::",
"hasValue",
"(",
"$",
"value",
")",
")",
"{",
"throw",
"new",
"InvalidValueException",
"(",
"sprintf",
"(",
"'The value %s is not defined in enum class \"%s\", known values: %s'",
",",
"self",
"::",
"dumpValue",
"(",
"$",
"value",
")",
",",
"static",
"::",
"class",
",",
"implode",
"(",
"', '",
",",
"array_map",
"(",
"[",
"static",
"::",
"class",
",",
"'dumpValue'",
"]",
",",
"self",
"::",
"getValues",
"(",
")",
")",
")",
")",
")",
";",
"}",
"}"
] | Ensure that a value exists
@throws InvalidValueException if there is no such value | [
"Ensure",
"that",
"a",
"value",
"exists"
] | 9d9c1907f8a6910552b50b175398393909028eaa | https://github.com/kuria/enum/blob/9d9c1907f8a6910552b50b175398393909028eaa/src/Enum.php#L224-L234 |
10,711 | kuria/enum | src/Enum.php | Enum.determineKeyToValueMap | protected static function determineKeyToValueMap(): array
{
// default behavior is to use all public constants of the current class
$keyToValueMap = [];
foreach ((new \ReflectionClass(static::class))->getReflectionConstants() as $constant) {
if ($constant->isPublic()) {
$keyToValueMap[$constant->name] = $constant->getValue();
}
}
return $keyToValueMap;
} | php | protected static function determineKeyToValueMap(): array
{
// default behavior is to use all public constants of the current class
$keyToValueMap = [];
foreach ((new \ReflectionClass(static::class))->getReflectionConstants() as $constant) {
if ($constant->isPublic()) {
$keyToValueMap[$constant->name] = $constant->getValue();
}
}
return $keyToValueMap;
} | [
"protected",
"static",
"function",
"determineKeyToValueMap",
"(",
")",
":",
"array",
"{",
"// default behavior is to use all public constants of the current class",
"$",
"keyToValueMap",
"=",
"[",
"]",
";",
"foreach",
"(",
"(",
"new",
"\\",
"ReflectionClass",
"(",
"static",
"::",
"class",
")",
")",
"->",
"getReflectionConstants",
"(",
")",
"as",
"$",
"constant",
")",
"{",
"if",
"(",
"$",
"constant",
"->",
"isPublic",
"(",
")",
")",
"{",
"$",
"keyToValueMap",
"[",
"$",
"constant",
"->",
"name",
"]",
"=",
"$",
"constant",
"->",
"getValue",
"(",
")",
";",
"}",
"}",
"return",
"$",
"keyToValueMap",
";",
"}"
] | Determine keys and values containing in this enum
The returned array must have string keys and string|int|null values.
@return array | [
"Determine",
"keys",
"and",
"values",
"containing",
"in",
"this",
"enum"
] | 9d9c1907f8a6910552b50b175398393909028eaa | https://github.com/kuria/enum/blob/9d9c1907f8a6910552b50b175398393909028eaa/src/Enum.php#L297-L309 |
10,712 | harvestcloud/CoreBundle | Entity/Account.php | Account.getAccountNameSuffix | public static function getAccountNameSuffix($type_code)
{
switch ($type_code)
{
case Account::TYPE_ACCOUNTS_RECEIVABLE: return ' A/R';
case Account::TYPE_ACCOUNTS_PAYABLE: return ' A/P';
case Account::TYPE_SALES: return ' Sales';
case Account::TYPE_BANK: return ' Bank';
default:
throw new \Exception('Incorrect type_code: '.$type_code);
}
} | php | public static function getAccountNameSuffix($type_code)
{
switch ($type_code)
{
case Account::TYPE_ACCOUNTS_RECEIVABLE: return ' A/R';
case Account::TYPE_ACCOUNTS_PAYABLE: return ' A/P';
case Account::TYPE_SALES: return ' Sales';
case Account::TYPE_BANK: return ' Bank';
default:
throw new \Exception('Incorrect type_code: '.$type_code);
}
} | [
"public",
"static",
"function",
"getAccountNameSuffix",
"(",
"$",
"type_code",
")",
"{",
"switch",
"(",
"$",
"type_code",
")",
"{",
"case",
"Account",
"::",
"TYPE_ACCOUNTS_RECEIVABLE",
":",
"return",
"' A/R'",
";",
"case",
"Account",
"::",
"TYPE_ACCOUNTS_PAYABLE",
":",
"return",
"' A/P'",
";",
"case",
"Account",
"::",
"TYPE_SALES",
":",
"return",
"' Sales'",
";",
"case",
"Account",
"::",
"TYPE_BANK",
":",
"return",
"' Bank'",
";",
"default",
":",
"throw",
"new",
"\\",
"Exception",
"(",
"'Incorrect type_code: '",
".",
"$",
"type_code",
")",
";",
"}",
"}"
] | Get account name suffix
@author Tom Haskins-Vaughan <[email protected]>
@since 2012-05-21
@return string | [
"Get",
"account",
"name",
"suffix"
] | f33e079c4a6191cf674aa2678f2fb2e6f0dd89cc | https://github.com/harvestcloud/CoreBundle/blob/f33e079c4a6191cf674aa2678f2fb2e6f0dd89cc/Entity/Account.php#L252-L265 |
10,713 | kompakt/mediameister | lib/Util/Filesystem/Directory.php | Directory.copyChildren | public function copyChildren($targetDir)
{
$info = new \SplFileInfo($targetDir);
if (!$info->isDir())
{
throw new InvalidArgumentException(sprintf('Target dir not found'));
}
if (!$info->isReadable())
{
throw new InvalidArgumentException(sprintf('Target dir not readable'));
}
if (!$info->isWritable())
{
throw new InvalidArgumentException(sprintf('Target dir not writable'));
}
$files = new \RecursiveIteratorIterator(
new \RecursiveDirectoryIterator($this->dir, \FilesystemIterator::SKIP_DOTS),
\RecursiveIteratorIterator::SELF_FIRST
);
foreach($files as $info)
{
$sourcePathname = $info->getPathname();
$subdirPathname = $this->subtractBasedir($sourcePathname, $this->dir);
$targetPathname = sprintf('%s/%s', $targetDir, $subdirPathname);
if ($info->isDir())
{
mkdir($targetPathname);
}
else {
copy($sourcePathname, $targetPathname);
}
}
} | php | public function copyChildren($targetDir)
{
$info = new \SplFileInfo($targetDir);
if (!$info->isDir())
{
throw new InvalidArgumentException(sprintf('Target dir not found'));
}
if (!$info->isReadable())
{
throw new InvalidArgumentException(sprintf('Target dir not readable'));
}
if (!$info->isWritable())
{
throw new InvalidArgumentException(sprintf('Target dir not writable'));
}
$files = new \RecursiveIteratorIterator(
new \RecursiveDirectoryIterator($this->dir, \FilesystemIterator::SKIP_DOTS),
\RecursiveIteratorIterator::SELF_FIRST
);
foreach($files as $info)
{
$sourcePathname = $info->getPathname();
$subdirPathname = $this->subtractBasedir($sourcePathname, $this->dir);
$targetPathname = sprintf('%s/%s', $targetDir, $subdirPathname);
if ($info->isDir())
{
mkdir($targetPathname);
}
else {
copy($sourcePathname, $targetPathname);
}
}
} | [
"public",
"function",
"copyChildren",
"(",
"$",
"targetDir",
")",
"{",
"$",
"info",
"=",
"new",
"\\",
"SplFileInfo",
"(",
"$",
"targetDir",
")",
";",
"if",
"(",
"!",
"$",
"info",
"->",
"isDir",
"(",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Target dir not found'",
")",
")",
";",
"}",
"if",
"(",
"!",
"$",
"info",
"->",
"isReadable",
"(",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Target dir not readable'",
")",
")",
";",
"}",
"if",
"(",
"!",
"$",
"info",
"->",
"isWritable",
"(",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Target dir not writable'",
")",
")",
";",
"}",
"$",
"files",
"=",
"new",
"\\",
"RecursiveIteratorIterator",
"(",
"new",
"\\",
"RecursiveDirectoryIterator",
"(",
"$",
"this",
"->",
"dir",
",",
"\\",
"FilesystemIterator",
"::",
"SKIP_DOTS",
")",
",",
"\\",
"RecursiveIteratorIterator",
"::",
"SELF_FIRST",
")",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"info",
")",
"{",
"$",
"sourcePathname",
"=",
"$",
"info",
"->",
"getPathname",
"(",
")",
";",
"$",
"subdirPathname",
"=",
"$",
"this",
"->",
"subtractBasedir",
"(",
"$",
"sourcePathname",
",",
"$",
"this",
"->",
"dir",
")",
";",
"$",
"targetPathname",
"=",
"sprintf",
"(",
"'%s/%s'",
",",
"$",
"targetDir",
",",
"$",
"subdirPathname",
")",
";",
"if",
"(",
"$",
"info",
"->",
"isDir",
"(",
")",
")",
"{",
"mkdir",
"(",
"$",
"targetPathname",
")",
";",
"}",
"else",
"{",
"copy",
"(",
"$",
"sourcePathname",
",",
"$",
"targetPathname",
")",
";",
"}",
"}",
"}"
] | Copy the children of this directory into targetDir
@param string $targetDir Target directory pathname
@return void | [
"Copy",
"the",
"children",
"of",
"this",
"directory",
"into",
"targetDir"
] | 370baa5532b4a4b57810d8d7a06061b2432599cb | https://github.com/kompakt/mediameister/blob/370baa5532b4a4b57810d8d7a06061b2432599cb/lib/Util/Filesystem/Directory.php#L42-L80 |
10,714 | kompakt/mediameister | lib/Util/Filesystem/Directory.php | Directory.moveChildren | public function moveChildren($targetDir)
{
$info = new \SplFileInfo($targetDir);
if (!$info->isDir())
{
throw new InvalidArgumentException(sprintf('Target dir not found'));
}
if (!$info->isReadable())
{
throw new InvalidArgumentException(sprintf('Target dir not readable'));
}
if (!$info->isWritable())
{
throw new InvalidArgumentException(sprintf('Target dir not writable'));
}
foreach (new \DirectoryIterator($this->dir) as $info)
{
if ($info->isDot())
{
continue;
}
$sourcePathname = $info->getPathname();
$subdirPathname = $this->subtractBasedir($sourcePathname, $this->dir);
$targetPathname = sprintf('%s/%s', $targetDir, $subdirPathname);
rename($sourcePathname, $targetPathname);
}
} | php | public function moveChildren($targetDir)
{
$info = new \SplFileInfo($targetDir);
if (!$info->isDir())
{
throw new InvalidArgumentException(sprintf('Target dir not found'));
}
if (!$info->isReadable())
{
throw new InvalidArgumentException(sprintf('Target dir not readable'));
}
if (!$info->isWritable())
{
throw new InvalidArgumentException(sprintf('Target dir not writable'));
}
foreach (new \DirectoryIterator($this->dir) as $info)
{
if ($info->isDot())
{
continue;
}
$sourcePathname = $info->getPathname();
$subdirPathname = $this->subtractBasedir($sourcePathname, $this->dir);
$targetPathname = sprintf('%s/%s', $targetDir, $subdirPathname);
rename($sourcePathname, $targetPathname);
}
} | [
"public",
"function",
"moveChildren",
"(",
"$",
"targetDir",
")",
"{",
"$",
"info",
"=",
"new",
"\\",
"SplFileInfo",
"(",
"$",
"targetDir",
")",
";",
"if",
"(",
"!",
"$",
"info",
"->",
"isDir",
"(",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Target dir not found'",
")",
")",
";",
"}",
"if",
"(",
"!",
"$",
"info",
"->",
"isReadable",
"(",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Target dir not readable'",
")",
")",
";",
"}",
"if",
"(",
"!",
"$",
"info",
"->",
"isWritable",
"(",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Target dir not writable'",
")",
")",
";",
"}",
"foreach",
"(",
"new",
"\\",
"DirectoryIterator",
"(",
"$",
"this",
"->",
"dir",
")",
"as",
"$",
"info",
")",
"{",
"if",
"(",
"$",
"info",
"->",
"isDot",
"(",
")",
")",
"{",
"continue",
";",
"}",
"$",
"sourcePathname",
"=",
"$",
"info",
"->",
"getPathname",
"(",
")",
";",
"$",
"subdirPathname",
"=",
"$",
"this",
"->",
"subtractBasedir",
"(",
"$",
"sourcePathname",
",",
"$",
"this",
"->",
"dir",
")",
";",
"$",
"targetPathname",
"=",
"sprintf",
"(",
"'%s/%s'",
",",
"$",
"targetDir",
",",
"$",
"subdirPathname",
")",
";",
"rename",
"(",
"$",
"sourcePathname",
",",
"$",
"targetPathname",
")",
";",
"}",
"}"
] | Move the children of this directory into targetDir
@param string $targetDir Target directory pathname
@return void | [
"Move",
"the",
"children",
"of",
"this",
"directory",
"into",
"targetDir"
] | 370baa5532b4a4b57810d8d7a06061b2432599cb | https://github.com/kompakt/mediameister/blob/370baa5532b4a4b57810d8d7a06061b2432599cb/lib/Util/Filesystem/Directory.php#L89-L120 |
10,715 | infinity-next/eightdown | src/Traits/ParsedownExtensibility.php | ParsedownExtensibility.extendBlock | public function extendBlock($blockName, Closure $closure)
{
$blockName = ucfirst(strtolower($blockName));
$methodName = camel_case("block_{$blockName}");
return $this->bindElementClosure($methodName, $closure);
} | php | public function extendBlock($blockName, Closure $closure)
{
$blockName = ucfirst(strtolower($blockName));
$methodName = camel_case("block_{$blockName}");
return $this->bindElementClosure($methodName, $closure);
} | [
"public",
"function",
"extendBlock",
"(",
"$",
"blockName",
",",
"Closure",
"$",
"closure",
")",
"{",
"$",
"blockName",
"=",
"ucfirst",
"(",
"strtolower",
"(",
"$",
"blockName",
")",
")",
";",
"$",
"methodName",
"=",
"camel_case",
"(",
"\"block_{$blockName}\"",
")",
";",
"return",
"$",
"this",
"->",
"bindElementClosure",
"(",
"$",
"methodName",
",",
"$",
"closure",
")",
";",
"}"
] | Adds a Block closure that handles the start of an element.
@param string $blockName
@param Closure $closure
@return boolean | [
"Adds",
"a",
"Block",
"closure",
"that",
"handles",
"the",
"start",
"of",
"an",
"element",
"."
] | e3ec0b573110a244880d09f1c92f1e932632733b | https://github.com/infinity-next/eightdown/blob/e3ec0b573110a244880d09f1c92f1e932632733b/src/Traits/ParsedownExtensibility.php#L16-L22 |
10,716 | infinity-next/eightdown | src/Traits/ParsedownExtensibility.php | ParsedownExtensibility.extendInline | public function extendInline($inlineName, Closure $closure)
{
$blockName = ucfirst(strtolower($inlineName));
$methodName = camel_case("inline_{$inlineName}");
return $this->bindElementClosure($methodName, $closure);
} | php | public function extendInline($inlineName, Closure $closure)
{
$blockName = ucfirst(strtolower($inlineName));
$methodName = camel_case("inline_{$inlineName}");
return $this->bindElementClosure($methodName, $closure);
} | [
"public",
"function",
"extendInline",
"(",
"$",
"inlineName",
",",
"Closure",
"$",
"closure",
")",
"{",
"$",
"blockName",
"=",
"ucfirst",
"(",
"strtolower",
"(",
"$",
"inlineName",
")",
")",
";",
"$",
"methodName",
"=",
"camel_case",
"(",
"\"inline_{$inlineName}\"",
")",
";",
"return",
"$",
"this",
"->",
"bindElementClosure",
"(",
"$",
"methodName",
",",
"$",
"closure",
")",
";",
"}"
] | Adds an Inline closure that handles the entirety of an inline element.
@param string $inlineName
@param Closure $closure
@return boolean | [
"Adds",
"an",
"Inline",
"closure",
"that",
"handles",
"the",
"entirety",
"of",
"an",
"inline",
"element",
"."
] | e3ec0b573110a244880d09f1c92f1e932632733b | https://github.com/infinity-next/eightdown/blob/e3ec0b573110a244880d09f1c92f1e932632733b/src/Traits/ParsedownExtensibility.php#L61-L67 |
10,717 | infinity-next/eightdown | src/Traits/ParsedownExtensibility.php | ParsedownExtensibility.bindElementClosure | protected function bindElementClosure($methodName, Closure $closure)
{
$this->elementClosures[$methodName] = $closure->bindTo($this);
return $this;
} | php | protected function bindElementClosure($methodName, Closure $closure)
{
$this->elementClosures[$methodName] = $closure->bindTo($this);
return $this;
} | [
"protected",
"function",
"bindElementClosure",
"(",
"$",
"methodName",
",",
"Closure",
"$",
"closure",
")",
"{",
"$",
"this",
"->",
"elementClosures",
"[",
"$",
"methodName",
"]",
"=",
"$",
"closure",
"->",
"bindTo",
"(",
"$",
"this",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Adds a closure that handles the start of an element.
@param string $blockName
@param Closure $closure
@return boolean | [
"Adds",
"a",
"closure",
"that",
"handles",
"the",
"start",
"of",
"an",
"element",
"."
] | e3ec0b573110a244880d09f1c92f1e932632733b | https://github.com/infinity-next/eightdown/blob/e3ec0b573110a244880d09f1c92f1e932632733b/src/Traits/ParsedownExtensibility.php#L76-L81 |
10,718 | infinity-next/eightdown | src/Traits/ParsedownExtensibility.php | ParsedownExtensibility.addInlineType | public function addInlineType($Marker, $Type)
{
if (!isset($this->InlineTypes[$Marker]))
{
$this->InlineTypes[$Marker] = [];
$this->inlineMarkerList .= $Marker;
}
$InlineTypes = &$this->InlineTypes[$Marker];
array_unshift($InlineTypes, $Type);
return $this;
} | php | public function addInlineType($Marker, $Type)
{
if (!isset($this->InlineTypes[$Marker]))
{
$this->InlineTypes[$Marker] = [];
$this->inlineMarkerList .= $Marker;
}
$InlineTypes = &$this->InlineTypes[$Marker];
array_unshift($InlineTypes, $Type);
return $this;
} | [
"public",
"function",
"addInlineType",
"(",
"$",
"Marker",
",",
"$",
"Type",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"InlineTypes",
"[",
"$",
"Marker",
"]",
")",
")",
"{",
"$",
"this",
"->",
"InlineTypes",
"[",
"$",
"Marker",
"]",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"inlineMarkerList",
".=",
"$",
"Marker",
";",
"}",
"$",
"InlineTypes",
"=",
"&",
"$",
"this",
"->",
"InlineTypes",
"[",
"$",
"Marker",
"]",
";",
"array_unshift",
"(",
"$",
"InlineTypes",
",",
"$",
"Type",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Extends the inline parser dictionary.
@param
@return | [
"Extends",
"the",
"inline",
"parser",
"dictionary",
"."
] | e3ec0b573110a244880d09f1c92f1e932632733b | https://github.com/infinity-next/eightdown/blob/e3ec0b573110a244880d09f1c92f1e932632733b/src/Traits/ParsedownExtensibility.php#L89-L101 |
10,719 | infinity-next/eightdown | src/Traits/ParsedownExtensibility.php | ParsedownExtensibility.addBlockType | public function addBlockType($Marker, $Type)
{
if (!isset($this->BlockTypes[$Marker]))
{
$this->BlockTypes[$Marker] = [];
}
$BlockTypes = &$this->BlockTypes[$Marker];
array_unshift($BlockTypes, $Type);
return $this;
} | php | public function addBlockType($Marker, $Type)
{
if (!isset($this->BlockTypes[$Marker]))
{
$this->BlockTypes[$Marker] = [];
}
$BlockTypes = &$this->BlockTypes[$Marker];
array_unshift($BlockTypes, $Type);
return $this;
} | [
"public",
"function",
"addBlockType",
"(",
"$",
"Marker",
",",
"$",
"Type",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"BlockTypes",
"[",
"$",
"Marker",
"]",
")",
")",
"{",
"$",
"this",
"->",
"BlockTypes",
"[",
"$",
"Marker",
"]",
"=",
"[",
"]",
";",
"}",
"$",
"BlockTypes",
"=",
"&",
"$",
"this",
"->",
"BlockTypes",
"[",
"$",
"Marker",
"]",
";",
"array_unshift",
"(",
"$",
"BlockTypes",
",",
"$",
"Type",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Extends the block parser dictionary.
@param
@return | [
"Extends",
"the",
"block",
"parser",
"dictionary",
"."
] | e3ec0b573110a244880d09f1c92f1e932632733b | https://github.com/infinity-next/eightdown/blob/e3ec0b573110a244880d09f1c92f1e932632733b/src/Traits/ParsedownExtensibility.php#L109-L120 |
10,720 | infinity-next/eightdown | src/Traits/ParsedownExtensibility.php | ParsedownExtensibility.removeInlineByMarker | public function removeInlineByMarker($element)
{
$this->disableElementInArray($marker, $this->InlineTypes, $this->inlineMarkerList);
return $this;
} | php | public function removeInlineByMarker($element)
{
$this->disableElementInArray($marker, $this->InlineTypes, $this->inlineMarkerList);
return $this;
} | [
"public",
"function",
"removeInlineByMarker",
"(",
"$",
"element",
")",
"{",
"$",
"this",
"->",
"disableElementInArray",
"(",
"$",
"marker",
",",
"$",
"this",
"->",
"InlineTypes",
",",
"$",
"this",
"->",
"inlineMarkerList",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Removes any reference to this inline marker in Parsedown.
@param string $marker
@return Parsedown | [
"Removes",
"any",
"reference",
"to",
"this",
"inline",
"marker",
"in",
"Parsedown",
"."
] | e3ec0b573110a244880d09f1c92f1e932632733b | https://github.com/infinity-next/eightdown/blob/e3ec0b573110a244880d09f1c92f1e932632733b/src/Traits/ParsedownExtensibility.php#L155-L160 |
10,721 | yii2lab/yii2-misc | src/yii/base/Model.php | Model.loadModel | protected function loadModel($id = null)
{
/** @var BaseActiveRecord $modelClass */
$modelClass = $this->modelClass();
if($id) {
$this->modelInstance = $modelClass::findOne($id);
} else {
$this->modelInstance = new $modelClass();
}
$this->modelInstance->load($this->attributes, '');
return $this->modelInstance;
} | php | protected function loadModel($id = null)
{
/** @var BaseActiveRecord $modelClass */
$modelClass = $this->modelClass();
if($id) {
$this->modelInstance = $modelClass::findOne($id);
} else {
$this->modelInstance = new $modelClass();
}
$this->modelInstance->load($this->attributes, '');
return $this->modelInstance;
} | [
"protected",
"function",
"loadModel",
"(",
"$",
"id",
"=",
"null",
")",
"{",
"/** @var BaseActiveRecord $modelClass */",
"$",
"modelClass",
"=",
"$",
"this",
"->",
"modelClass",
"(",
")",
";",
"if",
"(",
"$",
"id",
")",
"{",
"$",
"this",
"->",
"modelInstance",
"=",
"$",
"modelClass",
"::",
"findOne",
"(",
"$",
"id",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"modelInstance",
"=",
"new",
"$",
"modelClass",
"(",
")",
";",
"}",
"$",
"this",
"->",
"modelInstance",
"->",
"load",
"(",
"$",
"this",
"->",
"attributes",
",",
"''",
")",
";",
"return",
"$",
"this",
"->",
"modelInstance",
";",
"}"
] | load model instance.
@param integer|null $id
@return BaseActiveRecord|null the saved model or null if saving fails | [
"load",
"model",
"instance",
"."
] | 7d46f97363954270d18989a72d4eccdfda361de3 | https://github.com/yii2lab/yii2-misc/blob/7d46f97363954270d18989a72d4eccdfda361de3/src/yii/base/Model.php#L81-L92 |
10,722 | diatem-net/jin-ui | src/UI/Components/Pagination.php | Pagination.render | public function render()
{
$html = parent::render();
$items = '';
// Affichage lien FIRST
if ($this->currentPage > 1) {
$first = $this->getElementTemplate('first');
$first = str_replace('%page%', 1, $first);
$items .= $first;
}
// Affichage previous
if ($this->currentPage > 1) {
$prev = $this->getElementTemplate('previous');
$prev = str_replace('%page%', $this->currentPage - 1, $prev);
$items .= $prev;
}
// Affichage des pages
$startPage = $this->currentPage - floor($this->maxShowedPages / 2);
$endPage = $this->currentPage + floor($this->maxShowedPages / 2);
if ($startPage < 1) {
$endPage += (1 - $startPage);
$startPage = 1;
}
if ($endPage > $this->nbPages) {
$endPage = $this->nbPages;
}
if (($endPage - $startPage + 1) != $this->maxShowedPages) {
$startPage = $endPage - $this->maxShowedPages + 1;
if ($startPage < 1) {
$startPage = 1;
}
}
for ($i = $startPage; $i <= $endPage; $i++) {
if ($this->currentPage == $i) {
$page = $this->getElementTemplate('selectedpage');
} else {
$page = $this->getElementTemplate('page');
}
$page = str_replace('%page%', $i, $page);
$items .= $page;
}
// Affichage next
if ($this->currentPage < $this->nbPages) {
$next = $this->getElementTemplate('next');
$next = str_replace('%page%', $this->currentPage + 1, $next);
$items .= $next;
}
// Affichage last
if ($this->currentPage != $this->nbPages && $this->nbPages > 0) {
$last = $this->getElementTemplate('last');
$last = str_replace('%page%', $this->nbPages, $last);
$items .= $last;
}
$html = str_replace('%items%', $items, $html);
return $html;
} | php | public function render()
{
$html = parent::render();
$items = '';
// Affichage lien FIRST
if ($this->currentPage > 1) {
$first = $this->getElementTemplate('first');
$first = str_replace('%page%', 1, $first);
$items .= $first;
}
// Affichage previous
if ($this->currentPage > 1) {
$prev = $this->getElementTemplate('previous');
$prev = str_replace('%page%', $this->currentPage - 1, $prev);
$items .= $prev;
}
// Affichage des pages
$startPage = $this->currentPage - floor($this->maxShowedPages / 2);
$endPage = $this->currentPage + floor($this->maxShowedPages / 2);
if ($startPage < 1) {
$endPage += (1 - $startPage);
$startPage = 1;
}
if ($endPage > $this->nbPages) {
$endPage = $this->nbPages;
}
if (($endPage - $startPage + 1) != $this->maxShowedPages) {
$startPage = $endPage - $this->maxShowedPages + 1;
if ($startPage < 1) {
$startPage = 1;
}
}
for ($i = $startPage; $i <= $endPage; $i++) {
if ($this->currentPage == $i) {
$page = $this->getElementTemplate('selectedpage');
} else {
$page = $this->getElementTemplate('page');
}
$page = str_replace('%page%', $i, $page);
$items .= $page;
}
// Affichage next
if ($this->currentPage < $this->nbPages) {
$next = $this->getElementTemplate('next');
$next = str_replace('%page%', $this->currentPage + 1, $next);
$items .= $next;
}
// Affichage last
if ($this->currentPage != $this->nbPages && $this->nbPages > 0) {
$last = $this->getElementTemplate('last');
$last = str_replace('%page%', $this->nbPages, $last);
$items .= $last;
}
$html = str_replace('%items%', $items, $html);
return $html;
} | [
"public",
"function",
"render",
"(",
")",
"{",
"$",
"html",
"=",
"parent",
"::",
"render",
"(",
")",
";",
"$",
"items",
"=",
"''",
";",
"// Affichage lien FIRST\r",
"if",
"(",
"$",
"this",
"->",
"currentPage",
">",
"1",
")",
"{",
"$",
"first",
"=",
"$",
"this",
"->",
"getElementTemplate",
"(",
"'first'",
")",
";",
"$",
"first",
"=",
"str_replace",
"(",
"'%page%'",
",",
"1",
",",
"$",
"first",
")",
";",
"$",
"items",
".=",
"$",
"first",
";",
"}",
"// Affichage previous\r",
"if",
"(",
"$",
"this",
"->",
"currentPage",
">",
"1",
")",
"{",
"$",
"prev",
"=",
"$",
"this",
"->",
"getElementTemplate",
"(",
"'previous'",
")",
";",
"$",
"prev",
"=",
"str_replace",
"(",
"'%page%'",
",",
"$",
"this",
"->",
"currentPage",
"-",
"1",
",",
"$",
"prev",
")",
";",
"$",
"items",
".=",
"$",
"prev",
";",
"}",
"// Affichage des pages\r",
"$",
"startPage",
"=",
"$",
"this",
"->",
"currentPage",
"-",
"floor",
"(",
"$",
"this",
"->",
"maxShowedPages",
"/",
"2",
")",
";",
"$",
"endPage",
"=",
"$",
"this",
"->",
"currentPage",
"+",
"floor",
"(",
"$",
"this",
"->",
"maxShowedPages",
"/",
"2",
")",
";",
"if",
"(",
"$",
"startPage",
"<",
"1",
")",
"{",
"$",
"endPage",
"+=",
"(",
"1",
"-",
"$",
"startPage",
")",
";",
"$",
"startPage",
"=",
"1",
";",
"}",
"if",
"(",
"$",
"endPage",
">",
"$",
"this",
"->",
"nbPages",
")",
"{",
"$",
"endPage",
"=",
"$",
"this",
"->",
"nbPages",
";",
"}",
"if",
"(",
"(",
"$",
"endPage",
"-",
"$",
"startPage",
"+",
"1",
")",
"!=",
"$",
"this",
"->",
"maxShowedPages",
")",
"{",
"$",
"startPage",
"=",
"$",
"endPage",
"-",
"$",
"this",
"->",
"maxShowedPages",
"+",
"1",
";",
"if",
"(",
"$",
"startPage",
"<",
"1",
")",
"{",
"$",
"startPage",
"=",
"1",
";",
"}",
"}",
"for",
"(",
"$",
"i",
"=",
"$",
"startPage",
";",
"$",
"i",
"<=",
"$",
"endPage",
";",
"$",
"i",
"++",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"currentPage",
"==",
"$",
"i",
")",
"{",
"$",
"page",
"=",
"$",
"this",
"->",
"getElementTemplate",
"(",
"'selectedpage'",
")",
";",
"}",
"else",
"{",
"$",
"page",
"=",
"$",
"this",
"->",
"getElementTemplate",
"(",
"'page'",
")",
";",
"}",
"$",
"page",
"=",
"str_replace",
"(",
"'%page%'",
",",
"$",
"i",
",",
"$",
"page",
")",
";",
"$",
"items",
".=",
"$",
"page",
";",
"}",
"// Affichage next\r",
"if",
"(",
"$",
"this",
"->",
"currentPage",
"<",
"$",
"this",
"->",
"nbPages",
")",
"{",
"$",
"next",
"=",
"$",
"this",
"->",
"getElementTemplate",
"(",
"'next'",
")",
";",
"$",
"next",
"=",
"str_replace",
"(",
"'%page%'",
",",
"$",
"this",
"->",
"currentPage",
"+",
"1",
",",
"$",
"next",
")",
";",
"$",
"items",
".=",
"$",
"next",
";",
"}",
"// Affichage last\r",
"if",
"(",
"$",
"this",
"->",
"currentPage",
"!=",
"$",
"this",
"->",
"nbPages",
"&&",
"$",
"this",
"->",
"nbPages",
">",
"0",
")",
"{",
"$",
"last",
"=",
"$",
"this",
"->",
"getElementTemplate",
"(",
"'last'",
")",
";",
"$",
"last",
"=",
"str_replace",
"(",
"'%page%'",
",",
"$",
"this",
"->",
"nbPages",
",",
"$",
"last",
")",
";",
"$",
"items",
".=",
"$",
"last",
";",
"}",
"$",
"html",
"=",
"str_replace",
"(",
"'%items%'",
",",
"$",
"items",
",",
"$",
"html",
")",
";",
"return",
"$",
"html",
";",
"}"
] | Effectue un rendu du composant
@return string | [
"Effectue",
"un",
"rendu",
"du",
"composant"
] | d0825d3d0a983ee3d22b23e545eb9724b67bbaa5 | https://github.com/diatem-net/jin-ui/blob/d0825d3d0a983ee3d22b23e545eb9724b67bbaa5/src/UI/Components/Pagination.php#L114-L177 |
10,723 | consigliere/components | src/Commands/MigrateResetCommand.php | MigrateResetCommand.reset | public function reset($component)
{
if (is_string($component)) {
$component = $this->laravel['components']->findOrFail($component);
}
$migrator = new Migrator($component);
$database = $this->option('database');
if (!empty($database)) {
$migrator->setDatabase($database);
}
$migrated = $migrator->reset();
if (count($migrated)) {
foreach ($migrated as $migration) {
$this->line("Rollback: <info>{$migration}</info>");
}
return;
}
$this->comment('Nothing to rollback.');
} | php | public function reset($component)
{
if (is_string($component)) {
$component = $this->laravel['components']->findOrFail($component);
}
$migrator = new Migrator($component);
$database = $this->option('database');
if (!empty($database)) {
$migrator->setDatabase($database);
}
$migrated = $migrator->reset();
if (count($migrated)) {
foreach ($migrated as $migration) {
$this->line("Rollback: <info>{$migration}</info>");
}
return;
}
$this->comment('Nothing to rollback.');
} | [
"public",
"function",
"reset",
"(",
"$",
"component",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"component",
")",
")",
"{",
"$",
"component",
"=",
"$",
"this",
"->",
"laravel",
"[",
"'components'",
"]",
"->",
"findOrFail",
"(",
"$",
"component",
")",
";",
"}",
"$",
"migrator",
"=",
"new",
"Migrator",
"(",
"$",
"component",
")",
";",
"$",
"database",
"=",
"$",
"this",
"->",
"option",
"(",
"'database'",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"database",
")",
")",
"{",
"$",
"migrator",
"->",
"setDatabase",
"(",
"$",
"database",
")",
";",
"}",
"$",
"migrated",
"=",
"$",
"migrator",
"->",
"reset",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"migrated",
")",
")",
"{",
"foreach",
"(",
"$",
"migrated",
"as",
"$",
"migration",
")",
"{",
"$",
"this",
"->",
"line",
"(",
"\"Rollback: <info>{$migration}</info>\"",
")",
";",
"}",
"return",
";",
"}",
"$",
"this",
"->",
"comment",
"(",
"'Nothing to rollback.'",
")",
";",
"}"
] | Rollback migration from the specified component.
@param $component | [
"Rollback",
"migration",
"from",
"the",
"specified",
"component",
"."
] | 9b08bb111f0b55b0a860ed9c3407eda0d9cc1252 | https://github.com/consigliere/components/blob/9b08bb111f0b55b0a860ed9c3407eda0d9cc1252/src/Commands/MigrateResetCommand.php#L56-L81 |
10,724 | magnus-eriksson/file-db | src/FileDB.php | FileDB.table | public function table($table)
{
if (!isset($this->tables[$table])) {
$this->tables[$table] = new Table($table, $this->storage);
}
return new QueryBuilder($this->tables[$table], $this->filters);
} | php | public function table($table)
{
if (!isset($this->tables[$table])) {
$this->tables[$table] = new Table($table, $this->storage);
}
return new QueryBuilder($this->tables[$table], $this->filters);
} | [
"public",
"function",
"table",
"(",
"$",
"table",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"tables",
"[",
"$",
"table",
"]",
")",
")",
"{",
"$",
"this",
"->",
"tables",
"[",
"$",
"table",
"]",
"=",
"new",
"Table",
"(",
"$",
"table",
",",
"$",
"this",
"->",
"storage",
")",
";",
"}",
"return",
"new",
"QueryBuilder",
"(",
"$",
"this",
"->",
"tables",
"[",
"$",
"table",
"]",
",",
"$",
"this",
"->",
"filters",
")",
";",
"}"
] | Get a new query builder for the table
@param string $table
@return QueryBuilder | [
"Get",
"a",
"new",
"query",
"builder",
"for",
"the",
"table"
] | 61d50511b1dcb483eec13a9baf3994fdc86b70a2 | https://github.com/magnus-eriksson/file-db/blob/61d50511b1dcb483eec13a9baf3994fdc86b70a2/src/FileDB.php#L51-L58 |
10,725 | AlcyZ/Alcys-ORM | AutoLoader.php | AutoLoader.register | public static function register($directory, $first = true)
{
if($first)
{
self::$scannedDirectories[] = $directory;
}
$directory = trim($directory, '/');
$dir = dir(trim($directory));
while(false !== $file = $dir->read())
{
if($file !== '.' && $file !== '..')
{
if(is_dir($directory . DIRECTORY_SEPARATOR . $file))
{
self::register($directory . DIRECTORY_SEPARATOR . $file, false);
}
elseif(is_file($directory . DIRECTORY_SEPARATOR . $file))
{
self::_asd($directory, $file);
}
}
}
$dir->close();
} | php | public static function register($directory, $first = true)
{
if($first)
{
self::$scannedDirectories[] = $directory;
}
$directory = trim($directory, '/');
$dir = dir(trim($directory));
while(false !== $file = $dir->read())
{
if($file !== '.' && $file !== '..')
{
if(is_dir($directory . DIRECTORY_SEPARATOR . $file))
{
self::register($directory . DIRECTORY_SEPARATOR . $file, false);
}
elseif(is_file($directory . DIRECTORY_SEPARATOR . $file))
{
self::_asd($directory, $file);
}
}
}
$dir->close();
} | [
"public",
"static",
"function",
"register",
"(",
"$",
"directory",
",",
"$",
"first",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"first",
")",
"{",
"self",
"::",
"$",
"scannedDirectories",
"[",
"]",
"=",
"$",
"directory",
";",
"}",
"$",
"directory",
"=",
"trim",
"(",
"$",
"directory",
",",
"'/'",
")",
";",
"$",
"dir",
"=",
"dir",
"(",
"trim",
"(",
"$",
"directory",
")",
")",
";",
"while",
"(",
"false",
"!==",
"$",
"file",
"=",
"$",
"dir",
"->",
"read",
"(",
")",
")",
"{",
"if",
"(",
"$",
"file",
"!==",
"'.'",
"&&",
"$",
"file",
"!==",
"'..'",
")",
"{",
"if",
"(",
"is_dir",
"(",
"$",
"directory",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"file",
")",
")",
"{",
"self",
"::",
"register",
"(",
"$",
"directory",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"file",
",",
"false",
")",
";",
"}",
"elseif",
"(",
"is_file",
"(",
"$",
"directory",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"file",
")",
")",
"{",
"self",
"::",
"_asd",
"(",
"$",
"directory",
",",
"$",
"file",
")",
";",
"}",
"}",
"}",
"$",
"dir",
"->",
"close",
"(",
")",
";",
"}"
] | Register the directory for the Autoloader.
Scan all files inside the directory recursively and buffer them in the classes property.
@param string $directory Absolute or relative path to directory that should scanned.
@param bool $first | [
"Register",
"the",
"directory",
"for",
"the",
"Autoloader",
".",
"Scan",
"all",
"files",
"inside",
"the",
"directory",
"recursively",
"and",
"buffer",
"them",
"in",
"the",
"classes",
"property",
"."
] | dd30946ad35ab06cba2167cf6dfa02b733614720 | https://github.com/AlcyZ/Alcys-ORM/blob/dd30946ad35ab06cba2167cf6dfa02b733614720/AutoLoader.php#L46-L69 |
10,726 | AlcyZ/Alcys-ORM | AutoLoader.php | AutoLoader.load | public static function load($class)
{
// var_dump('Alcys\\' . $class);
if(array_key_exists($class, self::$classes) && is_file(self::$classes[$class]))
{
require_once self::$classes[$class];
}
elseif(array_key_exists('Alcys\\' . $class, self::$classes) && is_file(self::$classes[$class]))
{
require_once self::$classes['Alcys\\' . $class];
}
} | php | public static function load($class)
{
// var_dump('Alcys\\' . $class);
if(array_key_exists($class, self::$classes) && is_file(self::$classes[$class]))
{
require_once self::$classes[$class];
}
elseif(array_key_exists('Alcys\\' . $class, self::$classes) && is_file(self::$classes[$class]))
{
require_once self::$classes['Alcys\\' . $class];
}
} | [
"public",
"static",
"function",
"load",
"(",
"$",
"class",
")",
"{",
"//\t\tvar_dump('Alcys\\\\' . $class);",
"if",
"(",
"array_key_exists",
"(",
"$",
"class",
",",
"self",
"::",
"$",
"classes",
")",
"&&",
"is_file",
"(",
"self",
"::",
"$",
"classes",
"[",
"$",
"class",
"]",
")",
")",
"{",
"require_once",
"self",
"::",
"$",
"classes",
"[",
"$",
"class",
"]",
";",
"}",
"elseif",
"(",
"array_key_exists",
"(",
"'Alcys\\\\'",
".",
"$",
"class",
",",
"self",
"::",
"$",
"classes",
")",
"&&",
"is_file",
"(",
"self",
"::",
"$",
"classes",
"[",
"$",
"class",
"]",
")",
")",
"{",
"require_once",
"self",
"::",
"$",
"classes",
"[",
"'Alcys\\\\'",
".",
"$",
"class",
"]",
";",
"}",
"}"
] | This method will call when the system try to instantiate a not included class or interface.
The parsed class name should exist as key. If this is the case, the class will required.
@param $class | [
"This",
"method",
"will",
"call",
"when",
"the",
"system",
"try",
"to",
"instantiate",
"a",
"not",
"included",
"class",
"or",
"interface",
".",
"The",
"parsed",
"class",
"name",
"should",
"exist",
"as",
"key",
".",
"If",
"this",
"is",
"the",
"case",
"the",
"class",
"will",
"required",
"."
] | dd30946ad35ab06cba2167cf6dfa02b733614720 | https://github.com/AlcyZ/Alcys-ORM/blob/dd30946ad35ab06cba2167cf6dfa02b733614720/AutoLoader.php#L78-L89 |
10,727 | ripaclub/zf2-mailman | src/Transport/Mandrill/Mandrill.php | Mandrill.mapAddressListToArray | protected function mapAddressListToArray(Mail\AddressList $addresses, $type = 'to')
{
$array = [];
/** @var Mail\Address() $address */
foreach ($addresses as $address) {
$array[] = [
'email' => $address->getEmail(),
'name' => $address->getName(),
'type' => $type
];
}
return $array;
} | php | protected function mapAddressListToArray(Mail\AddressList $addresses, $type = 'to')
{
$array = [];
/** @var Mail\Address() $address */
foreach ($addresses as $address) {
$array[] = [
'email' => $address->getEmail(),
'name' => $address->getName(),
'type' => $type
];
}
return $array;
} | [
"protected",
"function",
"mapAddressListToArray",
"(",
"Mail",
"\\",
"AddressList",
"$",
"addresses",
",",
"$",
"type",
"=",
"'to'",
")",
"{",
"$",
"array",
"=",
"[",
"]",
";",
"/** @var Mail\\Address() $address */",
"foreach",
"(",
"$",
"addresses",
"as",
"$",
"address",
")",
"{",
"$",
"array",
"[",
"]",
"=",
"[",
"'email'",
"=>",
"$",
"address",
"->",
"getEmail",
"(",
")",
",",
"'name'",
"=>",
"$",
"address",
"->",
"getName",
"(",
")",
",",
"'type'",
"=>",
"$",
"type",
"]",
";",
"}",
"return",
"$",
"array",
";",
"}"
] | Map Address List to Mandrill array
@param Mail\AddressList $addresses
@param string $type
@return array | [
"Map",
"Address",
"List",
"to",
"Mandrill",
"array"
] | af7e69d15f41a99e8adcbf756e528c83cf2b2663 | https://github.com/ripaclub/zf2-mailman/blob/af7e69d15f41a99e8adcbf756e528c83cf2b2663/src/Transport/Mandrill/Mandrill.php#L178-L190 |
10,728 | pdenis/SnideTravinizerBundle | Twig/Extension/ScrutinizerExtension.php | ScrutinizerExtension.getUrl | public function getUrl(Repo $repo)
{
return $this->helper->getUrl(
$repo->getSlug(),
$repo->getType()
);
} | php | public function getUrl(Repo $repo)
{
return $this->helper->getUrl(
$repo->getSlug(),
$repo->getType()
);
} | [
"public",
"function",
"getUrl",
"(",
"Repo",
"$",
"repo",
")",
"{",
"return",
"$",
"this",
"->",
"helper",
"->",
"getUrl",
"(",
"$",
"repo",
"->",
"getSlug",
"(",
")",
",",
"$",
"repo",
"->",
"getType",
"(",
")",
")",
";",
"}"
] | Get Repo url
@param Repo $repo
@return string | [
"Get",
"Repo",
"url"
] | 53a6fd647280d81a496018d379e4b5c446f81729 | https://github.com/pdenis/SnideTravinizerBundle/blob/53a6fd647280d81a496018d379e4b5c446f81729/Twig/Extension/ScrutinizerExtension.php#L73-L79 |
10,729 | pdenis/SnideTravinizerBundle | Twig/Extension/ScrutinizerExtension.php | ScrutinizerExtension.getQualityBadge | public function getQualityBadge(Repo $repo)
{
if ($repo->getQualityBadgeHash()) {
return sprintf(
'<img src="%s" />',
$this->helper->getQualityBadgeUrl(
$repo->getSlug(),
$repo->getType(),
$repo->getQualityBadgeHash()
)
);
}
return '';
} | php | public function getQualityBadge(Repo $repo)
{
if ($repo->getQualityBadgeHash()) {
return sprintf(
'<img src="%s" />',
$this->helper->getQualityBadgeUrl(
$repo->getSlug(),
$repo->getType(),
$repo->getQualityBadgeHash()
)
);
}
return '';
} | [
"public",
"function",
"getQualityBadge",
"(",
"Repo",
"$",
"repo",
")",
"{",
"if",
"(",
"$",
"repo",
"->",
"getQualityBadgeHash",
"(",
")",
")",
"{",
"return",
"sprintf",
"(",
"'<img src=\"%s\" />'",
",",
"$",
"this",
"->",
"helper",
"->",
"getQualityBadgeUrl",
"(",
"$",
"repo",
"->",
"getSlug",
"(",
")",
",",
"$",
"repo",
"->",
"getType",
"(",
")",
",",
"$",
"repo",
"->",
"getQualityBadgeHash",
"(",
")",
")",
")",
";",
"}",
"return",
"''",
";",
"}"
] | Get Repo quality badge
@param Repo $repo
@return string | [
"Get",
"Repo",
"quality",
"badge"
] | 53a6fd647280d81a496018d379e4b5c446f81729 | https://github.com/pdenis/SnideTravinizerBundle/blob/53a6fd647280d81a496018d379e4b5c446f81729/Twig/Extension/ScrutinizerExtension.php#L87-L101 |
10,730 | pdenis/SnideTravinizerBundle | Twig/Extension/ScrutinizerExtension.php | ScrutinizerExtension.getCoverageBadge | public function getCoverageBadge(Repo $repo)
{
if ($repo->getCoverageBadgeHash()) {
return sprintf(
'<img src="%s" />',
$this->helper->getCoverageBadgeUrl(
$repo->getSlug(),
$repo->getType(),
$repo->getCoverageBadgeHash()
)
);
}
return '';
} | php | public function getCoverageBadge(Repo $repo)
{
if ($repo->getCoverageBadgeHash()) {
return sprintf(
'<img src="%s" />',
$this->helper->getCoverageBadgeUrl(
$repo->getSlug(),
$repo->getType(),
$repo->getCoverageBadgeHash()
)
);
}
return '';
} | [
"public",
"function",
"getCoverageBadge",
"(",
"Repo",
"$",
"repo",
")",
"{",
"if",
"(",
"$",
"repo",
"->",
"getCoverageBadgeHash",
"(",
")",
")",
"{",
"return",
"sprintf",
"(",
"'<img src=\"%s\" />'",
",",
"$",
"this",
"->",
"helper",
"->",
"getCoverageBadgeUrl",
"(",
"$",
"repo",
"->",
"getSlug",
"(",
")",
",",
"$",
"repo",
"->",
"getType",
"(",
")",
",",
"$",
"repo",
"->",
"getCoverageBadgeHash",
"(",
")",
")",
")",
";",
"}",
"return",
"''",
";",
"}"
] | Get Repo coverage badge
@param Repo $repo
@return string | [
"Get",
"Repo",
"coverage",
"badge"
] | 53a6fd647280d81a496018d379e4b5c446f81729 | https://github.com/pdenis/SnideTravinizerBundle/blob/53a6fd647280d81a496018d379e4b5c446f81729/Twig/Extension/ScrutinizerExtension.php#L109-L123 |
10,731 | samsonos/cms_app_material | src/Application.php | Application.__async_removenav | public function __async_removenav($materialId = null, $navigation = null)
{
$structureMaterials = dbQuery('structurematerial')->cond('MaterialID', $materialId)->cond('StructureID', $navigation)->first();
$structureMaterials->delete();
} | php | public function __async_removenav($materialId = null, $navigation = null)
{
$structureMaterials = dbQuery('structurematerial')->cond('MaterialID', $materialId)->cond('StructureID', $navigation)->first();
$structureMaterials->delete();
} | [
"public",
"function",
"__async_removenav",
"(",
"$",
"materialId",
"=",
"null",
",",
"$",
"navigation",
"=",
"null",
")",
"{",
"$",
"structureMaterials",
"=",
"dbQuery",
"(",
"'structurematerial'",
")",
"->",
"cond",
"(",
"'MaterialID'",
",",
"$",
"materialId",
")",
"->",
"cond",
"(",
"'StructureID'",
",",
"$",
"navigation",
")",
"->",
"first",
"(",
")",
";",
"$",
"structureMaterials",
"->",
"delete",
"(",
")",
";",
"}"
] | Delete structure from entity
@param int $navigation Parent navigation identifier | [
"Delete",
"structure",
"from",
"entity"
] | 24d8f8ce8dec68b18cd1e941c6b57a23501aa8c1 | https://github.com/samsonos/cms_app_material/blob/24d8f8ce8dec68b18cd1e941c6b57a23501aa8c1/src/Application.php#L173-L177 |
10,732 | samsonos/cms_app_material | src/Application.php | Application.__async_addnav | public function __async_addnav($materialId = null, $navigation = null)
{
// Save record
// $sm = new CMSNavMaterial(false);
$sm = new NavigationMaterial();
$sm->MaterialID = $materialId;
$sm->StructureID = $navigation;
$sm->Active = '1';
$sm->save();
} | php | public function __async_addnav($materialId = null, $navigation = null)
{
// Save record
// $sm = new CMSNavMaterial(false);
$sm = new NavigationMaterial();
$sm->MaterialID = $materialId;
$sm->StructureID = $navigation;
$sm->Active = '1';
$sm->save();
} | [
"public",
"function",
"__async_addnav",
"(",
"$",
"materialId",
"=",
"null",
",",
"$",
"navigation",
"=",
"null",
")",
"{",
"// Save record",
"// $sm = new CMSNavMaterial(false);",
"$",
"sm",
"=",
"new",
"NavigationMaterial",
"(",
")",
";",
"$",
"sm",
"->",
"MaterialID",
"=",
"$",
"materialId",
";",
"$",
"sm",
"->",
"StructureID",
"=",
"$",
"navigation",
";",
"$",
"sm",
"->",
"Active",
"=",
"'1'",
";",
"$",
"sm",
"->",
"save",
"(",
")",
";",
"}"
] | Add new structure to entity
@param int $navigation Parent navigation identifier | [
"Add",
"new",
"structure",
"to",
"entity"
] | 24d8f8ce8dec68b18cd1e941c6b57a23501aa8c1 | https://github.com/samsonos/cms_app_material/blob/24d8f8ce8dec68b18cd1e941c6b57a23501aa8c1/src/Application.php#L183-L192 |
10,733 | samsonos/cms_app_material | src/Application.php | Application.__async_collection | public function __async_collection($navigationId = '0', $search = '0', $page = 1)
{
// Save pager size in session
if (isset($_GET['pagerSize'])) {
$_SESSION['pagerSize'] = str_replace('/', '', $_GET['pagerSize']);
// delete get parameter from pager links
unset($_GET['pagerSize']);
}
// Save search filter
if (isset($_GET['search'])) {
$_SESSION['search'] = str_replace('/', '', $_GET['search']);
$search = str_replace('/', '', $_GET['search']);
unset($_GET['search']);
}
// Set filtration info
$navigationId = isset($navigationId) ? $navigationId : '0';
$search = !empty($search) ? urldecode($search) : 0;
$page = isset($page) ? $page : 1;
// Create pager for material collection
$pager = new Pager(
$page,
isset($_SESSION['pagerSize']) ? $_SESSION['pagerSize'] : $this->pageSize, $this->id . '/' . self::VIEW_TABLE_NAME . '/' . $navigationId . '/' . $search
);
// Create material collection
$collection = new $this->collectionClass($this, new dbQuery(), $pager);
// Add navigation filter
if (isset($navigationId) && !empty($navigationId)) {
$collection = $collection->navigation(array($navigationId));
}
return array_merge(
array(
'status' => true,
'navigationId' => $navigationId,
'searchQuery' => $search,
'pageNumber' => $page,
'rowsCount' => $collection->search($search)->fill()->getSize()
),
$collection
->search($search)
->fill()
->toView(self::VIEW_TABLE_NAME . '_')
);
} | php | public function __async_collection($navigationId = '0', $search = '0', $page = 1)
{
// Save pager size in session
if (isset($_GET['pagerSize'])) {
$_SESSION['pagerSize'] = str_replace('/', '', $_GET['pagerSize']);
// delete get parameter from pager links
unset($_GET['pagerSize']);
}
// Save search filter
if (isset($_GET['search'])) {
$_SESSION['search'] = str_replace('/', '', $_GET['search']);
$search = str_replace('/', '', $_GET['search']);
unset($_GET['search']);
}
// Set filtration info
$navigationId = isset($navigationId) ? $navigationId : '0';
$search = !empty($search) ? urldecode($search) : 0;
$page = isset($page) ? $page : 1;
// Create pager for material collection
$pager = new Pager(
$page,
isset($_SESSION['pagerSize']) ? $_SESSION['pagerSize'] : $this->pageSize, $this->id . '/' . self::VIEW_TABLE_NAME . '/' . $navigationId . '/' . $search
);
// Create material collection
$collection = new $this->collectionClass($this, new dbQuery(), $pager);
// Add navigation filter
if (isset($navigationId) && !empty($navigationId)) {
$collection = $collection->navigation(array($navigationId));
}
return array_merge(
array(
'status' => true,
'navigationId' => $navigationId,
'searchQuery' => $search,
'pageNumber' => $page,
'rowsCount' => $collection->search($search)->fill()->getSize()
),
$collection
->search($search)
->fill()
->toView(self::VIEW_TABLE_NAME . '_')
);
} | [
"public",
"function",
"__async_collection",
"(",
"$",
"navigationId",
"=",
"'0'",
",",
"$",
"search",
"=",
"'0'",
",",
"$",
"page",
"=",
"1",
")",
"{",
"// Save pager size in session",
"if",
"(",
"isset",
"(",
"$",
"_GET",
"[",
"'pagerSize'",
"]",
")",
")",
"{",
"$",
"_SESSION",
"[",
"'pagerSize'",
"]",
"=",
"str_replace",
"(",
"'/'",
",",
"''",
",",
"$",
"_GET",
"[",
"'pagerSize'",
"]",
")",
";",
"// delete get parameter from pager links",
"unset",
"(",
"$",
"_GET",
"[",
"'pagerSize'",
"]",
")",
";",
"}",
"// Save search filter",
"if",
"(",
"isset",
"(",
"$",
"_GET",
"[",
"'search'",
"]",
")",
")",
"{",
"$",
"_SESSION",
"[",
"'search'",
"]",
"=",
"str_replace",
"(",
"'/'",
",",
"''",
",",
"$",
"_GET",
"[",
"'search'",
"]",
")",
";",
"$",
"search",
"=",
"str_replace",
"(",
"'/'",
",",
"''",
",",
"$",
"_GET",
"[",
"'search'",
"]",
")",
";",
"unset",
"(",
"$",
"_GET",
"[",
"'search'",
"]",
")",
";",
"}",
"// Set filtration info",
"$",
"navigationId",
"=",
"isset",
"(",
"$",
"navigationId",
")",
"?",
"$",
"navigationId",
":",
"'0'",
";",
"$",
"search",
"=",
"!",
"empty",
"(",
"$",
"search",
")",
"?",
"urldecode",
"(",
"$",
"search",
")",
":",
"0",
";",
"$",
"page",
"=",
"isset",
"(",
"$",
"page",
")",
"?",
"$",
"page",
":",
"1",
";",
"// Create pager for material collection",
"$",
"pager",
"=",
"new",
"Pager",
"(",
"$",
"page",
",",
"isset",
"(",
"$",
"_SESSION",
"[",
"'pagerSize'",
"]",
")",
"?",
"$",
"_SESSION",
"[",
"'pagerSize'",
"]",
":",
"$",
"this",
"->",
"pageSize",
",",
"$",
"this",
"->",
"id",
".",
"'/'",
".",
"self",
"::",
"VIEW_TABLE_NAME",
".",
"'/'",
".",
"$",
"navigationId",
".",
"'/'",
".",
"$",
"search",
")",
";",
"// Create material collection",
"$",
"collection",
"=",
"new",
"$",
"this",
"->",
"collectionClass",
"(",
"$",
"this",
",",
"new",
"dbQuery",
"(",
")",
",",
"$",
"pager",
")",
";",
"// Add navigation filter",
"if",
"(",
"isset",
"(",
"$",
"navigationId",
")",
"&&",
"!",
"empty",
"(",
"$",
"navigationId",
")",
")",
"{",
"$",
"collection",
"=",
"$",
"collection",
"->",
"navigation",
"(",
"array",
"(",
"$",
"navigationId",
")",
")",
";",
"}",
"return",
"array_merge",
"(",
"array",
"(",
"'status'",
"=>",
"true",
",",
"'navigationId'",
"=>",
"$",
"navigationId",
",",
"'searchQuery'",
"=>",
"$",
"search",
",",
"'pageNumber'",
"=>",
"$",
"page",
",",
"'rowsCount'",
"=>",
"$",
"collection",
"->",
"search",
"(",
"$",
"search",
")",
"->",
"fill",
"(",
")",
"->",
"getSize",
"(",
")",
")",
",",
"$",
"collection",
"->",
"search",
"(",
"$",
"search",
")",
"->",
"fill",
"(",
")",
"->",
"toView",
"(",
"self",
"::",
"VIEW_TABLE_NAME",
".",
"'_'",
")",
")",
";",
"}"
] | Render materials list with pager
@param string $navigationId Structure identifier
@param string $search Keywords to filter table
@param int $page Current table page
@return array Asynchronous response containing status and materials list with pager on success
or just status on asynchronous controller failure | [
"Render",
"materials",
"list",
"with",
"pager"
] | 24d8f8ce8dec68b18cd1e941c6b57a23501aa8c1 | https://github.com/samsonos/cms_app_material/blob/24d8f8ce8dec68b18cd1e941c6b57a23501aa8c1/src/Application.php#L232-L281 |
10,734 | samsonos/cms_app_material | src/Application.php | Application.__async_form | public function __async_form($identifier = null)
{
$result = array('status' => false);
// Try to find entity
$entity = null;
if ($this->findAsyncEntityByID($identifier, $entity, $result)) { // Try to find
// Build form for entity
$form = new $this->formClassName($this, $this->query->className($this->entity), $entity);
//elapsed('rendering form');
// Render form
$result['form'] = $form->render();
$result['entity'] = $entity;
if (isset($form->tabs[0]->activeButton)) {
$result['activeButton'] = $form->tabs[0]->activeButton;
}
}
return $result;
} | php | public function __async_form($identifier = null)
{
$result = array('status' => false);
// Try to find entity
$entity = null;
if ($this->findAsyncEntityByID($identifier, $entity, $result)) { // Try to find
// Build form for entity
$form = new $this->formClassName($this, $this->query->className($this->entity), $entity);
//elapsed('rendering form');
// Render form
$result['form'] = $form->render();
$result['entity'] = $entity;
if (isset($form->tabs[0]->activeButton)) {
$result['activeButton'] = $form->tabs[0]->activeButton;
}
}
return $result;
} | [
"public",
"function",
"__async_form",
"(",
"$",
"identifier",
"=",
"null",
")",
"{",
"$",
"result",
"=",
"array",
"(",
"'status'",
"=>",
"false",
")",
";",
"// Try to find entity",
"$",
"entity",
"=",
"null",
";",
"if",
"(",
"$",
"this",
"->",
"findAsyncEntityByID",
"(",
"$",
"identifier",
",",
"$",
"entity",
",",
"$",
"result",
")",
")",
"{",
"// Try to find",
"// Build form for entity",
"$",
"form",
"=",
"new",
"$",
"this",
"->",
"formClassName",
"(",
"$",
"this",
",",
"$",
"this",
"->",
"query",
"->",
"className",
"(",
"$",
"this",
"->",
"entity",
")",
",",
"$",
"entity",
")",
";",
"//elapsed('rendering form');",
"// Render form",
"$",
"result",
"[",
"'form'",
"]",
"=",
"$",
"form",
"->",
"render",
"(",
")",
";",
"$",
"result",
"[",
"'entity'",
"]",
"=",
"$",
"entity",
";",
"if",
"(",
"isset",
"(",
"$",
"form",
"->",
"tabs",
"[",
"0",
"]",
"->",
"activeButton",
")",
")",
"{",
"$",
"result",
"[",
"'activeButton'",
"]",
"=",
"$",
"form",
"->",
"tabs",
"[",
"0",
"]",
"->",
"activeButton",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] | Asynchronous material entity form rendering action
@param int $identifier Material entity identifier
@return array Asynchronous response array | [
"Asynchronous",
"material",
"entity",
"form",
"rendering",
"action"
] | 24d8f8ce8dec68b18cd1e941c6b57a23501aa8c1 | https://github.com/samsonos/cms_app_material/blob/24d8f8ce8dec68b18cd1e941c6b57a23501aa8c1/src/Application.php#L288-L307 |
10,735 | samsonos/cms_app_material | src/Application.php | Application.__tocsv | public function __tocsv($structureId = null){
// Create pager for material collection
$pager = new Pager(0);
// Get collection
$collection = new $this->collectionClass($this, new dbQuery(), $pager);
// Set navigation
if (isset(static::$navigation)) {
$collection = $collection->navigation(static::$navigation);
} else {
$collection = $collection->navigation(array($structureId));
}
$collection->fill();
$this->tocsv($collection);
} | php | public function __tocsv($structureId = null){
// Create pager for material collection
$pager = new Pager(0);
// Get collection
$collection = new $this->collectionClass($this, new dbQuery(), $pager);
// Set navigation
if (isset(static::$navigation)) {
$collection = $collection->navigation(static::$navigation);
} else {
$collection = $collection->navigation(array($structureId));
}
$collection->fill();
$this->tocsv($collection);
} | [
"public",
"function",
"__tocsv",
"(",
"$",
"structureId",
"=",
"null",
")",
"{",
"// Create pager for material collection",
"$",
"pager",
"=",
"new",
"Pager",
"(",
"0",
")",
";",
"// Get collection",
"$",
"collection",
"=",
"new",
"$",
"this",
"->",
"collectionClass",
"(",
"$",
"this",
",",
"new",
"dbQuery",
"(",
")",
",",
"$",
"pager",
")",
";",
"// Set navigation",
"if",
"(",
"isset",
"(",
"static",
"::",
"$",
"navigation",
")",
")",
"{",
"$",
"collection",
"=",
"$",
"collection",
"->",
"navigation",
"(",
"static",
"::",
"$",
"navigation",
")",
";",
"}",
"else",
"{",
"$",
"collection",
"=",
"$",
"collection",
"->",
"navigation",
"(",
"array",
"(",
"$",
"structureId",
")",
")",
";",
"}",
"$",
"collection",
"->",
"fill",
"(",
")",
";",
"$",
"this",
"->",
"tocsv",
"(",
"$",
"collection",
")",
";",
"}"
] | Get current materials in csv format
@param Int $structureId if not set navigation id on application
then use default collection with passed id of structure | [
"Get",
"current",
"materials",
"in",
"csv",
"format"
] | 24d8f8ce8dec68b18cd1e941c6b57a23501aa8c1 | https://github.com/samsonos/cms_app_material/blob/24d8f8ce8dec68b18cd1e941c6b57a23501aa8c1/src/Application.php#L399-L416 |
10,736 | samsonos/cms_app_material | src/Application.php | Application.main | public function main()
{
$mainPageHTML = '';
$dbMaterials = array();
// Получим все материалы
if (
dbQuery('samsoncms\api\Material')
->join('user')
->cond('Active', 1)
->cond('Draft', 0)
->order_by('Created', 'DESC')
->cond('Name', "", dbRelation::NOT_EQUAL)
->limit(5)
->exec($dbMaterials)
) {
// Render material rows
$rowsHTML = '';
foreach ($dbMaterials as $dbMaterial) {
$rowsHTML .= $this->view('main/row')
->set($dbMaterial, 'material')
->set(isset($dbMaterial->onetoone['_user']) ? $dbMaterial->onetoone['_user'] : array(), 'user')
->output();
}
for ($i = sizeof($dbMaterials); $i < 5; $i++) {
$rowsHTML .= $this->view('main/row')->output();
}
// Render main template
$mainPageHTML = $this->view('main/index')->set($rowsHTML, 'rows')->output();
}
// Return material block HTML on main page
return $mainPageHTML;
} | php | public function main()
{
$mainPageHTML = '';
$dbMaterials = array();
// Получим все материалы
if (
dbQuery('samsoncms\api\Material')
->join('user')
->cond('Active', 1)
->cond('Draft', 0)
->order_by('Created', 'DESC')
->cond('Name', "", dbRelation::NOT_EQUAL)
->limit(5)
->exec($dbMaterials)
) {
// Render material rows
$rowsHTML = '';
foreach ($dbMaterials as $dbMaterial) {
$rowsHTML .= $this->view('main/row')
->set($dbMaterial, 'material')
->set(isset($dbMaterial->onetoone['_user']) ? $dbMaterial->onetoone['_user'] : array(), 'user')
->output();
}
for ($i = sizeof($dbMaterials); $i < 5; $i++) {
$rowsHTML .= $this->view('main/row')->output();
}
// Render main template
$mainPageHTML = $this->view('main/index')->set($rowsHTML, 'rows')->output();
}
// Return material block HTML on main page
return $mainPageHTML;
} | [
"public",
"function",
"main",
"(",
")",
"{",
"$",
"mainPageHTML",
"=",
"''",
";",
"$",
"dbMaterials",
"=",
"array",
"(",
")",
";",
"// Получим все материалы",
"if",
"(",
"dbQuery",
"(",
"'samsoncms\\api\\Material'",
")",
"->",
"join",
"(",
"'user'",
")",
"->",
"cond",
"(",
"'Active'",
",",
"1",
")",
"->",
"cond",
"(",
"'Draft'",
",",
"0",
")",
"->",
"order_by",
"(",
"'Created'",
",",
"'DESC'",
")",
"->",
"cond",
"(",
"'Name'",
",",
"\"\"",
",",
"dbRelation",
"::",
"NOT_EQUAL",
")",
"->",
"limit",
"(",
"5",
")",
"->",
"exec",
"(",
"$",
"dbMaterials",
")",
")",
"{",
"// Render material rows",
"$",
"rowsHTML",
"=",
"''",
";",
"foreach",
"(",
"$",
"dbMaterials",
"as",
"$",
"dbMaterial",
")",
"{",
"$",
"rowsHTML",
".=",
"$",
"this",
"->",
"view",
"(",
"'main/row'",
")",
"->",
"set",
"(",
"$",
"dbMaterial",
",",
"'material'",
")",
"->",
"set",
"(",
"isset",
"(",
"$",
"dbMaterial",
"->",
"onetoone",
"[",
"'_user'",
"]",
")",
"?",
"$",
"dbMaterial",
"->",
"onetoone",
"[",
"'_user'",
"]",
":",
"array",
"(",
")",
",",
"'user'",
")",
"->",
"output",
"(",
")",
";",
"}",
"for",
"(",
"$",
"i",
"=",
"sizeof",
"(",
"$",
"dbMaterials",
")",
";",
"$",
"i",
"<",
"5",
";",
"$",
"i",
"++",
")",
"{",
"$",
"rowsHTML",
".=",
"$",
"this",
"->",
"view",
"(",
"'main/row'",
")",
"->",
"output",
"(",
")",
";",
"}",
"// Render main template",
"$",
"mainPageHTML",
"=",
"$",
"this",
"->",
"view",
"(",
"'main/index'",
")",
"->",
"set",
"(",
"$",
"rowsHTML",
",",
"'rows'",
")",
"->",
"output",
"(",
")",
";",
"}",
"// Return material block HTML on main page",
"return",
"$",
"mainPageHTML",
";",
"}"
] | Output for main page | [
"Output",
"for",
"main",
"page"
] | 24d8f8ce8dec68b18cd1e941c6b57a23501aa8c1 | https://github.com/samsonos/cms_app_material/blob/24d8f8ce8dec68b18cd1e941c6b57a23501aa8c1/src/Application.php#L461-L496 |
10,737 | webriq/core | module/Core/src/Grid/Core/Model/Settings/DefinitionServiceFactory.php | DefinitionServiceFactory.createService | public function createService( ServiceLocatorInterface $serviceLocator )
{
// Configure the definitions
$config = $serviceLocator->get( 'Configuration' );
$srvConfig = isset( $config['modules']['Grid\Core']['settings'] )
? (array) $config['modules']['Grid\Core']['settings']
: array();
return new Definitions( $srvConfig );
} | php | public function createService( ServiceLocatorInterface $serviceLocator )
{
// Configure the definitions
$config = $serviceLocator->get( 'Configuration' );
$srvConfig = isset( $config['modules']['Grid\Core']['settings'] )
? (array) $config['modules']['Grid\Core']['settings']
: array();
return new Definitions( $srvConfig );
} | [
"public",
"function",
"createService",
"(",
"ServiceLocatorInterface",
"$",
"serviceLocator",
")",
"{",
"// Configure the definitions",
"$",
"config",
"=",
"$",
"serviceLocator",
"->",
"get",
"(",
"'Configuration'",
")",
";",
"$",
"srvConfig",
"=",
"isset",
"(",
"$",
"config",
"[",
"'modules'",
"]",
"[",
"'Grid\\Core'",
"]",
"[",
"'settings'",
"]",
")",
"?",
"(",
"array",
")",
"$",
"config",
"[",
"'modules'",
"]",
"[",
"'Grid\\Core'",
"]",
"[",
"'settings'",
"]",
":",
"array",
"(",
")",
";",
"return",
"new",
"Definitions",
"(",
"$",
"srvConfig",
")",
";",
"}"
] | Create the definitions-service
@param \Zend\ServiceManager\ServiceLocatorInterface $serviceLocator
@return \Grid\Core\Model\Settings\Definitions | [
"Create",
"the",
"definitions",
"-",
"service"
] | cfeb6e8a4732561c2215ec94e736c07f9b8bc990 | https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Core/src/Grid/Core/Model/Settings/DefinitionServiceFactory.php#L22-L30 |
10,738 | indigophp-archive/queue | src/Worker.php | Worker.listen | public function listen($interval = 5, $timeout = 0)
{
while (true) {
// Process the current job if available
// or sleep for a certain time
if ($manager = $this->getManager($timeout)) {
$manager->execute();
} elseif ($interval > 0) {
$this->sleep($interval);
}
}
} | php | public function listen($interval = 5, $timeout = 0)
{
while (true) {
// Process the current job if available
// or sleep for a certain time
if ($manager = $this->getManager($timeout)) {
$manager->execute();
} elseif ($interval > 0) {
$this->sleep($interval);
}
}
} | [
"public",
"function",
"listen",
"(",
"$",
"interval",
"=",
"5",
",",
"$",
"timeout",
"=",
"0",
")",
"{",
"while",
"(",
"true",
")",
"{",
"// Process the current job if available",
"// or sleep for a certain time",
"if",
"(",
"$",
"manager",
"=",
"$",
"this",
"->",
"getManager",
"(",
"$",
"timeout",
")",
")",
"{",
"$",
"manager",
"->",
"execute",
"(",
")",
";",
"}",
"elseif",
"(",
"$",
"interval",
">",
"0",
")",
"{",
"$",
"this",
"->",
"sleep",
"(",
"$",
"interval",
")",
";",
"}",
"}",
"}"
] | Listens to queue
@param float $interval Sleep for certain time if no job is available
@param integer $timeout Wait timeout for pop | [
"Listens",
"to",
"queue"
] | d364d5a1fc3b00d59846b19aa472d7f2aa130ff8 | https://github.com/indigophp-archive/queue/blob/d364d5a1fc3b00d59846b19aa472d7f2aa130ff8/src/Worker.php#L82-L93 |
10,739 | indigophp-archive/queue | src/Worker.php | Worker.getManager | protected function getManager($timeout = 0)
{
try {
$manager = $this->connector->pop($this->queue, $timeout);
} catch (JobNotFoundException $e) {
$this->connector->delete($manager);
return false;
} catch (QueueEmptyException $e) {
return false;
}
if ($manager instanceof LoggerAwareInterface) {
$manager->setLogger($this->logger);
}
return $manager;
} | php | protected function getManager($timeout = 0)
{
try {
$manager = $this->connector->pop($this->queue, $timeout);
} catch (JobNotFoundException $e) {
$this->connector->delete($manager);
return false;
} catch (QueueEmptyException $e) {
return false;
}
if ($manager instanceof LoggerAwareInterface) {
$manager->setLogger($this->logger);
}
return $manager;
} | [
"protected",
"function",
"getManager",
"(",
"$",
"timeout",
"=",
"0",
")",
"{",
"try",
"{",
"$",
"manager",
"=",
"$",
"this",
"->",
"connector",
"->",
"pop",
"(",
"$",
"this",
"->",
"queue",
",",
"$",
"timeout",
")",
";",
"}",
"catch",
"(",
"JobNotFoundException",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"connector",
"->",
"delete",
"(",
"$",
"manager",
")",
";",
"return",
"false",
";",
"}",
"catch",
"(",
"QueueEmptyException",
"$",
"e",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"manager",
"instanceof",
"LoggerAwareInterface",
")",
"{",
"$",
"manager",
"->",
"setLogger",
"(",
"$",
"this",
"->",
"logger",
")",
";",
"}",
"return",
"$",
"manager",
";",
"}"
] | Returns a ManagerInterface
@param integer $timeout Wait timeout for pop
@return ManagerInterface Returns null if $manager is not a valid ManagerIterface | [
"Returns",
"a",
"ManagerInterface"
] | d364d5a1fc3b00d59846b19aa472d7f2aa130ff8 | https://github.com/indigophp-archive/queue/blob/d364d5a1fc3b00d59846b19aa472d7f2aa130ff8/src/Worker.php#L117-L134 |
10,740 | soloproyectos-php/dom | src/dom/Dom.php | Dom.isValidXmlFragment | public static function isValidXmlFragment($xml, $doc = null)
{
if ($doc == null) {
$doc = new DOMDocument("1.0", "ISO-8859-1");
}
$fragment = $doc->createDocumentFragment();
@$fragment->appendXML($xml);
$node = @$doc->appendChild($fragment);
return $node !== false;
} | php | public static function isValidXmlFragment($xml, $doc = null)
{
if ($doc == null) {
$doc = new DOMDocument("1.0", "ISO-8859-1");
}
$fragment = $doc->createDocumentFragment();
@$fragment->appendXML($xml);
$node = @$doc->appendChild($fragment);
return $node !== false;
} | [
"public",
"static",
"function",
"isValidXmlFragment",
"(",
"$",
"xml",
",",
"$",
"doc",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"doc",
"==",
"null",
")",
"{",
"$",
"doc",
"=",
"new",
"DOMDocument",
"(",
"\"1.0\"",
",",
"\"ISO-8859-1\"",
")",
";",
"}",
"$",
"fragment",
"=",
"$",
"doc",
"->",
"createDocumentFragment",
"(",
")",
";",
"@",
"$",
"fragment",
"->",
"appendXML",
"(",
"$",
"xml",
")",
";",
"$",
"node",
"=",
"@",
"$",
"doc",
"->",
"appendChild",
"(",
"$",
"fragment",
")",
";",
"return",
"$",
"node",
"!==",
"false",
";",
"}"
] | Is a valid XML fragment?
@param string $xml XML fragment
@param DOMDocument $doc Document (not required)
@return boolean | [
"Is",
"a",
"valid",
"XML",
"fragment?"
] | cc93ff3f590c6180e2b9b23a00c9e9b54c75e663 | https://github.com/soloproyectos-php/dom/blob/cc93ff3f590c6180e2b9b23a00c9e9b54c75e663/src/dom/Dom.php#L67-L78 |
10,741 | soloproyectos-php/dom | src/dom/Dom.php | Dom.isValidXml | public static function isValidXml($xml, $doc = null)
{
if ($doc == null) {
$doc = new DOMDocument("1.0", "ISO-8859-1");
}
// tries to load the document and gets the errors
$useInternalErrors = libxml_use_internal_errors(true);
$doc->loadXML($xml);
$errors = libxml_get_errors();
libxml_use_internal_errors($useInternalErrors);
return count($errors) == 0;
} | php | public static function isValidXml($xml, $doc = null)
{
if ($doc == null) {
$doc = new DOMDocument("1.0", "ISO-8859-1");
}
// tries to load the document and gets the errors
$useInternalErrors = libxml_use_internal_errors(true);
$doc->loadXML($xml);
$errors = libxml_get_errors();
libxml_use_internal_errors($useInternalErrors);
return count($errors) == 0;
} | [
"public",
"static",
"function",
"isValidXml",
"(",
"$",
"xml",
",",
"$",
"doc",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"doc",
"==",
"null",
")",
"{",
"$",
"doc",
"=",
"new",
"DOMDocument",
"(",
"\"1.0\"",
",",
"\"ISO-8859-1\"",
")",
";",
"}",
"// tries to load the document and gets the errors",
"$",
"useInternalErrors",
"=",
"libxml_use_internal_errors",
"(",
"true",
")",
";",
"$",
"doc",
"->",
"loadXML",
"(",
"$",
"xml",
")",
";",
"$",
"errors",
"=",
"libxml_get_errors",
"(",
")",
";",
"libxml_use_internal_errors",
"(",
"$",
"useInternalErrors",
")",
";",
"return",
"count",
"(",
"$",
"errors",
")",
"==",
"0",
";",
"}"
] | Is a valid XML document?
@param string $xml XML document
@param DOMDocument $doc Document (not required)
@return boolean | [
"Is",
"a",
"valid",
"XML",
"document?"
] | cc93ff3f590c6180e2b9b23a00c9e9b54c75e663 | https://github.com/soloproyectos-php/dom/blob/cc93ff3f590c6180e2b9b23a00c9e9b54c75e663/src/dom/Dom.php#L88-L101 |
10,742 | soloproyectos-php/dom | src/dom/Dom.php | Dom.dom2str | public static function dom2str($node)
{
$doc = $node instanceof DOMDocument? $node : $node->ownerDocument;
return $doc->saveXML($node);
} | php | public static function dom2str($node)
{
$doc = $node instanceof DOMDocument? $node : $node->ownerDocument;
return $doc->saveXML($node);
} | [
"public",
"static",
"function",
"dom2str",
"(",
"$",
"node",
")",
"{",
"$",
"doc",
"=",
"$",
"node",
"instanceof",
"DOMDocument",
"?",
"$",
"node",
":",
"$",
"node",
"->",
"ownerDocument",
";",
"return",
"$",
"doc",
"->",
"saveXML",
"(",
"$",
"node",
")",
";",
"}"
] | Gets the string representation of a node.
@param DOMNode $node DOMNode object
@return string | [
"Gets",
"the",
"string",
"representation",
"of",
"a",
"node",
"."
] | cc93ff3f590c6180e2b9b23a00c9e9b54c75e663 | https://github.com/soloproyectos-php/dom/blob/cc93ff3f590c6180e2b9b23a00c9e9b54c75e663/src/dom/Dom.php#L110-L114 |
10,743 | soloproyectos-php/dom | src/dom/Dom.php | Dom.getChildElements | public static function getChildElements($node)
{
$ret = array();
$nodes = $node->childNodes;
foreach ($nodes as $node) {
if ($node instanceof DOMElement) {
array_push($ret, $node);
}
}
return $ret;
} | php | public static function getChildElements($node)
{
$ret = array();
$nodes = $node->childNodes;
foreach ($nodes as $node) {
if ($node instanceof DOMElement) {
array_push($ret, $node);
}
}
return $ret;
} | [
"public",
"static",
"function",
"getChildElements",
"(",
"$",
"node",
")",
"{",
"$",
"ret",
"=",
"array",
"(",
")",
";",
"$",
"nodes",
"=",
"$",
"node",
"->",
"childNodes",
";",
"foreach",
"(",
"$",
"nodes",
"as",
"$",
"node",
")",
"{",
"if",
"(",
"$",
"node",
"instanceof",
"DOMElement",
")",
"{",
"array_push",
"(",
"$",
"ret",
",",
"$",
"node",
")",
";",
"}",
"}",
"return",
"$",
"ret",
";",
"}"
] | Gets child elements of a given node.
This function returns all subnodes that are instance of DOMElement. It
ignores the rest of the subnodes.
@param DOMNode $node DOMNode object
@return array of DOMNode objects | [
"Gets",
"child",
"elements",
"of",
"a",
"given",
"node",
"."
] | cc93ff3f590c6180e2b9b23a00c9e9b54c75e663 | https://github.com/soloproyectos-php/dom/blob/cc93ff3f590c6180e2b9b23a00c9e9b54c75e663/src/dom/Dom.php#L156-L166 |
10,744 | soloproyectos-php/dom | src/dom/Dom.php | Dom.getElementsByTagName | public static function getElementsByTagName($node, $tagName)
{
$ret = array();
$nodes = $node->getElementsByTagName($tagName);
foreach ($nodes as $node) {
if ($node instanceof DOMElement) {
array_push($ret, $node);
}
}
return $ret;
} | php | public static function getElementsByTagName($node, $tagName)
{
$ret = array();
$nodes = $node->getElementsByTagName($tagName);
foreach ($nodes as $node) {
if ($node instanceof DOMElement) {
array_push($ret, $node);
}
}
return $ret;
} | [
"public",
"static",
"function",
"getElementsByTagName",
"(",
"$",
"node",
",",
"$",
"tagName",
")",
"{",
"$",
"ret",
"=",
"array",
"(",
")",
";",
"$",
"nodes",
"=",
"$",
"node",
"->",
"getElementsByTagName",
"(",
"$",
"tagName",
")",
";",
"foreach",
"(",
"$",
"nodes",
"as",
"$",
"node",
")",
"{",
"if",
"(",
"$",
"node",
"instanceof",
"DOMElement",
")",
"{",
"array_push",
"(",
"$",
"ret",
",",
"$",
"node",
")",
";",
"}",
"}",
"return",
"$",
"ret",
";",
"}"
] | Gets elements by tagname.
This function returns all subnodes that have a given tagname.
@param DOMElement $node DOMElement object
@param string $tagName Tag name
@return array of DOMElement objects | [
"Gets",
"elements",
"by",
"tagname",
"."
] | cc93ff3f590c6180e2b9b23a00c9e9b54c75e663 | https://github.com/soloproyectos-php/dom/blob/cc93ff3f590c6180e2b9b23a00c9e9b54c75e663/src/dom/Dom.php#L178-L188 |
10,745 | soloproyectos-php/dom | src/dom/Dom.php | Dom.searchNode | public static function searchNode($node, $items, $offset = 0)
{
$len = count($items);
for ($i = $offset; $i < $len; $i++) {
$item = $items[$i];
if ($item->isSameNode($node)) {
return $i;
}
}
return false;
} | php | public static function searchNode($node, $items, $offset = 0)
{
$len = count($items);
for ($i = $offset; $i < $len; $i++) {
$item = $items[$i];
if ($item->isSameNode($node)) {
return $i;
}
}
return false;
} | [
"public",
"static",
"function",
"searchNode",
"(",
"$",
"node",
",",
"$",
"items",
",",
"$",
"offset",
"=",
"0",
")",
"{",
"$",
"len",
"=",
"count",
"(",
"$",
"items",
")",
";",
"for",
"(",
"$",
"i",
"=",
"$",
"offset",
";",
"$",
"i",
"<",
"$",
"len",
";",
"$",
"i",
"++",
")",
"{",
"$",
"item",
"=",
"$",
"items",
"[",
"$",
"i",
"]",
";",
"if",
"(",
"$",
"item",
"->",
"isSameNode",
"(",
"$",
"node",
")",
")",
"{",
"return",
"$",
"i",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Searches a node in a list.
This function may return false, if the node was not found.
@param DOMNode $node DOMNode object
@param array $items List of DOMNode objects
@param integer $offset Offset (default is 0)
@return false|integer | [
"Searches",
"a",
"node",
"in",
"a",
"list",
"."
] | cc93ff3f590c6180e2b9b23a00c9e9b54c75e663 | https://github.com/soloproyectos-php/dom/blob/cc93ff3f590c6180e2b9b23a00c9e9b54c75e663/src/dom/Dom.php#L201-L211 |
10,746 | soloproyectos-php/dom | src/dom/Dom.php | Dom.mergeNodes | public static function mergeNodes($items1, $items2)
{
$ret = array();
$items = array_merge($items1, $items2);
$len = count($items);
// collects non-repeated elements
for ($i = 0; $i < $len; $i++) {
$item = $items[$i];
$position = Dom::searchNode($item, $items, $i + 1);
if ($position === false) {
array_push($ret, $item);
}
}
return $ret;
} | php | public static function mergeNodes($items1, $items2)
{
$ret = array();
$items = array_merge($items1, $items2);
$len = count($items);
// collects non-repeated elements
for ($i = 0; $i < $len; $i++) {
$item = $items[$i];
$position = Dom::searchNode($item, $items, $i + 1);
if ($position === false) {
array_push($ret, $item);
}
}
return $ret;
} | [
"public",
"static",
"function",
"mergeNodes",
"(",
"$",
"items1",
",",
"$",
"items2",
")",
"{",
"$",
"ret",
"=",
"array",
"(",
")",
";",
"$",
"items",
"=",
"array_merge",
"(",
"$",
"items1",
",",
"$",
"items2",
")",
";",
"$",
"len",
"=",
"count",
"(",
"$",
"items",
")",
";",
"// collects non-repeated elements",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"len",
";",
"$",
"i",
"++",
")",
"{",
"$",
"item",
"=",
"$",
"items",
"[",
"$",
"i",
"]",
";",
"$",
"position",
"=",
"Dom",
"::",
"searchNode",
"(",
"$",
"item",
",",
"$",
"items",
",",
"$",
"i",
"+",
"1",
")",
";",
"if",
"(",
"$",
"position",
"===",
"false",
")",
"{",
"array_push",
"(",
"$",
"ret",
",",
"$",
"item",
")",
";",
"}",
"}",
"return",
"$",
"ret",
";",
"}"
] | Merges two lists of nodes in a single list.
This function merges two list of nodes in a single list without repeating
nodes.
@param array $items1 List of DOMNode objects
@param array $items2 List of DOMNode objects
@return array of DOMNode objects | [
"Merges",
"two",
"lists",
"of",
"nodes",
"in",
"a",
"single",
"list",
"."
] | cc93ff3f590c6180e2b9b23a00c9e9b54c75e663 | https://github.com/soloproyectos-php/dom/blob/cc93ff3f590c6180e2b9b23a00c9e9b54c75e663/src/dom/Dom.php#L224-L240 |
10,747 | soloproyectos-php/dom | src/dom/Dom.php | Dom.sortNodes | public static function sortNodes($nodes)
{
// saves node paths
foreach ($nodes as $node) {
if (!isset($node->__path__)) {
$node->__path__ = Dom::_getNodePath($node);
}
}
// sorts elements in the same order they appear in the document
usort(
$nodes,
function ($node0, $node1) {
$path0 = $node0->__path__;
$path1 = $node1->__path__;
$count0 = count($path0);
$count1 = count($path1);
$len = min($count0, $count1);
for ($i = 0; $i < $len; $i++) {
if ($path0[$i] != $path1[$i]) {
return $path0[$i] > $path1[$i];
}
}
return $count0 > $count1;
}
);
// unsets __path__
foreach ($nodes as $node) {
unset($node->__path__);
}
return $nodes;
} | php | public static function sortNodes($nodes)
{
// saves node paths
foreach ($nodes as $node) {
if (!isset($node->__path__)) {
$node->__path__ = Dom::_getNodePath($node);
}
}
// sorts elements in the same order they appear in the document
usort(
$nodes,
function ($node0, $node1) {
$path0 = $node0->__path__;
$path1 = $node1->__path__;
$count0 = count($path0);
$count1 = count($path1);
$len = min($count0, $count1);
for ($i = 0; $i < $len; $i++) {
if ($path0[$i] != $path1[$i]) {
return $path0[$i] > $path1[$i];
}
}
return $count0 > $count1;
}
);
// unsets __path__
foreach ($nodes as $node) {
unset($node->__path__);
}
return $nodes;
} | [
"public",
"static",
"function",
"sortNodes",
"(",
"$",
"nodes",
")",
"{",
"// saves node paths",
"foreach",
"(",
"$",
"nodes",
"as",
"$",
"node",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"node",
"->",
"__path__",
")",
")",
"{",
"$",
"node",
"->",
"__path__",
"=",
"Dom",
"::",
"_getNodePath",
"(",
"$",
"node",
")",
";",
"}",
"}",
"// sorts elements in the same order they appear in the document",
"usort",
"(",
"$",
"nodes",
",",
"function",
"(",
"$",
"node0",
",",
"$",
"node1",
")",
"{",
"$",
"path0",
"=",
"$",
"node0",
"->",
"__path__",
";",
"$",
"path1",
"=",
"$",
"node1",
"->",
"__path__",
";",
"$",
"count0",
"=",
"count",
"(",
"$",
"path0",
")",
";",
"$",
"count1",
"=",
"count",
"(",
"$",
"path1",
")",
";",
"$",
"len",
"=",
"min",
"(",
"$",
"count0",
",",
"$",
"count1",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"len",
";",
"$",
"i",
"++",
")",
"{",
"if",
"(",
"$",
"path0",
"[",
"$",
"i",
"]",
"!=",
"$",
"path1",
"[",
"$",
"i",
"]",
")",
"{",
"return",
"$",
"path0",
"[",
"$",
"i",
"]",
">",
"$",
"path1",
"[",
"$",
"i",
"]",
";",
"}",
"}",
"return",
"$",
"count0",
">",
"$",
"count1",
";",
"}",
")",
";",
"// unsets __path__",
"foreach",
"(",
"$",
"nodes",
"as",
"$",
"node",
")",
"{",
"unset",
"(",
"$",
"node",
"->",
"__path__",
")",
";",
"}",
"return",
"$",
"nodes",
";",
"}"
] | Sort nodes in the same order they appear in the document.
@param array $nodes List of DOMNode objects
@return array of DOMNode objects | [
"Sort",
"nodes",
"in",
"the",
"same",
"order",
"they",
"appear",
"in",
"the",
"document",
"."
] | cc93ff3f590c6180e2b9b23a00c9e9b54c75e663 | https://github.com/soloproyectos-php/dom/blob/cc93ff3f590c6180e2b9b23a00c9e9b54c75e663/src/dom/Dom.php#L249-L284 |
10,748 | soloproyectos-php/dom | src/dom/Dom.php | Dom._getNodePath | private static function _getNodePath($node)
{
$ret = array();
$doc = $node->ownerDocument;
$parentNode = $node->parentNode;
while ($parentNode !== null && !$doc->isSameNode($parentNode)) {
// gets the sibling position
$pos = 0;
foreach ($parentNode->childNodes as $i => $childNode) {
if ($childNode->isSameNode($node)) {
$pos = $i;
break;
}
}
array_unshift($ret, $pos);
$node = $parentNode;
$parentNode = $node->parentNode;
}
return $ret;
} | php | private static function _getNodePath($node)
{
$ret = array();
$doc = $node->ownerDocument;
$parentNode = $node->parentNode;
while ($parentNode !== null && !$doc->isSameNode($parentNode)) {
// gets the sibling position
$pos = 0;
foreach ($parentNode->childNodes as $i => $childNode) {
if ($childNode->isSameNode($node)) {
$pos = $i;
break;
}
}
array_unshift($ret, $pos);
$node = $parentNode;
$parentNode = $node->parentNode;
}
return $ret;
} | [
"private",
"static",
"function",
"_getNodePath",
"(",
"$",
"node",
")",
"{",
"$",
"ret",
"=",
"array",
"(",
")",
";",
"$",
"doc",
"=",
"$",
"node",
"->",
"ownerDocument",
";",
"$",
"parentNode",
"=",
"$",
"node",
"->",
"parentNode",
";",
"while",
"(",
"$",
"parentNode",
"!==",
"null",
"&&",
"!",
"$",
"doc",
"->",
"isSameNode",
"(",
"$",
"parentNode",
")",
")",
"{",
"// gets the sibling position",
"$",
"pos",
"=",
"0",
";",
"foreach",
"(",
"$",
"parentNode",
"->",
"childNodes",
"as",
"$",
"i",
"=>",
"$",
"childNode",
")",
"{",
"if",
"(",
"$",
"childNode",
"->",
"isSameNode",
"(",
"$",
"node",
")",
")",
"{",
"$",
"pos",
"=",
"$",
"i",
";",
"break",
";",
"}",
"}",
"array_unshift",
"(",
"$",
"ret",
",",
"$",
"pos",
")",
";",
"$",
"node",
"=",
"$",
"parentNode",
";",
"$",
"parentNode",
"=",
"$",
"node",
"->",
"parentNode",
";",
"}",
"return",
"$",
"ret",
";",
"}"
] | Gets the node path.
@param DOMNode $node Node
@return integer[] | [
"Gets",
"the",
"node",
"path",
"."
] | cc93ff3f590c6180e2b9b23a00c9e9b54c75e663 | https://github.com/soloproyectos-php/dom/blob/cc93ff3f590c6180e2b9b23a00c9e9b54c75e663/src/dom/Dom.php#L293-L315 |
10,749 | konservs/brilliant.framework | libraries/Items/BItemsItem.php | BItemsItem.fieldAddRaw | protected function fieldAddRaw($name, $type, $params = array()) {
if (empty($name)) {
return false;
}
$fldobj = (object)$params;
$fldobj->name = $name;
$fldobj->type = $type;
$this->fields[$name] = $fldobj;
} | php | protected function fieldAddRaw($name, $type, $params = array()) {
if (empty($name)) {
return false;
}
$fldobj = (object)$params;
$fldobj->name = $name;
$fldobj->type = $type;
$this->fields[$name] = $fldobj;
} | [
"protected",
"function",
"fieldAddRaw",
"(",
"$",
"name",
",",
"$",
"type",
",",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"name",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"fldobj",
"=",
"(",
"object",
")",
"$",
"params",
";",
"$",
"fldobj",
"->",
"name",
"=",
"$",
"name",
";",
"$",
"fldobj",
"->",
"type",
"=",
"$",
"type",
";",
"$",
"this",
"->",
"fields",
"[",
"$",
"name",
"]",
"=",
"$",
"fldobj",
";",
"}"
] | Add field into fields list.
@param $name
@param $type
@param array $params
@return bool | [
"Add",
"field",
"into",
"fields",
"list",
"."
] | 95f03f1917f746fee98bea8a906ba0588c87762d | https://github.com/konservs/brilliant.framework/blob/95f03f1917f746fee98bea8a906ba0588c87762d/libraries/Items/BItemsItem.php#L51-L59 |
10,750 | konservs/brilliant.framework | libraries/Items/BItemsItem.php | BItemsItem.loadItem | protected function loadItem(&$obj, $item) {
switch ($item) {
case 'id':
$this->id = (int)$obj['id'];
return true;
case 'published':
$this->published = $obj['published'];
return true;
case 'name':
$this->name_ru = $obj['name_ru'];
$this->name_ua = $obj['name_ua'];
return true;
case 'alias':
$this->alias_ru = $obj['alias_ru'];
$this->alias_ua = $obj['alias_ua'];
return true;
case 'created':
$this->created = new \Brilliant\BDateTime($obj['created']);
return true;
case 'modified':
$this->modified = new \Brilliant\BDateTime($obj['modified']);
return true;
}
return false;
} | php | protected function loadItem(&$obj, $item) {
switch ($item) {
case 'id':
$this->id = (int)$obj['id'];
return true;
case 'published':
$this->published = $obj['published'];
return true;
case 'name':
$this->name_ru = $obj['name_ru'];
$this->name_ua = $obj['name_ua'];
return true;
case 'alias':
$this->alias_ru = $obj['alias_ru'];
$this->alias_ua = $obj['alias_ua'];
return true;
case 'created':
$this->created = new \Brilliant\BDateTime($obj['created']);
return true;
case 'modified':
$this->modified = new \Brilliant\BDateTime($obj['modified']);
return true;
}
return false;
} | [
"protected",
"function",
"loadItem",
"(",
"&",
"$",
"obj",
",",
"$",
"item",
")",
"{",
"switch",
"(",
"$",
"item",
")",
"{",
"case",
"'id'",
":",
"$",
"this",
"->",
"id",
"=",
"(",
"int",
")",
"$",
"obj",
"[",
"'id'",
"]",
";",
"return",
"true",
";",
"case",
"'published'",
":",
"$",
"this",
"->",
"published",
"=",
"$",
"obj",
"[",
"'published'",
"]",
";",
"return",
"true",
";",
"case",
"'name'",
":",
"$",
"this",
"->",
"name_ru",
"=",
"$",
"obj",
"[",
"'name_ru'",
"]",
";",
"$",
"this",
"->",
"name_ua",
"=",
"$",
"obj",
"[",
"'name_ua'",
"]",
";",
"return",
"true",
";",
"case",
"'alias'",
":",
"$",
"this",
"->",
"alias_ru",
"=",
"$",
"obj",
"[",
"'alias_ru'",
"]",
";",
"$",
"this",
"->",
"alias_ua",
"=",
"$",
"obj",
"[",
"'alias_ua'",
"]",
";",
"return",
"true",
";",
"case",
"'created'",
":",
"$",
"this",
"->",
"created",
"=",
"new",
"\\",
"Brilliant",
"\\",
"BDateTime",
"(",
"$",
"obj",
"[",
"'created'",
"]",
")",
";",
"return",
"true",
";",
"case",
"'modified'",
":",
"$",
"this",
"->",
"modified",
"=",
"new",
"\\",
"Brilliant",
"\\",
"BDateTime",
"(",
"$",
"obj",
"[",
"'modified'",
"]",
")",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Load item by type
@param $obj
@param $item
@return bool | [
"Load",
"item",
"by",
"type"
] | 95f03f1917f746fee98bea8a906ba0588c87762d | https://github.com/konservs/brilliant.framework/blob/95f03f1917f746fee98bea8a906ba0588c87762d/libraries/Items/BItemsItem.php#L256-L280 |
10,751 | konservs/brilliant.framework | libraries/Items/BItemsItem.php | BItemsItem.saveToDB | public function saveToDB() {
BLog::addToLog('[Items.Item.' . $this->tableName . ']: saveToDB()');
if ($this->isNew) {
return $this->dbInsert();
} else {
return $this->dbupdate();
}
} | php | public function saveToDB() {
BLog::addToLog('[Items.Item.' . $this->tableName . ']: saveToDB()');
if ($this->isNew) {
return $this->dbInsert();
} else {
return $this->dbupdate();
}
} | [
"public",
"function",
"saveToDB",
"(",
")",
"{",
"BLog",
"::",
"addToLog",
"(",
"'[Items.Item.'",
".",
"$",
"this",
"->",
"tableName",
".",
"']: saveToDB()'",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isNew",
")",
"{",
"return",
"$",
"this",
"->",
"dbInsert",
"(",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"dbupdate",
"(",
")",
";",
"}",
"}"
] | Check is and run insert or update query, reload cache.
@return bool | [
"Check",
"is",
"and",
"run",
"insert",
"or",
"update",
"query",
"reload",
"cache",
"."
] | 95f03f1917f746fee98bea8a906ba0588c87762d | https://github.com/konservs/brilliant.framework/blob/95f03f1917f746fee98bea8a906ba0588c87762d/libraries/Items/BItemsItem.php#L634-L641 |
10,752 | silverorange/Net_Notifier | Net/Notifier/Socket/Abstract.php | Net_Notifier_Socket_Abstract.setDeadline | public function setDeadline($deadline, $timeout)
{
$this->deadline = $deadline;
$this->timeout = $timeout;
return $this;
} | php | public function setDeadline($deadline, $timeout)
{
$this->deadline = $deadline;
$this->timeout = $timeout;
return $this;
} | [
"public",
"function",
"setDeadline",
"(",
"$",
"deadline",
",",
"$",
"timeout",
")",
"{",
"$",
"this",
"->",
"deadline",
"=",
"$",
"deadline",
";",
"$",
"this",
"->",
"timeout",
"=",
"$",
"timeout",
";",
"return",
"$",
"this",
";",
"}"
] | Sets request deadline
@param integer $deadline Exception will be thrown if request continues
past this time
@param integer $timeout Original request timeout value, to use in
Exception message
@return Net_Notifier_Socket_Abstract the current object, for fluent
interface. | [
"Sets",
"request",
"deadline"
] | b446e27cd1bebd58ba89243cde1272c5d281d3fb | https://github.com/silverorange/Net_Notifier/blob/b446e27cd1bebd58ba89243cde1272c5d281d3fb/Net/Notifier/Socket/Abstract.php#L237-L243 |
10,753 | silverorange/Net_Notifier | Net/Notifier/Socket/Abstract.php | Net_Notifier_Socket_Abstract.checkTimeout | protected function checkTimeout()
{
$info = stream_get_meta_data($this->socket);
if ($info['timed_out'] || $this->deadline && time() > $this->deadline) {
$reason = $this->deadline
? "after {$this->timeout} second(s)"
: 'due to default_socket_timeout php.ini setting';
throw new Net_Notifier_Socket_TimeoutException(
"Request timed out {$reason}"
);
}
} | php | protected function checkTimeout()
{
$info = stream_get_meta_data($this->socket);
if ($info['timed_out'] || $this->deadline && time() > $this->deadline) {
$reason = $this->deadline
? "after {$this->timeout} second(s)"
: 'due to default_socket_timeout php.ini setting';
throw new Net_Notifier_Socket_TimeoutException(
"Request timed out {$reason}"
);
}
} | [
"protected",
"function",
"checkTimeout",
"(",
")",
"{",
"$",
"info",
"=",
"stream_get_meta_data",
"(",
"$",
"this",
"->",
"socket",
")",
";",
"if",
"(",
"$",
"info",
"[",
"'timed_out'",
"]",
"||",
"$",
"this",
"->",
"deadline",
"&&",
"time",
"(",
")",
">",
"$",
"this",
"->",
"deadline",
")",
"{",
"$",
"reason",
"=",
"$",
"this",
"->",
"deadline",
"?",
"\"after {$this->timeout} second(s)\"",
":",
"'due to default_socket_timeout php.ini setting'",
";",
"throw",
"new",
"Net_Notifier_Socket_TimeoutException",
"(",
"\"Request timed out {$reason}\"",
")",
";",
"}",
"}"
] | Throws an exception if stream timed out
@return void
@throws Net_Notifier_Socket_TimeoutException | [
"Throws",
"an",
"exception",
"if",
"stream",
"timed",
"out"
] | b446e27cd1bebd58ba89243cde1272c5d281d3fb | https://github.com/silverorange/Net_Notifier/blob/b446e27cd1bebd58ba89243cde1272c5d281d3fb/Net/Notifier/Socket/Abstract.php#L286-L298 |
10,754 | lhs168/fasim | src/Fasim/Core/Security.php | Security.csrf_verify | public function csrf_verify() {
// If no POST data exists we will set the CSRF cookie
if (count($_POST) == 0) {
return $this->csrf_set_cookie();
}
// Do the tokens exist in both the _POST and _COOKIE arrays?
if (!isset($_POST[$this->_csrf_token_name]) or !isset($_COOKIE[$this->_csrf_cookie_name])) {
$this->csrf_show_error();
}
// Do the tokens match?
if ($_POST[$this->_csrf_token_name] != $_COOKIE[$this->_csrf_cookie_name]) {
$this->csrf_show_error();
}
// We kill this since we're done and we don't want to
// polute the _POST array
unset($_POST[$this->_csrf_token_name]);
// Nothing should last forever
unset($_COOKIE[$this->_csrf_cookie_name]);
$this->_csrf_set_hash();
$this->csrf_set_cookie();
//log_message('debug', "CSRF token verified ");
return $this;
} | php | public function csrf_verify() {
// If no POST data exists we will set the CSRF cookie
if (count($_POST) == 0) {
return $this->csrf_set_cookie();
}
// Do the tokens exist in both the _POST and _COOKIE arrays?
if (!isset($_POST[$this->_csrf_token_name]) or !isset($_COOKIE[$this->_csrf_cookie_name])) {
$this->csrf_show_error();
}
// Do the tokens match?
if ($_POST[$this->_csrf_token_name] != $_COOKIE[$this->_csrf_cookie_name]) {
$this->csrf_show_error();
}
// We kill this since we're done and we don't want to
// polute the _POST array
unset($_POST[$this->_csrf_token_name]);
// Nothing should last forever
unset($_COOKIE[$this->_csrf_cookie_name]);
$this->_csrf_set_hash();
$this->csrf_set_cookie();
//log_message('debug', "CSRF token verified ");
return $this;
} | [
"public",
"function",
"csrf_verify",
"(",
")",
"{",
"// If no POST data exists we will set the CSRF cookie",
"if",
"(",
"count",
"(",
"$",
"_POST",
")",
"==",
"0",
")",
"{",
"return",
"$",
"this",
"->",
"csrf_set_cookie",
"(",
")",
";",
"}",
"// Do the tokens exist in both the _POST and _COOKIE arrays?",
"if",
"(",
"!",
"isset",
"(",
"$",
"_POST",
"[",
"$",
"this",
"->",
"_csrf_token_name",
"]",
")",
"or",
"!",
"isset",
"(",
"$",
"_COOKIE",
"[",
"$",
"this",
"->",
"_csrf_cookie_name",
"]",
")",
")",
"{",
"$",
"this",
"->",
"csrf_show_error",
"(",
")",
";",
"}",
"// Do the tokens match?",
"if",
"(",
"$",
"_POST",
"[",
"$",
"this",
"->",
"_csrf_token_name",
"]",
"!=",
"$",
"_COOKIE",
"[",
"$",
"this",
"->",
"_csrf_cookie_name",
"]",
")",
"{",
"$",
"this",
"->",
"csrf_show_error",
"(",
")",
";",
"}",
"// We kill this since we're done and we don't want to",
"// polute the _POST array",
"unset",
"(",
"$",
"_POST",
"[",
"$",
"this",
"->",
"_csrf_token_name",
"]",
")",
";",
"// Nothing should last forever",
"unset",
"(",
"$",
"_COOKIE",
"[",
"$",
"this",
"->",
"_csrf_cookie_name",
"]",
")",
";",
"$",
"this",
"->",
"_csrf_set_hash",
"(",
")",
";",
"$",
"this",
"->",
"csrf_set_cookie",
"(",
")",
";",
"//log_message('debug', \"CSRF token verified \");",
"return",
"$",
"this",
";",
"}"
] | Verify Cross Site Request Forgery Protection
@return object | [
"Verify",
"Cross",
"Site",
"Request",
"Forgery",
"Protection"
] | df31e249593380421785f0be342cfb92cbb1d1d7 | https://github.com/lhs168/fasim/blob/df31e249593380421785f0be342cfb92cbb1d1d7/src/Fasim/Core/Security.php#L100-L128 |
10,755 | lhs168/fasim | src/Fasim/Core/Security.php | Security.xss_hash | public function xss_hash() {
if ($this->_xss_hash == '') {
mt_srand();
$this->_xss_hash = md5(time() + mt_rand(0, 1999999999));
}
return $this->_xss_hash;
} | php | public function xss_hash() {
if ($this->_xss_hash == '') {
mt_srand();
$this->_xss_hash = md5(time() + mt_rand(0, 1999999999));
}
return $this->_xss_hash;
} | [
"public",
"function",
"xss_hash",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_xss_hash",
"==",
"''",
")",
"{",
"mt_srand",
"(",
")",
";",
"$",
"this",
"->",
"_xss_hash",
"=",
"md5",
"(",
"time",
"(",
")",
"+",
"mt_rand",
"(",
"0",
",",
"1999999999",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_xss_hash",
";",
"}"
] | Random Hash for protecting URLs
@return string | [
"Random",
"Hash",
"for",
"protecting",
"URLs"
] | df31e249593380421785f0be342cfb92cbb1d1d7 | https://github.com/lhs168/fasim/blob/df31e249593380421785f0be342cfb92cbb1d1d7/src/Fasim/Core/Security.php#L395-L402 |
10,756 | lhs168/fasim | src/Fasim/Core/Security.php | Security._validate_entities | protected function _validate_entities($str) {
/*
* Protect GET variables in URLs
*/
// 901119URL5918AMP18930PROTECT8198
$str = preg_replace('|\&([a-z\_0-9\-]+)\=([a-z\_0-9\-]+)|i', $this->xss_hash() . "\\1=\\2", $str);
/*
* Validate standard character entities Add a semicolon if missing. We
* do this to enable the conversion of entities to ASCII later.
*/
$str = preg_replace('#(&\#?[0-9a-z]{2,})([\x00-\x20])*;?#i', "\\1;\\2", $str);
/*
* Validate UTF16 two byte encoding (x00) Just as above, adds a
* semicolon if missing.
*/
$str = preg_replace('#(&\#x?)([0-9A-F]+);?#i', "\\1\\2;", $str);
/*
* Un-Protect GET variables in URLs
*/
$str = str_replace($this->xss_hash(), '&', $str);
return $str;
} | php | protected function _validate_entities($str) {
/*
* Protect GET variables in URLs
*/
// 901119URL5918AMP18930PROTECT8198
$str = preg_replace('|\&([a-z\_0-9\-]+)\=([a-z\_0-9\-]+)|i', $this->xss_hash() . "\\1=\\2", $str);
/*
* Validate standard character entities Add a semicolon if missing. We
* do this to enable the conversion of entities to ASCII later.
*/
$str = preg_replace('#(&\#?[0-9a-z]{2,})([\x00-\x20])*;?#i', "\\1;\\2", $str);
/*
* Validate UTF16 two byte encoding (x00) Just as above, adds a
* semicolon if missing.
*/
$str = preg_replace('#(&\#x?)([0-9A-F]+);?#i', "\\1\\2;", $str);
/*
* Un-Protect GET variables in URLs
*/
$str = str_replace($this->xss_hash(), '&', $str);
return $str;
} | [
"protected",
"function",
"_validate_entities",
"(",
"$",
"str",
")",
"{",
"/*\n\t\t * Protect GET variables in URLs\n\t\t */",
"// 901119URL5918AMP18930PROTECT8198",
"$",
"str",
"=",
"preg_replace",
"(",
"'|\\&([a-z\\_0-9\\-]+)\\=([a-z\\_0-9\\-]+)|i'",
",",
"$",
"this",
"->",
"xss_hash",
"(",
")",
".",
"\"\\\\1=\\\\2\"",
",",
"$",
"str",
")",
";",
"/*\n\t\t * Validate standard character entities Add a semicolon if missing. We\n\t\t * do this to enable the conversion of entities to ASCII later.\n\t\t */",
"$",
"str",
"=",
"preg_replace",
"(",
"'#(&\\#?[0-9a-z]{2,})([\\x00-\\x20])*;?#i'",
",",
"\"\\\\1;\\\\2\"",
",",
"$",
"str",
")",
";",
"/*\n\t\t * Validate UTF16 two byte encoding (x00) Just as above, adds a\n\t\t * semicolon if missing.\n\t\t */",
"$",
"str",
"=",
"preg_replace",
"(",
"'#(&\\#x?)([0-9A-F]+);?#i'",
",",
"\"\\\\1\\\\2;\"",
",",
"$",
"str",
")",
";",
"/*\n\t\t * Un-Protect GET variables in URLs\n\t\t */",
"$",
"str",
"=",
"str_replace",
"(",
"$",
"this",
"->",
"xss_hash",
"(",
")",
",",
"'&'",
",",
"$",
"str",
")",
";",
"return",
"$",
"str",
";",
"}"
] | Validate URL entities
Called by xss_clean()
@param
string
@return string | [
"Validate",
"URL",
"entities"
] | df31e249593380421785f0be342cfb92cbb1d1d7 | https://github.com/lhs168/fasim/blob/df31e249593380421785f0be342cfb92cbb1d1d7/src/Fasim/Core/Security.php#L660-L687 |
10,757 | XTAIN/JoomlaBundle | Library/Loader.php | Loader.setup | public static function setup($enablePsr = true, $enablePrefixes = true, $enableClasses = true)
{
if ($enableClasses) {
// Register the class map based autoloader.
spl_autoload_register([self::$instance, 'load']);
}
if ($enablePrefixes) {
// Register the J prefix and base path for Joomla platform libraries.
self::registerPrefix('J', JPATH_PLATFORM . '/joomla');
// Register the prefix autoloader.
spl_autoload_register([self::$instance, '_autoload']);
}
if ($enablePsr) {
// Register the PSR-0 based autoloader.
spl_autoload_register([self::$instance, 'loadByPsr0']);
spl_autoload_register([self::$instance, 'loadByAlias']);
}
} | php | public static function setup($enablePsr = true, $enablePrefixes = true, $enableClasses = true)
{
if ($enableClasses) {
// Register the class map based autoloader.
spl_autoload_register([self::$instance, 'load']);
}
if ($enablePrefixes) {
// Register the J prefix and base path for Joomla platform libraries.
self::registerPrefix('J', JPATH_PLATFORM . '/joomla');
// Register the prefix autoloader.
spl_autoload_register([self::$instance, '_autoload']);
}
if ($enablePsr) {
// Register the PSR-0 based autoloader.
spl_autoload_register([self::$instance, 'loadByPsr0']);
spl_autoload_register([self::$instance, 'loadByAlias']);
}
} | [
"public",
"static",
"function",
"setup",
"(",
"$",
"enablePsr",
"=",
"true",
",",
"$",
"enablePrefixes",
"=",
"true",
",",
"$",
"enableClasses",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"enableClasses",
")",
"{",
"// Register the class map based autoloader.",
"spl_autoload_register",
"(",
"[",
"self",
"::",
"$",
"instance",
",",
"'load'",
"]",
")",
";",
"}",
"if",
"(",
"$",
"enablePrefixes",
")",
"{",
"// Register the J prefix and base path for Joomla platform libraries.",
"self",
"::",
"registerPrefix",
"(",
"'J'",
",",
"JPATH_PLATFORM",
".",
"'/joomla'",
")",
";",
"// Register the prefix autoloader.",
"spl_autoload_register",
"(",
"[",
"self",
"::",
"$",
"instance",
",",
"'_autoload'",
"]",
")",
";",
"}",
"if",
"(",
"$",
"enablePsr",
")",
"{",
"// Register the PSR-0 based autoloader.",
"spl_autoload_register",
"(",
"[",
"self",
"::",
"$",
"instance",
",",
"'loadByPsr0'",
"]",
")",
";",
"spl_autoload_register",
"(",
"[",
"self",
"::",
"$",
"instance",
",",
"'loadByAlias'",
"]",
")",
";",
"}",
"}"
] | Method to setup the autoloaders for the Joomla Platform.
Since the SPL autoloaders are called in a queue we will add our explicit
class-registration based loader first, then fall back on the autoloader based on conventions.
This will allow people to register a class in a specific location and override platform libraries
as was previously possible.
@param bool $enablePsr True to enable autoloading based on PSR-0.
@param bool $enablePrefixes True to enable prefix based class loading (needed to auto load the Joomla
core).
@param bool $enableClasses True to enable class map based class loading (needed to auto load the Joomla
core).
@return void
@author Maximilian Ruta <[email protected]> | [
"Method",
"to",
"setup",
"the",
"autoloaders",
"for",
"the",
"Joomla",
"Platform",
".",
"Since",
"the",
"SPL",
"autoloaders",
"are",
"called",
"in",
"a",
"queue",
"we",
"will",
"add",
"our",
"explicit",
"class",
"-",
"registration",
"based",
"loader",
"first",
"then",
"fall",
"back",
"on",
"the",
"autoloader",
"based",
"on",
"conventions",
".",
"This",
"will",
"allow",
"people",
"to",
"register",
"a",
"class",
"in",
"a",
"specific",
"location",
"and",
"override",
"platform",
"libraries",
"as",
"was",
"previously",
"possible",
"."
] | 3d39e1278deba77c5a2197ad91973964ed2a38bd | https://github.com/XTAIN/JoomlaBundle/blob/3d39e1278deba77c5a2197ad91973964ed2a38bd/Library/Loader.php#L165-L185 |
10,758 | XTAIN/JoomlaBundle | Library/Loader.php | Loader._autoload | private static function _autoload($class)
{
$realClass = $class;
if (preg_match('/^JProxy_/i', $class)) {
$class = preg_replace('/^JProxy_/i', '', $class);
}
foreach (self::$prefixes as $prefix => $lookup) {
$chr = strlen($prefix) < strlen($class) ? $class[strlen($prefix)] : 0;
if (strpos($class, $prefix) === 0 && ($chr === strtoupper($chr))) {
$existsBefore = class_exists($realClass, false);
if ($realClass === $class) {
self::loadByAlias($realClass);
self::load($realClass);
}
$return = true;
if (!$existsBefore && !class_exists($class, false)) {
$return = self::_load(substr($class, strlen($prefix)), $lookup);
}
if ($realClass === $class && !$existsBefore && class_exists($realClass, false)) {
self::injectStaticDependencies($class);
}
return $return;
}
}
return false;
} | php | private static function _autoload($class)
{
$realClass = $class;
if (preg_match('/^JProxy_/i', $class)) {
$class = preg_replace('/^JProxy_/i', '', $class);
}
foreach (self::$prefixes as $prefix => $lookup) {
$chr = strlen($prefix) < strlen($class) ? $class[strlen($prefix)] : 0;
if (strpos($class, $prefix) === 0 && ($chr === strtoupper($chr))) {
$existsBefore = class_exists($realClass, false);
if ($realClass === $class) {
self::loadByAlias($realClass);
self::load($realClass);
}
$return = true;
if (!$existsBefore && !class_exists($class, false)) {
$return = self::_load(substr($class, strlen($prefix)), $lookup);
}
if ($realClass === $class && !$existsBefore && class_exists($realClass, false)) {
self::injectStaticDependencies($class);
}
return $return;
}
}
return false;
} | [
"private",
"static",
"function",
"_autoload",
"(",
"$",
"class",
")",
"{",
"$",
"realClass",
"=",
"$",
"class",
";",
"if",
"(",
"preg_match",
"(",
"'/^JProxy_/i'",
",",
"$",
"class",
")",
")",
"{",
"$",
"class",
"=",
"preg_replace",
"(",
"'/^JProxy_/i'",
",",
"''",
",",
"$",
"class",
")",
";",
"}",
"foreach",
"(",
"self",
"::",
"$",
"prefixes",
"as",
"$",
"prefix",
"=>",
"$",
"lookup",
")",
"{",
"$",
"chr",
"=",
"strlen",
"(",
"$",
"prefix",
")",
"<",
"strlen",
"(",
"$",
"class",
")",
"?",
"$",
"class",
"[",
"strlen",
"(",
"$",
"prefix",
")",
"]",
":",
"0",
";",
"if",
"(",
"strpos",
"(",
"$",
"class",
",",
"$",
"prefix",
")",
"===",
"0",
"&&",
"(",
"$",
"chr",
"===",
"strtoupper",
"(",
"$",
"chr",
")",
")",
")",
"{",
"$",
"existsBefore",
"=",
"class_exists",
"(",
"$",
"realClass",
",",
"false",
")",
";",
"if",
"(",
"$",
"realClass",
"===",
"$",
"class",
")",
"{",
"self",
"::",
"loadByAlias",
"(",
"$",
"realClass",
")",
";",
"self",
"::",
"load",
"(",
"$",
"realClass",
")",
";",
"}",
"$",
"return",
"=",
"true",
";",
"if",
"(",
"!",
"$",
"existsBefore",
"&&",
"!",
"class_exists",
"(",
"$",
"class",
",",
"false",
")",
")",
"{",
"$",
"return",
"=",
"self",
"::",
"_load",
"(",
"substr",
"(",
"$",
"class",
",",
"strlen",
"(",
"$",
"prefix",
")",
")",
",",
"$",
"lookup",
")",
";",
"}",
"if",
"(",
"$",
"realClass",
"===",
"$",
"class",
"&&",
"!",
"$",
"existsBefore",
"&&",
"class_exists",
"(",
"$",
"realClass",
",",
"false",
")",
")",
"{",
"self",
"::",
"injectStaticDependencies",
"(",
"$",
"class",
")",
";",
"}",
"return",
"$",
"return",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Autoload a class based on name.
@param string $class The class to be loaded.
@return bool True if the class was loaded, false otherwise.
@author Maximilian Ruta <[email protected]> | [
"Autoload",
"a",
"class",
"based",
"on",
"name",
"."
] | 3d39e1278deba77c5a2197ad91973964ed2a38bd | https://github.com/XTAIN/JoomlaBundle/blob/3d39e1278deba77c5a2197ad91973964ed2a38bd/Library/Loader.php#L316-L344 |
10,759 | XTAIN/JoomlaBundle | Library/Loader.php | Loader._load | private static function _load($class, array $lookup)
{
// Split the class name into parts separated by camelCase.
$parts = preg_split('/(?<=[a-z0-9])(?=[A-Z])/x', $class);
$partsCount = count($parts);
foreach ($lookup as $base)
{
// Generate the path based on the class name parts.
$path = $base . '/' . implode('/', array_map('strtolower', $parts)) . '.php';
// Load the file if it exists.
if (file_exists($path))
{
return include $path;
}
// Backwards compatibility patch
// If there is only one part we want to duplicate that part for generating the path.
if ($partsCount === 1)
{
// Generate the path based on the class name parts.
$path = $base . '/' . implode('/', array_map('strtolower', array($parts[0], $parts[0]))) . '.php';
// Load the file if it exists.
if (file_exists($path))
{
return include $path;
}
}
}
return false;
} | php | private static function _load($class, array $lookup)
{
// Split the class name into parts separated by camelCase.
$parts = preg_split('/(?<=[a-z0-9])(?=[A-Z])/x', $class);
$partsCount = count($parts);
foreach ($lookup as $base)
{
// Generate the path based on the class name parts.
$path = $base . '/' . implode('/', array_map('strtolower', $parts)) . '.php';
// Load the file if it exists.
if (file_exists($path))
{
return include $path;
}
// Backwards compatibility patch
// If there is only one part we want to duplicate that part for generating the path.
if ($partsCount === 1)
{
// Generate the path based on the class name parts.
$path = $base . '/' . implode('/', array_map('strtolower', array($parts[0], $parts[0]))) . '.php';
// Load the file if it exists.
if (file_exists($path))
{
return include $path;
}
}
}
return false;
} | [
"private",
"static",
"function",
"_load",
"(",
"$",
"class",
",",
"array",
"$",
"lookup",
")",
"{",
"// Split the class name into parts separated by camelCase.",
"$",
"parts",
"=",
"preg_split",
"(",
"'/(?<=[a-z0-9])(?=[A-Z])/x'",
",",
"$",
"class",
")",
";",
"$",
"partsCount",
"=",
"count",
"(",
"$",
"parts",
")",
";",
"foreach",
"(",
"$",
"lookup",
"as",
"$",
"base",
")",
"{",
"// Generate the path based on the class name parts.",
"$",
"path",
"=",
"$",
"base",
".",
"'/'",
".",
"implode",
"(",
"'/'",
",",
"array_map",
"(",
"'strtolower'",
",",
"$",
"parts",
")",
")",
".",
"'.php'",
";",
"// Load the file if it exists.",
"if",
"(",
"file_exists",
"(",
"$",
"path",
")",
")",
"{",
"return",
"include",
"$",
"path",
";",
"}",
"// Backwards compatibility patch",
"// If there is only one part we want to duplicate that part for generating the path.",
"if",
"(",
"$",
"partsCount",
"===",
"1",
")",
"{",
"// Generate the path based on the class name parts.",
"$",
"path",
"=",
"$",
"base",
".",
"'/'",
".",
"implode",
"(",
"'/'",
",",
"array_map",
"(",
"'strtolower'",
",",
"array",
"(",
"$",
"parts",
"[",
"0",
"]",
",",
"$",
"parts",
"[",
"0",
"]",
")",
")",
")",
".",
"'.php'",
";",
"// Load the file if it exists.",
"if",
"(",
"file_exists",
"(",
"$",
"path",
")",
")",
"{",
"return",
"include",
"$",
"path",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}"
] | Load a class based on name and lookup array.
@param string $class The class to be loaded (wihtout prefix).
@param array $lookup The array of base paths to use for finding the class file.
@return bool True if the class was loaded, false otherwise.
@author Maximilian Ruta <[email protected]> | [
"Load",
"a",
"class",
"based",
"on",
"name",
"and",
"lookup",
"array",
"."
] | 3d39e1278deba77c5a2197ad91973964ed2a38bd | https://github.com/XTAIN/JoomlaBundle/blob/3d39e1278deba77c5a2197ad91973964ed2a38bd/Library/Loader.php#L355-L389 |
10,760 | chigix/chiji-frontend | src/Collection/RoadMap.php | RoadMap.append | public function append($road) {
if (!in_array($road->getName(), $this->priorityQueue)) {
$this->put($road);
array_push($this->priorityQueue, $road->getName());
}
return $this;
} | php | public function append($road) {
if (!in_array($road->getName(), $this->priorityQueue)) {
$this->put($road);
array_push($this->priorityQueue, $road->getName());
}
return $this;
} | [
"public",
"function",
"append",
"(",
"$",
"road",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"road",
"->",
"getName",
"(",
")",
",",
"$",
"this",
"->",
"priorityQueue",
")",
")",
"{",
"$",
"this",
"->",
"put",
"(",
"$",
"road",
")",
";",
"array_push",
"(",
"$",
"this",
"->",
"priorityQueue",
",",
"$",
"road",
"->",
"getName",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Append a given resource road into this map.
@param SourceRoad $road
@return RoadMap | [
"Append",
"a",
"given",
"resource",
"road",
"into",
"this",
"map",
"."
] | 5407f98c21ee99f8bbef43c97a231c0f81ed3e74 | https://github.com/chigix/chiji-frontend/blob/5407f98c21ee99f8bbef43c97a231c0f81ed3e74/src/Collection/RoadMap.php#L63-L69 |
10,761 | chigix/chiji-frontend | src/Collection/RoadMap.php | RoadMap.prepend | public function prepend(SourceRoad $road) {
if (!in_array($road->getName(), $this->priorityQueue)) {
$this->put($road);
array_unshift($this->priorityQueue, $road->getName());
}
} | php | public function prepend(SourceRoad $road) {
if (!in_array($road->getName(), $this->priorityQueue)) {
$this->put($road);
array_unshift($this->priorityQueue, $road->getName());
}
} | [
"public",
"function",
"prepend",
"(",
"SourceRoad",
"$",
"road",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"road",
"->",
"getName",
"(",
")",
",",
"$",
"this",
"->",
"priorityQueue",
")",
")",
"{",
"$",
"this",
"->",
"put",
"(",
"$",
"road",
")",
";",
"array_unshift",
"(",
"$",
"this",
"->",
"priorityQueue",
",",
"$",
"road",
"->",
"getName",
"(",
")",
")",
";",
"}",
"}"
] | Prepend a SourceRoad to this roadMap.
@param SourceRoad $road | [
"Prepend",
"a",
"SourceRoad",
"to",
"this",
"roadMap",
"."
] | 5407f98c21ee99f8bbef43c97a231c0f81ed3e74 | https://github.com/chigix/chiji-frontend/blob/5407f98c21ee99f8bbef43c97a231c0f81ed3e74/src/Collection/RoadMap.php#L76-L81 |
10,762 | AnonymPHP/Anonym-Library | src/Anonym/Support/Handler.php | Handler.handleErrors | public function handleErrors($code, $message, $file, $line)
{
throw new ErrorException($message, 0, $code, $file, $line);
} | php | public function handleErrors($code, $message, $file, $line)
{
throw new ErrorException($message, 0, $code, $file, $line);
} | [
"public",
"function",
"handleErrors",
"(",
"$",
"code",
",",
"$",
"message",
",",
"$",
"file",
",",
"$",
"line",
")",
"{",
"throw",
"new",
"ErrorException",
"(",
"$",
"message",
",",
"0",
",",
"$",
"code",
",",
"$",
"file",
",",
"$",
"line",
")",
";",
"}"
] | convert to errors to exceptions
@param int $code
@param string $message
@param string $file
@param int $line
@throws ErrorException | [
"convert",
"to",
"errors",
"to",
"exceptions"
] | c967ad804f84e8fb204593a0959cda2fed5ae075 | https://github.com/AnonymPHP/Anonym-Library/blob/c967ad804f84e8fb204593a0959cda2fed5ae075/src/Anonym/Support/Handler.php#L134-L137 |
10,763 | AnonymPHP/Anonym-Library | src/Anonym/Support/Handler.php | Handler.generateExceptionResponse | protected function generateExceptionResponse(Exception $e){
$e = FlattenException::create($e);
$content = $this->decoreate($this->exceptionHandler->getContent($e), $this->exceptionHandler->getStylesheet($e), 'utf-8');
return response($content, 500);
} | php | protected function generateExceptionResponse(Exception $e){
$e = FlattenException::create($e);
$content = $this->decoreate($this->exceptionHandler->getContent($e), $this->exceptionHandler->getStylesheet($e), 'utf-8');
return response($content, 500);
} | [
"protected",
"function",
"generateExceptionResponse",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"e",
"=",
"FlattenException",
"::",
"create",
"(",
"$",
"e",
")",
";",
"$",
"content",
"=",
"$",
"this",
"->",
"decoreate",
"(",
"$",
"this",
"->",
"exceptionHandler",
"->",
"getContent",
"(",
"$",
"e",
")",
",",
"$",
"this",
"->",
"exceptionHandler",
"->",
"getStylesheet",
"(",
"$",
"e",
")",
",",
"'utf-8'",
")",
";",
"return",
"response",
"(",
"$",
"content",
",",
"500",
")",
";",
"}"
] | create response objecto to exception message
@param Exception $e
@return mixed | [
"create",
"response",
"objecto",
"to",
"exception",
"message"
] | c967ad804f84e8fb204593a0959cda2fed5ae075 | https://github.com/AnonymPHP/Anonym-Library/blob/c967ad804f84e8fb204593a0959cda2fed5ae075/src/Anonym/Support/Handler.php#L185-L191 |
10,764 | AnonymPHP/Anonym-Library | src/Anonym/Support/Handler.php | Handler.shouldBeLog | protected function shouldBeLog($e)
{
foreach ($this->dontLog as $instance) {
if ($e instanceof $instance) {
return false;
}
}
return true;
} | php | protected function shouldBeLog($e)
{
foreach ($this->dontLog as $instance) {
if ($e instanceof $instance) {
return false;
}
}
return true;
} | [
"protected",
"function",
"shouldBeLog",
"(",
"$",
"e",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"dontLog",
"as",
"$",
"instance",
")",
"{",
"if",
"(",
"$",
"e",
"instanceof",
"$",
"instance",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | Determine if the exception should be reported.
@param Exception $e
@return bool | [
"Determine",
"if",
"the",
"exception",
"should",
"be",
"reported",
"."
] | c967ad804f84e8fb204593a0959cda2fed5ae075 | https://github.com/AnonymPHP/Anonym-Library/blob/c967ad804f84e8fb204593a0959cda2fed5ae075/src/Anonym/Support/Handler.php#L199-L208 |
10,765 | aedart/util | src/Traits/Collections/InternalCollectionTrait.php | InternalCollectionTrait.getInternalCollection | protected function getInternalCollection(): ?Collection
{
if (!$this->hasInternalCollection()) {
$this->setInternalCollection($this->getDefaultInternalCollection());
}
return $this->internalCollection;
} | php | protected function getInternalCollection(): ?Collection
{
if (!$this->hasInternalCollection()) {
$this->setInternalCollection($this->getDefaultInternalCollection());
}
return $this->internalCollection;
} | [
"protected",
"function",
"getInternalCollection",
"(",
")",
":",
"?",
"Collection",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasInternalCollection",
"(",
")",
")",
"{",
"$",
"this",
"->",
"setInternalCollection",
"(",
"$",
"this",
"->",
"getDefaultInternalCollection",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"internalCollection",
";",
"}"
] | Get internal collection
If no internal collection has been set, this method will
set and return a default internal collection, if any such
value is available
@see getDefaultInternalCollection()
@return Collection|null internal collection or null if none internal collection has been set | [
"Get",
"internal",
"collection"
] | 6282d19cea2d2f7922298523cdd55fd978929988 | https://github.com/aedart/util/blob/6282d19cea2d2f7922298523cdd55fd978929988/src/Traits/Collections/InternalCollectionTrait.php#L52-L58 |
10,766 | 99designs/ergo | classes/Ergo/Error/ErrorProxy.php | ErrorProxy.register | function register()
{
set_error_handler(array($this,'_handleError'));
set_exception_handler(array($this,'_handleException'));
register_shutdown_function(array($this,'_shutdown'));
$this->_registered = true;
return $this;
} | php | function register()
{
set_error_handler(array($this,'_handleError'));
set_exception_handler(array($this,'_handleException'));
register_shutdown_function(array($this,'_shutdown'));
$this->_registered = true;
return $this;
} | [
"function",
"register",
"(",
")",
"{",
"set_error_handler",
"(",
"array",
"(",
"$",
"this",
",",
"'_handleError'",
")",
")",
";",
"set_exception_handler",
"(",
"array",
"(",
"$",
"this",
",",
"'_handleException'",
")",
")",
";",
"register_shutdown_function",
"(",
"array",
"(",
"$",
"this",
",",
"'_shutdown'",
")",
")",
";",
"$",
"this",
"->",
"_registered",
"=",
"true",
";",
"return",
"$",
"this",
";",
"}"
] | Registers the error handler with PHP | [
"Registers",
"the",
"error",
"handler",
"with",
"PHP"
] | 8fbcfe683a14572cbf26ff59c3537c2261a7a4eb | https://github.com/99designs/ergo/blob/8fbcfe683a14572cbf26ff59c3537c2261a7a4eb/classes/Ergo/Error/ErrorProxy.php#L27-L34 |
10,767 | 99designs/ergo | classes/Ergo/Error/ErrorProxy.php | ErrorProxy._handleException | public function _handleException($e)
{
if(!$this->_inError && $handler = $this->_application->errorHandler())
{
$this->_inError = true;
$handler->handle($e);
$this->_inError = false;
}
else
{
if(php_sapi_name() == 'cli')
{
echo $e->__toString();
exit(1);
}
else
{
header('HTTP/1.1 500 Internal Server Error');
echo "<h1>Error: ".$e->getMessage().'</h1>';
echo '<pre>'.$e->__toString().'</pre>';
exit(1);
}
}
} | php | public function _handleException($e)
{
if(!$this->_inError && $handler = $this->_application->errorHandler())
{
$this->_inError = true;
$handler->handle($e);
$this->_inError = false;
}
else
{
if(php_sapi_name() == 'cli')
{
echo $e->__toString();
exit(1);
}
else
{
header('HTTP/1.1 500 Internal Server Error');
echo "<h1>Error: ".$e->getMessage().'</h1>';
echo '<pre>'.$e->__toString().'</pre>';
exit(1);
}
}
} | [
"public",
"function",
"_handleException",
"(",
"$",
"e",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_inError",
"&&",
"$",
"handler",
"=",
"$",
"this",
"->",
"_application",
"->",
"errorHandler",
"(",
")",
")",
"{",
"$",
"this",
"->",
"_inError",
"=",
"true",
";",
"$",
"handler",
"->",
"handle",
"(",
"$",
"e",
")",
";",
"$",
"this",
"->",
"_inError",
"=",
"false",
";",
"}",
"else",
"{",
"if",
"(",
"php_sapi_name",
"(",
")",
"==",
"'cli'",
")",
"{",
"echo",
"$",
"e",
"->",
"__toString",
"(",
")",
";",
"exit",
"(",
"1",
")",
";",
"}",
"else",
"{",
"header",
"(",
"'HTTP/1.1 500 Internal Server Error'",
")",
";",
"echo",
"\"<h1>Error: \"",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
".",
"'</h1>'",
";",
"echo",
"'<pre>'",
".",
"$",
"e",
"->",
"__toString",
"(",
")",
".",
"'</pre>'",
";",
"exit",
"(",
"1",
")",
";",
"}",
"}",
"}"
] | PHP exception handler interface
@see set_exception_handler | [
"PHP",
"exception",
"handler",
"interface"
] | 8fbcfe683a14572cbf26ff59c3537c2261a7a4eb | https://github.com/99designs/ergo/blob/8fbcfe683a14572cbf26ff59c3537c2261a7a4eb/classes/Ergo/Error/ErrorProxy.php#L51-L75 |
10,768 | 99designs/ergo | classes/Ergo/Error/ErrorProxy.php | ErrorProxy._handleError | public function _handleError($errno, $errstr, $errfile, $errline, $context=null)
{
// process errors based on the error reporting settings
if (error_reporting() & $errno)
{
try
{
// bit of a hack to consolidate errors to exceptions
$message = $this->_errorNumberString($errno).': '.$errstr;
throw new \ErrorException($message,0,$errno,$errfile,$errline);
}
catch(\ErrorException $e)
{
$this->_handleException($e);
}
}
} | php | public function _handleError($errno, $errstr, $errfile, $errline, $context=null)
{
// process errors based on the error reporting settings
if (error_reporting() & $errno)
{
try
{
// bit of a hack to consolidate errors to exceptions
$message = $this->_errorNumberString($errno).': '.$errstr;
throw new \ErrorException($message,0,$errno,$errfile,$errline);
}
catch(\ErrorException $e)
{
$this->_handleException($e);
}
}
} | [
"public",
"function",
"_handleError",
"(",
"$",
"errno",
",",
"$",
"errstr",
",",
"$",
"errfile",
",",
"$",
"errline",
",",
"$",
"context",
"=",
"null",
")",
"{",
"// process errors based on the error reporting settings",
"if",
"(",
"error_reporting",
"(",
")",
"&",
"$",
"errno",
")",
"{",
"try",
"{",
"// bit of a hack to consolidate errors to exceptions",
"$",
"message",
"=",
"$",
"this",
"->",
"_errorNumberString",
"(",
"$",
"errno",
")",
".",
"': '",
".",
"$",
"errstr",
";",
"throw",
"new",
"\\",
"ErrorException",
"(",
"$",
"message",
",",
"0",
",",
"$",
"errno",
",",
"$",
"errfile",
",",
"$",
"errline",
")",
";",
"}",
"catch",
"(",
"\\",
"ErrorException",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"_handleException",
"(",
"$",
"e",
")",
";",
"}",
"}",
"}"
] | PHP error handler interface
@see set_error_handler | [
"PHP",
"error",
"handler",
"interface"
] | 8fbcfe683a14572cbf26ff59c3537c2261a7a4eb | https://github.com/99designs/ergo/blob/8fbcfe683a14572cbf26ff59c3537c2261a7a4eb/classes/Ergo/Error/ErrorProxy.php#L81-L97 |
10,769 | 99designs/ergo | classes/Ergo/Error/ErrorProxy.php | ErrorProxy._errorNumberString | private function _errorNumberString($intval)
{
$errorlevels = array(
E_ALL => 'E_ALL',
E_RECOVERABLE_ERROR => 'E_RECOVERABLE_ERROR',
E_STRICT => 'E_STRICT',
E_USER_NOTICE => 'E_USER_NOTICE',
E_USER_WARNING => 'E_USER_WARNING',
E_USER_ERROR => 'E_USER_ERROR',
E_COMPILE_WARNING => 'E_COMPILE_WARNING',
E_COMPILE_ERROR => 'E_COMPILE_ERROR',
E_CORE_WARNING => 'E_CORE_WARNING',
E_CORE_ERROR => 'E_CORE_ERROR',
E_NOTICE => 'E_NOTICE',
E_PARSE => 'E_PARSE',
E_WARNING => 'E_WARNING',
E_ERROR => 'E_ERROR'
);
if (defined('E_DEPRECATED'))
{
$errorlevels[E_DEPRECATED] = 'E_DEPRECATED';
$errorlevels[E_USER_DEPRECATED] = 'E_USER_DEPRECATED';
}
return $errorlevels[$intval];
} | php | private function _errorNumberString($intval)
{
$errorlevels = array(
E_ALL => 'E_ALL',
E_RECOVERABLE_ERROR => 'E_RECOVERABLE_ERROR',
E_STRICT => 'E_STRICT',
E_USER_NOTICE => 'E_USER_NOTICE',
E_USER_WARNING => 'E_USER_WARNING',
E_USER_ERROR => 'E_USER_ERROR',
E_COMPILE_WARNING => 'E_COMPILE_WARNING',
E_COMPILE_ERROR => 'E_COMPILE_ERROR',
E_CORE_WARNING => 'E_CORE_WARNING',
E_CORE_ERROR => 'E_CORE_ERROR',
E_NOTICE => 'E_NOTICE',
E_PARSE => 'E_PARSE',
E_WARNING => 'E_WARNING',
E_ERROR => 'E_ERROR'
);
if (defined('E_DEPRECATED'))
{
$errorlevels[E_DEPRECATED] = 'E_DEPRECATED';
$errorlevels[E_USER_DEPRECATED] = 'E_USER_DEPRECATED';
}
return $errorlevels[$intval];
} | [
"private",
"function",
"_errorNumberString",
"(",
"$",
"intval",
")",
"{",
"$",
"errorlevels",
"=",
"array",
"(",
"E_ALL",
"=>",
"'E_ALL'",
",",
"E_RECOVERABLE_ERROR",
"=>",
"'E_RECOVERABLE_ERROR'",
",",
"E_STRICT",
"=>",
"'E_STRICT'",
",",
"E_USER_NOTICE",
"=>",
"'E_USER_NOTICE'",
",",
"E_USER_WARNING",
"=>",
"'E_USER_WARNING'",
",",
"E_USER_ERROR",
"=>",
"'E_USER_ERROR'",
",",
"E_COMPILE_WARNING",
"=>",
"'E_COMPILE_WARNING'",
",",
"E_COMPILE_ERROR",
"=>",
"'E_COMPILE_ERROR'",
",",
"E_CORE_WARNING",
"=>",
"'E_CORE_WARNING'",
",",
"E_CORE_ERROR",
"=>",
"'E_CORE_ERROR'",
",",
"E_NOTICE",
"=>",
"'E_NOTICE'",
",",
"E_PARSE",
"=>",
"'E_PARSE'",
",",
"E_WARNING",
"=>",
"'E_WARNING'",
",",
"E_ERROR",
"=>",
"'E_ERROR'",
")",
";",
"if",
"(",
"defined",
"(",
"'E_DEPRECATED'",
")",
")",
"{",
"$",
"errorlevels",
"[",
"E_DEPRECATED",
"]",
"=",
"'E_DEPRECATED'",
";",
"$",
"errorlevels",
"[",
"E_USER_DEPRECATED",
"]",
"=",
"'E_USER_DEPRECATED'",
";",
"}",
"return",
"$",
"errorlevels",
"[",
"$",
"intval",
"]",
";",
"}"
] | Converts a PHP error int to a string | [
"Converts",
"a",
"PHP",
"error",
"int",
"to",
"a",
"string"
] | 8fbcfe683a14572cbf26ff59c3537c2261a7a4eb | https://github.com/99designs/ergo/blob/8fbcfe683a14572cbf26ff59c3537c2261a7a4eb/classes/Ergo/Error/ErrorProxy.php#L102-L128 |
10,770 | 99designs/ergo | classes/Ergo/Error/ErrorProxy.php | ErrorProxy._shutdown | public function _shutdown()
{
if ($this->_registered && $error = error_get_last())
{
try
{
// clear the output buffer if we can
if(ob_get_level()>=1) ob_end_clean();
// build an error exception
if (isset($error['type']) && in_array($error['type'],
array(E_ERROR, E_PARSE, E_COMPILE_ERROR)))
{
$this->_handleError(
$error['type'],
$error['message'],
$error['file'],
$error['line']
);
}
}
catch(Exception $e)
{
}
}
} | php | public function _shutdown()
{
if ($this->_registered && $error = error_get_last())
{
try
{
// clear the output buffer if we can
if(ob_get_level()>=1) ob_end_clean();
// build an error exception
if (isset($error['type']) && in_array($error['type'],
array(E_ERROR, E_PARSE, E_COMPILE_ERROR)))
{
$this->_handleError(
$error['type'],
$error['message'],
$error['file'],
$error['line']
);
}
}
catch(Exception $e)
{
}
}
} | [
"public",
"function",
"_shutdown",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_registered",
"&&",
"$",
"error",
"=",
"error_get_last",
"(",
")",
")",
"{",
"try",
"{",
"// clear the output buffer if we can",
"if",
"(",
"ob_get_level",
"(",
")",
">=",
"1",
")",
"ob_end_clean",
"(",
")",
";",
"// build an error exception",
"if",
"(",
"isset",
"(",
"$",
"error",
"[",
"'type'",
"]",
")",
"&&",
"in_array",
"(",
"$",
"error",
"[",
"'type'",
"]",
",",
"array",
"(",
"E_ERROR",
",",
"E_PARSE",
",",
"E_COMPILE_ERROR",
")",
")",
")",
"{",
"$",
"this",
"->",
"_handleError",
"(",
"$",
"error",
"[",
"'type'",
"]",
",",
"$",
"error",
"[",
"'message'",
"]",
",",
"$",
"error",
"[",
"'file'",
"]",
",",
"$",
"error",
"[",
"'line'",
"]",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"}",
"}",
"}"
] | PHP shutdown function to catch fatal errors
@see http://www.eggplant.ws/blog/php/mayday-php-going-down/
@see register_shutdown_function | [
"PHP",
"shutdown",
"function",
"to",
"catch",
"fatal",
"errors"
] | 8fbcfe683a14572cbf26ff59c3537c2261a7a4eb | https://github.com/99designs/ergo/blob/8fbcfe683a14572cbf26ff59c3537c2261a7a4eb/classes/Ergo/Error/ErrorProxy.php#L135-L160 |
10,771 | air-php/dispatcher | src/Dispatcher.php | Dispatcher.dispatch | public function dispatch(ResolvedRequestInterface $resolvedRequest)
{
$route = $resolvedRequest->getRoute();
$controller = $this->container->make($route->getController(), ['resolvedRequest' => $resolvedRequest]);
// Call the before hook, if defined.
if (method_exists($controller, 'before')) {
$this->container->call(
[$controller, 'before'],
['resolvedRequest' => $resolvedRequest] // The resolvedRequest parameter should always receive this.
);
}
// Call the action.
$response = $this->container->call(
[$controller, 'action' . $route->getAction()],
['resolvedRequest' => $resolvedRequest] // The resolvedRequest parameter should always receive this.
);
// Call the after hook, if defined.
if (method_exists($controller, 'after')) {
$this->container->call(
[$controller, 'after'],
['resolvedRequest' => $resolvedRequest] // The resolvedRequest parameter should always receive this.
);
}
return $response;
} | php | public function dispatch(ResolvedRequestInterface $resolvedRequest)
{
$route = $resolvedRequest->getRoute();
$controller = $this->container->make($route->getController(), ['resolvedRequest' => $resolvedRequest]);
// Call the before hook, if defined.
if (method_exists($controller, 'before')) {
$this->container->call(
[$controller, 'before'],
['resolvedRequest' => $resolvedRequest] // The resolvedRequest parameter should always receive this.
);
}
// Call the action.
$response = $this->container->call(
[$controller, 'action' . $route->getAction()],
['resolvedRequest' => $resolvedRequest] // The resolvedRequest parameter should always receive this.
);
// Call the after hook, if defined.
if (method_exists($controller, 'after')) {
$this->container->call(
[$controller, 'after'],
['resolvedRequest' => $resolvedRequest] // The resolvedRequest parameter should always receive this.
);
}
return $response;
} | [
"public",
"function",
"dispatch",
"(",
"ResolvedRequestInterface",
"$",
"resolvedRequest",
")",
"{",
"$",
"route",
"=",
"$",
"resolvedRequest",
"->",
"getRoute",
"(",
")",
";",
"$",
"controller",
"=",
"$",
"this",
"->",
"container",
"->",
"make",
"(",
"$",
"route",
"->",
"getController",
"(",
")",
",",
"[",
"'resolvedRequest'",
"=>",
"$",
"resolvedRequest",
"]",
")",
";",
"// Call the before hook, if defined.",
"if",
"(",
"method_exists",
"(",
"$",
"controller",
",",
"'before'",
")",
")",
"{",
"$",
"this",
"->",
"container",
"->",
"call",
"(",
"[",
"$",
"controller",
",",
"'before'",
"]",
",",
"[",
"'resolvedRequest'",
"=>",
"$",
"resolvedRequest",
"]",
"// The resolvedRequest parameter should always receive this.",
")",
";",
"}",
"// Call the action.",
"$",
"response",
"=",
"$",
"this",
"->",
"container",
"->",
"call",
"(",
"[",
"$",
"controller",
",",
"'action'",
".",
"$",
"route",
"->",
"getAction",
"(",
")",
"]",
",",
"[",
"'resolvedRequest'",
"=>",
"$",
"resolvedRequest",
"]",
"// The resolvedRequest parameter should always receive this.",
")",
";",
"// Call the after hook, if defined.",
"if",
"(",
"method_exists",
"(",
"$",
"controller",
",",
"'after'",
")",
")",
"{",
"$",
"this",
"->",
"container",
"->",
"call",
"(",
"[",
"$",
"controller",
",",
"'after'",
"]",
",",
"[",
"'resolvedRequest'",
"=>",
"$",
"resolvedRequest",
"]",
"// The resolvedRequest parameter should always receive this.",
")",
";",
"}",
"return",
"$",
"response",
";",
"}"
] | Dispatch a route.
@param ResolvedRequestInterface $resolvedRequest A resolved request.
@return string The response. | [
"Dispatch",
"a",
"route",
"."
] | 9a14ae7db8186c4f44d38a66ade29bd0e10042ec | https://github.com/air-php/dispatcher/blob/9a14ae7db8186c4f44d38a66ade29bd0e10042ec/src/Dispatcher.php#L31-L59 |
10,772 | dave-redfern/laravel-environment-loader | src/ServiceProvider.php | ServiceProvider.registerBootProviders | protected function registerBootProviders(Repository $config)
{
foreach ($this->getComponentsFromConfig($config, 'boot', getenv('APP_ENV')) as $provider) {
$this->app->register($provider);
}
} | php | protected function registerBootProviders(Repository $config)
{
foreach ($this->getComponentsFromConfig($config, 'boot', getenv('APP_ENV')) as $provider) {
$this->app->register($provider);
}
} | [
"protected",
"function",
"registerBootProviders",
"(",
"Repository",
"$",
"config",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getComponentsFromConfig",
"(",
"$",
"config",
",",
"'boot'",
",",
"getenv",
"(",
"'APP_ENV'",
")",
")",
"as",
"$",
"provider",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"register",
"(",
"$",
"provider",
")",
";",
"}",
"}"
] | Registers the boot providers to run
@param Repository $config | [
"Registers",
"the",
"boot",
"providers",
"to",
"run"
] | ddf9def825086572e49378052ad33beac9a17f35 | https://github.com/dave-redfern/laravel-environment-loader/blob/ddf9def825086572e49378052ad33beac9a17f35/src/ServiceProvider.php#L65-L70 |
10,773 | dave-redfern/laravel-environment-loader | src/ServiceProvider.php | ServiceProvider.registerServiceProviders | protected function registerServiceProviders(Repository $config)
{
foreach ($this->getComponentsFromConfig($config, 'register', getenv('APP_ENV')) as $provider) {
$this->app->register($provider);
$config->push('app.providers', $provider);
}
} | php | protected function registerServiceProviders(Repository $config)
{
foreach ($this->getComponentsFromConfig($config, 'register', getenv('APP_ENV')) as $provider) {
$this->app->register($provider);
$config->push('app.providers', $provider);
}
} | [
"protected",
"function",
"registerServiceProviders",
"(",
"Repository",
"$",
"config",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getComponentsFromConfig",
"(",
"$",
"config",
",",
"'register'",
",",
"getenv",
"(",
"'APP_ENV'",
")",
")",
"as",
"$",
"provider",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"register",
"(",
"$",
"provider",
")",
";",
"$",
"config",
"->",
"push",
"(",
"'app.providers'",
",",
"$",
"provider",
")",
";",
"}",
"}"
] | Register the service providers under the "register" call
@param Repository $config | [
"Register",
"the",
"service",
"providers",
"under",
"the",
"register",
"call"
] | ddf9def825086572e49378052ad33beac9a17f35 | https://github.com/dave-redfern/laravel-environment-loader/blob/ddf9def825086572e49378052ad33beac9a17f35/src/ServiceProvider.php#L77-L84 |
10,774 | dave-redfern/laravel-environment-loader | src/ServiceProvider.php | ServiceProvider.registerFacadeAliases | protected function registerFacadeAliases(Repository $config)
{
$loader = AliasLoader::getInstance();
foreach ($this->getComponentsFromConfig($config, 'facades', getenv('APP_ENV')) as $alias => $facade) {
$loader->alias($alias, $facade);
$config->set('app.aliases.' . $alias, $facade);
}
} | php | protected function registerFacadeAliases(Repository $config)
{
$loader = AliasLoader::getInstance();
foreach ($this->getComponentsFromConfig($config, 'facades', getenv('APP_ENV')) as $alias => $facade) {
$loader->alias($alias, $facade);
$config->set('app.aliases.' . $alias, $facade);
}
} | [
"protected",
"function",
"registerFacadeAliases",
"(",
"Repository",
"$",
"config",
")",
"{",
"$",
"loader",
"=",
"AliasLoader",
"::",
"getInstance",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getComponentsFromConfig",
"(",
"$",
"config",
",",
"'facades'",
",",
"getenv",
"(",
"'APP_ENV'",
")",
")",
"as",
"$",
"alias",
"=>",
"$",
"facade",
")",
"{",
"$",
"loader",
"->",
"alias",
"(",
"$",
"alias",
",",
"$",
"facade",
")",
";",
"$",
"config",
"->",
"set",
"(",
"'app.aliases.'",
".",
"$",
"alias",
",",
"$",
"facade",
")",
";",
"}",
"}"
] | Registers any facades that have been defined
@param Repository $config | [
"Registers",
"any",
"facades",
"that",
"have",
"been",
"defined"
] | ddf9def825086572e49378052ad33beac9a17f35 | https://github.com/dave-redfern/laravel-environment-loader/blob/ddf9def825086572e49378052ad33beac9a17f35/src/ServiceProvider.php#L91-L100 |
10,775 | nullivex/lib-xport | LSS/Xport.php | Xport.init | protected function init(
$http_host='localhost'
,$http_port=80
,$http_scheme='http://'
,$log_level=Log::INFO
){
//setup stream handler
$this->stream = Stream::_get();
$this->stream->setCompression(Stream::COMPRESS_GZIP);
$this->stream->setEncryption(Stream::CRYPT_LSS);
//set environment
$this->setHTTPHost($http_host);
$this->setHTTPPort($http_port);
$this->setHTTPScheme($http_scheme);
//setup logging
$this->log = Log::_get()->setLevel($log_level);
//make sure the mda package exists
if(!is_callable('mda_get'))
throw new Exception('MDA package not loaded: required mda_get()');
//startup complete
} | php | protected function init(
$http_host='localhost'
,$http_port=80
,$http_scheme='http://'
,$log_level=Log::INFO
){
//setup stream handler
$this->stream = Stream::_get();
$this->stream->setCompression(Stream::COMPRESS_GZIP);
$this->stream->setEncryption(Stream::CRYPT_LSS);
//set environment
$this->setHTTPHost($http_host);
$this->setHTTPPort($http_port);
$this->setHTTPScheme($http_scheme);
//setup logging
$this->log = Log::_get()->setLevel($log_level);
//make sure the mda package exists
if(!is_callable('mda_get'))
throw new Exception('MDA package not loaded: required mda_get()');
//startup complete
} | [
"protected",
"function",
"init",
"(",
"$",
"http_host",
"=",
"'localhost'",
",",
"$",
"http_port",
"=",
"80",
",",
"$",
"http_scheme",
"=",
"'http://'",
",",
"$",
"log_level",
"=",
"Log",
"::",
"INFO",
")",
"{",
"//setup stream handler",
"$",
"this",
"->",
"stream",
"=",
"Stream",
"::",
"_get",
"(",
")",
";",
"$",
"this",
"->",
"stream",
"->",
"setCompression",
"(",
"Stream",
"::",
"COMPRESS_GZIP",
")",
";",
"$",
"this",
"->",
"stream",
"->",
"setEncryption",
"(",
"Stream",
"::",
"CRYPT_LSS",
")",
";",
"//set environment",
"$",
"this",
"->",
"setHTTPHost",
"(",
"$",
"http_host",
")",
";",
"$",
"this",
"->",
"setHTTPPort",
"(",
"$",
"http_port",
")",
";",
"$",
"this",
"->",
"setHTTPScheme",
"(",
"$",
"http_scheme",
")",
";",
"//setup logging",
"$",
"this",
"->",
"log",
"=",
"Log",
"::",
"_get",
"(",
")",
"->",
"setLevel",
"(",
"$",
"log_level",
")",
";",
"//make sure the mda package exists",
"if",
"(",
"!",
"is_callable",
"(",
"'mda_get'",
")",
")",
"throw",
"new",
"Exception",
"(",
"'MDA package not loaded: required mda_get()'",
")",
";",
"//startup complete",
"}"
] | the real constructor | [
"the",
"real",
"constructor"
] | 87a2156d9d15a8eecbcab3e5a00326dc24b9e97e | https://github.com/nullivex/lib-xport/blob/87a2156d9d15a8eecbcab3e5a00326dc24b9e97e/LSS/Xport.php#L61-L81 |
10,776 | vinala/kernel | src/Collections/Collection.php | Collection.get | public static function get($array, $pattern)
{
if (!is_array($array)) {
return;
}
//
if (array_key_exists($pattern, $array)) {
return $array[$pattern];
}
//
foreach (explode('.', $pattern) as $segment) {
if (is_array($array) && array_key_exists($segment, $array)) {
$array = $array[$segment];
} else {
return;
}
}
//
} | php | public static function get($array, $pattern)
{
if (!is_array($array)) {
return;
}
//
if (array_key_exists($pattern, $array)) {
return $array[$pattern];
}
//
foreach (explode('.', $pattern) as $segment) {
if (is_array($array) && array_key_exists($segment, $array)) {
$array = $array[$segment];
} else {
return;
}
}
//
} | [
"public",
"static",
"function",
"get",
"(",
"$",
"array",
",",
"$",
"pattern",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"array",
")",
")",
"{",
"return",
";",
"}",
"//",
"if",
"(",
"array_key_exists",
"(",
"$",
"pattern",
",",
"$",
"array",
")",
")",
"{",
"return",
"$",
"array",
"[",
"$",
"pattern",
"]",
";",
"}",
"//",
"foreach",
"(",
"explode",
"(",
"'.'",
",",
"$",
"pattern",
")",
"as",
"$",
"segment",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"array",
")",
"&&",
"array_key_exists",
"(",
"$",
"segment",
",",
"$",
"array",
")",
")",
"{",
"$",
"array",
"=",
"$",
"array",
"[",
"$",
"segment",
"]",
";",
"}",
"else",
"{",
"return",
";",
"}",
"}",
"//",
"}"
] | Get Element from array by dot aspect.
@param array $array
@param string $pattern
@return mixed | [
"Get",
"Element",
"from",
"array",
"by",
"dot",
"aspect",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Collections/Collection.php#L61-L79 |
10,777 | vinala/kernel | src/Collections/Collection.php | Collection.push | public static function push(&$array)
{
$params = func_get_arg();
for ($i = 1; $i < static::count($params); $i++) {
array_push($array, $params[$i]);
}
} | php | public static function push(&$array)
{
$params = func_get_arg();
for ($i = 1; $i < static::count($params); $i++) {
array_push($array, $params[$i]);
}
} | [
"public",
"static",
"function",
"push",
"(",
"&",
"$",
"array",
")",
"{",
"$",
"params",
"=",
"func_get_arg",
"(",
")",
";",
"for",
"(",
"$",
"i",
"=",
"1",
";",
"$",
"i",
"<",
"static",
"::",
"count",
"(",
"$",
"params",
")",
";",
"$",
"i",
"++",
")",
"{",
"array_push",
"(",
"$",
"array",
",",
"$",
"params",
"[",
"$",
"i",
"]",
")",
";",
"}",
"}"
] | Add element to end of array.
@param array $array
@param param[]
@return null | [
"Add",
"element",
"to",
"end",
"of",
"array",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Collections/Collection.php#L107-L114 |
10,778 | vinala/kernel | src/Collections/Collection.php | Collection.concat | public static function concat(array $array, $separator = ' ')
{
$result = '';
foreach ($array as $string) {
if (is_string($string)) {
$result .= $string;
}
}
return $result;
} | php | public static function concat(array $array, $separator = ' ')
{
$result = '';
foreach ($array as $string) {
if (is_string($string)) {
$result .= $string;
}
}
return $result;
} | [
"public",
"static",
"function",
"concat",
"(",
"array",
"$",
"array",
",",
"$",
"separator",
"=",
"' '",
")",
"{",
"$",
"result",
"=",
"''",
";",
"foreach",
"(",
"$",
"array",
"as",
"$",
"string",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"string",
")",
")",
"{",
"$",
"result",
".=",
"$",
"string",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] | Concat string elements in array.
@param array $array
@param string $separator
@return string | [
"Concat",
"string",
"elements",
"in",
"array",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Collections/Collection.php#L124-L135 |
10,779 | vinala/kernel | src/Collections/Collection.php | Collection.copy | public static function copy($array, $target)
{
foreach ($array as $key => $element) {
self::add($target, $element, $key);
}
} | php | public static function copy($array, $target)
{
foreach ($array as $key => $element) {
self::add($target, $element, $key);
}
} | [
"public",
"static",
"function",
"copy",
"(",
"$",
"array",
",",
"$",
"target",
")",
"{",
"foreach",
"(",
"$",
"array",
"as",
"$",
"key",
"=>",
"$",
"element",
")",
"{",
"self",
"::",
"add",
"(",
"$",
"target",
",",
"$",
"element",
",",
"$",
"key",
")",
";",
"}",
"}"
] | Copy element of an array to another array.
@param array $array
@param array $target
@return null | [
"Copy",
"element",
"of",
"an",
"array",
"to",
"another",
"array",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Collections/Collection.php#L164-L169 |
10,780 | vinala/kernel | src/Collections/Collection.php | Collection.equal | public static function equal(array $array1, array $array2)
{
if (static::count($array1) != static::count($array2)) {
return false;
} else {
for ($i = 0; $i < static::count($array1); $i++) {
if ($array1[$i] != $array2[$i]) {
return false;
}
}
}
return true;
} | php | public static function equal(array $array1, array $array2)
{
if (static::count($array1) != static::count($array2)) {
return false;
} else {
for ($i = 0; $i < static::count($array1); $i++) {
if ($array1[$i] != $array2[$i]) {
return false;
}
}
}
return true;
} | [
"public",
"static",
"function",
"equal",
"(",
"array",
"$",
"array1",
",",
"array",
"$",
"array2",
")",
"{",
"if",
"(",
"static",
"::",
"count",
"(",
"$",
"array1",
")",
"!=",
"static",
"::",
"count",
"(",
"$",
"array2",
")",
")",
"{",
"return",
"false",
";",
"}",
"else",
"{",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"static",
"::",
"count",
"(",
"$",
"array1",
")",
";",
"$",
"i",
"++",
")",
"{",
"if",
"(",
"$",
"array1",
"[",
"$",
"i",
"]",
"!=",
"$",
"array2",
"[",
"$",
"i",
"]",
")",
"{",
"return",
"false",
";",
"}",
"}",
"}",
"return",
"true",
";",
"}"
] | Check if array equal to another array.
@param array $array1
@param array $array2
@return bool | [
"Check",
"if",
"array",
"equal",
"to",
"another",
"array",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Collections/Collection.php#L179-L192 |
10,781 | vinala/kernel | src/Collections/Collection.php | Collection.except | public static function except($array1, $array2)
{
$result = [];
foreach ($array1 as $key => $value) {
if (!static::contains($array2, $value)) {
if (is_int($key)) {
static::add($array, $value);
} else {
static::add($array, $value, $key);
}
}
}
foreach ($array2 as $key => $value) {
if (!static::contains($array1, $value) && !self::contains($result, $value)) {
if (is_int($key)) {
static::add($array, $value);
} else {
static::add($array, $value, $key);
}
}
}
return $result;
} | php | public static function except($array1, $array2)
{
$result = [];
foreach ($array1 as $key => $value) {
if (!static::contains($array2, $value)) {
if (is_int($key)) {
static::add($array, $value);
} else {
static::add($array, $value, $key);
}
}
}
foreach ($array2 as $key => $value) {
if (!static::contains($array1, $value) && !self::contains($result, $value)) {
if (is_int($key)) {
static::add($array, $value);
} else {
static::add($array, $value, $key);
}
}
}
return $result;
} | [
"public",
"static",
"function",
"except",
"(",
"$",
"array1",
",",
"$",
"array2",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"array1",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"static",
"::",
"contains",
"(",
"$",
"array2",
",",
"$",
"value",
")",
")",
"{",
"if",
"(",
"is_int",
"(",
"$",
"key",
")",
")",
"{",
"static",
"::",
"add",
"(",
"$",
"array",
",",
"$",
"value",
")",
";",
"}",
"else",
"{",
"static",
"::",
"add",
"(",
"$",
"array",
",",
"$",
"value",
",",
"$",
"key",
")",
";",
"}",
"}",
"}",
"foreach",
"(",
"$",
"array2",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"static",
"::",
"contains",
"(",
"$",
"array1",
",",
"$",
"value",
")",
"&&",
"!",
"self",
"::",
"contains",
"(",
"$",
"result",
",",
"$",
"value",
")",
")",
"{",
"if",
"(",
"is_int",
"(",
"$",
"key",
")",
")",
"{",
"static",
"::",
"add",
"(",
"$",
"array",
",",
"$",
"value",
")",
";",
"}",
"else",
"{",
"static",
"::",
"add",
"(",
"$",
"array",
",",
"$",
"value",
",",
"$",
"key",
")",
";",
"}",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] | Distinct element between two array.
@param array $array1
@param array $array2
@return array | [
"Distinct",
"element",
"between",
"two",
"array",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Collections/Collection.php#L202-L227 |
10,782 | vinala/kernel | src/Collections/Collection.php | Collection.exists | public static function exists(array $array, $key)
{
//
if (array_key_exists($key, $array)) {
return true;
}
//
$keys = dot($key);
//
foreach ($keys as $key) {
if (array_key_exists($key, $array)) {
$array = (array) $array[$key];
continue;
} else {
return false;
}
}
//
return true;
} | php | public static function exists(array $array, $key)
{
//
if (array_key_exists($key, $array)) {
return true;
}
//
$keys = dot($key);
//
foreach ($keys as $key) {
if (array_key_exists($key, $array)) {
$array = (array) $array[$key];
continue;
} else {
return false;
}
}
//
return true;
} | [
"public",
"static",
"function",
"exists",
"(",
"array",
"$",
"array",
",",
"$",
"key",
")",
"{",
"//",
"if",
"(",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"array",
")",
")",
"{",
"return",
"true",
";",
"}",
"//",
"$",
"keys",
"=",
"dot",
"(",
"$",
"key",
")",
";",
"//",
"foreach",
"(",
"$",
"keys",
"as",
"$",
"key",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"array",
")",
")",
"{",
"$",
"array",
"=",
"(",
"array",
")",
"$",
"array",
"[",
"$",
"key",
"]",
";",
"continue",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}",
"//",
"return",
"true",
";",
"}"
] | check if array have a key from a given array using "dot" notation.
@param array $array
@param string $key
@return bool | [
"check",
"if",
"array",
"have",
"a",
"key",
"from",
"a",
"given",
"array",
"using",
"dot",
"notation",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Collections/Collection.php#L304-L323 |
10,783 | razielsd/webdriverlib | WebDriver/WebDriver/Object/Alert.php | WebDriver_Object_Alert.accept | public function accept()
{
$command = $this->driver->factoryCommand('accept_alert', WebDriver_Command::METHOD_POST);
return $this->driver->curl($command)['value'];
} | php | public function accept()
{
$command = $this->driver->factoryCommand('accept_alert', WebDriver_Command::METHOD_POST);
return $this->driver->curl($command)['value'];
} | [
"public",
"function",
"accept",
"(",
")",
"{",
"$",
"command",
"=",
"$",
"this",
"->",
"driver",
"->",
"factoryCommand",
"(",
"'accept_alert'",
",",
"WebDriver_Command",
"::",
"METHOD_POST",
")",
";",
"return",
"$",
"this",
"->",
"driver",
"->",
"curl",
"(",
"$",
"command",
")",
"[",
"'value'",
"]",
";",
"}"
] | Accepts the currently displayed alert dialog. | [
"Accepts",
"the",
"currently",
"displayed",
"alert",
"dialog",
"."
] | e498afc36a8cdeab5b6ca95016420557baf32f36 | https://github.com/razielsd/webdriverlib/blob/e498afc36a8cdeab5b6ca95016420557baf32f36/WebDriver/WebDriver/Object/Alert.php#L35-L39 |
10,784 | razielsd/webdriverlib | WebDriver/WebDriver/Object/Alert.php | WebDriver_Object_Alert.dismiss | public function dismiss()
{
$command = $this->driver->factoryCommand('dismiss_alert', WebDriver_Command::METHOD_POST);
return $this->driver->curl($command)['value'];
} | php | public function dismiss()
{
$command = $this->driver->factoryCommand('dismiss_alert', WebDriver_Command::METHOD_POST);
return $this->driver->curl($command)['value'];
} | [
"public",
"function",
"dismiss",
"(",
")",
"{",
"$",
"command",
"=",
"$",
"this",
"->",
"driver",
"->",
"factoryCommand",
"(",
"'dismiss_alert'",
",",
"WebDriver_Command",
"::",
"METHOD_POST",
")",
";",
"return",
"$",
"this",
"->",
"driver",
"->",
"curl",
"(",
"$",
"command",
")",
"[",
"'value'",
"]",
";",
"}"
] | Dismisses the currently displayed alert dialog. | [
"Dismisses",
"the",
"currently",
"displayed",
"alert",
"dialog",
"."
] | e498afc36a8cdeab5b6ca95016420557baf32f36 | https://github.com/razielsd/webdriverlib/blob/e498afc36a8cdeab5b6ca95016420557baf32f36/WebDriver/WebDriver/Object/Alert.php#L45-L49 |
10,785 | razielsd/webdriverlib | WebDriver/WebDriver/Object/Alert.php | WebDriver_Object_Alert.wait | public function wait($timeout = 30)
{
$lastException = null;
for ($i = 0; $i < $timeout; $i++) {
try {
$this->text();
return $this;
} catch (WebDriver_Exception $e) {
$lastException = $e;
sleep(1);
}
}
if (null !== $lastException) {
throw $lastException;
}
return $this;
} | php | public function wait($timeout = 30)
{
$lastException = null;
for ($i = 0; $i < $timeout; $i++) {
try {
$this->text();
return $this;
} catch (WebDriver_Exception $e) {
$lastException = $e;
sleep(1);
}
}
if (null !== $lastException) {
throw $lastException;
}
return $this;
} | [
"public",
"function",
"wait",
"(",
"$",
"timeout",
"=",
"30",
")",
"{",
"$",
"lastException",
"=",
"null",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"timeout",
";",
"$",
"i",
"++",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"text",
"(",
")",
";",
"return",
"$",
"this",
";",
"}",
"catch",
"(",
"WebDriver_Exception",
"$",
"e",
")",
"{",
"$",
"lastException",
"=",
"$",
"e",
";",
"sleep",
"(",
"1",
")",
";",
"}",
"}",
"if",
"(",
"null",
"!==",
"$",
"lastException",
")",
"{",
"throw",
"$",
"lastException",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Waits for an alert to appear.
@param int $timeout
@return $this
@throws WebDriver_Exception | [
"Waits",
"for",
"an",
"alert",
"to",
"appear",
"."
] | e498afc36a8cdeab5b6ca95016420557baf32f36 | https://github.com/razielsd/webdriverlib/blob/e498afc36a8cdeab5b6ca95016420557baf32f36/WebDriver/WebDriver/Object/Alert.php#L59-L77 |
10,786 | tigron/skeleton-i18n | lib/Skeleton/I18n/Object/Text.php | Text.get_by_object | public static function get_by_object($object) {
$db = Database::Get();
$class = get_class($object);
$data = $db->get_all('SELECT * FROM object_text WHERE classname=? AND object_id=?', [ $class, $object->id ]);
$object_texts = [];
foreach ($data as $details) {
$object_text = new self();
$object_text->id = $details['id'];
$object_text->details = $details;
$object_texts[] = $object_text;
}
return $object_texts;
} | php | public static function get_by_object($object) {
$db = Database::Get();
$class = get_class($object);
$data = $db->get_all('SELECT * FROM object_text WHERE classname=? AND object_id=?', [ $class, $object->id ]);
$object_texts = [];
foreach ($data as $details) {
$object_text = new self();
$object_text->id = $details['id'];
$object_text->details = $details;
$object_texts[] = $object_text;
}
return $object_texts;
} | [
"public",
"static",
"function",
"get_by_object",
"(",
"$",
"object",
")",
"{",
"$",
"db",
"=",
"Database",
"::",
"Get",
"(",
")",
";",
"$",
"class",
"=",
"get_class",
"(",
"$",
"object",
")",
";",
"$",
"data",
"=",
"$",
"db",
"->",
"get_all",
"(",
"'SELECT * FROM object_text WHERE classname=? AND object_id=?'",
",",
"[",
"$",
"class",
",",
"$",
"object",
"->",
"id",
"]",
")",
";",
"$",
"object_texts",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"details",
")",
"{",
"$",
"object_text",
"=",
"new",
"self",
"(",
")",
";",
"$",
"object_text",
"->",
"id",
"=",
"$",
"details",
"[",
"'id'",
"]",
";",
"$",
"object_text",
"->",
"details",
"=",
"$",
"details",
";",
"$",
"object_texts",
"[",
"]",
"=",
"$",
"object_text",
";",
"}",
"return",
"$",
"object_texts",
";",
"}"
] | Get by object
@access public
@param mixed $object | [
"Get",
"by",
"object"
] | b1523e69ec8674b9d9359045ff0ee4dfde66f9e6 | https://github.com/tigron/skeleton-i18n/blob/b1523e69ec8674b9d9359045ff0ee4dfde66f9e6/lib/Skeleton/I18n/Object/Text.php#L90-L104 |
10,787 | tigron/skeleton-i18n | lib/Skeleton/I18n/Object/Text.php | Text.get_by_object_label_language | public static function get_by_object_label_language($object, $label, \Skeleton\I18n\LanguageInterface $language, $auto_create = true) {
$class_parents = class_parents($object);
if ($class_parents === false OR count($class_parents) == 0) {
$class = get_class($object);
} else {
$class = array_pop($class_parents);
}
if (self::trait_cache_enabled()) {
try {
$key = $class . '_' . $object->id . '_' . $label . '_' . $language->name_short;
$object = self::cache_get($key);
return $object;
} catch (\Exception $e) {}
}
$db = Database::Get();
$data = $db->get_row('SELECT * FROM object_text WHERE classname=? AND object_id=? AND label=? AND language_id=?', [ $class, $object->id, $label, $language->id ]);
if ($data === null) {
if (!$auto_create) {
throw new \Exception('Object text does not exists');
} else {
$requested = new self();
$requested->object = $object;
$requested->language_id = $language->id;
$requested->label = $label;
$requested->content = '';
$requested->save();
if (self::trait_cache_enabled()) {
$key = $class . '_' . $object->id . '_' . $label . '_' . $language->name_short;
self::cache_set($key, $requested);
}
return $requested;
}
}
$object_text = new self();
$object_text->id = $data['id'];
$object_text->details = $data;
if (self::trait_cache_enabled()) {
$key = $class . '_' . $object->id . '_' . $label . '_' . $language->name_short;
self::cache_set($key, $object_text);
}
return $object_text;
} | php | public static function get_by_object_label_language($object, $label, \Skeleton\I18n\LanguageInterface $language, $auto_create = true) {
$class_parents = class_parents($object);
if ($class_parents === false OR count($class_parents) == 0) {
$class = get_class($object);
} else {
$class = array_pop($class_parents);
}
if (self::trait_cache_enabled()) {
try {
$key = $class . '_' . $object->id . '_' . $label . '_' . $language->name_short;
$object = self::cache_get($key);
return $object;
} catch (\Exception $e) {}
}
$db = Database::Get();
$data = $db->get_row('SELECT * FROM object_text WHERE classname=? AND object_id=? AND label=? AND language_id=?', [ $class, $object->id, $label, $language->id ]);
if ($data === null) {
if (!$auto_create) {
throw new \Exception('Object text does not exists');
} else {
$requested = new self();
$requested->object = $object;
$requested->language_id = $language->id;
$requested->label = $label;
$requested->content = '';
$requested->save();
if (self::trait_cache_enabled()) {
$key = $class . '_' . $object->id . '_' . $label . '_' . $language->name_short;
self::cache_set($key, $requested);
}
return $requested;
}
}
$object_text = new self();
$object_text->id = $data['id'];
$object_text->details = $data;
if (self::trait_cache_enabled()) {
$key = $class . '_' . $object->id . '_' . $label . '_' . $language->name_short;
self::cache_set($key, $object_text);
}
return $object_text;
} | [
"public",
"static",
"function",
"get_by_object_label_language",
"(",
"$",
"object",
",",
"$",
"label",
",",
"\\",
"Skeleton",
"\\",
"I18n",
"\\",
"LanguageInterface",
"$",
"language",
",",
"$",
"auto_create",
"=",
"true",
")",
"{",
"$",
"class_parents",
"=",
"class_parents",
"(",
"$",
"object",
")",
";",
"if",
"(",
"$",
"class_parents",
"===",
"false",
"OR",
"count",
"(",
"$",
"class_parents",
")",
"==",
"0",
")",
"{",
"$",
"class",
"=",
"get_class",
"(",
"$",
"object",
")",
";",
"}",
"else",
"{",
"$",
"class",
"=",
"array_pop",
"(",
"$",
"class_parents",
")",
";",
"}",
"if",
"(",
"self",
"::",
"trait_cache_enabled",
"(",
")",
")",
"{",
"try",
"{",
"$",
"key",
"=",
"$",
"class",
".",
"'_'",
".",
"$",
"object",
"->",
"id",
".",
"'_'",
".",
"$",
"label",
".",
"'_'",
".",
"$",
"language",
"->",
"name_short",
";",
"$",
"object",
"=",
"self",
"::",
"cache_get",
"(",
"$",
"key",
")",
";",
"return",
"$",
"object",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"}",
"}",
"$",
"db",
"=",
"Database",
"::",
"Get",
"(",
")",
";",
"$",
"data",
"=",
"$",
"db",
"->",
"get_row",
"(",
"'SELECT * FROM object_text WHERE classname=? AND object_id=? AND label=? AND language_id=?'",
",",
"[",
"$",
"class",
",",
"$",
"object",
"->",
"id",
",",
"$",
"label",
",",
"$",
"language",
"->",
"id",
"]",
")",
";",
"if",
"(",
"$",
"data",
"===",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"auto_create",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Object text does not exists'",
")",
";",
"}",
"else",
"{",
"$",
"requested",
"=",
"new",
"self",
"(",
")",
";",
"$",
"requested",
"->",
"object",
"=",
"$",
"object",
";",
"$",
"requested",
"->",
"language_id",
"=",
"$",
"language",
"->",
"id",
";",
"$",
"requested",
"->",
"label",
"=",
"$",
"label",
";",
"$",
"requested",
"->",
"content",
"=",
"''",
";",
"$",
"requested",
"->",
"save",
"(",
")",
";",
"if",
"(",
"self",
"::",
"trait_cache_enabled",
"(",
")",
")",
"{",
"$",
"key",
"=",
"$",
"class",
".",
"'_'",
".",
"$",
"object",
"->",
"id",
".",
"'_'",
".",
"$",
"label",
".",
"'_'",
".",
"$",
"language",
"->",
"name_short",
";",
"self",
"::",
"cache_set",
"(",
"$",
"key",
",",
"$",
"requested",
")",
";",
"}",
"return",
"$",
"requested",
";",
"}",
"}",
"$",
"object_text",
"=",
"new",
"self",
"(",
")",
";",
"$",
"object_text",
"->",
"id",
"=",
"$",
"data",
"[",
"'id'",
"]",
";",
"$",
"object_text",
"->",
"details",
"=",
"$",
"data",
";",
"if",
"(",
"self",
"::",
"trait_cache_enabled",
"(",
")",
")",
"{",
"$",
"key",
"=",
"$",
"class",
".",
"'_'",
".",
"$",
"object",
"->",
"id",
".",
"'_'",
".",
"$",
"label",
".",
"'_'",
".",
"$",
"language",
"->",
"name_short",
";",
"self",
"::",
"cache_set",
"(",
"$",
"key",
",",
"$",
"object_text",
")",
";",
"}",
"return",
"$",
"object_text",
";",
"}"
] | Get by object, label, language
@access public
@param mixed $object
@param string $label
@param Language $language | [
"Get",
"by",
"object",
"label",
"language"
] | b1523e69ec8674b9d9359045ff0ee4dfde66f9e6 | https://github.com/tigron/skeleton-i18n/blob/b1523e69ec8674b9d9359045ff0ee4dfde66f9e6/lib/Skeleton/I18n/Object/Text.php#L114-L163 |
10,788 | nodes-php/core | src/Support/UserAgent/Agents/Nodes.php | Nodes.parse | protected function parse()
{
// Parse Nodes user agent
if (!preg_match('|Nodes/(.*)\s\((.*)\)|s', $this->userAgent, $match)) {
return;
}
// Put matches into their own variables
list($version, $parameters) = array_slice($match, 1);
// Split comma-separated parameters
$parameters = explode(',', $parameters);
// Set version if available
if (!empty($version)) {
$this->setVersion($version);
}
// Set parameters if available
if (!empty($parameters)) {
$this->setParameters($parameters);
}
// Mark parsing as successful
$this->successful = true;
} | php | protected function parse()
{
// Parse Nodes user agent
if (!preg_match('|Nodes/(.*)\s\((.*)\)|s', $this->userAgent, $match)) {
return;
}
// Put matches into their own variables
list($version, $parameters) = array_slice($match, 1);
// Split comma-separated parameters
$parameters = explode(',', $parameters);
// Set version if available
if (!empty($version)) {
$this->setVersion($version);
}
// Set parameters if available
if (!empty($parameters)) {
$this->setParameters($parameters);
}
// Mark parsing as successful
$this->successful = true;
} | [
"protected",
"function",
"parse",
"(",
")",
"{",
"// Parse Nodes user agent",
"if",
"(",
"!",
"preg_match",
"(",
"'|Nodes/(.*)\\s\\((.*)\\)|s'",
",",
"$",
"this",
"->",
"userAgent",
",",
"$",
"match",
")",
")",
"{",
"return",
";",
"}",
"// Put matches into their own variables",
"list",
"(",
"$",
"version",
",",
"$",
"parameters",
")",
"=",
"array_slice",
"(",
"$",
"match",
",",
"1",
")",
";",
"// Split comma-separated parameters",
"$",
"parameters",
"=",
"explode",
"(",
"','",
",",
"$",
"parameters",
")",
";",
"// Set version if available",
"if",
"(",
"!",
"empty",
"(",
"$",
"version",
")",
")",
"{",
"$",
"this",
"->",
"setVersion",
"(",
"$",
"version",
")",
";",
"}",
"// Set parameters if available",
"if",
"(",
"!",
"empty",
"(",
"$",
"parameters",
")",
")",
"{",
"$",
"this",
"->",
"setParameters",
"(",
"$",
"parameters",
")",
";",
"}",
"// Mark parsing as successful",
"$",
"this",
"->",
"successful",
"=",
"true",
";",
"}"
] | Parse user agent string.
@author Morten Rugaard <[email protected]>
@return void | [
"Parse",
"user",
"agent",
"string",
"."
] | fc788bb3e9668872573838099f868ab162eb8a96 | https://github.com/nodes-php/core/blob/fc788bb3e9668872573838099f868ab162eb8a96/src/Support/UserAgent/Agents/Nodes.php#L96-L121 |
10,789 | nodes-php/core | src/Support/UserAgent/Agents/Nodes.php | Nodes.setVersion | public function setVersion($version)
{
// Set version
$this->version = $version;
// Split version into major, minor and patch
$version = explode('.', $version);
if (count($version) == 1) {
array_push($version, 0, 0);
}
// Set major, minor and patch version
$this->majorVersion = (int) isset($version[0]) ? $version[0] : 0;
$this->minorVersion = (int) isset($version[1]) ? $version[1] : 0;
$this->patchVersion = (int) isset($version[2]) ? $version[2] : 0;
return $this;
} | php | public function setVersion($version)
{
// Set version
$this->version = $version;
// Split version into major, minor and patch
$version = explode('.', $version);
if (count($version) == 1) {
array_push($version, 0, 0);
}
// Set major, minor and patch version
$this->majorVersion = (int) isset($version[0]) ? $version[0] : 0;
$this->minorVersion = (int) isset($version[1]) ? $version[1] : 0;
$this->patchVersion = (int) isset($version[2]) ? $version[2] : 0;
return $this;
} | [
"public",
"function",
"setVersion",
"(",
"$",
"version",
")",
"{",
"// Set version",
"$",
"this",
"->",
"version",
"=",
"$",
"version",
";",
"// Split version into major, minor and patch",
"$",
"version",
"=",
"explode",
"(",
"'.'",
",",
"$",
"version",
")",
";",
"if",
"(",
"count",
"(",
"$",
"version",
")",
"==",
"1",
")",
"{",
"array_push",
"(",
"$",
"version",
",",
"0",
",",
"0",
")",
";",
"}",
"// Set major, minor and patch version",
"$",
"this",
"->",
"majorVersion",
"=",
"(",
"int",
")",
"isset",
"(",
"$",
"version",
"[",
"0",
"]",
")",
"?",
"$",
"version",
"[",
"0",
"]",
":",
"0",
";",
"$",
"this",
"->",
"minorVersion",
"=",
"(",
"int",
")",
"isset",
"(",
"$",
"version",
"[",
"1",
"]",
")",
"?",
"$",
"version",
"[",
"1",
"]",
":",
"0",
";",
"$",
"this",
"->",
"patchVersion",
"=",
"(",
"int",
")",
"isset",
"(",
"$",
"version",
"[",
"2",
"]",
")",
"?",
"$",
"version",
"[",
"2",
"]",
":",
"0",
";",
"return",
"$",
"this",
";",
"}"
] | Set version.
@author Morten Rugaard <[email protected]>
@param string $version
@return $this | [
"Set",
"version",
"."
] | fc788bb3e9668872573838099f868ab162eb8a96 | https://github.com/nodes-php/core/blob/fc788bb3e9668872573838099f868ab162eb8a96/src/Support/UserAgent/Agents/Nodes.php#L132-L149 |
10,790 | indigophp-archive/guardian | src/RequestAuth.php | RequestAuth.authenticate | public function authenticate(array $subject)
{
$caller = $this->identifier->identify($subject);
return $this->authenticator->authenticate($subject, $caller);
} | php | public function authenticate(array $subject)
{
$caller = $this->identifier->identify($subject);
return $this->authenticator->authenticate($subject, $caller);
} | [
"public",
"function",
"authenticate",
"(",
"array",
"$",
"subject",
")",
"{",
"$",
"caller",
"=",
"$",
"this",
"->",
"identifier",
"->",
"identify",
"(",
"$",
"subject",
")",
";",
"return",
"$",
"this",
"->",
"authenticator",
"->",
"authenticate",
"(",
"$",
"subject",
",",
"$",
"caller",
")",
";",
"}"
] | Authenticates a subject
@param array $subject | [
"Authenticates",
"a",
"subject"
] | 244b1c3be1cc3da428c9dea03e80f9d74593830a | https://github.com/indigophp-archive/guardian/blob/244b1c3be1cc3da428c9dea03e80f9d74593830a/src/RequestAuth.php#L48-L53 |
10,791 | samurai-fw/samurai | src/Raikiri/Container.php | Container.import | public function import($dicon)
{
$defines = $this->get('yaml')->load($dicon);
foreach ($defines as $name => $def) {
$define = $this->getComponentDefine($def);
$this->register($name, $define);
}
} | php | public function import($dicon)
{
$defines = $this->get('yaml')->load($dicon);
foreach ($defines as $name => $def) {
$define = $this->getComponentDefine($def);
$this->register($name, $define);
}
} | [
"public",
"function",
"import",
"(",
"$",
"dicon",
")",
"{",
"$",
"defines",
"=",
"$",
"this",
"->",
"get",
"(",
"'yaml'",
")",
"->",
"load",
"(",
"$",
"dicon",
")",
";",
"foreach",
"(",
"$",
"defines",
"as",
"$",
"name",
"=>",
"$",
"def",
")",
"{",
"$",
"define",
"=",
"$",
"this",
"->",
"getComponentDefine",
"(",
"$",
"def",
")",
";",
"$",
"this",
"->",
"register",
"(",
"$",
"name",
",",
"$",
"define",
")",
";",
"}",
"}"
] | import dicon file.
@param string $dicon | [
"import",
"dicon",
"file",
"."
] | 7ca3847b13f86e2847a17ab5e8e4e20893021d5a | https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Raikiri/Container.php#L90-L97 |
10,792 | samurai-fw/samurai | src/Raikiri/Container.php | Container.register | public function register($name, $component)
{
// Closure
if ($component instanceof \Closure) {
$component = new ComponentDefine($component);
}
if ($component instanceof ComponentDefine) {
$component->setContainer($this);
}
elseif (method_exists($component, 'raikiri') && ! $component instanceof ProphecySubjectInterface) {
$component->setContainer($this);
}
$this->components[$name] = $component;
} | php | public function register($name, $component)
{
// Closure
if ($component instanceof \Closure) {
$component = new ComponentDefine($component);
}
if ($component instanceof ComponentDefine) {
$component->setContainer($this);
}
elseif (method_exists($component, 'raikiri') && ! $component instanceof ProphecySubjectInterface) {
$component->setContainer($this);
}
$this->components[$name] = $component;
} | [
"public",
"function",
"register",
"(",
"$",
"name",
",",
"$",
"component",
")",
"{",
"// Closure",
"if",
"(",
"$",
"component",
"instanceof",
"\\",
"Closure",
")",
"{",
"$",
"component",
"=",
"new",
"ComponentDefine",
"(",
"$",
"component",
")",
";",
"}",
"if",
"(",
"$",
"component",
"instanceof",
"ComponentDefine",
")",
"{",
"$",
"component",
"->",
"setContainer",
"(",
"$",
"this",
")",
";",
"}",
"elseif",
"(",
"method_exists",
"(",
"$",
"component",
",",
"'raikiri'",
")",
"&&",
"!",
"$",
"component",
"instanceof",
"ProphecySubjectInterface",
")",
"{",
"$",
"component",
"->",
"setContainer",
"(",
"$",
"this",
")",
";",
"}",
"$",
"this",
"->",
"components",
"[",
"$",
"name",
"]",
"=",
"$",
"component",
";",
"}"
] | register component to container.
@param string $name
@param object $component | [
"register",
"component",
"to",
"container",
"."
] | 7ca3847b13f86e2847a17ab5e8e4e20893021d5a | https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Raikiri/Container.php#L118-L133 |
10,793 | samurai-fw/samurai | src/Raikiri/Container.php | Container.getComponentDefine | public function getComponentDefine($setting = array())
{
if (is_string($setting)) {
$setting = array('class' => $setting);
}
$define = new ComponentDefine($setting);
return $define;
} | php | public function getComponentDefine($setting = array())
{
if (is_string($setting)) {
$setting = array('class' => $setting);
}
$define = new ComponentDefine($setting);
return $define;
} | [
"public",
"function",
"getComponentDefine",
"(",
"$",
"setting",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"setting",
")",
")",
"{",
"$",
"setting",
"=",
"array",
"(",
"'class'",
"=>",
"$",
"setting",
")",
";",
"}",
"$",
"define",
"=",
"new",
"ComponentDefine",
"(",
"$",
"setting",
")",
";",
"return",
"$",
"define",
";",
"}"
] | get define instance
@param mixed $setting
@return Samurai\Raikiri\ComponentDefine | [
"get",
"define",
"instance"
] | 7ca3847b13f86e2847a17ab5e8e4e20893021d5a | https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Raikiri/Container.php#L195-L202 |
10,794 | samurai-fw/samurai | src/Raikiri/Container.php | Container.injectDependency | public function injectDependency($component)
{
$nullFilter = function($var) {
return $var === null;
};
$members = array_keys(array_filter(get_object_vars($component), $nullFilter));
$names = array_keys($this->components);
$members = array_intersect($members, $names);
foreach ($members as $key) {
$component->$key = $this->get($key);
}
} | php | public function injectDependency($component)
{
$nullFilter = function($var) {
return $var === null;
};
$members = array_keys(array_filter(get_object_vars($component), $nullFilter));
$names = array_keys($this->components);
$members = array_intersect($members, $names);
foreach ($members as $key) {
$component->$key = $this->get($key);
}
} | [
"public",
"function",
"injectDependency",
"(",
"$",
"component",
")",
"{",
"$",
"nullFilter",
"=",
"function",
"(",
"$",
"var",
")",
"{",
"return",
"$",
"var",
"===",
"null",
";",
"}",
";",
"$",
"members",
"=",
"array_keys",
"(",
"array_filter",
"(",
"get_object_vars",
"(",
"$",
"component",
")",
",",
"$",
"nullFilter",
")",
")",
";",
"$",
"names",
"=",
"array_keys",
"(",
"$",
"this",
"->",
"components",
")",
";",
"$",
"members",
"=",
"array_intersect",
"(",
"$",
"members",
",",
"$",
"names",
")",
";",
"foreach",
"(",
"$",
"members",
"as",
"$",
"key",
")",
"{",
"$",
"component",
"->",
"$",
"key",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"key",
")",
";",
"}",
"}"
] | Inject dependency to component
@param object $component | [
"Inject",
"dependency",
"to",
"component"
] | 7ca3847b13f86e2847a17ab5e8e4e20893021d5a | https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Raikiri/Container.php#L210-L221 |
10,795 | samurai-fw/samurai | src/Raikiri/Container.php | Container.inherit | public function inherit(Container $parent)
{
foreach ($parent->getAll() as $name => $component) {
if (! $this->has($name)) {
$this->register($name, $component);
}
}
return $this;
} | php | public function inherit(Container $parent)
{
foreach ($parent->getAll() as $name => $component) {
if (! $this->has($name)) {
$this->register($name, $component);
}
}
return $this;
} | [
"public",
"function",
"inherit",
"(",
"Container",
"$",
"parent",
")",
"{",
"foreach",
"(",
"$",
"parent",
"->",
"getAll",
"(",
")",
"as",
"$",
"name",
"=>",
"$",
"component",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"has",
"(",
"$",
"name",
")",
")",
"{",
"$",
"this",
"->",
"register",
"(",
"$",
"name",
",",
"$",
"component",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] | inherit other container
@param Samurai\Raikiri\Container $parent | [
"inherit",
"other",
"container"
] | 7ca3847b13f86e2847a17ab5e8e4e20893021d5a | https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Raikiri/Container.php#L228-L236 |
10,796 | aloframework/log | src/class/Config.php | Config.checkSavePath | private static function checkSavePath($path) {
if (is_string($path)) {
$dir = dirname($path);
return file_exists($dir) && is_writeable($dir);
} elseif (is_resource($path)) {
return true;
}
return false;
} | php | private static function checkSavePath($path) {
if (is_string($path)) {
$dir = dirname($path);
return file_exists($dir) && is_writeable($dir);
} elseif (is_resource($path)) {
return true;
}
return false;
} | [
"private",
"static",
"function",
"checkSavePath",
"(",
"$",
"path",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"path",
")",
")",
"{",
"$",
"dir",
"=",
"dirname",
"(",
"$",
"path",
")",
";",
"return",
"file_exists",
"(",
"$",
"dir",
")",
"&&",
"is_writeable",
"(",
"$",
"dir",
")",
";",
"}",
"elseif",
"(",
"is_resource",
"(",
"$",
"path",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Checks if the log save path is acceptable
@author Art <[email protected]>
@param mixed $path The log save path
@return bool | [
"Checks",
"if",
"the",
"log",
"save",
"path",
"is",
"acceptable"
] | 0743f818275b7a17d6f21343bf53dad44156b7f2 | https://github.com/aloframework/log/blob/0743f818275b7a17d6f21343bf53dad44156b7f2/src/class/Config.php#L161-L171 |
10,797 | Talesoft/tale-stream | src/Stream/Iterator/ReadIterator.php | ReadIterator.getIterator | public function getIterator(): \Generator
{
while (!$this->stream->eof()) {
$item = $this->stream->read($this->chunkSize);
// @codeCoverageIgnoreStart
//I don't know how to fabricate this manually, so I can't test it.
if ($item === '') {
continue;
}
// @codeCoverageIgnoreEnd
yield $item;
}
} | php | public function getIterator(): \Generator
{
while (!$this->stream->eof()) {
$item = $this->stream->read($this->chunkSize);
// @codeCoverageIgnoreStart
//I don't know how to fabricate this manually, so I can't test it.
if ($item === '') {
continue;
}
// @codeCoverageIgnoreEnd
yield $item;
}
} | [
"public",
"function",
"getIterator",
"(",
")",
":",
"\\",
"Generator",
"{",
"while",
"(",
"!",
"$",
"this",
"->",
"stream",
"->",
"eof",
"(",
")",
")",
"{",
"$",
"item",
"=",
"$",
"this",
"->",
"stream",
"->",
"read",
"(",
"$",
"this",
"->",
"chunkSize",
")",
";",
"// @codeCoverageIgnoreStart",
"//I don't know how to fabricate this manually, so I can't test it.",
"if",
"(",
"$",
"item",
"===",
"''",
")",
"{",
"continue",
";",
"}",
"// @codeCoverageIgnoreEnd",
"yield",
"$",
"item",
";",
"}",
"}"
] | Generates chunks based on the passed chunk size through reading from the stream.
@return \Generator | [
"Generates",
"chunks",
"based",
"on",
"the",
"passed",
"chunk",
"size",
"through",
"reading",
"from",
"the",
"stream",
"."
] | 13cdaa8cbc2daf833af98c67bf14121ea18c80aa | https://github.com/Talesoft/tale-stream/blob/13cdaa8cbc2daf833af98c67bf14121ea18c80aa/src/Stream/Iterator/ReadIterator.php#L79-L91 |
10,798 | donghaichen/session | src/Session.php | Session.flash | public function flash()
{
if($this->flashdata === null)
{
$this->flashdata = new Flash(isset($_SESSION[$this->flashslot]) ? $_SESSION[$this->flashslot] : array());
}
return $this->flashdata;
} | php | public function flash()
{
if($this->flashdata === null)
{
$this->flashdata = new Flash(isset($_SESSION[$this->flashslot]) ? $_SESSION[$this->flashslot] : array());
}
return $this->flashdata;
} | [
"public",
"function",
"flash",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"flashdata",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"flashdata",
"=",
"new",
"Flash",
"(",
"isset",
"(",
"$",
"_SESSION",
"[",
"$",
"this",
"->",
"flashslot",
"]",
")",
"?",
"$",
"_SESSION",
"[",
"$",
"this",
"->",
"flashslot",
"]",
":",
"array",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"flashdata",
";",
"}"
] | Access flash object.
@access public
@return \Clovers\Session\Flash | [
"Access",
"flash",
"object",
"."
] | 704e506f06fdc9641f80ebde60e092027447624f | https://github.com/donghaichen/session/blob/704e506f06fdc9641f80ebde60e092027447624f/src/Session.php#L189-L197 |
10,799 | AlphaLabs/Pagination | src/Provider/PaginatedCollectionRequestProvider.php | PaginatedCollectionRequestProvider.validatePaginatedCollectionRequest | private function validatePaginatedCollectionRequest(PaginatedCollectionRequestInterface $paginationInfo)
{
if (!(ctype_digit((string)$paginationInfo->getPage()) && 0 <= (int)$paginationInfo->getPage())) {
throw new \InvalidArgumentException('Page must be a positive integer');
}
if (!(ctype_digit((string)$paginationInfo->getItemsPerPage()) && 0 <= (int)$paginationInfo->getItemsPerPage())) {
throw new \InvalidArgumentException('Items per page must be a positive integer');
}
} | php | private function validatePaginatedCollectionRequest(PaginatedCollectionRequestInterface $paginationInfo)
{
if (!(ctype_digit((string)$paginationInfo->getPage()) && 0 <= (int)$paginationInfo->getPage())) {
throw new \InvalidArgumentException('Page must be a positive integer');
}
if (!(ctype_digit((string)$paginationInfo->getItemsPerPage()) && 0 <= (int)$paginationInfo->getItemsPerPage())) {
throw new \InvalidArgumentException('Items per page must be a positive integer');
}
} | [
"private",
"function",
"validatePaginatedCollectionRequest",
"(",
"PaginatedCollectionRequestInterface",
"$",
"paginationInfo",
")",
"{",
"if",
"(",
"!",
"(",
"ctype_digit",
"(",
"(",
"string",
")",
"$",
"paginationInfo",
"->",
"getPage",
"(",
")",
")",
"&&",
"0",
"<=",
"(",
"int",
")",
"$",
"paginationInfo",
"->",
"getPage",
"(",
")",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Page must be a positive integer'",
")",
";",
"}",
"if",
"(",
"!",
"(",
"ctype_digit",
"(",
"(",
"string",
")",
"$",
"paginationInfo",
"->",
"getItemsPerPage",
"(",
")",
")",
"&&",
"0",
"<=",
"(",
"int",
")",
"$",
"paginationInfo",
"->",
"getItemsPerPage",
"(",
")",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Items per page must be a positive integer'",
")",
";",
"}",
"}"
] | Checks the pagination request validity
@param PaginatedCollectionRequestInterface $paginationInfo
@throws \InvalidArgumentException | [
"Checks",
"the",
"pagination",
"request",
"validity"
] | 7c5d10b6cab3827397689a0e7a98ecc2da26152f | https://github.com/AlphaLabs/Pagination/blob/7c5d10b6cab3827397689a0e7a98ecc2da26152f/src/Provider/PaginatedCollectionRequestProvider.php#L67-L76 |
Subsets and Splits