id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
list | docstring
stringlengths 3
47.2k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 91
247
|
|---|---|---|---|---|---|---|---|---|---|---|---|
235,200
|
makinacorpus/drupal-ucms
|
ucms_seo/src/Path/AliasManager.php
|
AliasManager.computePathAlias
|
public function computePathAlias($nodeId, $siteId)
{
$nodeIdList = [];
$menuId = $this->treeProvider->findTreeForNode($nodeId, ['site_id' => $siteId]);
if ($menuId) {
// Load the tree, with no access checks, else some parents might
// be hidden from it and the resulting path would be a failure.
$tree = $this->treeProvider->buildTree($menuId, false);
$trail = $tree->getMostRevelantTrailForNode($nodeId);
if ($trail) {
foreach ($trail as $item) {
$nodeIdList[] = $item->getNodeId();
}
} else {
// This should not happen, but it still can be possible
$nodeIdList[] = $nodeId;
}
} else {
$nodeIdList[] = $nodeId;
}
// And now, query all at once.
$segments = $this
->database
->query(
"SELECT nid, alias_segment FROM {ucms_seo_node} WHERE nid IN (:nodes)",
[':nodes' => $nodeIdList]
)
->fetchAllKeyed()
;
// This rather unperforming, but it will only act on very small
// arrays, so I guess that for now, this is enough.
$pieces = [];
foreach ($nodeIdList as $nodeId) {
if (isset($segments[$nodeId])) {
$pieces[] = $segments[$nodeId];
}
}
// This is probably not supposed to happen, but it might
if (!$pieces) {
return null;
}
return implode('/', $pieces);
}
|
php
|
public function computePathAlias($nodeId, $siteId)
{
$nodeIdList = [];
$menuId = $this->treeProvider->findTreeForNode($nodeId, ['site_id' => $siteId]);
if ($menuId) {
// Load the tree, with no access checks, else some parents might
// be hidden from it and the resulting path would be a failure.
$tree = $this->treeProvider->buildTree($menuId, false);
$trail = $tree->getMostRevelantTrailForNode($nodeId);
if ($trail) {
foreach ($trail as $item) {
$nodeIdList[] = $item->getNodeId();
}
} else {
// This should not happen, but it still can be possible
$nodeIdList[] = $nodeId;
}
} else {
$nodeIdList[] = $nodeId;
}
// And now, query all at once.
$segments = $this
->database
->query(
"SELECT nid, alias_segment FROM {ucms_seo_node} WHERE nid IN (:nodes)",
[':nodes' => $nodeIdList]
)
->fetchAllKeyed()
;
// This rather unperforming, but it will only act on very small
// arrays, so I guess that for now, this is enough.
$pieces = [];
foreach ($nodeIdList as $nodeId) {
if (isset($segments[$nodeId])) {
$pieces[] = $segments[$nodeId];
}
}
// This is probably not supposed to happen, but it might
if (!$pieces) {
return null;
}
return implode('/', $pieces);
}
|
[
"public",
"function",
"computePathAlias",
"(",
"$",
"nodeId",
",",
"$",
"siteId",
")",
"{",
"$",
"nodeIdList",
"=",
"[",
"]",
";",
"$",
"menuId",
"=",
"$",
"this",
"->",
"treeProvider",
"->",
"findTreeForNode",
"(",
"$",
"nodeId",
",",
"[",
"'site_id'",
"=>",
"$",
"siteId",
"]",
")",
";",
"if",
"(",
"$",
"menuId",
")",
"{",
"// Load the tree, with no access checks, else some parents might",
"// be hidden from it and the resulting path would be a failure.",
"$",
"tree",
"=",
"$",
"this",
"->",
"treeProvider",
"->",
"buildTree",
"(",
"$",
"menuId",
",",
"false",
")",
";",
"$",
"trail",
"=",
"$",
"tree",
"->",
"getMostRevelantTrailForNode",
"(",
"$",
"nodeId",
")",
";",
"if",
"(",
"$",
"trail",
")",
"{",
"foreach",
"(",
"$",
"trail",
"as",
"$",
"item",
")",
"{",
"$",
"nodeIdList",
"[",
"]",
"=",
"$",
"item",
"->",
"getNodeId",
"(",
")",
";",
"}",
"}",
"else",
"{",
"// This should not happen, but it still can be possible",
"$",
"nodeIdList",
"[",
"]",
"=",
"$",
"nodeId",
";",
"}",
"}",
"else",
"{",
"$",
"nodeIdList",
"[",
"]",
"=",
"$",
"nodeId",
";",
"}",
"// And now, query all at once.",
"$",
"segments",
"=",
"$",
"this",
"->",
"database",
"->",
"query",
"(",
"\"SELECT nid, alias_segment FROM {ucms_seo_node} WHERE nid IN (:nodes)\"",
",",
"[",
"':nodes'",
"=>",
"$",
"nodeIdList",
"]",
")",
"->",
"fetchAllKeyed",
"(",
")",
";",
"// This rather unperforming, but it will only act on very small",
"// arrays, so I guess that for now, this is enough.",
"$",
"pieces",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"nodeIdList",
"as",
"$",
"nodeId",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"segments",
"[",
"$",
"nodeId",
"]",
")",
")",
"{",
"$",
"pieces",
"[",
"]",
"=",
"$",
"segments",
"[",
"$",
"nodeId",
"]",
";",
"}",
"}",
"// This is probably not supposed to happen, but it might",
"if",
"(",
"!",
"$",
"pieces",
")",
"{",
"return",
"null",
";",
"}",
"return",
"implode",
"(",
"'/'",
",",
"$",
"pieces",
")",
";",
"}"
] |
Compute alias for node on site
@todo this algorithm does up to 3 sql queries, one for finding the
correct menu tree, another for loading it, and the third to lookup
the segments, a better approach would be to merge this code in umenu
itself, buy adding the 'segment' column in the menu, with a unique
constraint on (parent_id, segment).
@param int $nodeId
@param int $siteId
@return null|string
|
[
"Compute",
"alias",
"for",
"node",
"on",
"site"
] |
6b8a84305472d2cad816102672f10274b3bbb535
|
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_seo/src/Path/AliasManager.php#L62-L109
|
235,201
|
makinacorpus/drupal-ucms
|
ucms_seo/src/Path/AliasManager.php
|
AliasManager.deduplicate
|
private function deduplicate($nodeId, $siteId, $alias)
{
$dupFound = false;
$current = $alias;
$increment = 0;
do {
$dupFound = (bool)$this
->database
->query(
"SELECT 1 FROM {ucms_seo_route} WHERE route = :route AND site_id = :site",
[':route' => $current, ':site' => $siteId]
)
->fetchField()
;
if ($dupFound) {
$current = $alias . '-' . ($increment++);
}
} while ($dupFound);
return $current;
}
|
php
|
private function deduplicate($nodeId, $siteId, $alias)
{
$dupFound = false;
$current = $alias;
$increment = 0;
do {
$dupFound = (bool)$this
->database
->query(
"SELECT 1 FROM {ucms_seo_route} WHERE route = :route AND site_id = :site",
[':route' => $current, ':site' => $siteId]
)
->fetchField()
;
if ($dupFound) {
$current = $alias . '-' . ($increment++);
}
} while ($dupFound);
return $current;
}
|
[
"private",
"function",
"deduplicate",
"(",
"$",
"nodeId",
",",
"$",
"siteId",
",",
"$",
"alias",
")",
"{",
"$",
"dupFound",
"=",
"false",
";",
"$",
"current",
"=",
"$",
"alias",
";",
"$",
"increment",
"=",
"0",
";",
"do",
"{",
"$",
"dupFound",
"=",
"(",
"bool",
")",
"$",
"this",
"->",
"database",
"->",
"query",
"(",
"\"SELECT 1 FROM {ucms_seo_route} WHERE route = :route AND site_id = :site\"",
",",
"[",
"':route'",
"=>",
"$",
"current",
",",
"':site'",
"=>",
"$",
"siteId",
"]",
")",
"->",
"fetchField",
"(",
")",
";",
"if",
"(",
"$",
"dupFound",
")",
"{",
"$",
"current",
"=",
"$",
"alias",
".",
"'-'",
".",
"(",
"$",
"increment",
"++",
")",
";",
"}",
"}",
"while",
"(",
"$",
"dupFound",
")",
";",
"return",
"$",
"current",
";",
"}"
] |
Deduplicate alias if one or more already exsist
@param int $nodeId
@param int $siteId
@param string $alias
@return string
|
[
"Deduplicate",
"alias",
"if",
"one",
"or",
"more",
"already",
"exsist"
] |
6b8a84305472d2cad816102672f10274b3bbb535
|
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_seo/src/Path/AliasManager.php#L120-L143
|
235,202
|
makinacorpus/drupal-ucms
|
ucms_seo/src/Path/AliasManager.php
|
AliasManager.computeAndStorePathAlias
|
private function computeAndStorePathAlias($nodeId, $siteId, $outdated = null)
{
$transaction = null;
try {
$transaction = $this->database->startTransaction();
$computed = $this->computePathAlias($nodeId, $siteId);
// In all cases, delete outdated item if exists and backup
// it into the {ucms_seo_redirect} table with an expire. Not
// for self, and for all people still using MySQL, RETURNING
// clause would have been great here.
$this
->database
->query(
"DELETE FROM {ucms_seo_route} WHERE node_id = :node AND site_id = :site",
[':node' => $nodeId, ':site' => $siteId]
)
;
// @todo ucms_seo_redirect does not handle duplicates at all
// and will let you insert pretty much everything, we'll see
// later for this; but this is bad, we cannot deduplicate what
// are old sites urls and expired urls from us
if ($outdated) {
$this
->database
->insert('ucms_seo_redirect')
->fields([
'nid' => $nodeId,
'site_id' => $siteId,
'path' => '/' . $outdated,
'expires' => (new \DateTime(self::DEFAULT_EXPIRE))->format('Y-m-d H:i:s'),
])
->execute()
;
}
if ($computed) {
$computed = $this->deduplicate($nodeId, $siteId, $computed);
$this
->database
->insert('ucms_seo_route')
->fields([
'node_id' => $nodeId,
'site_id' => $siteId,
'route' => $computed,
'is_protected' => 0,
'is_outdated' => 0,
])
->execute()
;
}
// Explicit commit
unset($transaction);
return $computed;
} catch (\PDOException $e) {
try {
if ($transaction) {
$transaction->rollback();
}
} catch (\Exception $e2) {
// You are fucked.
watchdog_exception(__FUNCTION__, $e2);
}
throw $e;
}
}
|
php
|
private function computeAndStorePathAlias($nodeId, $siteId, $outdated = null)
{
$transaction = null;
try {
$transaction = $this->database->startTransaction();
$computed = $this->computePathAlias($nodeId, $siteId);
// In all cases, delete outdated item if exists and backup
// it into the {ucms_seo_redirect} table with an expire. Not
// for self, and for all people still using MySQL, RETURNING
// clause would have been great here.
$this
->database
->query(
"DELETE FROM {ucms_seo_route} WHERE node_id = :node AND site_id = :site",
[':node' => $nodeId, ':site' => $siteId]
)
;
// @todo ucms_seo_redirect does not handle duplicates at all
// and will let you insert pretty much everything, we'll see
// later for this; but this is bad, we cannot deduplicate what
// are old sites urls and expired urls from us
if ($outdated) {
$this
->database
->insert('ucms_seo_redirect')
->fields([
'nid' => $nodeId,
'site_id' => $siteId,
'path' => '/' . $outdated,
'expires' => (new \DateTime(self::DEFAULT_EXPIRE))->format('Y-m-d H:i:s'),
])
->execute()
;
}
if ($computed) {
$computed = $this->deduplicate($nodeId, $siteId, $computed);
$this
->database
->insert('ucms_seo_route')
->fields([
'node_id' => $nodeId,
'site_id' => $siteId,
'route' => $computed,
'is_protected' => 0,
'is_outdated' => 0,
])
->execute()
;
}
// Explicit commit
unset($transaction);
return $computed;
} catch (\PDOException $e) {
try {
if ($transaction) {
$transaction->rollback();
}
} catch (\Exception $e2) {
// You are fucked.
watchdog_exception(__FUNCTION__, $e2);
}
throw $e;
}
}
|
[
"private",
"function",
"computeAndStorePathAlias",
"(",
"$",
"nodeId",
",",
"$",
"siteId",
",",
"$",
"outdated",
"=",
"null",
")",
"{",
"$",
"transaction",
"=",
"null",
";",
"try",
"{",
"$",
"transaction",
"=",
"$",
"this",
"->",
"database",
"->",
"startTransaction",
"(",
")",
";",
"$",
"computed",
"=",
"$",
"this",
"->",
"computePathAlias",
"(",
"$",
"nodeId",
",",
"$",
"siteId",
")",
";",
"// In all cases, delete outdated item if exists and backup",
"// it into the {ucms_seo_redirect} table with an expire. Not",
"// for self, and for all people still using MySQL, RETURNING",
"// clause would have been great here.",
"$",
"this",
"->",
"database",
"->",
"query",
"(",
"\"DELETE FROM {ucms_seo_route} WHERE node_id = :node AND site_id = :site\"",
",",
"[",
"':node'",
"=>",
"$",
"nodeId",
",",
"':site'",
"=>",
"$",
"siteId",
"]",
")",
";",
"// @todo ucms_seo_redirect does not handle duplicates at all",
"// and will let you insert pretty much everything, we'll see",
"// later for this; but this is bad, we cannot deduplicate what",
"// are old sites urls and expired urls from us",
"if",
"(",
"$",
"outdated",
")",
"{",
"$",
"this",
"->",
"database",
"->",
"insert",
"(",
"'ucms_seo_redirect'",
")",
"->",
"fields",
"(",
"[",
"'nid'",
"=>",
"$",
"nodeId",
",",
"'site_id'",
"=>",
"$",
"siteId",
",",
"'path'",
"=>",
"'/'",
".",
"$",
"outdated",
",",
"'expires'",
"=>",
"(",
"new",
"\\",
"DateTime",
"(",
"self",
"::",
"DEFAULT_EXPIRE",
")",
")",
"->",
"format",
"(",
"'Y-m-d H:i:s'",
")",
",",
"]",
")",
"->",
"execute",
"(",
")",
";",
"}",
"if",
"(",
"$",
"computed",
")",
"{",
"$",
"computed",
"=",
"$",
"this",
"->",
"deduplicate",
"(",
"$",
"nodeId",
",",
"$",
"siteId",
",",
"$",
"computed",
")",
";",
"$",
"this",
"->",
"database",
"->",
"insert",
"(",
"'ucms_seo_route'",
")",
"->",
"fields",
"(",
"[",
"'node_id'",
"=>",
"$",
"nodeId",
",",
"'site_id'",
"=>",
"$",
"siteId",
",",
"'route'",
"=>",
"$",
"computed",
",",
"'is_protected'",
"=>",
"0",
",",
"'is_outdated'",
"=>",
"0",
",",
"]",
")",
"->",
"execute",
"(",
")",
";",
"}",
"// Explicit commit",
"unset",
"(",
"$",
"transaction",
")",
";",
"return",
"$",
"computed",
";",
"}",
"catch",
"(",
"\\",
"PDOException",
"$",
"e",
")",
"{",
"try",
"{",
"if",
"(",
"$",
"transaction",
")",
"{",
"$",
"transaction",
"->",
"rollback",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e2",
")",
"{",
"// You are fucked.",
"watchdog_exception",
"(",
"__FUNCTION__",
",",
"$",
"e2",
")",
";",
"}",
"throw",
"$",
"e",
";",
"}",
"}"
] |
Store given node alias in given site
@param int $nodeId
@param int $siteId
@param string $outdated
Outdated route if exists
@return string
|
[
"Store",
"given",
"node",
"alias",
"in",
"given",
"site"
] |
6b8a84305472d2cad816102672f10274b3bbb535
|
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_seo/src/Path/AliasManager.php#L155-L227
|
235,203
|
makinacorpus/drupal-ucms
|
ucms_seo/src/Path/AliasManager.php
|
AliasManager.invalidate
|
public function invalidate(array $conditions)
{
if (empty($conditions)) {
throw new \InvalidArgumentException("cannot invalidate aliases with no conditions");
}
$query = $this
->database
->update('ucms_seo_route')
->fields(['is_outdated' => 1])
->condition('is_protected', 0)
;
foreach ($conditions as $key => $value) {
switch ($key) {
case 'node_id':
$query->condition('node_id', $value);
break;
case 'site_id':
$query->condition('site_id', $value);
break;
default:
throw new \InvalidArgumentException(sprintf("condition '%s' is not supported for aliases invalidation", $key));
}
}
$query->execute();
}
|
php
|
public function invalidate(array $conditions)
{
if (empty($conditions)) {
throw new \InvalidArgumentException("cannot invalidate aliases with no conditions");
}
$query = $this
->database
->update('ucms_seo_route')
->fields(['is_outdated' => 1])
->condition('is_protected', 0)
;
foreach ($conditions as $key => $value) {
switch ($key) {
case 'node_id':
$query->condition('node_id', $value);
break;
case 'site_id':
$query->condition('site_id', $value);
break;
default:
throw new \InvalidArgumentException(sprintf("condition '%s' is not supported for aliases invalidation", $key));
}
}
$query->execute();
}
|
[
"public",
"function",
"invalidate",
"(",
"array",
"$",
"conditions",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"conditions",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"cannot invalidate aliases with no conditions\"",
")",
";",
"}",
"$",
"query",
"=",
"$",
"this",
"->",
"database",
"->",
"update",
"(",
"'ucms_seo_route'",
")",
"->",
"fields",
"(",
"[",
"'is_outdated'",
"=>",
"1",
"]",
")",
"->",
"condition",
"(",
"'is_protected'",
",",
"0",
")",
";",
"foreach",
"(",
"$",
"conditions",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"switch",
"(",
"$",
"key",
")",
"{",
"case",
"'node_id'",
":",
"$",
"query",
"->",
"condition",
"(",
"'node_id'",
",",
"$",
"value",
")",
";",
"break",
";",
"case",
"'site_id'",
":",
"$",
"query",
"->",
"condition",
"(",
"'site_id'",
",",
"$",
"value",
")",
";",
"break",
";",
"default",
":",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"\"condition '%s' is not supported for aliases invalidation\"",
",",
"$",
"key",
")",
")",
";",
"}",
"}",
"$",
"query",
"->",
"execute",
"(",
")",
";",
"}"
] |
Invalidate aliases with the given conditions
@param array $conditions
Keys are column names, values are either single value or an array of
value to match to invalidate; allowed keys are:
- node_id: one or more node identifiers
- site_id: one or more site identifiers
|
[
"Invalidate",
"aliases",
"with",
"the",
"given",
"conditions"
] |
6b8a84305472d2cad816102672f10274b3bbb535
|
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_seo/src/Path/AliasManager.php#L238-L268
|
235,204
|
makinacorpus/drupal-ucms
|
ucms_seo/src/Path/AliasManager.php
|
AliasManager.invalidateRelated
|
public function invalidateRelated($nodeIdList)
{
if (!$nodeIdList) {
return;
}
$this
->database
->query("
UPDATE {ucms_seo_route}
SET
is_outdated = 1
WHERE
is_outdated = 0
AND is_protected = 0
AND menu_id IS NOT NULL
AND menu_id IN (
SELECT
DISTINCT(i.menu_id)
FROM {umenu_item} i
WHERE
i.node_id IN (:nodeIdList)
)
", [':nodeIdList' => $nodeIdList])
;
// This is sad, but when data is not consistent and menu identifier
// is not set, we must wipe out the complete site cache instead, but
// hopefully, it won't happen again once we'll have fixed the item
// insertion.
$this
->database
->query("
UPDATE {ucms_seo_route}
SET
is_outdated = 1
WHERE
is_outdated = 0
AND is_protected = 0
AND menu_id IS NULL
AND site_id IN (
SELECT
DISTINCT(i.site_id)
FROM {umenu_item} i
WHERE
i.node_id IN (:nodeIdList)
)
", [':nodeIdList' => $nodeIdList])
;
}
|
php
|
public function invalidateRelated($nodeIdList)
{
if (!$nodeIdList) {
return;
}
$this
->database
->query("
UPDATE {ucms_seo_route}
SET
is_outdated = 1
WHERE
is_outdated = 0
AND is_protected = 0
AND menu_id IS NOT NULL
AND menu_id IN (
SELECT
DISTINCT(i.menu_id)
FROM {umenu_item} i
WHERE
i.node_id IN (:nodeIdList)
)
", [':nodeIdList' => $nodeIdList])
;
// This is sad, but when data is not consistent and menu identifier
// is not set, we must wipe out the complete site cache instead, but
// hopefully, it won't happen again once we'll have fixed the item
// insertion.
$this
->database
->query("
UPDATE {ucms_seo_route}
SET
is_outdated = 1
WHERE
is_outdated = 0
AND is_protected = 0
AND menu_id IS NULL
AND site_id IN (
SELECT
DISTINCT(i.site_id)
FROM {umenu_item} i
WHERE
i.node_id IN (:nodeIdList)
)
", [':nodeIdList' => $nodeIdList])
;
}
|
[
"public",
"function",
"invalidateRelated",
"(",
"$",
"nodeIdList",
")",
"{",
"if",
"(",
"!",
"$",
"nodeIdList",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"database",
"->",
"query",
"(",
"\"\n UPDATE {ucms_seo_route}\n SET\n is_outdated = 1\n WHERE\n is_outdated = 0\n AND is_protected = 0\n AND menu_id IS NOT NULL\n AND menu_id IN (\n SELECT\n DISTINCT(i.menu_id)\n FROM {umenu_item} i\n WHERE\n i.node_id IN (:nodeIdList)\n )\n \"",
",",
"[",
"':nodeIdList'",
"=>",
"$",
"nodeIdList",
"]",
")",
";",
"// This is sad, but when data is not consistent and menu identifier",
"// is not set, we must wipe out the complete site cache instead, but",
"// hopefully, it won't happen again once we'll have fixed the item",
"// insertion.",
"$",
"this",
"->",
"database",
"->",
"query",
"(",
"\"\n UPDATE {ucms_seo_route}\n SET\n is_outdated = 1\n WHERE\n is_outdated = 0\n AND is_protected = 0\n AND menu_id IS NULL\n AND site_id IN (\n SELECT\n DISTINCT(i.site_id)\n FROM {umenu_item} i\n WHERE\n i.node_id IN (:nodeIdList)\n )\n \"",
",",
"[",
"':nodeIdList'",
"=>",
"$",
"nodeIdList",
"]",
")",
";",
"}"
] |
Invalidate aliases related with the given node
@todo this will a few SQL indices
@param int[] $nodeIdList
|
[
"Invalidate",
"aliases",
"related",
"with",
"the",
"given",
"node"
] |
6b8a84305472d2cad816102672f10274b3bbb535
|
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_seo/src/Path/AliasManager.php#L277-L326
|
235,205
|
makinacorpus/drupal-ucms
|
ucms_seo/src/Path/AliasManager.php
|
AliasManager.setCustomAlias
|
public function setCustomAlias($nodeId, $siteId, $alias)
{
$this
->database
->merge('ucms_seo_route')
->key([
'node_id' => $nodeId,
'site_id' => $siteId,
])
->fields([
'route' => $alias,
'is_protected' => 1,
'is_outdated' => 0,
])
->execute()
;
}
|
php
|
public function setCustomAlias($nodeId, $siteId, $alias)
{
$this
->database
->merge('ucms_seo_route')
->key([
'node_id' => $nodeId,
'site_id' => $siteId,
])
->fields([
'route' => $alias,
'is_protected' => 1,
'is_outdated' => 0,
])
->execute()
;
}
|
[
"public",
"function",
"setCustomAlias",
"(",
"$",
"nodeId",
",",
"$",
"siteId",
",",
"$",
"alias",
")",
"{",
"$",
"this",
"->",
"database",
"->",
"merge",
"(",
"'ucms_seo_route'",
")",
"->",
"key",
"(",
"[",
"'node_id'",
"=>",
"$",
"nodeId",
",",
"'site_id'",
"=>",
"$",
"siteId",
",",
"]",
")",
"->",
"fields",
"(",
"[",
"'route'",
"=>",
"$",
"alias",
",",
"'is_protected'",
"=>",
"1",
",",
"'is_outdated'",
"=>",
"0",
",",
"]",
")",
"->",
"execute",
"(",
")",
";",
"}"
] |
Set custom alias for
@param int $nodeId
@param int $siteId
@param string $siteId
|
[
"Set",
"custom",
"alias",
"for"
] |
6b8a84305472d2cad816102672f10274b3bbb535
|
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_seo/src/Path/AliasManager.php#L335-L351
|
235,206
|
makinacorpus/drupal-ucms
|
ucms_seo/src/Path/AliasManager.php
|
AliasManager.removeCustomAlias
|
public function removeCustomAlias($nodeId, $siteId)
{
$this
->database
->update('ucms_seo_route')
->condition('node_id', $nodeId)
->condition('site_id', $siteId)
->fields(['is_protected' => 0, 'is_outdated' => 1])
->execute()
;
}
|
php
|
public function removeCustomAlias($nodeId, $siteId)
{
$this
->database
->update('ucms_seo_route')
->condition('node_id', $nodeId)
->condition('site_id', $siteId)
->fields(['is_protected' => 0, 'is_outdated' => 1])
->execute()
;
}
|
[
"public",
"function",
"removeCustomAlias",
"(",
"$",
"nodeId",
",",
"$",
"siteId",
")",
"{",
"$",
"this",
"->",
"database",
"->",
"update",
"(",
"'ucms_seo_route'",
")",
"->",
"condition",
"(",
"'node_id'",
",",
"$",
"nodeId",
")",
"->",
"condition",
"(",
"'site_id'",
",",
"$",
"siteId",
")",
"->",
"fields",
"(",
"[",
"'is_protected'",
"=>",
"0",
",",
"'is_outdated'",
"=>",
"1",
"]",
")",
"->",
"execute",
"(",
")",
";",
"}"
] |
Remove custom alias for
@param int $nodeId
@param int $siteId
|
[
"Remove",
"custom",
"alias",
"for"
] |
6b8a84305472d2cad816102672f10274b3bbb535
|
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_seo/src/Path/AliasManager.php#L359-L369
|
235,207
|
makinacorpus/drupal-ucms
|
ucms_seo/src/Path/AliasManager.php
|
AliasManager.getPathAlias
|
public function getPathAlias($nodeId, $siteId)
{
$route = $this
->database
->query(
"SELECT route, is_outdated FROM {ucms_seo_route} WHERE node_id = :node AND site_id = :site",
[':node' => $nodeId, ':site' => $siteId]
)
->fetch()
;
if (!$route || $route->is_outdated) {
return $this->computeAndStorePathAlias($nodeId, $siteId, ($route ? $route->route : null));
} else {
return $route->route;
}
}
|
php
|
public function getPathAlias($nodeId, $siteId)
{
$route = $this
->database
->query(
"SELECT route, is_outdated FROM {ucms_seo_route} WHERE node_id = :node AND site_id = :site",
[':node' => $nodeId, ':site' => $siteId]
)
->fetch()
;
if (!$route || $route->is_outdated) {
return $this->computeAndStorePathAlias($nodeId, $siteId, ($route ? $route->route : null));
} else {
return $route->route;
}
}
|
[
"public",
"function",
"getPathAlias",
"(",
"$",
"nodeId",
",",
"$",
"siteId",
")",
"{",
"$",
"route",
"=",
"$",
"this",
"->",
"database",
"->",
"query",
"(",
"\"SELECT route, is_outdated FROM {ucms_seo_route} WHERE node_id = :node AND site_id = :site\"",
",",
"[",
"':node'",
"=>",
"$",
"nodeId",
",",
"':site'",
"=>",
"$",
"siteId",
"]",
")",
"->",
"fetch",
"(",
")",
";",
"if",
"(",
"!",
"$",
"route",
"||",
"$",
"route",
"->",
"is_outdated",
")",
"{",
"return",
"$",
"this",
"->",
"computeAndStorePathAlias",
"(",
"$",
"nodeId",
",",
"$",
"siteId",
",",
"(",
"$",
"route",
"?",
"$",
"route",
"->",
"route",
":",
"null",
")",
")",
";",
"}",
"else",
"{",
"return",
"$",
"route",
"->",
"route",
";",
"}",
"}"
] |
Get alias for node on site
Internally, if no alias was already computed, this will recompute
and store it into a custom route match table.
@param int $nodeId
@param int $siteId
@return string
|
[
"Get",
"alias",
"for",
"node",
"on",
"site"
] |
6b8a84305472d2cad816102672f10274b3bbb535
|
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_seo/src/Path/AliasManager.php#L402-L418
|
235,208
|
makinacorpus/drupal-ucms
|
ucms_seo/src/Path/AliasManager.php
|
AliasManager.matchPath
|
public function matchPath($alias, $siteId)
{
$nodeId = $this
->database
->query(
"SELECT node_id FROM {ucms_seo_route} WHERE route = :route AND site_id = :site",
[':route' => $alias, ':site' => $siteId]
)
->fetchField()
;
return $nodeId ? ((int)$nodeId) : null;
}
|
php
|
public function matchPath($alias, $siteId)
{
$nodeId = $this
->database
->query(
"SELECT node_id FROM {ucms_seo_route} WHERE route = :route AND site_id = :site",
[':route' => $alias, ':site' => $siteId]
)
->fetchField()
;
return $nodeId ? ((int)$nodeId) : null;
}
|
[
"public",
"function",
"matchPath",
"(",
"$",
"alias",
",",
"$",
"siteId",
")",
"{",
"$",
"nodeId",
"=",
"$",
"this",
"->",
"database",
"->",
"query",
"(",
"\"SELECT node_id FROM {ucms_seo_route} WHERE route = :route AND site_id = :site\"",
",",
"[",
"':route'",
"=>",
"$",
"alias",
",",
"':site'",
"=>",
"$",
"siteId",
"]",
")",
"->",
"fetchField",
"(",
")",
";",
"return",
"$",
"nodeId",
"?",
"(",
"(",
"int",
")",
"$",
"nodeId",
")",
":",
"null",
";",
"}"
] |
Match path on given site
@todo this one will be *very* hard to compute without umenu taking
care of it for us;
@param string $alias
@param int $siteId
@return null|int
The node identifier if found
|
[
"Match",
"path",
"on",
"given",
"site"
] |
6b8a84305472d2cad816102672f10274b3bbb535
|
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_seo/src/Path/AliasManager.php#L432-L444
|
235,209
|
makinacorpus/drupal-ucms
|
ucms_site/src/Controller/AutocompleteController.php
|
AutocompleteController.userAutocompleteAction
|
public function userAutocompleteAction($string)
{
$manager = $this->getSiteManager();
$account = $this->getCurrentUser();
if (!$manager->getAccess()->userIsWebmaster($account) && !$this->isGranted(Access::PERM_USER_MANAGE_ALL)) {
throw $this->createAccessDeniedException();
}
$database = $this->getDatabaseConnection();
$q = $database
->select('users', 'u')
->fields('u', ['uid', 'name'])
->condition('u.name', '%' . $database->escapeLike($string) . '%', 'LIKE')
->condition('u.uid', [0, 1], 'NOT IN')
->orderBy('u.name', 'asc')
->range(0, 16)
->addTag('ucms_user_access')
;
$suggest = [];
foreach ($q->execute()->fetchAll() as $record) {
$key = $record->name . ' [' . $record->uid . ']';
$suggest[$key] = check_plain($record->name);
}
return new JsonResponse($suggest);
}
|
php
|
public function userAutocompleteAction($string)
{
$manager = $this->getSiteManager();
$account = $this->getCurrentUser();
if (!$manager->getAccess()->userIsWebmaster($account) && !$this->isGranted(Access::PERM_USER_MANAGE_ALL)) {
throw $this->createAccessDeniedException();
}
$database = $this->getDatabaseConnection();
$q = $database
->select('users', 'u')
->fields('u', ['uid', 'name'])
->condition('u.name', '%' . $database->escapeLike($string) . '%', 'LIKE')
->condition('u.uid', [0, 1], 'NOT IN')
->orderBy('u.name', 'asc')
->range(0, 16)
->addTag('ucms_user_access')
;
$suggest = [];
foreach ($q->execute()->fetchAll() as $record) {
$key = $record->name . ' [' . $record->uid . ']';
$suggest[$key] = check_plain($record->name);
}
return new JsonResponse($suggest);
}
|
[
"public",
"function",
"userAutocompleteAction",
"(",
"$",
"string",
")",
"{",
"$",
"manager",
"=",
"$",
"this",
"->",
"getSiteManager",
"(",
")",
";",
"$",
"account",
"=",
"$",
"this",
"->",
"getCurrentUser",
"(",
")",
";",
"if",
"(",
"!",
"$",
"manager",
"->",
"getAccess",
"(",
")",
"->",
"userIsWebmaster",
"(",
"$",
"account",
")",
"&&",
"!",
"$",
"this",
"->",
"isGranted",
"(",
"Access",
"::",
"PERM_USER_MANAGE_ALL",
")",
")",
"{",
"throw",
"$",
"this",
"->",
"createAccessDeniedException",
"(",
")",
";",
"}",
"$",
"database",
"=",
"$",
"this",
"->",
"getDatabaseConnection",
"(",
")",
";",
"$",
"q",
"=",
"$",
"database",
"->",
"select",
"(",
"'users'",
",",
"'u'",
")",
"->",
"fields",
"(",
"'u'",
",",
"[",
"'uid'",
",",
"'name'",
"]",
")",
"->",
"condition",
"(",
"'u.name'",
",",
"'%'",
".",
"$",
"database",
"->",
"escapeLike",
"(",
"$",
"string",
")",
".",
"'%'",
",",
"'LIKE'",
")",
"->",
"condition",
"(",
"'u.uid'",
",",
"[",
"0",
",",
"1",
"]",
",",
"'NOT IN'",
")",
"->",
"orderBy",
"(",
"'u.name'",
",",
"'asc'",
")",
"->",
"range",
"(",
"0",
",",
"16",
")",
"->",
"addTag",
"(",
"'ucms_user_access'",
")",
";",
"$",
"suggest",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"q",
"->",
"execute",
"(",
")",
"->",
"fetchAll",
"(",
")",
"as",
"$",
"record",
")",
"{",
"$",
"key",
"=",
"$",
"record",
"->",
"name",
".",
"' ['",
".",
"$",
"record",
"->",
"uid",
".",
"']'",
";",
"$",
"suggest",
"[",
"$",
"key",
"]",
"=",
"check_plain",
"(",
"$",
"record",
"->",
"name",
")",
";",
"}",
"return",
"new",
"JsonResponse",
"(",
"$",
"suggest",
")",
";",
"}"
] |
User autocomplete callback
|
[
"User",
"autocomplete",
"callback"
] |
6b8a84305472d2cad816102672f10274b3bbb535
|
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_site/src/Controller/AutocompleteController.php#L45-L73
|
235,210
|
makinacorpus/drupal-ucms
|
ucms_composition/src/Command/MigrateFromLayoutCommand.php
|
MigrateFromLayoutCommand.parseSquash
|
private function parseSquash(string $string) : array
{
// As always, regexes to the rescue
$matches = [];
// @todo find out why using /^...$/ does not work capturing all groups
if (!preg_match_all('/((\(\w+(?:\s+\w+)+\)\s*)+?)/ui', trim($string), $matches)) {
throw new \InvalidArgumentException();
}
$ret = [];
foreach ($matches[1] as $group) {
$ret[] = array_filter(preg_split('/[\(\)\s]+/', $group));
}
return $ret;
}
|
php
|
private function parseSquash(string $string) : array
{
// As always, regexes to the rescue
$matches = [];
// @todo find out why using /^...$/ does not work capturing all groups
if (!preg_match_all('/((\(\w+(?:\s+\w+)+\)\s*)+?)/ui', trim($string), $matches)) {
throw new \InvalidArgumentException();
}
$ret = [];
foreach ($matches[1] as $group) {
$ret[] = array_filter(preg_split('/[\(\)\s]+/', $group));
}
return $ret;
}
|
[
"private",
"function",
"parseSquash",
"(",
"string",
"$",
"string",
")",
":",
"array",
"{",
"// As always, regexes to the rescue",
"$",
"matches",
"=",
"[",
"]",
";",
"// @todo find out why using /^...$/ does not work capturing all groups",
"if",
"(",
"!",
"preg_match_all",
"(",
"'/((\\(\\w+(?:\\s+\\w+)+\\)\\s*)+?)/ui'",
",",
"trim",
"(",
"$",
"string",
")",
",",
"$",
"matches",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
")",
";",
"}",
"$",
"ret",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"matches",
"[",
"1",
"]",
"as",
"$",
"group",
")",
"{",
"$",
"ret",
"[",
"]",
"=",
"array_filter",
"(",
"preg_split",
"(",
"'/[\\(\\)\\s]+/'",
",",
"$",
"group",
")",
")",
";",
"}",
"return",
"$",
"ret",
";",
"}"
] |
Parse the squash option
@param string $string
@return null|string[][]
|
[
"Parse",
"the",
"squash",
"option"
] |
6b8a84305472d2cad816102672f10274b3bbb535
|
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_composition/src/Command/MigrateFromLayoutCommand.php#L62-L78
|
235,211
|
despark/ignicms
|
src/Console/Commands/File/ClearTemp.php
|
ClearTemp.handle
|
public function handle()
{
$deleteBefore = Carbon::now()->subWeek();
$filesToDelete = $this->tempModel->where('created_at', '<=', $deleteBefore)->get();
$failed = [];
foreach ($filesToDelete as $file) {
// delete the file
if (! \File::delete($file->getTempPath())) {
$this->output->warning(sprintf('%s file not found. Skipping...', $file->getTempPath()));
}
}
$deletedRecords = DB::table($this->tempModel->getTable())
->where('created_at', '<=', $deleteBefore)
->delete();
$this->output->success(sprintf('%d temp file cleaned', $deletedRecords));
}
|
php
|
public function handle()
{
$deleteBefore = Carbon::now()->subWeek();
$filesToDelete = $this->tempModel->where('created_at', '<=', $deleteBefore)->get();
$failed = [];
foreach ($filesToDelete as $file) {
// delete the file
if (! \File::delete($file->getTempPath())) {
$this->output->warning(sprintf('%s file not found. Skipping...', $file->getTempPath()));
}
}
$deletedRecords = DB::table($this->tempModel->getTable())
->where('created_at', '<=', $deleteBefore)
->delete();
$this->output->success(sprintf('%d temp file cleaned', $deletedRecords));
}
|
[
"public",
"function",
"handle",
"(",
")",
"{",
"$",
"deleteBefore",
"=",
"Carbon",
"::",
"now",
"(",
")",
"->",
"subWeek",
"(",
")",
";",
"$",
"filesToDelete",
"=",
"$",
"this",
"->",
"tempModel",
"->",
"where",
"(",
"'created_at'",
",",
"'<='",
",",
"$",
"deleteBefore",
")",
"->",
"get",
"(",
")",
";",
"$",
"failed",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"filesToDelete",
"as",
"$",
"file",
")",
"{",
"// delete the file",
"if",
"(",
"!",
"\\",
"File",
"::",
"delete",
"(",
"$",
"file",
"->",
"getTempPath",
"(",
")",
")",
")",
"{",
"$",
"this",
"->",
"output",
"->",
"warning",
"(",
"sprintf",
"(",
"'%s file not found. Skipping...'",
",",
"$",
"file",
"->",
"getTempPath",
"(",
")",
")",
")",
";",
"}",
"}",
"$",
"deletedRecords",
"=",
"DB",
"::",
"table",
"(",
"$",
"this",
"->",
"tempModel",
"->",
"getTable",
"(",
")",
")",
"->",
"where",
"(",
"'created_at'",
",",
"'<='",
",",
"$",
"deleteBefore",
")",
"->",
"delete",
"(",
")",
";",
"$",
"this",
"->",
"output",
"->",
"success",
"(",
"sprintf",
"(",
"'%d temp file cleaned'",
",",
"$",
"deletedRecords",
")",
")",
";",
"}"
] |
Run command.
|
[
"Run",
"command",
"."
] |
d55775a4656a7e99017d2ef3f8160599d600d2a7
|
https://github.com/despark/ignicms/blob/d55775a4656a7e99017d2ef3f8160599d600d2a7/src/Console/Commands/File/ClearTemp.php#L47-L65
|
235,212
|
despark/ignicms
|
public/admin_assets/plugins/tinymce/plugins/jbimages/ci/system/core/Config.php
|
CI_Config.load
|
function load($file = '', $use_sections = FALSE, $fail_gracefully = FALSE)
{
$file = ($file == '') ? 'config' : str_replace('.php', '', $file);
$found = FALSE;
$loaded = FALSE;
$check_locations = defined('ENVIRONMENT')
? array(ENVIRONMENT.'/'.$file, $file)
: array($file);
foreach ($this->_config_paths as $path)
{
foreach ($check_locations as $location)
{
$file_path = $path.'config/'.$location.'.php';
if (in_array($file_path, $this->is_loaded, TRUE))
{
$loaded = TRUE;
continue 2;
}
if (file_exists($file_path))
{
$found = TRUE;
break;
}
}
if ($found === FALSE)
{
continue;
}
include($file_path);
if ( ! isset($config) OR ! is_array($config))
{
if ($fail_gracefully === TRUE)
{
return FALSE;
}
show_error('Your '.$file_path.' file does not appear to contain a valid configuration array.');
}
if ($use_sections === TRUE)
{
if (isset($this->config[$file]))
{
$this->config[$file] = array_merge($this->config[$file], $config);
}
else
{
$this->config[$file] = $config;
}
}
else
{
$this->config = array_merge($this->config, $config);
}
$this->is_loaded[] = $file_path;
unset($config);
$loaded = TRUE;
log_message('debug', 'Config file loaded: '.$file_path);
break;
}
if ($loaded === FALSE)
{
if ($fail_gracefully === TRUE)
{
return FALSE;
}
show_error('The configuration file '.$file.'.php does not exist.');
}
return TRUE;
}
|
php
|
function load($file = '', $use_sections = FALSE, $fail_gracefully = FALSE)
{
$file = ($file == '') ? 'config' : str_replace('.php', '', $file);
$found = FALSE;
$loaded = FALSE;
$check_locations = defined('ENVIRONMENT')
? array(ENVIRONMENT.'/'.$file, $file)
: array($file);
foreach ($this->_config_paths as $path)
{
foreach ($check_locations as $location)
{
$file_path = $path.'config/'.$location.'.php';
if (in_array($file_path, $this->is_loaded, TRUE))
{
$loaded = TRUE;
continue 2;
}
if (file_exists($file_path))
{
$found = TRUE;
break;
}
}
if ($found === FALSE)
{
continue;
}
include($file_path);
if ( ! isset($config) OR ! is_array($config))
{
if ($fail_gracefully === TRUE)
{
return FALSE;
}
show_error('Your '.$file_path.' file does not appear to contain a valid configuration array.');
}
if ($use_sections === TRUE)
{
if (isset($this->config[$file]))
{
$this->config[$file] = array_merge($this->config[$file], $config);
}
else
{
$this->config[$file] = $config;
}
}
else
{
$this->config = array_merge($this->config, $config);
}
$this->is_loaded[] = $file_path;
unset($config);
$loaded = TRUE;
log_message('debug', 'Config file loaded: '.$file_path);
break;
}
if ($loaded === FALSE)
{
if ($fail_gracefully === TRUE)
{
return FALSE;
}
show_error('The configuration file '.$file.'.php does not exist.');
}
return TRUE;
}
|
[
"function",
"load",
"(",
"$",
"file",
"=",
"''",
",",
"$",
"use_sections",
"=",
"FALSE",
",",
"$",
"fail_gracefully",
"=",
"FALSE",
")",
"{",
"$",
"file",
"=",
"(",
"$",
"file",
"==",
"''",
")",
"?",
"'config'",
":",
"str_replace",
"(",
"'.php'",
",",
"''",
",",
"$",
"file",
")",
";",
"$",
"found",
"=",
"FALSE",
";",
"$",
"loaded",
"=",
"FALSE",
";",
"$",
"check_locations",
"=",
"defined",
"(",
"'ENVIRONMENT'",
")",
"?",
"array",
"(",
"ENVIRONMENT",
".",
"'/'",
".",
"$",
"file",
",",
"$",
"file",
")",
":",
"array",
"(",
"$",
"file",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"_config_paths",
"as",
"$",
"path",
")",
"{",
"foreach",
"(",
"$",
"check_locations",
"as",
"$",
"location",
")",
"{",
"$",
"file_path",
"=",
"$",
"path",
".",
"'config/'",
".",
"$",
"location",
".",
"'.php'",
";",
"if",
"(",
"in_array",
"(",
"$",
"file_path",
",",
"$",
"this",
"->",
"is_loaded",
",",
"TRUE",
")",
")",
"{",
"$",
"loaded",
"=",
"TRUE",
";",
"continue",
"2",
";",
"}",
"if",
"(",
"file_exists",
"(",
"$",
"file_path",
")",
")",
"{",
"$",
"found",
"=",
"TRUE",
";",
"break",
";",
"}",
"}",
"if",
"(",
"$",
"found",
"===",
"FALSE",
")",
"{",
"continue",
";",
"}",
"include",
"(",
"$",
"file_path",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"config",
")",
"OR",
"!",
"is_array",
"(",
"$",
"config",
")",
")",
"{",
"if",
"(",
"$",
"fail_gracefully",
"===",
"TRUE",
")",
"{",
"return",
"FALSE",
";",
"}",
"show_error",
"(",
"'Your '",
".",
"$",
"file_path",
".",
"' file does not appear to contain a valid configuration array.'",
")",
";",
"}",
"if",
"(",
"$",
"use_sections",
"===",
"TRUE",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"config",
"[",
"$",
"file",
"]",
")",
")",
"{",
"$",
"this",
"->",
"config",
"[",
"$",
"file",
"]",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"config",
"[",
"$",
"file",
"]",
",",
"$",
"config",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"config",
"[",
"$",
"file",
"]",
"=",
"$",
"config",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"config",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"config",
",",
"$",
"config",
")",
";",
"}",
"$",
"this",
"->",
"is_loaded",
"[",
"]",
"=",
"$",
"file_path",
";",
"unset",
"(",
"$",
"config",
")",
";",
"$",
"loaded",
"=",
"TRUE",
";",
"log_message",
"(",
"'debug'",
",",
"'Config file loaded: '",
".",
"$",
"file_path",
")",
";",
"break",
";",
"}",
"if",
"(",
"$",
"loaded",
"===",
"FALSE",
")",
"{",
"if",
"(",
"$",
"fail_gracefully",
"===",
"TRUE",
")",
"{",
"return",
"FALSE",
";",
"}",
"show_error",
"(",
"'The configuration file '",
".",
"$",
"file",
".",
"'.php does not exist.'",
")",
";",
"}",
"return",
"TRUE",
";",
"}"
] |
Load Config File
@access public
@param string the config file name
@param boolean if configuration values should be loaded into their own section
@param boolean true if errors should just return false, false if an error message should be displayed
@return boolean if the file was loaded correctly
|
[
"Load",
"Config",
"File"
] |
d55775a4656a7e99017d2ef3f8160599d600d2a7
|
https://github.com/despark/ignicms/blob/d55775a4656a7e99017d2ef3f8160599d600d2a7/public/admin_assets/plugins/tinymce/plugins/jbimages/ci/system/core/Config.php#L96-L175
|
235,213
|
despark/ignicms
|
public/admin_assets/plugins/tinymce/plugins/jbimages/ci/system/core/Config.php
|
CI_Config.item
|
function item($item, $index = '')
{
if ($index == '')
{
if ( ! isset($this->config[$item]))
{
return FALSE;
}
$pref = $this->config[$item];
}
else
{
if ( ! isset($this->config[$index]))
{
return FALSE;
}
if ( ! isset($this->config[$index][$item]))
{
return FALSE;
}
$pref = $this->config[$index][$item];
}
return $pref;
}
|
php
|
function item($item, $index = '')
{
if ($index == '')
{
if ( ! isset($this->config[$item]))
{
return FALSE;
}
$pref = $this->config[$item];
}
else
{
if ( ! isset($this->config[$index]))
{
return FALSE;
}
if ( ! isset($this->config[$index][$item]))
{
return FALSE;
}
$pref = $this->config[$index][$item];
}
return $pref;
}
|
[
"function",
"item",
"(",
"$",
"item",
",",
"$",
"index",
"=",
"''",
")",
"{",
"if",
"(",
"$",
"index",
"==",
"''",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"config",
"[",
"$",
"item",
"]",
")",
")",
"{",
"return",
"FALSE",
";",
"}",
"$",
"pref",
"=",
"$",
"this",
"->",
"config",
"[",
"$",
"item",
"]",
";",
"}",
"else",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"config",
"[",
"$",
"index",
"]",
")",
")",
"{",
"return",
"FALSE",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"config",
"[",
"$",
"index",
"]",
"[",
"$",
"item",
"]",
")",
")",
"{",
"return",
"FALSE",
";",
"}",
"$",
"pref",
"=",
"$",
"this",
"->",
"config",
"[",
"$",
"index",
"]",
"[",
"$",
"item",
"]",
";",
"}",
"return",
"$",
"pref",
";",
"}"
] |
Fetch a config file item
@access public
@param string the config item name
@param string the index name
@param bool
@return string
|
[
"Fetch",
"a",
"config",
"file",
"item"
] |
d55775a4656a7e99017d2ef3f8160599d600d2a7
|
https://github.com/despark/ignicms/blob/d55775a4656a7e99017d2ef3f8160599d600d2a7/public/admin_assets/plugins/tinymce/plugins/jbimages/ci/system/core/Config.php#L189-L216
|
235,214
|
loyals-online/silverstripe-tinymce4
|
code/forms/CustomHtmlEditorConfig.php
|
CustomHtmlEditorConfig.get
|
public static function get($identifier = 'default') {
if (!array_key_exists($identifier, self::$configs)) self::$configs[$identifier] = new CustomHtmlEditorConfig();
return self::$configs[$identifier];
}
|
php
|
public static function get($identifier = 'default') {
if (!array_key_exists($identifier, self::$configs)) self::$configs[$identifier] = new CustomHtmlEditorConfig();
return self::$configs[$identifier];
}
|
[
"public",
"static",
"function",
"get",
"(",
"$",
"identifier",
"=",
"'default'",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"identifier",
",",
"self",
"::",
"$",
"configs",
")",
")",
"self",
"::",
"$",
"configs",
"[",
"$",
"identifier",
"]",
"=",
"new",
"CustomHtmlEditorConfig",
"(",
")",
";",
"return",
"self",
"::",
"$",
"configs",
"[",
"$",
"identifier",
"]",
";",
"}"
] |
Get the HtmlEditorConfig object for the given identifier. This is a correct way to get an HtmlEditorConfig
instance - do not call 'new'
@param $identifier string - the identifier for the config set
@return HtmlEditorConfig - the configuration object. This will be created if it does not yet exist for that
identifier
|
[
"Get",
"the",
"HtmlEditorConfig",
"object",
"for",
"the",
"given",
"identifier",
".",
"This",
"is",
"a",
"correct",
"way",
"to",
"get",
"an",
"HtmlEditorConfig",
"instance",
"-",
"do",
"not",
"call",
"new"
] |
c0603d074ebbb6b8a429f2d2856778e3643bba34
|
https://github.com/loyals-online/silverstripe-tinymce4/blob/c0603d074ebbb6b8a429f2d2856778e3643bba34/code/forms/CustomHtmlEditorConfig.php#L28-L31
|
235,215
|
artkonekt/gears
|
src/Backend/BackendFactory.php
|
BackendFactory.create
|
public static function create(string $driver) : Backend
{
if (strpos($driver, '\\') === false) {
$class = __NAMESPACE__ . '\\Drivers\\' . studly_case($driver);
} else {
$class = $driver;
}
if (!class_exists($class)) {
throw new \InvalidArgumentException(
sprintf(
'Class `%s` does not exist, so it\'s far from being a good settings backend candidate',
$class
)
);
}
return app()->make($class);
}
|
php
|
public static function create(string $driver) : Backend
{
if (strpos($driver, '\\') === false) {
$class = __NAMESPACE__ . '\\Drivers\\' . studly_case($driver);
} else {
$class = $driver;
}
if (!class_exists($class)) {
throw new \InvalidArgumentException(
sprintf(
'Class `%s` does not exist, so it\'s far from being a good settings backend candidate',
$class
)
);
}
return app()->make($class);
}
|
[
"public",
"static",
"function",
"create",
"(",
"string",
"$",
"driver",
")",
":",
"Backend",
"{",
"if",
"(",
"strpos",
"(",
"$",
"driver",
",",
"'\\\\'",
")",
"===",
"false",
")",
"{",
"$",
"class",
"=",
"__NAMESPACE__",
".",
"'\\\\Drivers\\\\'",
".",
"studly_case",
"(",
"$",
"driver",
")",
";",
"}",
"else",
"{",
"$",
"class",
"=",
"$",
"driver",
";",
"}",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"class",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Class `%s` does not exist, so it\\'s far from being a good settings backend candidate'",
",",
"$",
"class",
")",
")",
";",
"}",
"return",
"app",
"(",
")",
"->",
"make",
"(",
"$",
"class",
")",
";",
"}"
] |
Creates a new backend instance based on the passed driver
@param string $driver Can be a short name for built in drivers eg. 'database' or a FQCN
@return Backend
|
[
"Creates",
"a",
"new",
"backend",
"instance",
"based",
"on",
"the",
"passed",
"driver"
] |
6c006a3e8e334d8100aab768a2a5e807bcac5695
|
https://github.com/artkonekt/gears/blob/6c006a3e8e334d8100aab768a2a5e807bcac5695/src/Backend/BackendFactory.php#L25-L43
|
235,216
|
makinacorpus/drupal-ucms
|
ucms_site/src/NodeManager.php
|
NodeManager.createReference
|
public function createReference(Site $site, NodeInterface $node)
{
$nodeId = $node->id();
$siteId = $site->getId();
$this
->db
->merge('ucms_site_node')
->key(['nid' => $nodeId, 'site_id' => $siteId])
->execute()
;
if (!in_array($siteId, $node->ucms_sites)) {
$node->ucms_sites[] = $siteId;
}
$this->eventDispatcher->dispatch(NodeEvents::ACCESS_CHANGE, new ResourceEvent('node', [$nodeId]));
$this->eventDispatcher->dispatch(SiteEvents::EVENT_ATTACH, new SiteAttachEvent($siteId, $nodeId));
}
|
php
|
public function createReference(Site $site, NodeInterface $node)
{
$nodeId = $node->id();
$siteId = $site->getId();
$this
->db
->merge('ucms_site_node')
->key(['nid' => $nodeId, 'site_id' => $siteId])
->execute()
;
if (!in_array($siteId, $node->ucms_sites)) {
$node->ucms_sites[] = $siteId;
}
$this->eventDispatcher->dispatch(NodeEvents::ACCESS_CHANGE, new ResourceEvent('node', [$nodeId]));
$this->eventDispatcher->dispatch(SiteEvents::EVENT_ATTACH, new SiteAttachEvent($siteId, $nodeId));
}
|
[
"public",
"function",
"createReference",
"(",
"Site",
"$",
"site",
",",
"NodeInterface",
"$",
"node",
")",
"{",
"$",
"nodeId",
"=",
"$",
"node",
"->",
"id",
"(",
")",
";",
"$",
"siteId",
"=",
"$",
"site",
"->",
"getId",
"(",
")",
";",
"$",
"this",
"->",
"db",
"->",
"merge",
"(",
"'ucms_site_node'",
")",
"->",
"key",
"(",
"[",
"'nid'",
"=>",
"$",
"nodeId",
",",
"'site_id'",
"=>",
"$",
"siteId",
"]",
")",
"->",
"execute",
"(",
")",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"siteId",
",",
"$",
"node",
"->",
"ucms_sites",
")",
")",
"{",
"$",
"node",
"->",
"ucms_sites",
"[",
"]",
"=",
"$",
"siteId",
";",
"}",
"$",
"this",
"->",
"eventDispatcher",
"->",
"dispatch",
"(",
"NodeEvents",
"::",
"ACCESS_CHANGE",
",",
"new",
"ResourceEvent",
"(",
"'node'",
",",
"[",
"$",
"nodeId",
"]",
")",
")",
";",
"$",
"this",
"->",
"eventDispatcher",
"->",
"dispatch",
"(",
"SiteEvents",
"::",
"EVENT_ATTACH",
",",
"new",
"SiteAttachEvent",
"(",
"$",
"siteId",
",",
"$",
"nodeId",
")",
")",
";",
"}"
] |
Reference node into a site
@param Site $site
@param NodeInterface $node
|
[
"Reference",
"node",
"into",
"a",
"site"
] |
6b8a84305472d2cad816102672f10274b3bbb535
|
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_site/src/NodeManager.php#L91-L109
|
235,217
|
makinacorpus/drupal-ucms
|
ucms_site/src/NodeManager.php
|
NodeManager.createReferenceBulkForNode
|
public function createReferenceBulkForNode($nodeId, $siteIdList)
{
// @todo Optimize me
foreach ($siteIdList as $siteId) {
$this
->db
->merge('ucms_site_node')
->key(['nid' => $nodeId, 'site_id' => $siteId])
->execute()
;
}
$this
->entityManager
->getStorage('node')
->resetCache([$nodeId])
;
$this->eventDispatcher->dispatch(NodeEvents::ACCESS_CHANGE, new ResourceEvent('node', [$nodeId]));
$this->eventDispatcher->dispatch(SiteEvents::EVENT_ATTACH, new SiteAttachEvent($siteIdList, $nodeId));
}
|
php
|
public function createReferenceBulkForNode($nodeId, $siteIdList)
{
// @todo Optimize me
foreach ($siteIdList as $siteId) {
$this
->db
->merge('ucms_site_node')
->key(['nid' => $nodeId, 'site_id' => $siteId])
->execute()
;
}
$this
->entityManager
->getStorage('node')
->resetCache([$nodeId])
;
$this->eventDispatcher->dispatch(NodeEvents::ACCESS_CHANGE, new ResourceEvent('node', [$nodeId]));
$this->eventDispatcher->dispatch(SiteEvents::EVENT_ATTACH, new SiteAttachEvent($siteIdList, $nodeId));
}
|
[
"public",
"function",
"createReferenceBulkForNode",
"(",
"$",
"nodeId",
",",
"$",
"siteIdList",
")",
"{",
"// @todo Optimize me",
"foreach",
"(",
"$",
"siteIdList",
"as",
"$",
"siteId",
")",
"{",
"$",
"this",
"->",
"db",
"->",
"merge",
"(",
"'ucms_site_node'",
")",
"->",
"key",
"(",
"[",
"'nid'",
"=>",
"$",
"nodeId",
",",
"'site_id'",
"=>",
"$",
"siteId",
"]",
")",
"->",
"execute",
"(",
")",
";",
"}",
"$",
"this",
"->",
"entityManager",
"->",
"getStorage",
"(",
"'node'",
")",
"->",
"resetCache",
"(",
"[",
"$",
"nodeId",
"]",
")",
";",
"$",
"this",
"->",
"eventDispatcher",
"->",
"dispatch",
"(",
"NodeEvents",
"::",
"ACCESS_CHANGE",
",",
"new",
"ResourceEvent",
"(",
"'node'",
",",
"[",
"$",
"nodeId",
"]",
")",
")",
";",
"$",
"this",
"->",
"eventDispatcher",
"->",
"dispatch",
"(",
"SiteEvents",
"::",
"EVENT_ATTACH",
",",
"new",
"SiteAttachEvent",
"(",
"$",
"siteIdList",
",",
"$",
"nodeId",
")",
")",
";",
"}"
] |
Reference a single within multiple sites
@param int $nodeId
@param int[] $siteIdList
|
[
"Reference",
"a",
"single",
"within",
"multiple",
"sites"
] |
6b8a84305472d2cad816102672f10274b3bbb535
|
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_site/src/NodeManager.php#L117-L137
|
235,218
|
makinacorpus/drupal-ucms
|
ucms_site/src/NodeManager.php
|
NodeManager.createReferenceBulkInSite
|
public function createReferenceBulkInSite($siteId, $nodeIdList)
{
// @todo Optimize me
foreach ($nodeIdList as $nodeId) {
$this
->db
->merge('ucms_site_node')
->key(['nid' => $nodeId, 'site_id' => $siteId])
->execute()
;
}
$this
->entityManager
->getStorage('node')
->resetCache($nodeIdList)
;
$this->eventDispatcher->dispatch(NodeEvents::ACCESS_CHANGE, new ResourceEvent('node', $nodeIdList));
$this->eventDispatcher->dispatch(SiteEvents::EVENT_ATTACH, new SiteAttachEvent($siteId, $nodeIdList));
}
|
php
|
public function createReferenceBulkInSite($siteId, $nodeIdList)
{
// @todo Optimize me
foreach ($nodeIdList as $nodeId) {
$this
->db
->merge('ucms_site_node')
->key(['nid' => $nodeId, 'site_id' => $siteId])
->execute()
;
}
$this
->entityManager
->getStorage('node')
->resetCache($nodeIdList)
;
$this->eventDispatcher->dispatch(NodeEvents::ACCESS_CHANGE, new ResourceEvent('node', $nodeIdList));
$this->eventDispatcher->dispatch(SiteEvents::EVENT_ATTACH, new SiteAttachEvent($siteId, $nodeIdList));
}
|
[
"public",
"function",
"createReferenceBulkInSite",
"(",
"$",
"siteId",
",",
"$",
"nodeIdList",
")",
"{",
"// @todo Optimize me",
"foreach",
"(",
"$",
"nodeIdList",
"as",
"$",
"nodeId",
")",
"{",
"$",
"this",
"->",
"db",
"->",
"merge",
"(",
"'ucms_site_node'",
")",
"->",
"key",
"(",
"[",
"'nid'",
"=>",
"$",
"nodeId",
",",
"'site_id'",
"=>",
"$",
"siteId",
"]",
")",
"->",
"execute",
"(",
")",
";",
"}",
"$",
"this",
"->",
"entityManager",
"->",
"getStorage",
"(",
"'node'",
")",
"->",
"resetCache",
"(",
"$",
"nodeIdList",
")",
";",
"$",
"this",
"->",
"eventDispatcher",
"->",
"dispatch",
"(",
"NodeEvents",
"::",
"ACCESS_CHANGE",
",",
"new",
"ResourceEvent",
"(",
"'node'",
",",
"$",
"nodeIdList",
")",
")",
";",
"$",
"this",
"->",
"eventDispatcher",
"->",
"dispatch",
"(",
"SiteEvents",
"::",
"EVENT_ATTACH",
",",
"new",
"SiteAttachEvent",
"(",
"$",
"siteId",
",",
"$",
"nodeIdList",
")",
")",
";",
"}"
] |
Reference multiple nodes within a single site
@param int $siteId
@param int[] $nodeIdList
|
[
"Reference",
"multiple",
"nodes",
"within",
"a",
"single",
"site"
] |
6b8a84305472d2cad816102672f10274b3bbb535
|
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_site/src/NodeManager.php#L145-L165
|
235,219
|
makinacorpus/drupal-ucms
|
ucms_site/src/NodeManager.php
|
NodeManager.createUnsavedClone
|
public function createUnsavedClone(NodeInterface $original, array $updates = [])
{
// This method, instead of the clone operator, will actually drop all
// existing references and pointers and give you raw values.
// All credits to https://stackoverflow.com/a/10831885/5826569
$node = unserialize(serialize($original));
$node->nid = null;
$node->vid = null;
$node->tnid = null;
$node->log = null;
$node->created = null;
$node->changed = null;
$node->path = null;
$node->files = [];
// Fills in the some default values.
$node->status = 0;
$node->promote = 0;
$node->sticky = 0;
$node->revision = 1;
// Resets sites information.
$node->site_id = null;
$node->ucms_sites = [];
// Sets the origin_id and parent_id.
$node->parent_nid = $original->id();
$node->origin_nid = empty($original->origin_nid) ? $original->id() : $original->origin_nid;
// Forces node indexing.
$node->ucms_index_now = 1; // @todo find a better way
// Sets the node's owner.
if (isset($updates['uid'])) {
$account = $this->entityManager->getStorage('user')->load($updates['uid']);
$node->uid = $account->id();
$node->name = $account->getAccountName();
$node->revision_uid = $account->id();
unset($updates['uid']);
}
foreach ($updates as $key => $value) {
$node->{$key} = $value;
}
return $node;
}
|
php
|
public function createUnsavedClone(NodeInterface $original, array $updates = [])
{
// This method, instead of the clone operator, will actually drop all
// existing references and pointers and give you raw values.
// All credits to https://stackoverflow.com/a/10831885/5826569
$node = unserialize(serialize($original));
$node->nid = null;
$node->vid = null;
$node->tnid = null;
$node->log = null;
$node->created = null;
$node->changed = null;
$node->path = null;
$node->files = [];
// Fills in the some default values.
$node->status = 0;
$node->promote = 0;
$node->sticky = 0;
$node->revision = 1;
// Resets sites information.
$node->site_id = null;
$node->ucms_sites = [];
// Sets the origin_id and parent_id.
$node->parent_nid = $original->id();
$node->origin_nid = empty($original->origin_nid) ? $original->id() : $original->origin_nid;
// Forces node indexing.
$node->ucms_index_now = 1; // @todo find a better way
// Sets the node's owner.
if (isset($updates['uid'])) {
$account = $this->entityManager->getStorage('user')->load($updates['uid']);
$node->uid = $account->id();
$node->name = $account->getAccountName();
$node->revision_uid = $account->id();
unset($updates['uid']);
}
foreach ($updates as $key => $value) {
$node->{$key} = $value;
}
return $node;
}
|
[
"public",
"function",
"createUnsavedClone",
"(",
"NodeInterface",
"$",
"original",
",",
"array",
"$",
"updates",
"=",
"[",
"]",
")",
"{",
"// This method, instead of the clone operator, will actually drop all",
"// existing references and pointers and give you raw values.",
"// All credits to https://stackoverflow.com/a/10831885/5826569",
"$",
"node",
"=",
"unserialize",
"(",
"serialize",
"(",
"$",
"original",
")",
")",
";",
"$",
"node",
"->",
"nid",
"=",
"null",
";",
"$",
"node",
"->",
"vid",
"=",
"null",
";",
"$",
"node",
"->",
"tnid",
"=",
"null",
";",
"$",
"node",
"->",
"log",
"=",
"null",
";",
"$",
"node",
"->",
"created",
"=",
"null",
";",
"$",
"node",
"->",
"changed",
"=",
"null",
";",
"$",
"node",
"->",
"path",
"=",
"null",
";",
"$",
"node",
"->",
"files",
"=",
"[",
"]",
";",
"// Fills in the some default values.",
"$",
"node",
"->",
"status",
"=",
"0",
";",
"$",
"node",
"->",
"promote",
"=",
"0",
";",
"$",
"node",
"->",
"sticky",
"=",
"0",
";",
"$",
"node",
"->",
"revision",
"=",
"1",
";",
"// Resets sites information.",
"$",
"node",
"->",
"site_id",
"=",
"null",
";",
"$",
"node",
"->",
"ucms_sites",
"=",
"[",
"]",
";",
"// Sets the origin_id and parent_id.",
"$",
"node",
"->",
"parent_nid",
"=",
"$",
"original",
"->",
"id",
"(",
")",
";",
"$",
"node",
"->",
"origin_nid",
"=",
"empty",
"(",
"$",
"original",
"->",
"origin_nid",
")",
"?",
"$",
"original",
"->",
"id",
"(",
")",
":",
"$",
"original",
"->",
"origin_nid",
";",
"// Forces node indexing.",
"$",
"node",
"->",
"ucms_index_now",
"=",
"1",
";",
"// @todo find a better way",
"// Sets the node's owner.",
"if",
"(",
"isset",
"(",
"$",
"updates",
"[",
"'uid'",
"]",
")",
")",
"{",
"$",
"account",
"=",
"$",
"this",
"->",
"entityManager",
"->",
"getStorage",
"(",
"'user'",
")",
"->",
"load",
"(",
"$",
"updates",
"[",
"'uid'",
"]",
")",
";",
"$",
"node",
"->",
"uid",
"=",
"$",
"account",
"->",
"id",
"(",
")",
";",
"$",
"node",
"->",
"name",
"=",
"$",
"account",
"->",
"getAccountName",
"(",
")",
";",
"$",
"node",
"->",
"revision_uid",
"=",
"$",
"account",
"->",
"id",
"(",
")",
";",
"unset",
"(",
"$",
"updates",
"[",
"'uid'",
"]",
")",
";",
"}",
"foreach",
"(",
"$",
"updates",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"node",
"->",
"{",
"$",
"key",
"}",
"=",
"$",
"value",
";",
"}",
"return",
"$",
"node",
";",
"}"
] |
Create unsaved node clone
@param NodeInterface $original
Original node to clone
@param array $updates
Any fields that will replace properties on the new node object, set
the 'uid' property as user identifier
@return NodeInterface
Unsaved clone
|
[
"Create",
"unsaved",
"node",
"clone"
] |
6b8a84305472d2cad816102672f10274b3bbb535
|
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_site/src/NodeManager.php#L179-L222
|
235,220
|
makinacorpus/drupal-ucms
|
ucms_site/src/NodeManager.php
|
NodeManager.createAndSaveClone
|
public function createAndSaveClone(NodeInterface $original, array $updates = [])
{
$clone = $this->createUnsavedClone($original, $updates);
$this->entityManager->getStorage('node')->save($clone);
return $clone;
}
|
php
|
public function createAndSaveClone(NodeInterface $original, array $updates = [])
{
$clone = $this->createUnsavedClone($original, $updates);
$this->entityManager->getStorage('node')->save($clone);
return $clone;
}
|
[
"public",
"function",
"createAndSaveClone",
"(",
"NodeInterface",
"$",
"original",
",",
"array",
"$",
"updates",
"=",
"[",
"]",
")",
"{",
"$",
"clone",
"=",
"$",
"this",
"->",
"createUnsavedClone",
"(",
"$",
"original",
",",
"$",
"updates",
")",
";",
"$",
"this",
"->",
"entityManager",
"->",
"getStorage",
"(",
"'node'",
")",
"->",
"save",
"(",
"$",
"clone",
")",
";",
"return",
"$",
"clone",
";",
"}"
] |
Clone the given node
@param NodeInterface $original
Original node to clone
@param array $updates
Any fields that will replace properties on the new node object, set
the 'uid' property as user identifier
@return NodeInterface
New duplicated node, it has already been saved, to update values use
the $updates parameter
|
[
"Clone",
"the",
"given",
"node"
] |
6b8a84305472d2cad816102672f10274b3bbb535
|
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_site/src/NodeManager.php#L237-L243
|
235,221
|
makinacorpus/drupal-ucms
|
ucms_site/src/NodeManager.php
|
NodeManager.deleteReferenceBulkFromSite
|
public function deleteReferenceBulkFromSite($siteId, $nodeIdList)
{
if (!$nodeIdList) {
return;
}
$this
->db
->delete('ucms_site_node')
->condition('nid', $nodeIdList)
->condition('site_id', $siteId)
->execute()
;
$this
->entityManager
->getStorage('node')
->resetCache($nodeIdList)
;
$this->eventDispatcher->dispatch(NodeEvents::ACCESS_CHANGE, new ResourceEvent('node', $nodeIdList));
$this->eventDispatcher->dispatch(SiteEvents::EVENT_DETACH, new SiteAttachEvent($siteId, $nodeIdList));
}
|
php
|
public function deleteReferenceBulkFromSite($siteId, $nodeIdList)
{
if (!$nodeIdList) {
return;
}
$this
->db
->delete('ucms_site_node')
->condition('nid', $nodeIdList)
->condition('site_id', $siteId)
->execute()
;
$this
->entityManager
->getStorage('node')
->resetCache($nodeIdList)
;
$this->eventDispatcher->dispatch(NodeEvents::ACCESS_CHANGE, new ResourceEvent('node', $nodeIdList));
$this->eventDispatcher->dispatch(SiteEvents::EVENT_DETACH, new SiteAttachEvent($siteId, $nodeIdList));
}
|
[
"public",
"function",
"deleteReferenceBulkFromSite",
"(",
"$",
"siteId",
",",
"$",
"nodeIdList",
")",
"{",
"if",
"(",
"!",
"$",
"nodeIdList",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"db",
"->",
"delete",
"(",
"'ucms_site_node'",
")",
"->",
"condition",
"(",
"'nid'",
",",
"$",
"nodeIdList",
")",
"->",
"condition",
"(",
"'site_id'",
",",
"$",
"siteId",
")",
"->",
"execute",
"(",
")",
";",
"$",
"this",
"->",
"entityManager",
"->",
"getStorage",
"(",
"'node'",
")",
"->",
"resetCache",
"(",
"$",
"nodeIdList",
")",
";",
"$",
"this",
"->",
"eventDispatcher",
"->",
"dispatch",
"(",
"NodeEvents",
"::",
"ACCESS_CHANGE",
",",
"new",
"ResourceEvent",
"(",
"'node'",
",",
"$",
"nodeIdList",
")",
")",
";",
"$",
"this",
"->",
"eventDispatcher",
"->",
"dispatch",
"(",
"SiteEvents",
"::",
"EVENT_DETACH",
",",
"new",
"SiteAttachEvent",
"(",
"$",
"siteId",
",",
"$",
"nodeIdList",
")",
")",
";",
"}"
] |
Unreference node for a site
@param int $siteId
@param int[] $nodeIdList
|
[
"Unreference",
"node",
"for",
"a",
"site"
] |
6b8a84305472d2cad816102672f10274b3bbb535
|
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_site/src/NodeManager.php#L251-L273
|
235,222
|
makinacorpus/drupal-ucms
|
ucms_site/src/NodeManager.php
|
NodeManager.findSiteCandidatesForReference
|
public function findSiteCandidatesForReference(NodeInterface $node, $userId)
{
$ne = $this
->db
->select('ucms_site_node', 'sn')
->where("sn.site_id = sa.site_id")
->condition('sn.nid', $node->id())
;
$ne->addExpression('1');
$idList = $this
->db
->select('ucms_site_access', 'sa')
->fields('sa', ['site_id'])
->condition('sa.uid', $userId)
->notExists($ne)
->groupBy('sa.site_id')
->execute()
->fetchCol()
;
return $this->manager->getStorage()->loadAll($idList);
}
|
php
|
public function findSiteCandidatesForReference(NodeInterface $node, $userId)
{
$ne = $this
->db
->select('ucms_site_node', 'sn')
->where("sn.site_id = sa.site_id")
->condition('sn.nid', $node->id())
;
$ne->addExpression('1');
$idList = $this
->db
->select('ucms_site_access', 'sa')
->fields('sa', ['site_id'])
->condition('sa.uid', $userId)
->notExists($ne)
->groupBy('sa.site_id')
->execute()
->fetchCol()
;
return $this->manager->getStorage()->loadAll($idList);
}
|
[
"public",
"function",
"findSiteCandidatesForReference",
"(",
"NodeInterface",
"$",
"node",
",",
"$",
"userId",
")",
"{",
"$",
"ne",
"=",
"$",
"this",
"->",
"db",
"->",
"select",
"(",
"'ucms_site_node'",
",",
"'sn'",
")",
"->",
"where",
"(",
"\"sn.site_id = sa.site_id\"",
")",
"->",
"condition",
"(",
"'sn.nid'",
",",
"$",
"node",
"->",
"id",
"(",
")",
")",
";",
"$",
"ne",
"->",
"addExpression",
"(",
"'1'",
")",
";",
"$",
"idList",
"=",
"$",
"this",
"->",
"db",
"->",
"select",
"(",
"'ucms_site_access'",
",",
"'sa'",
")",
"->",
"fields",
"(",
"'sa'",
",",
"[",
"'site_id'",
"]",
")",
"->",
"condition",
"(",
"'sa.uid'",
",",
"$",
"userId",
")",
"->",
"notExists",
"(",
"$",
"ne",
")",
"->",
"groupBy",
"(",
"'sa.site_id'",
")",
"->",
"execute",
"(",
")",
"->",
"fetchCol",
"(",
")",
";",
"return",
"$",
"this",
"->",
"manager",
"->",
"getStorage",
"(",
")",
"->",
"loadAll",
"(",
"$",
"idList",
")",
";",
"}"
] |
Find candidate sites for referencing this node
@param NodeInterface $node
@param int $userId
@return Site[]
|
[
"Find",
"candidate",
"sites",
"for",
"referencing",
"this",
"node"
] |
6b8a84305472d2cad816102672f10274b3bbb535
|
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_site/src/NodeManager.php#L283-L305
|
235,223
|
makinacorpus/drupal-ucms
|
ucms_site/src/NodeManager.php
|
NodeManager.findSiteCandidatesForCloning
|
public function findSiteCandidatesForCloning(NodeInterface $node, $userId)
{
/*
* The right and only working query for this.
*
SELECT DISTINCT(sa.site_id)
FROM ucms_site_access sa
JOIN ucms_site_node sn ON sn.site_id = sa.site_id
WHERE
sa.uid = 13 -- current user
AND sn.
AND sa.role = 1 -- webmaster
AND sa.site_id <> 2 -- node current site
AND NOT EXISTS (
SELECT 1
FROM node en
WHERE
en.site_id = sa.site_id
AND (
en.parent_nid = 6 -- node we are looking for
OR nid = 6
)
)
;
*/
$sq = $this
->db
->select('node', 'en')
->where('en.site_id = sa.site_id')
->where('en.parent_nid = :nid1 OR nid = :nid2', [':nid1' => $node->id(), ':nid2' => $node->id()])
;
$sq->addExpression('1');
$q = $this
->db
->select('ucms_site_access', 'sa')
->fields('sa', ['site_id'])
->condition('sa.uid', $userId)
->condition('sa.role', Access::ROLE_WEBMASTER)
;
$q->join('ucms_site_node', 'sn', 'sn.site_id = sa.site_id');
$q->condition('sn.nid', $node->id());
// The node might not be attached to any site if it is a global content
if ($node->site_id) {
$q->condition('sa.site_id', $node->site_id, '<>');
}
$idList = $q
->notExists($sq)
->addTag('ucms_site_access')
->execute()
->fetchCol()
;
return $this->manager->getStorage()->loadAll($idList);
}
|
php
|
public function findSiteCandidatesForCloning(NodeInterface $node, $userId)
{
/*
* The right and only working query for this.
*
SELECT DISTINCT(sa.site_id)
FROM ucms_site_access sa
JOIN ucms_site_node sn ON sn.site_id = sa.site_id
WHERE
sa.uid = 13 -- current user
AND sn.
AND sa.role = 1 -- webmaster
AND sa.site_id <> 2 -- node current site
AND NOT EXISTS (
SELECT 1
FROM node en
WHERE
en.site_id = sa.site_id
AND (
en.parent_nid = 6 -- node we are looking for
OR nid = 6
)
)
;
*/
$sq = $this
->db
->select('node', 'en')
->where('en.site_id = sa.site_id')
->where('en.parent_nid = :nid1 OR nid = :nid2', [':nid1' => $node->id(), ':nid2' => $node->id()])
;
$sq->addExpression('1');
$q = $this
->db
->select('ucms_site_access', 'sa')
->fields('sa', ['site_id'])
->condition('sa.uid', $userId)
->condition('sa.role', Access::ROLE_WEBMASTER)
;
$q->join('ucms_site_node', 'sn', 'sn.site_id = sa.site_id');
$q->condition('sn.nid', $node->id());
// The node might not be attached to any site if it is a global content
if ($node->site_id) {
$q->condition('sa.site_id', $node->site_id, '<>');
}
$idList = $q
->notExists($sq)
->addTag('ucms_site_access')
->execute()
->fetchCol()
;
return $this->manager->getStorage()->loadAll($idList);
}
|
[
"public",
"function",
"findSiteCandidatesForCloning",
"(",
"NodeInterface",
"$",
"node",
",",
"$",
"userId",
")",
"{",
"/*\n * The right and only working query for this.\n *\n SELECT DISTINCT(sa.site_id)\n FROM ucms_site_access sa\n JOIN ucms_site_node sn ON sn.site_id = sa.site_id\n WHERE\n sa.uid = 13 -- current user\n AND sn.\n AND sa.role = 1 -- webmaster\n AND sa.site_id <> 2 -- node current site\n AND NOT EXISTS (\n SELECT 1\n FROM node en\n WHERE\n en.site_id = sa.site_id\n AND (\n en.parent_nid = 6 -- node we are looking for\n OR nid = 6\n )\n )\n ;\n */",
"$",
"sq",
"=",
"$",
"this",
"->",
"db",
"->",
"select",
"(",
"'node'",
",",
"'en'",
")",
"->",
"where",
"(",
"'en.site_id = sa.site_id'",
")",
"->",
"where",
"(",
"'en.parent_nid = :nid1 OR nid = :nid2'",
",",
"[",
"':nid1'",
"=>",
"$",
"node",
"->",
"id",
"(",
")",
",",
"':nid2'",
"=>",
"$",
"node",
"->",
"id",
"(",
")",
"]",
")",
";",
"$",
"sq",
"->",
"addExpression",
"(",
"'1'",
")",
";",
"$",
"q",
"=",
"$",
"this",
"->",
"db",
"->",
"select",
"(",
"'ucms_site_access'",
",",
"'sa'",
")",
"->",
"fields",
"(",
"'sa'",
",",
"[",
"'site_id'",
"]",
")",
"->",
"condition",
"(",
"'sa.uid'",
",",
"$",
"userId",
")",
"->",
"condition",
"(",
"'sa.role'",
",",
"Access",
"::",
"ROLE_WEBMASTER",
")",
";",
"$",
"q",
"->",
"join",
"(",
"'ucms_site_node'",
",",
"'sn'",
",",
"'sn.site_id = sa.site_id'",
")",
";",
"$",
"q",
"->",
"condition",
"(",
"'sn.nid'",
",",
"$",
"node",
"->",
"id",
"(",
")",
")",
";",
"// The node might not be attached to any site if it is a global content",
"if",
"(",
"$",
"node",
"->",
"site_id",
")",
"{",
"$",
"q",
"->",
"condition",
"(",
"'sa.site_id'",
",",
"$",
"node",
"->",
"site_id",
",",
"'<>'",
")",
";",
"}",
"$",
"idList",
"=",
"$",
"q",
"->",
"notExists",
"(",
"$",
"sq",
")",
"->",
"addTag",
"(",
"'ucms_site_access'",
")",
"->",
"execute",
"(",
")",
"->",
"fetchCol",
"(",
")",
";",
"return",
"$",
"this",
"->",
"manager",
"->",
"getStorage",
"(",
")",
"->",
"loadAll",
"(",
"$",
"idList",
")",
";",
"}"
] |
Find candidate sites for cloning this node
@param NodeInterface $node
@param int $userId
@return Site[]
|
[
"Find",
"candidate",
"sites",
"for",
"cloning",
"this",
"node"
] |
6b8a84305472d2cad816102672f10274b3bbb535
|
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_site/src/NodeManager.php#L315-L374
|
235,224
|
makinacorpus/drupal-ucms
|
ucms_site/src/NodeManager.php
|
NodeManager.getCloningMapping
|
public function getCloningMapping(Site $site)
{
if (isset($this->cloningMapping[$site->getId()])) {
return $this->cloningMapping[$site->getId()];
}
$q = $this->db
->select('node', 'n')
->fields('n', ['parent_nid', 'nid'])
->isNotNull('parent_nid')
->condition('site_id', $site->id)
->condition('status', NODE_PUBLISHED)
->orderBy('created', 'ASC')
;
$mapping = [];
foreach ($q->execute()->fetchAll() as $row) {
if (isset($mapping[(int) $row->parent_nid])) {
continue;
}
$mapping[(int) $row->parent_nid] = (int) $row->nid;
}
$this->cloningMapping[$site->getId()] = $mapping;
return $mapping;
}
|
php
|
public function getCloningMapping(Site $site)
{
if (isset($this->cloningMapping[$site->getId()])) {
return $this->cloningMapping[$site->getId()];
}
$q = $this->db
->select('node', 'n')
->fields('n', ['parent_nid', 'nid'])
->isNotNull('parent_nid')
->condition('site_id', $site->id)
->condition('status', NODE_PUBLISHED)
->orderBy('created', 'ASC')
;
$mapping = [];
foreach ($q->execute()->fetchAll() as $row) {
if (isset($mapping[(int) $row->parent_nid])) {
continue;
}
$mapping[(int) $row->parent_nid] = (int) $row->nid;
}
$this->cloningMapping[$site->getId()] = $mapping;
return $mapping;
}
|
[
"public",
"function",
"getCloningMapping",
"(",
"Site",
"$",
"site",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"cloningMapping",
"[",
"$",
"site",
"->",
"getId",
"(",
")",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"cloningMapping",
"[",
"$",
"site",
"->",
"getId",
"(",
")",
"]",
";",
"}",
"$",
"q",
"=",
"$",
"this",
"->",
"db",
"->",
"select",
"(",
"'node'",
",",
"'n'",
")",
"->",
"fields",
"(",
"'n'",
",",
"[",
"'parent_nid'",
",",
"'nid'",
"]",
")",
"->",
"isNotNull",
"(",
"'parent_nid'",
")",
"->",
"condition",
"(",
"'site_id'",
",",
"$",
"site",
"->",
"id",
")",
"->",
"condition",
"(",
"'status'",
",",
"NODE_PUBLISHED",
")",
"->",
"orderBy",
"(",
"'created'",
",",
"'ASC'",
")",
";",
"$",
"mapping",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"q",
"->",
"execute",
"(",
")",
"->",
"fetchAll",
"(",
")",
"as",
"$",
"row",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"mapping",
"[",
"(",
"int",
")",
"$",
"row",
"->",
"parent_nid",
"]",
")",
")",
"{",
"continue",
";",
"}",
"$",
"mapping",
"[",
"(",
"int",
")",
"$",
"row",
"->",
"parent_nid",
"]",
"=",
"(",
"int",
")",
"$",
"row",
"->",
"nid",
";",
"}",
"$",
"this",
"->",
"cloningMapping",
"[",
"$",
"site",
"->",
"getId",
"(",
")",
"]",
"=",
"$",
"mapping",
";",
"return",
"$",
"mapping",
";",
"}"
] |
Provides a mapping array of parent identifiers to clone identifiers.
If there is several clones for a same parent,
the first created will be passed.
@param Site $site
@return integer[]
|
[
"Provides",
"a",
"mapping",
"array",
"of",
"parent",
"identifiers",
"to",
"clone",
"identifiers",
"."
] |
6b8a84305472d2cad816102672f10274b3bbb535
|
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_site/src/NodeManager.php#L386-L413
|
235,225
|
tck/zf-imageresizer
|
src/TckImageResizer/Service/ImageProcessing.php
|
ImageProcessing.process
|
public function process($source, $target, $commands)
{
$targetFolder = pathinfo($target, PATHINFO_DIRNAME);
if (!file_exists($targetFolder)) {
mkdir($targetFolder, 0777, true);
}
$this->image = $this->getImagineService()->open($source);
foreach ($this->analyseCommands($commands) as $command) {
if ($this->runCommand($command)) {
continue;
}
$this->runCustomCommand($command);
}
$this->image->save($target);
}
|
php
|
public function process($source, $target, $commands)
{
$targetFolder = pathinfo($target, PATHINFO_DIRNAME);
if (!file_exists($targetFolder)) {
mkdir($targetFolder, 0777, true);
}
$this->image = $this->getImagineService()->open($source);
foreach ($this->analyseCommands($commands) as $command) {
if ($this->runCommand($command)) {
continue;
}
$this->runCustomCommand($command);
}
$this->image->save($target);
}
|
[
"public",
"function",
"process",
"(",
"$",
"source",
",",
"$",
"target",
",",
"$",
"commands",
")",
"{",
"$",
"targetFolder",
"=",
"pathinfo",
"(",
"$",
"target",
",",
"PATHINFO_DIRNAME",
")",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"targetFolder",
")",
")",
"{",
"mkdir",
"(",
"$",
"targetFolder",
",",
"0777",
",",
"true",
")",
";",
"}",
"$",
"this",
"->",
"image",
"=",
"$",
"this",
"->",
"getImagineService",
"(",
")",
"->",
"open",
"(",
"$",
"source",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"analyseCommands",
"(",
"$",
"commands",
")",
"as",
"$",
"command",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"runCommand",
"(",
"$",
"command",
")",
")",
"{",
"continue",
";",
"}",
"$",
"this",
"->",
"runCustomCommand",
"(",
"$",
"command",
")",
";",
"}",
"$",
"this",
"->",
"image",
"->",
"save",
"(",
"$",
"target",
")",
";",
"}"
] |
Process command to image source and save to target
@param string $source
@param string $target
@param string $commands
@return void
|
[
"Process",
"command",
"to",
"image",
"source",
"and",
"save",
"to",
"target"
] |
7461f588bbf12cbf9544a68778541d052b68fd07
|
https://github.com/tck/zf-imageresizer/blob/7461f588bbf12cbf9544a68778541d052b68fd07/src/TckImageResizer/Service/ImageProcessing.php#L82-L97
|
235,226
|
tck/zf-imageresizer
|
src/TckImageResizer/Service/ImageProcessing.php
|
ImageProcessing.process404
|
public function process404($target, $commands)
{
if (file_exists($target)) {
return;
}
$targetFolder = pathinfo($target, PATHINFO_DIRNAME);
if (!file_exists($targetFolder)) {
mkdir($targetFolder, 0777, true);
}
$text = 'Not found';
$backgroundColor = null;
$color = null;
$width = null;
$height = null;
foreach ($this->analyseCommands($commands) as $command) {
if ('thumb' === $command['command'] || 'resize' === $command['command']) {
$width = $command['params'][0];
$height = $command['params'][1];
} elseif ('404' === $command['command']) {
if (isset($command['params'][0]) && UrlSafeBase64::valid($command['params'][0])) {
$text = UrlSafeBase64::decode($command['params'][0]);
}
if (isset($command['params'][1])) {
$backgroundColor = $command['params'][1];
}
if (isset($command['params'][2])) {
$color = $command['params'][2];
}
if (isset($command['params'][3])) {
$width = $command['params'][3];
}
if (isset($command['params'][4])) {
$height = $command['params'][4];
}
}
}
$this->image404($text, $backgroundColor, $color, $width, $height);
$this->image->save($target);
}
|
php
|
public function process404($target, $commands)
{
if (file_exists($target)) {
return;
}
$targetFolder = pathinfo($target, PATHINFO_DIRNAME);
if (!file_exists($targetFolder)) {
mkdir($targetFolder, 0777, true);
}
$text = 'Not found';
$backgroundColor = null;
$color = null;
$width = null;
$height = null;
foreach ($this->analyseCommands($commands) as $command) {
if ('thumb' === $command['command'] || 'resize' === $command['command']) {
$width = $command['params'][0];
$height = $command['params'][1];
} elseif ('404' === $command['command']) {
if (isset($command['params'][0]) && UrlSafeBase64::valid($command['params'][0])) {
$text = UrlSafeBase64::decode($command['params'][0]);
}
if (isset($command['params'][1])) {
$backgroundColor = $command['params'][1];
}
if (isset($command['params'][2])) {
$color = $command['params'][2];
}
if (isset($command['params'][3])) {
$width = $command['params'][3];
}
if (isset($command['params'][4])) {
$height = $command['params'][4];
}
}
}
$this->image404($text, $backgroundColor, $color, $width, $height);
$this->image->save($target);
}
|
[
"public",
"function",
"process404",
"(",
"$",
"target",
",",
"$",
"commands",
")",
"{",
"if",
"(",
"file_exists",
"(",
"$",
"target",
")",
")",
"{",
"return",
";",
"}",
"$",
"targetFolder",
"=",
"pathinfo",
"(",
"$",
"target",
",",
"PATHINFO_DIRNAME",
")",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"targetFolder",
")",
")",
"{",
"mkdir",
"(",
"$",
"targetFolder",
",",
"0777",
",",
"true",
")",
";",
"}",
"$",
"text",
"=",
"'Not found'",
";",
"$",
"backgroundColor",
"=",
"null",
";",
"$",
"color",
"=",
"null",
";",
"$",
"width",
"=",
"null",
";",
"$",
"height",
"=",
"null",
";",
"foreach",
"(",
"$",
"this",
"->",
"analyseCommands",
"(",
"$",
"commands",
")",
"as",
"$",
"command",
")",
"{",
"if",
"(",
"'thumb'",
"===",
"$",
"command",
"[",
"'command'",
"]",
"||",
"'resize'",
"===",
"$",
"command",
"[",
"'command'",
"]",
")",
"{",
"$",
"width",
"=",
"$",
"command",
"[",
"'params'",
"]",
"[",
"0",
"]",
";",
"$",
"height",
"=",
"$",
"command",
"[",
"'params'",
"]",
"[",
"1",
"]",
";",
"}",
"elseif",
"(",
"'404'",
"===",
"$",
"command",
"[",
"'command'",
"]",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"command",
"[",
"'params'",
"]",
"[",
"0",
"]",
")",
"&&",
"UrlSafeBase64",
"::",
"valid",
"(",
"$",
"command",
"[",
"'params'",
"]",
"[",
"0",
"]",
")",
")",
"{",
"$",
"text",
"=",
"UrlSafeBase64",
"::",
"decode",
"(",
"$",
"command",
"[",
"'params'",
"]",
"[",
"0",
"]",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"command",
"[",
"'params'",
"]",
"[",
"1",
"]",
")",
")",
"{",
"$",
"backgroundColor",
"=",
"$",
"command",
"[",
"'params'",
"]",
"[",
"1",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"command",
"[",
"'params'",
"]",
"[",
"2",
"]",
")",
")",
"{",
"$",
"color",
"=",
"$",
"command",
"[",
"'params'",
"]",
"[",
"2",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"command",
"[",
"'params'",
"]",
"[",
"3",
"]",
")",
")",
"{",
"$",
"width",
"=",
"$",
"command",
"[",
"'params'",
"]",
"[",
"3",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"command",
"[",
"'params'",
"]",
"[",
"4",
"]",
")",
")",
"{",
"$",
"height",
"=",
"$",
"command",
"[",
"'params'",
"]",
"[",
"4",
"]",
";",
"}",
"}",
"}",
"$",
"this",
"->",
"image404",
"(",
"$",
"text",
",",
"$",
"backgroundColor",
",",
"$",
"color",
",",
"$",
"width",
",",
"$",
"height",
")",
";",
"$",
"this",
"->",
"image",
"->",
"save",
"(",
"$",
"target",
")",
";",
"}"
] |
Process command to create 404 image and save to target
@param string $target
@param string $commands
@return void
|
[
"Process",
"command",
"to",
"create",
"404",
"image",
"and",
"save",
"to",
"target"
] |
7461f588bbf12cbf9544a68778541d052b68fd07
|
https://github.com/tck/zf-imageresizer/blob/7461f588bbf12cbf9544a68778541d052b68fd07/src/TckImageResizer/Service/ImageProcessing.php#L107-L149
|
235,227
|
tck/zf-imageresizer
|
src/TckImageResizer/Service/ImageProcessing.php
|
ImageProcessing.runCommand
|
protected function runCommand($command)
{
$method = 'image' . ucfirst(strtolower($command['command']));
if (!method_exists($this, $method)) {
return false;
}
call_user_func_array([$this, $method], $command['params']);
return true;
}
|
php
|
protected function runCommand($command)
{
$method = 'image' . ucfirst(strtolower($command['command']));
if (!method_exists($this, $method)) {
return false;
}
call_user_func_array([$this, $method], $command['params']);
return true;
}
|
[
"protected",
"function",
"runCommand",
"(",
"$",
"command",
")",
"{",
"$",
"method",
"=",
"'image'",
".",
"ucfirst",
"(",
"strtolower",
"(",
"$",
"command",
"[",
"'command'",
"]",
")",
")",
";",
"if",
"(",
"!",
"method_exists",
"(",
"$",
"this",
",",
"$",
"method",
")",
")",
"{",
"return",
"false",
";",
"}",
"call_user_func_array",
"(",
"[",
"$",
"this",
",",
"$",
"method",
"]",
",",
"$",
"command",
"[",
"'params'",
"]",
")",
";",
"return",
"true",
";",
"}"
] |
Run command if exists
@param array $command
@return boolean
|
[
"Run",
"command",
"if",
"exists"
] |
7461f588bbf12cbf9544a68778541d052b68fd07
|
https://github.com/tck/zf-imageresizer/blob/7461f588bbf12cbf9544a68778541d052b68fd07/src/TckImageResizer/Service/ImageProcessing.php#L179-L188
|
235,228
|
tck/zf-imageresizer
|
src/TckImageResizer/Service/ImageProcessing.php
|
ImageProcessing.runCustomCommand
|
protected function runCustomCommand($command)
{
if (!CommandRegistry::hasCommand($command['command'])) {
throw new BadMethodCallException('Command "' . $command['command'] . '" not found');
}
$customCommand = CommandRegistry::getCommand($command['command']);
array_unshift($command['params'], $this->image);
call_user_func_array($customCommand, $command['params']);
return true;
}
|
php
|
protected function runCustomCommand($command)
{
if (!CommandRegistry::hasCommand($command['command'])) {
throw new BadMethodCallException('Command "' . $command['command'] . '" not found');
}
$customCommand = CommandRegistry::getCommand($command['command']);
array_unshift($command['params'], $this->image);
call_user_func_array($customCommand, $command['params']);
return true;
}
|
[
"protected",
"function",
"runCustomCommand",
"(",
"$",
"command",
")",
"{",
"if",
"(",
"!",
"CommandRegistry",
"::",
"hasCommand",
"(",
"$",
"command",
"[",
"'command'",
"]",
")",
")",
"{",
"throw",
"new",
"BadMethodCallException",
"(",
"'Command \"'",
".",
"$",
"command",
"[",
"'command'",
"]",
".",
"'\" not found'",
")",
";",
"}",
"$",
"customCommand",
"=",
"CommandRegistry",
"::",
"getCommand",
"(",
"$",
"command",
"[",
"'command'",
"]",
")",
";",
"array_unshift",
"(",
"$",
"command",
"[",
"'params'",
"]",
",",
"$",
"this",
"->",
"image",
")",
";",
"call_user_func_array",
"(",
"$",
"customCommand",
",",
"$",
"command",
"[",
"'params'",
"]",
")",
";",
"return",
"true",
";",
"}"
] |
Run custom command if exists
@param array $command
@return boolean
|
[
"Run",
"custom",
"command",
"if",
"exists"
] |
7461f588bbf12cbf9544a68778541d052b68fd07
|
https://github.com/tck/zf-imageresizer/blob/7461f588bbf12cbf9544a68778541d052b68fd07/src/TckImageResizer/Service/ImageProcessing.php#L197-L208
|
235,229
|
tck/zf-imageresizer
|
src/TckImageResizer/Service/ImageProcessing.php
|
ImageProcessing.imageThumb
|
protected function imageThumb($width, $height)
{
$width = (int) $width;
$height = (int) $height;
if ($width <= 0) {
throw new BadMethodCallException('Invalid parameter width for command "thumb"');
}
if ($height <= 0) {
throw new BadMethodCallException('Invalid parameter height for command "thumb"');
}
$this->image = $this->image->thumbnail(new Box($width, $height));
}
|
php
|
protected function imageThumb($width, $height)
{
$width = (int) $width;
$height = (int) $height;
if ($width <= 0) {
throw new BadMethodCallException('Invalid parameter width for command "thumb"');
}
if ($height <= 0) {
throw new BadMethodCallException('Invalid parameter height for command "thumb"');
}
$this->image = $this->image->thumbnail(new Box($width, $height));
}
|
[
"protected",
"function",
"imageThumb",
"(",
"$",
"width",
",",
"$",
"height",
")",
"{",
"$",
"width",
"=",
"(",
"int",
")",
"$",
"width",
";",
"$",
"height",
"=",
"(",
"int",
")",
"$",
"height",
";",
"if",
"(",
"$",
"width",
"<=",
"0",
")",
"{",
"throw",
"new",
"BadMethodCallException",
"(",
"'Invalid parameter width for command \"thumb\"'",
")",
";",
"}",
"if",
"(",
"$",
"height",
"<=",
"0",
")",
"{",
"throw",
"new",
"BadMethodCallException",
"(",
"'Invalid parameter height for command \"thumb\"'",
")",
";",
"}",
"$",
"this",
"->",
"image",
"=",
"$",
"this",
"->",
"image",
"->",
"thumbnail",
"(",
"new",
"Box",
"(",
"$",
"width",
",",
"$",
"height",
")",
")",
";",
"}"
] |
Command image thumb
@param int $width
@param int $height
@return void
|
[
"Command",
"image",
"thumb"
] |
7461f588bbf12cbf9544a68778541d052b68fd07
|
https://github.com/tck/zf-imageresizer/blob/7461f588bbf12cbf9544a68778541d052b68fd07/src/TckImageResizer/Service/ImageProcessing.php#L218-L229
|
235,230
|
tck/zf-imageresizer
|
src/TckImageResizer/Service/ImageProcessing.php
|
ImageProcessing.imageGamma
|
protected function imageGamma($correction)
{
$correction = (float) $correction;
$this->image->effects()->gamma($correction);
}
|
php
|
protected function imageGamma($correction)
{
$correction = (float) $correction;
$this->image->effects()->gamma($correction);
}
|
[
"protected",
"function",
"imageGamma",
"(",
"$",
"correction",
")",
"{",
"$",
"correction",
"=",
"(",
"float",
")",
"$",
"correction",
";",
"$",
"this",
"->",
"image",
"->",
"effects",
"(",
")",
"->",
"gamma",
"(",
"$",
"correction",
")",
";",
"}"
] |
Command image gamma
@param float $correction
@return void
|
[
"Command",
"image",
"gamma"
] |
7461f588bbf12cbf9544a68778541d052b68fd07
|
https://github.com/tck/zf-imageresizer/blob/7461f588bbf12cbf9544a68778541d052b68fd07/src/TckImageResizer/Service/ImageProcessing.php#L279-L284
|
235,231
|
tck/zf-imageresizer
|
src/TckImageResizer/Service/ImageProcessing.php
|
ImageProcessing.imageColorize
|
protected function imageColorize($hexColor)
{
if (strlen($hexColor) != 6 || !preg_match('![0-9abcdef]!i', $hexColor)) {
throw new BadMethodCallException('Invalid parameter color for command "colorize"');
}
$color = $this->image->palette()->color('#' . $hexColor);
$this->image->effects()->colorize($color);
}
|
php
|
protected function imageColorize($hexColor)
{
if (strlen($hexColor) != 6 || !preg_match('![0-9abcdef]!i', $hexColor)) {
throw new BadMethodCallException('Invalid parameter color for command "colorize"');
}
$color = $this->image->palette()->color('#' . $hexColor);
$this->image->effects()->colorize($color);
}
|
[
"protected",
"function",
"imageColorize",
"(",
"$",
"hexColor",
")",
"{",
"if",
"(",
"strlen",
"(",
"$",
"hexColor",
")",
"!=",
"6",
"||",
"!",
"preg_match",
"(",
"'![0-9abcdef]!i'",
",",
"$",
"hexColor",
")",
")",
"{",
"throw",
"new",
"BadMethodCallException",
"(",
"'Invalid parameter color for command \"colorize\"'",
")",
";",
"}",
"$",
"color",
"=",
"$",
"this",
"->",
"image",
"->",
"palette",
"(",
")",
"->",
"color",
"(",
"'#'",
".",
"$",
"hexColor",
")",
";",
"$",
"this",
"->",
"image",
"->",
"effects",
"(",
")",
"->",
"colorize",
"(",
"$",
"color",
")",
";",
"}"
] |
Command image colorize
@param string $hexColor
@return void
|
[
"Command",
"image",
"colorize"
] |
7461f588bbf12cbf9544a68778541d052b68fd07
|
https://github.com/tck/zf-imageresizer/blob/7461f588bbf12cbf9544a68778541d052b68fd07/src/TckImageResizer/Service/ImageProcessing.php#L293-L301
|
235,232
|
tck/zf-imageresizer
|
src/TckImageResizer/Service/ImageProcessing.php
|
ImageProcessing.imageBlur
|
protected function imageBlur($sigma = 1)
{
$sigma = (float) $sigma;
$this->image->effects()->blur($sigma);
}
|
php
|
protected function imageBlur($sigma = 1)
{
$sigma = (float) $sigma;
$this->image->effects()->blur($sigma);
}
|
[
"protected",
"function",
"imageBlur",
"(",
"$",
"sigma",
"=",
"1",
")",
"{",
"$",
"sigma",
"=",
"(",
"float",
")",
"$",
"sigma",
";",
"$",
"this",
"->",
"image",
"->",
"effects",
"(",
")",
"->",
"blur",
"(",
"$",
"sigma",
")",
";",
"}"
] |
Command image blur
@param float $sigma
@return void
|
[
"Command",
"image",
"blur"
] |
7461f588bbf12cbf9544a68778541d052b68fd07
|
https://github.com/tck/zf-imageresizer/blob/7461f588bbf12cbf9544a68778541d052b68fd07/src/TckImageResizer/Service/ImageProcessing.php#L320-L325
|
235,233
|
tck/zf-imageresizer
|
src/TckImageResizer/Service/ImageProcessing.php
|
ImageProcessing.drawCenteredText
|
protected function drawCenteredText($text, $color)
{
$width = $this->image->getSize()->getWidth();
$height = $this->image->getSize()->getHeight();
$fontColor = $this->image->palette()->color('#' . $color);
$fontSize = 48;
$widthFactor = $width > 160 ? 0.8 : 0.9;
$heightFactor = $height > 160 ? 0.8 : 0.9;
do {
$font = $this->getImagineService()
->font(__DIR__ . '/../../../data/font/Roboto-Regular.ttf', $fontSize, $fontColor);
$fontBox = $font->box($text);
$fontSize = round($fontSize * 0.8);
} while ($fontSize > 5
&& ($width * $widthFactor < $fontBox->getWidth() || $height * $heightFactor < $fontBox->getHeight()));
$pointX = max(0, floor(($width - $fontBox->getWidth()) / 2));
$pointY = max(0, floor(($height - $fontBox->getHeight()) / 2));
$this->image->draw()->text($text, $font, new Point($pointX, $pointY));
}
|
php
|
protected function drawCenteredText($text, $color)
{
$width = $this->image->getSize()->getWidth();
$height = $this->image->getSize()->getHeight();
$fontColor = $this->image->palette()->color('#' . $color);
$fontSize = 48;
$widthFactor = $width > 160 ? 0.8 : 0.9;
$heightFactor = $height > 160 ? 0.8 : 0.9;
do {
$font = $this->getImagineService()
->font(__DIR__ . '/../../../data/font/Roboto-Regular.ttf', $fontSize, $fontColor);
$fontBox = $font->box($text);
$fontSize = round($fontSize * 0.8);
} while ($fontSize > 5
&& ($width * $widthFactor < $fontBox->getWidth() || $height * $heightFactor < $fontBox->getHeight()));
$pointX = max(0, floor(($width - $fontBox->getWidth()) / 2));
$pointY = max(0, floor(($height - $fontBox->getHeight()) / 2));
$this->image->draw()->text($text, $font, new Point($pointX, $pointY));
}
|
[
"protected",
"function",
"drawCenteredText",
"(",
"$",
"text",
",",
"$",
"color",
")",
"{",
"$",
"width",
"=",
"$",
"this",
"->",
"image",
"->",
"getSize",
"(",
")",
"->",
"getWidth",
"(",
")",
";",
"$",
"height",
"=",
"$",
"this",
"->",
"image",
"->",
"getSize",
"(",
")",
"->",
"getHeight",
"(",
")",
";",
"$",
"fontColor",
"=",
"$",
"this",
"->",
"image",
"->",
"palette",
"(",
")",
"->",
"color",
"(",
"'#'",
".",
"$",
"color",
")",
";",
"$",
"fontSize",
"=",
"48",
";",
"$",
"widthFactor",
"=",
"$",
"width",
">",
"160",
"?",
"0.8",
":",
"0.9",
";",
"$",
"heightFactor",
"=",
"$",
"height",
">",
"160",
"?",
"0.8",
":",
"0.9",
";",
"do",
"{",
"$",
"font",
"=",
"$",
"this",
"->",
"getImagineService",
"(",
")",
"->",
"font",
"(",
"__DIR__",
".",
"'/../../../data/font/Roboto-Regular.ttf'",
",",
"$",
"fontSize",
",",
"$",
"fontColor",
")",
";",
"$",
"fontBox",
"=",
"$",
"font",
"->",
"box",
"(",
"$",
"text",
")",
";",
"$",
"fontSize",
"=",
"round",
"(",
"$",
"fontSize",
"*",
"0.8",
")",
";",
"}",
"while",
"(",
"$",
"fontSize",
">",
"5",
"&&",
"(",
"$",
"width",
"*",
"$",
"widthFactor",
"<",
"$",
"fontBox",
"->",
"getWidth",
"(",
")",
"||",
"$",
"height",
"*",
"$",
"heightFactor",
"<",
"$",
"fontBox",
"->",
"getHeight",
"(",
")",
")",
")",
";",
"$",
"pointX",
"=",
"max",
"(",
"0",
",",
"floor",
"(",
"(",
"$",
"width",
"-",
"$",
"fontBox",
"->",
"getWidth",
"(",
")",
")",
"/",
"2",
")",
")",
";",
"$",
"pointY",
"=",
"max",
"(",
"0",
",",
"floor",
"(",
"(",
"$",
"height",
"-",
"$",
"fontBox",
"->",
"getHeight",
"(",
")",
")",
"/",
"2",
")",
")",
";",
"$",
"this",
"->",
"image",
"->",
"draw",
"(",
")",
"->",
"text",
"(",
"$",
"text",
",",
"$",
"font",
",",
"new",
"Point",
"(",
"$",
"pointX",
",",
"$",
"pointY",
")",
")",
";",
"}"
] |
Draw centered text in current image
@param string $text
@param string $color
@return void
|
[
"Draw",
"centered",
"text",
"in",
"current",
"image"
] |
7461f588bbf12cbf9544a68778541d052b68fd07
|
https://github.com/tck/zf-imageresizer/blob/7461f588bbf12cbf9544a68778541d052b68fd07/src/TckImageResizer/Service/ImageProcessing.php#L385-L406
|
235,234
|
runcmf/runbb
|
src/RunBB/Model/Admin/Plugins.php
|
Plugins.deactivate
|
public function deactivate($name)
{
$name = Container::get('hooks')->fire('model.plugin.deactivate.name', $name);
$activePlugins = $this->manager->getActivePlugins();
// Check if plugin is actually activated
if (($k = array_search($name, $activePlugins)) !== false) {
$plugin = DB::forTable('plugins')->where('name', $name)->find_one();
if (!$plugin) {
$plugin = DB::forTable('plugins')->create()->set('name', $name);
}
$plugin->set('active', 0);
// Allow additionnal deactivate functions
$this->manager->deactivate($name);
$plugin = Container::get('hooks')->fireDB('model.plugin.deactivate', $plugin);
$plugin->save();
$this->manager->setActivePlugins();
return $plugin;
}
return true;
}
|
php
|
public function deactivate($name)
{
$name = Container::get('hooks')->fire('model.plugin.deactivate.name', $name);
$activePlugins = $this->manager->getActivePlugins();
// Check if plugin is actually activated
if (($k = array_search($name, $activePlugins)) !== false) {
$plugin = DB::forTable('plugins')->where('name', $name)->find_one();
if (!$plugin) {
$plugin = DB::forTable('plugins')->create()->set('name', $name);
}
$plugin->set('active', 0);
// Allow additionnal deactivate functions
$this->manager->deactivate($name);
$plugin = Container::get('hooks')->fireDB('model.plugin.deactivate', $plugin);
$plugin->save();
$this->manager->setActivePlugins();
return $plugin;
}
return true;
}
|
[
"public",
"function",
"deactivate",
"(",
"$",
"name",
")",
"{",
"$",
"name",
"=",
"Container",
"::",
"get",
"(",
"'hooks'",
")",
"->",
"fire",
"(",
"'model.plugin.deactivate.name'",
",",
"$",
"name",
")",
";",
"$",
"activePlugins",
"=",
"$",
"this",
"->",
"manager",
"->",
"getActivePlugins",
"(",
")",
";",
"// Check if plugin is actually activated",
"if",
"(",
"(",
"$",
"k",
"=",
"array_search",
"(",
"$",
"name",
",",
"$",
"activePlugins",
")",
")",
"!==",
"false",
")",
"{",
"$",
"plugin",
"=",
"DB",
"::",
"forTable",
"(",
"'plugins'",
")",
"->",
"where",
"(",
"'name'",
",",
"$",
"name",
")",
"->",
"find_one",
"(",
")",
";",
"if",
"(",
"!",
"$",
"plugin",
")",
"{",
"$",
"plugin",
"=",
"DB",
"::",
"forTable",
"(",
"'plugins'",
")",
"->",
"create",
"(",
")",
"->",
"set",
"(",
"'name'",
",",
"$",
"name",
")",
";",
"}",
"$",
"plugin",
"->",
"set",
"(",
"'active'",
",",
"0",
")",
";",
"// Allow additionnal deactivate functions",
"$",
"this",
"->",
"manager",
"->",
"deactivate",
"(",
"$",
"name",
")",
";",
"$",
"plugin",
"=",
"Container",
"::",
"get",
"(",
"'hooks'",
")",
"->",
"fireDB",
"(",
"'model.plugin.deactivate'",
",",
"$",
"plugin",
")",
";",
"$",
"plugin",
"->",
"save",
"(",
")",
";",
"$",
"this",
"->",
"manager",
"->",
"setActivePlugins",
"(",
")",
";",
"return",
"$",
"plugin",
";",
"}",
"return",
"true",
";",
"}"
] |
Deactivate a plugin
|
[
"Deactivate",
"a",
"plugin"
] |
d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463
|
https://github.com/runcmf/runbb/blob/d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463/src/RunBB/Model/Admin/Plugins.php#L99-L123
|
235,235
|
runcmf/runbb
|
src/RunBB/Model/Admin/Plugins.php
|
Plugins.uninstall
|
public function uninstall($name)
{
$name = Container::get('hooks')->fire('model.plugin.uninstall.name', $name);
$activePlugins = $this->manager->getActivePlugins();
// Check if plugin is disabled, for security
if (!in_array($name, $activePlugins)) {
$plugin = DB::forTable('plugins')->where('name', $name)->find_one();
if ($plugin) {
$plugin->delete();
}
// Allow additional uninstalling functions
$this->manager->uninstall($name);
if (file_exists(ForumEnv::get('FORUM_ROOT').'plugins'.DIRECTORY_SEPARATOR.$name)) {
AdminUtils::deleteFolder(ForumEnv::get('FORUM_ROOT').'plugins'.DIRECTORY_SEPARATOR.$name);
}
$this->manager->setActivePlugins();
}
return true;
}
|
php
|
public function uninstall($name)
{
$name = Container::get('hooks')->fire('model.plugin.uninstall.name', $name);
$activePlugins = $this->manager->getActivePlugins();
// Check if plugin is disabled, for security
if (!in_array($name, $activePlugins)) {
$plugin = DB::forTable('plugins')->where('name', $name)->find_one();
if ($plugin) {
$plugin->delete();
}
// Allow additional uninstalling functions
$this->manager->uninstall($name);
if (file_exists(ForumEnv::get('FORUM_ROOT').'plugins'.DIRECTORY_SEPARATOR.$name)) {
AdminUtils::deleteFolder(ForumEnv::get('FORUM_ROOT').'plugins'.DIRECTORY_SEPARATOR.$name);
}
$this->manager->setActivePlugins();
}
return true;
}
|
[
"public",
"function",
"uninstall",
"(",
"$",
"name",
")",
"{",
"$",
"name",
"=",
"Container",
"::",
"get",
"(",
"'hooks'",
")",
"->",
"fire",
"(",
"'model.plugin.uninstall.name'",
",",
"$",
"name",
")",
";",
"$",
"activePlugins",
"=",
"$",
"this",
"->",
"manager",
"->",
"getActivePlugins",
"(",
")",
";",
"// Check if plugin is disabled, for security",
"if",
"(",
"!",
"in_array",
"(",
"$",
"name",
",",
"$",
"activePlugins",
")",
")",
"{",
"$",
"plugin",
"=",
"DB",
"::",
"forTable",
"(",
"'plugins'",
")",
"->",
"where",
"(",
"'name'",
",",
"$",
"name",
")",
"->",
"find_one",
"(",
")",
";",
"if",
"(",
"$",
"plugin",
")",
"{",
"$",
"plugin",
"->",
"delete",
"(",
")",
";",
"}",
"// Allow additional uninstalling functions",
"$",
"this",
"->",
"manager",
"->",
"uninstall",
"(",
"$",
"name",
")",
";",
"if",
"(",
"file_exists",
"(",
"ForumEnv",
"::",
"get",
"(",
"'FORUM_ROOT'",
")",
".",
"'plugins'",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"name",
")",
")",
"{",
"AdminUtils",
"::",
"deleteFolder",
"(",
"ForumEnv",
"::",
"get",
"(",
"'FORUM_ROOT'",
")",
".",
"'plugins'",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"name",
")",
";",
"}",
"$",
"this",
"->",
"manager",
"->",
"setActivePlugins",
"(",
")",
";",
"}",
"return",
"true",
";",
"}"
] |
Uninstall a plugin after deactivated
|
[
"Uninstall",
"a",
"plugin",
"after",
"deactivated"
] |
d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463
|
https://github.com/runcmf/runbb/blob/d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463/src/RunBB/Model/Admin/Plugins.php#L128-L151
|
235,236
|
bitExpert/adroit
|
src/bitExpert/Adroit/Resolver/AbstractResolverMiddleware.php
|
AbstractResolverMiddleware.validateResolvers
|
private function validateResolvers(array $resolvers)
{
foreach ($resolvers as $index => $resolver) {
if (!$this->isValidResolver($resolver)) {
throw new \InvalidArgumentException(sprintf(
'Resolver at index %s of type "%s" is not valid resolver type',
$index,
get_class($resolver)
));
}
}
}
|
php
|
private function validateResolvers(array $resolvers)
{
foreach ($resolvers as $index => $resolver) {
if (!$this->isValidResolver($resolver)) {
throw new \InvalidArgumentException(sprintf(
'Resolver at index %s of type "%s" is not valid resolver type',
$index,
get_class($resolver)
));
}
}
}
|
[
"private",
"function",
"validateResolvers",
"(",
"array",
"$",
"resolvers",
")",
"{",
"foreach",
"(",
"$",
"resolvers",
"as",
"$",
"index",
"=>",
"$",
"resolver",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isValidResolver",
"(",
"$",
"resolver",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Resolver at index %s of type \"%s\" is not valid resolver type'",
",",
"$",
"index",
",",
"get_class",
"(",
"$",
"resolver",
")",
")",
")",
";",
"}",
"}",
"}"
] |
Internal resolver setter which validates the resolvers
@param \bitExpert\Adroit\Resolver\Resolver[] $resolvers
@throws \InvalidArgumentException
|
[
"Internal",
"resolver",
"setter",
"which",
"validates",
"the",
"resolvers"
] |
ecba7e59b864c88bd4639c87194ad842320e5f76
|
https://github.com/bitExpert/adroit/blob/ecba7e59b864c88bd4639c87194ad842320e5f76/src/bitExpert/Adroit/Resolver/AbstractResolverMiddleware.php#L47-L58
|
235,237
|
despark/ignicms
|
src/Models/Image.php
|
Image.__isset
|
public function __isset($key)
{
$result = parent::__isset($key);
if ($result) {
return $result;
}
// if (! $result && $key == 'identifier') {
// $resourceModel = $this->getResourceModel();
// if ($resourceModel && $resourceModel instanceof AdminModel) {
// return ! is_null($resourceModel->getIdentifier());
// }
// }
// If we don't have a value try to find it in metadata
if (! $result && $key != 'meta') {
return isset($this->meta[$key]);
}
}
|
php
|
public function __isset($key)
{
$result = parent::__isset($key);
if ($result) {
return $result;
}
// if (! $result && $key == 'identifier') {
// $resourceModel = $this->getResourceModel();
// if ($resourceModel && $resourceModel instanceof AdminModel) {
// return ! is_null($resourceModel->getIdentifier());
// }
// }
// If we don't have a value try to find it in metadata
if (! $result && $key != 'meta') {
return isset($this->meta[$key]);
}
}
|
[
"public",
"function",
"__isset",
"(",
"$",
"key",
")",
"{",
"$",
"result",
"=",
"parent",
"::",
"__isset",
"(",
"$",
"key",
")",
";",
"if",
"(",
"$",
"result",
")",
"{",
"return",
"$",
"result",
";",
"}",
"// if (! $result && $key == 'identifier') {",
"// $resourceModel = $this->getResourceModel();",
"// if ($resourceModel && $resourceModel instanceof AdminModel) {",
"// return ! is_null($resourceModel->getIdentifier());",
"// }",
"// }",
"// If we don't have a value try to find it in metadata",
"if",
"(",
"!",
"$",
"result",
"&&",
"$",
"key",
"!=",
"'meta'",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"meta",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}"
] |
Override magic isset so we can check for identifier metadata and properties.
@param string $key
@return bool
|
[
"Override",
"magic",
"isset",
"so",
"we",
"can",
"check",
"for",
"identifier",
"metadata",
"and",
"properties",
"."
] |
d55775a4656a7e99017d2ef3f8160599d600d2a7
|
https://github.com/despark/ignicms/blob/d55775a4656a7e99017d2ef3f8160599d600d2a7/src/Models/Image.php#L423-L440
|
235,238
|
accompli/accompli
|
src/Configuration/Configuration.php
|
Configuration.load
|
public function load($configurationFile = null)
{
$this->hosts = array();
$this->configuration = array();
if (isset($configurationFile)) {
$this->configurationFile = $configurationFile;
}
if (file_exists($this->configurationFile) === false) {
throw new InvalidArgumentException(sprintf('The configuration file "%s" is not valid.', $this->configurationFile));
}
$json = file_get_contents($this->configurationFile);
$this->validateSyntax($json);
$json = $this->importExtendedConfiguration($json);
if ($this->validateSchema($json)) {
$this->configuration = json_decode($json, true);
}
$this->processEventSubscribers();
}
|
php
|
public function load($configurationFile = null)
{
$this->hosts = array();
$this->configuration = array();
if (isset($configurationFile)) {
$this->configurationFile = $configurationFile;
}
if (file_exists($this->configurationFile) === false) {
throw new InvalidArgumentException(sprintf('The configuration file "%s" is not valid.', $this->configurationFile));
}
$json = file_get_contents($this->configurationFile);
$this->validateSyntax($json);
$json = $this->importExtendedConfiguration($json);
if ($this->validateSchema($json)) {
$this->configuration = json_decode($json, true);
}
$this->processEventSubscribers();
}
|
[
"public",
"function",
"load",
"(",
"$",
"configurationFile",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"hosts",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"configuration",
"=",
"array",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"configurationFile",
")",
")",
"{",
"$",
"this",
"->",
"configurationFile",
"=",
"$",
"configurationFile",
";",
"}",
"if",
"(",
"file_exists",
"(",
"$",
"this",
"->",
"configurationFile",
")",
"===",
"false",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'The configuration file \"%s\" is not valid.'",
",",
"$",
"this",
"->",
"configurationFile",
")",
")",
";",
"}",
"$",
"json",
"=",
"file_get_contents",
"(",
"$",
"this",
"->",
"configurationFile",
")",
";",
"$",
"this",
"->",
"validateSyntax",
"(",
"$",
"json",
")",
";",
"$",
"json",
"=",
"$",
"this",
"->",
"importExtendedConfiguration",
"(",
"$",
"json",
")",
";",
"if",
"(",
"$",
"this",
"->",
"validateSchema",
"(",
"$",
"json",
")",
")",
"{",
"$",
"this",
"->",
"configuration",
"=",
"json_decode",
"(",
"$",
"json",
",",
"true",
")",
";",
"}",
"$",
"this",
"->",
"processEventSubscribers",
"(",
")",
";",
"}"
] |
Loads and validates the JSON configuration.
@param string|null $configurationFile
@throws InvalidArgumentException
|
[
"Loads",
"and",
"validates",
"the",
"JSON",
"configuration",
"."
] |
618f28377448d8caa90d63bfa5865a3ee15e49e7
|
https://github.com/accompli/accompli/blob/618f28377448d8caa90d63bfa5865a3ee15e49e7/src/Configuration/Configuration.php#L73-L96
|
235,239
|
accompli/accompli
|
src/Configuration/Configuration.php
|
Configuration.processEventSubscribers
|
private function processEventSubscribers()
{
if (isset($this->configuration['events']['subscribers'])) {
foreach ($this->configuration['events']['subscribers'] as $i => $subscriber) {
if (is_string($subscriber)) {
$this->configuration['events']['subscribers'][$i] = array('class' => $subscriber);
}
}
}
}
|
php
|
private function processEventSubscribers()
{
if (isset($this->configuration['events']['subscribers'])) {
foreach ($this->configuration['events']['subscribers'] as $i => $subscriber) {
if (is_string($subscriber)) {
$this->configuration['events']['subscribers'][$i] = array('class' => $subscriber);
}
}
}
}
|
[
"private",
"function",
"processEventSubscribers",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"configuration",
"[",
"'events'",
"]",
"[",
"'subscribers'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"configuration",
"[",
"'events'",
"]",
"[",
"'subscribers'",
"]",
"as",
"$",
"i",
"=>",
"$",
"subscriber",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"subscriber",
")",
")",
"{",
"$",
"this",
"->",
"configuration",
"[",
"'events'",
"]",
"[",
"'subscribers'",
"]",
"[",
"$",
"i",
"]",
"=",
"array",
"(",
"'class'",
"=>",
"$",
"subscriber",
")",
";",
"}",
"}",
"}",
"}"
] |
Processes event subscriber configurations to match the same format.
|
[
"Processes",
"event",
"subscriber",
"configurations",
"to",
"match",
"the",
"same",
"format",
"."
] |
618f28377448d8caa90d63bfa5865a3ee15e49e7
|
https://github.com/accompli/accompli/blob/618f28377448d8caa90d63bfa5865a3ee15e49e7/src/Configuration/Configuration.php#L180-L189
|
235,240
|
accompli/accompli
|
src/Configuration/Configuration.php
|
Configuration.getHosts
|
public function getHosts()
{
if (empty($this->hosts) && isset($this->configuration['hosts'])) {
foreach ($this->configuration['hosts'] as $host) {
$this->hosts[] = ObjectFactory::getInstance()->newInstance(Host::class, $host);
}
}
return $this->hosts;
}
|
php
|
public function getHosts()
{
if (empty($this->hosts) && isset($this->configuration['hosts'])) {
foreach ($this->configuration['hosts'] as $host) {
$this->hosts[] = ObjectFactory::getInstance()->newInstance(Host::class, $host);
}
}
return $this->hosts;
}
|
[
"public",
"function",
"getHosts",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"hosts",
")",
"&&",
"isset",
"(",
"$",
"this",
"->",
"configuration",
"[",
"'hosts'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"configuration",
"[",
"'hosts'",
"]",
"as",
"$",
"host",
")",
"{",
"$",
"this",
"->",
"hosts",
"[",
"]",
"=",
"ObjectFactory",
"::",
"getInstance",
"(",
")",
"->",
"newInstance",
"(",
"Host",
"::",
"class",
",",
"$",
"host",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"hosts",
";",
"}"
] |
Returns the configured hosts.
@return Host[]
|
[
"Returns",
"the",
"configured",
"hosts",
"."
] |
618f28377448d8caa90d63bfa5865a3ee15e49e7
|
https://github.com/accompli/accompli/blob/618f28377448d8caa90d63bfa5865a3ee15e49e7/src/Configuration/Configuration.php#L196-L205
|
235,241
|
shopgate/cart-integration-sdk
|
src/configuration.php
|
ShopgateConfig.loadArray
|
public function loadArray(array $data = array())
{
// if no $data was passed try loading the default configuration file
if (empty($data)) {
$this->loadFile();
return;
}
// if data was passed, map via setters
$unmappedData = parent::loadArray($data);
// put the rest into $this->additionalSettings
$this->mapAdditionalSettings($unmappedData);
}
|
php
|
public function loadArray(array $data = array())
{
// if no $data was passed try loading the default configuration file
if (empty($data)) {
$this->loadFile();
return;
}
// if data was passed, map via setters
$unmappedData = parent::loadArray($data);
// put the rest into $this->additionalSettings
$this->mapAdditionalSettings($unmappedData);
}
|
[
"public",
"function",
"loadArray",
"(",
"array",
"$",
"data",
"=",
"array",
"(",
")",
")",
"{",
"// if no $data was passed try loading the default configuration file",
"if",
"(",
"empty",
"(",
"$",
"data",
")",
")",
"{",
"$",
"this",
"->",
"loadFile",
"(",
")",
";",
"return",
";",
"}",
"// if data was passed, map via setters",
"$",
"unmappedData",
"=",
"parent",
"::",
"loadArray",
"(",
"$",
"data",
")",
";",
"// put the rest into $this->additionalSettings",
"$",
"this",
"->",
"mapAdditionalSettings",
"(",
"$",
"unmappedData",
")",
";",
"}"
] |
Tries to assign the values of an array to the configuration fields or load it from a file.
This overrides ShopgateContainer::loadArray() which is called on object instantiation. It tries to assign
the values of $data to the class attributes by $data's keys. If a key is not the name of a
class attribute it's appended to $this->additionalSettings.<br />
<br />
If $data is empty or not an array, the method calls $this->loadFile().
@param $data array<string, mixed> The data to be assigned to the configuration.
@return void
|
[
"Tries",
"to",
"assign",
"the",
"values",
"of",
"an",
"array",
"to",
"the",
"configuration",
"fields",
"or",
"load",
"it",
"from",
"a",
"file",
"."
] |
cf12ecf8bdb8f4c407209000002fd00261e53b06
|
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/configuration.php#L705-L719
|
235,242
|
shopgate/cart-integration-sdk
|
src/configuration.php
|
ShopgateConfig.loadFile
|
public function loadFile($path = null)
{
$config = null;
// try loading files
if (!empty($path) && file_exists($path)) {
// try $path
$config = $this->includeFile($path);
if (!$config) {
throw new ShopgateLibraryException(
ShopgateLibraryException::CONFIG_READ_WRITE_ERROR,
'The passed configuration file "' . $path . '" does not exist or does not define the $shopgate_config variable.'
);
}
} else {
// try myconfig.php
$config = $this->includeFile($this->buildConfigFilePath());
// if unsuccessful, use default configuration values
if (!$config) {
return;
}
}
// if we got here, we have a $shopgate_config to load
$unmappedData = parent::loadArray($config);
$this->mapAdditionalSettings($unmappedData);
}
|
php
|
public function loadFile($path = null)
{
$config = null;
// try loading files
if (!empty($path) && file_exists($path)) {
// try $path
$config = $this->includeFile($path);
if (!$config) {
throw new ShopgateLibraryException(
ShopgateLibraryException::CONFIG_READ_WRITE_ERROR,
'The passed configuration file "' . $path . '" does not exist or does not define the $shopgate_config variable.'
);
}
} else {
// try myconfig.php
$config = $this->includeFile($this->buildConfigFilePath());
// if unsuccessful, use default configuration values
if (!$config) {
return;
}
}
// if we got here, we have a $shopgate_config to load
$unmappedData = parent::loadArray($config);
$this->mapAdditionalSettings($unmappedData);
}
|
[
"public",
"function",
"loadFile",
"(",
"$",
"path",
"=",
"null",
")",
"{",
"$",
"config",
"=",
"null",
";",
"// try loading files",
"if",
"(",
"!",
"empty",
"(",
"$",
"path",
")",
"&&",
"file_exists",
"(",
"$",
"path",
")",
")",
"{",
"// try $path",
"$",
"config",
"=",
"$",
"this",
"->",
"includeFile",
"(",
"$",
"path",
")",
";",
"if",
"(",
"!",
"$",
"config",
")",
"{",
"throw",
"new",
"ShopgateLibraryException",
"(",
"ShopgateLibraryException",
"::",
"CONFIG_READ_WRITE_ERROR",
",",
"'The passed configuration file \"'",
".",
"$",
"path",
".",
"'\" does not exist or does not define the $shopgate_config variable.'",
")",
";",
"}",
"}",
"else",
"{",
"// try myconfig.php",
"$",
"config",
"=",
"$",
"this",
"->",
"includeFile",
"(",
"$",
"this",
"->",
"buildConfigFilePath",
"(",
")",
")",
";",
"// if unsuccessful, use default configuration values",
"if",
"(",
"!",
"$",
"config",
")",
"{",
"return",
";",
"}",
"}",
"// if we got here, we have a $shopgate_config to load",
"$",
"unmappedData",
"=",
"parent",
"::",
"loadArray",
"(",
"$",
"config",
")",
";",
"$",
"this",
"->",
"mapAdditionalSettings",
"(",
"$",
"unmappedData",
")",
";",
"}"
] |
Tries to load the configuration from a file.
If a $path is passed, this method tries to include the file. If that fails an exception is thrown.<br />
<br />
If $path is empty it tries to load .../shopgate_library/config/myconfig.php or if that fails,
.../shopgate_library/config/config.php is tried to be loaded. If that fails too, an exception is
thrown.<br />
<br />
The configuration file must be a PHP script defining an indexed array called $shopgate_config
containing the desired configuration values to set. If that is not the case, an exception is thrown
@param string $path The path to the configuration file or nothing to load the default Shopgate Cart Integration
SDK configuration files.
@throws ShopgateLibraryException in case a configuration file could not be loaded or the $shopgate_config is not
set.
|
[
"Tries",
"to",
"load",
"the",
"configuration",
"from",
"a",
"file",
"."
] |
cf12ecf8bdb8f4c407209000002fd00261e53b06
|
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/configuration.php#L739-L767
|
235,243
|
shopgate/cart-integration-sdk
|
src/configuration.php
|
ShopgateConfig.loadByShopNumber
|
public function loadByShopNumber($shopNumber)
{
if (empty($shopNumber) || !preg_match($this->coreValidations['shop_number'], $shopNumber)) {
throw new ShopgateLibraryException(
ShopgateLibraryException::CONFIG_READ_WRITE_ERROR,
'configuration file cannot be found without shop number'
);
}
// find all config files
$configFile = null;
$files = scandir(dirname($this->buildConfigFilePath()));
ob_start();
foreach ($files as $file) {
if (!is_file($this->buildConfigFilePath($file))) {
continue;
}
$shopgate_config = null;
/** @noinspection PhpIncludeInspection */
include($this->buildConfigFilePath($file));
if (isset($shopgate_config) && isset($shopgate_config['shop_number'])
&& ($shopgate_config['shop_number'] == $shopNumber)) {
$configFile = $this->buildConfigFilePath($file);
break;
}
}
ob_end_clean();
if (empty($configFile)) {
throw new ShopgateLibraryException(
ShopgateLibraryException::CONFIG_READ_WRITE_ERROR,
'no configuration file found for shop number "' . $shopNumber . '"',
true,
false
);
}
$this->loadFile($configFile);
$this->initFileNames();
}
|
php
|
public function loadByShopNumber($shopNumber)
{
if (empty($shopNumber) || !preg_match($this->coreValidations['shop_number'], $shopNumber)) {
throw new ShopgateLibraryException(
ShopgateLibraryException::CONFIG_READ_WRITE_ERROR,
'configuration file cannot be found without shop number'
);
}
// find all config files
$configFile = null;
$files = scandir(dirname($this->buildConfigFilePath()));
ob_start();
foreach ($files as $file) {
if (!is_file($this->buildConfigFilePath($file))) {
continue;
}
$shopgate_config = null;
/** @noinspection PhpIncludeInspection */
include($this->buildConfigFilePath($file));
if (isset($shopgate_config) && isset($shopgate_config['shop_number'])
&& ($shopgate_config['shop_number'] == $shopNumber)) {
$configFile = $this->buildConfigFilePath($file);
break;
}
}
ob_end_clean();
if (empty($configFile)) {
throw new ShopgateLibraryException(
ShopgateLibraryException::CONFIG_READ_WRITE_ERROR,
'no configuration file found for shop number "' . $shopNumber . '"',
true,
false
);
}
$this->loadFile($configFile);
$this->initFileNames();
}
|
[
"public",
"function",
"loadByShopNumber",
"(",
"$",
"shopNumber",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"shopNumber",
")",
"||",
"!",
"preg_match",
"(",
"$",
"this",
"->",
"coreValidations",
"[",
"'shop_number'",
"]",
",",
"$",
"shopNumber",
")",
")",
"{",
"throw",
"new",
"ShopgateLibraryException",
"(",
"ShopgateLibraryException",
"::",
"CONFIG_READ_WRITE_ERROR",
",",
"'configuration file cannot be found without shop number'",
")",
";",
"}",
"// find all config files",
"$",
"configFile",
"=",
"null",
";",
"$",
"files",
"=",
"scandir",
"(",
"dirname",
"(",
"$",
"this",
"->",
"buildConfigFilePath",
"(",
")",
")",
")",
";",
"ob_start",
"(",
")",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"file",
")",
"{",
"if",
"(",
"!",
"is_file",
"(",
"$",
"this",
"->",
"buildConfigFilePath",
"(",
"$",
"file",
")",
")",
")",
"{",
"continue",
";",
"}",
"$",
"shopgate_config",
"=",
"null",
";",
"/** @noinspection PhpIncludeInspection */",
"include",
"(",
"$",
"this",
"->",
"buildConfigFilePath",
"(",
"$",
"file",
")",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"shopgate_config",
")",
"&&",
"isset",
"(",
"$",
"shopgate_config",
"[",
"'shop_number'",
"]",
")",
"&&",
"(",
"$",
"shopgate_config",
"[",
"'shop_number'",
"]",
"==",
"$",
"shopNumber",
")",
")",
"{",
"$",
"configFile",
"=",
"$",
"this",
"->",
"buildConfigFilePath",
"(",
"$",
"file",
")",
";",
"break",
";",
"}",
"}",
"ob_end_clean",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"configFile",
")",
")",
"{",
"throw",
"new",
"ShopgateLibraryException",
"(",
"ShopgateLibraryException",
"::",
"CONFIG_READ_WRITE_ERROR",
",",
"'no configuration file found for shop number \"'",
".",
"$",
"shopNumber",
".",
"'\"'",
",",
"true",
",",
"false",
")",
";",
"}",
"$",
"this",
"->",
"loadFile",
"(",
"$",
"configFile",
")",
";",
"$",
"this",
"->",
"initFileNames",
"(",
")",
";",
"}"
] |
Loads the configuration file for a given Shopgate shop number.
@param string $shopNumber The shop number.
@throws ShopgateLibraryException in case the $shopNumber is empty or no configuration file can be found.
|
[
"Loads",
"the",
"configuration",
"file",
"for",
"a",
"given",
"Shopgate",
"shop",
"number",
"."
] |
cf12ecf8bdb8f4c407209000002fd00261e53b06
|
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/configuration.php#L776-L815
|
235,244
|
shopgate/cart-integration-sdk
|
src/configuration.php
|
ShopgateConfig.loadByLanguage
|
public function loadByLanguage($language)
{
if (!is_null($language) && !preg_match('/[a-z]{2}/', $language)) {
throw new ShopgateLibraryException(
ShopgateLibraryException::CONFIG_READ_WRITE_ERROR,
'invalid language code "' . $language . '"',
true,
false
);
}
$this->loadFile($this->buildConfigFilePath('myconfig-' . $language . '.php'));
$this->initFileNames();
}
|
php
|
public function loadByLanguage($language)
{
if (!is_null($language) && !preg_match('/[a-z]{2}/', $language)) {
throw new ShopgateLibraryException(
ShopgateLibraryException::CONFIG_READ_WRITE_ERROR,
'invalid language code "' . $language . '"',
true,
false
);
}
$this->loadFile($this->buildConfigFilePath('myconfig-' . $language . '.php'));
$this->initFileNames();
}
|
[
"public",
"function",
"loadByLanguage",
"(",
"$",
"language",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"language",
")",
"&&",
"!",
"preg_match",
"(",
"'/[a-z]{2}/'",
",",
"$",
"language",
")",
")",
"{",
"throw",
"new",
"ShopgateLibraryException",
"(",
"ShopgateLibraryException",
"::",
"CONFIG_READ_WRITE_ERROR",
",",
"'invalid language code \"'",
".",
"$",
"language",
".",
"'\"'",
",",
"true",
",",
"false",
")",
";",
"}",
"$",
"this",
"->",
"loadFile",
"(",
"$",
"this",
"->",
"buildConfigFilePath",
"(",
"'myconfig-'",
".",
"$",
"language",
".",
"'.php'",
")",
")",
";",
"$",
"this",
"->",
"initFileNames",
"(",
")",
";",
"}"
] |
Loads the configuration file by a given language or the global configuration file.
@param string|null $language the ISO-639 code of the language or null to load global configuration
@throws ShopgateLibraryException
|
[
"Loads",
"the",
"configuration",
"file",
"by",
"a",
"given",
"language",
"or",
"the",
"global",
"configuration",
"file",
"."
] |
cf12ecf8bdb8f4c407209000002fd00261e53b06
|
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/configuration.php#L824-L837
|
235,245
|
shopgate/cart-integration-sdk
|
src/configuration.php
|
ShopgateConfig.initFileNames
|
protected function initFileNames()
{
$this->items_csv_filename = 'items-' . $this->language . '.csv';
$this->items_xml_filename = 'items-' . $this->language . '.xml';
$this->items_json_filename = 'items-' . $this->language . '.json';
$this->media_csv_filename = 'media-' . $this->language . '.csv';
$this->categories_csv_filename = 'categories-' . $this->language . '.csv';
$this->categories_xml_filename = 'categories-' . $this->language . '.xml';
$this->categories_json_filename = 'categories-' . $this->language . '.json';
$this->reviews_csv_filename = 'reviews-' . $this->language . '.csv';
$this->access_log_filename = 'access-' . $this->language . '.log';
$this->request_log_filename = 'request-' . $this->language . '.log';
$this->error_log_filename = 'error-' . $this->language . '.log';
$this->debug_log_filename = 'debug-' . $this->language . '.log';
$this->redirect_keyword_cache_filename = 'redirect_keywords-' . $this->language . '.txt';
$this->redirect_skip_keyword_cache_filename = 'skip_redirect_keywords-' . $this->language . '.txt';
}
|
php
|
protected function initFileNames()
{
$this->items_csv_filename = 'items-' . $this->language . '.csv';
$this->items_xml_filename = 'items-' . $this->language . '.xml';
$this->items_json_filename = 'items-' . $this->language . '.json';
$this->media_csv_filename = 'media-' . $this->language . '.csv';
$this->categories_csv_filename = 'categories-' . $this->language . '.csv';
$this->categories_xml_filename = 'categories-' . $this->language . '.xml';
$this->categories_json_filename = 'categories-' . $this->language . '.json';
$this->reviews_csv_filename = 'reviews-' . $this->language . '.csv';
$this->access_log_filename = 'access-' . $this->language . '.log';
$this->request_log_filename = 'request-' . $this->language . '.log';
$this->error_log_filename = 'error-' . $this->language . '.log';
$this->debug_log_filename = 'debug-' . $this->language . '.log';
$this->redirect_keyword_cache_filename = 'redirect_keywords-' . $this->language . '.txt';
$this->redirect_skip_keyword_cache_filename = 'skip_redirect_keywords-' . $this->language . '.txt';
}
|
[
"protected",
"function",
"initFileNames",
"(",
")",
"{",
"$",
"this",
"->",
"items_csv_filename",
"=",
"'items-'",
".",
"$",
"this",
"->",
"language",
".",
"'.csv'",
";",
"$",
"this",
"->",
"items_xml_filename",
"=",
"'items-'",
".",
"$",
"this",
"->",
"language",
".",
"'.xml'",
";",
"$",
"this",
"->",
"items_json_filename",
"=",
"'items-'",
".",
"$",
"this",
"->",
"language",
".",
"'.json'",
";",
"$",
"this",
"->",
"media_csv_filename",
"=",
"'media-'",
".",
"$",
"this",
"->",
"language",
".",
"'.csv'",
";",
"$",
"this",
"->",
"categories_csv_filename",
"=",
"'categories-'",
".",
"$",
"this",
"->",
"language",
".",
"'.csv'",
";",
"$",
"this",
"->",
"categories_xml_filename",
"=",
"'categories-'",
".",
"$",
"this",
"->",
"language",
".",
"'.xml'",
";",
"$",
"this",
"->",
"categories_json_filename",
"=",
"'categories-'",
".",
"$",
"this",
"->",
"language",
".",
"'.json'",
";",
"$",
"this",
"->",
"reviews_csv_filename",
"=",
"'reviews-'",
".",
"$",
"this",
"->",
"language",
".",
"'.csv'",
";",
"$",
"this",
"->",
"access_log_filename",
"=",
"'access-'",
".",
"$",
"this",
"->",
"language",
".",
"'.log'",
";",
"$",
"this",
"->",
"request_log_filename",
"=",
"'request-'",
".",
"$",
"this",
"->",
"language",
".",
"'.log'",
";",
"$",
"this",
"->",
"error_log_filename",
"=",
"'error-'",
".",
"$",
"this",
"->",
"language",
".",
"'.log'",
";",
"$",
"this",
"->",
"debug_log_filename",
"=",
"'debug-'",
".",
"$",
"this",
"->",
"language",
".",
"'.log'",
";",
"$",
"this",
"->",
"redirect_keyword_cache_filename",
"=",
"'redirect_keywords-'",
".",
"$",
"this",
"->",
"language",
".",
"'.txt'",
";",
"$",
"this",
"->",
"redirect_skip_keyword_cache_filename",
"=",
"'skip_redirect_keywords-'",
".",
"$",
"this",
"->",
"language",
".",
"'.txt'",
";",
"}"
] |
Sets the file names according to the language of the configuration.
|
[
"Sets",
"the",
"file",
"names",
"according",
"to",
"the",
"language",
"of",
"the",
"configuration",
"."
] |
cf12ecf8bdb8f4c407209000002fd00261e53b06
|
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/configuration.php#L842-L863
|
235,246
|
shopgate/cart-integration-sdk
|
src/configuration.php
|
ShopgateConfig.saveFile
|
public function saveFile(array $fieldList, $path = null, $validate = true)
{
// if desired, validate before doing anything else
if ($validate) {
$this->validate($fieldList);
}
// preserve values of the fields to save
$saveFields = array();
$currentConfig = $this->toArray();
foreach ($fieldList as $field) {
$saveFields[$field] = (isset($currentConfig[$field]))
? $currentConfig[$field]
: null;
}
// load the current configuration file
try {
$this->loadFile($path);
} catch (ShopgateLibraryException $e) {
ShopgateLogger::getInstance()->log(
'-- Don\'t worry about the "error reading or writing configuration", that was just a routine check during saving.'
);
}
// merge old config with new values
$newConfig = array_merge($this->toArray(), $saveFields);
// default if no path to the configuration file is set
if (empty($path)) {
$path = $this->buildConfigFilePath();
}
// create the array definition string and save it to the file
$shopgateConfigFile = "<?php\n\$shopgate_config = " . var_export($newConfig, true) . ';';
if (!@file_put_contents($path, $shopgateConfigFile)) {
throw new ShopgateLibraryException(
ShopgateLibraryException::CONFIG_READ_WRITE_ERROR,
'The configuration file "' . $path . '" could not be saved.'
);
}
}
|
php
|
public function saveFile(array $fieldList, $path = null, $validate = true)
{
// if desired, validate before doing anything else
if ($validate) {
$this->validate($fieldList);
}
// preserve values of the fields to save
$saveFields = array();
$currentConfig = $this->toArray();
foreach ($fieldList as $field) {
$saveFields[$field] = (isset($currentConfig[$field]))
? $currentConfig[$field]
: null;
}
// load the current configuration file
try {
$this->loadFile($path);
} catch (ShopgateLibraryException $e) {
ShopgateLogger::getInstance()->log(
'-- Don\'t worry about the "error reading or writing configuration", that was just a routine check during saving.'
);
}
// merge old config with new values
$newConfig = array_merge($this->toArray(), $saveFields);
// default if no path to the configuration file is set
if (empty($path)) {
$path = $this->buildConfigFilePath();
}
// create the array definition string and save it to the file
$shopgateConfigFile = "<?php\n\$shopgate_config = " . var_export($newConfig, true) . ';';
if (!@file_put_contents($path, $shopgateConfigFile)) {
throw new ShopgateLibraryException(
ShopgateLibraryException::CONFIG_READ_WRITE_ERROR,
'The configuration file "' . $path . '" could not be saved.'
);
}
}
|
[
"public",
"function",
"saveFile",
"(",
"array",
"$",
"fieldList",
",",
"$",
"path",
"=",
"null",
",",
"$",
"validate",
"=",
"true",
")",
"{",
"// if desired, validate before doing anything else",
"if",
"(",
"$",
"validate",
")",
"{",
"$",
"this",
"->",
"validate",
"(",
"$",
"fieldList",
")",
";",
"}",
"// preserve values of the fields to save",
"$",
"saveFields",
"=",
"array",
"(",
")",
";",
"$",
"currentConfig",
"=",
"$",
"this",
"->",
"toArray",
"(",
")",
";",
"foreach",
"(",
"$",
"fieldList",
"as",
"$",
"field",
")",
"{",
"$",
"saveFields",
"[",
"$",
"field",
"]",
"=",
"(",
"isset",
"(",
"$",
"currentConfig",
"[",
"$",
"field",
"]",
")",
")",
"?",
"$",
"currentConfig",
"[",
"$",
"field",
"]",
":",
"null",
";",
"}",
"// load the current configuration file",
"try",
"{",
"$",
"this",
"->",
"loadFile",
"(",
"$",
"path",
")",
";",
"}",
"catch",
"(",
"ShopgateLibraryException",
"$",
"e",
")",
"{",
"ShopgateLogger",
"::",
"getInstance",
"(",
")",
"->",
"log",
"(",
"'-- Don\\'t worry about the \"error reading or writing configuration\", that was just a routine check during saving.'",
")",
";",
"}",
"// merge old config with new values",
"$",
"newConfig",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"toArray",
"(",
")",
",",
"$",
"saveFields",
")",
";",
"// default if no path to the configuration file is set",
"if",
"(",
"empty",
"(",
"$",
"path",
")",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"buildConfigFilePath",
"(",
")",
";",
"}",
"// create the array definition string and save it to the file",
"$",
"shopgateConfigFile",
"=",
"\"<?php\\n\\$shopgate_config = \"",
".",
"var_export",
"(",
"$",
"newConfig",
",",
"true",
")",
".",
"';'",
";",
"if",
"(",
"!",
"@",
"file_put_contents",
"(",
"$",
"path",
",",
"$",
"shopgateConfigFile",
")",
")",
"{",
"throw",
"new",
"ShopgateLibraryException",
"(",
"ShopgateLibraryException",
"::",
"CONFIG_READ_WRITE_ERROR",
",",
"'The configuration file \"'",
".",
"$",
"path",
".",
"'\" could not be saved.'",
")",
";",
"}",
"}"
] |
Saves the desired configuration fields to the specified file or myconfig.php.
This calls $this->loadFile() with the given $path to load the current configuration. In case that fails, the
$shopgate_config array is initialized empty. The values defined in $fieldList are then validated (if desired),
assigned to $shopgate_config and saved to the specified file or myconfig.php.
In case the file cannot be (over)written or created, an exception with code
ShopgateLibrary::CONFIG_READ_WRITE_ERROR is thrown.
In case the validation fails for one or more fields, an exception with code
ShopgateLibrary::CONFIG_INVALID_VALUE is thrown. The failed fields are appended as additional information in
form of a comma-separated list.
@param string[] $fieldList The list of fieldnames that should be saved to the configuration file.
@param string $path The path to the configuration file or empty to use
.../shopgate_library/config/myconfig.php.
@param bool $validate True to validate the fields that should be set.
@throws ShopgateLibraryException in case the configuration can't be loaded or saved.
|
[
"Saves",
"the",
"desired",
"configuration",
"fields",
"to",
"the",
"specified",
"file",
"or",
"myconfig",
".",
"php",
"."
] |
cf12ecf8bdb8f4c407209000002fd00261e53b06
|
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/configuration.php#L895-L936
|
235,247
|
shopgate/cart-integration-sdk
|
src/configuration.php
|
ShopgateConfig.saveFileForLanguage
|
public function saveFileForLanguage(array $fieldList, $language = null, $validate = true)
{
$fileName = null;
if (!is_null($language)) {
$this->setLanguage($language);
$fieldList[] = 'language';
$fileName = $this->buildConfigFilePath('myconfig-' . $language . '.php');
}
$this->saveFile($fieldList, $fileName, $validate);
}
|
php
|
public function saveFileForLanguage(array $fieldList, $language = null, $validate = true)
{
$fileName = null;
if (!is_null($language)) {
$this->setLanguage($language);
$fieldList[] = 'language';
$fileName = $this->buildConfigFilePath('myconfig-' . $language . '.php');
}
$this->saveFile($fieldList, $fileName, $validate);
}
|
[
"public",
"function",
"saveFileForLanguage",
"(",
"array",
"$",
"fieldList",
",",
"$",
"language",
"=",
"null",
",",
"$",
"validate",
"=",
"true",
")",
"{",
"$",
"fileName",
"=",
"null",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"language",
")",
")",
"{",
"$",
"this",
"->",
"setLanguage",
"(",
"$",
"language",
")",
";",
"$",
"fieldList",
"[",
"]",
"=",
"'language'",
";",
"$",
"fileName",
"=",
"$",
"this",
"->",
"buildConfigFilePath",
"(",
"'myconfig-'",
".",
"$",
"language",
".",
"'.php'",
")",
";",
"}",
"$",
"this",
"->",
"saveFile",
"(",
"$",
"fieldList",
",",
"$",
"fileName",
",",
"$",
"validate",
")",
";",
"}"
] |
Saves the desired fields to the configuration file for a given language or global configuration
@param string[] $fieldList the list of fieldnames that should be saved to the configuration file.
@param string $language the ISO-639 code of the language or null to save to global configuration
@param bool $validate true to validate the fields that should be set.
@throws ShopgateLibraryException in case the configuration can't be loaded or saved.
|
[
"Saves",
"the",
"desired",
"fields",
"to",
"the",
"configuration",
"file",
"for",
"a",
"given",
"language",
"or",
"global",
"configuration"
] |
cf12ecf8bdb8f4c407209000002fd00261e53b06
|
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/configuration.php#L947-L957
|
235,248
|
shopgate/cart-integration-sdk
|
src/configuration.php
|
ShopgateConfig.checkDuplicates
|
public function checkDuplicates()
{
$shopNumbers = array();
$files = scandir(dirname($this->buildConfigFilePath()));
foreach ($files as $file) {
if (!is_file($this->buildConfigFilePath($file))) {
continue;
}
$shopgate_config = null;
/** @noinspection PhpIncludeInspection */
include($this->buildConfigFilePath($file));
if (isset($shopgate_config) && isset($shopgate_config['shop_number'])) {
if (in_array($shopgate_config['shop_number'], $shopNumbers)) {
return true;
} else {
$shopNumbers[] = $shopgate_config['shop_number'];
}
}
}
return false;
}
|
php
|
public function checkDuplicates()
{
$shopNumbers = array();
$files = scandir(dirname($this->buildConfigFilePath()));
foreach ($files as $file) {
if (!is_file($this->buildConfigFilePath($file))) {
continue;
}
$shopgate_config = null;
/** @noinspection PhpIncludeInspection */
include($this->buildConfigFilePath($file));
if (isset($shopgate_config) && isset($shopgate_config['shop_number'])) {
if (in_array($shopgate_config['shop_number'], $shopNumbers)) {
return true;
} else {
$shopNumbers[] = $shopgate_config['shop_number'];
}
}
}
return false;
}
|
[
"public",
"function",
"checkDuplicates",
"(",
")",
"{",
"$",
"shopNumbers",
"=",
"array",
"(",
")",
";",
"$",
"files",
"=",
"scandir",
"(",
"dirname",
"(",
"$",
"this",
"->",
"buildConfigFilePath",
"(",
")",
")",
")",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"file",
")",
"{",
"if",
"(",
"!",
"is_file",
"(",
"$",
"this",
"->",
"buildConfigFilePath",
"(",
"$",
"file",
")",
")",
")",
"{",
"continue",
";",
"}",
"$",
"shopgate_config",
"=",
"null",
";",
"/** @noinspection PhpIncludeInspection */",
"include",
"(",
"$",
"this",
"->",
"buildConfigFilePath",
"(",
"$",
"file",
")",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"shopgate_config",
")",
"&&",
"isset",
"(",
"$",
"shopgate_config",
"[",
"'shop_number'",
"]",
")",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"shopgate_config",
"[",
"'shop_number'",
"]",
",",
"$",
"shopNumbers",
")",
")",
"{",
"return",
"true",
";",
"}",
"else",
"{",
"$",
"shopNumbers",
"[",
"]",
"=",
"$",
"shopgate_config",
"[",
"'shop_number'",
"]",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}"
] |
Checks for duplicate shop numbers in multiple configurations.
This checks all files in the configuration folder and shop numbers in all
configuration files.
@return bool true if there are duplicates, false otherwise.
|
[
"Checks",
"for",
"duplicate",
"shop",
"numbers",
"in",
"multiple",
"configurations",
"."
] |
cf12ecf8bdb8f4c407209000002fd00261e53b06
|
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/configuration.php#L967-L990
|
235,249
|
shopgate/cart-integration-sdk
|
src/configuration.php
|
ShopgateConfig.checkMultipleConfigs
|
public function checkMultipleConfigs()
{
$files = scandir(dirname($this->buildConfigFilePath()));
$counter = 0;
foreach ($files as $file) {
if (!is_file($this->buildConfigFilePath($file))) {
continue;
}
if (substr($file, -4) !== '.php') {
continue;
}
ob_start();
/** @noinspection PhpIncludeInspection */
include($this->buildConfigFilePath($file));
ob_end_clean();
if (!isset($shopgate_config)) {
continue;
}
$counter++;
unset($shopgate_config);
}
return ($counter > 1);
}
|
php
|
public function checkMultipleConfigs()
{
$files = scandir(dirname($this->buildConfigFilePath()));
$counter = 0;
foreach ($files as $file) {
if (!is_file($this->buildConfigFilePath($file))) {
continue;
}
if (substr($file, -4) !== '.php') {
continue;
}
ob_start();
/** @noinspection PhpIncludeInspection */
include($this->buildConfigFilePath($file));
ob_end_clean();
if (!isset($shopgate_config)) {
continue;
}
$counter++;
unset($shopgate_config);
}
return ($counter > 1);
}
|
[
"public",
"function",
"checkMultipleConfigs",
"(",
")",
"{",
"$",
"files",
"=",
"scandir",
"(",
"dirname",
"(",
"$",
"this",
"->",
"buildConfigFilePath",
"(",
")",
")",
")",
";",
"$",
"counter",
"=",
"0",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"file",
")",
"{",
"if",
"(",
"!",
"is_file",
"(",
"$",
"this",
"->",
"buildConfigFilePath",
"(",
"$",
"file",
")",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"substr",
"(",
"$",
"file",
",",
"-",
"4",
")",
"!==",
"'.php'",
")",
"{",
"continue",
";",
"}",
"ob_start",
"(",
")",
";",
"/** @noinspection PhpIncludeInspection */",
"include",
"(",
"$",
"this",
"->",
"buildConfigFilePath",
"(",
"$",
"file",
")",
")",
";",
"ob_end_clean",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"shopgate_config",
")",
")",
"{",
"continue",
";",
"}",
"$",
"counter",
"++",
";",
"unset",
"(",
"$",
"shopgate_config",
")",
";",
"}",
"return",
"(",
"$",
"counter",
">",
"1",
")",
";",
"}"
] |
Checks if there is more than one configuration file available.
@return bool true if multiple configuration files are available, false otherwise.
|
[
"Checks",
"if",
"there",
"is",
"more",
"than",
"one",
"configuration",
"file",
"available",
"."
] |
cf12ecf8bdb8f4c407209000002fd00261e53b06
|
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/configuration.php#L997-L1024
|
235,250
|
shopgate/cart-integration-sdk
|
src/configuration.php
|
ShopgateConfig.useGlobalFor
|
public function useGlobalFor($language)
{
$fileName = $this->buildConfigFilePath('myconfig-' . $language . '.php');
if (file_exists($fileName)) {
if (!@unlink($fileName)) {
throw new ShopgateLibraryException(
ShopgateLibraryException::CONFIG_READ_WRITE_ERROR,
'Error deleting configuration file "' . $fileName . "'."
);
}
}
}
|
php
|
public function useGlobalFor($language)
{
$fileName = $this->buildConfigFilePath('myconfig-' . $language . '.php');
if (file_exists($fileName)) {
if (!@unlink($fileName)) {
throw new ShopgateLibraryException(
ShopgateLibraryException::CONFIG_READ_WRITE_ERROR,
'Error deleting configuration file "' . $fileName . "'."
);
}
}
}
|
[
"public",
"function",
"useGlobalFor",
"(",
"$",
"language",
")",
"{",
"$",
"fileName",
"=",
"$",
"this",
"->",
"buildConfigFilePath",
"(",
"'myconfig-'",
".",
"$",
"language",
".",
"'.php'",
")",
";",
"if",
"(",
"file_exists",
"(",
"$",
"fileName",
")",
")",
"{",
"if",
"(",
"!",
"@",
"unlink",
"(",
"$",
"fileName",
")",
")",
"{",
"throw",
"new",
"ShopgateLibraryException",
"(",
"ShopgateLibraryException",
"::",
"CONFIG_READ_WRITE_ERROR",
",",
"'Error deleting configuration file \"'",
".",
"$",
"fileName",
".",
"\"'.\"",
")",
";",
"}",
"}",
"}"
] |
Removes the configuration file for the language requested.
@param string $language the ISO-639 code of the language or null to load global configuration
@throws ShopgateLibraryException in case the file exists but cannot be deleted.
|
[
"Removes",
"the",
"configuration",
"file",
"for",
"the",
"language",
"requested",
"."
] |
cf12ecf8bdb8f4c407209000002fd00261e53b06
|
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/configuration.php#L1045-L1056
|
235,251
|
shopgate/cart-integration-sdk
|
src/configuration.php
|
ShopgateConfig.mapAdditionalSettings
|
private function mapAdditionalSettings($data = array())
{
foreach ($data as $key => $value) {
$this->additionalSettings[$key] = $value;
}
}
|
php
|
private function mapAdditionalSettings($data = array())
{
foreach ($data as $key => $value) {
$this->additionalSettings[$key] = $value;
}
}
|
[
"private",
"function",
"mapAdditionalSettings",
"(",
"$",
"data",
"=",
"array",
"(",
")",
")",
"{",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"additionalSettings",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"}"
] |
Maps the passed data to the additional settings array.
@param array <string, mixed> $data The data to map.
|
[
"Maps",
"the",
"passed",
"data",
"to",
"the",
"additional",
"settings",
"array",
"."
] |
cf12ecf8bdb8f4c407209000002fd00261e53b06
|
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/configuration.php#L2305-L2310
|
235,252
|
shopgate/cart-integration-sdk
|
src/configuration.php
|
ShopgateConfigOld.deprecated
|
private static function deprecated($methodName)
{
$message = 'Use of ' . $methodName . ' and the whole ShopgateConfigOld class is deprecated.';
trigger_error($message, E_USER_DEPRECATED);
ShopgateLogger::getInstance()->log($message);
}
|
php
|
private static function deprecated($methodName)
{
$message = 'Use of ' . $methodName . ' and the whole ShopgateConfigOld class is deprecated.';
trigger_error($message, E_USER_DEPRECATED);
ShopgateLogger::getInstance()->log($message);
}
|
[
"private",
"static",
"function",
"deprecated",
"(",
"$",
"methodName",
")",
"{",
"$",
"message",
"=",
"'Use of '",
".",
"$",
"methodName",
".",
"' and the whole ShopgateConfigOld class is deprecated.'",
";",
"trigger_error",
"(",
"$",
"message",
",",
"E_USER_DEPRECATED",
")",
";",
"ShopgateLogger",
"::",
"getInstance",
"(",
")",
"->",
"log",
"(",
"$",
"message",
")",
";",
"}"
] |
Issues a PHP deprecated warning and log entry for calls to deprecated ShopgateConfigOld methods.
@param string $methodName The name of the called method.
|
[
"Issues",
"a",
"PHP",
"deprecated",
"warning",
"and",
"log",
"entry",
"for",
"calls",
"to",
"deprecated",
"ShopgateConfigOld",
"methods",
"."
] |
cf12ecf8bdb8f4c407209000002fd00261e53b06
|
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/configuration.php#L2838-L2843
|
235,253
|
mosbth/Anax-MVC
|
src/View/CViewContainerBasic.php
|
CViewContainerBasic.addString
|
public function addString($content, $region = 'main', $sort = 0)
{
$view = $this->di->get('view');
$view->set($content, [], $sort, 'string');
$view->setDI($this->di);
$this->views[$region][] = $view;
return $this;
}
|
php
|
public function addString($content, $region = 'main', $sort = 0)
{
$view = $this->di->get('view');
$view->set($content, [], $sort, 'string');
$view->setDI($this->di);
$this->views[$region][] = $view;
return $this;
}
|
[
"public",
"function",
"addString",
"(",
"$",
"content",
",",
"$",
"region",
"=",
"'main'",
",",
"$",
"sort",
"=",
"0",
")",
"{",
"$",
"view",
"=",
"$",
"this",
"->",
"di",
"->",
"get",
"(",
"'view'",
")",
";",
"$",
"view",
"->",
"set",
"(",
"$",
"content",
",",
"[",
"]",
",",
"$",
"sort",
",",
"'string'",
")",
";",
"$",
"view",
"->",
"setDI",
"(",
"$",
"this",
"->",
"di",
")",
";",
"$",
"this",
"->",
"views",
"[",
"$",
"region",
"]",
"[",
"]",
"=",
"$",
"view",
";",
"return",
"$",
"this",
";",
"}"
] |
Add a string as a view.
@param string $content the content
@param string $region which region to attach the view
@param int $sort which order to display the views
@return $this
|
[
"Add",
"a",
"string",
"as",
"a",
"view",
"."
] |
5574d105bcec9df8e57532a321585f6521b4581c
|
https://github.com/mosbth/Anax-MVC/blob/5574d105bcec9df8e57532a321585f6521b4581c/src/View/CViewContainerBasic.php#L88-L96
|
235,254
|
mosbth/Anax-MVC
|
src/View/CViewContainerBasic.php
|
CViewContainerBasic.setBasePath
|
public function setBasePath($path)
{
if (!is_dir($path)) {
throw new \Exception("Base path for views is not a directory: " . $path);
}
$this->path = rtrim($path, '/') . '/';
}
|
php
|
public function setBasePath($path)
{
if (!is_dir($path)) {
throw new \Exception("Base path for views is not a directory: " . $path);
}
$this->path = rtrim($path, '/') . '/';
}
|
[
"public",
"function",
"setBasePath",
"(",
"$",
"path",
")",
"{",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"path",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Base path for views is not a directory: \"",
".",
"$",
"path",
")",
";",
"}",
"$",
"this",
"->",
"path",
"=",
"rtrim",
"(",
"$",
"path",
",",
"'/'",
")",
".",
"'/'",
";",
"}"
] |
Set base path where to find views.
@param string $path where all views reside
@return $this
@throws \Exception
|
[
"Set",
"base",
"path",
"where",
"to",
"find",
"views",
"."
] |
5574d105bcec9df8e57532a321585f6521b4581c
|
https://github.com/mosbth/Anax-MVC/blob/5574d105bcec9df8e57532a321585f6521b4581c/src/View/CViewContainerBasic.php#L121-L127
|
235,255
|
mosbth/Anax-MVC
|
src/View/CViewContainerBasic.php
|
CViewContainerBasic.render
|
public function render($region = 'main')
{
if (!isset($this->views[$region])) {
return $this;
}
mergesort($this->views[$region], function ($a, $b) {
$sa = $a->sortOrder();
$sb = $b->sortOrder();
if ($sa == $sb) {
return 0;
}
return $sa < $sb ? -1 : 1;
});
foreach ($this->views[$region] as $view) {
$view->render();
}
return $this;
}
|
php
|
public function render($region = 'main')
{
if (!isset($this->views[$region])) {
return $this;
}
mergesort($this->views[$region], function ($a, $b) {
$sa = $a->sortOrder();
$sb = $b->sortOrder();
if ($sa == $sb) {
return 0;
}
return $sa < $sb ? -1 : 1;
});
foreach ($this->views[$region] as $view) {
$view->render();
}
return $this;
}
|
[
"public",
"function",
"render",
"(",
"$",
"region",
"=",
"'main'",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"views",
"[",
"$",
"region",
"]",
")",
")",
"{",
"return",
"$",
"this",
";",
"}",
"mergesort",
"(",
"$",
"this",
"->",
"views",
"[",
"$",
"region",
"]",
",",
"function",
"(",
"$",
"a",
",",
"$",
"b",
")",
"{",
"$",
"sa",
"=",
"$",
"a",
"->",
"sortOrder",
"(",
")",
";",
"$",
"sb",
"=",
"$",
"b",
"->",
"sortOrder",
"(",
")",
";",
"if",
"(",
"$",
"sa",
"==",
"$",
"sb",
")",
"{",
"return",
"0",
";",
"}",
"return",
"$",
"sa",
"<",
"$",
"sb",
"?",
"-",
"1",
":",
"1",
";",
"}",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"views",
"[",
"$",
"region",
"]",
"as",
"$",
"view",
")",
"{",
"$",
"view",
"->",
"render",
"(",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Render all views for a specific region.
@param string $region which region to use
@return $this
|
[
"Render",
"all",
"views",
"for",
"a",
"specific",
"region",
"."
] |
5574d105bcec9df8e57532a321585f6521b4581c
|
https://github.com/mosbth/Anax-MVC/blob/5574d105bcec9df8e57532a321585f6521b4581c/src/View/CViewContainerBasic.php#L152-L174
|
235,256
|
shopgate/cart-integration-sdk
|
src/models/Abstract.php
|
Shopgate_Model_Abstract.getData
|
public function getData($key = '', $index = null)
{
if ('' === $key) {
return $this->data;
}
$default = null;
if (isset($this->data[$key])) {
if (is_null($index)) {
return $this->data[$key];
}
$value = $this->data[$key];
if (is_array($value)) {
if (isset($value[$index])) {
return $value[$index];
}
return null;
}
return $default;
}
return $default;
}
|
php
|
public function getData($key = '', $index = null)
{
if ('' === $key) {
return $this->data;
}
$default = null;
if (isset($this->data[$key])) {
if (is_null($index)) {
return $this->data[$key];
}
$value = $this->data[$key];
if (is_array($value)) {
if (isset($value[$index])) {
return $value[$index];
}
return null;
}
return $default;
}
return $default;
}
|
[
"public",
"function",
"getData",
"(",
"$",
"key",
"=",
"''",
",",
"$",
"index",
"=",
"null",
")",
"{",
"if",
"(",
"''",
"===",
"$",
"key",
")",
"{",
"return",
"$",
"this",
"->",
"data",
";",
"}",
"$",
"default",
"=",
"null",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"data",
"[",
"$",
"key",
"]",
")",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"index",
")",
")",
"{",
"return",
"$",
"this",
"->",
"data",
"[",
"$",
"key",
"]",
";",
"}",
"$",
"value",
"=",
"$",
"this",
"->",
"data",
"[",
"$",
"key",
"]",
";",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"value",
"[",
"$",
"index",
"]",
")",
")",
"{",
"return",
"$",
"value",
"[",
"$",
"index",
"]",
";",
"}",
"return",
"null",
";",
"}",
"return",
"$",
"default",
";",
"}",
"return",
"$",
"default",
";",
"}"
] |
returns data from key or all
@param string $key
@param null $index
@return array|null
|
[
"returns",
"data",
"from",
"key",
"or",
"all"
] |
cf12ecf8bdb8f4c407209000002fd00261e53b06
|
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/models/Abstract.php#L131-L156
|
235,257
|
BugBuster1701/contao-xing-bundle
|
src/Resources/contao/classes/XingImage.php
|
XingImage.getXingImageLink
|
public function getXingImageLink($xinglayout, $xing_source = 'xing_local')
{
$arrXingImageDefinitions= array();
$xingSrcProfile = '//www.xing.com/img/buttons/';
$xingSrcCompany = '//www.xing.com/img/xing/xe/corporate_pages/';
$xingSrcLocal = 'bundles/bugbusterxing/';
if (file_exists(TL_ROOT . "/vendor/bugbuster/contao-xing-bundle/src/Resources/contao/config/xing_image_definitions.php"))
{
include(TL_ROOT . "/vendor/bugbuster/contao-xing-bundle/src/Resources/contao/config/xing_image_definitions.php");
}
if (isset($arrXingImageDefinitions[$xinglayout]))
{
$this->image_file = $arrXingImageDefinitions[$xinglayout]['image_file'];
$this->image_size = $arrXingImageDefinitions[$xinglayout]['image_size'];
$this->image_title = $arrXingImageDefinitions[$xinglayout]['image_title'];
}
if ('xing_local' == $xing_source || '' == $xing_source)
{
$xingSrcProfile = $xingSrcLocal;
$xingSrcCompany = $xingSrcLocal;
}
if ($xinglayout < 999)
{
$xing_images = '<img src="'.$xingSrcProfile.$this->image_file.'" '.$this->image_size.' alt="XING" title="'.$this->image_title.'">';
}
else
{
$xing_images = '<img src="'.$xingSrcCompany.$this->image_file.'" '.$this->image_size.' alt="XING" title="'.$this->image_title.'">';
}
return $xing_images;
}
|
php
|
public function getXingImageLink($xinglayout, $xing_source = 'xing_local')
{
$arrXingImageDefinitions= array();
$xingSrcProfile = '//www.xing.com/img/buttons/';
$xingSrcCompany = '//www.xing.com/img/xing/xe/corporate_pages/';
$xingSrcLocal = 'bundles/bugbusterxing/';
if (file_exists(TL_ROOT . "/vendor/bugbuster/contao-xing-bundle/src/Resources/contao/config/xing_image_definitions.php"))
{
include(TL_ROOT . "/vendor/bugbuster/contao-xing-bundle/src/Resources/contao/config/xing_image_definitions.php");
}
if (isset($arrXingImageDefinitions[$xinglayout]))
{
$this->image_file = $arrXingImageDefinitions[$xinglayout]['image_file'];
$this->image_size = $arrXingImageDefinitions[$xinglayout]['image_size'];
$this->image_title = $arrXingImageDefinitions[$xinglayout]['image_title'];
}
if ('xing_local' == $xing_source || '' == $xing_source)
{
$xingSrcProfile = $xingSrcLocal;
$xingSrcCompany = $xingSrcLocal;
}
if ($xinglayout < 999)
{
$xing_images = '<img src="'.$xingSrcProfile.$this->image_file.'" '.$this->image_size.' alt="XING" title="'.$this->image_title.'">';
}
else
{
$xing_images = '<img src="'.$xingSrcCompany.$this->image_file.'" '.$this->image_size.' alt="XING" title="'.$this->image_title.'">';
}
return $xing_images;
}
|
[
"public",
"function",
"getXingImageLink",
"(",
"$",
"xinglayout",
",",
"$",
"xing_source",
"=",
"'xing_local'",
")",
"{",
"$",
"arrXingImageDefinitions",
"=",
"array",
"(",
")",
";",
"$",
"xingSrcProfile",
"=",
"'//www.xing.com/img/buttons/'",
";",
"$",
"xingSrcCompany",
"=",
"'//www.xing.com/img/xing/xe/corporate_pages/'",
";",
"$",
"xingSrcLocal",
"=",
"'bundles/bugbusterxing/'",
";",
"if",
"(",
"file_exists",
"(",
"TL_ROOT",
".",
"\"/vendor/bugbuster/contao-xing-bundle/src/Resources/contao/config/xing_image_definitions.php\"",
")",
")",
"{",
"include",
"(",
"TL_ROOT",
".",
"\"/vendor/bugbuster/contao-xing-bundle/src/Resources/contao/config/xing_image_definitions.php\"",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"arrXingImageDefinitions",
"[",
"$",
"xinglayout",
"]",
")",
")",
"{",
"$",
"this",
"->",
"image_file",
"=",
"$",
"arrXingImageDefinitions",
"[",
"$",
"xinglayout",
"]",
"[",
"'image_file'",
"]",
";",
"$",
"this",
"->",
"image_size",
"=",
"$",
"arrXingImageDefinitions",
"[",
"$",
"xinglayout",
"]",
"[",
"'image_size'",
"]",
";",
"$",
"this",
"->",
"image_title",
"=",
"$",
"arrXingImageDefinitions",
"[",
"$",
"xinglayout",
"]",
"[",
"'image_title'",
"]",
";",
"}",
"if",
"(",
"'xing_local'",
"==",
"$",
"xing_source",
"||",
"''",
"==",
"$",
"xing_source",
")",
"{",
"$",
"xingSrcProfile",
"=",
"$",
"xingSrcLocal",
";",
"$",
"xingSrcCompany",
"=",
"$",
"xingSrcLocal",
";",
"}",
"if",
"(",
"$",
"xinglayout",
"<",
"999",
")",
"{",
"$",
"xing_images",
"=",
"'<img src=\"'",
".",
"$",
"xingSrcProfile",
".",
"$",
"this",
"->",
"image_file",
".",
"'\" '",
".",
"$",
"this",
"->",
"image_size",
".",
"' alt=\"XING\" title=\"'",
".",
"$",
"this",
"->",
"image_title",
".",
"'\">'",
";",
"}",
"else",
"{",
"$",
"xing_images",
"=",
"'<img src=\"'",
".",
"$",
"xingSrcCompany",
".",
"$",
"this",
"->",
"image_file",
".",
"'\" '",
".",
"$",
"this",
"->",
"image_size",
".",
"' alt=\"XING\" title=\"'",
".",
"$",
"this",
"->",
"image_title",
".",
"'\">'",
";",
"}",
"return",
"$",
"xing_images",
";",
"}"
] |
get Image Link
|
[
"get",
"Image",
"Link"
] |
e2816a6e6ff439812de6599712c5b8b756e4738a
|
https://github.com/BugBuster1701/contao-xing-bundle/blob/e2816a6e6ff439812de6599712c5b8b756e4738a/src/Resources/contao/classes/XingImage.php#L32-L66
|
235,258
|
shopgate/cart-integration-sdk
|
src/models/AbstractExport.php
|
Shopgate_Model_AbstractExport.generateData
|
public function generateData()
{
foreach ($this->fireMethods as $method) {
$this->log(
"Calling function \"{$method}\": Actual memory usage before method: " .
$this->getMemoryUsageString(),
ShopgateLogger::LOGTYPE_DEBUG
);
$this->{$method}();
}
return $this;
}
|
php
|
public function generateData()
{
foreach ($this->fireMethods as $method) {
$this->log(
"Calling function \"{$method}\": Actual memory usage before method: " .
$this->getMemoryUsageString(),
ShopgateLogger::LOGTYPE_DEBUG
);
$this->{$method}();
}
return $this;
}
|
[
"public",
"function",
"generateData",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"fireMethods",
"as",
"$",
"method",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"\"Calling function \\\"{$method}\\\": Actual memory usage before method: \"",
".",
"$",
"this",
"->",
"getMemoryUsageString",
"(",
")",
",",
"ShopgateLogger",
"::",
"LOGTYPE_DEBUG",
")",
";",
"$",
"this",
"->",
"{",
"$",
"method",
"}",
"(",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
generate data dom object
@return $this
|
[
"generate",
"data",
"dom",
"object"
] |
cf12ecf8bdb8f4c407209000002fd00261e53b06
|
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/models/AbstractExport.php#L134-L146
|
235,259
|
accompli/accompli
|
src/Console/Logger/ConsoleLogger.php
|
ConsoleLogger.getTaskActionStatusSectionFromContext
|
private function getTaskActionStatusSectionFromContext(array $context)
{
$actionStatusSection = '';
if ($this->output->isDecorated()) {
$actionStatusSection = sprintf(self::ANSI_CURSOR_BACKWARD_FORMAT, 1);
}
if (isset($context['event.task.action']) && isset($this->taskActionStatusToOutputMap[$context['event.task.action']])) {
$actionStatusSection = sprintf('[<event-task-action-%1$s>%2$s</event-task-action-%1$s>]', $context['event.task.action'], $this->taskActionStatusToOutputMap[$context['event.task.action']]);
}
return $actionStatusSection;
}
|
php
|
private function getTaskActionStatusSectionFromContext(array $context)
{
$actionStatusSection = '';
if ($this->output->isDecorated()) {
$actionStatusSection = sprintf(self::ANSI_CURSOR_BACKWARD_FORMAT, 1);
}
if (isset($context['event.task.action']) && isset($this->taskActionStatusToOutputMap[$context['event.task.action']])) {
$actionStatusSection = sprintf('[<event-task-action-%1$s>%2$s</event-task-action-%1$s>]', $context['event.task.action'], $this->taskActionStatusToOutputMap[$context['event.task.action']]);
}
return $actionStatusSection;
}
|
[
"private",
"function",
"getTaskActionStatusSectionFromContext",
"(",
"array",
"$",
"context",
")",
"{",
"$",
"actionStatusSection",
"=",
"''",
";",
"if",
"(",
"$",
"this",
"->",
"output",
"->",
"isDecorated",
"(",
")",
")",
"{",
"$",
"actionStatusSection",
"=",
"sprintf",
"(",
"self",
"::",
"ANSI_CURSOR_BACKWARD_FORMAT",
",",
"1",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"context",
"[",
"'event.task.action'",
"]",
")",
"&&",
"isset",
"(",
"$",
"this",
"->",
"taskActionStatusToOutputMap",
"[",
"$",
"context",
"[",
"'event.task.action'",
"]",
"]",
")",
")",
"{",
"$",
"actionStatusSection",
"=",
"sprintf",
"(",
"'[<event-task-action-%1$s>%2$s</event-task-action-%1$s>]'",
",",
"$",
"context",
"[",
"'event.task.action'",
"]",
",",
"$",
"this",
"->",
"taskActionStatusToOutputMap",
"[",
"$",
"context",
"[",
"'event.task.action'",
"]",
"]",
")",
";",
"}",
"return",
"$",
"actionStatusSection",
";",
"}"
] |
Returns the task status section based on the context.
@param array $context
@return string
|
[
"Returns",
"the",
"task",
"status",
"section",
"based",
"on",
"the",
"context",
"."
] |
618f28377448d8caa90d63bfa5865a3ee15e49e7
|
https://github.com/accompli/accompli/blob/618f28377448d8caa90d63bfa5865a3ee15e49e7/src/Console/Logger/ConsoleLogger.php#L233-L244
|
235,260
|
accompli/accompli
|
src/Console/Logger/ConsoleLogger.php
|
ConsoleLogger.getMessageLineCount
|
private function getMessageLineCount($message)
{
$messageLength = FormatterHelper::strlenWithoutDecoration($this->output->getFormatter(), $message);
return ceil($messageLength / $this->getTerminalWidth());
}
|
php
|
private function getMessageLineCount($message)
{
$messageLength = FormatterHelper::strlenWithoutDecoration($this->output->getFormatter(), $message);
return ceil($messageLength / $this->getTerminalWidth());
}
|
[
"private",
"function",
"getMessageLineCount",
"(",
"$",
"message",
")",
"{",
"$",
"messageLength",
"=",
"FormatterHelper",
"::",
"strlenWithoutDecoration",
"(",
"$",
"this",
"->",
"output",
"->",
"getFormatter",
"(",
")",
",",
"$",
"message",
")",
";",
"return",
"ceil",
"(",
"$",
"messageLength",
"/",
"$",
"this",
"->",
"getTerminalWidth",
"(",
")",
")",
";",
"}"
] |
Returns the line count of the message based on the terminal width.
@param string $message
@return int
|
[
"Returns",
"the",
"line",
"count",
"of",
"the",
"message",
"based",
"on",
"the",
"terminal",
"width",
"."
] |
618f28377448d8caa90d63bfa5865a3ee15e49e7
|
https://github.com/accompli/accompli/blob/618f28377448d8caa90d63bfa5865a3ee15e49e7/src/Console/Logger/ConsoleLogger.php#L275-L280
|
235,261
|
silverstripe/silverstripe-versionfeed
|
src/VersionFeed.php
|
VersionFeed.getDiff
|
public function getDiff()
{
$changes = $this->getDiffList($this->owner->Version, 1);
if ($changes && $changes->Count()) {
return $changes->First();
}
return null;
}
|
php
|
public function getDiff()
{
$changes = $this->getDiffList($this->owner->Version, 1);
if ($changes && $changes->Count()) {
return $changes->First();
}
return null;
}
|
[
"public",
"function",
"getDiff",
"(",
")",
"{",
"$",
"changes",
"=",
"$",
"this",
"->",
"getDiffList",
"(",
"$",
"this",
"->",
"owner",
"->",
"Version",
",",
"1",
")",
";",
"if",
"(",
"$",
"changes",
"&&",
"$",
"changes",
"->",
"Count",
"(",
")",
")",
"{",
"return",
"$",
"changes",
"->",
"First",
"(",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Return a single diff representing this version.
Returns the initial version if there is nothing to compare to.
@return DataObject|null Object with relevant fields diffed.
|
[
"Return",
"a",
"single",
"diff",
"representing",
"this",
"version",
".",
"Returns",
"the",
"initial",
"version",
"if",
"there",
"is",
"nothing",
"to",
"compare",
"to",
"."
] |
831f03a2b85602c7a7fba110e0ef51c36ad4f204
|
https://github.com/silverstripe/silverstripe-versionfeed/blob/831f03a2b85602c7a7fba110e0ef51c36ad4f204/src/VersionFeed.php#L161-L169
|
235,262
|
aimeos/ai-admin-extadm
|
controller/extjs/src/Controller/ExtJS/Product/Import/Text/Standard.php
|
Standard.uploadFile
|
public function uploadFile( \stdClass $params )
{
$this->checkParams( $params, array( 'site' ) );
$this->setLocale( $params->site );
$clientFilename = '';
$context = $this->getContext();
$request = $context->getView()->request();
$dest = $this->storeFile( $request, $clientFilename );
$result = (object) array(
'site' => $params->site,
'items' => array(
(object) array(
'job.label' => 'Product text import: ' . $clientFilename,
'job.method' => 'Product_Import_Text.importFile',
'job.parameter' => array(
'site' => $params->site,
'items' => $dest,
),
'job.status' => 1,
),
),
);
$jobController = \Aimeos\Controller\ExtJS\Factory::createController( $context, 'admin/job' );
$jobController->saveItems( $result );
return array(
'items' => $dest,
'success' => true,
);
}
|
php
|
public function uploadFile( \stdClass $params )
{
$this->checkParams( $params, array( 'site' ) );
$this->setLocale( $params->site );
$clientFilename = '';
$context = $this->getContext();
$request = $context->getView()->request();
$dest = $this->storeFile( $request, $clientFilename );
$result = (object) array(
'site' => $params->site,
'items' => array(
(object) array(
'job.label' => 'Product text import: ' . $clientFilename,
'job.method' => 'Product_Import_Text.importFile',
'job.parameter' => array(
'site' => $params->site,
'items' => $dest,
),
'job.status' => 1,
),
),
);
$jobController = \Aimeos\Controller\ExtJS\Factory::createController( $context, 'admin/job' );
$jobController->saveItems( $result );
return array(
'items' => $dest,
'success' => true,
);
}
|
[
"public",
"function",
"uploadFile",
"(",
"\\",
"stdClass",
"$",
"params",
")",
"{",
"$",
"this",
"->",
"checkParams",
"(",
"$",
"params",
",",
"array",
"(",
"'site'",
")",
")",
";",
"$",
"this",
"->",
"setLocale",
"(",
"$",
"params",
"->",
"site",
")",
";",
"$",
"clientFilename",
"=",
"''",
";",
"$",
"context",
"=",
"$",
"this",
"->",
"getContext",
"(",
")",
";",
"$",
"request",
"=",
"$",
"context",
"->",
"getView",
"(",
")",
"->",
"request",
"(",
")",
";",
"$",
"dest",
"=",
"$",
"this",
"->",
"storeFile",
"(",
"$",
"request",
",",
"$",
"clientFilename",
")",
";",
"$",
"result",
"=",
"(",
"object",
")",
"array",
"(",
"'site'",
"=>",
"$",
"params",
"->",
"site",
",",
"'items'",
"=>",
"array",
"(",
"(",
"object",
")",
"array",
"(",
"'job.label'",
"=>",
"'Product text import: '",
".",
"$",
"clientFilename",
",",
"'job.method'",
"=>",
"'Product_Import_Text.importFile'",
",",
"'job.parameter'",
"=>",
"array",
"(",
"'site'",
"=>",
"$",
"params",
"->",
"site",
",",
"'items'",
"=>",
"$",
"dest",
",",
")",
",",
"'job.status'",
"=>",
"1",
",",
")",
",",
")",
",",
")",
";",
"$",
"jobController",
"=",
"\\",
"Aimeos",
"\\",
"Controller",
"\\",
"ExtJS",
"\\",
"Factory",
"::",
"createController",
"(",
"$",
"context",
",",
"'admin/job'",
")",
";",
"$",
"jobController",
"->",
"saveItems",
"(",
"$",
"result",
")",
";",
"return",
"array",
"(",
"'items'",
"=>",
"$",
"dest",
",",
"'success'",
"=>",
"true",
",",
")",
";",
"}"
] |
Uploads a CSV file with all product texts.
@param \stdClass $params Object containing the properties
|
[
"Uploads",
"a",
"CSV",
"file",
"with",
"all",
"product",
"texts",
"."
] |
594ee7cec90fd63a4773c05c93f353e66d9b3408
|
https://github.com/aimeos/ai-admin-extadm/blob/594ee7cec90fd63a4773c05c93f353e66d9b3408/controller/extjs/src/Controller/ExtJS/Product/Import/Text/Standard.php#L42-L75
|
235,263
|
aimeos/ai-admin-extadm
|
controller/extjs/src/Controller/ExtJS/Product/Import/Text/Standard.php
|
Standard.importFile
|
public function importFile( \stdClass $params )
{
$this->checkParams( $params, array( 'site', 'items' ) );
$this->setLocale( $params->site );
$fs = $this->getContext()->getFilesystemManager()->get( 'fs-admin' );
$items = ( !is_array( $params->items ) ? array( $params->items ) : $params->items );
foreach( $items as $path )
{
$tmpfile = $fs->readf( $path );
/** controller/extjs/product/import/text/standard/container/type
* Container file type storing all language files of the texts to import
*
* When exporting texts, one file or content object is created per
* language. All those files or content objects are put into one container
* file so editors don't have to download one file for each language.
*
* The container file types that are supported by default are:
* * Zip
*
* Extensions implement other container types like spread sheets, XMLs or
* more advanced ways of handling the exported data.
*
* @param string Container file type
* @since 2014.03
* @category Developer
* @category User
* @see controller/extjs/product/import/text/standard/container/format
*/
/** controller/extjs/product/import/text/standard/container/format
* Format of the language files for the texts to import
*
* The exported texts are stored in one file or content object per
* language. The format of that file or content object can be configured
* with this option but most formats are bound to a specific container
* type.
*
* The formats that are supported by default are:
* * CSV (requires container type "Zip")
*
* Extensions implement other container types like spread sheets, XMLs or
* more advanced ways of handling the exported data.
*
* @param string Content file type
* @since 2014.03
* @category Developer
* @category User
* @see controller/extjs/product/import/text/standard/container/type
* @see controller/extjs/product/import/text/standard/container/options
*/
/** controller/extjs/product/import/text/standard/container/options
* Options changing the expected format for the texts to import
*
* Each content format may support some configuration options to change
* the output for that content type.
*
* The options for the CSV content format are:
* * csv-separator, default ','
* * csv-enclosure, default '"'
* * csv-escape, default '"'
* * csv-lineend, default '\n'
*
* For format options provided by other container types implemented by
* extensions, please have a look into the extension documentation.
*
* @param array Associative list of options with the name as key and its value
* @since 2014.03
* @category Developer
* @category User
* @see controller/extjs/product/import/text/standard/container/format
*/
$container = $this->createContainer( $tmpfile, 'controller/extjs/product/import/text/standard/container' );
$textTypeMap = [];
foreach( $this->getTextTypes( 'product' ) as $item ) {
$textTypeMap[$item->getCode()] = $item->getId();
}
foreach( $container as $content ) {
$this->importTextsFromContent( $content, $textTypeMap, 'product' );
}
unlink( $tmpfile );
$fs->rm( $path );
}
return array(
'success' => true,
);
}
|
php
|
public function importFile( \stdClass $params )
{
$this->checkParams( $params, array( 'site', 'items' ) );
$this->setLocale( $params->site );
$fs = $this->getContext()->getFilesystemManager()->get( 'fs-admin' );
$items = ( !is_array( $params->items ) ? array( $params->items ) : $params->items );
foreach( $items as $path )
{
$tmpfile = $fs->readf( $path );
/** controller/extjs/product/import/text/standard/container/type
* Container file type storing all language files of the texts to import
*
* When exporting texts, one file or content object is created per
* language. All those files or content objects are put into one container
* file so editors don't have to download one file for each language.
*
* The container file types that are supported by default are:
* * Zip
*
* Extensions implement other container types like spread sheets, XMLs or
* more advanced ways of handling the exported data.
*
* @param string Container file type
* @since 2014.03
* @category Developer
* @category User
* @see controller/extjs/product/import/text/standard/container/format
*/
/** controller/extjs/product/import/text/standard/container/format
* Format of the language files for the texts to import
*
* The exported texts are stored in one file or content object per
* language. The format of that file or content object can be configured
* with this option but most formats are bound to a specific container
* type.
*
* The formats that are supported by default are:
* * CSV (requires container type "Zip")
*
* Extensions implement other container types like spread sheets, XMLs or
* more advanced ways of handling the exported data.
*
* @param string Content file type
* @since 2014.03
* @category Developer
* @category User
* @see controller/extjs/product/import/text/standard/container/type
* @see controller/extjs/product/import/text/standard/container/options
*/
/** controller/extjs/product/import/text/standard/container/options
* Options changing the expected format for the texts to import
*
* Each content format may support some configuration options to change
* the output for that content type.
*
* The options for the CSV content format are:
* * csv-separator, default ','
* * csv-enclosure, default '"'
* * csv-escape, default '"'
* * csv-lineend, default '\n'
*
* For format options provided by other container types implemented by
* extensions, please have a look into the extension documentation.
*
* @param array Associative list of options with the name as key and its value
* @since 2014.03
* @category Developer
* @category User
* @see controller/extjs/product/import/text/standard/container/format
*/
$container = $this->createContainer( $tmpfile, 'controller/extjs/product/import/text/standard/container' );
$textTypeMap = [];
foreach( $this->getTextTypes( 'product' ) as $item ) {
$textTypeMap[$item->getCode()] = $item->getId();
}
foreach( $container as $content ) {
$this->importTextsFromContent( $content, $textTypeMap, 'product' );
}
unlink( $tmpfile );
$fs->rm( $path );
}
return array(
'success' => true,
);
}
|
[
"public",
"function",
"importFile",
"(",
"\\",
"stdClass",
"$",
"params",
")",
"{",
"$",
"this",
"->",
"checkParams",
"(",
"$",
"params",
",",
"array",
"(",
"'site'",
",",
"'items'",
")",
")",
";",
"$",
"this",
"->",
"setLocale",
"(",
"$",
"params",
"->",
"site",
")",
";",
"$",
"fs",
"=",
"$",
"this",
"->",
"getContext",
"(",
")",
"->",
"getFilesystemManager",
"(",
")",
"->",
"get",
"(",
"'fs-admin'",
")",
";",
"$",
"items",
"=",
"(",
"!",
"is_array",
"(",
"$",
"params",
"->",
"items",
")",
"?",
"array",
"(",
"$",
"params",
"->",
"items",
")",
":",
"$",
"params",
"->",
"items",
")",
";",
"foreach",
"(",
"$",
"items",
"as",
"$",
"path",
")",
"{",
"$",
"tmpfile",
"=",
"$",
"fs",
"->",
"readf",
"(",
"$",
"path",
")",
";",
"/** controller/extjs/product/import/text/standard/container/type\n\t\t\t * Container file type storing all language files of the texts to import\n\t\t\t *\n\t\t\t * When exporting texts, one file or content object is created per\n\t\t\t * language. All those files or content objects are put into one container\n\t\t\t * file so editors don't have to download one file for each language.\n\t\t\t *\n\t\t\t * The container file types that are supported by default are:\n\t\t\t * * Zip\n\t\t\t *\n\t\t\t * Extensions implement other container types like spread sheets, XMLs or\n\t\t\t * more advanced ways of handling the exported data.\n\t\t\t *\n\t\t\t * @param string Container file type\n\t\t\t * @since 2014.03\n\t\t\t * @category Developer\n\t\t\t * @category User\n\t\t\t * @see controller/extjs/product/import/text/standard/container/format\n\t\t\t */",
"/** controller/extjs/product/import/text/standard/container/format\n\t\t\t * Format of the language files for the texts to import\n\t\t\t *\n\t\t\t * The exported texts are stored in one file or content object per\n\t\t\t * language. The format of that file or content object can be configured\n\t\t\t * with this option but most formats are bound to a specific container\n\t\t\t * type.\n\t\t\t *\n\t\t\t * The formats that are supported by default are:\n\t\t\t * * CSV (requires container type \"Zip\")\n\t\t\t *\n\t\t\t * Extensions implement other container types like spread sheets, XMLs or\n\t\t\t * more advanced ways of handling the exported data.\n\t\t\t *\n\t\t\t * @param string Content file type\n\t\t\t * @since 2014.03\n\t\t\t * @category Developer\n\t\t\t * @category User\n\t\t\t * @see controller/extjs/product/import/text/standard/container/type\n\t\t\t * @see controller/extjs/product/import/text/standard/container/options\n\t\t\t */",
"/** controller/extjs/product/import/text/standard/container/options\n\t\t\t * Options changing the expected format for the texts to import\n\t\t\t *\n\t\t\t * Each content format may support some configuration options to change\n\t\t\t * the output for that content type.\n\t\t\t *\n\t\t\t * The options for the CSV content format are:\n\t\t\t * * csv-separator, default ','\n\t\t\t * * csv-enclosure, default '\"'\n\t\t\t * * csv-escape, default '\"'\n\t\t\t * * csv-lineend, default '\\n'\n\t\t\t *\n\t\t\t * For format options provided by other container types implemented by\n\t\t\t * extensions, please have a look into the extension documentation.\n\t\t\t *\n\t\t\t * @param array Associative list of options with the name as key and its value\n\t\t\t * @since 2014.03\n\t\t\t * @category Developer\n\t\t\t * @category User\n\t\t\t * @see controller/extjs/product/import/text/standard/container/format\n\t\t\t */",
"$",
"container",
"=",
"$",
"this",
"->",
"createContainer",
"(",
"$",
"tmpfile",
",",
"'controller/extjs/product/import/text/standard/container'",
")",
";",
"$",
"textTypeMap",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"getTextTypes",
"(",
"'product'",
")",
"as",
"$",
"item",
")",
"{",
"$",
"textTypeMap",
"[",
"$",
"item",
"->",
"getCode",
"(",
")",
"]",
"=",
"$",
"item",
"->",
"getId",
"(",
")",
";",
"}",
"foreach",
"(",
"$",
"container",
"as",
"$",
"content",
")",
"{",
"$",
"this",
"->",
"importTextsFromContent",
"(",
"$",
"content",
",",
"$",
"textTypeMap",
",",
"'product'",
")",
";",
"}",
"unlink",
"(",
"$",
"tmpfile",
")",
";",
"$",
"fs",
"->",
"rm",
"(",
"$",
"path",
")",
";",
"}",
"return",
"array",
"(",
"'success'",
"=>",
"true",
",",
")",
";",
"}"
] |
Imports a CSV file with all product texts.
@param \stdClass $params Object containing the properties
|
[
"Imports",
"a",
"CSV",
"file",
"with",
"all",
"product",
"texts",
"."
] |
594ee7cec90fd63a4773c05c93f353e66d9b3408
|
https://github.com/aimeos/ai-admin-extadm/blob/594ee7cec90fd63a4773c05c93f353e66d9b3408/controller/extjs/src/Controller/ExtJS/Product/Import/Text/Standard.php#L83-L176
|
235,264
|
artkonekt/gears
|
src/Backend/Drivers/CachedDatabase.php
|
CachedDatabase.pkey
|
protected function pkey(string $key, $userId): string
{
return sprintf('%s(%s).%s', self::PREFERENCES_KEY_PREFIX, $userId, $key);
}
|
php
|
protected function pkey(string $key, $userId): string
{
return sprintf('%s(%s).%s', self::PREFERENCES_KEY_PREFIX, $userId, $key);
}
|
[
"protected",
"function",
"pkey",
"(",
"string",
"$",
"key",
",",
"$",
"userId",
")",
":",
"string",
"{",
"return",
"sprintf",
"(",
"'%s(%s).%s'",
",",
"self",
"::",
"PREFERENCES_KEY_PREFIX",
",",
"$",
"userId",
",",
"$",
"key",
")",
";",
"}"
] |
Returns the cache key for a preference for user
@param string $key
@param int $userId
@return string
|
[
"Returns",
"the",
"cache",
"key",
"for",
"a",
"preference",
"for",
"user"
] |
6c006a3e8e334d8100aab768a2a5e807bcac5695
|
https://github.com/artkonekt/gears/blob/6c006a3e8e334d8100aab768a2a5e807bcac5695/src/Backend/Drivers/CachedDatabase.php#L168-L171
|
235,265
|
artkonekt/gears
|
src/Backend/Drivers/CachedDatabase.php
|
CachedDatabase.sforget
|
protected function sforget($key)
{
$keys = is_array($key) ? $key : [$key];
foreach ($keys as $key) {
$this->cache->forget($this->skey($key));
}
$this->cache->forget($this->skey('*'));
}
|
php
|
protected function sforget($key)
{
$keys = is_array($key) ? $key : [$key];
foreach ($keys as $key) {
$this->cache->forget($this->skey($key));
}
$this->cache->forget($this->skey('*'));
}
|
[
"protected",
"function",
"sforget",
"(",
"$",
"key",
")",
"{",
"$",
"keys",
"=",
"is_array",
"(",
"$",
"key",
")",
"?",
"$",
"key",
":",
"[",
"$",
"key",
"]",
";",
"foreach",
"(",
"$",
"keys",
"as",
"$",
"key",
")",
"{",
"$",
"this",
"->",
"cache",
"->",
"forget",
"(",
"$",
"this",
"->",
"skey",
"(",
"$",
"key",
")",
")",
";",
"}",
"$",
"this",
"->",
"cache",
"->",
"forget",
"(",
"$",
"this",
"->",
"skey",
"(",
"'*'",
")",
")",
";",
"}"
] |
Removes a setting from the cache by its key
@param string|array $key One or more keys
|
[
"Removes",
"a",
"setting",
"from",
"the",
"cache",
"by",
"its",
"key"
] |
6c006a3e8e334d8100aab768a2a5e807bcac5695
|
https://github.com/artkonekt/gears/blob/6c006a3e8e334d8100aab768a2a5e807bcac5695/src/Backend/Drivers/CachedDatabase.php#L178-L187
|
235,266
|
artkonekt/gears
|
src/Backend/Drivers/CachedDatabase.php
|
CachedDatabase.pforget
|
protected function pforget($key, $userId)
{
$keys = is_array($key) ? $key : [$key];
foreach ($keys as $key) {
$this->cache->forget($this->pkey($key, $userId));
}
$this->cache->forget($this->pkey('*', $userId));
}
|
php
|
protected function pforget($key, $userId)
{
$keys = is_array($key) ? $key : [$key];
foreach ($keys as $key) {
$this->cache->forget($this->pkey($key, $userId));
}
$this->cache->forget($this->pkey('*', $userId));
}
|
[
"protected",
"function",
"pforget",
"(",
"$",
"key",
",",
"$",
"userId",
")",
"{",
"$",
"keys",
"=",
"is_array",
"(",
"$",
"key",
")",
"?",
"$",
"key",
":",
"[",
"$",
"key",
"]",
";",
"foreach",
"(",
"$",
"keys",
"as",
"$",
"key",
")",
"{",
"$",
"this",
"->",
"cache",
"->",
"forget",
"(",
"$",
"this",
"->",
"pkey",
"(",
"$",
"key",
",",
"$",
"userId",
")",
")",
";",
"}",
"$",
"this",
"->",
"cache",
"->",
"forget",
"(",
"$",
"this",
"->",
"pkey",
"(",
"'*'",
",",
"$",
"userId",
")",
")",
";",
"}"
] |
Removes a preference from the cache by key and user
@param string|array $key One or more keys
@param int $userId
|
[
"Removes",
"a",
"preference",
"from",
"the",
"cache",
"by",
"key",
"and",
"user"
] |
6c006a3e8e334d8100aab768a2a5e807bcac5695
|
https://github.com/artkonekt/gears/blob/6c006a3e8e334d8100aab768a2a5e807bcac5695/src/Backend/Drivers/CachedDatabase.php#L195-L204
|
235,267
|
ZimTis/array-validation
|
src/ValidationBuilder.php
|
ValidationBuilder.buildValidation
|
public static function buildValidation(array $schema, $name = null)
{
$validation = new NestedValidation($name);
foreach ($schema as $key => $value) {
if (!is_array($value)) {
trigger_error('parsing error', E_USER_ERROR);
}
if (self::isNestedValidation($value)) {
$validation->addValidation(self::buildValidation($value, $key));
} else {
$validation->addValidation(self::buildKeyValidation($value, $key));
}
}
return $validation;
}
|
php
|
public static function buildValidation(array $schema, $name = null)
{
$validation = new NestedValidation($name);
foreach ($schema as $key => $value) {
if (!is_array($value)) {
trigger_error('parsing error', E_USER_ERROR);
}
if (self::isNestedValidation($value)) {
$validation->addValidation(self::buildValidation($value, $key));
} else {
$validation->addValidation(self::buildKeyValidation($value, $key));
}
}
return $validation;
}
|
[
"public",
"static",
"function",
"buildValidation",
"(",
"array",
"$",
"schema",
",",
"$",
"name",
"=",
"null",
")",
"{",
"$",
"validation",
"=",
"new",
"NestedValidation",
"(",
"$",
"name",
")",
";",
"foreach",
"(",
"$",
"schema",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"trigger_error",
"(",
"'parsing error'",
",",
"E_USER_ERROR",
")",
";",
"}",
"if",
"(",
"self",
"::",
"isNestedValidation",
"(",
"$",
"value",
")",
")",
"{",
"$",
"validation",
"->",
"addValidation",
"(",
"self",
"::",
"buildValidation",
"(",
"$",
"value",
",",
"$",
"key",
")",
")",
";",
"}",
"else",
"{",
"$",
"validation",
"->",
"addValidation",
"(",
"self",
"::",
"buildKeyValidation",
"(",
"$",
"value",
",",
"$",
"key",
")",
")",
";",
"}",
"}",
"return",
"$",
"validation",
";",
"}"
] |
This function builds a validation acording to the specifgications of the json file
@param array $schema
@param null $name
@return NestedValidation
|
[
"This",
"function",
"builds",
"a",
"validation",
"acording",
"to",
"the",
"specifgications",
"of",
"the",
"json",
"file"
] |
e908e9598d806e7e5a8da5d46480137c474f93fb
|
https://github.com/ZimTis/array-validation/blob/e908e9598d806e7e5a8da5d46480137c474f93fb/src/ValidationBuilder.php#L29-L47
|
235,268
|
ZimTis/array-validation
|
src/ValidationBuilder.php
|
ValidationBuilder.isNestedValidation
|
private static function isNestedValidation(array $value)
{
return !(key_exists(Properties::TYPE, $value) && !is_array($value[Properties::TYPE]));
}
|
php
|
private static function isNestedValidation(array $value)
{
return !(key_exists(Properties::TYPE, $value) && !is_array($value[Properties::TYPE]));
}
|
[
"private",
"static",
"function",
"isNestedValidation",
"(",
"array",
"$",
"value",
")",
"{",
"return",
"!",
"(",
"key_exists",
"(",
"Properties",
"::",
"TYPE",
",",
"$",
"value",
")",
"&&",
"!",
"is_array",
"(",
"$",
"value",
"[",
"Properties",
"::",
"TYPE",
"]",
")",
")",
";",
"}"
] |
Check if the found value is a nestedValidation
@param array $value
@return boolean
@see NestedValidation
|
[
"Check",
"if",
"the",
"found",
"value",
"is",
"a",
"nestedValidation"
] |
e908e9598d806e7e5a8da5d46480137c474f93fb
|
https://github.com/ZimTis/array-validation/blob/e908e9598d806e7e5a8da5d46480137c474f93fb/src/ValidationBuilder.php#L57-L60
|
235,269
|
ZimTis/array-validation
|
src/ValidationBuilder.php
|
ValidationBuilder.buildKeyValidation
|
public static function buildKeyValidation(array $options, $name)
{
if (!key_exists(Properties::TYPE, $options)) {
trigger_error($name . ' must have a type');
}
switch ($options[Properties::TYPE]) {
case Types::STR:
case Types::STRING:
return new StringValidation($name, $options);
case Types::INT:
case Types::INTEGER:
return new IntegerValidation($name, $options);
case Types::FLOAT:
return new FloatValidation($name, $options);
case Types::BOOLEAN:
return new BooleanValidation($name, $options);
case Types::ARRY:
return new ArrayValidation($name, $options);
default:
trigger_error(sprintf('%s is unknown', $options[Properties::TYPE]), E_USER_ERROR);
}
}
|
php
|
public static function buildKeyValidation(array $options, $name)
{
if (!key_exists(Properties::TYPE, $options)) {
trigger_error($name . ' must have a type');
}
switch ($options[Properties::TYPE]) {
case Types::STR:
case Types::STRING:
return new StringValidation($name, $options);
case Types::INT:
case Types::INTEGER:
return new IntegerValidation($name, $options);
case Types::FLOAT:
return new FloatValidation($name, $options);
case Types::BOOLEAN:
return new BooleanValidation($name, $options);
case Types::ARRY:
return new ArrayValidation($name, $options);
default:
trigger_error(sprintf('%s is unknown', $options[Properties::TYPE]), E_USER_ERROR);
}
}
|
[
"public",
"static",
"function",
"buildKeyValidation",
"(",
"array",
"$",
"options",
",",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"key_exists",
"(",
"Properties",
"::",
"TYPE",
",",
"$",
"options",
")",
")",
"{",
"trigger_error",
"(",
"$",
"name",
".",
"' must have a type'",
")",
";",
"}",
"switch",
"(",
"$",
"options",
"[",
"Properties",
"::",
"TYPE",
"]",
")",
"{",
"case",
"Types",
"::",
"STR",
":",
"case",
"Types",
"::",
"STRING",
":",
"return",
"new",
"StringValidation",
"(",
"$",
"name",
",",
"$",
"options",
")",
";",
"case",
"Types",
"::",
"INT",
":",
"case",
"Types",
"::",
"INTEGER",
":",
"return",
"new",
"IntegerValidation",
"(",
"$",
"name",
",",
"$",
"options",
")",
";",
"case",
"Types",
"::",
"FLOAT",
":",
"return",
"new",
"FloatValidation",
"(",
"$",
"name",
",",
"$",
"options",
")",
";",
"case",
"Types",
"::",
"BOOLEAN",
":",
"return",
"new",
"BooleanValidation",
"(",
"$",
"name",
",",
"$",
"options",
")",
";",
"case",
"Types",
"::",
"ARRY",
":",
"return",
"new",
"ArrayValidation",
"(",
"$",
"name",
",",
"$",
"options",
")",
";",
"default",
":",
"trigger_error",
"(",
"sprintf",
"(",
"'%s is unknown'",
",",
"$",
"options",
"[",
"Properties",
"::",
"TYPE",
"]",
")",
",",
"E_USER_ERROR",
")",
";",
"}",
"}"
] |
Builds a KeyValidation
@param array $options
@param string $name
@return \zimtis\arrayvalidation\validations\KeyValidation
|
[
"Builds",
"a",
"KeyValidation"
] |
e908e9598d806e7e5a8da5d46480137c474f93fb
|
https://github.com/ZimTis/array-validation/blob/e908e9598d806e7e5a8da5d46480137c474f93fb/src/ValidationBuilder.php#L70-L92
|
235,270
|
sellerlabs/nucleus
|
src/SellerLabs/Nucleus/Support/Html.php
|
Html.escape
|
public static function escape($string)
{
Arguments::define(
Boa::either(
Boa::either(
Boa::instance(SafeHtmlWrapper::class),
Boa::instance(SafeHtmlProducerInterface::class)
),
Boa::string()
)
)->check($string);
if ($string instanceof SafeHtmlWrapper) {
return $string;
} elseif ($string instanceof SafeHtmlProducerInterface) {
$result = $string->getSafeHtml();
if ($result instanceof SafeHtmlWrapper) {
return $result;
} elseif ($result instanceof SafeHtmlProducerInterface) {
return static::escape($result);
}
throw new CoreException(vsprintf(
'Object of class %s implements SafeHtmlProducerInterface'
. ' but it returned an unsafe type: %s',
[get_class($string), TypeHound::fetch($result)]
));
}
return htmlspecialchars($string, ENT_QUOTES, 'UTF-8');
}
|
php
|
public static function escape($string)
{
Arguments::define(
Boa::either(
Boa::either(
Boa::instance(SafeHtmlWrapper::class),
Boa::instance(SafeHtmlProducerInterface::class)
),
Boa::string()
)
)->check($string);
if ($string instanceof SafeHtmlWrapper) {
return $string;
} elseif ($string instanceof SafeHtmlProducerInterface) {
$result = $string->getSafeHtml();
if ($result instanceof SafeHtmlWrapper) {
return $result;
} elseif ($result instanceof SafeHtmlProducerInterface) {
return static::escape($result);
}
throw new CoreException(vsprintf(
'Object of class %s implements SafeHtmlProducerInterface'
. ' but it returned an unsafe type: %s',
[get_class($string), TypeHound::fetch($result)]
));
}
return htmlspecialchars($string, ENT_QUOTES, 'UTF-8');
}
|
[
"public",
"static",
"function",
"escape",
"(",
"$",
"string",
")",
"{",
"Arguments",
"::",
"define",
"(",
"Boa",
"::",
"either",
"(",
"Boa",
"::",
"either",
"(",
"Boa",
"::",
"instance",
"(",
"SafeHtmlWrapper",
"::",
"class",
")",
",",
"Boa",
"::",
"instance",
"(",
"SafeHtmlProducerInterface",
"::",
"class",
")",
")",
",",
"Boa",
"::",
"string",
"(",
")",
")",
")",
"->",
"check",
"(",
"$",
"string",
")",
";",
"if",
"(",
"$",
"string",
"instanceof",
"SafeHtmlWrapper",
")",
"{",
"return",
"$",
"string",
";",
"}",
"elseif",
"(",
"$",
"string",
"instanceof",
"SafeHtmlProducerInterface",
")",
"{",
"$",
"result",
"=",
"$",
"string",
"->",
"getSafeHtml",
"(",
")",
";",
"if",
"(",
"$",
"result",
"instanceof",
"SafeHtmlWrapper",
")",
"{",
"return",
"$",
"result",
";",
"}",
"elseif",
"(",
"$",
"result",
"instanceof",
"SafeHtmlProducerInterface",
")",
"{",
"return",
"static",
"::",
"escape",
"(",
"$",
"result",
")",
";",
"}",
"throw",
"new",
"CoreException",
"(",
"vsprintf",
"(",
"'Object of class %s implements SafeHtmlProducerInterface'",
".",
"' but it returned an unsafe type: %s'",
",",
"[",
"get_class",
"(",
"$",
"string",
")",
",",
"TypeHound",
"::",
"fetch",
"(",
"$",
"result",
")",
"]",
")",
")",
";",
"}",
"return",
"htmlspecialchars",
"(",
"$",
"string",
",",
"ENT_QUOTES",
",",
"'UTF-8'",
")",
";",
"}"
] |
Escape the provided string.
@param SafeHtmlWrapper|SafeHtmlProducerInterface|string $string
@throws CoreException
@throws InvalidArgumentException
@return SafeHtmlWrapper|string
|
[
"Escape",
"the",
"provided",
"string",
"."
] |
c05d9c23d424a6bd5ab2e29140805cc6e37e4623
|
https://github.com/sellerlabs/nucleus/blob/c05d9c23d424a6bd5ab2e29140805cc6e37e4623/src/SellerLabs/Nucleus/Support/Html.php#L42-L73
|
235,271
|
clacy-builders/calendar-php
|
src/DateTime.php
|
DateTime.forceWorkday
|
public function forceWorkday($next = false)
{
$weekday = $this->format('N');
if ($weekday == 7) $this->addDays(1);
elseif ($weekday == 6) $next ? $this->addDays(2) : $this->addDays(-1);
return $this;
}
|
php
|
public function forceWorkday($next = false)
{
$weekday = $this->format('N');
if ($weekday == 7) $this->addDays(1);
elseif ($weekday == 6) $next ? $this->addDays(2) : $this->addDays(-1);
return $this;
}
|
[
"public",
"function",
"forceWorkday",
"(",
"$",
"next",
"=",
"false",
")",
"{",
"$",
"weekday",
"=",
"$",
"this",
"->",
"format",
"(",
"'N'",
")",
";",
"if",
"(",
"$",
"weekday",
"==",
"7",
")",
"$",
"this",
"->",
"addDays",
"(",
"1",
")",
";",
"elseif",
"(",
"$",
"weekday",
"==",
"6",
")",
"$",
"next",
"?",
"$",
"this",
"->",
"addDays",
"(",
"2",
")",
":",
"$",
"this",
"->",
"addDays",
"(",
"-",
"1",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Sets the current date to the nearest or next workday.
Sunday always becomes monday.
@param string $next if <code>true</code> saturday becomes monday, otherwise friday.
@return DateTime
|
[
"Sets",
"the",
"current",
"date",
"to",
"the",
"nearest",
"or",
"next",
"workday",
"."
] |
9e868c4fa37f6c81da0e7444a8e0da25cc6c9051
|
https://github.com/clacy-builders/calendar-php/blob/9e868c4fa37f6c81da0e7444a8e0da25cc6c9051/src/DateTime.php#L50-L56
|
235,272
|
clacy-builders/calendar-php
|
src/DateTime.php
|
DateTime.formatLocalized
|
public function formatLocalized($format, $encoding = 'UTF-8')
{
$str = strftime($format, $this->getTimestamp());
if ($encoding == 'UTF-8') {
$str = utf8_encode($str);
}
return $str;
}
|
php
|
public function formatLocalized($format, $encoding = 'UTF-8')
{
$str = strftime($format, $this->getTimestamp());
if ($encoding == 'UTF-8') {
$str = utf8_encode($str);
}
return $str;
}
|
[
"public",
"function",
"formatLocalized",
"(",
"$",
"format",
",",
"$",
"encoding",
"=",
"'UTF-8'",
")",
"{",
"$",
"str",
"=",
"strftime",
"(",
"$",
"format",
",",
"$",
"this",
"->",
"getTimestamp",
"(",
")",
")",
";",
"if",
"(",
"$",
"encoding",
"==",
"'UTF-8'",
")",
"{",
"$",
"str",
"=",
"utf8_encode",
"(",
"$",
"str",
")",
";",
"}",
"return",
"$",
"str",
";",
"}"
] |
Returns a string representation according to locale settings.
@link http://php.net/manual/en/function.strftime.php
@link http://php.net/manual/en/class.datetime.php
@param string $format A format string containing specifiers like <code>%a</code>,
<code>%B</code> etc.
@param string $encoding For example 'UTF-8', 'ISO-8859-1'.
@return string
|
[
"Returns",
"a",
"string",
"representation",
"according",
"to",
"locale",
"settings",
"."
] |
9e868c4fa37f6c81da0e7444a8e0da25cc6c9051
|
https://github.com/clacy-builders/calendar-php/blob/9e868c4fa37f6c81da0e7444a8e0da25cc6c9051/src/DateTime.php#L69-L76
|
235,273
|
wasabi-cms/cms
|
src/Model/Table/MenusTable.php
|
MenusTable.getLinkTypes
|
public function getLinkTypes()
{
$event = new Event('Wasabi.Backend.MenuItems.getLinkTypes', $this);
EventManager::instance()->dispatch($event);
$typeExternal = ['type' => 'external'];
$typeCustom = ['type' => 'custom'];
$event->result[__d('wasabi_core', 'General')] = [
json_encode($typeExternal) => __d('wasabi_core', 'External Link'),
json_encode($typeCustom) => __d('wasabi_core', 'Custom Controller Action')
];
return $event->result;
}
|
php
|
public function getLinkTypes()
{
$event = new Event('Wasabi.Backend.MenuItems.getLinkTypes', $this);
EventManager::instance()->dispatch($event);
$typeExternal = ['type' => 'external'];
$typeCustom = ['type' => 'custom'];
$event->result[__d('wasabi_core', 'General')] = [
json_encode($typeExternal) => __d('wasabi_core', 'External Link'),
json_encode($typeCustom) => __d('wasabi_core', 'Custom Controller Action')
];
return $event->result;
}
|
[
"public",
"function",
"getLinkTypes",
"(",
")",
"{",
"$",
"event",
"=",
"new",
"Event",
"(",
"'Wasabi.Backend.MenuItems.getLinkTypes'",
",",
"$",
"this",
")",
";",
"EventManager",
"::",
"instance",
"(",
")",
"->",
"dispatch",
"(",
"$",
"event",
")",
";",
"$",
"typeExternal",
"=",
"[",
"'type'",
"=>",
"'external'",
"]",
";",
"$",
"typeCustom",
"=",
"[",
"'type'",
"=>",
"'custom'",
"]",
";",
"$",
"event",
"->",
"result",
"[",
"__d",
"(",
"'wasabi_core'",
",",
"'General'",
")",
"]",
"=",
"[",
"json_encode",
"(",
"$",
"typeExternal",
")",
"=>",
"__d",
"(",
"'wasabi_core'",
",",
"'External Link'",
")",
",",
"json_encode",
"(",
"$",
"typeCustom",
")",
"=>",
"__d",
"(",
"'wasabi_core'",
",",
"'Custom Controller Action'",
")",
"]",
";",
"return",
"$",
"event",
"->",
"result",
";",
"}"
] |
Get available link types via an Event trigger
This fetches avilable Links from all activated Plugins.
@return array
|
[
"Get",
"available",
"link",
"types",
"via",
"an",
"Event",
"trigger",
"This",
"fetches",
"avilable",
"Links",
"from",
"all",
"activated",
"Plugins",
"."
] |
2787b6422ea1d719cf49951b3253fd0ac31d22ca
|
https://github.com/wasabi-cms/cms/blob/2787b6422ea1d719cf49951b3253fd0ac31d22ca/src/Model/Table/MenusTable.php#L75-L89
|
235,274
|
squire-assistant/dependency-injection
|
Definition.php
|
Definition.replaceArgument
|
public function replaceArgument($index, $argument)
{
if (0 === count($this->arguments)) {
throw new OutOfBoundsException('Cannot replace arguments if none have been configured yet.');
}
if ($index < 0 || $index > count($this->arguments) - 1) {
throw new OutOfBoundsException(sprintf('The index "%d" is not in the range [0, %d].', $index, count($this->arguments) - 1));
}
$this->arguments[$index] = $argument;
return $this;
}
|
php
|
public function replaceArgument($index, $argument)
{
if (0 === count($this->arguments)) {
throw new OutOfBoundsException('Cannot replace arguments if none have been configured yet.');
}
if ($index < 0 || $index > count($this->arguments) - 1) {
throw new OutOfBoundsException(sprintf('The index "%d" is not in the range [0, %d].', $index, count($this->arguments) - 1));
}
$this->arguments[$index] = $argument;
return $this;
}
|
[
"public",
"function",
"replaceArgument",
"(",
"$",
"index",
",",
"$",
"argument",
")",
"{",
"if",
"(",
"0",
"===",
"count",
"(",
"$",
"this",
"->",
"arguments",
")",
")",
"{",
"throw",
"new",
"OutOfBoundsException",
"(",
"'Cannot replace arguments if none have been configured yet.'",
")",
";",
"}",
"if",
"(",
"$",
"index",
"<",
"0",
"||",
"$",
"index",
">",
"count",
"(",
"$",
"this",
"->",
"arguments",
")",
"-",
"1",
")",
"{",
"throw",
"new",
"OutOfBoundsException",
"(",
"sprintf",
"(",
"'The index \"%d\" is not in the range [0, %d].'",
",",
"$",
"index",
",",
"count",
"(",
"$",
"this",
"->",
"arguments",
")",
"-",
"1",
")",
")",
";",
"}",
"$",
"this",
"->",
"arguments",
"[",
"$",
"index",
"]",
"=",
"$",
"argument",
";",
"return",
"$",
"this",
";",
"}"
] |
Sets a specific argument.
@param int $index
@param mixed $argument
@return $this
@throws OutOfBoundsException When the replaced argument does not exist
|
[
"Sets",
"a",
"specific",
"argument",
"."
] |
c61d77bf8814369344fd71b015d7238322126041
|
https://github.com/squire-assistant/dependency-injection/blob/c61d77bf8814369344fd71b015d7238322126041/Definition.php#L199-L212
|
235,275
|
jaredtking/jaqb
|
src/Statement/LimitStatement.php
|
LimitStatement.getLimit
|
public function getLimit()
{
if ($this->max > 0) {
return min($this->max, $this->limit);
}
return $this->limit;
}
|
php
|
public function getLimit()
{
if ($this->max > 0) {
return min($this->max, $this->limit);
}
return $this->limit;
}
|
[
"public",
"function",
"getLimit",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"max",
">",
"0",
")",
"{",
"return",
"min",
"(",
"$",
"this",
"->",
"max",
",",
"$",
"this",
"->",
"limit",
")",
";",
"}",
"return",
"$",
"this",
"->",
"limit",
";",
"}"
] |
Gets the limit.
@return int
|
[
"Gets",
"the",
"limit",
"."
] |
04a853b530fcc12a9863349d3d0da6377d1b9995
|
https://github.com/jaredtking/jaqb/blob/04a853b530fcc12a9863349d3d0da6377d1b9995/src/Statement/LimitStatement.php#L72-L79
|
235,276
|
marando/phpSOFA
|
src/Marando/IAU/iauTaiut1.php
|
iauTaiut1.Taiut1
|
public static function Taiut1($tai1, $tai2, $dta, &$ut11, &$ut12) {
$dtad;
/* Result, safeguarding precision. */
$dtad = $dta / DAYSEC;
if ($tai1 > $tai2) {
$ut11 = $tai1;
$ut12 = $tai2 + $dtad;
}
else {
$ut11 = $tai1 + $dtad;
$ut12 = $tai2;
}
/* Status (always OK). */
return 0;
}
|
php
|
public static function Taiut1($tai1, $tai2, $dta, &$ut11, &$ut12) {
$dtad;
/* Result, safeguarding precision. */
$dtad = $dta / DAYSEC;
if ($tai1 > $tai2) {
$ut11 = $tai1;
$ut12 = $tai2 + $dtad;
}
else {
$ut11 = $tai1 + $dtad;
$ut12 = $tai2;
}
/* Status (always OK). */
return 0;
}
|
[
"public",
"static",
"function",
"Taiut1",
"(",
"$",
"tai1",
",",
"$",
"tai2",
",",
"$",
"dta",
",",
"&",
"$",
"ut11",
",",
"&",
"$",
"ut12",
")",
"{",
"$",
"dtad",
";",
"/* Result, safeguarding precision. */",
"$",
"dtad",
"=",
"$",
"dta",
"/",
"DAYSEC",
";",
"if",
"(",
"$",
"tai1",
">",
"$",
"tai2",
")",
"{",
"$",
"ut11",
"=",
"$",
"tai1",
";",
"$",
"ut12",
"=",
"$",
"tai2",
"+",
"$",
"dtad",
";",
"}",
"else",
"{",
"$",
"ut11",
"=",
"$",
"tai1",
"+",
"$",
"dtad",
";",
"$",
"ut12",
"=",
"$",
"tai2",
";",
"}",
"/* Status (always OK). */",
"return",
"0",
";",
"}"
] |
- - - - - - - - - -
i a u T a i u t 1
- - - - - - - - - -
Time scale transformation: International Atomic Time, TAI, to
Universal Time, UT1.
This function is part of the International Astronomical Union's
SOFA (Standards of Fundamental Astronomy) software collection.
Status: canonical.
Given:
tai1,tai2 double TAI as a 2-part Julian Date
dta double UT1-TAI in seconds
Returned:
ut11,ut12 double UT1 as a 2-part Julian Date
Returned (function value):
int status: 0 = OK
Notes:
1) tai1+tai2 is Julian Date, apportioned in any convenient way
between the two arguments, for example where tai1 is the Julian
Day Number and tai2 is the fraction of a day. The returned
UT11,UT12 follow suit.
2) The argument dta, i.e. UT1-TAI, is an observed quantity, and is
available from IERS tabulations.
Reference:
Explanatory Supplement to the Astronomical Almanac,
P. Kenneth Seidelmann (ed), University Science Books (1992)
This revision: 2013 June 18
SOFA release 2015-02-09
Copyright (C) 2015 IAU SOFA Board. See notes at end.
|
[
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"i",
"a",
"u",
"T",
"a",
"i",
"u",
"t",
"1",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-"
] |
757fa49fe335ae1210eaa7735473fd4388b13f07
|
https://github.com/marando/phpSOFA/blob/757fa49fe335ae1210eaa7735473fd4388b13f07/src/Marando/IAU/iauTaiut1.php#L52-L68
|
235,277
|
10usb/css-lib
|
src/query/Specificity.php
|
Specificity.compare
|
public static function compare($left, $right){
if($left->a != $right->a) return $left->a <=> $right->a;
if($left->b != $right->b) return $left->b <=> $right->b;
if($left->c != $right->c) return $left->c <=> $right->c;
if($left->i < 0 || $right->i < 0) return 0;
return $left->i <=> $right->i;
}
|
php
|
public static function compare($left, $right){
if($left->a != $right->a) return $left->a <=> $right->a;
if($left->b != $right->b) return $left->b <=> $right->b;
if($left->c != $right->c) return $left->c <=> $right->c;
if($left->i < 0 || $right->i < 0) return 0;
return $left->i <=> $right->i;
}
|
[
"public",
"static",
"function",
"compare",
"(",
"$",
"left",
",",
"$",
"right",
")",
"{",
"if",
"(",
"$",
"left",
"->",
"a",
"!=",
"$",
"right",
"->",
"a",
")",
"return",
"$",
"left",
"->",
"a",
"<=>",
"$",
"right",
"->",
"a",
";",
"if",
"(",
"$",
"left",
"->",
"b",
"!=",
"$",
"right",
"->",
"b",
")",
"return",
"$",
"left",
"->",
"b",
"<=>",
"$",
"right",
"->",
"b",
";",
"if",
"(",
"$",
"left",
"->",
"c",
"!=",
"$",
"right",
"->",
"c",
")",
"return",
"$",
"left",
"->",
"c",
"<=>",
"$",
"right",
"->",
"c",
";",
"if",
"(",
"$",
"left",
"->",
"i",
"<",
"0",
"||",
"$",
"right",
"->",
"i",
"<",
"0",
")",
"return",
"0",
";",
"return",
"$",
"left",
"->",
"i",
"<=>",
"$",
"right",
"->",
"i",
";",
"}"
] |
Compares to specificities
@param \csslib\query\Specificity $left
@param \csslib\query\Specificity $right
@return integer
|
[
"Compares",
"to",
"specificities"
] |
6370b1404bae3eecb44c214ed4eaaf33113858dd
|
https://github.com/10usb/css-lib/blob/6370b1404bae3eecb44c214ed4eaaf33113858dd/src/query/Specificity.php#L40-L46
|
235,278
|
10usb/css-lib
|
src/query/Specificity.php
|
Specificity.get
|
public static function get($selector){
$specificity = $selector->hasNext() ? self::get($selector->getNext()) : new self();
if($selector->getIdentification()) $specificity->a++;
if($selector->getClasses()) $specificity->b+= count($selector->getClasses());
if($selector->getAttributes()) $specificity->b+= count($selector->getAttributes());
if($selector->getPseudos()) $specificity->b+= count($selector->getPseudos());
if($selector->getTagName()) $specificity->c++;
return $specificity;
}
|
php
|
public static function get($selector){
$specificity = $selector->hasNext() ? self::get($selector->getNext()) : new self();
if($selector->getIdentification()) $specificity->a++;
if($selector->getClasses()) $specificity->b+= count($selector->getClasses());
if($selector->getAttributes()) $specificity->b+= count($selector->getAttributes());
if($selector->getPseudos()) $specificity->b+= count($selector->getPseudos());
if($selector->getTagName()) $specificity->c++;
return $specificity;
}
|
[
"public",
"static",
"function",
"get",
"(",
"$",
"selector",
")",
"{",
"$",
"specificity",
"=",
"$",
"selector",
"->",
"hasNext",
"(",
")",
"?",
"self",
"::",
"get",
"(",
"$",
"selector",
"->",
"getNext",
"(",
")",
")",
":",
"new",
"self",
"(",
")",
";",
"if",
"(",
"$",
"selector",
"->",
"getIdentification",
"(",
")",
")",
"$",
"specificity",
"->",
"a",
"++",
";",
"if",
"(",
"$",
"selector",
"->",
"getClasses",
"(",
")",
")",
"$",
"specificity",
"->",
"b",
"+=",
"count",
"(",
"$",
"selector",
"->",
"getClasses",
"(",
")",
")",
";",
"if",
"(",
"$",
"selector",
"->",
"getAttributes",
"(",
")",
")",
"$",
"specificity",
"->",
"b",
"+=",
"count",
"(",
"$",
"selector",
"->",
"getAttributes",
"(",
")",
")",
";",
"if",
"(",
"$",
"selector",
"->",
"getPseudos",
"(",
")",
")",
"$",
"specificity",
"->",
"b",
"+=",
"count",
"(",
"$",
"selector",
"->",
"getPseudos",
"(",
")",
")",
";",
"if",
"(",
"$",
"selector",
"->",
"getTagName",
"(",
")",
")",
"$",
"specificity",
"->",
"c",
"++",
";",
"return",
"$",
"specificity",
";",
"}"
] |
Calculated the specificity of a selector
@param \csslib\Selector $selector
@return \csslib\query\Specificity
|
[
"Calculated",
"the",
"specificity",
"of",
"a",
"selector"
] |
6370b1404bae3eecb44c214ed4eaaf33113858dd
|
https://github.com/10usb/css-lib/blob/6370b1404bae3eecb44c214ed4eaaf33113858dd/src/query/Specificity.php#L53-L63
|
235,279
|
EcomDev/phpspec-file-matcher
|
src/MatchLexer.php
|
MatchLexer.supports
|
public function supports($phrase, array $arguments)
{
if (!isset($this->forms[$phrase])) {
return false;
}
$argumentMatch = $this->forms[$phrase];
if ($this->validateNoArgumentsCondition($arguments, $argumentMatch)
|| $this->validateStrictArgumentCountCondition($arguments, $argumentMatch)) {
return false;
}
return true;
}
|
php
|
public function supports($phrase, array $arguments)
{
if (!isset($this->forms[$phrase])) {
return false;
}
$argumentMatch = $this->forms[$phrase];
if ($this->validateNoArgumentsCondition($arguments, $argumentMatch)
|| $this->validateStrictArgumentCountCondition($arguments, $argumentMatch)) {
return false;
}
return true;
}
|
[
"public",
"function",
"supports",
"(",
"$",
"phrase",
",",
"array",
"$",
"arguments",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"forms",
"[",
"$",
"phrase",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"argumentMatch",
"=",
"$",
"this",
"->",
"forms",
"[",
"$",
"phrase",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"validateNoArgumentsCondition",
"(",
"$",
"arguments",
",",
"$",
"argumentMatch",
")",
"||",
"$",
"this",
"->",
"validateStrictArgumentCountCondition",
"(",
"$",
"arguments",
",",
"$",
"argumentMatch",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Validates matcher condition based on specified rules
@param string $phrase
@param mixed[] $arguments
@return bool
|
[
"Validates",
"matcher",
"condition",
"based",
"on",
"specified",
"rules"
] |
5323bf833774c3d9d763bc01cdc7354a2985b47c
|
https://github.com/EcomDev/phpspec-file-matcher/blob/5323bf833774c3d9d763bc01cdc7354a2985b47c/src/MatchLexer.php#L46-L60
|
235,280
|
sasedev/extra-tools-bundle
|
src/Sasedev/ExtraToolsBundle/Command/UpdateTransCommand.php
|
UpdateTransCommand._crawlNode
|
private function _crawlNode(\Twig_Node $node)
{
if ($node instanceof TransNode && !$node->getNode('body') instanceof \Twig_Node_Expression_GetAttr) {
// trans block
$domain = $node->getNode('domain')->getAttribute('value');
$message = $node->getNode('body')->getAttribute('data');
$this->messages->set($message, $this->prefix . $message, $domain);
} elseif ($node instanceof \Twig_Node_Print) {
// trans filter (be carefull of how you chain your filters)
$message = $this->_extractMessage($node->getNode('expr'));
$domain = $this->_extractDomain($node->getNode('expr'));
if ($message !== null && $domain !== null) {
$this->messages->set($message, $this->prefix . $message, $domain);
}
} else {
// continue crawling
foreach ($node as $child) {
if ($child != null) {
$this->_crawlNode($child);
}
}
}
}
|
php
|
private function _crawlNode(\Twig_Node $node)
{
if ($node instanceof TransNode && !$node->getNode('body') instanceof \Twig_Node_Expression_GetAttr) {
// trans block
$domain = $node->getNode('domain')->getAttribute('value');
$message = $node->getNode('body')->getAttribute('data');
$this->messages->set($message, $this->prefix . $message, $domain);
} elseif ($node instanceof \Twig_Node_Print) {
// trans filter (be carefull of how you chain your filters)
$message = $this->_extractMessage($node->getNode('expr'));
$domain = $this->_extractDomain($node->getNode('expr'));
if ($message !== null && $domain !== null) {
$this->messages->set($message, $this->prefix . $message, $domain);
}
} else {
// continue crawling
foreach ($node as $child) {
if ($child != null) {
$this->_crawlNode($child);
}
}
}
}
|
[
"private",
"function",
"_crawlNode",
"(",
"\\",
"Twig_Node",
"$",
"node",
")",
"{",
"if",
"(",
"$",
"node",
"instanceof",
"TransNode",
"&&",
"!",
"$",
"node",
"->",
"getNode",
"(",
"'body'",
")",
"instanceof",
"\\",
"Twig_Node_Expression_GetAttr",
")",
"{",
"// trans block",
"$",
"domain",
"=",
"$",
"node",
"->",
"getNode",
"(",
"'domain'",
")",
"->",
"getAttribute",
"(",
"'value'",
")",
";",
"$",
"message",
"=",
"$",
"node",
"->",
"getNode",
"(",
"'body'",
")",
"->",
"getAttribute",
"(",
"'data'",
")",
";",
"$",
"this",
"->",
"messages",
"->",
"set",
"(",
"$",
"message",
",",
"$",
"this",
"->",
"prefix",
".",
"$",
"message",
",",
"$",
"domain",
")",
";",
"}",
"elseif",
"(",
"$",
"node",
"instanceof",
"\\",
"Twig_Node_Print",
")",
"{",
"// trans filter (be carefull of how you chain your filters)",
"$",
"message",
"=",
"$",
"this",
"->",
"_extractMessage",
"(",
"$",
"node",
"->",
"getNode",
"(",
"'expr'",
")",
")",
";",
"$",
"domain",
"=",
"$",
"this",
"->",
"_extractDomain",
"(",
"$",
"node",
"->",
"getNode",
"(",
"'expr'",
")",
")",
";",
"if",
"(",
"$",
"message",
"!==",
"null",
"&&",
"$",
"domain",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"messages",
"->",
"set",
"(",
"$",
"message",
",",
"$",
"this",
"->",
"prefix",
".",
"$",
"message",
",",
"$",
"domain",
")",
";",
"}",
"}",
"else",
"{",
"// continue crawling",
"foreach",
"(",
"$",
"node",
"as",
"$",
"child",
")",
"{",
"if",
"(",
"$",
"child",
"!=",
"null",
")",
"{",
"$",
"this",
"->",
"_crawlNode",
"(",
"$",
"child",
")",
";",
"}",
"}",
"}",
"}"
] |
Recursive function that extract trans message from a twig tree
@param
\Twig_Node The twig tree root
|
[
"Recursive",
"function",
"that",
"extract",
"trans",
"message",
"from",
"a",
"twig",
"tree"
] |
14037d6b5c8ba9520ffe33f26057e2e53bea7a75
|
https://github.com/sasedev/extra-tools-bundle/blob/14037d6b5c8ba9520ffe33f26057e2e53bea7a75/src/Sasedev/ExtraToolsBundle/Command/UpdateTransCommand.php#L184-L206
|
235,281
|
sasedev/extra-tools-bundle
|
src/Sasedev/ExtraToolsBundle/Command/UpdateTransCommand.php
|
UpdateTransCommand._extractMessage
|
private function _extractMessage(\Twig_Node $node)
{
if ($node->hasNode('node')) {
return $this->_extractMessage($node->getNode('node'));
}
if ($node instanceof \Twig_Node_Expression_Constant) {
return $node->getAttribute('value');
}
return null;
}
|
php
|
private function _extractMessage(\Twig_Node $node)
{
if ($node->hasNode('node')) {
return $this->_extractMessage($node->getNode('node'));
}
if ($node instanceof \Twig_Node_Expression_Constant) {
return $node->getAttribute('value');
}
return null;
}
|
[
"private",
"function",
"_extractMessage",
"(",
"\\",
"Twig_Node",
"$",
"node",
")",
"{",
"if",
"(",
"$",
"node",
"->",
"hasNode",
"(",
"'node'",
")",
")",
"{",
"return",
"$",
"this",
"->",
"_extractMessage",
"(",
"$",
"node",
"->",
"getNode",
"(",
"'node'",
")",
")",
";",
"}",
"if",
"(",
"$",
"node",
"instanceof",
"\\",
"Twig_Node_Expression_Constant",
")",
"{",
"return",
"$",
"node",
"->",
"getAttribute",
"(",
"'value'",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Extract a message from a \Twig_Node_Print
Return null if not a constant message
@param \Twig_Node $node
|
[
"Extract",
"a",
"message",
"from",
"a",
"\\",
"Twig_Node_Print",
"Return",
"null",
"if",
"not",
"a",
"constant",
"message"
] |
14037d6b5c8ba9520ffe33f26057e2e53bea7a75
|
https://github.com/sasedev/extra-tools-bundle/blob/14037d6b5c8ba9520ffe33f26057e2e53bea7a75/src/Sasedev/ExtraToolsBundle/Command/UpdateTransCommand.php#L214-L224
|
235,282
|
sasedev/extra-tools-bundle
|
src/Sasedev/ExtraToolsBundle/Command/UpdateTransCommand.php
|
UpdateTransCommand._extractDomain
|
private function _extractDomain(\Twig_Node $node)
{
// must be a filter node
if (!$node instanceof \Twig_Node_Expression_Filter) {
return null;
}
// is a trans filter
if ($node->getNode('filter')->getAttribute('value') == 'trans') {
if ($node->getNode('arguments')->hasNode(1)) {
return $node->getNode('arguments')
->getNode(1)
->getAttribute('value');
} else {
return $this->defaultDomain;
}
}
return $this->_extractDomain($node->getNode('node'));
}
|
php
|
private function _extractDomain(\Twig_Node $node)
{
// must be a filter node
if (!$node instanceof \Twig_Node_Expression_Filter) {
return null;
}
// is a trans filter
if ($node->getNode('filter')->getAttribute('value') == 'trans') {
if ($node->getNode('arguments')->hasNode(1)) {
return $node->getNode('arguments')
->getNode(1)
->getAttribute('value');
} else {
return $this->defaultDomain;
}
}
return $this->_extractDomain($node->getNode('node'));
}
|
[
"private",
"function",
"_extractDomain",
"(",
"\\",
"Twig_Node",
"$",
"node",
")",
"{",
"// must be a filter node",
"if",
"(",
"!",
"$",
"node",
"instanceof",
"\\",
"Twig_Node_Expression_Filter",
")",
"{",
"return",
"null",
";",
"}",
"// is a trans filter",
"if",
"(",
"$",
"node",
"->",
"getNode",
"(",
"'filter'",
")",
"->",
"getAttribute",
"(",
"'value'",
")",
"==",
"'trans'",
")",
"{",
"if",
"(",
"$",
"node",
"->",
"getNode",
"(",
"'arguments'",
")",
"->",
"hasNode",
"(",
"1",
")",
")",
"{",
"return",
"$",
"node",
"->",
"getNode",
"(",
"'arguments'",
")",
"->",
"getNode",
"(",
"1",
")",
"->",
"getAttribute",
"(",
"'value'",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"defaultDomain",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"_extractDomain",
"(",
"$",
"node",
"->",
"getNode",
"(",
"'node'",
")",
")",
";",
"}"
] |
Extract a domain from a \Twig_Node_Print
Return null if no trans filter
@param \Twig_Node $node
|
[
"Extract",
"a",
"domain",
"from",
"a",
"\\",
"Twig_Node_Print",
"Return",
"null",
"if",
"no",
"trans",
"filter"
] |
14037d6b5c8ba9520ffe33f26057e2e53bea7a75
|
https://github.com/sasedev/extra-tools-bundle/blob/14037d6b5c8ba9520ffe33f26057e2e53bea7a75/src/Sasedev/ExtraToolsBundle/Command/UpdateTransCommand.php#L232-L250
|
235,283
|
makinacorpus/drupal-udate
|
lib/Udate/CalendarEntityRowPlugin.php
|
Udate_CalendarEntityRowPlugin.preloadEntities
|
protected function preloadEntities($values)
{
$ids = array();
foreach ($values as $row) {
$id = $row->{$this->field_alias};
if ($this->view->base_table == 'node_revision') {
$this->entities[$id] = node_load(NULL, $id);
} else {
$ids[$id] = $id;
}
}
$base_tables = date_views_base_tables();
$this->entity_type = $base_tables[$this->view->base_table];
if (!empty($ids)) {
$this->entities = entity_load($this->entity_type, $ids);
}
}
|
php
|
protected function preloadEntities($values)
{
$ids = array();
foreach ($values as $row) {
$id = $row->{$this->field_alias};
if ($this->view->base_table == 'node_revision') {
$this->entities[$id] = node_load(NULL, $id);
} else {
$ids[$id] = $id;
}
}
$base_tables = date_views_base_tables();
$this->entity_type = $base_tables[$this->view->base_table];
if (!empty($ids)) {
$this->entities = entity_load($this->entity_type, $ids);
}
}
|
[
"protected",
"function",
"preloadEntities",
"(",
"$",
"values",
")",
"{",
"$",
"ids",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"values",
"as",
"$",
"row",
")",
"{",
"$",
"id",
"=",
"$",
"row",
"->",
"{",
"$",
"this",
"->",
"field_alias",
"}",
";",
"if",
"(",
"$",
"this",
"->",
"view",
"->",
"base_table",
"==",
"'node_revision'",
")",
"{",
"$",
"this",
"->",
"entities",
"[",
"$",
"id",
"]",
"=",
"node_load",
"(",
"NULL",
",",
"$",
"id",
")",
";",
"}",
"else",
"{",
"$",
"ids",
"[",
"$",
"id",
"]",
"=",
"$",
"id",
";",
"}",
"}",
"$",
"base_tables",
"=",
"date_views_base_tables",
"(",
")",
";",
"$",
"this",
"->",
"entity_type",
"=",
"$",
"base_tables",
"[",
"$",
"this",
"->",
"view",
"->",
"base_table",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"ids",
")",
")",
"{",
"$",
"this",
"->",
"entities",
"=",
"entity_load",
"(",
"$",
"this",
"->",
"entity_type",
",",
"$",
"ids",
")",
";",
"}",
"}"
] |
This actually was a good idea
|
[
"This",
"actually",
"was",
"a",
"good",
"idea"
] |
75f296acd7ba230b2d0a28c1fb906f4f1da863cf
|
https://github.com/makinacorpus/drupal-udate/blob/75f296acd7ba230b2d0a28c1fb906f4f1da863cf/lib/Udate/CalendarEntityRowPlugin.php#L16-L36
|
235,284
|
encorephp/view-controller
|
src/View/Style/StyleCollection.php
|
StyleCollection.addById
|
public function addById($id, array $styles)
{
$this->ids[$id] = array_merge_recursive($this->getById($id), $styles);
}
|
php
|
public function addById($id, array $styles)
{
$this->ids[$id] = array_merge_recursive($this->getById($id), $styles);
}
|
[
"public",
"function",
"addById",
"(",
"$",
"id",
",",
"array",
"$",
"styles",
")",
"{",
"$",
"this",
"->",
"ids",
"[",
"$",
"id",
"]",
"=",
"array_merge_recursive",
"(",
"$",
"this",
"->",
"getById",
"(",
"$",
"id",
")",
",",
"$",
"styles",
")",
";",
"}"
] |
Add a style by ID
@param string $id
@param array $styles [description]
|
[
"Add",
"a",
"style",
"by",
"ID"
] |
38335ee5c175364ea49bc378c141aabfe9fa3def
|
https://github.com/encorephp/view-controller/blob/38335ee5c175364ea49bc378c141aabfe9fa3def/src/View/Style/StyleCollection.php#L40-L43
|
235,285
|
encorephp/view-controller
|
src/View/Style/StyleCollection.php
|
StyleCollection.addByElement
|
public function addByElement($element, array $styles)
{
$this->elements[$element] = array_merge_recursive($this->getByElement($element), $styles);
}
|
php
|
public function addByElement($element, array $styles)
{
$this->elements[$element] = array_merge_recursive($this->getByElement($element), $styles);
}
|
[
"public",
"function",
"addByElement",
"(",
"$",
"element",
",",
"array",
"$",
"styles",
")",
"{",
"$",
"this",
"->",
"elements",
"[",
"$",
"element",
"]",
"=",
"array_merge_recursive",
"(",
"$",
"this",
"->",
"getByElement",
"(",
"$",
"element",
")",
",",
"$",
"styles",
")",
";",
"}"
] |
Add style by element name
@param string $element
@param array $styles
|
[
"Add",
"style",
"by",
"element",
"name"
] |
38335ee5c175364ea49bc378c141aabfe9fa3def
|
https://github.com/encorephp/view-controller/blob/38335ee5c175364ea49bc378c141aabfe9fa3def/src/View/Style/StyleCollection.php#L64-L67
|
235,286
|
znframework/package-console
|
Upgrade.php
|
Upgrade.fe
|
protected static function fe()
{
if( ! empty(ZN::upgrade()) )
{
$status = self::$lang['upgradeSuccess'];
}
else
{
$status = self::$lang['alreadyVersion'];
if( $upgradeError = ZN::upgradeError() )
{
$status = $upgradeError;
}
}
return $status;
}
|
php
|
protected static function fe()
{
if( ! empty(ZN::upgrade()) )
{
$status = self::$lang['upgradeSuccess'];
}
else
{
$status = self::$lang['alreadyVersion'];
if( $upgradeError = ZN::upgradeError() )
{
$status = $upgradeError;
}
}
return $status;
}
|
[
"protected",
"static",
"function",
"fe",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"ZN",
"::",
"upgrade",
"(",
")",
")",
")",
"{",
"$",
"status",
"=",
"self",
"::",
"$",
"lang",
"[",
"'upgradeSuccess'",
"]",
";",
"}",
"else",
"{",
"$",
"status",
"=",
"self",
"::",
"$",
"lang",
"[",
"'alreadyVersion'",
"]",
";",
"if",
"(",
"$",
"upgradeError",
"=",
"ZN",
"::",
"upgradeError",
"(",
")",
")",
"{",
"$",
"status",
"=",
"$",
"upgradeError",
";",
"}",
"}",
"return",
"$",
"status",
";",
"}"
] |
Protected upgrade FE
|
[
"Protected",
"upgrade",
"FE"
] |
fde428da8b9d926ea4256c235f542e6225c5d788
|
https://github.com/znframework/package-console/blob/fde428da8b9d926ea4256c235f542e6225c5d788/Upgrade.php#L59-L76
|
235,287
|
znframework/package-console
|
Upgrade.php
|
Upgrade.eip
|
protected static function eip($tag = 'znframework')
{
if( $return = Restful::useragent(true)->get('https://api.github.com/repos/znframework/'.$tag.'/tags') )
{
if( ! isset($return->message) )
{
usort($return, function($data1, $data2){ return strcmp($data1->name, $data2->name); });
rsort($return);
$lastest = $return[0];
$lastVersionData = $lastest->name ?? ZN_VERSION;
$open = popen('composer update 2>&1', 'r');
$result = fread($open, 2048);
pclose($open);
if( empty($result) )
{
$status = self::$lang['composerUpdate'];
}
else
{
if( ZN_VERSION !== $lastVersionData )
{
File::replace(DIRECTORY_INDEX, ZN_VERSION, $lastVersionData);
$status = self::$lang['upgradeSuccess'];
}
else
{
$status = self::$lang['alreadyVersion'];
}
}
}
else
{
$status = $return->message;
}
return $status;
}
}
|
php
|
protected static function eip($tag = 'znframework')
{
if( $return = Restful::useragent(true)->get('https://api.github.com/repos/znframework/'.$tag.'/tags') )
{
if( ! isset($return->message) )
{
usort($return, function($data1, $data2){ return strcmp($data1->name, $data2->name); });
rsort($return);
$lastest = $return[0];
$lastVersionData = $lastest->name ?? ZN_VERSION;
$open = popen('composer update 2>&1', 'r');
$result = fread($open, 2048);
pclose($open);
if( empty($result) )
{
$status = self::$lang['composerUpdate'];
}
else
{
if( ZN_VERSION !== $lastVersionData )
{
File::replace(DIRECTORY_INDEX, ZN_VERSION, $lastVersionData);
$status = self::$lang['upgradeSuccess'];
}
else
{
$status = self::$lang['alreadyVersion'];
}
}
}
else
{
$status = $return->message;
}
return $status;
}
}
|
[
"protected",
"static",
"function",
"eip",
"(",
"$",
"tag",
"=",
"'znframework'",
")",
"{",
"if",
"(",
"$",
"return",
"=",
"Restful",
"::",
"useragent",
"(",
"true",
")",
"->",
"get",
"(",
"'https://api.github.com/repos/znframework/'",
".",
"$",
"tag",
".",
"'/tags'",
")",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"return",
"->",
"message",
")",
")",
"{",
"usort",
"(",
"$",
"return",
",",
"function",
"(",
"$",
"data1",
",",
"$",
"data2",
")",
"{",
"return",
"strcmp",
"(",
"$",
"data1",
"->",
"name",
",",
"$",
"data2",
"->",
"name",
")",
";",
"}",
")",
";",
"rsort",
"(",
"$",
"return",
")",
";",
"$",
"lastest",
"=",
"$",
"return",
"[",
"0",
"]",
";",
"$",
"lastVersionData",
"=",
"$",
"lastest",
"->",
"name",
"??",
"ZN_VERSION",
";",
"$",
"open",
"=",
"popen",
"(",
"'composer update 2>&1'",
",",
"'r'",
")",
";",
"$",
"result",
"=",
"fread",
"(",
"$",
"open",
",",
"2048",
")",
";",
"pclose",
"(",
"$",
"open",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"result",
")",
")",
"{",
"$",
"status",
"=",
"self",
"::",
"$",
"lang",
"[",
"'composerUpdate'",
"]",
";",
"}",
"else",
"{",
"if",
"(",
"ZN_VERSION",
"!==",
"$",
"lastVersionData",
")",
"{",
"File",
"::",
"replace",
"(",
"DIRECTORY_INDEX",
",",
"ZN_VERSION",
",",
"$",
"lastVersionData",
")",
";",
"$",
"status",
"=",
"self",
"::",
"$",
"lang",
"[",
"'upgradeSuccess'",
"]",
";",
"}",
"else",
"{",
"$",
"status",
"=",
"self",
"::",
"$",
"lang",
"[",
"'alreadyVersion'",
"]",
";",
"}",
"}",
"}",
"else",
"{",
"$",
"status",
"=",
"$",
"return",
"->",
"message",
";",
"}",
"return",
"$",
"status",
";",
"}",
"}"
] |
Proteted upgrade EIP
|
[
"Proteted",
"upgrade",
"EIP"
] |
fde428da8b9d926ea4256c235f542e6225c5d788
|
https://github.com/znframework/package-console/blob/fde428da8b9d926ea4256c235f542e6225c5d788/Upgrade.php#L81-L124
|
235,288
|
jivoo/http
|
src/Message/Response.php
|
Response.cached
|
public function cached($public = true, $expires = '+1 year')
{
if (!is_int($expires)) {
$expires = strtotime($expires);
}
$maxAge = $expires - time();
$pragma = $public ? 'public' : 'private';
$cache = $pragma . ', max-age=' . $maxAge;
$response = clone $this;
$response->setHeader('Expires', Message::date($expires));
$response->setHeader('Pragma', $pragma);
$response->setHeader('Cache-Control', $cache);
return $response;
}
|
php
|
public function cached($public = true, $expires = '+1 year')
{
if (!is_int($expires)) {
$expires = strtotime($expires);
}
$maxAge = $expires - time();
$pragma = $public ? 'public' : 'private';
$cache = $pragma . ', max-age=' . $maxAge;
$response = clone $this;
$response->setHeader('Expires', Message::date($expires));
$response->setHeader('Pragma', $pragma);
$response->setHeader('Cache-Control', $cache);
return $response;
}
|
[
"public",
"function",
"cached",
"(",
"$",
"public",
"=",
"true",
",",
"$",
"expires",
"=",
"'+1 year'",
")",
"{",
"if",
"(",
"!",
"is_int",
"(",
"$",
"expires",
")",
")",
"{",
"$",
"expires",
"=",
"strtotime",
"(",
"$",
"expires",
")",
";",
"}",
"$",
"maxAge",
"=",
"$",
"expires",
"-",
"time",
"(",
")",
";",
"$",
"pragma",
"=",
"$",
"public",
"?",
"'public'",
":",
"'private'",
";",
"$",
"cache",
"=",
"$",
"pragma",
".",
"', max-age='",
".",
"$",
"maxAge",
";",
"$",
"response",
"=",
"clone",
"$",
"this",
";",
"$",
"response",
"->",
"setHeader",
"(",
"'Expires'",
",",
"Message",
"::",
"date",
"(",
"$",
"expires",
")",
")",
";",
"$",
"response",
"->",
"setHeader",
"(",
"'Pragma'",
",",
"$",
"pragma",
")",
";",
"$",
"response",
"->",
"setHeader",
"(",
"'Cache-Control'",
",",
"$",
"cache",
")",
";",
"return",
"$",
"response",
";",
"}"
] |
Set cache settings.
@param string $public Public or private.
@param int|string $expires Time on which cache expires. Can be a UNIX
timestamp or a string used with {@see strtotime()}.
|
[
"Set",
"cache",
"settings",
"."
] |
3c1d8dba66978bc91fc2b324dd941e5da3b253bc
|
https://github.com/jivoo/http/blob/3c1d8dba66978bc91fc2b324dd941e5da3b253bc/src/Message/Response.php#L77-L90
|
235,289
|
jivoo/http
|
src/Message/Response.php
|
Response.file
|
public static function file($path, $type = null)
{
$response = new self(
Status::OK,
new PhpStream($path, 'rb')
);
if (isset($type)) {
$response->setHeader('Content-Type', $type);
}
return $response;
}
|
php
|
public static function file($path, $type = null)
{
$response = new self(
Status::OK,
new PhpStream($path, 'rb')
);
if (isset($type)) {
$response->setHeader('Content-Type', $type);
}
return $response;
}
|
[
"public",
"static",
"function",
"file",
"(",
"$",
"path",
",",
"$",
"type",
"=",
"null",
")",
"{",
"$",
"response",
"=",
"new",
"self",
"(",
"Status",
"::",
"OK",
",",
"new",
"PhpStream",
"(",
"$",
"path",
",",
"'rb'",
")",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"type",
")",
")",
"{",
"$",
"response",
"->",
"setHeader",
"(",
"'Content-Type'",
",",
"$",
"type",
")",
";",
"}",
"return",
"$",
"response",
";",
"}"
] |
Create a file response.
@param string $path Path to file.
@param string|null $type Optional MIME type.
@return self The response.
|
[
"Create",
"a",
"file",
"response",
"."
] |
3c1d8dba66978bc91fc2b324dd941e5da3b253bc
|
https://github.com/jivoo/http/blob/3c1d8dba66978bc91fc2b324dd941e5da3b253bc/src/Message/Response.php#L116-L126
|
235,290
|
nonetallt/jinitialize-core
|
src/JinitializeApplication.php
|
JinitializeApplication.registerPlugin
|
public function registerPlugin(array $plugin)
{
/* Dont't process nameless plugins */
if(! isset($plugin['name'])) return;
/* Create a container for the plugin */
$this->getContainer()->addPlugin($plugin['name']);
/* Commands are registered first so they can be found be porcedures */
if(isset($plugin['commands'])) {
$this->registerCommands($plugin['name'], $plugin['commands']);
}
if(isset($plugin['procedures'])) {
/* The path info is appended by ComposerScripts */
$this->registerProcedures($plugin['name'], $plugin['procedures'], $plugin['path']);
}
if(isset($plugin['settings'])) {
$this->registerSettings($plugin['name'], $plugin[ 'settings' ]);
}
}
|
php
|
public function registerPlugin(array $plugin)
{
/* Dont't process nameless plugins */
if(! isset($plugin['name'])) return;
/* Create a container for the plugin */
$this->getContainer()->addPlugin($plugin['name']);
/* Commands are registered first so they can be found be porcedures */
if(isset($plugin['commands'])) {
$this->registerCommands($plugin['name'], $plugin['commands']);
}
if(isset($plugin['procedures'])) {
/* The path info is appended by ComposerScripts */
$this->registerProcedures($plugin['name'], $plugin['procedures'], $plugin['path']);
}
if(isset($plugin['settings'])) {
$this->registerSettings($plugin['name'], $plugin[ 'settings' ]);
}
}
|
[
"public",
"function",
"registerPlugin",
"(",
"array",
"$",
"plugin",
")",
"{",
"/* Dont't process nameless plugins */",
"if",
"(",
"!",
"isset",
"(",
"$",
"plugin",
"[",
"'name'",
"]",
")",
")",
"return",
";",
"/* Create a container for the plugin */",
"$",
"this",
"->",
"getContainer",
"(",
")",
"->",
"addPlugin",
"(",
"$",
"plugin",
"[",
"'name'",
"]",
")",
";",
"/* Commands are registered first so they can be found be porcedures */",
"if",
"(",
"isset",
"(",
"$",
"plugin",
"[",
"'commands'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"registerCommands",
"(",
"$",
"plugin",
"[",
"'name'",
"]",
",",
"$",
"plugin",
"[",
"'commands'",
"]",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"plugin",
"[",
"'procedures'",
"]",
")",
")",
"{",
"/* The path info is appended by ComposerScripts */",
"$",
"this",
"->",
"registerProcedures",
"(",
"$",
"plugin",
"[",
"'name'",
"]",
",",
"$",
"plugin",
"[",
"'procedures'",
"]",
",",
"$",
"plugin",
"[",
"'path'",
"]",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"plugin",
"[",
"'settings'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"registerSettings",
"(",
"$",
"plugin",
"[",
"'name'",
"]",
",",
"$",
"plugin",
"[",
"'settings'",
"]",
")",
";",
"}",
"}"
] |
Register a plugin found in manifest file
@param array $plugin
@return null
|
[
"Register",
"a",
"plugin",
"found",
"in",
"manifest",
"file"
] |
284fbd72b7c1d6f5f8f265dfe2589c0d99b6a88f
|
https://github.com/nonetallt/jinitialize-core/blob/284fbd72b7c1d6f5f8f265dfe2589c0d99b6a88f/src/JinitializeApplication.php#L61-L82
|
235,291
|
nonetallt/jinitialize-core
|
src/JinitializeApplication.php
|
JinitializeApplication.registerProcedures
|
public function registerProcedures(string $plugin, array $procedures, string $path)
{
/* Append the installation path before the files */
array_walk($procedures, function(&$procedure) use ($path){
$procedure = "$path/$procedure";
});
/* Create a factory from list of paths defined by plugin */
$factory = new ProcedureFactory($this, $procedures);
/* Get a list of all procedure names contained in file paths */
foreach($factory->getNames() as $name) {
/* Use the factory to create and register each procedure */
$procedure = $factory->create($name);
$this->add($procedure);
}
}
|
php
|
public function registerProcedures(string $plugin, array $procedures, string $path)
{
/* Append the installation path before the files */
array_walk($procedures, function(&$procedure) use ($path){
$procedure = "$path/$procedure";
});
/* Create a factory from list of paths defined by plugin */
$factory = new ProcedureFactory($this, $procedures);
/* Get a list of all procedure names contained in file paths */
foreach($factory->getNames() as $name) {
/* Use the factory to create and register each procedure */
$procedure = $factory->create($name);
$this->add($procedure);
}
}
|
[
"public",
"function",
"registerProcedures",
"(",
"string",
"$",
"plugin",
",",
"array",
"$",
"procedures",
",",
"string",
"$",
"path",
")",
"{",
"/* Append the installation path before the files */",
"array_walk",
"(",
"$",
"procedures",
",",
"function",
"(",
"&",
"$",
"procedure",
")",
"use",
"(",
"$",
"path",
")",
"{",
"$",
"procedure",
"=",
"\"$path/$procedure\"",
";",
"}",
")",
";",
"/* Create a factory from list of paths defined by plugin */",
"$",
"factory",
"=",
"new",
"ProcedureFactory",
"(",
"$",
"this",
",",
"$",
"procedures",
")",
";",
"/* Get a list of all procedure names contained in file paths */",
"foreach",
"(",
"$",
"factory",
"->",
"getNames",
"(",
")",
"as",
"$",
"name",
")",
"{",
"/* Use the factory to create and register each procedure */",
"$",
"procedure",
"=",
"$",
"factory",
"->",
"create",
"(",
"$",
"name",
")",
";",
"$",
"this",
"->",
"add",
"(",
"$",
"procedure",
")",
";",
"}",
"}"
] |
Register all procedures for a given plugin
|
[
"Register",
"all",
"procedures",
"for",
"a",
"given",
"plugin"
] |
284fbd72b7c1d6f5f8f265dfe2589c0d99b6a88f
|
https://github.com/nonetallt/jinitialize-core/blob/284fbd72b7c1d6f5f8f265dfe2589c0d99b6a88f/src/JinitializeApplication.php#L87-L103
|
235,292
|
nonetallt/jinitialize-core
|
src/JinitializeApplication.php
|
JinitializeApplication.registerCommands
|
public function registerCommands(string $plugin, array $commands)
{
$newCommands = [];
foreach($commands as $commandClass) {
$command = new $commandClass($plugin);
$command = CommandFactory::setNamespace($command);
$this->add($command);
$newCommands[] = $command;
}
return $newCommands;
}
|
php
|
public function registerCommands(string $plugin, array $commands)
{
$newCommands = [];
foreach($commands as $commandClass) {
$command = new $commandClass($plugin);
$command = CommandFactory::setNamespace($command);
$this->add($command);
$newCommands[] = $command;
}
return $newCommands;
}
|
[
"public",
"function",
"registerCommands",
"(",
"string",
"$",
"plugin",
",",
"array",
"$",
"commands",
")",
"{",
"$",
"newCommands",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"commands",
"as",
"$",
"commandClass",
")",
"{",
"$",
"command",
"=",
"new",
"$",
"commandClass",
"(",
"$",
"plugin",
")",
";",
"$",
"command",
"=",
"CommandFactory",
"::",
"setNamespace",
"(",
"$",
"command",
")",
";",
"$",
"this",
"->",
"add",
"(",
"$",
"command",
")",
";",
"$",
"newCommands",
"[",
"]",
"=",
"$",
"command",
";",
"}",
"return",
"$",
"newCommands",
";",
"}"
] |
Register all commands for a given plugin
@param string $plugin The plugin these commands will be registered for
@param array $commands array containing the classnames of the commands
@return array $newCommands array containing JinitializeCommand objects
|
[
"Register",
"all",
"commands",
"for",
"a",
"given",
"plugin"
] |
284fbd72b7c1d6f5f8f265dfe2589c0d99b6a88f
|
https://github.com/nonetallt/jinitialize-core/blob/284fbd72b7c1d6f5f8f265dfe2589c0d99b6a88f/src/JinitializeApplication.php#L114-L125
|
235,293
|
nonetallt/jinitialize-core
|
src/JinitializeApplication.php
|
JinitializeApplication.missingSettings
|
public function missingSettings()
{
$missing = [];
foreach($this->recommendedSettings() as $plugin => $settings) {
foreach($settings as $setting) {
/* Get value for the setting */
$value = $_ENV[$setting] ?? null;
if(is_null($value)) $missing[$plugin][] = $setting;
}
}
return $missing;
}
|
php
|
public function missingSettings()
{
$missing = [];
foreach($this->recommendedSettings() as $plugin => $settings) {
foreach($settings as $setting) {
/* Get value for the setting */
$value = $_ENV[$setting] ?? null;
if(is_null($value)) $missing[$plugin][] = $setting;
}
}
return $missing;
}
|
[
"public",
"function",
"missingSettings",
"(",
")",
"{",
"$",
"missing",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"recommendedSettings",
"(",
")",
"as",
"$",
"plugin",
"=>",
"$",
"settings",
")",
"{",
"foreach",
"(",
"$",
"settings",
"as",
"$",
"setting",
")",
"{",
"/* Get value for the setting */",
"$",
"value",
"=",
"$",
"_ENV",
"[",
"$",
"setting",
"]",
"??",
"null",
";",
"if",
"(",
"is_null",
"(",
"$",
"value",
")",
")",
"$",
"missing",
"[",
"$",
"plugin",
"]",
"[",
"]",
"=",
"$",
"setting",
";",
"}",
"}",
"return",
"$",
"missing",
";",
"}"
] |
Get an array of plugins and their settings that are not defined in env
|
[
"Get",
"an",
"array",
"of",
"plugins",
"and",
"their",
"settings",
"that",
"are",
"not",
"defined",
"in",
"env"
] |
284fbd72b7c1d6f5f8f265dfe2589c0d99b6a88f
|
https://github.com/nonetallt/jinitialize-core/blob/284fbd72b7c1d6f5f8f265dfe2589c0d99b6a88f/src/JinitializeApplication.php#L150-L162
|
235,294
|
weew/console
|
src/Weew/Console/Output.php
|
Output.flushBuffer
|
public function flushBuffer() {
$content = $this->format($this->buffer->flush());
if ( ! $this->is(OutputVerbosity::SILENT)) {
fwrite($this->getOutputStream(), $content);
}
}
|
php
|
public function flushBuffer() {
$content = $this->format($this->buffer->flush());
if ( ! $this->is(OutputVerbosity::SILENT)) {
fwrite($this->getOutputStream(), $content);
}
}
|
[
"public",
"function",
"flushBuffer",
"(",
")",
"{",
"$",
"content",
"=",
"$",
"this",
"->",
"format",
"(",
"$",
"this",
"->",
"buffer",
"->",
"flush",
"(",
")",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"is",
"(",
"OutputVerbosity",
"::",
"SILENT",
")",
")",
"{",
"fwrite",
"(",
"$",
"this",
"->",
"getOutputStream",
"(",
")",
",",
"$",
"content",
")",
";",
"}",
"}"
] |
Manually flush buffered output.
|
[
"Manually",
"flush",
"buffered",
"output",
"."
] |
083703f21fdeff3cfe6036ebd21ab9cb84ca74c7
|
https://github.com/weew/console/blob/083703f21fdeff3cfe6036ebd21ab9cb84ca74c7/src/Weew/Console/Output.php#L219-L225
|
235,295
|
ntentan/ajumamoro
|
src/Queue.php
|
Queue.add
|
public function add(Job $job)
{
$jobClass = new \ReflectionClass($job);
$name = $jobClass->getName();
$object = serialize($job);
$jobId = $this->broker->put(['object' => $object, 'class' => $name]);
$this->broker->setStatus($jobId,
['status' => Job::STATUS_QUEUED, 'queued'=> date(DATE_RFC3339_EXTENDED)]
);
return $jobId;
}
|
php
|
public function add(Job $job)
{
$jobClass = new \ReflectionClass($job);
$name = $jobClass->getName();
$object = serialize($job);
$jobId = $this->broker->put(['object' => $object, 'class' => $name]);
$this->broker->setStatus($jobId,
['status' => Job::STATUS_QUEUED, 'queued'=> date(DATE_RFC3339_EXTENDED)]
);
return $jobId;
}
|
[
"public",
"function",
"add",
"(",
"Job",
"$",
"job",
")",
"{",
"$",
"jobClass",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"job",
")",
";",
"$",
"name",
"=",
"$",
"jobClass",
"->",
"getName",
"(",
")",
";",
"$",
"object",
"=",
"serialize",
"(",
"$",
"job",
")",
";",
"$",
"jobId",
"=",
"$",
"this",
"->",
"broker",
"->",
"put",
"(",
"[",
"'object'",
"=>",
"$",
"object",
",",
"'class'",
"=>",
"$",
"name",
"]",
")",
";",
"$",
"this",
"->",
"broker",
"->",
"setStatus",
"(",
"$",
"jobId",
",",
"[",
"'status'",
"=>",
"Job",
"::",
"STATUS_QUEUED",
",",
"'queued'",
"=>",
"date",
"(",
"DATE_RFC3339_EXTENDED",
")",
"]",
")",
";",
"return",
"$",
"jobId",
";",
"}"
] |
Add a job to the job queue.
@param Job $job
@return string
|
[
"Add",
"a",
"job",
"to",
"the",
"job",
"queue",
"."
] |
160c772c02e40e9656ab03acd1e9387aebce7219
|
https://github.com/ntentan/ajumamoro/blob/160c772c02e40e9656ab03acd1e9387aebce7219/src/Queue.php#L27-L37
|
235,296
|
robotdance/php-console
|
src/Console.php
|
Console.indent
|
public static function indent($str, $spaces = 4, $level = 1){
return str_repeat(" ", $spaces * $level)
. str_replace("\n", "\n" . str_repeat(" ", $spaces * $level), $str);
}
|
php
|
public static function indent($str, $spaces = 4, $level = 1){
return str_repeat(" ", $spaces * $level)
. str_replace("\n", "\n" . str_repeat(" ", $spaces * $level), $str);
}
|
[
"public",
"static",
"function",
"indent",
"(",
"$",
"str",
",",
"$",
"spaces",
"=",
"4",
",",
"$",
"level",
"=",
"1",
")",
"{",
"return",
"str_repeat",
"(",
"\" \"",
",",
"$",
"spaces",
"*",
"$",
"level",
")",
".",
"str_replace",
"(",
"\"\\n\"",
",",
"\"\\n\"",
".",
"str_repeat",
"(",
"\" \"",
",",
"$",
"spaces",
"*",
"$",
"level",
")",
",",
"$",
"str",
")",
";",
"}"
] |
Inserts N spaces to the left of a string
@param $str String
@param $spaces Number of spaces to insert
@param $level Indentation level (1, 2, 3, ...)
@return String with N spaces inserted
|
[
"Inserts",
"N",
"spaces",
"to",
"the",
"left",
"of",
"a",
"string"
] |
1bac28ed8868e5247040dec96e8b8df162fdaa07
|
https://github.com/robotdance/php-console/blob/1bac28ed8868e5247040dec96e8b8df162fdaa07/src/Console.php#L165-L168
|
235,297
|
robotdance/php-console
|
src/Console.php
|
Console.moveCursorRel
|
public function moveCursorRel($x, $y)
{
$yChar = ($y < 0) ? "A" : "B"; // up / down
$xChar = ($x < 0) ? "D" : "C"; // left / right
fwrite(STDOUT, "\e[" . abs($x) . $xChar);
fwrite(STDOUT, "\e[" . abs($y) . $yChar);
}
|
php
|
public function moveCursorRel($x, $y)
{
$yChar = ($y < 0) ? "A" : "B"; // up / down
$xChar = ($x < 0) ? "D" : "C"; // left / right
fwrite(STDOUT, "\e[" . abs($x) . $xChar);
fwrite(STDOUT, "\e[" . abs($y) . $yChar);
}
|
[
"public",
"function",
"moveCursorRel",
"(",
"$",
"x",
",",
"$",
"y",
")",
"{",
"$",
"yChar",
"=",
"(",
"$",
"y",
"<",
"0",
")",
"?",
"\"A\"",
":",
"\"B\"",
";",
"// up / down",
"$",
"xChar",
"=",
"(",
"$",
"x",
"<",
"0",
")",
"?",
"\"D\"",
":",
"\"C\"",
";",
"// left / right",
"fwrite",
"(",
"STDOUT",
",",
"\"\\e[\"",
".",
"abs",
"(",
"$",
"x",
")",
".",
"$",
"xChar",
")",
";",
"fwrite",
"(",
"STDOUT",
",",
"\"\\e[\"",
".",
"abs",
"(",
"$",
"y",
")",
".",
"$",
"yChar",
")",
";",
"}"
] |
Moves cursor relatively to its current position
@param $x Positive value move to right, left otherwise
@param $y Positive value move to down, up otherwise
|
[
"Moves",
"cursor",
"relatively",
"to",
"its",
"current",
"position"
] |
1bac28ed8868e5247040dec96e8b8df162fdaa07
|
https://github.com/robotdance/php-console/blob/1bac28ed8868e5247040dec96e8b8df162fdaa07/src/Console.php#L184-L190
|
235,298
|
CampaignChain/channel-mailchimp
|
REST/MailChimpOAuth.php
|
Hybrid_Providers_MailChimp.getEndpoint
|
function getEndpoint()
{
$this->api->curl_header = array(
'Authorization: OAuth '.$this->api->access_token,
);
$data = $this->api->get( $this->metadata_url );
if ( ! isset( $data->api_endpoint ) ){
throw new Exception( "Endpoint request failed! {$this->providerId} returned an invalid response.", 6 );
}
return $data->api_endpoint;
}
|
php
|
function getEndpoint()
{
$this->api->curl_header = array(
'Authorization: OAuth '.$this->api->access_token,
);
$data = $this->api->get( $this->metadata_url );
if ( ! isset( $data->api_endpoint ) ){
throw new Exception( "Endpoint request failed! {$this->providerId} returned an invalid response.", 6 );
}
return $data->api_endpoint;
}
|
[
"function",
"getEndpoint",
"(",
")",
"{",
"$",
"this",
"->",
"api",
"->",
"curl_header",
"=",
"array",
"(",
"'Authorization: OAuth '",
".",
"$",
"this",
"->",
"api",
"->",
"access_token",
",",
")",
";",
"$",
"data",
"=",
"$",
"this",
"->",
"api",
"->",
"get",
"(",
"$",
"this",
"->",
"metadata_url",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"data",
"->",
"api_endpoint",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Endpoint request failed! {$this->providerId} returned an invalid response.\"",
",",
"6",
")",
";",
"}",
"return",
"$",
"data",
"->",
"api_endpoint",
";",
"}"
] |
Load the metadata, which includes the URL of the API endpoint.
|
[
"Load",
"the",
"metadata",
"which",
"includes",
"the",
"URL",
"of",
"the",
"API",
"endpoint",
"."
] |
c68035c8140aa05db5cf8556e68f5d4eaae8e2fa
|
https://github.com/CampaignChain/channel-mailchimp/blob/c68035c8140aa05db5cf8556e68f5d4eaae8e2fa/REST/MailChimpOAuth.php#L74-L86
|
235,299
|
nattreid/app-manager
|
src/Helpers/Info.php
|
Info.getPhpInfo
|
protected function getPhpInfo(): string
{
ob_start();
phpinfo();
$result = ob_get_contents();
ob_end_clean();
$result = preg_replace('%^.*<body>(.*)</body>.*$%ms', '$1', $result);
$result = preg_replace('/,\s*/', ', ', $result);
return $result;
}
|
php
|
protected function getPhpInfo(): string
{
ob_start();
phpinfo();
$result = ob_get_contents();
ob_end_clean();
$result = preg_replace('%^.*<body>(.*)</body>.*$%ms', '$1', $result);
$result = preg_replace('/,\s*/', ', ', $result);
return $result;
}
|
[
"protected",
"function",
"getPhpInfo",
"(",
")",
":",
"string",
"{",
"ob_start",
"(",
")",
";",
"phpinfo",
"(",
")",
";",
"$",
"result",
"=",
"ob_get_contents",
"(",
")",
";",
"ob_end_clean",
"(",
")",
";",
"$",
"result",
"=",
"preg_replace",
"(",
"'%^.*<body>(.*)</body>.*$%ms'",
",",
"'$1'",
",",
"$",
"result",
")",
";",
"$",
"result",
"=",
"preg_replace",
"(",
"'/,\\s*/'",
",",
"', '",
",",
"$",
"result",
")",
";",
"return",
"$",
"result",
";",
"}"
] |
Vrati vypis PHP info
@return string
|
[
"Vrati",
"vypis",
"PHP",
"info"
] |
7821d09a0b3e58ba9c6eb81d44e35aacce55de75
|
https://github.com/nattreid/app-manager/blob/7821d09a0b3e58ba9c6eb81d44e35aacce55de75/src/Helpers/Info.php#L34-L44
|
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.