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
|
|---|---|---|---|---|---|---|---|---|---|---|---|
237,800
|
AthensFramework/Core
|
src/writer/HTMLWriter.php
|
HTMLWriter.visitForm
|
public function visitForm(FormInterface $form)
{
$template = "form/{$form->getType()}.twig";
return $this
->loadTemplate($template)
->render(
[
"id" => $form->getId(),
"classes" => $form->getClasses(),
"data" => $form->getData(),
"method" => $form->getMethod(),
"target" => $form->getTarget(),
"writables" => $form->getWritableBearer()->getWritables(),
"actions" => $form->getActions(),
"errors" => $form->getErrors(),
]
);
}
|
php
|
public function visitForm(FormInterface $form)
{
$template = "form/{$form->getType()}.twig";
return $this
->loadTemplate($template)
->render(
[
"id" => $form->getId(),
"classes" => $form->getClasses(),
"data" => $form->getData(),
"method" => $form->getMethod(),
"target" => $form->getTarget(),
"writables" => $form->getWritableBearer()->getWritables(),
"actions" => $form->getActions(),
"errors" => $form->getErrors(),
]
);
}
|
[
"public",
"function",
"visitForm",
"(",
"FormInterface",
"$",
"form",
")",
"{",
"$",
"template",
"=",
"\"form/{$form->getType()}.twig\"",
";",
"return",
"$",
"this",
"->",
"loadTemplate",
"(",
"$",
"template",
")",
"->",
"render",
"(",
"[",
"\"id\"",
"=>",
"$",
"form",
"->",
"getId",
"(",
")",
",",
"\"classes\"",
"=>",
"$",
"form",
"->",
"getClasses",
"(",
")",
",",
"\"data\"",
"=>",
"$",
"form",
"->",
"getData",
"(",
")",
",",
"\"method\"",
"=>",
"$",
"form",
"->",
"getMethod",
"(",
")",
",",
"\"target\"",
"=>",
"$",
"form",
"->",
"getTarget",
"(",
")",
",",
"\"writables\"",
"=>",
"$",
"form",
"->",
"getWritableBearer",
"(",
")",
"->",
"getWritables",
"(",
")",
",",
"\"actions\"",
"=>",
"$",
"form",
"->",
"getActions",
"(",
")",
",",
"\"errors\"",
"=>",
"$",
"form",
"->",
"getErrors",
"(",
")",
",",
"]",
")",
";",
"}"
] |
Render FormInterface into html.
This method is generally called via double-dispatch, as provided by Visitor\VisitableTrait.
@param FormInterface $form
@return string
|
[
"Render",
"FormInterface",
"into",
"html",
"."
] |
6237b914b9f6aef6b2fcac23094b657a86185340
|
https://github.com/AthensFramework/Core/blob/6237b914b9f6aef6b2fcac23094b657a86185340/src/writer/HTMLWriter.php#L264-L282
|
237,801
|
AthensFramework/Core
|
src/writer/HTMLWriter.php
|
HTMLWriter.visitFormAction
|
public function visitFormAction(FormActionInterface $formAction)
{
$template = "form-action/{$formAction->getType()}.twig";
return $this
->loadTemplate($template)
->render(
[
"label" => $formAction->getLabel(),
"target" => $formAction->getTarget(),
"classes" => $formAction->getClasses(),
"data" => $formAction->getData(),
]
);
}
|
php
|
public function visitFormAction(FormActionInterface $formAction)
{
$template = "form-action/{$formAction->getType()}.twig";
return $this
->loadTemplate($template)
->render(
[
"label" => $formAction->getLabel(),
"target" => $formAction->getTarget(),
"classes" => $formAction->getClasses(),
"data" => $formAction->getData(),
]
);
}
|
[
"public",
"function",
"visitFormAction",
"(",
"FormActionInterface",
"$",
"formAction",
")",
"{",
"$",
"template",
"=",
"\"form-action/{$formAction->getType()}.twig\"",
";",
"return",
"$",
"this",
"->",
"loadTemplate",
"(",
"$",
"template",
")",
"->",
"render",
"(",
"[",
"\"label\"",
"=>",
"$",
"formAction",
"->",
"getLabel",
"(",
")",
",",
"\"target\"",
"=>",
"$",
"formAction",
"->",
"getTarget",
"(",
")",
",",
"\"classes\"",
"=>",
"$",
"formAction",
"->",
"getClasses",
"(",
")",
",",
"\"data\"",
"=>",
"$",
"formAction",
"->",
"getData",
"(",
")",
",",
"]",
")",
";",
"}"
] |
Render FormActionInterface into html.
This method is generally called via double-dispatch, as provided by Visitor\VisitableTrait.
@param FormActionInterface $formAction
@return string
|
[
"Render",
"FormActionInterface",
"into",
"html",
"."
] |
6237b914b9f6aef6b2fcac23094b657a86185340
|
https://github.com/AthensFramework/Core/blob/6237b914b9f6aef6b2fcac23094b657a86185340/src/writer/HTMLWriter.php#L292-L306
|
237,802
|
AthensFramework/Core
|
src/writer/HTMLWriter.php
|
HTMLWriter.visitFilter
|
public function visitFilter(FilterInterface $filter)
{
if ($filter instanceof DummyFilter) {
$type = 'dummy';
} elseif ($filter instanceof SelectFilter) {
$type = 'select';
} elseif ($filter instanceof SearchFilter) {
$type = 'search';
} elseif ($filter instanceof SortFilter) {
$type = 'sort';
} elseif ($filter instanceof PaginationFilter) {
$type = "{$filter->getType()}-pagination";
} elseif (method_exists($filter, 'getType') === true) {
$type = $filter->getType();
} else {
$type = 'dummy';
}
$template = "filter/$type.twig";
return $this
->loadTemplate($template)
->render(
[
"id" => $filter->getId(),
"options" => $filter->getOptions(),
]
);
}
|
php
|
public function visitFilter(FilterInterface $filter)
{
if ($filter instanceof DummyFilter) {
$type = 'dummy';
} elseif ($filter instanceof SelectFilter) {
$type = 'select';
} elseif ($filter instanceof SearchFilter) {
$type = 'search';
} elseif ($filter instanceof SortFilter) {
$type = 'sort';
} elseif ($filter instanceof PaginationFilter) {
$type = "{$filter->getType()}-pagination";
} elseif (method_exists($filter, 'getType') === true) {
$type = $filter->getType();
} else {
$type = 'dummy';
}
$template = "filter/$type.twig";
return $this
->loadTemplate($template)
->render(
[
"id" => $filter->getId(),
"options" => $filter->getOptions(),
]
);
}
|
[
"public",
"function",
"visitFilter",
"(",
"FilterInterface",
"$",
"filter",
")",
"{",
"if",
"(",
"$",
"filter",
"instanceof",
"DummyFilter",
")",
"{",
"$",
"type",
"=",
"'dummy'",
";",
"}",
"elseif",
"(",
"$",
"filter",
"instanceof",
"SelectFilter",
")",
"{",
"$",
"type",
"=",
"'select'",
";",
"}",
"elseif",
"(",
"$",
"filter",
"instanceof",
"SearchFilter",
")",
"{",
"$",
"type",
"=",
"'search'",
";",
"}",
"elseif",
"(",
"$",
"filter",
"instanceof",
"SortFilter",
")",
"{",
"$",
"type",
"=",
"'sort'",
";",
"}",
"elseif",
"(",
"$",
"filter",
"instanceof",
"PaginationFilter",
")",
"{",
"$",
"type",
"=",
"\"{$filter->getType()}-pagination\"",
";",
"}",
"elseif",
"(",
"method_exists",
"(",
"$",
"filter",
",",
"'getType'",
")",
"===",
"true",
")",
"{",
"$",
"type",
"=",
"$",
"filter",
"->",
"getType",
"(",
")",
";",
"}",
"else",
"{",
"$",
"type",
"=",
"'dummy'",
";",
"}",
"$",
"template",
"=",
"\"filter/$type.twig\"",
";",
"return",
"$",
"this",
"->",
"loadTemplate",
"(",
"$",
"template",
")",
"->",
"render",
"(",
"[",
"\"id\"",
"=>",
"$",
"filter",
"->",
"getId",
"(",
")",
",",
"\"options\"",
"=>",
"$",
"filter",
"->",
"getOptions",
"(",
")",
",",
"]",
")",
";",
"}"
] |
Helper method to render a FilterInterface to html.
@param FilterInterface $filter
@return array
|
[
"Helper",
"method",
"to",
"render",
"a",
"FilterInterface",
"to",
"html",
"."
] |
6237b914b9f6aef6b2fcac23094b657a86185340
|
https://github.com/AthensFramework/Core/blob/6237b914b9f6aef6b2fcac23094b657a86185340/src/writer/HTMLWriter.php#L314-L341
|
237,803
|
joegreen88/zf1-component-http
|
src/Zend/Http/UserAgent/AbstractDevice.php
|
Zend_Http_UserAgent_AbstractDevice._restoreFromArray
|
protected function _restoreFromArray(array $spec)
{
foreach ($spec as $key => $value) {
if (property_exists($this, $key)) {
$this->{$key} = $value;
}
}
}
|
php
|
protected function _restoreFromArray(array $spec)
{
foreach ($spec as $key => $value) {
if (property_exists($this, $key)) {
$this->{$key} = $value;
}
}
}
|
[
"protected",
"function",
"_restoreFromArray",
"(",
"array",
"$",
"spec",
")",
"{",
"foreach",
"(",
"$",
"spec",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"property_exists",
"(",
"$",
"this",
",",
"$",
"key",
")",
")",
"{",
"$",
"this",
"->",
"{",
"$",
"key",
"}",
"=",
"$",
"value",
";",
"}",
"}",
"}"
] |
Restore object state from array
@param array $spec
@return void
|
[
"Restore",
"object",
"state",
"from",
"array"
] |
39e834e8f0393cf4223d099a0acaab5fa05e9ad4
|
https://github.com/joegreen88/zf1-component-http/blob/39e834e8f0393cf4223d099a0acaab5fa05e9ad4/src/Zend/Http/UserAgent/AbstractDevice.php#L156-L163
|
237,804
|
joegreen88/zf1-component-http
|
src/Zend/Http/UserAgent/AbstractDevice.php
|
Zend_Http_UserAgent_AbstractDevice.setGroup
|
public function setGroup($group, $feature)
{
if (!isset($this->_aGroup[$group])) {
$this->_aGroup[$group] = array();
}
if (!in_array($feature, $this->_aGroup[$group])) {
$this->_aGroup[$group][] = $feature;
}
return $this;
}
|
php
|
public function setGroup($group, $feature)
{
if (!isset($this->_aGroup[$group])) {
$this->_aGroup[$group] = array();
}
if (!in_array($feature, $this->_aGroup[$group])) {
$this->_aGroup[$group][] = $feature;
}
return $this;
}
|
[
"public",
"function",
"setGroup",
"(",
"$",
"group",
",",
"$",
"feature",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_aGroup",
"[",
"$",
"group",
"]",
")",
")",
"{",
"$",
"this",
"->",
"_aGroup",
"[",
"$",
"group",
"]",
"=",
"array",
"(",
")",
";",
"}",
"if",
"(",
"!",
"in_array",
"(",
"$",
"feature",
",",
"$",
"this",
"->",
"_aGroup",
"[",
"$",
"group",
"]",
")",
")",
"{",
"$",
"this",
"->",
"_aGroup",
"[",
"$",
"group",
"]",
"[",
"]",
"=",
"$",
"feature",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Affects a feature to a group
@param string $group Group name
@param string $feature Feature name
@return Zend_Http_UserAgent_AbstractDevice
|
[
"Affects",
"a",
"feature",
"to",
"a",
"group"
] |
39e834e8f0393cf4223d099a0acaab5fa05e9ad4
|
https://github.com/joegreen88/zf1-component-http/blob/39e834e8f0393cf4223d099a0acaab5fa05e9ad4/src/Zend/Http/UserAgent/AbstractDevice.php#L236-L245
|
237,805
|
joegreen88/zf1-component-http
|
src/Zend/Http/UserAgent/AbstractDevice.php
|
Zend_Http_UserAgent_AbstractDevice._matchAgentAgainstSignatures
|
protected static function _matchAgentAgainstSignatures($userAgent, $signatures)
{
$userAgent = strtolower($userAgent);
foreach ($signatures as $signature) {
if (!empty($signature)) {
if (strpos($userAgent, $signature) !== false) {
// Browser signature was found in user agent string
return true;
}
}
}
return false;
}
|
php
|
protected static function _matchAgentAgainstSignatures($userAgent, $signatures)
{
$userAgent = strtolower($userAgent);
foreach ($signatures as $signature) {
if (!empty($signature)) {
if (strpos($userAgent, $signature) !== false) {
// Browser signature was found in user agent string
return true;
}
}
}
return false;
}
|
[
"protected",
"static",
"function",
"_matchAgentAgainstSignatures",
"(",
"$",
"userAgent",
",",
"$",
"signatures",
")",
"{",
"$",
"userAgent",
"=",
"strtolower",
"(",
"$",
"userAgent",
")",
";",
"foreach",
"(",
"$",
"signatures",
"as",
"$",
"signature",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"signature",
")",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"userAgent",
",",
"$",
"signature",
")",
"!==",
"false",
")",
"{",
"// Browser signature was found in user agent string",
"return",
"true",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}"
] |
Match a user agent string against a list of signatures
@param string $userAgent
@param array $signatures
@return bool
|
[
"Match",
"a",
"user",
"agent",
"string",
"against",
"a",
"list",
"of",
"signatures"
] |
39e834e8f0393cf4223d099a0acaab5fa05e9ad4
|
https://github.com/joegreen88/zf1-component-http/blob/39e834e8f0393cf4223d099a0acaab5fa05e9ad4/src/Zend/Http/UserAgent/AbstractDevice.php#L980-L992
|
237,806
|
ehough/chaingang
|
src/main/php/ehough/chaingang/impl/StandardContext.php
|
ehough_chaingang_impl_StandardContext.get
|
public final function get($key)
{
if (isset($this->_map[$key])) {
return $this->_map[$key];
}
return null;
}
|
php
|
public final function get($key)
{
if (isset($this->_map[$key])) {
return $this->_map[$key];
}
return null;
}
|
[
"public",
"final",
"function",
"get",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_map",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"_map",
"[",
"$",
"key",
"]",
";",
"}",
"return",
"null",
";",
"}"
] |
Returns the value to which this map maps the specified key.
Returns null if the map contains no mapping for this key. A return value of null
does not necessarily indicate that the map contains no mapping for the key; it's
also possible that the map explicitly maps the key to null. The containsKey
operation may be used to distinguish these two cases.
@param string $key Key whose associated value is to be returned.
@return mixed The value to which this map maps the specified key, or null if the
map contains no mapping for this key.
|
[
"Returns",
"the",
"value",
"to",
"which",
"this",
"map",
"maps",
"the",
"specified",
"key",
"."
] |
823f7f54333df89c480ddf8d14ac0f2c6bb75868
|
https://github.com/ehough/chaingang/blob/823f7f54333df89c480ddf8d14ac0f2c6bb75868/src/main/php/ehough/chaingang/impl/StandardContext.php#L87-L95
|
237,807
|
ehough/chaingang
|
src/main/php/ehough/chaingang/impl/StandardContext.php
|
ehough_chaingang_impl_StandardContext.putAll
|
public final function putAll(array $values)
{
if (! is_array($values)) {
return;
}
foreach ($values as $key => $value) {
$this->put($key, $value);
}
}
|
php
|
public final function putAll(array $values)
{
if (! is_array($values)) {
return;
}
foreach ($values as $key => $value) {
$this->put($key, $value);
}
}
|
[
"public",
"final",
"function",
"putAll",
"(",
"array",
"$",
"values",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"values",
")",
")",
"{",
"return",
";",
"}",
"foreach",
"(",
"$",
"values",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"put",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"}"
] |
Copies all of the mappings from the specified map to this map.
The effect of this call is equivalent to that of calling put(k, v) on this map
once for each mapping from key k to value v in the specified map.
@param array $values Mappings to be stored in this map.
@return void
|
[
"Copies",
"all",
"of",
"the",
"mappings",
"from",
"the",
"specified",
"map",
"to",
"this",
"map",
"."
] |
823f7f54333df89c480ddf8d14ac0f2c6bb75868
|
https://github.com/ehough/chaingang/blob/823f7f54333df89c480ddf8d14ac0f2c6bb75868/src/main/php/ehough/chaingang/impl/StandardContext.php#L140-L151
|
237,808
|
ehough/chaingang
|
src/main/php/ehough/chaingang/impl/StandardContext.php
|
ehough_chaingang_impl_StandardContext.remove
|
public final function remove($key)
{
$previous = $this->get($key);
if (isset($this->_map[$key])) {
unset($this->_map[$key]);
}
return $previous;
}
|
php
|
public final function remove($key)
{
$previous = $this->get($key);
if (isset($this->_map[$key])) {
unset($this->_map[$key]);
}
return $previous;
}
|
[
"public",
"final",
"function",
"remove",
"(",
"$",
"key",
")",
"{",
"$",
"previous",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"key",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_map",
"[",
"$",
"key",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"_map",
"[",
"$",
"key",
"]",
")",
";",
"}",
"return",
"$",
"previous",
";",
"}"
] |
Removes the mapping for this key from this map if it is present.
@param string $key Key whose mapping is to be removed from the map.
@return mixed Previous value associated with specified key, or null if there was no mapping for key.
|
[
"Removes",
"the",
"mapping",
"for",
"this",
"key",
"from",
"this",
"map",
"if",
"it",
"is",
"present",
"."
] |
823f7f54333df89c480ddf8d14ac0f2c6bb75868
|
https://github.com/ehough/chaingang/blob/823f7f54333df89c480ddf8d14ac0f2c6bb75868/src/main/php/ehough/chaingang/impl/StandardContext.php#L160-L170
|
237,809
|
phellow/intl
|
src/ArrayTranslator.php
|
ArrayTranslator.initLocale
|
protected function initLocale($locale)
{
$file = $this->localeDir . '/' . $locale . '.php';
if (file_exists($file)) {
$data = include $file;
if (!is_array($data)) {
$data = [];
}
} else {
$data = [];
}
if (!isset($data['pluralForm']) || !is_callable($data['pluralForm'])) {
$data['pluralForm'] = null;
}
if (!isset($data['texts'])) {
$data['texts'] = [];
}
$this->data[$locale] = $data;
}
|
php
|
protected function initLocale($locale)
{
$file = $this->localeDir . '/' . $locale . '.php';
if (file_exists($file)) {
$data = include $file;
if (!is_array($data)) {
$data = [];
}
} else {
$data = [];
}
if (!isset($data['pluralForm']) || !is_callable($data['pluralForm'])) {
$data['pluralForm'] = null;
}
if (!isset($data['texts'])) {
$data['texts'] = [];
}
$this->data[$locale] = $data;
}
|
[
"protected",
"function",
"initLocale",
"(",
"$",
"locale",
")",
"{",
"$",
"file",
"=",
"$",
"this",
"->",
"localeDir",
".",
"'/'",
".",
"$",
"locale",
".",
"'.php'",
";",
"if",
"(",
"file_exists",
"(",
"$",
"file",
")",
")",
"{",
"$",
"data",
"=",
"include",
"$",
"file",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"data",
")",
")",
"{",
"$",
"data",
"=",
"[",
"]",
";",
"}",
"}",
"else",
"{",
"$",
"data",
"=",
"[",
"]",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"data",
"[",
"'pluralForm'",
"]",
")",
"||",
"!",
"is_callable",
"(",
"$",
"data",
"[",
"'pluralForm'",
"]",
")",
")",
"{",
"$",
"data",
"[",
"'pluralForm'",
"]",
"=",
"null",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"data",
"[",
"'texts'",
"]",
")",
")",
"{",
"$",
"data",
"[",
"'texts'",
"]",
"=",
"[",
"]",
";",
"}",
"$",
"this",
"->",
"data",
"[",
"$",
"locale",
"]",
"=",
"$",
"data",
";",
"}"
] |
Set translations and plural form for the given locale.
@param string $locale
|
[
"Set",
"translations",
"and",
"plural",
"form",
"for",
"the",
"given",
"locale",
"."
] |
7817f57242a6084ce68ddfb3055191c955ec14f1
|
https://github.com/phellow/intl/blob/7817f57242a6084ce68ddfb3055191c955ec14f1/src/ArrayTranslator.php#L66-L87
|
237,810
|
phellow/intl
|
src/ArrayTranslator.php
|
ArrayTranslator.getPluralIndex
|
protected function getPluralIndex(callable $pluralForm, $number)
{
$nplurals = 0;
$plural = 0;
call_user_func_array($pluralForm, [&$nplurals, &$plural, $number]);
if (is_bool($plural)) {
$plural = $plural ? 1 : 0;
}
if ($plural < 0) {
$plural = 0;
}
if ($plural > $nplurals - 1) {
$plural = $nplurals - 1;
}
return $plural;
}
|
php
|
protected function getPluralIndex(callable $pluralForm, $number)
{
$nplurals = 0;
$plural = 0;
call_user_func_array($pluralForm, [&$nplurals, &$plural, $number]);
if (is_bool($plural)) {
$plural = $plural ? 1 : 0;
}
if ($plural < 0) {
$plural = 0;
}
if ($plural > $nplurals - 1) {
$plural = $nplurals - 1;
}
return $plural;
}
|
[
"protected",
"function",
"getPluralIndex",
"(",
"callable",
"$",
"pluralForm",
",",
"$",
"number",
")",
"{",
"$",
"nplurals",
"=",
"0",
";",
"$",
"plural",
"=",
"0",
";",
"call_user_func_array",
"(",
"$",
"pluralForm",
",",
"[",
"&",
"$",
"nplurals",
",",
"&",
"$",
"plural",
",",
"$",
"number",
"]",
")",
";",
"if",
"(",
"is_bool",
"(",
"$",
"plural",
")",
")",
"{",
"$",
"plural",
"=",
"$",
"plural",
"?",
"1",
":",
"0",
";",
"}",
"if",
"(",
"$",
"plural",
"<",
"0",
")",
"{",
"$",
"plural",
"=",
"0",
";",
"}",
"if",
"(",
"$",
"plural",
">",
"$",
"nplurals",
"-",
"1",
")",
"{",
"$",
"plural",
"=",
"$",
"nplurals",
"-",
"1",
";",
"}",
"return",
"$",
"plural",
";",
"}"
] |
Get plural form index for the given number.
@param callable $pluralForm
@param int $number
@return int
|
[
"Get",
"plural",
"form",
"index",
"for",
"the",
"given",
"number",
"."
] |
7817f57242a6084ce68ddfb3055191c955ec14f1
|
https://github.com/phellow/intl/blob/7817f57242a6084ce68ddfb3055191c955ec14f1/src/ArrayTranslator.php#L147-L167
|
237,811
|
ForceLabsDev/framework
|
src/Psr/ClassLoader.php
|
ClassLoader.addNamespace
|
public function addNamespace($prefix, $baseDir)
{
$prefix = trim($prefix, '\\').'\\';
$baseDir = rtrim($baseDir, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR;
if (!isset($this->namespaceMap[$prefix])) {
$this->namespaceMap[$prefix] = [];
}
array_push($this->namespaceMap[$prefix], str_replace('$path', $this->basePath, $baseDir));
}
|
php
|
public function addNamespace($prefix, $baseDir)
{
$prefix = trim($prefix, '\\').'\\';
$baseDir = rtrim($baseDir, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR;
if (!isset($this->namespaceMap[$prefix])) {
$this->namespaceMap[$prefix] = [];
}
array_push($this->namespaceMap[$prefix], str_replace('$path', $this->basePath, $baseDir));
}
|
[
"public",
"function",
"addNamespace",
"(",
"$",
"prefix",
",",
"$",
"baseDir",
")",
"{",
"$",
"prefix",
"=",
"trim",
"(",
"$",
"prefix",
",",
"'\\\\'",
")",
".",
"'\\\\'",
";",
"$",
"baseDir",
"=",
"rtrim",
"(",
"$",
"baseDir",
",",
"DIRECTORY_SEPARATOR",
")",
".",
"DIRECTORY_SEPARATOR",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"namespaceMap",
"[",
"$",
"prefix",
"]",
")",
")",
"{",
"$",
"this",
"->",
"namespaceMap",
"[",
"$",
"prefix",
"]",
"=",
"[",
"]",
";",
"}",
"array_push",
"(",
"$",
"this",
"->",
"namespaceMap",
"[",
"$",
"prefix",
"]",
",",
"str_replace",
"(",
"'$path'",
",",
"$",
"this",
"->",
"basePath",
",",
"$",
"baseDir",
")",
")",
";",
"}"
] |
Registers a PSR-4 namespace.
@param string $prefix
@param string $baseDir
|
[
"Registers",
"a",
"PSR",
"-",
"4",
"namespace",
"."
] |
e2288582432857771e85c9859acd6d32e5f2f9b7
|
https://github.com/ForceLabsDev/framework/blob/e2288582432857771e85c9859acd6d32e5f2f9b7/src/Psr/ClassLoader.php#L31-L39
|
237,812
|
ForceLabsDev/framework
|
src/Psr/ClassLoader.php
|
ClassLoader.register
|
public function register()
{
spl_autoload_register(function ($class) {
$prefix = $class;
while (false !== $pos = strrpos($prefix, '\\')) {
$prefix = substr($class, 0, $pos + 1);
$relativeClass = substr($class, $pos + 1);
$paths = $this->getPaths($prefix);
if ($paths !== null) {
foreach ($paths as $baseDir) {
$file = $baseDir.str_replace('\\', DIRECTORY_SEPARATOR, $relativeClass).'.php';
if (file_exists($file)) {
require $file;
return true;
}
}
}
$prefix = rtrim($prefix, '\\');
}
return false;
});
}
|
php
|
public function register()
{
spl_autoload_register(function ($class) {
$prefix = $class;
while (false !== $pos = strrpos($prefix, '\\')) {
$prefix = substr($class, 0, $pos + 1);
$relativeClass = substr($class, $pos + 1);
$paths = $this->getPaths($prefix);
if ($paths !== null) {
foreach ($paths as $baseDir) {
$file = $baseDir.str_replace('\\', DIRECTORY_SEPARATOR, $relativeClass).'.php';
if (file_exists($file)) {
require $file;
return true;
}
}
}
$prefix = rtrim($prefix, '\\');
}
return false;
});
}
|
[
"public",
"function",
"register",
"(",
")",
"{",
"spl_autoload_register",
"(",
"function",
"(",
"$",
"class",
")",
"{",
"$",
"prefix",
"=",
"$",
"class",
";",
"while",
"(",
"false",
"!==",
"$",
"pos",
"=",
"strrpos",
"(",
"$",
"prefix",
",",
"'\\\\'",
")",
")",
"{",
"$",
"prefix",
"=",
"substr",
"(",
"$",
"class",
",",
"0",
",",
"$",
"pos",
"+",
"1",
")",
";",
"$",
"relativeClass",
"=",
"substr",
"(",
"$",
"class",
",",
"$",
"pos",
"+",
"1",
")",
";",
"$",
"paths",
"=",
"$",
"this",
"->",
"getPaths",
"(",
"$",
"prefix",
")",
";",
"if",
"(",
"$",
"paths",
"!==",
"null",
")",
"{",
"foreach",
"(",
"$",
"paths",
"as",
"$",
"baseDir",
")",
"{",
"$",
"file",
"=",
"$",
"baseDir",
".",
"str_replace",
"(",
"'\\\\'",
",",
"DIRECTORY_SEPARATOR",
",",
"$",
"relativeClass",
")",
".",
"'.php'",
";",
"if",
"(",
"file_exists",
"(",
"$",
"file",
")",
")",
"{",
"require",
"$",
"file",
";",
"return",
"true",
";",
"}",
"}",
"}",
"$",
"prefix",
"=",
"rtrim",
"(",
"$",
"prefix",
",",
"'\\\\'",
")",
";",
"}",
"return",
"false",
";",
"}",
")",
";",
"}"
] |
Registers the autoloading via SPL.
|
[
"Registers",
"the",
"autoloading",
"via",
"SPL",
"."
] |
e2288582432857771e85c9859acd6d32e5f2f9b7
|
https://github.com/ForceLabsDev/framework/blob/e2288582432857771e85c9859acd6d32e5f2f9b7/src/Psr/ClassLoader.php#L61-L84
|
237,813
|
phPoirot/View
|
src/ViewModelTemplate.php
|
ViewModelTemplate.setRenderer
|
function setRenderer($renderer)
{
if (!$renderer instanceof iViewRenderer && !is_callable($renderer))
throw new \InvalidArgumentException(sprintf(
'Renderer must extend of (iViewRenderer) or callable. given: (%s)'
, \Poirot\Std\flatten($renderer)
));
$this->renderer = $renderer;
return $this;
}
|
php
|
function setRenderer($renderer)
{
if (!$renderer instanceof iViewRenderer && !is_callable($renderer))
throw new \InvalidArgumentException(sprintf(
'Renderer must extend of (iViewRenderer) or callable. given: (%s)'
, \Poirot\Std\flatten($renderer)
));
$this->renderer = $renderer;
return $this;
}
|
[
"function",
"setRenderer",
"(",
"$",
"renderer",
")",
"{",
"if",
"(",
"!",
"$",
"renderer",
"instanceof",
"iViewRenderer",
"&&",
"!",
"is_callable",
"(",
"$",
"renderer",
")",
")",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Renderer must extend of (iViewRenderer) or callable. given: (%s)'",
",",
"\\",
"Poirot",
"\\",
"Std",
"\\",
"flatten",
"(",
"$",
"renderer",
")",
")",
")",
";",
"$",
"this",
"->",
"renderer",
"=",
"$",
"renderer",
";",
"return",
"$",
"this",
";",
"}"
] |
Set Iso Renderer
Closure Renderer:
- function(string $templatePathName, array $viewVars)
@param iViewRenderer|\Closure|callable $renderer
@return $this
|
[
"Set",
"Iso",
"Renderer"
] |
37434b14ebc11e86651f356233a55ef36cac1cc0
|
https://github.com/phPoirot/View/blob/37434b14ebc11e86651f356233a55ef36cac1cc0/src/ViewModelTemplate.php#L118-L128
|
237,814
|
phPoirot/View
|
src/ViewModelTemplate.php
|
ViewModelTemplate.setResolverOptions
|
protected function setResolverOptions($options)
{
$resolver = $this->resolver();
$resolver->with($resolver::parseWith($options));
}
|
php
|
protected function setResolverOptions($options)
{
$resolver = $this->resolver();
$resolver->with($resolver::parseWith($options));
}
|
[
"protected",
"function",
"setResolverOptions",
"(",
"$",
"options",
")",
"{",
"$",
"resolver",
"=",
"$",
"this",
"->",
"resolver",
"(",
")",
";",
"$",
"resolver",
"->",
"with",
"(",
"$",
"resolver",
"::",
"parseWith",
"(",
"$",
"options",
")",
")",
";",
"}"
] |
Proxy Helper Options For Resolver
@param $options
|
[
"Proxy",
"Helper",
"Options",
"For",
"Resolver"
] |
37434b14ebc11e86651f356233a55ef36cac1cc0
|
https://github.com/phPoirot/View/blob/37434b14ebc11e86651f356233a55ef36cac1cc0/src/ViewModelTemplate.php#L160-L164
|
237,815
|
Archi-Strasbourg/archi-wiki
|
includes/framework/frameworkClasses/chartObject.class.php
|
chartObject.getMaxValue
|
public function getMaxValue()
{
$retour = 0;
foreach($this->listeValues as $indice => $value)
{
if(is_array($value))
{
for($i=0 ; $i<count($value) ; $i++)
{
if($value[$i]>$retour)
$retour = $value[$i];
}
}
else
{
if($value>$retour)
$retour = $value;
}
}
return $retour;
}
|
php
|
public function getMaxValue()
{
$retour = 0;
foreach($this->listeValues as $indice => $value)
{
if(is_array($value))
{
for($i=0 ; $i<count($value) ; $i++)
{
if($value[$i]>$retour)
$retour = $value[$i];
}
}
else
{
if($value>$retour)
$retour = $value;
}
}
return $retour;
}
|
[
"public",
"function",
"getMaxValue",
"(",
")",
"{",
"$",
"retour",
"=",
"0",
";",
"foreach",
"(",
"$",
"this",
"->",
"listeValues",
"as",
"$",
"indice",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"count",
"(",
"$",
"value",
")",
";",
"$",
"i",
"++",
")",
"{",
"if",
"(",
"$",
"value",
"[",
"$",
"i",
"]",
">",
"$",
"retour",
")",
"$",
"retour",
"=",
"$",
"value",
"[",
"$",
"i",
"]",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"$",
"value",
">",
"$",
"retour",
")",
"$",
"retour",
"=",
"$",
"value",
";",
"}",
"}",
"return",
"$",
"retour",
";",
"}"
] |
renvoi la valeur maximal parmis la liste de valeur
|
[
"renvoi",
"la",
"valeur",
"maximal",
"parmis",
"la",
"liste",
"de",
"valeur"
] |
b9fb39f43a78409890a7de96426c1f6c49d5c323
|
https://github.com/Archi-Strasbourg/archi-wiki/blob/b9fb39f43a78409890a7de96426c1f6c49d5c323/includes/framework/frameworkClasses/chartObject.class.php#L180-L201
|
237,816
|
michaelcullum/voting-lib
|
src/STV/Election.php
|
Election.getStateCandidates
|
public function getStateCandidates(int $state): array
{
$candidates = [];
foreach ($this->candidates as $candidateId => $candidate) {
if ($candidate->getState() == $state) {
$candidates[$candidateId] = $candidate;
}
}
return $candidates;
}
|
php
|
public function getStateCandidates(int $state): array
{
$candidates = [];
foreach ($this->candidates as $candidateId => $candidate) {
if ($candidate->getState() == $state) {
$candidates[$candidateId] = $candidate;
}
}
return $candidates;
}
|
[
"public",
"function",
"getStateCandidates",
"(",
"int",
"$",
"state",
")",
":",
"array",
"{",
"$",
"candidates",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"candidates",
"as",
"$",
"candidateId",
"=>",
"$",
"candidate",
")",
"{",
"if",
"(",
"$",
"candidate",
"->",
"getState",
"(",
")",
"==",
"$",
"state",
")",
"{",
"$",
"candidates",
"[",
"$",
"candidateId",
"]",
"=",
"$",
"candidate",
";",
"}",
"}",
"return",
"$",
"candidates",
";",
"}"
] |
Get all candidates of a specific state.
@param int $state A candidate state (See Candidate constants)
@return \Michaelc\Voting\STV\Candidate[]
|
[
"Get",
"all",
"candidates",
"of",
"a",
"specific",
"state",
"."
] |
83f0543493448021386e3a3b8c95d3268f1ee212
|
https://github.com/michaelcullum/voting-lib/blob/83f0543493448021386e3a3b8c95d3268f1ee212/src/STV/Election.php#L122-L133
|
237,817
|
michaelcullum/voting-lib
|
src/STV/Election.php
|
Election.getCandidateIds
|
public function getCandidateIds(): array
{
$candidateIds = [];
foreach ($this->candidates as $candidate) {
$candidateIds[] = $candidate->getId();
}
return $candidateIds;
}
|
php
|
public function getCandidateIds(): array
{
$candidateIds = [];
foreach ($this->candidates as $candidate) {
$candidateIds[] = $candidate->getId();
}
return $candidateIds;
}
|
[
"public",
"function",
"getCandidateIds",
"(",
")",
":",
"array",
"{",
"$",
"candidateIds",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"candidates",
"as",
"$",
"candidate",
")",
"{",
"$",
"candidateIds",
"[",
"]",
"=",
"$",
"candidate",
"->",
"getId",
"(",
")",
";",
"}",
"return",
"$",
"candidateIds",
";",
"}"
] |
Get an array of candidate ids.
@return int[]
|
[
"Get",
"an",
"array",
"of",
"candidate",
"ids",
"."
] |
83f0543493448021386e3a3b8c95d3268f1ee212
|
https://github.com/michaelcullum/voting-lib/blob/83f0543493448021386e3a3b8c95d3268f1ee212/src/STV/Election.php#L150-L159
|
237,818
|
michaelcullum/voting-lib
|
src/STV/Election.php
|
Election.getCandidatesStatus
|
public function getCandidatesStatus(): array
{
$candidates = [];
foreach ($this->getElectedCandidates() as $candidate) {
$candidates['elected'][] = $candidate->getId();
}
foreach ($this->getActiveCandidates() as $candidate) {
$candidates['active'][] = [$candidate->getId(), $candidate->getVotes()];
}
foreach ($this->getDefeatedCandidates() as $candidate) {
$candidates['defeated'][] = $candidate->getId();
}
return $candidates;
}
|
php
|
public function getCandidatesStatus(): array
{
$candidates = [];
foreach ($this->getElectedCandidates() as $candidate) {
$candidates['elected'][] = $candidate->getId();
}
foreach ($this->getActiveCandidates() as $candidate) {
$candidates['active'][] = [$candidate->getId(), $candidate->getVotes()];
}
foreach ($this->getDefeatedCandidates() as $candidate) {
$candidates['defeated'][] = $candidate->getId();
}
return $candidates;
}
|
[
"public",
"function",
"getCandidatesStatus",
"(",
")",
":",
"array",
"{",
"$",
"candidates",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"getElectedCandidates",
"(",
")",
"as",
"$",
"candidate",
")",
"{",
"$",
"candidates",
"[",
"'elected'",
"]",
"[",
"]",
"=",
"$",
"candidate",
"->",
"getId",
"(",
")",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"getActiveCandidates",
"(",
")",
"as",
"$",
"candidate",
")",
"{",
"$",
"candidates",
"[",
"'active'",
"]",
"[",
"]",
"=",
"[",
"$",
"candidate",
"->",
"getId",
"(",
")",
",",
"$",
"candidate",
"->",
"getVotes",
"(",
")",
"]",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"getDefeatedCandidates",
"(",
")",
"as",
"$",
"candidate",
")",
"{",
"$",
"candidates",
"[",
"'defeated'",
"]",
"[",
"]",
"=",
"$",
"candidate",
"->",
"getId",
"(",
")",
";",
"}",
"return",
"$",
"candidates",
";",
"}"
] |
Get status of all candidates.
@return array
|
[
"Get",
"status",
"of",
"all",
"candidates",
"."
] |
83f0543493448021386e3a3b8c95d3268f1ee212
|
https://github.com/michaelcullum/voting-lib/blob/83f0543493448021386e3a3b8c95d3268f1ee212/src/STV/Election.php#L206-L223
|
237,819
|
NamelessCoder/gizzle-git-plugins
|
src/GizzlePlugins/PullPlugin.php
|
PullPlugin.process
|
public function process(Payload $payload) {
$directory = $this->getDirectorySettingOrFail();
$branch = $this->getSettingValue(self::OPTION_BRANCH, $payload->getRepository()->getMasterBranch());
$url = $this->getSettingValue(self::OPTION_REPOSITORY, $payload->getRepository()->getUrl());
$git = $this->resolveGitCommand();
$command = array(
'cd', escapeshellarg($directory), '&&',
$git, self::COMMAND, escapeshellarg($url), escapeshellarg($branch)
);
if (TRUE === (boolean) $this->getSettingValue(self::OPTION_REBASE, FALSE)) {
$command[] = self::COMMAND_REBASE;
}
$output = $this->executeGitCommand($command);
$payload->getResponse()->addOutputFromPlugin($this, $output);
}
|
php
|
public function process(Payload $payload) {
$directory = $this->getDirectorySettingOrFail();
$branch = $this->getSettingValue(self::OPTION_BRANCH, $payload->getRepository()->getMasterBranch());
$url = $this->getSettingValue(self::OPTION_REPOSITORY, $payload->getRepository()->getUrl());
$git = $this->resolveGitCommand();
$command = array(
'cd', escapeshellarg($directory), '&&',
$git, self::COMMAND, escapeshellarg($url), escapeshellarg($branch)
);
if (TRUE === (boolean) $this->getSettingValue(self::OPTION_REBASE, FALSE)) {
$command[] = self::COMMAND_REBASE;
}
$output = $this->executeGitCommand($command);
$payload->getResponse()->addOutputFromPlugin($this, $output);
}
|
[
"public",
"function",
"process",
"(",
"Payload",
"$",
"payload",
")",
"{",
"$",
"directory",
"=",
"$",
"this",
"->",
"getDirectorySettingOrFail",
"(",
")",
";",
"$",
"branch",
"=",
"$",
"this",
"->",
"getSettingValue",
"(",
"self",
"::",
"OPTION_BRANCH",
",",
"$",
"payload",
"->",
"getRepository",
"(",
")",
"->",
"getMasterBranch",
"(",
")",
")",
";",
"$",
"url",
"=",
"$",
"this",
"->",
"getSettingValue",
"(",
"self",
"::",
"OPTION_REPOSITORY",
",",
"$",
"payload",
"->",
"getRepository",
"(",
")",
"->",
"getUrl",
"(",
")",
")",
";",
"$",
"git",
"=",
"$",
"this",
"->",
"resolveGitCommand",
"(",
")",
";",
"$",
"command",
"=",
"array",
"(",
"'cd'",
",",
"escapeshellarg",
"(",
"$",
"directory",
")",
",",
"'&&'",
",",
"$",
"git",
",",
"self",
"::",
"COMMAND",
",",
"escapeshellarg",
"(",
"$",
"url",
")",
",",
"escapeshellarg",
"(",
"$",
"branch",
")",
")",
";",
"if",
"(",
"TRUE",
"===",
"(",
"boolean",
")",
"$",
"this",
"->",
"getSettingValue",
"(",
"self",
"::",
"OPTION_REBASE",
",",
"FALSE",
")",
")",
"{",
"$",
"command",
"[",
"]",
"=",
"self",
"::",
"COMMAND_REBASE",
";",
"}",
"$",
"output",
"=",
"$",
"this",
"->",
"executeGitCommand",
"(",
"$",
"command",
")",
";",
"$",
"payload",
"->",
"getResponse",
"(",
")",
"->",
"addOutputFromPlugin",
"(",
"$",
"this",
",",
"$",
"output",
")",
";",
"}"
] |
Perform whichever task the Plugin should perform based
on the payload's data.
@param Payload $payload
@return void
|
[
"Perform",
"whichever",
"task",
"the",
"Plugin",
"should",
"perform",
"based",
"on",
"the",
"payload",
"s",
"data",
"."
] |
7c476db81b58bed7dc769866491b2adb6ddb19bb
|
https://github.com/NamelessCoder/gizzle-git-plugins/blob/7c476db81b58bed7dc769866491b2adb6ddb19bb/src/GizzlePlugins/PullPlugin.php#L33-L47
|
237,820
|
ItinerisLtd/preflight-command
|
src/CheckerCollection.php
|
CheckerCollection.set
|
public function set(CheckerInterface $checker): self
{
$this->checkers[$checker->getId()] = $checker;
return $this;
}
|
php
|
public function set(CheckerInterface $checker): self
{
$this->checkers[$checker->getId()] = $checker;
return $this;
}
|
[
"public",
"function",
"set",
"(",
"CheckerInterface",
"$",
"checker",
")",
":",
"self",
"{",
"$",
"this",
"->",
"checkers",
"[",
"$",
"checker",
"->",
"getId",
"(",
")",
"]",
"=",
"$",
"checker",
";",
"return",
"$",
"this",
";",
"}"
] |
Add or replace a checker instance to the collection at given id.
@param CheckerInterface $checker The checker instance.
@return CheckerCollection
|
[
"Add",
"or",
"replace",
"a",
"checker",
"instance",
"to",
"the",
"collection",
"at",
"given",
"id",
"."
] |
d1c1360ea8d7de0312b5c0c09c9c486949594049
|
https://github.com/ItinerisLtd/preflight-command/blob/d1c1360ea8d7de0312b5c0c09c9c486949594049/src/CheckerCollection.php#L22-L27
|
237,821
|
tomvlk/sweet-orm
|
src/SweetORM/Structure/ValidationManager.php
|
ValidationManager.validator
|
public static function validator (EntityStructure $entityStructure, $data)
{
switch (gettype($data)) {
case 'array':
return new ArrayValidator($entityStructure, $data);
default:
return false;
}
}
|
php
|
public static function validator (EntityStructure $entityStructure, $data)
{
switch (gettype($data)) {
case 'array':
return new ArrayValidator($entityStructure, $data);
default:
return false;
}
}
|
[
"public",
"static",
"function",
"validator",
"(",
"EntityStructure",
"$",
"entityStructure",
",",
"$",
"data",
")",
"{",
"switch",
"(",
"gettype",
"(",
"$",
"data",
")",
")",
"{",
"case",
"'array'",
":",
"return",
"new",
"ArrayValidator",
"(",
"$",
"entityStructure",
",",
"$",
"data",
")",
";",
"default",
":",
"return",
"false",
";",
"}",
"}"
] |
Get validator matching for the given data type.
@param EntityStructure $entityStructure
@param mixed $data
@return Validator|false
@codeCoverageIgnore ignore due to the coverage issue in switches.
|
[
"Get",
"validator",
"matching",
"for",
"the",
"given",
"data",
"type",
"."
] |
bca014a9f83be34c87b14d6c8a36156e24577374
|
https://github.com/tomvlk/sweet-orm/blob/bca014a9f83be34c87b14d6c8a36156e24577374/src/SweetORM/Structure/ValidationManager.php#L30-L38
|
237,822
|
ptorn/bth-anax-user
|
src/User/UserController.php
|
UserController.init
|
public function init()
{
$this->userService = $this->di->get("userService");
$this->session = $this->di->get("session");
$this->response = $this->di->get("response");
$this->view = $this->di->get("view");
$this->pageRender = $this->di->get("pageRender");
}
|
php
|
public function init()
{
$this->userService = $this->di->get("userService");
$this->session = $this->di->get("session");
$this->response = $this->di->get("response");
$this->view = $this->di->get("view");
$this->pageRender = $this->di->get("pageRender");
}
|
[
"public",
"function",
"init",
"(",
")",
"{",
"$",
"this",
"->",
"userService",
"=",
"$",
"this",
"->",
"di",
"->",
"get",
"(",
"\"userService\"",
")",
";",
"$",
"this",
"->",
"session",
"=",
"$",
"this",
"->",
"di",
"->",
"get",
"(",
"\"session\"",
")",
";",
"$",
"this",
"->",
"response",
"=",
"$",
"this",
"->",
"di",
"->",
"get",
"(",
"\"response\"",
")",
";",
"$",
"this",
"->",
"view",
"=",
"$",
"this",
"->",
"di",
"->",
"get",
"(",
"\"view\"",
")",
";",
"$",
"this",
"->",
"pageRender",
"=",
"$",
"this",
"->",
"di",
"->",
"get",
"(",
"\"pageRender\"",
")",
";",
"}"
] |
Initiate the controller.
@return void
|
[
"Initiate",
"the",
"controller",
"."
] |
223e569cbebfd3f9302bdef648b13b73cb3f1d19
|
https://github.com/ptorn/bth-anax-user/blob/223e569cbebfd3f9302bdef648b13b73cb3f1d19/src/User/UserController.php#L31-L38
|
237,823
|
ptorn/bth-anax-user
|
src/User/UserController.php
|
UserController.getPostLogin
|
public function getPostLogin()
{
if ($this->userService->checkLoggedin()) {
$this->response->redirect("");
}
$title = "Administration - Login";
$form = new UserLoginForm($this->di);
$form->check();
$data = [
"form" => $form->getHTML(),
];
$this->view->add("user/login", $data);
$this->pageRender->renderPage(["title" => $title]);
}
|
php
|
public function getPostLogin()
{
if ($this->userService->checkLoggedin()) {
$this->response->redirect("");
}
$title = "Administration - Login";
$form = new UserLoginForm($this->di);
$form->check();
$data = [
"form" => $form->getHTML(),
];
$this->view->add("user/login", $data);
$this->pageRender->renderPage(["title" => $title]);
}
|
[
"public",
"function",
"getPostLogin",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"userService",
"->",
"checkLoggedin",
"(",
")",
")",
"{",
"$",
"this",
"->",
"response",
"->",
"redirect",
"(",
"\"\"",
")",
";",
"}",
"$",
"title",
"=",
"\"Administration - Login\"",
";",
"$",
"form",
"=",
"new",
"UserLoginForm",
"(",
"$",
"this",
"->",
"di",
")",
";",
"$",
"form",
"->",
"check",
"(",
")",
";",
"$",
"data",
"=",
"[",
"\"form\"",
"=>",
"$",
"form",
"->",
"getHTML",
"(",
")",
",",
"]",
";",
"$",
"this",
"->",
"view",
"->",
"add",
"(",
"\"user/login\"",
",",
"$",
"data",
")",
";",
"$",
"this",
"->",
"pageRender",
"->",
"renderPage",
"(",
"[",
"\"title\"",
"=>",
"$",
"title",
"]",
")",
";",
"}"
] |
Login-page
@throws Exception
@return void
|
[
"Login",
"-",
"page"
] |
223e569cbebfd3f9302bdef648b13b73cb3f1d19
|
https://github.com/ptorn/bth-anax-user/blob/223e569cbebfd3f9302bdef648b13b73cb3f1d19/src/User/UserController.php#L49-L67
|
237,824
|
afonzeca/arun-core
|
src/ArunCore/Core/Helpers/Sanitizer.php
|
Sanitizer.stripBadChars
|
public function stripBadChars(string $parameter, array $optionalChars = []): string
{
return str_replace(self::badChars . $optionalChars, "", $parameter);
}
|
php
|
public function stripBadChars(string $parameter, array $optionalChars = []): string
{
return str_replace(self::badChars . $optionalChars, "", $parameter);
}
|
[
"public",
"function",
"stripBadChars",
"(",
"string",
"$",
"parameter",
",",
"array",
"$",
"optionalChars",
"=",
"[",
"]",
")",
":",
"string",
"{",
"return",
"str_replace",
"(",
"self",
"::",
"badChars",
".",
"$",
"optionalChars",
",",
"\"\"",
",",
"$",
"parameter",
")",
";",
"}"
] |
Strip unauthorized chars from string
@param string $parameter []
@param array $optionalChars
@return string
|
[
"Strip",
"unauthorized",
"chars",
"from",
"string"
] |
7a8af37e326187ff9ed7e2ff7bde6a489a9803a2
|
https://github.com/afonzeca/arun-core/blob/7a8af37e326187ff9ed7e2ff7bde6a489a9803a2/src/ArunCore/Core/Helpers/Sanitizer.php#L62-L65
|
237,825
|
calgamo/config
|
src/ConfigReader.php
|
ConfigReader.readFromArray
|
public function readFromArray(array $data) : array
{
foreach($data as $key => $value)
{
if (is_string($value)){
$value = $this->macro_processor->process($value);
$data[$key] = $value;
}
else if(is_array($value)){
$data[$key] = $this->readFromArray($value);
}
}
return $data;
}
|
php
|
public function readFromArray(array $data) : array
{
foreach($data as $key => $value)
{
if (is_string($value)){
$value = $this->macro_processor->process($value);
$data[$key] = $value;
}
else if(is_array($value)){
$data[$key] = $this->readFromArray($value);
}
}
return $data;
}
|
[
"public",
"function",
"readFromArray",
"(",
"array",
"$",
"data",
")",
":",
"array",
"{",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"macro_processor",
"->",
"process",
"(",
"$",
"value",
")",
";",
"$",
"data",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"else",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"data",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"readFromArray",
"(",
"$",
"value",
")",
";",
"}",
"}",
"return",
"$",
"data",
";",
"}"
] |
Read from array
@param array $data
@return array
|
[
"Read",
"from",
"array"
] |
315c87f0ab1283a805a24db3a6220eda281d49e8
|
https://github.com/calgamo/config/blob/315c87f0ab1283a805a24db3a6220eda281d49e8/src/ConfigReader.php#L58-L71
|
237,826
|
loopsframework/base
|
src/Loops/Object.php
|
Object.offsetGet
|
public function offsetGet($offset) {
if($this->ResolveTraitOffsetExists($offset)) {
return $this->ResolveTraitOffsetGet($offset);
}
if($this->AccessTraitOffsetExists($offset)) {
return $this->AccessTraitOffsetGet($offset);
}
//return service if one exists with the requested name
if($this->getLoops()->hasService($offset)) {
return $this->getLoops()->getService($offset);
}
user_error("Undefined index: $offset", E_USER_NOTICE);
}
|
php
|
public function offsetGet($offset) {
if($this->ResolveTraitOffsetExists($offset)) {
return $this->ResolveTraitOffsetGet($offset);
}
if($this->AccessTraitOffsetExists($offset)) {
return $this->AccessTraitOffsetGet($offset);
}
//return service if one exists with the requested name
if($this->getLoops()->hasService($offset)) {
return $this->getLoops()->getService($offset);
}
user_error("Undefined index: $offset", E_USER_NOTICE);
}
|
[
"public",
"function",
"offsetGet",
"(",
"$",
"offset",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"ResolveTraitOffsetExists",
"(",
"$",
"offset",
")",
")",
"{",
"return",
"$",
"this",
"->",
"ResolveTraitOffsetGet",
"(",
"$",
"offset",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"AccessTraitOffsetExists",
"(",
"$",
"offset",
")",
")",
"{",
"return",
"$",
"this",
"->",
"AccessTraitOffsetGet",
"(",
"$",
"offset",
")",
";",
"}",
"//return service if one exists with the requested name",
"if",
"(",
"$",
"this",
"->",
"getLoops",
"(",
")",
"->",
"hasService",
"(",
"$",
"offset",
")",
")",
"{",
"return",
"$",
"this",
"->",
"getLoops",
"(",
")",
"->",
"getService",
"(",
"$",
"offset",
")",
";",
"}",
"user_error",
"(",
"\"Undefined index: $offset\"",
",",
"E_USER_NOTICE",
")",
";",
"}"
] |
Gets a value either via the ResolveTrait, AccessTrait or the loops getService functionality
Values are checked in that order. If no value existed, a notice will be generated.
@param string $key The name of the service
@return mixed The requested service or NULL if not available
|
[
"Gets",
"a",
"value",
"either",
"via",
"the",
"ResolveTrait",
"AccessTrait",
"or",
"the",
"loops",
"getService",
"functionality"
] |
5a15172ed4e543d7d5ecd8bd65e31f26bab3d192
|
https://github.com/loopsframework/base/blob/5a15172ed4e543d7d5ecd8bd65e31f26bab3d192/src/Loops/Object.php#L91-L106
|
237,827
|
GrupaZero/core
|
src/Gzero/Core/Services/RoutesService.php
|
RoutesService.add
|
public function add(...$parameters)
{
if (count($parameters) === 1) {
$this->routes['regular'][] = ['closure' => $parameters[0], 'groupArgs' => []];
} elseif (count($parameters) === 2) {
$this->routes['regular'][] = ['closure' => $parameters[1], 'groupArgs' => $parameters[0]];
} else {
throw new \InvalidArgumentException;
}
}
|
php
|
public function add(...$parameters)
{
if (count($parameters) === 1) {
$this->routes['regular'][] = ['closure' => $parameters[0], 'groupArgs' => []];
} elseif (count($parameters) === 2) {
$this->routes['regular'][] = ['closure' => $parameters[1], 'groupArgs' => $parameters[0]];
} else {
throw new \InvalidArgumentException;
}
}
|
[
"public",
"function",
"add",
"(",
"...",
"$",
"parameters",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"parameters",
")",
"===",
"1",
")",
"{",
"$",
"this",
"->",
"routes",
"[",
"'regular'",
"]",
"[",
"]",
"=",
"[",
"'closure'",
"=>",
"$",
"parameters",
"[",
"0",
"]",
",",
"'groupArgs'",
"=>",
"[",
"]",
"]",
";",
"}",
"elseif",
"(",
"count",
"(",
"$",
"parameters",
")",
"===",
"2",
")",
"{",
"$",
"this",
"->",
"routes",
"[",
"'regular'",
"]",
"[",
"]",
"=",
"[",
"'closure'",
"=>",
"$",
"parameters",
"[",
"1",
"]",
",",
"'groupArgs'",
"=>",
"$",
"parameters",
"[",
"0",
"]",
"]",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
";",
"}",
"}"
] |
Add non multilingual route
@param array ...$parameters closure or group options plus closure
@throws \InvalidArgumentException
@return void
|
[
"Add",
"non",
"multilingual",
"route"
] |
093e515234fa0385b259ba4d8bc7832174a44eab
|
https://github.com/GrupaZero/core/blob/093e515234fa0385b259ba4d8bc7832174a44eab/src/Gzero/Core/Services/RoutesService.php#L23-L32
|
237,828
|
GrupaZero/core
|
src/Gzero/Core/Services/RoutesService.php
|
RoutesService.addMultiLanguage
|
public function addMultiLanguage(...$parameters)
{
if (count($parameters) === 1) {
$this->routes['ml'][] = ['closure' => $parameters[0], 'groupArgs' => []];
} elseif (count($parameters) === 2) {
$this->routes['ml'][] = ['closure' => $parameters[1], 'groupArgs' => $parameters[0]];
} else {
throw new \InvalidArgumentException;
}
}
|
php
|
public function addMultiLanguage(...$parameters)
{
if (count($parameters) === 1) {
$this->routes['ml'][] = ['closure' => $parameters[0], 'groupArgs' => []];
} elseif (count($parameters) === 2) {
$this->routes['ml'][] = ['closure' => $parameters[1], 'groupArgs' => $parameters[0]];
} else {
throw new \InvalidArgumentException;
}
}
|
[
"public",
"function",
"addMultiLanguage",
"(",
"...",
"$",
"parameters",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"parameters",
")",
"===",
"1",
")",
"{",
"$",
"this",
"->",
"routes",
"[",
"'ml'",
"]",
"[",
"]",
"=",
"[",
"'closure'",
"=>",
"$",
"parameters",
"[",
"0",
"]",
",",
"'groupArgs'",
"=>",
"[",
"]",
"]",
";",
"}",
"elseif",
"(",
"count",
"(",
"$",
"parameters",
")",
"===",
"2",
")",
"{",
"$",
"this",
"->",
"routes",
"[",
"'ml'",
"]",
"[",
"]",
"=",
"[",
"'closure'",
"=>",
"$",
"parameters",
"[",
"1",
"]",
",",
"'groupArgs'",
"=>",
"$",
"parameters",
"[",
"0",
"]",
"]",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
";",
"}",
"}"
] |
Add multilingual route
@param array ...$parameters closure or group options plus closure
@throws \InvalidArgumentException
@return void
|
[
"Add",
"multilingual",
"route"
] |
093e515234fa0385b259ba4d8bc7832174a44eab
|
https://github.com/GrupaZero/core/blob/093e515234fa0385b259ba4d8bc7832174a44eab/src/Gzero/Core/Services/RoutesService.php#L43-L52
|
237,829
|
GrupaZero/core
|
src/Gzero/Core/Services/RoutesService.php
|
RoutesService.setCatchAll
|
public function setCatchAll(...$parameters)
{
if (count($parameters) === 1) {
$this->routes['catchAll'] = ['closure' => $parameters[0], 'groupArgs' => []];
} elseif (count($parameters) === 2) {
$this->routes['catchAll'] = ['closure' => $parameters[1], 'groupArgs' => $parameters[0]];
} else {
throw new \InvalidArgumentException;
}
}
|
php
|
public function setCatchAll(...$parameters)
{
if (count($parameters) === 1) {
$this->routes['catchAll'] = ['closure' => $parameters[0], 'groupArgs' => []];
} elseif (count($parameters) === 2) {
$this->routes['catchAll'] = ['closure' => $parameters[1], 'groupArgs' => $parameters[0]];
} else {
throw new \InvalidArgumentException;
}
}
|
[
"public",
"function",
"setCatchAll",
"(",
"...",
"$",
"parameters",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"parameters",
")",
"===",
"1",
")",
"{",
"$",
"this",
"->",
"routes",
"[",
"'catchAll'",
"]",
"=",
"[",
"'closure'",
"=>",
"$",
"parameters",
"[",
"0",
"]",
",",
"'groupArgs'",
"=>",
"[",
"]",
"]",
";",
"}",
"elseif",
"(",
"count",
"(",
"$",
"parameters",
")",
"===",
"2",
")",
"{",
"$",
"this",
"->",
"routes",
"[",
"'catchAll'",
"]",
"=",
"[",
"'closure'",
"=>",
"$",
"parameters",
"[",
"1",
"]",
",",
"'groupArgs'",
"=>",
"$",
"parameters",
"[",
"0",
"]",
"]",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
";",
"}",
"}"
] |
Add catch all route
@param array ...$parameters closure or group options plus closure
@throws \InvalidArgumentException
@return void
|
[
"Add",
"catch",
"all",
"route"
] |
093e515234fa0385b259ba4d8bc7832174a44eab
|
https://github.com/GrupaZero/core/blob/093e515234fa0385b259ba4d8bc7832174a44eab/src/Gzero/Core/Services/RoutesService.php#L63-L72
|
237,830
|
GrupaZero/core
|
src/Gzero/Core/Services/RoutesService.php
|
RoutesService.registerAll
|
public function registerAll()
{
/** @var LanguageService $service */
$service = resolve(LanguageService::class);
$languages = $service->getAllEnabled();
foreach ($this->routes['ml'] as $value) {
foreach ($languages as $language) {
$prefix = null;
if (!$language->is_default) {
$prefix = $language->code;
}
Route::group(
array_merge(['prefix' => $prefix], $value['groupArgs']),
function ($router) use ($value, $language) {
$value['closure']($router, $language->code);
}
);
}
}
foreach ($this->routes['regular'] as $value) {
Route::group(
$value['groupArgs'],
function ($router) use ($value) {
$value['closure']($router);
}
);
}
if (!empty($this->routes['catchAll'])) {
Route::group(
$this->routes['catchAll']['groupArgs'],
function ($router) {
$this->routes['catchAll']['closure']($router);
}
);
}
$router = resolve('router');
$router->getRoutes()->refreshActionLookups();
$router->getRoutes()->refreshNameLookups();
}
|
php
|
public function registerAll()
{
/** @var LanguageService $service */
$service = resolve(LanguageService::class);
$languages = $service->getAllEnabled();
foreach ($this->routes['ml'] as $value) {
foreach ($languages as $language) {
$prefix = null;
if (!$language->is_default) {
$prefix = $language->code;
}
Route::group(
array_merge(['prefix' => $prefix], $value['groupArgs']),
function ($router) use ($value, $language) {
$value['closure']($router, $language->code);
}
);
}
}
foreach ($this->routes['regular'] as $value) {
Route::group(
$value['groupArgs'],
function ($router) use ($value) {
$value['closure']($router);
}
);
}
if (!empty($this->routes['catchAll'])) {
Route::group(
$this->routes['catchAll']['groupArgs'],
function ($router) {
$this->routes['catchAll']['closure']($router);
}
);
}
$router = resolve('router');
$router->getRoutes()->refreshActionLookups();
$router->getRoutes()->refreshNameLookups();
}
|
[
"public",
"function",
"registerAll",
"(",
")",
"{",
"/** @var LanguageService $service */",
"$",
"service",
"=",
"resolve",
"(",
"LanguageService",
"::",
"class",
")",
";",
"$",
"languages",
"=",
"$",
"service",
"->",
"getAllEnabled",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"routes",
"[",
"'ml'",
"]",
"as",
"$",
"value",
")",
"{",
"foreach",
"(",
"$",
"languages",
"as",
"$",
"language",
")",
"{",
"$",
"prefix",
"=",
"null",
";",
"if",
"(",
"!",
"$",
"language",
"->",
"is_default",
")",
"{",
"$",
"prefix",
"=",
"$",
"language",
"->",
"code",
";",
"}",
"Route",
"::",
"group",
"(",
"array_merge",
"(",
"[",
"'prefix'",
"=>",
"$",
"prefix",
"]",
",",
"$",
"value",
"[",
"'groupArgs'",
"]",
")",
",",
"function",
"(",
"$",
"router",
")",
"use",
"(",
"$",
"value",
",",
"$",
"language",
")",
"{",
"$",
"value",
"[",
"'closure'",
"]",
"(",
"$",
"router",
",",
"$",
"language",
"->",
"code",
")",
";",
"}",
")",
";",
"}",
"}",
"foreach",
"(",
"$",
"this",
"->",
"routes",
"[",
"'regular'",
"]",
"as",
"$",
"value",
")",
"{",
"Route",
"::",
"group",
"(",
"$",
"value",
"[",
"'groupArgs'",
"]",
",",
"function",
"(",
"$",
"router",
")",
"use",
"(",
"$",
"value",
")",
"{",
"$",
"value",
"[",
"'closure'",
"]",
"(",
"$",
"router",
")",
";",
"}",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"routes",
"[",
"'catchAll'",
"]",
")",
")",
"{",
"Route",
"::",
"group",
"(",
"$",
"this",
"->",
"routes",
"[",
"'catchAll'",
"]",
"[",
"'groupArgs'",
"]",
",",
"function",
"(",
"$",
"router",
")",
"{",
"$",
"this",
"->",
"routes",
"[",
"'catchAll'",
"]",
"[",
"'closure'",
"]",
"(",
"$",
"router",
")",
";",
"}",
")",
";",
"}",
"$",
"router",
"=",
"resolve",
"(",
"'router'",
")",
";",
"$",
"router",
"->",
"getRoutes",
"(",
")",
"->",
"refreshActionLookups",
"(",
")",
";",
"$",
"router",
"->",
"getRoutes",
"(",
")",
"->",
"refreshNameLookups",
"(",
")",
";",
"}"
] |
It registers all routes
@return void
|
[
"It",
"registers",
"all",
"routes"
] |
093e515234fa0385b259ba4d8bc7832174a44eab
|
https://github.com/GrupaZero/core/blob/093e515234fa0385b259ba4d8bc7832174a44eab/src/Gzero/Core/Services/RoutesService.php#L79-L118
|
237,831
|
WellCommerce/DataGrid
|
Column/ColumnCollection.php
|
ColumnCollection.get
|
public function get($identifier) : ColumnInterface
{
if (false === $this->has($identifier)) {
throw new ColumnNotFoundException($identifier);
}
return $this->items[$identifier];
}
|
php
|
public function get($identifier) : ColumnInterface
{
if (false === $this->has($identifier)) {
throw new ColumnNotFoundException($identifier);
}
return $this->items[$identifier];
}
|
[
"public",
"function",
"get",
"(",
"$",
"identifier",
")",
":",
"ColumnInterface",
"{",
"if",
"(",
"false",
"===",
"$",
"this",
"->",
"has",
"(",
"$",
"identifier",
")",
")",
"{",
"throw",
"new",
"ColumnNotFoundException",
"(",
"$",
"identifier",
")",
";",
"}",
"return",
"$",
"this",
"->",
"items",
"[",
"$",
"identifier",
"]",
";",
"}"
] |
Returns column by its identifier
@param string $identifier Column identifier
@return ColumnInterface
|
[
"Returns",
"column",
"by",
"its",
"identifier"
] |
5ce3cd47c7902aaeb07c343a76574399286f56ff
|
https://github.com/WellCommerce/DataGrid/blob/5ce3cd47c7902aaeb07c343a76574399286f56ff/Column/ColumnCollection.php#L42-L49
|
237,832
|
flextype-components/debug
|
Debug.php
|
Debug.elapsedTime
|
public static function elapsedTime(string $point_name) : string
{
if (isset(Debug::$time[$point_name])) return sprintf("%01.4f", microtime(true) - Debug::$time[$point_name]);
}
|
php
|
public static function elapsedTime(string $point_name) : string
{
if (isset(Debug::$time[$point_name])) return sprintf("%01.4f", microtime(true) - Debug::$time[$point_name]);
}
|
[
"public",
"static",
"function",
"elapsedTime",
"(",
"string",
"$",
"point_name",
")",
":",
"string",
"{",
"if",
"(",
"isset",
"(",
"Debug",
"::",
"$",
"time",
"[",
"$",
"point_name",
"]",
")",
")",
"return",
"sprintf",
"(",
"\"%01.4f\"",
",",
"microtime",
"(",
"true",
")",
"-",
"Debug",
"::",
"$",
"time",
"[",
"$",
"point_name",
"]",
")",
";",
"}"
] |
Get elapsed time for current point
echo Debug::elapsedTime('point_name');
@param string $point_name Point name
@return string
|
[
"Get",
"elapsed",
"time",
"for",
"current",
"point"
] |
af8a12f0cecf713ea8394694c75b5be065a35ffe
|
https://github.com/flextype-components/debug/blob/af8a12f0cecf713ea8394694c75b5be065a35ffe/Debug.php#L51-L54
|
237,833
|
flextype-components/debug
|
Debug.php
|
Debug.memoryUsage
|
public static function memoryUsage(string $point_name) : string
{
if (isset(Debug::$memory[$point_name])) {
$unit = array('B', 'KB', 'MB', 'GB', 'TiB', 'PiB');
$size = memory_get_usage() - Debug::$memory[$point_name];
$memory_usage = @round($size/pow(1024, ($i=floor(log($size, 1024)))), 2).' '.$unit[($i < 0 ? 0 : $i)];
return $memory_usage;
}
}
|
php
|
public static function memoryUsage(string $point_name) : string
{
if (isset(Debug::$memory[$point_name])) {
$unit = array('B', 'KB', 'MB', 'GB', 'TiB', 'PiB');
$size = memory_get_usage() - Debug::$memory[$point_name];
$memory_usage = @round($size/pow(1024, ($i=floor(log($size, 1024)))), 2).' '.$unit[($i < 0 ? 0 : $i)];
return $memory_usage;
}
}
|
[
"public",
"static",
"function",
"memoryUsage",
"(",
"string",
"$",
"point_name",
")",
":",
"string",
"{",
"if",
"(",
"isset",
"(",
"Debug",
"::",
"$",
"memory",
"[",
"$",
"point_name",
"]",
")",
")",
"{",
"$",
"unit",
"=",
"array",
"(",
"'B'",
",",
"'KB'",
",",
"'MB'",
",",
"'GB'",
",",
"'TiB'",
",",
"'PiB'",
")",
";",
"$",
"size",
"=",
"memory_get_usage",
"(",
")",
"-",
"Debug",
"::",
"$",
"memory",
"[",
"$",
"point_name",
"]",
";",
"$",
"memory_usage",
"=",
"@",
"round",
"(",
"$",
"size",
"/",
"pow",
"(",
"1024",
",",
"(",
"$",
"i",
"=",
"floor",
"(",
"log",
"(",
"$",
"size",
",",
"1024",
")",
")",
")",
")",
",",
"2",
")",
".",
"' '",
".",
"$",
"unit",
"[",
"(",
"$",
"i",
"<",
"0",
"?",
"0",
":",
"$",
"i",
")",
"]",
";",
"return",
"$",
"memory_usage",
";",
"}",
"}"
] |
Get memory usage for current point
echo Debug::memoryUsage('point_name');
@param string $point_name Point name
@return string
|
[
"Get",
"memory",
"usage",
"for",
"current",
"point"
] |
af8a12f0cecf713ea8394694c75b5be065a35ffe
|
https://github.com/flextype-components/debug/blob/af8a12f0cecf713ea8394694c75b5be065a35ffe/Debug.php#L76-L84
|
237,834
|
clusterpoint/php-client-api
|
request.class.php
|
CPS_Request.setShape
|
public function setShape($value, $replace = true)
{
$name = 'shapes';
if (!(is_array($value) || is_string($value))) {
throw new CPS_Exception(array(array('long_message' => 'Invalid request parameter', 'code' => ERROR_CODE_INVALID_PARAMETER, 'level' => 'REJECTED', 'source' => 'CPS_API')));
}
if ($replace) {
$this->_setRawParam($name, $value);
} else {
$exParam = $this->_getRawParam($name);
if (!is_array($exParam)) {
$exParam = array($exParam);
}
if (is_array($value)) {
foreach($value as $val){
$exParam[] = $val;
}
} else if (is_string($value)) {
$exParam[] = $value;
}
$this->_setRawParam($name, $exParam);
}
}
|
php
|
public function setShape($value, $replace = true)
{
$name = 'shapes';
if (!(is_array($value) || is_string($value))) {
throw new CPS_Exception(array(array('long_message' => 'Invalid request parameter', 'code' => ERROR_CODE_INVALID_PARAMETER, 'level' => 'REJECTED', 'source' => 'CPS_API')));
}
if ($replace) {
$this->_setRawParam($name, $value);
} else {
$exParam = $this->_getRawParam($name);
if (!is_array($exParam)) {
$exParam = array($exParam);
}
if (is_array($value)) {
foreach($value as $val){
$exParam[] = $val;
}
} else if (is_string($value)) {
$exParam[] = $value;
}
$this->_setRawParam($name, $exParam);
}
}
|
[
"public",
"function",
"setShape",
"(",
"$",
"value",
",",
"$",
"replace",
"=",
"true",
")",
"{",
"$",
"name",
"=",
"'shapes'",
";",
"if",
"(",
"!",
"(",
"is_array",
"(",
"$",
"value",
")",
"||",
"is_string",
"(",
"$",
"value",
")",
")",
")",
"{",
"throw",
"new",
"CPS_Exception",
"(",
"array",
"(",
"array",
"(",
"'long_message'",
"=>",
"'Invalid request parameter'",
",",
"'code'",
"=>",
"ERROR_CODE_INVALID_PARAMETER",
",",
"'level'",
"=>",
"'REJECTED'",
",",
"'source'",
"=>",
"'CPS_API'",
")",
")",
")",
";",
"}",
"if",
"(",
"$",
"replace",
")",
"{",
"$",
"this",
"->",
"_setRawParam",
"(",
"$",
"name",
",",
"$",
"value",
")",
";",
"}",
"else",
"{",
"$",
"exParam",
"=",
"$",
"this",
"->",
"_getRawParam",
"(",
"$",
"name",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"exParam",
")",
")",
"{",
"$",
"exParam",
"=",
"array",
"(",
"$",
"exParam",
")",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"foreach",
"(",
"$",
"value",
"as",
"$",
"val",
")",
"{",
"$",
"exParam",
"[",
"]",
"=",
"$",
"val",
";",
"}",
"}",
"else",
"if",
"(",
"is_string",
"(",
"$",
"value",
")",
")",
"{",
"$",
"exParam",
"[",
"]",
"=",
"$",
"value",
";",
"}",
"$",
"this",
"->",
"_setRawParam",
"(",
"$",
"name",
",",
"$",
"exParam",
")",
";",
"}",
"}"
] |
Sets shape definition for geospatial search
@param String|array $value A single shape definition as string or array of string that define multiple shapes
@param bool $replace Should previous set values be replaced
|
[
"Sets",
"shape",
"definition",
"for",
"geospatial",
"search"
] |
44c98a727271c91bb9b9a70975ec4f69d99e64e7
|
https://github.com/clusterpoint/php-client-api/blob/44c98a727271c91bb9b9a70975ec4f69d99e64e7/request.class.php#L267-L289
|
237,835
|
clusterpoint/php-client-api
|
request.class.php
|
CPS_Request.setParam
|
public function setParam($name, $value) {
if (in_array($name, $this->_textParamNames)) {
$this->_setTextParam($name, $value);
} else if (in_array($name, $this->_rawParamNames)) {
$this->_setRawParam($name, $value);
} else {
throw new CPS_Exception(array(array('long_message' => 'Invalid request parameter', 'code' => ERROR_CODE_INVALID_PARAMETER, 'level' => 'REJECTED', 'source' => 'CPS_API')));
}
}
|
php
|
public function setParam($name, $value) {
if (in_array($name, $this->_textParamNames)) {
$this->_setTextParam($name, $value);
} else if (in_array($name, $this->_rawParamNames)) {
$this->_setRawParam($name, $value);
} else {
throw new CPS_Exception(array(array('long_message' => 'Invalid request parameter', 'code' => ERROR_CODE_INVALID_PARAMETER, 'level' => 'REJECTED', 'source' => 'CPS_API')));
}
}
|
[
"public",
"function",
"setParam",
"(",
"$",
"name",
",",
"$",
"value",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"_textParamNames",
")",
")",
"{",
"$",
"this",
"->",
"_setTextParam",
"(",
"$",
"name",
",",
"$",
"value",
")",
";",
"}",
"else",
"if",
"(",
"in_array",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"_rawParamNames",
")",
")",
"{",
"$",
"this",
"->",
"_setRawParam",
"(",
"$",
"name",
",",
"$",
"value",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"CPS_Exception",
"(",
"array",
"(",
"array",
"(",
"'long_message'",
"=>",
"'Invalid request parameter'",
",",
"'code'",
"=>",
"ERROR_CODE_INVALID_PARAMETER",
",",
"'level'",
"=>",
"'REJECTED'",
",",
"'source'",
"=>",
"'CPS_API'",
")",
")",
")",
";",
"}",
"}"
] |
sets a request parameter
@param string $name name of the parameter
@param mixed $value value to set. Could be a single string or an array of strings
|
[
"sets",
"a",
"request",
"parameter"
] |
44c98a727271c91bb9b9a70975ec4f69d99e64e7
|
https://github.com/clusterpoint/php-client-api/blob/44c98a727271c91bb9b9a70975ec4f69d99e64e7/request.class.php#L296-L304
|
237,836
|
clusterpoint/php-client-api
|
request.class.php
|
CPS_Request._setTextParam
|
private function _setTextParam(&$name, &$value) {
if (!is_array($value))
$value = array($value);
$this->_textParams[$name] = $value;
}
|
php
|
private function _setTextParam(&$name, &$value) {
if (!is_array($value))
$value = array($value);
$this->_textParams[$name] = $value;
}
|
[
"private",
"function",
"_setTextParam",
"(",
"&",
"$",
"name",
",",
"&",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"value",
")",
")",
"$",
"value",
"=",
"array",
"(",
"$",
"value",
")",
";",
"$",
"this",
"->",
"_textParams",
"[",
"$",
"name",
"]",
"=",
"$",
"value",
";",
"}"
] |
sets a text-only request parameter
@param string &$name name of the parameter
@param mixed &$value value to set. Could be a single string or an array of strings
|
[
"sets",
"a",
"text",
"-",
"only",
"request",
"parameter"
] |
44c98a727271c91bb9b9a70975ec4f69d99e64e7
|
https://github.com/clusterpoint/php-client-api/blob/44c98a727271c91bb9b9a70975ec4f69d99e64e7/request.class.php#L386-L390
|
237,837
|
clusterpoint/php-client-api
|
request.class.php
|
CPS_Request._setRawParam
|
private function _setRawParam(&$name, &$value) {
if (!is_array($value))
$value = array($value);
$this->_rawParams[$name] = $value;
}
|
php
|
private function _setRawParam(&$name, &$value) {
if (!is_array($value))
$value = array($value);
$this->_rawParams[$name] = $value;
}
|
[
"private",
"function",
"_setRawParam",
"(",
"&",
"$",
"name",
",",
"&",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"value",
")",
")",
"$",
"value",
"=",
"array",
"(",
"$",
"value",
")",
";",
"$",
"this",
"->",
"_rawParams",
"[",
"$",
"name",
"]",
"=",
"$",
"value",
";",
"}"
] |
sets a raw request parameter
@param string &$name name of the parameter
@param mixed &$value value to set. Could be a single string or an array of strings
|
[
"sets",
"a",
"raw",
"request",
"parameter"
] |
44c98a727271c91bb9b9a70975ec4f69d99e64e7
|
https://github.com/clusterpoint/php-client-api/blob/44c98a727271c91bb9b9a70975ec4f69d99e64e7/request.class.php#L396-L400
|
237,838
|
clusterpoint/php-client-api
|
request.class.php
|
CPS_Request._setDocId
|
private static function _setDocId(&$subdoc, &$parentNode, $id, &$docIdXpath, $curLevel = 0) {
if ($parentNode->nodeName == $docIdXpath[$curLevel]) {
if ($curLevel == count($docIdXpath) - 1) {
// remove all sub-nodes
$curChild = $parentNode->firstChild;
while ($curChild) {
$nextChild = $curChild->nextSibling;
$parentNode->removeChild($curChild);
$curChild = $nextChild;
}
// set the ID
if (!CPS_Request::isValidUTF8((string) $id))
throw new CPS_Exception(array(array('long_message' => 'Invalid UTF-8 encoding in document ID', 'code' => ERROR_CODE_INVALID_UTF8, 'level' => 'ERROR', 'source' => 'CPS_API')));
$textNode = $subdoc->createTextNode($id);
$parentNode->appendChild($textNode);
} else {
// traverse children
$found = false;
$curChild = $parentNode->firstChild;
while ($curChild) {
if ($curChild->nodeName == $docIdXpath[$curLevel + 1]) {
CPS_Request::_setDocId($subdoc, $curChild, $id, $docIdXpath, $curLevel + 1);
$found = true;
break;
}
$curChild = $curChild->nextSibling;
}
if (!$found) {
$newNode = $subdoc->createElement($docIdXpath[$curLevel + 1]);
$parentNode->appendChild($newNode);
CPS_Request::_setDocId($subdoc, $newNode, $id, $docIdXpath, $curLevel + 1);
}
}
} else {
throw new CPS_Exception(array(array('long_message' => 'Document root xpath not matching document ID xpath', 'code' => ERROR_CODE_INVALID_XPATHS, 'level' => 'REJECTED', 'source' => 'CPS_API')));
}
}
|
php
|
private static function _setDocId(&$subdoc, &$parentNode, $id, &$docIdXpath, $curLevel = 0) {
if ($parentNode->nodeName == $docIdXpath[$curLevel]) {
if ($curLevel == count($docIdXpath) - 1) {
// remove all sub-nodes
$curChild = $parentNode->firstChild;
while ($curChild) {
$nextChild = $curChild->nextSibling;
$parentNode->removeChild($curChild);
$curChild = $nextChild;
}
// set the ID
if (!CPS_Request::isValidUTF8((string) $id))
throw new CPS_Exception(array(array('long_message' => 'Invalid UTF-8 encoding in document ID', 'code' => ERROR_CODE_INVALID_UTF8, 'level' => 'ERROR', 'source' => 'CPS_API')));
$textNode = $subdoc->createTextNode($id);
$parentNode->appendChild($textNode);
} else {
// traverse children
$found = false;
$curChild = $parentNode->firstChild;
while ($curChild) {
if ($curChild->nodeName == $docIdXpath[$curLevel + 1]) {
CPS_Request::_setDocId($subdoc, $curChild, $id, $docIdXpath, $curLevel + 1);
$found = true;
break;
}
$curChild = $curChild->nextSibling;
}
if (!$found) {
$newNode = $subdoc->createElement($docIdXpath[$curLevel + 1]);
$parentNode->appendChild($newNode);
CPS_Request::_setDocId($subdoc, $newNode, $id, $docIdXpath, $curLevel + 1);
}
}
} else {
throw new CPS_Exception(array(array('long_message' => 'Document root xpath not matching document ID xpath', 'code' => ERROR_CODE_INVALID_XPATHS, 'level' => 'REJECTED', 'source' => 'CPS_API')));
}
}
|
[
"private",
"static",
"function",
"_setDocId",
"(",
"&",
"$",
"subdoc",
",",
"&",
"$",
"parentNode",
",",
"$",
"id",
",",
"&",
"$",
"docIdXpath",
",",
"$",
"curLevel",
"=",
"0",
")",
"{",
"if",
"(",
"$",
"parentNode",
"->",
"nodeName",
"==",
"$",
"docIdXpath",
"[",
"$",
"curLevel",
"]",
")",
"{",
"if",
"(",
"$",
"curLevel",
"==",
"count",
"(",
"$",
"docIdXpath",
")",
"-",
"1",
")",
"{",
"// remove all sub-nodes",
"$",
"curChild",
"=",
"$",
"parentNode",
"->",
"firstChild",
";",
"while",
"(",
"$",
"curChild",
")",
"{",
"$",
"nextChild",
"=",
"$",
"curChild",
"->",
"nextSibling",
";",
"$",
"parentNode",
"->",
"removeChild",
"(",
"$",
"curChild",
")",
";",
"$",
"curChild",
"=",
"$",
"nextChild",
";",
"}",
"// set the ID",
"if",
"(",
"!",
"CPS_Request",
"::",
"isValidUTF8",
"(",
"(",
"string",
")",
"$",
"id",
")",
")",
"throw",
"new",
"CPS_Exception",
"(",
"array",
"(",
"array",
"(",
"'long_message'",
"=>",
"'Invalid UTF-8 encoding in document ID'",
",",
"'code'",
"=>",
"ERROR_CODE_INVALID_UTF8",
",",
"'level'",
"=>",
"'ERROR'",
",",
"'source'",
"=>",
"'CPS_API'",
")",
")",
")",
";",
"$",
"textNode",
"=",
"$",
"subdoc",
"->",
"createTextNode",
"(",
"$",
"id",
")",
";",
"$",
"parentNode",
"->",
"appendChild",
"(",
"$",
"textNode",
")",
";",
"}",
"else",
"{",
"// traverse children",
"$",
"found",
"=",
"false",
";",
"$",
"curChild",
"=",
"$",
"parentNode",
"->",
"firstChild",
";",
"while",
"(",
"$",
"curChild",
")",
"{",
"if",
"(",
"$",
"curChild",
"->",
"nodeName",
"==",
"$",
"docIdXpath",
"[",
"$",
"curLevel",
"+",
"1",
"]",
")",
"{",
"CPS_Request",
"::",
"_setDocId",
"(",
"$",
"subdoc",
",",
"$",
"curChild",
",",
"$",
"id",
",",
"$",
"docIdXpath",
",",
"$",
"curLevel",
"+",
"1",
")",
";",
"$",
"found",
"=",
"true",
";",
"break",
";",
"}",
"$",
"curChild",
"=",
"$",
"curChild",
"->",
"nextSibling",
";",
"}",
"if",
"(",
"!",
"$",
"found",
")",
"{",
"$",
"newNode",
"=",
"$",
"subdoc",
"->",
"createElement",
"(",
"$",
"docIdXpath",
"[",
"$",
"curLevel",
"+",
"1",
"]",
")",
";",
"$",
"parentNode",
"->",
"appendChild",
"(",
"$",
"newNode",
")",
";",
"CPS_Request",
"::",
"_setDocId",
"(",
"$",
"subdoc",
",",
"$",
"newNode",
",",
"$",
"id",
",",
"$",
"docIdXpath",
",",
"$",
"curLevel",
"+",
"1",
")",
";",
"}",
"}",
"}",
"else",
"{",
"throw",
"new",
"CPS_Exception",
"(",
"array",
"(",
"array",
"(",
"'long_message'",
"=>",
"'Document root xpath not matching document ID xpath'",
",",
"'code'",
"=>",
"ERROR_CODE_INVALID_XPATHS",
",",
"'level'",
"=>",
"'REJECTED'",
",",
"'source'",
"=>",
"'CPS_API'",
")",
")",
")",
";",
"}",
"}"
] |
sets the docid inside the document
@param DOMDocument &$subdoc document where the id should be loaded into
|
[
"sets",
"the",
"docid",
"inside",
"the",
"document"
] |
44c98a727271c91bb9b9a70975ec4f69d99e64e7
|
https://github.com/clusterpoint/php-client-api/blob/44c98a727271c91bb9b9a70975ec4f69d99e64e7/request.class.php#L467-L503
|
237,839
|
priskz/paylorm
|
src/Priskz/Paylorm/Data/MySQL/Eloquent/CrudMemcachedRepository.php
|
CrudMemcachedRepository.delete
|
public function delete($object)
{
$deleted = $object->delete();
if( ! $deleted)
{
return new Payload($object, 'not_deleted');
}
// Remove the deleted model from cache.
Cache::tags($this->model->getTable())->flush($updated->getKey());
return new Payload(null, 'deleted');
}
|
php
|
public function delete($object)
{
$deleted = $object->delete();
if( ! $deleted)
{
return new Payload($object, 'not_deleted');
}
// Remove the deleted model from cache.
Cache::tags($this->model->getTable())->flush($updated->getKey());
return new Payload(null, 'deleted');
}
|
[
"public",
"function",
"delete",
"(",
"$",
"object",
")",
"{",
"$",
"deleted",
"=",
"$",
"object",
"->",
"delete",
"(",
")",
";",
"if",
"(",
"!",
"$",
"deleted",
")",
"{",
"return",
"new",
"Payload",
"(",
"$",
"object",
",",
"'not_deleted'",
")",
";",
"}",
"// Remove the deleted model from cache.",
"Cache",
"::",
"tags",
"(",
"$",
"this",
"->",
"model",
"->",
"getTable",
"(",
")",
")",
"->",
"flush",
"(",
"$",
"updated",
"->",
"getKey",
"(",
")",
")",
";",
"return",
"new",
"Payload",
"(",
"null",
",",
"'deleted'",
")",
";",
"}"
] |
Delete the given Model
@param $object
@return Payload
|
[
"Delete",
"the",
"given",
"Model"
] |
ae59eb4d9382f0c6fd361cca8ae465a0da88bc93
|
https://github.com/priskz/paylorm/blob/ae59eb4d9382f0c6fd361cca8ae465a0da88bc93/src/Priskz/Paylorm/Data/MySQL/Eloquent/CrudMemcachedRepository.php#L75-L88
|
237,840
|
synapsestudios/synapse-base
|
src/Synapse/Install/GenerateInstallCommand.php
|
GenerateInstallCommand.execute
|
public function execute(InputInterface $input, OutputInterface $output)
{
$outputPath = DATADIR;
$output->write(['', ' Generating install files...', ''], true);
$this->dumpStructure($outputPath);
$output->writeln(' Exported DB structure');
$this->dumpData($outputPath);
$output->write([' Exported DB data', ''], true);
}
|
php
|
public function execute(InputInterface $input, OutputInterface $output)
{
$outputPath = DATADIR;
$output->write(['', ' Generating install files...', ''], true);
$this->dumpStructure($outputPath);
$output->writeln(' Exported DB structure');
$this->dumpData($outputPath);
$output->write([' Exported DB data', ''], true);
}
|
[
"public",
"function",
"execute",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"outputPath",
"=",
"DATADIR",
";",
"$",
"output",
"->",
"write",
"(",
"[",
"''",
",",
"' Generating install files...'",
",",
"''",
"]",
",",
"true",
")",
";",
"$",
"this",
"->",
"dumpStructure",
"(",
"$",
"outputPath",
")",
";",
"$",
"output",
"->",
"writeln",
"(",
"' Exported DB structure'",
")",
";",
"$",
"this",
"->",
"dumpData",
"(",
"$",
"outputPath",
")",
";",
"$",
"output",
"->",
"write",
"(",
"[",
"' Exported DB data'",
",",
"''",
"]",
",",
"true",
")",
";",
"}"
] |
Execute this console command, in order to generate install files
@param InputInterface $input Command line input interface
@param OutputInterface $output Command line output interface
|
[
"Execute",
"this",
"console",
"command",
"in",
"order",
"to",
"generate",
"install",
"files"
] |
60c830550491742a077ab063f924e2f0b63825da
|
https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/Install/GenerateInstallCommand.php#L92-L103
|
237,841
|
synapsestudios/synapse-base
|
src/Synapse/Install/GenerateInstallCommand.php
|
GenerateInstallCommand.getDumpStructureCommand
|
public function getDumpStructureCommand($database, $username, $password, $outputPath)
{
return sprintf(
'mysqldump %s -u %s -p%s --no-data | sed "s/AUTO_INCREMENT=[0-9]*//" > %s',
escapeshellarg($database),
escapeshellarg($username),
escapeshellarg($password),
escapeshellarg($outputPath)
);
}
|
php
|
public function getDumpStructureCommand($database, $username, $password, $outputPath)
{
return sprintf(
'mysqldump %s -u %s -p%s --no-data | sed "s/AUTO_INCREMENT=[0-9]*//" > %s',
escapeshellarg($database),
escapeshellarg($username),
escapeshellarg($password),
escapeshellarg($outputPath)
);
}
|
[
"public",
"function",
"getDumpStructureCommand",
"(",
"$",
"database",
",",
"$",
"username",
",",
"$",
"password",
",",
"$",
"outputPath",
")",
"{",
"return",
"sprintf",
"(",
"'mysqldump %s -u %s -p%s --no-data | sed \"s/AUTO_INCREMENT=[0-9]*//\" > %s'",
",",
"escapeshellarg",
"(",
"$",
"database",
")",
",",
"escapeshellarg",
"(",
"$",
"username",
")",
",",
"escapeshellarg",
"(",
"$",
"password",
")",
",",
"escapeshellarg",
"(",
"$",
"outputPath",
")",
")",
";",
"}"
] |
Return the mysqldump command for structure only
@param string $database the database name
@param string $username the database username
@param string $password the database password
@param string $outputPath the resultant file location
@return string the command to run
|
[
"Return",
"the",
"mysqldump",
"command",
"for",
"structure",
"only"
] |
60c830550491742a077ab063f924e2f0b63825da
|
https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/Install/GenerateInstallCommand.php#L114-L123
|
237,842
|
synapsestudios/synapse-base
|
src/Synapse/Install/GenerateInstallCommand.php
|
GenerateInstallCommand.getDumpDataCommand
|
public function getDumpDataCommand($database, $username, $password, $outputPath, $tables = array())
{
$tables = array_map('escapeshellarg', $tables);
$command = sprintf(
'mysqldump %s %s -u %s -p%s --no-create-info > %s',
escapeshellarg($database),
implode(' ', $tables),
escapeshellarg($username),
escapeshellarg($password),
escapeshellarg($outputPath)
);
return $command;
}
|
php
|
public function getDumpDataCommand($database, $username, $password, $outputPath, $tables = array())
{
$tables = array_map('escapeshellarg', $tables);
$command = sprintf(
'mysqldump %s %s -u %s -p%s --no-create-info > %s',
escapeshellarg($database),
implode(' ', $tables),
escapeshellarg($username),
escapeshellarg($password),
escapeshellarg($outputPath)
);
return $command;
}
|
[
"public",
"function",
"getDumpDataCommand",
"(",
"$",
"database",
",",
"$",
"username",
",",
"$",
"password",
",",
"$",
"outputPath",
",",
"$",
"tables",
"=",
"array",
"(",
")",
")",
"{",
"$",
"tables",
"=",
"array_map",
"(",
"'escapeshellarg'",
",",
"$",
"tables",
")",
";",
"$",
"command",
"=",
"sprintf",
"(",
"'mysqldump %s %s -u %s -p%s --no-create-info > %s'",
",",
"escapeshellarg",
"(",
"$",
"database",
")",
",",
"implode",
"(",
"' '",
",",
"$",
"tables",
")",
",",
"escapeshellarg",
"(",
"$",
"username",
")",
",",
"escapeshellarg",
"(",
"$",
"password",
")",
",",
"escapeshellarg",
"(",
"$",
"outputPath",
")",
")",
";",
"return",
"$",
"command",
";",
"}"
] |
Return the mysqldump command for data only
@param string $database the database name
@param string $username the database username
@param string $password the database password
@param string $outputPath the resultant file location
@param array $tables the tables to include (optional)
@return string the command to run
|
[
"Return",
"the",
"mysqldump",
"command",
"for",
"data",
"only"
] |
60c830550491742a077ab063f924e2f0b63825da
|
https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/Install/GenerateInstallCommand.php#L135-L149
|
237,843
|
synapsestudios/synapse-base
|
src/Synapse/Install/GenerateInstallCommand.php
|
GenerateInstallCommand.dumpStructure
|
protected function dumpStructure($outputPath)
{
return shell_exec($this->getDumpStructureCommand(
$this->dbConfig['database'],
$this->dbConfig['username'],
$this->dbConfig['password'],
$outputPath.'/'.self::STRUCTURE_FILE
));
}
|
php
|
protected function dumpStructure($outputPath)
{
return shell_exec($this->getDumpStructureCommand(
$this->dbConfig['database'],
$this->dbConfig['username'],
$this->dbConfig['password'],
$outputPath.'/'.self::STRUCTURE_FILE
));
}
|
[
"protected",
"function",
"dumpStructure",
"(",
"$",
"outputPath",
")",
"{",
"return",
"shell_exec",
"(",
"$",
"this",
"->",
"getDumpStructureCommand",
"(",
"$",
"this",
"->",
"dbConfig",
"[",
"'database'",
"]",
",",
"$",
"this",
"->",
"dbConfig",
"[",
"'username'",
"]",
",",
"$",
"this",
"->",
"dbConfig",
"[",
"'password'",
"]",
",",
"$",
"outputPath",
".",
"'/'",
".",
"self",
"::",
"STRUCTURE_FILE",
")",
")",
";",
"}"
] |
Export database structure to dbStructure install file
@param string $outputPath Path where file should be exported
|
[
"Export",
"database",
"structure",
"to",
"dbStructure",
"install",
"file"
] |
60c830550491742a077ab063f924e2f0b63825da
|
https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/Install/GenerateInstallCommand.php#L156-L164
|
237,844
|
synapsestudios/synapse-base
|
src/Synapse/Install/GenerateInstallCommand.php
|
GenerateInstallCommand.dumpData
|
protected function dumpData($outputPath)
{
$tables = Arr::get($this->installConfig, 'dataTables', []);
/**
* Do not attempt to create an empty data install file if no tables are to be exported.
* Otherwise all tables will be exported.
*/
if (! count($tables)) {
return;
}
$command = sprintf(
'mysqldump %s %s -u %s -p%s --no-create-info > %s',
escapeshellarg($this->dbConfig['database']),
implode(' ', $tables),
escapeshellarg($this->dbConfig['username']),
escapeshellarg($this->dbConfig['password']),
escapeshellarg($outputPath.'/'.self::DATA_FILE)
);
return shell_exec($command);
}
|
php
|
protected function dumpData($outputPath)
{
$tables = Arr::get($this->installConfig, 'dataTables', []);
/**
* Do not attempt to create an empty data install file if no tables are to be exported.
* Otherwise all tables will be exported.
*/
if (! count($tables)) {
return;
}
$command = sprintf(
'mysqldump %s %s -u %s -p%s --no-create-info > %s',
escapeshellarg($this->dbConfig['database']),
implode(' ', $tables),
escapeshellarg($this->dbConfig['username']),
escapeshellarg($this->dbConfig['password']),
escapeshellarg($outputPath.'/'.self::DATA_FILE)
);
return shell_exec($command);
}
|
[
"protected",
"function",
"dumpData",
"(",
"$",
"outputPath",
")",
"{",
"$",
"tables",
"=",
"Arr",
"::",
"get",
"(",
"$",
"this",
"->",
"installConfig",
",",
"'dataTables'",
",",
"[",
"]",
")",
";",
"/**\n * Do not attempt to create an empty data install file if no tables are to be exported.\n * Otherwise all tables will be exported.\n */",
"if",
"(",
"!",
"count",
"(",
"$",
"tables",
")",
")",
"{",
"return",
";",
"}",
"$",
"command",
"=",
"sprintf",
"(",
"'mysqldump %s %s -u %s -p%s --no-create-info > %s'",
",",
"escapeshellarg",
"(",
"$",
"this",
"->",
"dbConfig",
"[",
"'database'",
"]",
")",
",",
"implode",
"(",
"' '",
",",
"$",
"tables",
")",
",",
"escapeshellarg",
"(",
"$",
"this",
"->",
"dbConfig",
"[",
"'username'",
"]",
")",
",",
"escapeshellarg",
"(",
"$",
"this",
"->",
"dbConfig",
"[",
"'password'",
"]",
")",
",",
"escapeshellarg",
"(",
"$",
"outputPath",
".",
"'/'",
".",
"self",
"::",
"DATA_FILE",
")",
")",
";",
"return",
"shell_exec",
"(",
"$",
"command",
")",
";",
"}"
] |
Export database data to dbData install file
@param string $outputPath Path where file should be exported
|
[
"Export",
"database",
"data",
"to",
"dbData",
"install",
"file"
] |
60c830550491742a077ab063f924e2f0b63825da
|
https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/Install/GenerateInstallCommand.php#L171-L193
|
237,845
|
getconnect/connect-php
|
src/APIClient.php
|
APIClient.pushEvent
|
public function pushEvent($collectionName, $event) {
$url = self::BASE_API_URL . $collectionName;
$result = Request::post($url)
->sendsAndExpectsType(Mime::JSON)
->addHeaders([
'X-Project-Id' => $this->projectId,
'X-Api-Key' => $this->apiKey
])
->body(json_encode($event))
->send();
return $this->buildResponse($event, $result);
}
|
php
|
public function pushEvent($collectionName, $event) {
$url = self::BASE_API_URL . $collectionName;
$result = Request::post($url)
->sendsAndExpectsType(Mime::JSON)
->addHeaders([
'X-Project-Id' => $this->projectId,
'X-Api-Key' => $this->apiKey
])
->body(json_encode($event))
->send();
return $this->buildResponse($event, $result);
}
|
[
"public",
"function",
"pushEvent",
"(",
"$",
"collectionName",
",",
"$",
"event",
")",
"{",
"$",
"url",
"=",
"self",
"::",
"BASE_API_URL",
".",
"$",
"collectionName",
";",
"$",
"result",
"=",
"Request",
"::",
"post",
"(",
"$",
"url",
")",
"->",
"sendsAndExpectsType",
"(",
"Mime",
"::",
"JSON",
")",
"->",
"addHeaders",
"(",
"[",
"'X-Project-Id'",
"=>",
"$",
"this",
"->",
"projectId",
",",
"'X-Api-Key'",
"=>",
"$",
"this",
"->",
"apiKey",
"]",
")",
"->",
"body",
"(",
"json_encode",
"(",
"$",
"event",
")",
")",
"->",
"send",
"(",
")",
";",
"return",
"$",
"this",
"->",
"buildResponse",
"(",
"$",
"event",
",",
"$",
"result",
")",
";",
"}"
] |
Push an event to the Connect API.
@param string $collectionName The name of the collection to push to
@param array $event The event details
@return Response
|
[
"Push",
"an",
"event",
"to",
"the",
"Connect",
"API",
"."
] |
cbce3daae58eca16450df811ac6f1280fc1ef6b1
|
https://github.com/getconnect/connect-php/blob/cbce3daae58eca16450df811ac6f1280fc1ef6b1/src/APIClient.php#L44-L55
|
237,846
|
getconnect/connect-php
|
src/APIClient.php
|
APIClient.buildResponse
|
private function buildResponse($event, $response) {
$success = !$response->hasErrors();
$duplicate = ($response->code == 409);
$statusCode = $response->code;
$errorMessage = null;
if ($response->code == 401) {
$errorMessage = 'Unauthorised. Please check your Project Id and API Key';
}
if ($response->body != null && $response->body->errorMessage != null) {
$errorMessage = $response->body->errorMessage;
}
return new Response($success, $duplicate, $statusCode, $errorMessage, $event);
}
|
php
|
private function buildResponse($event, $response) {
$success = !$response->hasErrors();
$duplicate = ($response->code == 409);
$statusCode = $response->code;
$errorMessage = null;
if ($response->code == 401) {
$errorMessage = 'Unauthorised. Please check your Project Id and API Key';
}
if ($response->body != null && $response->body->errorMessage != null) {
$errorMessage = $response->body->errorMessage;
}
return new Response($success, $duplicate, $statusCode, $errorMessage, $event);
}
|
[
"private",
"function",
"buildResponse",
"(",
"$",
"event",
",",
"$",
"response",
")",
"{",
"$",
"success",
"=",
"!",
"$",
"response",
"->",
"hasErrors",
"(",
")",
";",
"$",
"duplicate",
"=",
"(",
"$",
"response",
"->",
"code",
"==",
"409",
")",
";",
"$",
"statusCode",
"=",
"$",
"response",
"->",
"code",
";",
"$",
"errorMessage",
"=",
"null",
";",
"if",
"(",
"$",
"response",
"->",
"code",
"==",
"401",
")",
"{",
"$",
"errorMessage",
"=",
"'Unauthorised. Please check your Project Id and API Key'",
";",
"}",
"if",
"(",
"$",
"response",
"->",
"body",
"!=",
"null",
"&&",
"$",
"response",
"->",
"body",
"->",
"errorMessage",
"!=",
"null",
")",
"{",
"$",
"errorMessage",
"=",
"$",
"response",
"->",
"body",
"->",
"errorMessage",
";",
"}",
"return",
"new",
"Response",
"(",
"$",
"success",
",",
"$",
"duplicate",
",",
"$",
"statusCode",
",",
"$",
"errorMessage",
",",
"$",
"event",
")",
";",
"}"
] |
Build a single response to return to the user
@param array $event the event that the response is related to
@param \Httpful\Response $response The response from the API
@return Response
|
[
"Build",
"a",
"single",
"response",
"to",
"return",
"to",
"the",
"user"
] |
cbce3daae58eca16450df811ac6f1280fc1ef6b1
|
https://github.com/getconnect/connect-php/blob/cbce3daae58eca16450df811ac6f1280fc1ef6b1/src/APIClient.php#L81-L93
|
237,847
|
getconnect/connect-php
|
src/APIClient.php
|
APIClient.buildBatchResponse
|
private function buildBatchResponse($batch, $response) {
$result = [];
$responseBody = json_decode($response->raw_body, true);
foreach ($batch as $collection => $events) {
$eventResults = [];
$eventResponses = $responseBody[$collection];
foreach($events as $index => $event) {
$eventResponse = $eventResponses[$index];
$eventResult = new Response($eventResponse['success'], $eventResponse['duplicate'], null, $eventResponse['message'], $event);
array_push($eventResults, $eventResult);
}
$result[$collection] = $eventResults;
}
$statusCode = $response->code;
$errorMessage = $response->body->errorMessage;
return new ResponseBatch($statusCode, $errorMessage, $result);
}
|
php
|
private function buildBatchResponse($batch, $response) {
$result = [];
$responseBody = json_decode($response->raw_body, true);
foreach ($batch as $collection => $events) {
$eventResults = [];
$eventResponses = $responseBody[$collection];
foreach($events as $index => $event) {
$eventResponse = $eventResponses[$index];
$eventResult = new Response($eventResponse['success'], $eventResponse['duplicate'], null, $eventResponse['message'], $event);
array_push($eventResults, $eventResult);
}
$result[$collection] = $eventResults;
}
$statusCode = $response->code;
$errorMessage = $response->body->errorMessage;
return new ResponseBatch($statusCode, $errorMessage, $result);
}
|
[
"private",
"function",
"buildBatchResponse",
"(",
"$",
"batch",
",",
"$",
"response",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"$",
"responseBody",
"=",
"json_decode",
"(",
"$",
"response",
"->",
"raw_body",
",",
"true",
")",
";",
"foreach",
"(",
"$",
"batch",
"as",
"$",
"collection",
"=>",
"$",
"events",
")",
"{",
"$",
"eventResults",
"=",
"[",
"]",
";",
"$",
"eventResponses",
"=",
"$",
"responseBody",
"[",
"$",
"collection",
"]",
";",
"foreach",
"(",
"$",
"events",
"as",
"$",
"index",
"=>",
"$",
"event",
")",
"{",
"$",
"eventResponse",
"=",
"$",
"eventResponses",
"[",
"$",
"index",
"]",
";",
"$",
"eventResult",
"=",
"new",
"Response",
"(",
"$",
"eventResponse",
"[",
"'success'",
"]",
",",
"$",
"eventResponse",
"[",
"'duplicate'",
"]",
",",
"null",
",",
"$",
"eventResponse",
"[",
"'message'",
"]",
",",
"$",
"event",
")",
";",
"array_push",
"(",
"$",
"eventResults",
",",
"$",
"eventResult",
")",
";",
"}",
"$",
"result",
"[",
"$",
"collection",
"]",
"=",
"$",
"eventResults",
";",
"}",
"$",
"statusCode",
"=",
"$",
"response",
"->",
"code",
";",
"$",
"errorMessage",
"=",
"$",
"response",
"->",
"body",
"->",
"errorMessage",
";",
"return",
"new",
"ResponseBatch",
"(",
"$",
"statusCode",
",",
"$",
"errorMessage",
",",
"$",
"result",
")",
";",
"}"
] |
Build a batch of responses to return to the user
@param array $batch the batch that the response is related to
@param \Httpful\Response $response The response from the API
@return Response
|
[
"Build",
"a",
"batch",
"of",
"responses",
"to",
"return",
"to",
"the",
"user"
] |
cbce3daae58eca16450df811ac6f1280fc1ef6b1
|
https://github.com/getconnect/connect-php/blob/cbce3daae58eca16450df811ac6f1280fc1ef6b1/src/APIClient.php#L101-L119
|
237,848
|
yoanm/php-jsonrpc-http-server-swagger-doc-sdk
|
features/bootstrap/DocNormalizerContext.php
|
DocNormalizerContext.thenPathNamedShouldHaveTheFollowingResponse
|
public function thenPathNamedShouldHaveTheFollowingResponse($httpMethod, $pathName, PyStringNode $data)
{
$this->thenIShouldHaveAPathNamed($httpMethod, $pathName);
$operation = $this->extractPath($httpMethod, $pathName);
$operationResponseSchemaList = $operation['responses']['200']['schema']['allOf'];
$decodedExpected = $this->jsonDecode($data->getRaw());
Assert::assertContains($decodedExpected, $operationResponseSchemaList);
}
|
php
|
public function thenPathNamedShouldHaveTheFollowingResponse($httpMethod, $pathName, PyStringNode $data)
{
$this->thenIShouldHaveAPathNamed($httpMethod, $pathName);
$operation = $this->extractPath($httpMethod, $pathName);
$operationResponseSchemaList = $operation['responses']['200']['schema']['allOf'];
$decodedExpected = $this->jsonDecode($data->getRaw());
Assert::assertContains($decodedExpected, $operationResponseSchemaList);
}
|
[
"public",
"function",
"thenPathNamedShouldHaveTheFollowingResponse",
"(",
"$",
"httpMethod",
",",
"$",
"pathName",
",",
"PyStringNode",
"$",
"data",
")",
"{",
"$",
"this",
"->",
"thenIShouldHaveAPathNamed",
"(",
"$",
"httpMethod",
",",
"$",
"pathName",
")",
";",
"$",
"operation",
"=",
"$",
"this",
"->",
"extractPath",
"(",
"$",
"httpMethod",
",",
"$",
"pathName",
")",
";",
"$",
"operationResponseSchemaList",
"=",
"$",
"operation",
"[",
"'responses'",
"]",
"[",
"'200'",
"]",
"[",
"'schema'",
"]",
"[",
"'allOf'",
"]",
";",
"$",
"decodedExpected",
"=",
"$",
"this",
"->",
"jsonDecode",
"(",
"$",
"data",
"->",
"getRaw",
"(",
")",
")",
";",
"Assert",
"::",
"assertContains",
"(",
"$",
"decodedExpected",
",",
"$",
"operationResponseSchemaList",
")",
";",
"}"
] |
Error and response result are stored under the same key
@Then :httpMethod path named :pathName should have the following response:
@Then :httpMethod path named :pathName should have the following error:
|
[
"Error",
"and",
"response",
"result",
"are",
"stored",
"under",
"the",
"same",
"key"
] |
058a23941d25719a3f21deb5e4a17153ff7f32e8
|
https://github.com/yoanm/php-jsonrpc-http-server-swagger-doc-sdk/blob/058a23941d25719a3f21deb5e4a17153ff7f32e8/features/bootstrap/DocNormalizerContext.php#L428-L437
|
237,849
|
tomphp/TjoAnnotationRouter
|
src/TjoAnnotationRouter/Config/Merger.php
|
Merger.merge
|
public function merge(array $newConfig, array &$config)
{
foreach ($newConfig as $routeName => $routeInfo) {
if (!isset($config[$routeName])) {
$config[$routeName] = $this->newRoute($routeName, $routeInfo);
}
if (isset($routeInfo['child_routes'])) {
if (!isset($config[$routeName]['child_routes'])) {
$config[$routeName]['child_routes'] = array();
}
$this->merge($routeInfo['child_routes'], $config[$routeName]['child_routes']);
}
}
}
|
php
|
public function merge(array $newConfig, array &$config)
{
foreach ($newConfig as $routeName => $routeInfo) {
if (!isset($config[$routeName])) {
$config[$routeName] = $this->newRoute($routeName, $routeInfo);
}
if (isset($routeInfo['child_routes'])) {
if (!isset($config[$routeName]['child_routes'])) {
$config[$routeName]['child_routes'] = array();
}
$this->merge($routeInfo['child_routes'], $config[$routeName]['child_routes']);
}
}
}
|
[
"public",
"function",
"merge",
"(",
"array",
"$",
"newConfig",
",",
"array",
"&",
"$",
"config",
")",
"{",
"foreach",
"(",
"$",
"newConfig",
"as",
"$",
"routeName",
"=>",
"$",
"routeInfo",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"config",
"[",
"$",
"routeName",
"]",
")",
")",
"{",
"$",
"config",
"[",
"$",
"routeName",
"]",
"=",
"$",
"this",
"->",
"newRoute",
"(",
"$",
"routeName",
",",
"$",
"routeInfo",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"routeInfo",
"[",
"'child_routes'",
"]",
")",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"config",
"[",
"$",
"routeName",
"]",
"[",
"'child_routes'",
"]",
")",
")",
"{",
"$",
"config",
"[",
"$",
"routeName",
"]",
"[",
"'child_routes'",
"]",
"=",
"array",
"(",
")",
";",
"}",
"$",
"this",
"->",
"merge",
"(",
"$",
"routeInfo",
"[",
"'child_routes'",
"]",
",",
"$",
"config",
"[",
"$",
"routeName",
"]",
"[",
"'child_routes'",
"]",
")",
";",
"}",
"}",
"}"
] |
Recursively update the route stack.
@todo Convert recursion to iteration
@param array $newConfig
@param array $config
@return RouteInterface
|
[
"Recursively",
"update",
"the",
"route",
"stack",
"."
] |
ee323691e948d82449287eae5c1ecce80cc90971
|
https://github.com/tomphp/TjoAnnotationRouter/blob/ee323691e948d82449287eae5c1ecce80cc90971/src/TjoAnnotationRouter/Config/Merger.php#L50-L65
|
237,850
|
SocietyCMS/Setting
|
Support/Settings.php
|
Settings.get
|
public function get($name, $default = null)
{
if (! str_contains($name, '::')) {
throw new InvalidArgumentException("Setting key must be in the format '[module]::[setting]', '$name' given.");
}
$defaultFromConfig = $this->getDefaultFromConfigFor($name);
if ($this->setting->has($name)) {
return $this->setting->get($name);
}
return is_null($default) ? $defaultFromConfig : $default;
}
|
php
|
public function get($name, $default = null)
{
if (! str_contains($name, '::')) {
throw new InvalidArgumentException("Setting key must be in the format '[module]::[setting]', '$name' given.");
}
$defaultFromConfig = $this->getDefaultFromConfigFor($name);
if ($this->setting->has($name)) {
return $this->setting->get($name);
}
return is_null($default) ? $defaultFromConfig : $default;
}
|
[
"public",
"function",
"get",
"(",
"$",
"name",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"str_contains",
"(",
"$",
"name",
",",
"'::'",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Setting key must be in the format '[module]::[setting]', '$name' given.\"",
")",
";",
"}",
"$",
"defaultFromConfig",
"=",
"$",
"this",
"->",
"getDefaultFromConfigFor",
"(",
"$",
"name",
")",
";",
"if",
"(",
"$",
"this",
"->",
"setting",
"->",
"has",
"(",
"$",
"name",
")",
")",
"{",
"return",
"$",
"this",
"->",
"setting",
"->",
"get",
"(",
"$",
"name",
")",
";",
"}",
"return",
"is_null",
"(",
"$",
"default",
")",
"?",
"$",
"defaultFromConfig",
":",
"$",
"default",
";",
"}"
] |
Getting the setting.
@param string $name
@param string $locale
@param string $default
@return mixed
|
[
"Getting",
"the",
"setting",
"."
] |
a2726098cd596d2979750cd47d6fcec61c77e391
|
https://github.com/SocietyCMS/Setting/blob/a2726098cd596d2979750cd47d6fcec61c77e391/Support/Settings.php#L49-L62
|
237,851
|
SocietyCMS/Setting
|
Support/Settings.php
|
Settings.setFromRequest
|
public function setFromRequest($settings)
{
$this->removeTokenKey($settings);
foreach ($settings as $settingName => $settingValues) {
$this->set($settingName, $settingValues);
}
}
|
php
|
public function setFromRequest($settings)
{
$this->removeTokenKey($settings);
foreach ($settings as $settingName => $settingValues) {
$this->set($settingName, $settingValues);
}
}
|
[
"public",
"function",
"setFromRequest",
"(",
"$",
"settings",
")",
"{",
"$",
"this",
"->",
"removeTokenKey",
"(",
"$",
"settings",
")",
";",
"foreach",
"(",
"$",
"settings",
"as",
"$",
"settingName",
"=>",
"$",
"settingValues",
")",
"{",
"$",
"this",
"->",
"set",
"(",
"$",
"settingName",
",",
"$",
"settingValues",
")",
";",
"}",
"}"
] |
Set multiple given configuration values from a request.
@param mixed $settings
@return void
|
[
"Set",
"multiple",
"given",
"configuration",
"values",
"from",
"a",
"request",
"."
] |
a2726098cd596d2979750cd47d6fcec61c77e391
|
https://github.com/SocietyCMS/Setting/blob/a2726098cd596d2979750cd47d6fcec61c77e391/Support/Settings.php#L89-L96
|
237,852
|
SocietyCMS/Setting
|
Support/Settings.php
|
Settings.moduleConfig
|
public function moduleConfig($modules)
{
if (is_string($modules)) {
$config = config('society.'.strtolower($modules).'.settings');
return $config;
}
$config = [];
foreach ($modules as $module) {
if ($moduleSettings = config('society.'.strtolower($module->getName()).'.settings')) {
$config[$module->getName()] = $moduleSettings;
}
}
return $config;
}
|
php
|
public function moduleConfig($modules)
{
if (is_string($modules)) {
$config = config('society.'.strtolower($modules).'.settings');
return $config;
}
$config = [];
foreach ($modules as $module) {
if ($moduleSettings = config('society.'.strtolower($module->getName()).'.settings')) {
$config[$module->getName()] = $moduleSettings;
}
}
return $config;
}
|
[
"public",
"function",
"moduleConfig",
"(",
"$",
"modules",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"modules",
")",
")",
"{",
"$",
"config",
"=",
"config",
"(",
"'society.'",
".",
"strtolower",
"(",
"$",
"modules",
")",
".",
"'.settings'",
")",
";",
"return",
"$",
"config",
";",
"}",
"$",
"config",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"modules",
"as",
"$",
"module",
")",
"{",
"if",
"(",
"$",
"moduleSettings",
"=",
"config",
"(",
"'society.'",
".",
"strtolower",
"(",
"$",
"module",
"->",
"getName",
"(",
")",
")",
".",
"'.settings'",
")",
")",
"{",
"$",
"config",
"[",
"$",
"module",
"->",
"getName",
"(",
")",
"]",
"=",
"$",
"moduleSettings",
";",
"}",
"}",
"return",
"$",
"config",
";",
"}"
] |
Return all modules that have settings
with its settings.
@param array|string $modules
@return array
|
[
"Return",
"all",
"modules",
"that",
"have",
"settings",
"with",
"its",
"settings",
"."
] |
a2726098cd596d2979750cd47d6fcec61c77e391
|
https://github.com/SocietyCMS/Setting/blob/a2726098cd596d2979750cd47d6fcec61c77e391/Support/Settings.php#L106-L122
|
237,853
|
SocietyCMS/Setting
|
Support/Settings.php
|
Settings.getConfigFor
|
private function getConfigFor($name)
{
list($module, $settingName) = explode('::', $name);
$result = [];
foreach (config("society.$module.settings") as $sub) {
$result = array_merge($result, $sub);
}
return Arr::get($result, "$settingName");
}
|
php
|
private function getConfigFor($name)
{
list($module, $settingName) = explode('::', $name);
$result = [];
foreach (config("society.$module.settings") as $sub) {
$result = array_merge($result, $sub);
}
return Arr::get($result, "$settingName");
}
|
[
"private",
"function",
"getConfigFor",
"(",
"$",
"name",
")",
"{",
"list",
"(",
"$",
"module",
",",
"$",
"settingName",
")",
"=",
"explode",
"(",
"'::'",
",",
"$",
"name",
")",
";",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"config",
"(",
"\"society.$module.settings\"",
")",
"as",
"$",
"sub",
")",
"{",
"$",
"result",
"=",
"array_merge",
"(",
"$",
"result",
",",
"$",
"sub",
")",
";",
"}",
"return",
"Arr",
"::",
"get",
"(",
"$",
"result",
",",
"\"$settingName\"",
")",
";",
"}"
] |
Get the settings configuration file.
@param $name
@return mixed
|
[
"Get",
"the",
"settings",
"configuration",
"file",
"."
] |
a2726098cd596d2979750cd47d6fcec61c77e391
|
https://github.com/SocietyCMS/Setting/blob/a2726098cd596d2979750cd47d6fcec61c77e391/Support/Settings.php#L154-L164
|
237,854
|
zepi/turbo-base
|
Zepi/Core/AccessControl/src/DataSource/AccessEntitiesDataSourceDoctrine.php
|
AccessEntitiesDataSourceDoctrine.find
|
public function find($class, DataRequest $dataRequest)
{
try {
$dataRequest->setSelectedFields(array('*'));
$queryBuilder = $this->entityManager->getQueryBuilder();
$this->entityManager->buildDataRequestQuery($dataRequest, $queryBuilder, $class, 'a');
$accessEntities = $queryBuilder->getQuery()->getResult();
if ($accessEntities == null) {
return array();
}
foreach ($accessEntities as $accessEntity) {
$this->loadPermissions($accessEntity);
}
return $accessEntities;
} catch (\Exception $e) {
throw new Exception('Cannot load the access entities for the given data request from the database.', 0, $e);
}
}
|
php
|
public function find($class, DataRequest $dataRequest)
{
try {
$dataRequest->setSelectedFields(array('*'));
$queryBuilder = $this->entityManager->getQueryBuilder();
$this->entityManager->buildDataRequestQuery($dataRequest, $queryBuilder, $class, 'a');
$accessEntities = $queryBuilder->getQuery()->getResult();
if ($accessEntities == null) {
return array();
}
foreach ($accessEntities as $accessEntity) {
$this->loadPermissions($accessEntity);
}
return $accessEntities;
} catch (\Exception $e) {
throw new Exception('Cannot load the access entities for the given data request from the database.', 0, $e);
}
}
|
[
"public",
"function",
"find",
"(",
"$",
"class",
",",
"DataRequest",
"$",
"dataRequest",
")",
"{",
"try",
"{",
"$",
"dataRequest",
"->",
"setSelectedFields",
"(",
"array",
"(",
"'*'",
")",
")",
";",
"$",
"queryBuilder",
"=",
"$",
"this",
"->",
"entityManager",
"->",
"getQueryBuilder",
"(",
")",
";",
"$",
"this",
"->",
"entityManager",
"->",
"buildDataRequestQuery",
"(",
"$",
"dataRequest",
",",
"$",
"queryBuilder",
",",
"$",
"class",
",",
"'a'",
")",
";",
"$",
"accessEntities",
"=",
"$",
"queryBuilder",
"->",
"getQuery",
"(",
")",
"->",
"getResult",
"(",
")",
";",
"if",
"(",
"$",
"accessEntities",
"==",
"null",
")",
"{",
"return",
"array",
"(",
")",
";",
"}",
"foreach",
"(",
"$",
"accessEntities",
"as",
"$",
"accessEntity",
")",
"{",
"$",
"this",
"->",
"loadPermissions",
"(",
"$",
"accessEntity",
")",
";",
"}",
"return",
"$",
"accessEntities",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Cannot load the access entities for the given data request from the database.'",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"}"
] |
Returns an array with all found access entities for the given DataRequest
object.
@param string $class
@param \Zepi\Core\Utils\DataRequest $dataRequest
@return array
@throws \Zepi\Core\AccessControl\Exception Cannot load the access entities for the given data request.
|
[
"Returns",
"an",
"array",
"with",
"all",
"found",
"access",
"entities",
"for",
"the",
"given",
"DataRequest",
"object",
"."
] |
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
|
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Core/AccessControl/src/DataSource/AccessEntitiesDataSourceDoctrine.php#L101-L122
|
237,855
|
zepi/turbo-base
|
Zepi/Core/AccessControl/src/DataSource/AccessEntitiesDataSourceDoctrine.php
|
AccessEntitiesDataSourceDoctrine.count
|
public function count($class, DataRequest $dataRequest)
{
try {
$request = clone $dataRequest;
$request->setPage(0);
$request->setNumberOfEntries(0);
$queryBuilder = $this->entityManager->getQueryBuilder();
$this->entityManager->buildDataRequestQuery($request, $queryBuilder, $class, 'a');
// Count
$queryBuilder->select($queryBuilder->expr()->count('a.id'));
$data = $queryBuilder->getQuery();
if ($data === false) {
return 0;
}
return $data->getSingleScalarResult();
} catch (\Exception $e) {
throw new Exception('Cannot count the access entities for the given data request.', 0, $e);
}
}
|
php
|
public function count($class, DataRequest $dataRequest)
{
try {
$request = clone $dataRequest;
$request->setPage(0);
$request->setNumberOfEntries(0);
$queryBuilder = $this->entityManager->getQueryBuilder();
$this->entityManager->buildDataRequestQuery($request, $queryBuilder, $class, 'a');
// Count
$queryBuilder->select($queryBuilder->expr()->count('a.id'));
$data = $queryBuilder->getQuery();
if ($data === false) {
return 0;
}
return $data->getSingleScalarResult();
} catch (\Exception $e) {
throw new Exception('Cannot count the access entities for the given data request.', 0, $e);
}
}
|
[
"public",
"function",
"count",
"(",
"$",
"class",
",",
"DataRequest",
"$",
"dataRequest",
")",
"{",
"try",
"{",
"$",
"request",
"=",
"clone",
"$",
"dataRequest",
";",
"$",
"request",
"->",
"setPage",
"(",
"0",
")",
";",
"$",
"request",
"->",
"setNumberOfEntries",
"(",
"0",
")",
";",
"$",
"queryBuilder",
"=",
"$",
"this",
"->",
"entityManager",
"->",
"getQueryBuilder",
"(",
")",
";",
"$",
"this",
"->",
"entityManager",
"->",
"buildDataRequestQuery",
"(",
"$",
"request",
",",
"$",
"queryBuilder",
",",
"$",
"class",
",",
"'a'",
")",
";",
"// Count",
"$",
"queryBuilder",
"->",
"select",
"(",
"$",
"queryBuilder",
"->",
"expr",
"(",
")",
"->",
"count",
"(",
"'a.id'",
")",
")",
";",
"$",
"data",
"=",
"$",
"queryBuilder",
"->",
"getQuery",
"(",
")",
";",
"if",
"(",
"$",
"data",
"===",
"false",
")",
"{",
"return",
"0",
";",
"}",
"return",
"$",
"data",
"->",
"getSingleScalarResult",
"(",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Cannot count the access entities for the given data request.'",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"}"
] |
Returns the number of all found access entities for the given DataRequest
object.
@param string $class
@param \Zepi\Core\Utils\DataRequest $dataRequest
@return integer
@throws \Zepi\Core\AccessControl\Exception Cannot count the access entities for the given data request.
|
[
"Returns",
"the",
"number",
"of",
"all",
"found",
"access",
"entities",
"for",
"the",
"given",
"DataRequest",
"object",
"."
] |
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
|
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Core/AccessControl/src/DataSource/AccessEntitiesDataSourceDoctrine.php#L134-L157
|
237,856
|
zepi/turbo-base
|
Zepi/Core/AccessControl/src/DataSource/AccessEntitiesDataSourceDoctrine.php
|
AccessEntitiesDataSourceDoctrine.has
|
public function has($class, $entityId)
{
try {
$em = $this->entityManager->getDoctrineEntityManager();
$data = $em->getRepository($class)->findOneBy(array(
'id' => $entityId,
));
if ($data !== null) {
return true;
}
return false;
} catch (\Exception $e) {
throw new Exception('Cannot check if there is an access entitiy for the given class "' . $class . '" and id "' . $entityId . '".', 0, $e);
}
}
|
php
|
public function has($class, $entityId)
{
try {
$em = $this->entityManager->getDoctrineEntityManager();
$data = $em->getRepository($class)->findOneBy(array(
'id' => $entityId,
));
if ($data !== null) {
return true;
}
return false;
} catch (\Exception $e) {
throw new Exception('Cannot check if there is an access entitiy for the given class "' . $class . '" and id "' . $entityId . '".', 0, $e);
}
}
|
[
"public",
"function",
"has",
"(",
"$",
"class",
",",
"$",
"entityId",
")",
"{",
"try",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"entityManager",
"->",
"getDoctrineEntityManager",
"(",
")",
";",
"$",
"data",
"=",
"$",
"em",
"->",
"getRepository",
"(",
"$",
"class",
")",
"->",
"findOneBy",
"(",
"array",
"(",
"'id'",
"=>",
"$",
"entityId",
",",
")",
")",
";",
"if",
"(",
"$",
"data",
"!==",
"null",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Cannot check if there is an access entitiy for the given class \"'",
".",
"$",
"class",
".",
"'\" and id \"'",
".",
"$",
"entityId",
".",
"'\".'",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"}"
] |
Returns true if the given entity id exists
@param string $class
@param integer $entityId
@return boolean
@throws \Zepi\Core\AccessControl\Exception Cannot check if there is an access entitiy for the given class "{class}" and id "{entityId}".
|
[
"Returns",
"true",
"if",
"the",
"given",
"entity",
"id",
"exists"
] |
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
|
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Core/AccessControl/src/DataSource/AccessEntitiesDataSourceDoctrine.php#L168-L184
|
237,857
|
zepi/turbo-base
|
Zepi/Core/AccessControl/src/DataSource/AccessEntitiesDataSourceDoctrine.php
|
AccessEntitiesDataSourceDoctrine.get
|
public function get($class, $entityId)
{
try {
$em = $this->entityManager->getDoctrineEntityManager();
$accessEntity = $em->getRepository($class)->findOneBy(array(
'id' => $entityId,
));
if ($accessEntity !== null) {
$this->loadPermissions($accessEntity);
return $accessEntity;
}
return false;
} catch (\Exception $e) {
throw new Exception('Cannot load the access entitiy for the given class "' . $class . '" and id "' . $entityId . '".', 0, $e);
}
}
|
php
|
public function get($class, $entityId)
{
try {
$em = $this->entityManager->getDoctrineEntityManager();
$accessEntity = $em->getRepository($class)->findOneBy(array(
'id' => $entityId,
));
if ($accessEntity !== null) {
$this->loadPermissions($accessEntity);
return $accessEntity;
}
return false;
} catch (\Exception $e) {
throw new Exception('Cannot load the access entitiy for the given class "' . $class . '" and id "' . $entityId . '".', 0, $e);
}
}
|
[
"public",
"function",
"get",
"(",
"$",
"class",
",",
"$",
"entityId",
")",
"{",
"try",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"entityManager",
"->",
"getDoctrineEntityManager",
"(",
")",
";",
"$",
"accessEntity",
"=",
"$",
"em",
"->",
"getRepository",
"(",
"$",
"class",
")",
"->",
"findOneBy",
"(",
"array",
"(",
"'id'",
"=>",
"$",
"entityId",
",",
")",
")",
";",
"if",
"(",
"$",
"accessEntity",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"loadPermissions",
"(",
"$",
"accessEntity",
")",
";",
"return",
"$",
"accessEntity",
";",
"}",
"return",
"false",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Cannot load the access entitiy for the given class \"'",
".",
"$",
"class",
".",
"'\" and id \"'",
".",
"$",
"entityId",
".",
"'\".'",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"}"
] |
Returns the entity for the given id. Returns false if
there is no entity for the given id.
@param string $class
@param integer $entityId
@return false|mixed
@throws \Zepi\Core\AccessControl\Exception Cannot load the access entitiy for the given class "{class}" and id "{entityId}".
|
[
"Returns",
"the",
"entity",
"for",
"the",
"given",
"id",
".",
"Returns",
"false",
"if",
"there",
"is",
"no",
"entity",
"for",
"the",
"given",
"id",
"."
] |
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
|
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Core/AccessControl/src/DataSource/AccessEntitiesDataSourceDoctrine.php#L196-L214
|
237,858
|
zepi/turbo-base
|
Zepi/Core/AccessControl/src/DataSource/AccessEntitiesDataSourceDoctrine.php
|
AccessEntitiesDataSourceDoctrine.hasAccessEntityForUuid
|
public function hasAccessEntityForUuid($class, $uuid)
{
try {
$em = $this->entityManager->getDoctrineEntityManager();
$data = $em->getRepository($class)->findOneBy(array(
'uuid' => $uuid,
));
if ($data !== null) {
return true;
}
return false;
} catch (\Exception $e) {
throw new Exception('Cannot check if there is an access entitiy for the given uuid "' . $uuid . '".', 0, $e);
}
}
|
php
|
public function hasAccessEntityForUuid($class, $uuid)
{
try {
$em = $this->entityManager->getDoctrineEntityManager();
$data = $em->getRepository($class)->findOneBy(array(
'uuid' => $uuid,
));
if ($data !== null) {
return true;
}
return false;
} catch (\Exception $e) {
throw new Exception('Cannot check if there is an access entitiy for the given uuid "' . $uuid . '".', 0, $e);
}
}
|
[
"public",
"function",
"hasAccessEntityForUuid",
"(",
"$",
"class",
",",
"$",
"uuid",
")",
"{",
"try",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"entityManager",
"->",
"getDoctrineEntityManager",
"(",
")",
";",
"$",
"data",
"=",
"$",
"em",
"->",
"getRepository",
"(",
"$",
"class",
")",
"->",
"findOneBy",
"(",
"array",
"(",
"'uuid'",
"=>",
"$",
"uuid",
",",
")",
")",
";",
"if",
"(",
"$",
"data",
"!==",
"null",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Cannot check if there is an access entitiy for the given uuid \"'",
".",
"$",
"uuid",
".",
"'\".'",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"}"
] |
Returns true if there is a access entity for the given uuid
@access public
@param string $class
@param string $uuid
@return boolean
@throws \Zepi\Core\AccessControl\Exception Cannot check if there is an access entitiy for the given uuid "{uuid}".
|
[
"Returns",
"true",
"if",
"there",
"is",
"a",
"access",
"entity",
"for",
"the",
"given",
"uuid"
] |
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
|
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Core/AccessControl/src/DataSource/AccessEntitiesDataSourceDoctrine.php#L226-L242
|
237,859
|
zepi/turbo-base
|
Zepi/Core/AccessControl/src/DataSource/AccessEntitiesDataSourceDoctrine.php
|
AccessEntitiesDataSourceDoctrine.hasAccessEntityForName
|
public function hasAccessEntityForName($class, $name)
{
try {
$em = $this->entityManager->getDoctrineEntityManager();
$data = $em->getRepository($class)->findOneBy(array(
'name' => $name,
));
if ($data !== null) {
return true;
}
return false;
} catch (\Exception $e) {
throw new Exception('Cannot check if there is an access entitiy for the given type "' . $class . '" and name "' . $name . '".', 0, $e);
}
}
|
php
|
public function hasAccessEntityForName($class, $name)
{
try {
$em = $this->entityManager->getDoctrineEntityManager();
$data = $em->getRepository($class)->findOneBy(array(
'name' => $name,
));
if ($data !== null) {
return true;
}
return false;
} catch (\Exception $e) {
throw new Exception('Cannot check if there is an access entitiy for the given type "' . $class . '" and name "' . $name . '".', 0, $e);
}
}
|
[
"public",
"function",
"hasAccessEntityForName",
"(",
"$",
"class",
",",
"$",
"name",
")",
"{",
"try",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"entityManager",
"->",
"getDoctrineEntityManager",
"(",
")",
";",
"$",
"data",
"=",
"$",
"em",
"->",
"getRepository",
"(",
"$",
"class",
")",
"->",
"findOneBy",
"(",
"array",
"(",
"'name'",
"=>",
"$",
"name",
",",
")",
")",
";",
"if",
"(",
"$",
"data",
"!==",
"null",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Cannot check if there is an access entitiy for the given type \"'",
".",
"$",
"class",
".",
"'\" and name \"'",
".",
"$",
"name",
".",
"'\".'",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"}"
] |
Returns true if there is a access entity for the given type and name
@access public
@param string $class
@param string $name
@return boolean
@throws \Zepi\Core\AccessControl\Exception Cannot check if there is an access entitiy for the given type "{type}" and name "{name}".
|
[
"Returns",
"true",
"if",
"there",
"is",
"a",
"access",
"entity",
"for",
"the",
"given",
"type",
"and",
"name"
] |
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
|
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Core/AccessControl/src/DataSource/AccessEntitiesDataSourceDoctrine.php#L254-L270
|
237,860
|
zepi/turbo-base
|
Zepi/Core/AccessControl/src/DataSource/AccessEntitiesDataSourceDoctrine.php
|
AccessEntitiesDataSourceDoctrine.getAccessEntityForUuid
|
public function getAccessEntityForUuid($class, $uuid)
{
try {
$em = $this->entityManager->getDoctrineEntityManager();
$accessEntity = $em->getRepository($class)->findOneBy(array(
'uuid' => $uuid,
));
if ($accessEntity !== null) {
$this->loadPermissions($accessEntity);
return $accessEntity;
}
return false;
} catch (\Exception $e) {
throw new Exception('Cannot load the access entitiy from the database for the given uuid "' . $uuid . '".', 0, $e);
}
}
|
php
|
public function getAccessEntityForUuid($class, $uuid)
{
try {
$em = $this->entityManager->getDoctrineEntityManager();
$accessEntity = $em->getRepository($class)->findOneBy(array(
'uuid' => $uuid,
));
if ($accessEntity !== null) {
$this->loadPermissions($accessEntity);
return $accessEntity;
}
return false;
} catch (\Exception $e) {
throw new Exception('Cannot load the access entitiy from the database for the given uuid "' . $uuid . '".', 0, $e);
}
}
|
[
"public",
"function",
"getAccessEntityForUuid",
"(",
"$",
"class",
",",
"$",
"uuid",
")",
"{",
"try",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"entityManager",
"->",
"getDoctrineEntityManager",
"(",
")",
";",
"$",
"accessEntity",
"=",
"$",
"em",
"->",
"getRepository",
"(",
"$",
"class",
")",
"->",
"findOneBy",
"(",
"array",
"(",
"'uuid'",
"=>",
"$",
"uuid",
",",
")",
")",
";",
"if",
"(",
"$",
"accessEntity",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"loadPermissions",
"(",
"$",
"accessEntity",
")",
";",
"return",
"$",
"accessEntity",
";",
"}",
"return",
"false",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Cannot load the access entitiy from the database for the given uuid \"'",
".",
"$",
"uuid",
".",
"'\".'",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"}"
] |
Returns the access entity object for the given uuid
@access public
@param string $class
@param string $uuid
@return false|\Zepi\Core\AccessControl\Entity\AccessEntity
@throws \Zepi\Core\AccessControl\Exception Cannot load the access entitiy from the database for the given uuid "{uuid}".
|
[
"Returns",
"the",
"access",
"entity",
"object",
"for",
"the",
"given",
"uuid"
] |
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
|
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Core/AccessControl/src/DataSource/AccessEntitiesDataSourceDoctrine.php#L282-L300
|
237,861
|
zepi/turbo-base
|
Zepi/Core/AccessControl/src/DataSource/AccessEntitiesDataSourceDoctrine.php
|
AccessEntitiesDataSourceDoctrine.getAccessEntityForName
|
public function getAccessEntityForName($class, $name)
{
try {
$em = $this->entityManager->getDoctrineEntityManager();
$accessEntity = $em->getRepository($class)->findOneBy(array(
'name' => $name,
));
if ($accessEntity !== null) {
$this->loadPermissions($accessEntity);
return $accessEntity;
}
return false;
} catch (\Exception $e) {
throw new Exception('Cannot load the access entitiy for the given class "' . $class . '" and name "' . $name . '".', 0, $e);
}
}
|
php
|
public function getAccessEntityForName($class, $name)
{
try {
$em = $this->entityManager->getDoctrineEntityManager();
$accessEntity = $em->getRepository($class)->findOneBy(array(
'name' => $name,
));
if ($accessEntity !== null) {
$this->loadPermissions($accessEntity);
return $accessEntity;
}
return false;
} catch (\Exception $e) {
throw new Exception('Cannot load the access entitiy for the given class "' . $class . '" and name "' . $name . '".', 0, $e);
}
}
|
[
"public",
"function",
"getAccessEntityForName",
"(",
"$",
"class",
",",
"$",
"name",
")",
"{",
"try",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"entityManager",
"->",
"getDoctrineEntityManager",
"(",
")",
";",
"$",
"accessEntity",
"=",
"$",
"em",
"->",
"getRepository",
"(",
"$",
"class",
")",
"->",
"findOneBy",
"(",
"array",
"(",
"'name'",
"=>",
"$",
"name",
",",
")",
")",
";",
"if",
"(",
"$",
"accessEntity",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"loadPermissions",
"(",
"$",
"accessEntity",
")",
";",
"return",
"$",
"accessEntity",
";",
"}",
"return",
"false",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Cannot load the access entitiy for the given class \"'",
".",
"$",
"class",
".",
"'\" and name \"'",
".",
"$",
"name",
".",
"'\".'",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"}"
] |
Returns the access entity object for the given type and name
@access public
@param string $class
@param string $name
@return false|\Zepi\Core\AccessControl\Entity\AccessEntity
@throws \Zepi\Core\AccessControl\Exception Cannot load access entitiy from the database for the given class "{class}" and name "{name}".
|
[
"Returns",
"the",
"access",
"entity",
"object",
"for",
"the",
"given",
"type",
"and",
"name"
] |
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
|
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Core/AccessControl/src/DataSource/AccessEntitiesDataSourceDoctrine.php#L312-L330
|
237,862
|
zepi/turbo-base
|
Zepi/Core/AccessControl/src/DataSource/AccessEntitiesDataSourceDoctrine.php
|
AccessEntitiesDataSourceDoctrine.addAccessEntity
|
public function addAccessEntity(AccessEntity $accessEntity)
{
try {
$em = $this->entityManager->getDoctrineEntityManager();
$em->persist($accessEntity);
$em->flush();
return $accessEntity->getUuid();
} catch (\Exception $e) {
throw new Exception('Cannot add the new access entitiy "' . $accessEntity->getName() . '".', 0, $e);
}
}
|
php
|
public function addAccessEntity(AccessEntity $accessEntity)
{
try {
$em = $this->entityManager->getDoctrineEntityManager();
$em->persist($accessEntity);
$em->flush();
return $accessEntity->getUuid();
} catch (\Exception $e) {
throw new Exception('Cannot add the new access entitiy "' . $accessEntity->getName() . '".', 0, $e);
}
}
|
[
"public",
"function",
"addAccessEntity",
"(",
"AccessEntity",
"$",
"accessEntity",
")",
"{",
"try",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"entityManager",
"->",
"getDoctrineEntityManager",
"(",
")",
";",
"$",
"em",
"->",
"persist",
"(",
"$",
"accessEntity",
")",
";",
"$",
"em",
"->",
"flush",
"(",
")",
";",
"return",
"$",
"accessEntity",
"->",
"getUuid",
"(",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Cannot add the new access entitiy \"'",
".",
"$",
"accessEntity",
"->",
"getName",
"(",
")",
".",
"'\".'",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"}"
] |
Adds an access entity. Returns the uuid of the access entity
or false, if the access entity can not inserted.
@access public
@param \Zepi\Core\AccessControl\Entity\AccessEntity $accessEntity
@return string|false
@throws \Zepi\Core\AccessControl\Exception Cannot add the new access entity "{name}".
|
[
"Adds",
"an",
"access",
"entity",
".",
"Returns",
"the",
"uuid",
"of",
"the",
"access",
"entity",
"or",
"false",
"if",
"the",
"access",
"entity",
"can",
"not",
"inserted",
"."
] |
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
|
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Core/AccessControl/src/DataSource/AccessEntitiesDataSourceDoctrine.php#L342-L353
|
237,863
|
zepi/turbo-base
|
Zepi/Core/AccessControl/src/DataSource/AccessEntitiesDataSourceDoctrine.php
|
AccessEntitiesDataSourceDoctrine.updateAccessEntity
|
public function updateAccessEntity(AccessEntity $accessEntity)
{
try {
$em = $this->entityManager->getDoctrineEntityManager();
$em->flush();
return true;
} catch (\Exception $e) {
throw new Exception('Cannot update the access entitiy "' . $accessEntity->getUuid() . '".', 0, $e);
}
}
|
php
|
public function updateAccessEntity(AccessEntity $accessEntity)
{
try {
$em = $this->entityManager->getDoctrineEntityManager();
$em->flush();
return true;
} catch (\Exception $e) {
throw new Exception('Cannot update the access entitiy "' . $accessEntity->getUuid() . '".', 0, $e);
}
}
|
[
"public",
"function",
"updateAccessEntity",
"(",
"AccessEntity",
"$",
"accessEntity",
")",
"{",
"try",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"entityManager",
"->",
"getDoctrineEntityManager",
"(",
")",
";",
"$",
"em",
"->",
"flush",
"(",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Cannot update the access entitiy \"'",
".",
"$",
"accessEntity",
"->",
"getUuid",
"(",
")",
".",
"'\".'",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"}"
] |
Updates the access entity. Returns true if everything worked as excepted or
false if the update didn't worked.
@access public
@param \Zepi\Core\AccessControl\Entity\AccessEntity $accessEntity
@return boolean
@throws \Zepi\Core\AccessControl\Exception Cannot update the access entity "{name}".
|
[
"Updates",
"the",
"access",
"entity",
".",
"Returns",
"true",
"if",
"everything",
"worked",
"as",
"excepted",
"or",
"false",
"if",
"the",
"update",
"didn",
"t",
"worked",
"."
] |
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
|
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Core/AccessControl/src/DataSource/AccessEntitiesDataSourceDoctrine.php#L365-L375
|
237,864
|
zepi/turbo-base
|
Zepi/Core/AccessControl/src/DataSource/AccessEntitiesDataSourceDoctrine.php
|
AccessEntitiesDataSourceDoctrine.deleteAccessEntity
|
public function deleteAccessEntity(AccessEntity $accessEntity)
{
try {
$em = $this->entityManager->getDoctrineEntityManager();
$em->remove($accessEntity);
$em->flush();
return true;
} catch (\Exception $e) {
throw new Exception('Cannot delete the access entitiy "' . $uuid . '".', 0, $e);
}
}
|
php
|
public function deleteAccessEntity(AccessEntity $accessEntity)
{
try {
$em = $this->entityManager->getDoctrineEntityManager();
$em->remove($accessEntity);
$em->flush();
return true;
} catch (\Exception $e) {
throw new Exception('Cannot delete the access entitiy "' . $uuid . '".', 0, $e);
}
}
|
[
"public",
"function",
"deleteAccessEntity",
"(",
"AccessEntity",
"$",
"accessEntity",
")",
"{",
"try",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"entityManager",
"->",
"getDoctrineEntityManager",
"(",
")",
";",
"$",
"em",
"->",
"remove",
"(",
"$",
"accessEntity",
")",
";",
"$",
"em",
"->",
"flush",
"(",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Cannot delete the access entitiy \"'",
".",
"$",
"uuid",
".",
"'\".'",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"}"
] |
Deletes the given access entity in the database.
@access public
@param \Zepi\Core\AccessControl\Entity\AccessEntity $accessEntity
@return boolean
|
[
"Deletes",
"the",
"given",
"access",
"entity",
"in",
"the",
"database",
"."
] |
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
|
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Core/AccessControl/src/DataSource/AccessEntitiesDataSourceDoctrine.php#L384-L395
|
237,865
|
zepi/turbo-base
|
Zepi/Core/AccessControl/src/DataSource/AccessEntitiesDataSourceDoctrine.php
|
AccessEntitiesDataSourceDoctrine.loadPermissions
|
protected function loadPermissions(AccessEntity $accessEntity)
{
$permissions = $this->permissionsDataSource->getPermissionsForUuid($accessEntity->getUuid());
if ($permissions === false) {
return;
}
$accessEntity->setPermissions($permissions);
}
|
php
|
protected function loadPermissions(AccessEntity $accessEntity)
{
$permissions = $this->permissionsDataSource->getPermissionsForUuid($accessEntity->getUuid());
if ($permissions === false) {
return;
}
$accessEntity->setPermissions($permissions);
}
|
[
"protected",
"function",
"loadPermissions",
"(",
"AccessEntity",
"$",
"accessEntity",
")",
"{",
"$",
"permissions",
"=",
"$",
"this",
"->",
"permissionsDataSource",
"->",
"getPermissionsForUuid",
"(",
"$",
"accessEntity",
"->",
"getUuid",
"(",
")",
")",
";",
"if",
"(",
"$",
"permissions",
"===",
"false",
")",
"{",
"return",
";",
"}",
"$",
"accessEntity",
"->",
"setPermissions",
"(",
"$",
"permissions",
")",
";",
"}"
] |
Loads the permissions for the given access entity object
@param \Zepi\Core\AccessControl\Entity\AccessEntity $accessEntity
|
[
"Loads",
"the",
"permissions",
"for",
"the",
"given",
"access",
"entity",
"object"
] |
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
|
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Core/AccessControl/src/DataSource/AccessEntitiesDataSourceDoctrine.php#L402-L411
|
237,866
|
strident/Container
|
src/LockBox.php
|
LockBox.set
|
public function set($name, $value)
{
if (isset($this->locked[$name])) {
throw new LockedItemException($name);
}
$this->items[$name] = $value;
}
|
php
|
public function set($name, $value)
{
if (isset($this->locked[$name])) {
throw new LockedItemException($name);
}
$this->items[$name] = $value;
}
|
[
"public",
"function",
"set",
"(",
"$",
"name",
",",
"$",
"value",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"locked",
"[",
"$",
"name",
"]",
")",
")",
"{",
"throw",
"new",
"LockedItemException",
"(",
"$",
"name",
")",
";",
"}",
"$",
"this",
"->",
"items",
"[",
"$",
"name",
"]",
"=",
"$",
"value",
";",
"}"
] |
Sets a item by name.
@param string $name
@param mixed $value
@return LockBox
|
[
"Sets",
"a",
"item",
"by",
"name",
"."
] |
88fc1cded20d2baf69ea94f950c1e89cdb62262b
|
https://github.com/strident/Container/blob/88fc1cded20d2baf69ea94f950c1e89cdb62262b/src/LockBox.php#L53-L60
|
237,867
|
strident/Container
|
src/LockBox.php
|
LockBox.get
|
public function get($name)
{
if (!$this->has($name)) {
throw new ItemNotFoundException($name);
}
return $this->items[$name];
}
|
php
|
public function get($name)
{
if (!$this->has($name)) {
throw new ItemNotFoundException($name);
}
return $this->items[$name];
}
|
[
"public",
"function",
"get",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"has",
"(",
"$",
"name",
")",
")",
"{",
"throw",
"new",
"ItemNotFoundException",
"(",
"$",
"name",
")",
";",
"}",
"return",
"$",
"this",
"->",
"items",
"[",
"$",
"name",
"]",
";",
"}"
] |
Returns a item by name.
@param string $name
@return mixed
|
[
"Returns",
"a",
"item",
"by",
"name",
"."
] |
88fc1cded20d2baf69ea94f950c1e89cdb62262b
|
https://github.com/strident/Container/blob/88fc1cded20d2baf69ea94f950c1e89cdb62262b/src/LockBox.php#L69-L76
|
237,868
|
strident/Container
|
src/LockBox.php
|
LockBox.lock
|
public function lock($name)
{
if (!$this->has($name)) {
throw new ItemNotFoundException($name);
}
$this->locked[$name] = true;
return $this;
}
|
php
|
public function lock($name)
{
if (!$this->has($name)) {
throw new ItemNotFoundException($name);
}
$this->locked[$name] = true;
return $this;
}
|
[
"public",
"function",
"lock",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"has",
"(",
"$",
"name",
")",
")",
"{",
"throw",
"new",
"ItemNotFoundException",
"(",
"$",
"name",
")",
";",
"}",
"$",
"this",
"->",
"locked",
"[",
"$",
"name",
"]",
"=",
"true",
";",
"return",
"$",
"this",
";",
"}"
] |
Locks an item.
@param string $name
@return LockBox
|
[
"Locks",
"an",
"item",
"."
] |
88fc1cded20d2baf69ea94f950c1e89cdb62262b
|
https://github.com/strident/Container/blob/88fc1cded20d2baf69ea94f950c1e89cdb62262b/src/LockBox.php#L111-L120
|
237,869
|
strident/Container
|
src/LockBox.php
|
LockBox.unlock
|
public function unlock($name)
{
if (!$this->has($name)) {
throw new ItemNotFoundException($name);
}
unset($this->locked[$name]);
return $this;
}
|
php
|
public function unlock($name)
{
if (!$this->has($name)) {
throw new ItemNotFoundException($name);
}
unset($this->locked[$name]);
return $this;
}
|
[
"public",
"function",
"unlock",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"has",
"(",
"$",
"name",
")",
")",
"{",
"throw",
"new",
"ItemNotFoundException",
"(",
"$",
"name",
")",
";",
"}",
"unset",
"(",
"$",
"this",
"->",
"locked",
"[",
"$",
"name",
"]",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Unlocks an item.
@param string $name
@return LockBox
|
[
"Unlocks",
"an",
"item",
"."
] |
88fc1cded20d2baf69ea94f950c1e89cdb62262b
|
https://github.com/strident/Container/blob/88fc1cded20d2baf69ea94f950c1e89cdb62262b/src/LockBox.php#L129-L138
|
237,870
|
strident/Container
|
src/LockBox.php
|
LockBox.isLocked
|
public function isLocked($name)
{
if (!$this->has($name)) {
throw new ItemNotFoundException($name);
}
return isset($this->locked[$name]);
}
|
php
|
public function isLocked($name)
{
if (!$this->has($name)) {
throw new ItemNotFoundException($name);
}
return isset($this->locked[$name]);
}
|
[
"public",
"function",
"isLocked",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"has",
"(",
"$",
"name",
")",
")",
"{",
"throw",
"new",
"ItemNotFoundException",
"(",
"$",
"name",
")",
";",
"}",
"return",
"isset",
"(",
"$",
"this",
"->",
"locked",
"[",
"$",
"name",
"]",
")",
";",
"}"
] |
Returns true if the item is locked.
@param string $name
@return boolean
|
[
"Returns",
"true",
"if",
"the",
"item",
"is",
"locked",
"."
] |
88fc1cded20d2baf69ea94f950c1e89cdb62262b
|
https://github.com/strident/Container/blob/88fc1cded20d2baf69ea94f950c1e89cdb62262b/src/LockBox.php#L147-L154
|
237,871
|
xiewulong/yii2-xui
|
Tinymce.php
|
Tinymce.init
|
public function init(){
parent::init();
$id = $this->getRandomId();
$view = $this->getView();
TinymceAsset::register($view);
TinymceLanguageAsset::register($view);
$view->registerJs("tinymce.init({selector:'#$id',plugins:'$this->plugins',font_formats:'$this->font_formats',fontsize_formats:'$this->fontsize_formats',autosave_ask_before_unload:false,preview_styles:false,toolbar:'$this->toolbar'});");
}
|
php
|
public function init(){
parent::init();
$id = $this->getRandomId();
$view = $this->getView();
TinymceAsset::register($view);
TinymceLanguageAsset::register($view);
$view->registerJs("tinymce.init({selector:'#$id',plugins:'$this->plugins',font_formats:'$this->font_formats',fontsize_formats:'$this->fontsize_formats',autosave_ask_before_unload:false,preview_styles:false,toolbar:'$this->toolbar'});");
}
|
[
"public",
"function",
"init",
"(",
")",
"{",
"parent",
"::",
"init",
"(",
")",
";",
"$",
"id",
"=",
"$",
"this",
"->",
"getRandomId",
"(",
")",
";",
"$",
"view",
"=",
"$",
"this",
"->",
"getView",
"(",
")",
";",
"TinymceAsset",
"::",
"register",
"(",
"$",
"view",
")",
";",
"TinymceLanguageAsset",
"::",
"register",
"(",
"$",
"view",
")",
";",
"$",
"view",
"->",
"registerJs",
"(",
"\"tinymce.init({selector:'#$id',plugins:'$this->plugins',font_formats:'$this->font_formats',fontsize_formats:'$this->fontsize_formats',autosave_ask_before_unload:false,preview_styles:false,toolbar:'$this->toolbar'});\"",
")",
";",
"}"
] |
newdocument strikethrough cut copy paste blockquote removeformat subscript superscript
|
[
"newdocument",
"strikethrough",
"cut",
"copy",
"paste",
"blockquote",
"removeformat",
"subscript",
"superscript"
] |
ec64752d88eddc0cdb8bcb26c4616473a3a18235
|
https://github.com/xiewulong/yii2-xui/blob/ec64752d88eddc0cdb8bcb26c4616473a3a18235/Tinymce.php#L40-L48
|
237,872
|
wasabi-cms/core
|
src/Controller/LanguagesController.php
|
LanguagesController.sort
|
public function sort()
{
if (!$this->request->is('ajax') || !$this->request->is('post')) {
throw new MethodNotAllowedException();
}
if (empty($this->request->data)) {
throw new BadRequestException();
}
// save the new language positions
$languages = $this->Languages->patchEntities(
$this->Languages->find('allFrontendBackend'),
$this->request->data
);
/** @var Connection $connection */
$connection = $this->Languages->connection();
$connection->begin();
foreach ($languages as $language) {
if (!$this->Languages->save($language)) {
$connection->rollback();
break;
}
}
if ($connection->inTransaction()) {
$connection->commit();
$status = 'success';
$flashMessage = __d('wasabi_core', 'The language position has been updated.');
} else {
$status = 'error';
$flashMessage = $this->dbErrorMessage;
}
// create the json response
$frontendLanguages = $this->Languages
->filterFrontend(new Collection($languages))
->sortBy('position', SORT_ASC, SORT_NUMERIC)
->toList();
$backendLanguages = $this->Languages
->filterBackend(new Collection($languages))
->sortBy('position', SORT_ASC, SORT_NUMERIC)
->toList();
$this->set(compact('status', 'flashMessage', 'frontendLanguages', 'backendLanguages'));
$this->set('_serialize', ['status', 'flashMessage', 'frontendLanguages', 'backendLanguages']);
$this->RequestHandler->renderAs($this, 'json');
}
|
php
|
public function sort()
{
if (!$this->request->is('ajax') || !$this->request->is('post')) {
throw new MethodNotAllowedException();
}
if (empty($this->request->data)) {
throw new BadRequestException();
}
// save the new language positions
$languages = $this->Languages->patchEntities(
$this->Languages->find('allFrontendBackend'),
$this->request->data
);
/** @var Connection $connection */
$connection = $this->Languages->connection();
$connection->begin();
foreach ($languages as $language) {
if (!$this->Languages->save($language)) {
$connection->rollback();
break;
}
}
if ($connection->inTransaction()) {
$connection->commit();
$status = 'success';
$flashMessage = __d('wasabi_core', 'The language position has been updated.');
} else {
$status = 'error';
$flashMessage = $this->dbErrorMessage;
}
// create the json response
$frontendLanguages = $this->Languages
->filterFrontend(new Collection($languages))
->sortBy('position', SORT_ASC, SORT_NUMERIC)
->toList();
$backendLanguages = $this->Languages
->filterBackend(new Collection($languages))
->sortBy('position', SORT_ASC, SORT_NUMERIC)
->toList();
$this->set(compact('status', 'flashMessage', 'frontendLanguages', 'backendLanguages'));
$this->set('_serialize', ['status', 'flashMessage', 'frontendLanguages', 'backendLanguages']);
$this->RequestHandler->renderAs($this, 'json');
}
|
[
"public",
"function",
"sort",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"request",
"->",
"is",
"(",
"'ajax'",
")",
"||",
"!",
"$",
"this",
"->",
"request",
"->",
"is",
"(",
"'post'",
")",
")",
"{",
"throw",
"new",
"MethodNotAllowedException",
"(",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"request",
"->",
"data",
")",
")",
"{",
"throw",
"new",
"BadRequestException",
"(",
")",
";",
"}",
"// save the new language positions",
"$",
"languages",
"=",
"$",
"this",
"->",
"Languages",
"->",
"patchEntities",
"(",
"$",
"this",
"->",
"Languages",
"->",
"find",
"(",
"'allFrontendBackend'",
")",
",",
"$",
"this",
"->",
"request",
"->",
"data",
")",
";",
"/** @var Connection $connection */",
"$",
"connection",
"=",
"$",
"this",
"->",
"Languages",
"->",
"connection",
"(",
")",
";",
"$",
"connection",
"->",
"begin",
"(",
")",
";",
"foreach",
"(",
"$",
"languages",
"as",
"$",
"language",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"Languages",
"->",
"save",
"(",
"$",
"language",
")",
")",
"{",
"$",
"connection",
"->",
"rollback",
"(",
")",
";",
"break",
";",
"}",
"}",
"if",
"(",
"$",
"connection",
"->",
"inTransaction",
"(",
")",
")",
"{",
"$",
"connection",
"->",
"commit",
"(",
")",
";",
"$",
"status",
"=",
"'success'",
";",
"$",
"flashMessage",
"=",
"__d",
"(",
"'wasabi_core'",
",",
"'The language position has been updated.'",
")",
";",
"}",
"else",
"{",
"$",
"status",
"=",
"'error'",
";",
"$",
"flashMessage",
"=",
"$",
"this",
"->",
"dbErrorMessage",
";",
"}",
"// create the json response",
"$",
"frontendLanguages",
"=",
"$",
"this",
"->",
"Languages",
"->",
"filterFrontend",
"(",
"new",
"Collection",
"(",
"$",
"languages",
")",
")",
"->",
"sortBy",
"(",
"'position'",
",",
"SORT_ASC",
",",
"SORT_NUMERIC",
")",
"->",
"toList",
"(",
")",
";",
"$",
"backendLanguages",
"=",
"$",
"this",
"->",
"Languages",
"->",
"filterBackend",
"(",
"new",
"Collection",
"(",
"$",
"languages",
")",
")",
"->",
"sortBy",
"(",
"'position'",
",",
"SORT_ASC",
",",
"SORT_NUMERIC",
")",
"->",
"toList",
"(",
")",
";",
"$",
"this",
"->",
"set",
"(",
"compact",
"(",
"'status'",
",",
"'flashMessage'",
",",
"'frontendLanguages'",
",",
"'backendLanguages'",
")",
")",
";",
"$",
"this",
"->",
"set",
"(",
"'_serialize'",
",",
"[",
"'status'",
",",
"'flashMessage'",
",",
"'frontendLanguages'",
",",
"'backendLanguages'",
"]",
")",
";",
"$",
"this",
"->",
"RequestHandler",
"->",
"renderAs",
"(",
"$",
"this",
",",
"'json'",
")",
";",
"}"
] |
Sort action
AJAX POST
Save the order of languages.
@return void
|
[
"Sort",
"action",
"AJAX",
"POST"
] |
0eadbb64d2fc201bacc63c93814adeca70e08f90
|
https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/Controller/LanguagesController.php#L143-L189
|
237,873
|
wasabi-cms/core
|
src/Controller/LanguagesController.php
|
LanguagesController.change
|
public function change($id = null)
{
if ($id === null || !$this->Languages->exists(['id' => $id])) {
$this->Flash->error($this->invalidRequestMessage);
$this->redirect($this->referer());
return;
}
$this->request->session()->write('contentLanguageId', (int)$id);
$this->redirect($this->referer());
}
|
php
|
public function change($id = null)
{
if ($id === null || !$this->Languages->exists(['id' => $id])) {
$this->Flash->error($this->invalidRequestMessage);
$this->redirect($this->referer());
return;
}
$this->request->session()->write('contentLanguageId', (int)$id);
$this->redirect($this->referer());
}
|
[
"public",
"function",
"change",
"(",
"$",
"id",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"id",
"===",
"null",
"||",
"!",
"$",
"this",
"->",
"Languages",
"->",
"exists",
"(",
"[",
"'id'",
"=>",
"$",
"id",
"]",
")",
")",
"{",
"$",
"this",
"->",
"Flash",
"->",
"error",
"(",
"$",
"this",
"->",
"invalidRequestMessage",
")",
";",
"$",
"this",
"->",
"redirect",
"(",
"$",
"this",
"->",
"referer",
"(",
")",
")",
";",
"return",
";",
"}",
"$",
"this",
"->",
"request",
"->",
"session",
"(",
")",
"->",
"write",
"(",
"'contentLanguageId'",
",",
"(",
"int",
")",
"$",
"id",
")",
";",
"$",
"this",
"->",
"redirect",
"(",
"$",
"this",
"->",
"referer",
"(",
")",
")",
";",
"}"
] |
Change action
GET
Change the content language to $id and update the session.
@param string $id The language id.
@return void
|
[
"Change",
"action",
"GET"
] |
0eadbb64d2fc201bacc63c93814adeca70e08f90
|
https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/Controller/LanguagesController.php#L200-L209
|
237,874
|
unclecheese/silverstripe-reflection-templates
|
code/SiteTreeReflectionTemplate.php
|
SiteTreeReflectionTemplate.getTemplateAccessors
|
public function getTemplateAccessors() {
if($this->templateAccessors) return $this->templateAccessors;
$vars = parent::getTemplateAccessors();
$cc = new ReflectionClass('ContentController');
$site_tree = new ReflectionClass('SiteTree');
$hierarchy = new ReflectionClass('Hierarchy');
$methods = array_merge(
$site_tree->getMethods(),
$cc->getMethods(),
$hierarchy->getMethods(),
array_keys(singleton('SiteTree')->has_many()),
array_keys(singleton('SiteTree')->many_many()),
array_keys(singleton('SiteTree')->db()),
array_keys(DataObject::config()->fixed_fields)
);
foreach($methods as $m) {
$name = is_object($m) ? $m->getName() : $m;
// We only care about methods that follow the UpperCamelCase convention.
if(preg_match("/[A-Z]/",$name[0])) {
$vars[] = $name;
}
}
// Just a random exception case
$vars[] = "Form";
return $this->templateAccessors = $vars;
}
|
php
|
public function getTemplateAccessors() {
if($this->templateAccessors) return $this->templateAccessors;
$vars = parent::getTemplateAccessors();
$cc = new ReflectionClass('ContentController');
$site_tree = new ReflectionClass('SiteTree');
$hierarchy = new ReflectionClass('Hierarchy');
$methods = array_merge(
$site_tree->getMethods(),
$cc->getMethods(),
$hierarchy->getMethods(),
array_keys(singleton('SiteTree')->has_many()),
array_keys(singleton('SiteTree')->many_many()),
array_keys(singleton('SiteTree')->db()),
array_keys(DataObject::config()->fixed_fields)
);
foreach($methods as $m) {
$name = is_object($m) ? $m->getName() : $m;
// We only care about methods that follow the UpperCamelCase convention.
if(preg_match("/[A-Z]/",$name[0])) {
$vars[] = $name;
}
}
// Just a random exception case
$vars[] = "Form";
return $this->templateAccessors = $vars;
}
|
[
"public",
"function",
"getTemplateAccessors",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"templateAccessors",
")",
"return",
"$",
"this",
"->",
"templateAccessors",
";",
"$",
"vars",
"=",
"parent",
"::",
"getTemplateAccessors",
"(",
")",
";",
"$",
"cc",
"=",
"new",
"ReflectionClass",
"(",
"'ContentController'",
")",
";",
"$",
"site_tree",
"=",
"new",
"ReflectionClass",
"(",
"'SiteTree'",
")",
";",
"$",
"hierarchy",
"=",
"new",
"ReflectionClass",
"(",
"'Hierarchy'",
")",
";",
"$",
"methods",
"=",
"array_merge",
"(",
"$",
"site_tree",
"->",
"getMethods",
"(",
")",
",",
"$",
"cc",
"->",
"getMethods",
"(",
")",
",",
"$",
"hierarchy",
"->",
"getMethods",
"(",
")",
",",
"array_keys",
"(",
"singleton",
"(",
"'SiteTree'",
")",
"->",
"has_many",
"(",
")",
")",
",",
"array_keys",
"(",
"singleton",
"(",
"'SiteTree'",
")",
"->",
"many_many",
"(",
")",
")",
",",
"array_keys",
"(",
"singleton",
"(",
"'SiteTree'",
")",
"->",
"db",
"(",
")",
")",
",",
"array_keys",
"(",
"DataObject",
"::",
"config",
"(",
")",
"->",
"fixed_fields",
")",
")",
";",
"foreach",
"(",
"$",
"methods",
"as",
"$",
"m",
")",
"{",
"$",
"name",
"=",
"is_object",
"(",
"$",
"m",
")",
"?",
"$",
"m",
"->",
"getName",
"(",
")",
":",
"$",
"m",
";",
"// We only care about methods that follow the UpperCamelCase convention.",
"if",
"(",
"preg_match",
"(",
"\"/[A-Z]/\"",
",",
"$",
"name",
"[",
"0",
"]",
")",
")",
"{",
"$",
"vars",
"[",
"]",
"=",
"$",
"name",
";",
"}",
"}",
"// Just a random exception case",
"$",
"vars",
"[",
"]",
"=",
"\"Form\"",
";",
"return",
"$",
"this",
"->",
"templateAccessors",
"=",
"$",
"vars",
";",
"}"
] |
Gets all the core template accessors available to SiteTree templates
and caches the result
@return array
|
[
"Gets",
"all",
"the",
"core",
"template",
"accessors",
"available",
"to",
"SiteTree",
"templates",
"and",
"caches",
"the",
"result"
] |
7ae6fc333246afd1099bf91f281211ec8d8232d2
|
https://github.com/unclecheese/silverstripe-reflection-templates/blob/7ae6fc333246afd1099bf91f281211ec8d8232d2/code/SiteTreeReflectionTemplate.php#L18-L49
|
237,875
|
twanhaverkamp/core-bundle
|
Twig/AbstractExtension.php
|
AbstractExtension.generateUrl
|
final protected function generateUrl(string $name, array $params = []) : string
{
return $this->urlGenerator
->generate($name, $params);
}
|
php
|
final protected function generateUrl(string $name, array $params = []) : string
{
return $this->urlGenerator
->generate($name, $params);
}
|
[
"final",
"protected",
"function",
"generateUrl",
"(",
"string",
"$",
"name",
",",
"array",
"$",
"params",
"=",
"[",
"]",
")",
":",
"string",
"{",
"return",
"$",
"this",
"->",
"urlGenerator",
"->",
"generate",
"(",
"$",
"name",
",",
"$",
"params",
")",
";",
"}"
] |
Generate a URL by the given name and params
@param string $name
@param array $params
@return string
|
[
"Generate",
"a",
"URL",
"by",
"the",
"given",
"name",
"and",
"params"
] |
04ccf69c159566a850ed9d048d09accd12e68e26
|
https://github.com/twanhaverkamp/core-bundle/blob/04ccf69c159566a850ed9d048d09accd12e68e26/Twig/AbstractExtension.php#L51-L55
|
237,876
|
OWeb/OWeb-Framework
|
OWeb/defaults/extensions/bbcode/SBBCodeParser/classes/Node/Container.php
|
Node_Container.replace_child
|
public function replace_child(Node $what, $with)
{
$replace_key = array_search($what, $this->children);
if($replace_key === false)
return false;
if(is_array($with))
foreach($with as $child)
$child->set_parent($this);
array_splice($this->children, $replace_key, 1, $with);
return true;
}
|
php
|
public function replace_child(Node $what, $with)
{
$replace_key = array_search($what, $this->children);
if($replace_key === false)
return false;
if(is_array($with))
foreach($with as $child)
$child->set_parent($this);
array_splice($this->children, $replace_key, 1, $with);
return true;
}
|
[
"public",
"function",
"replace_child",
"(",
"Node",
"$",
"what",
",",
"$",
"with",
")",
"{",
"$",
"replace_key",
"=",
"array_search",
"(",
"$",
"what",
",",
"$",
"this",
"->",
"children",
")",
";",
"if",
"(",
"$",
"replace_key",
"===",
"false",
")",
"return",
"false",
";",
"if",
"(",
"is_array",
"(",
"$",
"with",
")",
")",
"foreach",
"(",
"$",
"with",
"as",
"$",
"child",
")",
"$",
"child",
"->",
"set_parent",
"(",
"$",
"this",
")",
";",
"array_splice",
"(",
"$",
"this",
"->",
"children",
",",
"$",
"replace_key",
",",
"1",
",",
"$",
"with",
")",
";",
"return",
"true",
";",
"}"
] |
Replaces a child node
@param Node $what
@param mixed $with Node or an array of Node
@return bool
|
[
"Replaces",
"a",
"child",
"node"
] |
fb441f51afb16860b0c946a55c36c789fbb125fa
|
https://github.com/OWeb/OWeb-Framework/blob/fb441f51afb16860b0c946a55c36c789fbb125fa/OWeb/defaults/extensions/bbcode/SBBCodeParser/classes/Node/Container.php#L32-L46
|
237,877
|
OWeb/OWeb-Framework
|
OWeb/defaults/extensions/bbcode/SBBCodeParser/classes/Node/Container.php
|
Node_Container.remove_child
|
public function remove_child(Node $child)
{
$key = array_search($what, $this->children);
if($key === false)
return false;
$this->children[$key]->set_parent();
unset($this->children[$key]);
return true;
}
|
php
|
public function remove_child(Node $child)
{
$key = array_search($what, $this->children);
if($key === false)
return false;
$this->children[$key]->set_parent();
unset($this->children[$key]);
return true;
}
|
[
"public",
"function",
"remove_child",
"(",
"Node",
"$",
"child",
")",
"{",
"$",
"key",
"=",
"array_search",
"(",
"$",
"what",
",",
"$",
"this",
"->",
"children",
")",
";",
"if",
"(",
"$",
"key",
"===",
"false",
")",
"return",
"false",
";",
"$",
"this",
"->",
"children",
"[",
"$",
"key",
"]",
"->",
"set_parent",
"(",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"children",
"[",
"$",
"key",
"]",
")",
";",
"return",
"true",
";",
"}"
] |
Removes a child fromthe node
@param Node $child
@return bool
|
[
"Removes",
"a",
"child",
"fromthe",
"node"
] |
fb441f51afb16860b0c946a55c36c789fbb125fa
|
https://github.com/OWeb/OWeb-Framework/blob/fb441f51afb16860b0c946a55c36c789fbb125fa/OWeb/defaults/extensions/bbcode/SBBCodeParser/classes/Node/Container.php#L53-L63
|
237,878
|
OWeb/OWeb-Framework
|
OWeb/defaults/extensions/bbcode/SBBCodeParser/classes/Node/Container.php
|
Node_Container.last_tag_node
|
public function last_tag_node()
{
$children_len = count($this->children);
for($i=$children_len-1; $i >= 0; $i--)
if($this->children[$i] instanceof Node_Container_Tag)
return $this->children[$i];
return null;
}
|
php
|
public function last_tag_node()
{
$children_len = count($this->children);
for($i=$children_len-1; $i >= 0; $i--)
if($this->children[$i] instanceof Node_Container_Tag)
return $this->children[$i];
return null;
}
|
[
"public",
"function",
"last_tag_node",
"(",
")",
"{",
"$",
"children_len",
"=",
"count",
"(",
"$",
"this",
"->",
"children",
")",
";",
"for",
"(",
"$",
"i",
"=",
"$",
"children_len",
"-",
"1",
";",
"$",
"i",
">=",
"0",
";",
"$",
"i",
"--",
")",
"if",
"(",
"$",
"this",
"->",
"children",
"[",
"$",
"i",
"]",
"instanceof",
"Node_Container_Tag",
")",
"return",
"$",
"this",
"->",
"children",
"[",
"$",
"i",
"]",
";",
"return",
"null",
";",
"}"
] |
Gets the last child of type Node_Container_Tag.
@return Node_Container_Tag
|
[
"Gets",
"the",
"last",
"child",
"of",
"type",
"Node_Container_Tag",
"."
] |
fb441f51afb16860b0c946a55c36c789fbb125fa
|
https://github.com/OWeb/OWeb-Framework/blob/fb441f51afb16860b0c946a55c36c789fbb125fa/OWeb/defaults/extensions/bbcode/SBBCodeParser/classes/Node/Container.php#L78-L87
|
237,879
|
OWeb/OWeb-Framework
|
OWeb/defaults/extensions/bbcode/SBBCodeParser/classes/Node/Container.php
|
Node_Container.get_html
|
public function get_html($nl2br=true, $htmlEntities = true)
{
$html = '';
foreach($this->children as $child)
$html .= $child->get_html($nl2br, $htmlEntities);
if($this instanceof Node_Container_Document)
return $html;
$bbcode = $this->root()->get_bbcode($this->tag);
if(is_callable($bbcode->handler()) && ($func = $bbcode->handler()) !== false)
return $func($html, $this->attribs, $this);
//return call_user_func($bbcode->handler(), $html, $this->attribs, $this);
return str_replace('%content%', $html, $bbcode->handler());
}
|
php
|
public function get_html($nl2br=true, $htmlEntities = true)
{
$html = '';
foreach($this->children as $child)
$html .= $child->get_html($nl2br, $htmlEntities);
if($this instanceof Node_Container_Document)
return $html;
$bbcode = $this->root()->get_bbcode($this->tag);
if(is_callable($bbcode->handler()) && ($func = $bbcode->handler()) !== false)
return $func($html, $this->attribs, $this);
//return call_user_func($bbcode->handler(), $html, $this->attribs, $this);
return str_replace('%content%', $html, $bbcode->handler());
}
|
[
"public",
"function",
"get_html",
"(",
"$",
"nl2br",
"=",
"true",
",",
"$",
"htmlEntities",
"=",
"true",
")",
"{",
"$",
"html",
"=",
"''",
";",
"foreach",
"(",
"$",
"this",
"->",
"children",
"as",
"$",
"child",
")",
"$",
"html",
".=",
"$",
"child",
"->",
"get_html",
"(",
"$",
"nl2br",
",",
"$",
"htmlEntities",
")",
";",
"if",
"(",
"$",
"this",
"instanceof",
"Node_Container_Document",
")",
"return",
"$",
"html",
";",
"$",
"bbcode",
"=",
"$",
"this",
"->",
"root",
"(",
")",
"->",
"get_bbcode",
"(",
"$",
"this",
"->",
"tag",
")",
";",
"if",
"(",
"is_callable",
"(",
"$",
"bbcode",
"->",
"handler",
"(",
")",
")",
"&&",
"(",
"$",
"func",
"=",
"$",
"bbcode",
"->",
"handler",
"(",
")",
")",
"!==",
"false",
")",
"return",
"$",
"func",
"(",
"$",
"html",
",",
"$",
"this",
"->",
"attribs",
",",
"$",
"this",
")",
";",
"//return call_user_func($bbcode->handler(), $html, $this->attribs, $this);",
"return",
"str_replace",
"(",
"'%content%'",
",",
"$",
"html",
",",
"$",
"bbcode",
"->",
"handler",
"(",
")",
")",
";",
"}"
] |
Gets a HTML representation of this node
@return string
|
[
"Gets",
"a",
"HTML",
"representation",
"of",
"this",
"node"
] |
fb441f51afb16860b0c946a55c36c789fbb125fa
|
https://github.com/OWeb/OWeb-Framework/blob/fb441f51afb16860b0c946a55c36c789fbb125fa/OWeb/defaults/extensions/bbcode/SBBCodeParser/classes/Node/Container.php#L93-L110
|
237,880
|
OWeb/OWeb-Framework
|
OWeb/defaults/extensions/bbcode/SBBCodeParser/classes/Node/Container.php
|
Node_Container.get_text
|
public function get_text()
{
$text = '';
foreach($this->children as $child)
$text .= $child->get_text();
return $text;
}
|
php
|
public function get_text()
{
$text = '';
foreach($this->children as $child)
$text .= $child->get_text();
return $text;
}
|
[
"public",
"function",
"get_text",
"(",
")",
"{",
"$",
"text",
"=",
"''",
";",
"foreach",
"(",
"$",
"this",
"->",
"children",
"as",
"$",
"child",
")",
"$",
"text",
".=",
"$",
"child",
"->",
"get_text",
"(",
")",
";",
"return",
"$",
"text",
";",
"}"
] |
Gets the raw text content of this node
and it's children.
The returned text is UNSAFE and should not
be used without filtering!
@return string
|
[
"Gets",
"the",
"raw",
"text",
"content",
"of",
"this",
"node",
"and",
"it",
"s",
"children",
"."
] |
fb441f51afb16860b0c946a55c36c789fbb125fa
|
https://github.com/OWeb/OWeb-Framework/blob/fb441f51afb16860b0c946a55c36c789fbb125fa/OWeb/defaults/extensions/bbcode/SBBCodeParser/classes/Node/Container.php#L120-L128
|
237,881
|
wisquimas/valleysofsorcery
|
admin/mf_custom_fields.php
|
mf_custom_fields.edit_field
|
function edit_field() {
global $mf_domain;
//check param custom_field_id
$data = $this->fields_form();
$field = $this->get_custom_field($_GET['custom_field_id']);
//check if exist field
if(!$field){
$this->mf_flash('error');
}else{
$no_set = array('options','active','display_order');
foreach($field as $k => $v){
if( !in_array($k,$no_set) ){
$data['core'][$k]['value'] = $v;
}
}
$data['option'] = unserialize($field['options'] );
}
$this->form_custom_field($data);
?>
<?php
}
|
php
|
function edit_field() {
global $mf_domain;
//check param custom_field_id
$data = $this->fields_form();
$field = $this->get_custom_field($_GET['custom_field_id']);
//check if exist field
if(!$field){
$this->mf_flash('error');
}else{
$no_set = array('options','active','display_order');
foreach($field as $k => $v){
if( !in_array($k,$no_set) ){
$data['core'][$k]['value'] = $v;
}
}
$data['option'] = unserialize($field['options'] );
}
$this->form_custom_field($data);
?>
<?php
}
|
[
"function",
"edit_field",
"(",
")",
"{",
"global",
"$",
"mf_domain",
";",
"//check param custom_field_id",
"$",
"data",
"=",
"$",
"this",
"->",
"fields_form",
"(",
")",
";",
"$",
"field",
"=",
"$",
"this",
"->",
"get_custom_field",
"(",
"$",
"_GET",
"[",
"'custom_field_id'",
"]",
")",
";",
"//check if exist field",
"if",
"(",
"!",
"$",
"field",
")",
"{",
"$",
"this",
"->",
"mf_flash",
"(",
"'error'",
")",
";",
"}",
"else",
"{",
"$",
"no_set",
"=",
"array",
"(",
"'options'",
",",
"'active'",
",",
"'display_order'",
")",
";",
"foreach",
"(",
"$",
"field",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"k",
",",
"$",
"no_set",
")",
")",
"{",
"$",
"data",
"[",
"'core'",
"]",
"[",
"$",
"k",
"]",
"[",
"'value'",
"]",
"=",
"$",
"v",
";",
"}",
"}",
"$",
"data",
"[",
"'option'",
"]",
"=",
"unserialize",
"(",
"$",
"field",
"[",
"'options'",
"]",
")",
";",
"}",
"$",
"this",
"->",
"form_custom_field",
"(",
"$",
"data",
")",
";",
"?>\n <?php",
"}"
] |
Page for edit a custom field
|
[
"Page",
"for",
"edit",
"a",
"custom",
"field"
] |
78a8d8f1d1102c5043e2cf7c98762e63464d2d7a
|
https://github.com/wisquimas/valleysofsorcery/blob/78a8d8f1d1102c5043e2cf7c98762e63464d2d7a/admin/mf_custom_fields.php#L242-L264
|
237,882
|
wisquimas/valleysofsorcery
|
admin/mf_custom_fields.php
|
mf_custom_fields.get_custom_fields_name
|
function get_custom_fields_name () {
$path = MF_PATH.'/field_types/*';
$folders = glob($path,GLOB_ONLYDIR);
$fields = array();
foreach($folders as $folder) {
$name = preg_match('/\/([\w\_]+)\_field$/i',$folder,$name_match);
$fields[$name_match[1]] = preg_replace('/_/',' ',$name_match[1]);
}
return $fields;
}
|
php
|
function get_custom_fields_name () {
$path = MF_PATH.'/field_types/*';
$folders = glob($path,GLOB_ONLYDIR);
$fields = array();
foreach($folders as $folder) {
$name = preg_match('/\/([\w\_]+)\_field$/i',$folder,$name_match);
$fields[$name_match[1]] = preg_replace('/_/',' ',$name_match[1]);
}
return $fields;
}
|
[
"function",
"get_custom_fields_name",
"(",
")",
"{",
"$",
"path",
"=",
"MF_PATH",
".",
"'/field_types/*'",
";",
"$",
"folders",
"=",
"glob",
"(",
"$",
"path",
",",
"GLOB_ONLYDIR",
")",
";",
"$",
"fields",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"folders",
"as",
"$",
"folder",
")",
"{",
"$",
"name",
"=",
"preg_match",
"(",
"'/\\/([\\w\\_]+)\\_field$/i'",
",",
"$",
"folder",
",",
"$",
"name_match",
")",
";",
"$",
"fields",
"[",
"$",
"name_match",
"[",
"1",
"]",
"]",
"=",
"preg_replace",
"(",
"'/_/'",
",",
"' '",
",",
"$",
"name_match",
"[",
"1",
"]",
")",
";",
"}",
"return",
"$",
"fields",
";",
"}"
] |
Get the list of custom fields
@return array
|
[
"Get",
"the",
"list",
"of",
"custom",
"fields"
] |
78a8d8f1d1102c5043e2cf7c98762e63464d2d7a
|
https://github.com/wisquimas/valleysofsorcery/blob/78a8d8f1d1102c5043e2cf7c98762e63464d2d7a/admin/mf_custom_fields.php#L321-L333
|
237,883
|
wisquimas/valleysofsorcery
|
admin/mf_custom_fields.php
|
mf_custom_fields.save_order_field
|
public static function save_order_field( $group_id, $order ) {
global $wpdb;
if( !is_numeric($group_id) ) {
return false;
}
foreach( $order as $key => $value ) {
$update = $wpdb->update(
MF_TABLE_CUSTOM_FIELDS,
array( 'display_order' => $key ),
array( 'custom_group_id' => $group_id, 'id' => $value ),
array( '%d' ),
array( '%d', '%d' )
);
if( $update === false ) {
return $update;
}
}
return true;
}
|
php
|
public static function save_order_field( $group_id, $order ) {
global $wpdb;
if( !is_numeric($group_id) ) {
return false;
}
foreach( $order as $key => $value ) {
$update = $wpdb->update(
MF_TABLE_CUSTOM_FIELDS,
array( 'display_order' => $key ),
array( 'custom_group_id' => $group_id, 'id' => $value ),
array( '%d' ),
array( '%d', '%d' )
);
if( $update === false ) {
return $update;
}
}
return true;
}
|
[
"public",
"static",
"function",
"save_order_field",
"(",
"$",
"group_id",
",",
"$",
"order",
")",
"{",
"global",
"$",
"wpdb",
";",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"group_id",
")",
")",
"{",
"return",
"false",
";",
"}",
"foreach",
"(",
"$",
"order",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"update",
"=",
"$",
"wpdb",
"->",
"update",
"(",
"MF_TABLE_CUSTOM_FIELDS",
",",
"array",
"(",
"'display_order'",
"=>",
"$",
"key",
")",
",",
"array",
"(",
"'custom_group_id'",
"=>",
"$",
"group_id",
",",
"'id'",
"=>",
"$",
"value",
")",
",",
"array",
"(",
"'%d'",
")",
",",
"array",
"(",
"'%d'",
",",
"'%d'",
")",
")",
";",
"if",
"(",
"$",
"update",
"===",
"false",
")",
"{",
"return",
"$",
"update",
";",
"}",
"}",
"return",
"true",
";",
"}"
] |
Save the order of the custom fields
|
[
"Save",
"the",
"order",
"of",
"the",
"custom",
"fields"
] |
78a8d8f1d1102c5043e2cf7c98762e63464d2d7a
|
https://github.com/wisquimas/valleysofsorcery/blob/78a8d8f1d1102c5043e2cf7c98762e63464d2d7a/admin/mf_custom_fields.php#L564-L585
|
237,884
|
wisquimas/valleysofsorcery
|
admin/mf_custom_fields.php
|
mf_custom_fields.has_fields
|
public static function has_fields($post_type_name) {
global $wpdb;
$sql = $wpdb->prepare("SELECT COUNT(1) FROM ".MF_TABLE_CUSTOM_FIELDS. " WHERE post_type = %s",$post_type_name);
return $wpdb->get_var( $sql ) > 0;
}
|
php
|
public static function has_fields($post_type_name) {
global $wpdb;
$sql = $wpdb->prepare("SELECT COUNT(1) FROM ".MF_TABLE_CUSTOM_FIELDS. " WHERE post_type = %s",$post_type_name);
return $wpdb->get_var( $sql ) > 0;
}
|
[
"public",
"static",
"function",
"has_fields",
"(",
"$",
"post_type_name",
")",
"{",
"global",
"$",
"wpdb",
";",
"$",
"sql",
"=",
"$",
"wpdb",
"->",
"prepare",
"(",
"\"SELECT COUNT(1) FROM \"",
".",
"MF_TABLE_CUSTOM_FIELDS",
".",
"\" WHERE post_type = %s\"",
",",
"$",
"post_type_name",
")",
";",
"return",
"$",
"wpdb",
"->",
"get_var",
"(",
"$",
"sql",
")",
">",
"0",
";",
"}"
] |
Return True if the post type has at least one custom field
return @bool
|
[
"Return",
"True",
"if",
"the",
"post",
"type",
"has",
"at",
"least",
"one",
"custom",
"field"
] |
78a8d8f1d1102c5043e2cf7c98762e63464d2d7a
|
https://github.com/wisquimas/valleysofsorcery/blob/78a8d8f1d1102c5043e2cf7c98762e63464d2d7a/admin/mf_custom_fields.php#L592-L598
|
237,885
|
wisquimas/valleysofsorcery
|
admin/mf_custom_fields.php
|
mf_custom_fields.delete_custom_field
|
function delete_custom_field() {
global $wpdb;
//checking the nonce
check_admin_referer('delete_custom_field');
if( isset($_GET['custom_field_id']) ) {
$id = (int)$_GET['custom_field_id'];
if( is_int($id) ){
$sql = $wpdb->prepare( "DELETE FROM ".MF_TABLE_CUSTOM_FIELDS." WHERE id = %d",$id );
$wpdb->query($sql);
}
}
//ToDo: poner mensaje de que se borro correctamente
wp_safe_redirect(
add_query_arg(
'field_deleted',
'true',
wp_get_referer()
)
);
}
|
php
|
function delete_custom_field() {
global $wpdb;
//checking the nonce
check_admin_referer('delete_custom_field');
if( isset($_GET['custom_field_id']) ) {
$id = (int)$_GET['custom_field_id'];
if( is_int($id) ){
$sql = $wpdb->prepare( "DELETE FROM ".MF_TABLE_CUSTOM_FIELDS." WHERE id = %d",$id );
$wpdb->query($sql);
}
}
//ToDo: poner mensaje de que se borro correctamente
wp_safe_redirect(
add_query_arg(
'field_deleted',
'true',
wp_get_referer()
)
);
}
|
[
"function",
"delete_custom_field",
"(",
")",
"{",
"global",
"$",
"wpdb",
";",
"//checking the nonce",
"check_admin_referer",
"(",
"'delete_custom_field'",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"_GET",
"[",
"'custom_field_id'",
"]",
")",
")",
"{",
"$",
"id",
"=",
"(",
"int",
")",
"$",
"_GET",
"[",
"'custom_field_id'",
"]",
";",
"if",
"(",
"is_int",
"(",
"$",
"id",
")",
")",
"{",
"$",
"sql",
"=",
"$",
"wpdb",
"->",
"prepare",
"(",
"\"DELETE FROM \"",
".",
"MF_TABLE_CUSTOM_FIELDS",
".",
"\" WHERE id = %d\"",
",",
"$",
"id",
")",
";",
"$",
"wpdb",
"->",
"query",
"(",
"$",
"sql",
")",
";",
"}",
"}",
"//ToDo: poner mensaje de que se borro correctamente",
"wp_safe_redirect",
"(",
"add_query_arg",
"(",
"'field_deleted'",
",",
"'true'",
",",
"wp_get_referer",
"(",
")",
")",
")",
";",
"}"
] |
Delete Custom Field
|
[
"Delete",
"Custom",
"Field"
] |
78a8d8f1d1102c5043e2cf7c98762e63464d2d7a
|
https://github.com/wisquimas/valleysofsorcery/blob/78a8d8f1d1102c5043e2cf7c98762e63464d2d7a/admin/mf_custom_fields.php#L604-L627
|
237,886
|
SocietyCMS/Core
|
Composers/MasterViewComposer.php
|
MasterViewComposer.provideAPIRoutes
|
protected function provideAPIRoutes()
{
$routes = Cache::rememberForever('provideAPIRoutes', function () {
$router = app(Router::class);
$routes = [];
foreach ($router->getRoutes() as $collection) {
foreach ($collection->getRoutes() as $route) {
$temp = &$routes;
if ($routeName = $route->getName()) {
foreach (explode('.', $routeName) as $key) {
$temp = &$temp[$key];
}
$temp = preg_replace('/{(\w+)}/', ':$1', $route->uri());
}
}
}
return $routes['api'];
});
JavaScript::put(['api' => $routes]);
}
|
php
|
protected function provideAPIRoutes()
{
$routes = Cache::rememberForever('provideAPIRoutes', function () {
$router = app(Router::class);
$routes = [];
foreach ($router->getRoutes() as $collection) {
foreach ($collection->getRoutes() as $route) {
$temp = &$routes;
if ($routeName = $route->getName()) {
foreach (explode('.', $routeName) as $key) {
$temp = &$temp[$key];
}
$temp = preg_replace('/{(\w+)}/', ':$1', $route->uri());
}
}
}
return $routes['api'];
});
JavaScript::put(['api' => $routes]);
}
|
[
"protected",
"function",
"provideAPIRoutes",
"(",
")",
"{",
"$",
"routes",
"=",
"Cache",
"::",
"rememberForever",
"(",
"'provideAPIRoutes'",
",",
"function",
"(",
")",
"{",
"$",
"router",
"=",
"app",
"(",
"Router",
"::",
"class",
")",
";",
"$",
"routes",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"router",
"->",
"getRoutes",
"(",
")",
"as",
"$",
"collection",
")",
"{",
"foreach",
"(",
"$",
"collection",
"->",
"getRoutes",
"(",
")",
"as",
"$",
"route",
")",
"{",
"$",
"temp",
"=",
"&",
"$",
"routes",
";",
"if",
"(",
"$",
"routeName",
"=",
"$",
"route",
"->",
"getName",
"(",
")",
")",
"{",
"foreach",
"(",
"explode",
"(",
"'.'",
",",
"$",
"routeName",
")",
"as",
"$",
"key",
")",
"{",
"$",
"temp",
"=",
"&",
"$",
"temp",
"[",
"$",
"key",
"]",
";",
"}",
"$",
"temp",
"=",
"preg_replace",
"(",
"'/{(\\w+)}/'",
",",
"':$1'",
",",
"$",
"route",
"->",
"uri",
"(",
")",
")",
";",
"}",
"}",
"}",
"return",
"$",
"routes",
"[",
"'api'",
"]",
";",
"}",
")",
";",
"JavaScript",
"::",
"put",
"(",
"[",
"'api'",
"=>",
"$",
"routes",
"]",
")",
";",
"}"
] |
Provide all api routes as javascript variables.
|
[
"Provide",
"all",
"api",
"routes",
"as",
"javascript",
"variables",
"."
] |
fb6be1b1dd46c89a976c02feb998e9af01ddca54
|
https://github.com/SocietyCMS/Core/blob/fb6be1b1dd46c89a976c02feb998e9af01ddca54/Composers/MasterViewComposer.php#L98-L119
|
237,887
|
extendsframework/extends-http
|
src/Request/Uri/Uri.php
|
Uri.fromEnvironment
|
public static function fromEnvironment(): UriInterface
{
parse_str($_SERVER['QUERY_STRING'] ?? '', $query);
$uri = (new static())
->withScheme((isset($_SERVER['HTTPS']) === true && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http')
->withHost($_SERVER['HTTP_HOST'])
->withPort((int)$_SERVER['SERVER_PORT'])
->withPath(strtok($_SERVER['REQUEST_URI'], '?'))
->withQuery($query);
if (array_key_exists('PHP_AUTH_USER', $_SERVER) === true) {
$uri = $uri->withUser($_SERVER['PHP_AUTH_USER']);
}
if (array_key_exists('PHP_AUTH_PW', $_SERVER) === true) {
$uri = $uri->withPass($_SERVER['PHP_AUTH_PW']);
}
return $uri;
}
|
php
|
public static function fromEnvironment(): UriInterface
{
parse_str($_SERVER['QUERY_STRING'] ?? '', $query);
$uri = (new static())
->withScheme((isset($_SERVER['HTTPS']) === true && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http')
->withHost($_SERVER['HTTP_HOST'])
->withPort((int)$_SERVER['SERVER_PORT'])
->withPath(strtok($_SERVER['REQUEST_URI'], '?'))
->withQuery($query);
if (array_key_exists('PHP_AUTH_USER', $_SERVER) === true) {
$uri = $uri->withUser($_SERVER['PHP_AUTH_USER']);
}
if (array_key_exists('PHP_AUTH_PW', $_SERVER) === true) {
$uri = $uri->withPass($_SERVER['PHP_AUTH_PW']);
}
return $uri;
}
|
[
"public",
"static",
"function",
"fromEnvironment",
"(",
")",
":",
"UriInterface",
"{",
"parse_str",
"(",
"$",
"_SERVER",
"[",
"'QUERY_STRING'",
"]",
"??",
"''",
",",
"$",
"query",
")",
";",
"$",
"uri",
"=",
"(",
"new",
"static",
"(",
")",
")",
"->",
"withScheme",
"(",
"(",
"isset",
"(",
"$",
"_SERVER",
"[",
"'HTTPS'",
"]",
")",
"===",
"true",
"&&",
"$",
"_SERVER",
"[",
"'HTTPS'",
"]",
"!==",
"'off'",
")",
"?",
"'https'",
":",
"'http'",
")",
"->",
"withHost",
"(",
"$",
"_SERVER",
"[",
"'HTTP_HOST'",
"]",
")",
"->",
"withPort",
"(",
"(",
"int",
")",
"$",
"_SERVER",
"[",
"'SERVER_PORT'",
"]",
")",
"->",
"withPath",
"(",
"strtok",
"(",
"$",
"_SERVER",
"[",
"'REQUEST_URI'",
"]",
",",
"'?'",
")",
")",
"->",
"withQuery",
"(",
"$",
"query",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"'PHP_AUTH_USER'",
",",
"$",
"_SERVER",
")",
"===",
"true",
")",
"{",
"$",
"uri",
"=",
"$",
"uri",
"->",
"withUser",
"(",
"$",
"_SERVER",
"[",
"'PHP_AUTH_USER'",
"]",
")",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"'PHP_AUTH_PW'",
",",
"$",
"_SERVER",
")",
"===",
"true",
")",
"{",
"$",
"uri",
"=",
"$",
"uri",
"->",
"withPass",
"(",
"$",
"_SERVER",
"[",
"'PHP_AUTH_PW'",
"]",
")",
";",
"}",
"return",
"$",
"uri",
";",
"}"
] |
Create URI from environment variables.
@return UriInterface
|
[
"Create",
"URI",
"from",
"environment",
"variables",
"."
] |
08576827ebf5a6d39a7674e35dadb268e0ba8f1d
|
https://github.com/extendsframework/extends-http/blob/08576827ebf5a6d39a7674e35dadb268e0ba8f1d/src/Request/Uri/Uri.php#L338-L358
|
237,888
|
Softpampa/moip-sdk-php
|
src/MoipResponse.php
|
MoipResponse.analyzeResponseErrors
|
protected function analyzeResponseErrors()
{
$content = $this->content;
if ($content && property_exists($content, 'errors')) {
$this->setErrors($content, 'errors');
} elseif ($content && property_exists($content, 'ERROR')) {
$this->setError('Unknown', $content->ERROR);
}
$this->throwExceptions();
}
|
php
|
protected function analyzeResponseErrors()
{
$content = $this->content;
if ($content && property_exists($content, 'errors')) {
$this->setErrors($content, 'errors');
} elseif ($content && property_exists($content, 'ERROR')) {
$this->setError('Unknown', $content->ERROR);
}
$this->throwExceptions();
}
|
[
"protected",
"function",
"analyzeResponseErrors",
"(",
")",
"{",
"$",
"content",
"=",
"$",
"this",
"->",
"content",
";",
"if",
"(",
"$",
"content",
"&&",
"property_exists",
"(",
"$",
"content",
",",
"'errors'",
")",
")",
"{",
"$",
"this",
"->",
"setErrors",
"(",
"$",
"content",
",",
"'errors'",
")",
";",
"}",
"elseif",
"(",
"$",
"content",
"&&",
"property_exists",
"(",
"$",
"content",
",",
"'ERROR'",
")",
")",
"{",
"$",
"this",
"->",
"setError",
"(",
"'Unknown'",
",",
"$",
"content",
"->",
"ERROR",
")",
";",
"}",
"$",
"this",
"->",
"throwExceptions",
"(",
")",
";",
"}"
] |
Analyze errors from response
@return void
|
[
"Analyze",
"errors",
"from",
"response"
] |
621a71bd2ef1f9b690cd3431507af608152f6ad2
|
https://github.com/Softpampa/moip-sdk-php/blob/621a71bd2ef1f9b690cd3431507af608152f6ad2/src/MoipResponse.php#L109-L120
|
237,889
|
Softpampa/moip-sdk-php
|
src/MoipResponse.php
|
MoipResponse.setErrors
|
protected function setErrors($response, $key)
{
foreach ($response->{$key} as $error) {
$this->setError($error->code, $error->description);
}
}
|
php
|
protected function setErrors($response, $key)
{
foreach ($response->{$key} as $error) {
$this->setError($error->code, $error->description);
}
}
|
[
"protected",
"function",
"setErrors",
"(",
"$",
"response",
",",
"$",
"key",
")",
"{",
"foreach",
"(",
"$",
"response",
"->",
"{",
"$",
"key",
"}",
"as",
"$",
"error",
")",
"{",
"$",
"this",
"->",
"setError",
"(",
"$",
"error",
"->",
"code",
",",
"$",
"error",
"->",
"description",
")",
";",
"}",
"}"
] |
Set errors from response
@param array $response
@param string $key
@return void
|
[
"Set",
"errors",
"from",
"response"
] |
621a71bd2ef1f9b690cd3431507af608152f6ad2
|
https://github.com/Softpampa/moip-sdk-php/blob/621a71bd2ef1f9b690cd3431507af608152f6ad2/src/MoipResponse.php#L129-L134
|
237,890
|
Softpampa/moip-sdk-php
|
src/MoipResponse.php
|
MoipResponse.setError
|
public function setError($code, $description)
{
$error = new stdClass;
$error->code = $code;
$error->description = $description;
$this->errors[] = $error;
}
|
php
|
public function setError($code, $description)
{
$error = new stdClass;
$error->code = $code;
$error->description = $description;
$this->errors[] = $error;
}
|
[
"public",
"function",
"setError",
"(",
"$",
"code",
",",
"$",
"description",
")",
"{",
"$",
"error",
"=",
"new",
"stdClass",
";",
"$",
"error",
"->",
"code",
"=",
"$",
"code",
";",
"$",
"error",
"->",
"description",
"=",
"$",
"description",
";",
"$",
"this",
"->",
"errors",
"[",
"]",
"=",
"$",
"error",
";",
"}"
] |
Set a error
@param string $code
@param string $description
@return void
|
[
"Set",
"a",
"error"
] |
621a71bd2ef1f9b690cd3431507af608152f6ad2
|
https://github.com/Softpampa/moip-sdk-php/blob/621a71bd2ef1f9b690cd3431507af608152f6ad2/src/MoipResponse.php#L143-L150
|
237,891
|
Softpampa/moip-sdk-php
|
src/MoipResponse.php
|
MoipResponse.throwExceptions
|
protected function throwExceptions()
{
$status = $this->getStatusCode();
switch ($status) {
case 400:
throw new ValidationException($this);
break;
case 401:
throw new UnauthorizedException($this);
break;
case 404:
throw new ResourceNotFoundException($this);
break;
default:
//
break;
}
if ($status >= 400 && $status < 500) {
throw new ClientRequestException($this, 'Whoops looks like something went wrong');
} elseif ($status >= 500) {
throw new ServerRequestException($this);
}
}
|
php
|
protected function throwExceptions()
{
$status = $this->getStatusCode();
switch ($status) {
case 400:
throw new ValidationException($this);
break;
case 401:
throw new UnauthorizedException($this);
break;
case 404:
throw new ResourceNotFoundException($this);
break;
default:
//
break;
}
if ($status >= 400 && $status < 500) {
throw new ClientRequestException($this, 'Whoops looks like something went wrong');
} elseif ($status >= 500) {
throw new ServerRequestException($this);
}
}
|
[
"protected",
"function",
"throwExceptions",
"(",
")",
"{",
"$",
"status",
"=",
"$",
"this",
"->",
"getStatusCode",
"(",
")",
";",
"switch",
"(",
"$",
"status",
")",
"{",
"case",
"400",
":",
"throw",
"new",
"ValidationException",
"(",
"$",
"this",
")",
";",
"break",
";",
"case",
"401",
":",
"throw",
"new",
"UnauthorizedException",
"(",
"$",
"this",
")",
";",
"break",
";",
"case",
"404",
":",
"throw",
"new",
"ResourceNotFoundException",
"(",
"$",
"this",
")",
";",
"break",
";",
"default",
":",
"//",
"break",
";",
"}",
"if",
"(",
"$",
"status",
">=",
"400",
"&&",
"$",
"status",
"<",
"500",
")",
"{",
"throw",
"new",
"ClientRequestException",
"(",
"$",
"this",
",",
"'Whoops looks like something went wrong'",
")",
";",
"}",
"elseif",
"(",
"$",
"status",
">=",
"500",
")",
"{",
"throw",
"new",
"ServerRequestException",
"(",
"$",
"this",
")",
";",
"}",
"}"
] |
Throw request exceptions
@throws ValidationException
@throws UnauthorizedException
@throws ResourceNotFoundException
@throws ClientRequestException
@throws ServerRequestException
@return void
|
[
"Throw",
"request",
"exceptions"
] |
621a71bd2ef1f9b690cd3431507af608152f6ad2
|
https://github.com/Softpampa/moip-sdk-php/blob/621a71bd2ef1f9b690cd3431507af608152f6ad2/src/MoipResponse.php#L162-L186
|
237,892
|
Softpampa/moip-sdk-php
|
src/MoipResponse.php
|
MoipResponse.getResults
|
public function getResults()
{
$key = $this->dataKey;
$content = $this->content;
if (is_object($content) && property_exists($content, $key)) {
return new Collection($content->{$key});
} elseif (is_array($content)) {
return new Collection($content);
}
return $content;
}
|
php
|
public function getResults()
{
$key = $this->dataKey;
$content = $this->content;
if (is_object($content) && property_exists($content, $key)) {
return new Collection($content->{$key});
} elseif (is_array($content)) {
return new Collection($content);
}
return $content;
}
|
[
"public",
"function",
"getResults",
"(",
")",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"dataKey",
";",
"$",
"content",
"=",
"$",
"this",
"->",
"content",
";",
"if",
"(",
"is_object",
"(",
"$",
"content",
")",
"&&",
"property_exists",
"(",
"$",
"content",
",",
"$",
"key",
")",
")",
"{",
"return",
"new",
"Collection",
"(",
"$",
"content",
"->",
"{",
"$",
"key",
"}",
")",
";",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"content",
")",
")",
"{",
"return",
"new",
"Collection",
"(",
"$",
"content",
")",
";",
"}",
"return",
"$",
"content",
";",
"}"
] |
Return response content
@return \Illuminate\Support\Collection
|
[
"Return",
"response",
"content"
] |
621a71bd2ef1f9b690cd3431507af608152f6ad2
|
https://github.com/Softpampa/moip-sdk-php/blob/621a71bd2ef1f9b690cd3431507af608152f6ad2/src/MoipResponse.php#L217-L229
|
237,893
|
tacone/datasource
|
src/RelationApi.php
|
RelationApi.registerRelations
|
protected static function registerRelations()
{
if (!static::$relations) {
$supported = [
HasOne::class => HasOneWrapper::class,
BelongsTo::class => BelongsToWrapper::class,
BelongsToMany::class => BelongsToManyWrapper::class,
HasMany::class => HasManyWrapper::class,
];
static::$relations = Collection::make([]);
foreach ($supported as $rel => $wrapperName) {
static::$relations[$rel] = [
'className' => $wrapperName,
];
}
}
}
|
php
|
protected static function registerRelations()
{
if (!static::$relations) {
$supported = [
HasOne::class => HasOneWrapper::class,
BelongsTo::class => BelongsToWrapper::class,
BelongsToMany::class => BelongsToManyWrapper::class,
HasMany::class => HasManyWrapper::class,
];
static::$relations = Collection::make([]);
foreach ($supported as $rel => $wrapperName) {
static::$relations[$rel] = [
'className' => $wrapperName,
];
}
}
}
|
[
"protected",
"static",
"function",
"registerRelations",
"(",
")",
"{",
"if",
"(",
"!",
"static",
"::",
"$",
"relations",
")",
"{",
"$",
"supported",
"=",
"[",
"HasOne",
"::",
"class",
"=>",
"HasOneWrapper",
"::",
"class",
",",
"BelongsTo",
"::",
"class",
"=>",
"BelongsToWrapper",
"::",
"class",
",",
"BelongsToMany",
"::",
"class",
"=>",
"BelongsToManyWrapper",
"::",
"class",
",",
"HasMany",
"::",
"class",
"=>",
"HasManyWrapper",
"::",
"class",
",",
"]",
";",
"static",
"::",
"$",
"relations",
"=",
"Collection",
"::",
"make",
"(",
"[",
"]",
")",
";",
"foreach",
"(",
"$",
"supported",
"as",
"$",
"rel",
"=>",
"$",
"wrapperName",
")",
"{",
"static",
"::",
"$",
"relations",
"[",
"$",
"rel",
"]",
"=",
"[",
"'className'",
"=>",
"$",
"wrapperName",
",",
"]",
";",
"}",
"}",
"}"
] |
const AFTER = 'AFTER';
|
[
"const",
"AFTER",
"=",
"AFTER",
";"
] |
9cf4423764ba14e9bbd9fa7d5cdbed27d70001f3
|
https://github.com/tacone/datasource/blob/9cf4423764ba14e9bbd9fa7d5cdbed27d70001f3/src/RelationApi.php#L25-L43
|
237,894
|
tekkla/core-html
|
Core/Html/Bootstrap/Breadcrumb/Breadcrumb.php
|
Breadcrumb.createActiveItem
|
public function createActiveItem($text, $title = '')
{
$breadcrumb = new BreadcrumbObject();
$breadcrumb->setText($text);
$breadcrumb->setActive(true);
if ($title) {
$breadcrumb->setTitle($title);
}
$this->breadcrumbs[] = $breadcrumb;
return $breadcrumb;
}
|
php
|
public function createActiveItem($text, $title = '')
{
$breadcrumb = new BreadcrumbObject();
$breadcrumb->setText($text);
$breadcrumb->setActive(true);
if ($title) {
$breadcrumb->setTitle($title);
}
$this->breadcrumbs[] = $breadcrumb;
return $breadcrumb;
}
|
[
"public",
"function",
"createActiveItem",
"(",
"$",
"text",
",",
"$",
"title",
"=",
"''",
")",
"{",
"$",
"breadcrumb",
"=",
"new",
"BreadcrumbObject",
"(",
")",
";",
"$",
"breadcrumb",
"->",
"setText",
"(",
"$",
"text",
")",
";",
"$",
"breadcrumb",
"->",
"setActive",
"(",
"true",
")",
";",
"if",
"(",
"$",
"title",
")",
"{",
"$",
"breadcrumb",
"->",
"setTitle",
"(",
"$",
"title",
")",
";",
"}",
"$",
"this",
"->",
"breadcrumbs",
"[",
"]",
"=",
"$",
"breadcrumb",
";",
"return",
"$",
"breadcrumb",
";",
"}"
] |
Creates an active breadcrumb object and adds it to the crumbs list.
@param string $text Text to show
@param string $title Title to use
@return \Core\Html\Bootstrap\Breadcrumb\BreadcrumbObject
|
[
"Creates",
"an",
"active",
"breadcrumb",
"object",
"and",
"adds",
"it",
"to",
"the",
"crumbs",
"list",
"."
] |
00bf3fa8e060e8aadf1c341f6e3c548c7a76cfd3
|
https://github.com/tekkla/core-html/blob/00bf3fa8e060e8aadf1c341f6e3c548c7a76cfd3/Core/Html/Bootstrap/Breadcrumb/Breadcrumb.php#L36-L50
|
237,895
|
tekkla/core-html
|
Core/Html/Bootstrap/Breadcrumb/Breadcrumb.php
|
Breadcrumb.createItem
|
public function createItem($text, $href, $title = '')
{
$breadcrumb = new BreadcrumbObject();
$breadcrumb->setText($text);
$breadcrumb->setHref($href);
if ($title) {
$breadcrumb->setTitle($title);
}
$this->breadcrumbs[] = $breadcrumb;
return $breadcrumb;
}
|
php
|
public function createItem($text, $href, $title = '')
{
$breadcrumb = new BreadcrumbObject();
$breadcrumb->setText($text);
$breadcrumb->setHref($href);
if ($title) {
$breadcrumb->setTitle($title);
}
$this->breadcrumbs[] = $breadcrumb;
return $breadcrumb;
}
|
[
"public",
"function",
"createItem",
"(",
"$",
"text",
",",
"$",
"href",
",",
"$",
"title",
"=",
"''",
")",
"{",
"$",
"breadcrumb",
"=",
"new",
"BreadcrumbObject",
"(",
")",
";",
"$",
"breadcrumb",
"->",
"setText",
"(",
"$",
"text",
")",
";",
"$",
"breadcrumb",
"->",
"setHref",
"(",
"$",
"href",
")",
";",
"if",
"(",
"$",
"title",
")",
"{",
"$",
"breadcrumb",
"->",
"setTitle",
"(",
"$",
"title",
")",
";",
"}",
"$",
"this",
"->",
"breadcrumbs",
"[",
"]",
"=",
"$",
"breadcrumb",
";",
"return",
"$",
"breadcrumb",
";",
"}"
] |
Creates an breadcrumb object with link and adds it to the crumbs list.
@param string $text Text to show
@param string $href Href of the link
@param string $title Title to use
@return \Core\Html\Bootstrap\Breadcrumb\BreadcrumbObject
|
[
"Creates",
"an",
"breadcrumb",
"object",
"with",
"link",
"and",
"adds",
"it",
"to",
"the",
"crumbs",
"list",
"."
] |
00bf3fa8e060e8aadf1c341f6e3c548c7a76cfd3
|
https://github.com/tekkla/core-html/blob/00bf3fa8e060e8aadf1c341f6e3c548c7a76cfd3/Core/Html/Bootstrap/Breadcrumb/Breadcrumb.php#L61-L75
|
237,896
|
indigophp-archive/codeception-fuel-module
|
fuel/fuel/packages/auth/classes/auth/login/driver.php
|
Auth_Login_Driver.get_user_array
|
final public function get_user_array(Array $additional_fields = array())
{
$user = array(
'email' => $this->get_email(),
'screen_name' => $this->get_screen_name(),
'groups' => $this->get_groups(),
);
$additional_fields = array_merge($this->config['additional_fields'], $additional_fields);
foreach($additional_fields as $af)
{
// only works if it actually can be fetched through a get_ method
if (is_callable(array($this, $method = 'get_'.$af)))
{
$user[$af] = $this->$method();
}
}
return $user;
}
|
php
|
final public function get_user_array(Array $additional_fields = array())
{
$user = array(
'email' => $this->get_email(),
'screen_name' => $this->get_screen_name(),
'groups' => $this->get_groups(),
);
$additional_fields = array_merge($this->config['additional_fields'], $additional_fields);
foreach($additional_fields as $af)
{
// only works if it actually can be fetched through a get_ method
if (is_callable(array($this, $method = 'get_'.$af)))
{
$user[$af] = $this->$method();
}
}
return $user;
}
|
[
"final",
"public",
"function",
"get_user_array",
"(",
"Array",
"$",
"additional_fields",
"=",
"array",
"(",
")",
")",
"{",
"$",
"user",
"=",
"array",
"(",
"'email'",
"=>",
"$",
"this",
"->",
"get_email",
"(",
")",
",",
"'screen_name'",
"=>",
"$",
"this",
"->",
"get_screen_name",
"(",
")",
",",
"'groups'",
"=>",
"$",
"this",
"->",
"get_groups",
"(",
")",
",",
")",
";",
"$",
"additional_fields",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"config",
"[",
"'additional_fields'",
"]",
",",
"$",
"additional_fields",
")",
";",
"foreach",
"(",
"$",
"additional_fields",
"as",
"$",
"af",
")",
"{",
"// only works if it actually can be fetched through a get_ method",
"if",
"(",
"is_callable",
"(",
"array",
"(",
"$",
"this",
",",
"$",
"method",
"=",
"'get_'",
".",
"$",
"af",
")",
")",
")",
"{",
"$",
"user",
"[",
"$",
"af",
"]",
"=",
"$",
"this",
"->",
"$",
"method",
"(",
")",
";",
"}",
"}",
"return",
"$",
"user",
";",
"}"
] |
Return user info in an array, always includes email & screen_name
Additional fields can be requested in the first param or set in config,
all additional fields must have their own method "get_" + fieldname
@param array additional fields
@return array
|
[
"Return",
"user",
"info",
"in",
"an",
"array",
"always",
"includes",
"email",
"&",
"screen_name",
"Additional",
"fields",
"can",
"be",
"requested",
"in",
"the",
"first",
"param",
"or",
"set",
"in",
"config",
"all",
"additional",
"fields",
"must",
"have",
"their",
"own",
"method",
"get_",
"+",
"fieldname"
] |
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
|
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/auth/classes/auth/login/driver.php#L98-L116
|
237,897
|
indigophp-archive/codeception-fuel-module
|
fuel/fuel/packages/auth/classes/auth/login/driver.php
|
Auth_Login_Driver.member
|
public function member($group, $driver = null, $user = null)
{
$user = $user ?: $this->get_user_id();
if ($driver === null)
{
foreach (\Auth::group(true) as $g)
{
if ($g->member($group, $user))
{
return true;
}
}
return false;
}
return \Auth::group($driver)->member($group, $user);
}
|
php
|
public function member($group, $driver = null, $user = null)
{
$user = $user ?: $this->get_user_id();
if ($driver === null)
{
foreach (\Auth::group(true) as $g)
{
if ($g->member($group, $user))
{
return true;
}
}
return false;
}
return \Auth::group($driver)->member($group, $user);
}
|
[
"public",
"function",
"member",
"(",
"$",
"group",
",",
"$",
"driver",
"=",
"null",
",",
"$",
"user",
"=",
"null",
")",
"{",
"$",
"user",
"=",
"$",
"user",
"?",
":",
"$",
"this",
"->",
"get_user_id",
"(",
")",
";",
"if",
"(",
"$",
"driver",
"===",
"null",
")",
"{",
"foreach",
"(",
"\\",
"Auth",
"::",
"group",
"(",
"true",
")",
"as",
"$",
"g",
")",
"{",
"if",
"(",
"$",
"g",
"->",
"member",
"(",
"$",
"group",
",",
"$",
"user",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}",
"return",
"\\",
"Auth",
"::",
"group",
"(",
"$",
"driver",
")",
"->",
"member",
"(",
"$",
"group",
",",
"$",
"user",
")",
";",
"}"
] |
Verify Group membership
@param mixed group identifier to check for membership
@param string group driver id or null to check all
@param array user identifier to check in form array(driver_id, user_id)
@return bool
|
[
"Verify",
"Group",
"membership"
] |
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
|
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/auth/classes/auth/login/driver.php#L126-L144
|
237,898
|
indigophp-archive/codeception-fuel-module
|
fuel/fuel/packages/auth/classes/auth/login/driver.php
|
Auth_Login_Driver.hash_password
|
public function hash_password($password)
{
return base64_encode($this->hasher()->pbkdf2($password, \Config::get('auth.salt'), \Config::get('auth.iterations', 10000), 32));
}
|
php
|
public function hash_password($password)
{
return base64_encode($this->hasher()->pbkdf2($password, \Config::get('auth.salt'), \Config::get('auth.iterations', 10000), 32));
}
|
[
"public",
"function",
"hash_password",
"(",
"$",
"password",
")",
"{",
"return",
"base64_encode",
"(",
"$",
"this",
"->",
"hasher",
"(",
")",
"->",
"pbkdf2",
"(",
"$",
"password",
",",
"\\",
"Config",
"::",
"get",
"(",
"'auth.salt'",
")",
",",
"\\",
"Config",
"::",
"get",
"(",
"'auth.iterations'",
",",
"10000",
")",
",",
"32",
")",
")",
";",
"}"
] |
Default password hash method
@param string
@return string
|
[
"Default",
"password",
"hash",
"method"
] |
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
|
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/auth/classes/auth/login/driver.php#L180-L183
|
237,899
|
indigophp-archive/codeception-fuel-module
|
fuel/fuel/packages/auth/classes/auth/login/driver.php
|
Auth_Login_Driver.hasher
|
public function hasher()
{
is_null($this->hasher) and $this->hasher = new \PHPSecLib\Crypt_Hash();
return $this->hasher;
}
|
php
|
public function hasher()
{
is_null($this->hasher) and $this->hasher = new \PHPSecLib\Crypt_Hash();
return $this->hasher;
}
|
[
"public",
"function",
"hasher",
"(",
")",
"{",
"is_null",
"(",
"$",
"this",
"->",
"hasher",
")",
"and",
"$",
"this",
"->",
"hasher",
"=",
"new",
"\\",
"PHPSecLib",
"\\",
"Crypt_Hash",
"(",
")",
";",
"return",
"$",
"this",
"->",
"hasher",
";",
"}"
] |
Returns the hash object and creates it if necessary
@return PHPSecLib\Crypt_Hash
|
[
"Returns",
"the",
"hash",
"object",
"and",
"creates",
"it",
"if",
"necessary"
] |
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
|
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/auth/classes/auth/login/driver.php#L190-L195
|
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.