repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
sequence
docstring
stringlengths
3
47.2k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
mpf-soft/admin-widgets
form/Field.php
Field.getLabel
public function getLabel() { if ($this->label) { return $this->translate($this->label); } $labels = array(); if ($this->form->model && is_string($this->form->model)) { $class = $this->form->model; $labels = $class::getLabels(); } elseif ($this->form->model && is_object($this->form->model)) { $class = get_class($this->form->model); $labels = $class::getLabels(); } if (isset($labels[$this->name])) { return $this->translate($labels[$this->name]); } return $this->translate(ucwords(str_replace('_', ' ', $this->name))); }
php
public function getLabel() { if ($this->label) { return $this->translate($this->label); } $labels = array(); if ($this->form->model && is_string($this->form->model)) { $class = $this->form->model; $labels = $class::getLabels(); } elseif ($this->form->model && is_object($this->form->model)) { $class = get_class($this->form->model); $labels = $class::getLabels(); } if (isset($labels[$this->name])) { return $this->translate($labels[$this->name]); } return $this->translate(ucwords(str_replace('_', ' ', $this->name))); }
[ "public", "function", "getLabel", "(", ")", "{", "if", "(", "$", "this", "->", "label", ")", "{", "return", "$", "this", "->", "translate", "(", "$", "this", "->", "label", ")", ";", "}", "$", "labels", "=", "array", "(", ")", ";", "if", "(", "$", "this", "->", "form", "->", "model", "&&", "is_string", "(", "$", "this", "->", "form", "->", "model", ")", ")", "{", "$", "class", "=", "$", "this", "->", "form", "->", "model", ";", "$", "labels", "=", "$", "class", "::", "getLabels", "(", ")", ";", "}", "elseif", "(", "$", "this", "->", "form", "->", "model", "&&", "is_object", "(", "$", "this", "->", "form", "->", "model", ")", ")", "{", "$", "class", "=", "get_class", "(", "$", "this", "->", "form", "->", "model", ")", ";", "$", "labels", "=", "$", "class", "::", "getLabels", "(", ")", ";", "}", "if", "(", "isset", "(", "$", "labels", "[", "$", "this", "->", "name", "]", ")", ")", "{", "return", "$", "this", "->", "translate", "(", "$", "labels", "[", "$", "this", "->", "name", "]", ")", ";", "}", "return", "$", "this", "->", "translate", "(", "ucwords", "(", "str_replace", "(", "'_'", ",", "' '", ",", "$", "this", "->", "name", ")", ")", ")", ";", "}" ]
Get label for current field. It will first try to get label attribute, if that's not specified it will check for a model and read the label from there, if it's still not found then it will generate one using the name. @return string
[ "Get", "label", "for", "current", "field", ".", "It", "will", "first", "try", "to", "get", "label", "attribute", "if", "that", "s", "not", "specified", "it", "will", "check", "for", "a", "model", "and", "read", "the", "label", "from", "there", "if", "it", "s", "still", "not", "found", "then", "it", "will", "generate", "one", "using", "the", "name", "." ]
92597f9a09d086664268d6b7e0111d5a5586d8c7
https://github.com/mpf-soft/admin-widgets/blob/92597f9a09d086664268d6b7e0111d5a5586d8c7/form/Field.php#L123-L139
train
mpf-soft/admin-widgets
form/Field.php
Field.display
public function display(Form $form) { if (!$this->visible){ return ""; } $this->form = $form; if (!isset($this->rowHtmlOptions['class'])) { $this->rowHtmlOptions['class'] = $this->rowClass; } else { $this->rowHtmlOptions['class'] .= ' ' . $this->rowClass; } if (!is_null($this->getError())){ $this->rowHtmlOptions['class'] .= ' has-error'; } return Html::get()->tag('div', $this->getContent(), $this->rowHtmlOptions); }
php
public function display(Form $form) { if (!$this->visible){ return ""; } $this->form = $form; if (!isset($this->rowHtmlOptions['class'])) { $this->rowHtmlOptions['class'] = $this->rowClass; } else { $this->rowHtmlOptions['class'] .= ' ' . $this->rowClass; } if (!is_null($this->getError())){ $this->rowHtmlOptions['class'] .= ' has-error'; } return Html::get()->tag('div', $this->getContent(), $this->rowHtmlOptions); }
[ "public", "function", "display", "(", "Form", "$", "form", ")", "{", "if", "(", "!", "$", "this", "->", "visible", ")", "{", "return", "\"\"", ";", "}", "$", "this", "->", "form", "=", "$", "form", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "rowHtmlOptions", "[", "'class'", "]", ")", ")", "{", "$", "this", "->", "rowHtmlOptions", "[", "'class'", "]", "=", "$", "this", "->", "rowClass", ";", "}", "else", "{", "$", "this", "->", "rowHtmlOptions", "[", "'class'", "]", ".=", "' '", ".", "$", "this", "->", "rowClass", ";", "}", "if", "(", "!", "is_null", "(", "$", "this", "->", "getError", "(", ")", ")", ")", "{", "$", "this", "->", "rowHtmlOptions", "[", "'class'", "]", ".=", "' has-error'", ";", "}", "return", "Html", "::", "get", "(", ")", "->", "tag", "(", "'div'", ",", "$", "this", "->", "getContent", "(", ")", ",", "$", "this", "->", "rowHtmlOptions", ")", ";", "}" ]
Get html content for current field. @param \mpf\widgets\form\Form $form @return string
[ "Get", "html", "content", "for", "current", "field", "." ]
92597f9a09d086664268d6b7e0111d5a5586d8c7
https://github.com/mpf-soft/admin-widgets/blob/92597f9a09d086664268d6b7e0111d5a5586d8c7/form/Field.php#L146-L160
train
mpf-soft/admin-widgets
form/Field.php
Field.getHTMLError
public function getHTMLError() { $error = $this->getError(); if (!is_null($error)) { if (is_string($error)) { $errorContent = Html::get()->tag('span', $error); } elseif (is_array($error)) { $errors = array(); foreach ($error as $message) { $errors[] = Html::get()->tag('li', $message); } $errorContent = Html::get()->tag('ul', implode("\n", $errors)); } else { $errorContent = ''; } return Html::get()->tag('div', $errorContent, array('class' => 'errors')); } return ''; }
php
public function getHTMLError() { $error = $this->getError(); if (!is_null($error)) { if (is_string($error)) { $errorContent = Html::get()->tag('span', $error); } elseif (is_array($error)) { $errors = array(); foreach ($error as $message) { $errors[] = Html::get()->tag('li', $message); } $errorContent = Html::get()->tag('ul', implode("\n", $errors)); } else { $errorContent = ''; } return Html::get()->tag('div', $errorContent, array('class' => 'errors')); } return ''; }
[ "public", "function", "getHTMLError", "(", ")", "{", "$", "error", "=", "$", "this", "->", "getError", "(", ")", ";", "if", "(", "!", "is_null", "(", "$", "error", ")", ")", "{", "if", "(", "is_string", "(", "$", "error", ")", ")", "{", "$", "errorContent", "=", "Html", "::", "get", "(", ")", "->", "tag", "(", "'span'", ",", "$", "error", ")", ";", "}", "elseif", "(", "is_array", "(", "$", "error", ")", ")", "{", "$", "errors", "=", "array", "(", ")", ";", "foreach", "(", "$", "error", "as", "$", "message", ")", "{", "$", "errors", "[", "]", "=", "Html", "::", "get", "(", ")", "->", "tag", "(", "'li'", ",", "$", "message", ")", ";", "}", "$", "errorContent", "=", "Html", "::", "get", "(", ")", "->", "tag", "(", "'ul'", ",", "implode", "(", "\"\\n\"", ",", "$", "errors", ")", ")", ";", "}", "else", "{", "$", "errorContent", "=", "''", ";", "}", "return", "Html", "::", "get", "(", ")", "->", "tag", "(", "'div'", ",", "$", "errorContent", ",", "array", "(", "'class'", "=>", "'errors'", ")", ")", ";", "}", "return", "''", ";", "}" ]
Get HTML code for errors. @return string
[ "Get", "HTML", "code", "for", "errors", "." ]
92597f9a09d086664268d6b7e0111d5a5586d8c7
https://github.com/mpf-soft/admin-widgets/blob/92597f9a09d086664268d6b7e0111d5a5586d8c7/form/Field.php#L173-L190
train
mpf-soft/admin-widgets
form/Field.php
Field.getError
public function getError() { if ($this->error) { return $this->translate($this->error); } if ($this->form->model && is_object($this->form->model) && $this->form->model->hasErrors($this->name)) { $errors = $this->form->model->getErrors($this->name); foreach ($errors as &$message) { $message = $this->translate($message); } return $errors; } return null; }
php
public function getError() { if ($this->error) { return $this->translate($this->error); } if ($this->form->model && is_object($this->form->model) && $this->form->model->hasErrors($this->name)) { $errors = $this->form->model->getErrors($this->name); foreach ($errors as &$message) { $message = $this->translate($message); } return $errors; } return null; }
[ "public", "function", "getError", "(", ")", "{", "if", "(", "$", "this", "->", "error", ")", "{", "return", "$", "this", "->", "translate", "(", "$", "this", "->", "error", ")", ";", "}", "if", "(", "$", "this", "->", "form", "->", "model", "&&", "is_object", "(", "$", "this", "->", "form", "->", "model", ")", "&&", "$", "this", "->", "form", "->", "model", "->", "hasErrors", "(", "$", "this", "->", "name", ")", ")", "{", "$", "errors", "=", "$", "this", "->", "form", "->", "model", "->", "getErrors", "(", "$", "this", "->", "name", ")", ";", "foreach", "(", "$", "errors", "as", "&", "$", "message", ")", "{", "$", "message", "=", "$", "this", "->", "translate", "(", "$", "message", ")", ";", "}", "return", "$", "errors", ";", "}", "return", "null", ";", "}" ]
Return a simple text message or a list of messages with errors for current field @return string|string[]|null
[ "Return", "a", "simple", "text", "message", "or", "a", "list", "of", "messages", "with", "errors", "for", "current", "field" ]
92597f9a09d086664268d6b7e0111d5a5586d8c7
https://github.com/mpf-soft/admin-widgets/blob/92597f9a09d086664268d6b7e0111d5a5586d8c7/form/Field.php#L202-L214
train
SlabPHP/database
src/Driver.php
Driver.query
public function query($sql, $binders = array(), $suggestedClass = null, $debug = false) { //By keeping track of the last binding location, we can skip //binders that are within bound data $minBinderLocation = 0; if (!is_array($binders)) $binders = array($binders); if (!empty($binders)) { foreach ($binders as &$bound) { $bound = $this->provider->escapeItem($bound); $bindingLocation = strpos($sql, static::DATABASE_BINDING_TOKEN, $minBinderLocation); if ($bindingLocation !== false) { $sql = substr_replace($sql, $bound, $bindingLocation, 1); $minBinderLocation = $bindingLocation + mb_strlen($bound) + 1; } } } $data = $this->provider->query($sql, $suggestedClass); if (!empty($debug)) { $output = new \stdClass(); $output->sql = $sql; $output->response = $data; $output->inputs = $binders; if (!empty($this->log)) { $this->log->notice('Debug Output', [$output]); } } return $data; }
php
public function query($sql, $binders = array(), $suggestedClass = null, $debug = false) { //By keeping track of the last binding location, we can skip //binders that are within bound data $minBinderLocation = 0; if (!is_array($binders)) $binders = array($binders); if (!empty($binders)) { foreach ($binders as &$bound) { $bound = $this->provider->escapeItem($bound); $bindingLocation = strpos($sql, static::DATABASE_BINDING_TOKEN, $minBinderLocation); if ($bindingLocation !== false) { $sql = substr_replace($sql, $bound, $bindingLocation, 1); $minBinderLocation = $bindingLocation + mb_strlen($bound) + 1; } } } $data = $this->provider->query($sql, $suggestedClass); if (!empty($debug)) { $output = new \stdClass(); $output->sql = $sql; $output->response = $data; $output->inputs = $binders; if (!empty($this->log)) { $this->log->notice('Debug Output', [$output]); } } return $data; }
[ "public", "function", "query", "(", "$", "sql", ",", "$", "binders", "=", "array", "(", ")", ",", "$", "suggestedClass", "=", "null", ",", "$", "debug", "=", "false", ")", "{", "//By keeping track of the last binding location, we can skip", "//binders that are within bound data", "$", "minBinderLocation", "=", "0", ";", "if", "(", "!", "is_array", "(", "$", "binders", ")", ")", "$", "binders", "=", "array", "(", "$", "binders", ")", ";", "if", "(", "!", "empty", "(", "$", "binders", ")", ")", "{", "foreach", "(", "$", "binders", "as", "&", "$", "bound", ")", "{", "$", "bound", "=", "$", "this", "->", "provider", "->", "escapeItem", "(", "$", "bound", ")", ";", "$", "bindingLocation", "=", "strpos", "(", "$", "sql", ",", "static", "::", "DATABASE_BINDING_TOKEN", ",", "$", "minBinderLocation", ")", ";", "if", "(", "$", "bindingLocation", "!==", "false", ")", "{", "$", "sql", "=", "substr_replace", "(", "$", "sql", ",", "$", "bound", ",", "$", "bindingLocation", ",", "1", ")", ";", "$", "minBinderLocation", "=", "$", "bindingLocation", "+", "mb_strlen", "(", "$", "bound", ")", "+", "1", ";", "}", "}", "}", "$", "data", "=", "$", "this", "->", "provider", "->", "query", "(", "$", "sql", ",", "$", "suggestedClass", ")", ";", "if", "(", "!", "empty", "(", "$", "debug", ")", ")", "{", "$", "output", "=", "new", "\\", "stdClass", "(", ")", ";", "$", "output", "->", "sql", "=", "$", "sql", ";", "$", "output", "->", "response", "=", "$", "data", ";", "$", "output", "->", "inputs", "=", "$", "binders", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "log", ")", ")", "{", "$", "this", "->", "log", "->", "notice", "(", "'Debug Output'", ",", "[", "$", "output", "]", ")", ";", "}", "}", "return", "$", "data", ";", "}" ]
Run an SQL query @param string $sql @param string[] $binders @param string $suggestedClass @return \Slab\Components\Database\ResponseInterface
[ "Run", "an", "SQL", "query" ]
d77c38f2260429c6e054633eb0daf3f755c988a9
https://github.com/SlabPHP/database/blob/d77c38f2260429c6e054633eb0daf3f755c988a9/src/Driver.php#L72-L109
train
OxfordInfoLabs/kinikit-core
src/Util/Serialisation/Serialisable.php
Serialisable.__getSerialisablePropertyValue
public function __getSerialisablePropertyValue($propertyName) { $map = $this->__getSerialisablePropertyMap(); if (array_key_exists($propertyName, $map)) { return $map [$propertyName]; } elseif (array_key_exists(substr(strtoupper($propertyName), 0, 1) . substr($propertyName, 1), $map)) { return $map [substr(strtoupper($propertyName), 0, 1) . substr($propertyName, 1)]; } else { throw new PropertyNotReadableException (get_class($this), $propertyName); } }
php
public function __getSerialisablePropertyValue($propertyName) { $map = $this->__getSerialisablePropertyMap(); if (array_key_exists($propertyName, $map)) { return $map [$propertyName]; } elseif (array_key_exists(substr(strtoupper($propertyName), 0, 1) . substr($propertyName, 1), $map)) { return $map [substr(strtoupper($propertyName), 0, 1) . substr($propertyName, 1)]; } else { throw new PropertyNotReadableException (get_class($this), $propertyName); } }
[ "public", "function", "__getSerialisablePropertyValue", "(", "$", "propertyName", ")", "{", "$", "map", "=", "$", "this", "->", "__getSerialisablePropertyMap", "(", ")", ";", "if", "(", "array_key_exists", "(", "$", "propertyName", ",", "$", "map", ")", ")", "{", "return", "$", "map", "[", "$", "propertyName", "]", ";", "}", "elseif", "(", "array_key_exists", "(", "substr", "(", "strtoupper", "(", "$", "propertyName", ")", ",", "0", ",", "1", ")", ".", "substr", "(", "$", "propertyName", ",", "1", ")", ",", "$", "map", ")", ")", "{", "return", "$", "map", "[", "substr", "(", "strtoupper", "(", "$", "propertyName", ")", ",", "0", ",", "1", ")", ".", "substr", "(", "$", "propertyName", ",", "1", ")", "]", ";", "}", "else", "{", "throw", "new", "PropertyNotReadableException", "(", "get_class", "(", "$", "this", ")", ",", "$", "propertyName", ")", ";", "}", "}" ]
Get a serialisable property value by name if it exists. Throw an exception if it doesn't exist. @param string $propertyName
[ "Get", "a", "serialisable", "property", "value", "by", "name", "if", "it", "exists", ".", "Throw", "an", "exception", "if", "it", "doesn", "t", "exist", "." ]
edc1b2e6ffabd595c4c7d322279b3dd1e59ef359
https://github.com/OxfordInfoLabs/kinikit-core/blob/edc1b2e6ffabd595c4c7d322279b3dd1e59ef359/src/Util/Serialisation/Serialisable.php#L32-L41
train
OxfordInfoLabs/kinikit-core
src/Util/Serialisation/Serialisable.php
Serialisable.__getSerialisablePropertyMap
public function __getSerialisablePropertyMap() { $propertyAccessors = $this->__findSerialisablePropertyAccessors(); $propertyMap = array(); foreach ($propertyAccessors as $accessorSet) { // If a get accessor exists, add it to the map if (isset ($accessorSet ["get"])) { $accessor = $accessorSet ["get"]; if ($accessor instanceof \ReflectionMethod) { // Check that this is not qualified with a @no-serialise tag if (strpos($accessor->getDocComment(), "@no-serialise")) continue; $propertyName = substr($accessor->getName(), 3); $propertyName = CodeUtils::instance()->normalisePropertyName($propertyName); if ($accessor->isPublic()) $propertyMap [$propertyName] = $accessor->invoke($this); else if ($accessor->isProtected()) { $methodName = "get" . $propertyName; $propertyMap [$propertyName] = $this->$methodName (); } } else if ($accessor instanceof \ReflectionProperty) { if (strpos($accessor->getDocComment(), "@no-serialise")) continue; $propertyName = $accessor->getName(); if ($accessor->isPublic()) $propertyMap [$propertyName] = $accessor->getValue($this); else if ($accessor->isProtected()) { $propertyName = $accessor->getName(); $propertyMap [$propertyName] = $this->$propertyName; } } } } return $propertyMap; }
php
public function __getSerialisablePropertyMap() { $propertyAccessors = $this->__findSerialisablePropertyAccessors(); $propertyMap = array(); foreach ($propertyAccessors as $accessorSet) { // If a get accessor exists, add it to the map if (isset ($accessorSet ["get"])) { $accessor = $accessorSet ["get"]; if ($accessor instanceof \ReflectionMethod) { // Check that this is not qualified with a @no-serialise tag if (strpos($accessor->getDocComment(), "@no-serialise")) continue; $propertyName = substr($accessor->getName(), 3); $propertyName = CodeUtils::instance()->normalisePropertyName($propertyName); if ($accessor->isPublic()) $propertyMap [$propertyName] = $accessor->invoke($this); else if ($accessor->isProtected()) { $methodName = "get" . $propertyName; $propertyMap [$propertyName] = $this->$methodName (); } } else if ($accessor instanceof \ReflectionProperty) { if (strpos($accessor->getDocComment(), "@no-serialise")) continue; $propertyName = $accessor->getName(); if ($accessor->isPublic()) $propertyMap [$propertyName] = $accessor->getValue($this); else if ($accessor->isProtected()) { $propertyName = $accessor->getName(); $propertyMap [$propertyName] = $this->$propertyName; } } } } return $propertyMap; }
[ "public", "function", "__getSerialisablePropertyMap", "(", ")", "{", "$", "propertyAccessors", "=", "$", "this", "->", "__findSerialisablePropertyAccessors", "(", ")", ";", "$", "propertyMap", "=", "array", "(", ")", ";", "foreach", "(", "$", "propertyAccessors", "as", "$", "accessorSet", ")", "{", "// If a get accessor exists, add it to the map", "if", "(", "isset", "(", "$", "accessorSet", "[", "\"get\"", "]", ")", ")", "{", "$", "accessor", "=", "$", "accessorSet", "[", "\"get\"", "]", ";", "if", "(", "$", "accessor", "instanceof", "\\", "ReflectionMethod", ")", "{", "// Check that this is not qualified with a @no-serialise tag", "if", "(", "strpos", "(", "$", "accessor", "->", "getDocComment", "(", ")", ",", "\"@no-serialise\"", ")", ")", "continue", ";", "$", "propertyName", "=", "substr", "(", "$", "accessor", "->", "getName", "(", ")", ",", "3", ")", ";", "$", "propertyName", "=", "CodeUtils", "::", "instance", "(", ")", "->", "normalisePropertyName", "(", "$", "propertyName", ")", ";", "if", "(", "$", "accessor", "->", "isPublic", "(", ")", ")", "$", "propertyMap", "[", "$", "propertyName", "]", "=", "$", "accessor", "->", "invoke", "(", "$", "this", ")", ";", "else", "if", "(", "$", "accessor", "->", "isProtected", "(", ")", ")", "{", "$", "methodName", "=", "\"get\"", ".", "$", "propertyName", ";", "$", "propertyMap", "[", "$", "propertyName", "]", "=", "$", "this", "->", "$", "methodName", "(", ")", ";", "}", "}", "else", "if", "(", "$", "accessor", "instanceof", "\\", "ReflectionProperty", ")", "{", "if", "(", "strpos", "(", "$", "accessor", "->", "getDocComment", "(", ")", ",", "\"@no-serialise\"", ")", ")", "continue", ";", "$", "propertyName", "=", "$", "accessor", "->", "getName", "(", ")", ";", "if", "(", "$", "accessor", "->", "isPublic", "(", ")", ")", "$", "propertyMap", "[", "$", "propertyName", "]", "=", "$", "accessor", "->", "getValue", "(", "$", "this", ")", ";", "else", "if", "(", "$", "accessor", "->", "isProtected", "(", ")", ")", "{", "$", "propertyName", "=", "$", "accessor", "->", "getName", "(", ")", ";", "$", "propertyMap", "[", "$", "propertyName", "]", "=", "$", "this", "->", "$", "propertyName", ";", "}", "}", "}", "}", "return", "$", "propertyMap", ";", "}" ]
Get an associative array of all of the serialisable properties defined on this class.
[ "Get", "an", "associative", "array", "of", "all", "of", "the", "serialisable", "properties", "defined", "on", "this", "class", "." ]
edc1b2e6ffabd595c4c7d322279b3dd1e59ef359
https://github.com/OxfordInfoLabs/kinikit-core/blob/edc1b2e6ffabd595c4c7d322279b3dd1e59ef359/src/Util/Serialisation/Serialisable.php#L56-L98
train
OxfordInfoLabs/kinikit-core
src/Util/Serialisation/Serialisable.php
Serialisable.__setSerialisablePropertyMap
public function __setSerialisablePropertyMap($propertyMap, $ignoreNoneWritableProperties = false) { $propertyAccessors = $this->__findSerialisablePropertyAccessors(); $noneWritables = array(); foreach ($propertyMap as $inputPropertyName => $propertyValue) { $propertyName = strtolower($inputPropertyName); // If we get a match, call the appropriate function if (isset ($propertyAccessors [$propertyName]) && isset ($propertyAccessors [$propertyName] ["set"])) { $accessor = $propertyAccessors [$propertyName] ["set"]; if ($accessor instanceof \ReflectionMethod) { if ($accessor->isPublic()) $accessor->invoke($this, $propertyValue); else if ($accessor->isProtected()) { $methodName = "set" . $propertyName; $this->$methodName ($propertyValue); } else { if (!$ignoreNoneWritableProperties) throw new PropertyNotWritableException (get_class($this), $propertyName); } } else if ($accessor instanceof \ReflectionProperty) { if ($accessor->isPublic()) $accessor->setValue($this, $propertyValue); else if ($accessor->isProtected()) { $propertyName = $accessor->getName(); $this->$propertyName = $propertyValue; } else { if (!$ignoreNoneWritableProperties) throw new PropertyNotWritableException (get_class($this), $propertyName); } } } else { // If none writable properties ignored, instead add them to an array for return for processing // higher if required, else throw exceptions. if ($ignoreNoneWritableProperties) { $noneWritables [$inputPropertyName] = $propertyValue; } else { throw new PropertyNotWritableException (get_class($this), $propertyName); } } } return $noneWritables; }
php
public function __setSerialisablePropertyMap($propertyMap, $ignoreNoneWritableProperties = false) { $propertyAccessors = $this->__findSerialisablePropertyAccessors(); $noneWritables = array(); foreach ($propertyMap as $inputPropertyName => $propertyValue) { $propertyName = strtolower($inputPropertyName); // If we get a match, call the appropriate function if (isset ($propertyAccessors [$propertyName]) && isset ($propertyAccessors [$propertyName] ["set"])) { $accessor = $propertyAccessors [$propertyName] ["set"]; if ($accessor instanceof \ReflectionMethod) { if ($accessor->isPublic()) $accessor->invoke($this, $propertyValue); else if ($accessor->isProtected()) { $methodName = "set" . $propertyName; $this->$methodName ($propertyValue); } else { if (!$ignoreNoneWritableProperties) throw new PropertyNotWritableException (get_class($this), $propertyName); } } else if ($accessor instanceof \ReflectionProperty) { if ($accessor->isPublic()) $accessor->setValue($this, $propertyValue); else if ($accessor->isProtected()) { $propertyName = $accessor->getName(); $this->$propertyName = $propertyValue; } else { if (!$ignoreNoneWritableProperties) throw new PropertyNotWritableException (get_class($this), $propertyName); } } } else { // If none writable properties ignored, instead add them to an array for return for processing // higher if required, else throw exceptions. if ($ignoreNoneWritableProperties) { $noneWritables [$inputPropertyName] = $propertyValue; } else { throw new PropertyNotWritableException (get_class($this), $propertyName); } } } return $noneWritables; }
[ "public", "function", "__setSerialisablePropertyMap", "(", "$", "propertyMap", ",", "$", "ignoreNoneWritableProperties", "=", "false", ")", "{", "$", "propertyAccessors", "=", "$", "this", "->", "__findSerialisablePropertyAccessors", "(", ")", ";", "$", "noneWritables", "=", "array", "(", ")", ";", "foreach", "(", "$", "propertyMap", "as", "$", "inputPropertyName", "=>", "$", "propertyValue", ")", "{", "$", "propertyName", "=", "strtolower", "(", "$", "inputPropertyName", ")", ";", "// If we get a match, call the appropriate function", "if", "(", "isset", "(", "$", "propertyAccessors", "[", "$", "propertyName", "]", ")", "&&", "isset", "(", "$", "propertyAccessors", "[", "$", "propertyName", "]", "[", "\"set\"", "]", ")", ")", "{", "$", "accessor", "=", "$", "propertyAccessors", "[", "$", "propertyName", "]", "[", "\"set\"", "]", ";", "if", "(", "$", "accessor", "instanceof", "\\", "ReflectionMethod", ")", "{", "if", "(", "$", "accessor", "->", "isPublic", "(", ")", ")", "$", "accessor", "->", "invoke", "(", "$", "this", ",", "$", "propertyValue", ")", ";", "else", "if", "(", "$", "accessor", "->", "isProtected", "(", ")", ")", "{", "$", "methodName", "=", "\"set\"", ".", "$", "propertyName", ";", "$", "this", "->", "$", "methodName", "(", "$", "propertyValue", ")", ";", "}", "else", "{", "if", "(", "!", "$", "ignoreNoneWritableProperties", ")", "throw", "new", "PropertyNotWritableException", "(", "get_class", "(", "$", "this", ")", ",", "$", "propertyName", ")", ";", "}", "}", "else", "if", "(", "$", "accessor", "instanceof", "\\", "ReflectionProperty", ")", "{", "if", "(", "$", "accessor", "->", "isPublic", "(", ")", ")", "$", "accessor", "->", "setValue", "(", "$", "this", ",", "$", "propertyValue", ")", ";", "else", "if", "(", "$", "accessor", "->", "isProtected", "(", ")", ")", "{", "$", "propertyName", "=", "$", "accessor", "->", "getName", "(", ")", ";", "$", "this", "->", "$", "propertyName", "=", "$", "propertyValue", ";", "}", "else", "{", "if", "(", "!", "$", "ignoreNoneWritableProperties", ")", "throw", "new", "PropertyNotWritableException", "(", "get_class", "(", "$", "this", ")", ",", "$", "propertyName", ")", ";", "}", "}", "}", "else", "{", "// If none writable properties ignored, instead add them to an array for return for processing", "// higher if required, else throw exceptions.", "if", "(", "$", "ignoreNoneWritableProperties", ")", "{", "$", "noneWritables", "[", "$", "inputPropertyName", "]", "=", "$", "propertyValue", ";", "}", "else", "{", "throw", "new", "PropertyNotWritableException", "(", "get_class", "(", "$", "this", ")", ",", "$", "propertyName", ")", ";", "}", "}", "}", "return", "$", "noneWritables", ";", "}" ]
Set an associative array of serialisable properties
[ "Set", "an", "associative", "array", "of", "serialisable", "properties" ]
edc1b2e6ffabd595c4c7d322279b3dd1e59ef359
https://github.com/OxfordInfoLabs/kinikit-core/blob/edc1b2e6ffabd595c4c7d322279b3dd1e59ef359/src/Util/Serialisation/Serialisable.php#L104-L148
train
OxfordInfoLabs/kinikit-core
src/Util/Serialisation/Serialisable.php
Serialisable.__findSerialisablePropertyAccessors
public function __findSerialisablePropertyAccessors() { // Grab the class name first. $className = get_class($this); // If no accessor map has been previously cached for this class type, cache it now. if (!isset (self::$__accessorMaps [$className])) { $reflectionClass = new \ReflectionClass ($className); // Create the accessors array for storing all possible accessors. $accessors = array(); // Loop through all methods, checking for public get and set accessors first. $methods = $reflectionClass->getMethods(); foreach ($methods as $method) { if ($method->isStatic()) continue; if ((substr($method->getName(), 0, 3) == "get") && ($method->getNumberOfRequiredParameters() == 0)) { $propertyName = strtolower(substr($method->getName(), 3)); if (!isset ($accessors [$propertyName])) { $accessors [$propertyName] = array(); } $accessors [$propertyName] ["get"] = $method; } else if (substr($method->getName(), 0, 3) == "set") { $propertyName = strtolower(substr($method->getName(), 3)); if (!isset ($accessors [$propertyName])) { $accessors [$propertyName] = array(); } $accessors [$propertyName] ["set"] = $method; } } // Now loop through all properties, checking for any public / protected ones $properties = $reflectionClass->getProperties(); foreach ($properties as $property) { if ($property->isStatic()) continue; $propertyName = strtolower($property->getName()); if (!isset ($accessors [$propertyName])) { $accessors [$propertyName] = array(); } if (!isset ($accessors [$propertyName] ["get"])) $accessors [$propertyName] ["get"] = $property; if (!isset ($accessors [$propertyName] ["set"])) $accessors [$propertyName] ["set"] = $property; } self::$__accessorMaps [$className] = $accessors; } return self::$__accessorMaps [$className]; }
php
public function __findSerialisablePropertyAccessors() { // Grab the class name first. $className = get_class($this); // If no accessor map has been previously cached for this class type, cache it now. if (!isset (self::$__accessorMaps [$className])) { $reflectionClass = new \ReflectionClass ($className); // Create the accessors array for storing all possible accessors. $accessors = array(); // Loop through all methods, checking for public get and set accessors first. $methods = $reflectionClass->getMethods(); foreach ($methods as $method) { if ($method->isStatic()) continue; if ((substr($method->getName(), 0, 3) == "get") && ($method->getNumberOfRequiredParameters() == 0)) { $propertyName = strtolower(substr($method->getName(), 3)); if (!isset ($accessors [$propertyName])) { $accessors [$propertyName] = array(); } $accessors [$propertyName] ["get"] = $method; } else if (substr($method->getName(), 0, 3) == "set") { $propertyName = strtolower(substr($method->getName(), 3)); if (!isset ($accessors [$propertyName])) { $accessors [$propertyName] = array(); } $accessors [$propertyName] ["set"] = $method; } } // Now loop through all properties, checking for any public / protected ones $properties = $reflectionClass->getProperties(); foreach ($properties as $property) { if ($property->isStatic()) continue; $propertyName = strtolower($property->getName()); if (!isset ($accessors [$propertyName])) { $accessors [$propertyName] = array(); } if (!isset ($accessors [$propertyName] ["get"])) $accessors [$propertyName] ["get"] = $property; if (!isset ($accessors [$propertyName] ["set"])) $accessors [$propertyName] ["set"] = $property; } self::$__accessorMaps [$className] = $accessors; } return self::$__accessorMaps [$className]; }
[ "public", "function", "__findSerialisablePropertyAccessors", "(", ")", "{", "// Grab the class name first.", "$", "className", "=", "get_class", "(", "$", "this", ")", ";", "// If no accessor map has been previously cached for this class type, cache it now.", "if", "(", "!", "isset", "(", "self", "::", "$", "__accessorMaps", "[", "$", "className", "]", ")", ")", "{", "$", "reflectionClass", "=", "new", "\\", "ReflectionClass", "(", "$", "className", ")", ";", "// Create the accessors array for storing all possible accessors.", "$", "accessors", "=", "array", "(", ")", ";", "// Loop through all methods, checking for public get and set accessors first.", "$", "methods", "=", "$", "reflectionClass", "->", "getMethods", "(", ")", ";", "foreach", "(", "$", "methods", "as", "$", "method", ")", "{", "if", "(", "$", "method", "->", "isStatic", "(", ")", ")", "continue", ";", "if", "(", "(", "substr", "(", "$", "method", "->", "getName", "(", ")", ",", "0", ",", "3", ")", "==", "\"get\"", ")", "&&", "(", "$", "method", "->", "getNumberOfRequiredParameters", "(", ")", "==", "0", ")", ")", "{", "$", "propertyName", "=", "strtolower", "(", "substr", "(", "$", "method", "->", "getName", "(", ")", ",", "3", ")", ")", ";", "if", "(", "!", "isset", "(", "$", "accessors", "[", "$", "propertyName", "]", ")", ")", "{", "$", "accessors", "[", "$", "propertyName", "]", "=", "array", "(", ")", ";", "}", "$", "accessors", "[", "$", "propertyName", "]", "[", "\"get\"", "]", "=", "$", "method", ";", "}", "else", "if", "(", "substr", "(", "$", "method", "->", "getName", "(", ")", ",", "0", ",", "3", ")", "==", "\"set\"", ")", "{", "$", "propertyName", "=", "strtolower", "(", "substr", "(", "$", "method", "->", "getName", "(", ")", ",", "3", ")", ")", ";", "if", "(", "!", "isset", "(", "$", "accessors", "[", "$", "propertyName", "]", ")", ")", "{", "$", "accessors", "[", "$", "propertyName", "]", "=", "array", "(", ")", ";", "}", "$", "accessors", "[", "$", "propertyName", "]", "[", "\"set\"", "]", "=", "$", "method", ";", "}", "}", "// Now loop through all properties, checking for any public / protected ones", "$", "properties", "=", "$", "reflectionClass", "->", "getProperties", "(", ")", ";", "foreach", "(", "$", "properties", "as", "$", "property", ")", "{", "if", "(", "$", "property", "->", "isStatic", "(", ")", ")", "continue", ";", "$", "propertyName", "=", "strtolower", "(", "$", "property", "->", "getName", "(", ")", ")", ";", "if", "(", "!", "isset", "(", "$", "accessors", "[", "$", "propertyName", "]", ")", ")", "{", "$", "accessors", "[", "$", "propertyName", "]", "=", "array", "(", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "accessors", "[", "$", "propertyName", "]", "[", "\"get\"", "]", ")", ")", "$", "accessors", "[", "$", "propertyName", "]", "[", "\"get\"", "]", "=", "$", "property", ";", "if", "(", "!", "isset", "(", "$", "accessors", "[", "$", "propertyName", "]", "[", "\"set\"", "]", ")", ")", "$", "accessors", "[", "$", "propertyName", "]", "[", "\"set\"", "]", "=", "$", "property", ";", "}", "self", "::", "$", "__accessorMaps", "[", "$", "className", "]", "=", "$", "accessors", ";", "}", "return", "self", "::", "$", "__accessorMaps", "[", "$", "className", "]", ";", "}" ]
Find all serialisable property objects, return a map of accessor objects keyed in by GET and SET.
[ "Find", "all", "serialisable", "property", "objects", "return", "a", "map", "of", "accessor", "objects", "keyed", "in", "by", "GET", "and", "SET", "." ]
edc1b2e6ffabd595c4c7d322279b3dd1e59ef359
https://github.com/OxfordInfoLabs/kinikit-core/blob/edc1b2e6ffabd595c4c7d322279b3dd1e59ef359/src/Util/Serialisation/Serialisable.php#L154-L214
train
AnonymPHP/Anonym-Cookie
src/Anonym/Components/Cookie.php
Cookie.forever
public function forever( $name = '', $value = '', $path = '/', $domain = null, $secure = false, $httpOnly = false ) { $this->set($name, $value, 2628000, $path, $domain, $secure, $httpOnly); return $this; }
php
public function forever( $name = '', $value = '', $path = '/', $domain = null, $secure = false, $httpOnly = false ) { $this->set($name, $value, 2628000, $path, $domain, $secure, $httpOnly); return $this; }
[ "public", "function", "forever", "(", "$", "name", "=", "''", ",", "$", "value", "=", "''", ",", "$", "path", "=", "'/'", ",", "$", "domain", "=", "null", ",", "$", "secure", "=", "false", ",", "$", "httpOnly", "=", "false", ")", "{", "$", "this", "->", "set", "(", "$", "name", ",", "$", "value", ",", "2628000", ",", "$", "path", ",", "$", "domain", ",", "$", "secure", ",", "$", "httpOnly", ")", ";", "return", "$", "this", ";", "}" ]
this cookie life very long time @param string $name @param string $value @param string $path @param null $domain @param bool $secure @param bool $httpOnly @return $this
[ "this", "cookie", "life", "very", "long", "time" ]
7e02403f76fab42355f02326c5589d3fca271e3b
https://github.com/AnonymPHP/Anonym-Cookie/blob/7e02403f76fab42355f02326c5589d3fca271e3b/src/Anonym/Components/Cookie.php#L174-L184
train
togucms/FrontendBundle
Data/Formatter.php
Formatter.format
public function format($entities) { $data = array( 'models' => array(), 'images' => array(), 'links' => array() ); if(! is_array($entities)) { $entities = array($entities->getId() => $entities); } foreach ($entities as $entity) { if($entity instanceof \Application\Togu\ApplicationModelsBundle\Document\Page) { foreach ($entity->getAllSections() as $section) { $entities[$section->getId()] = $section; } } } foreach ($entities as $entity) { $this->processor->getAllObjects($entity, $data['models']); $this->processor->getFieldValuesOfType($entity, 'image', $data['images']); $this->processor->getFieldValuesOfType($entity, 'link', $data['links']); } $this->convertLinks($data['links']); return $data; }
php
public function format($entities) { $data = array( 'models' => array(), 'images' => array(), 'links' => array() ); if(! is_array($entities)) { $entities = array($entities->getId() => $entities); } foreach ($entities as $entity) { if($entity instanceof \Application\Togu\ApplicationModelsBundle\Document\Page) { foreach ($entity->getAllSections() as $section) { $entities[$section->getId()] = $section; } } } foreach ($entities as $entity) { $this->processor->getAllObjects($entity, $data['models']); $this->processor->getFieldValuesOfType($entity, 'image', $data['images']); $this->processor->getFieldValuesOfType($entity, 'link', $data['links']); } $this->convertLinks($data['links']); return $data; }
[ "public", "function", "format", "(", "$", "entities", ")", "{", "$", "data", "=", "array", "(", "'models'", "=>", "array", "(", ")", ",", "'images'", "=>", "array", "(", ")", ",", "'links'", "=>", "array", "(", ")", ")", ";", "if", "(", "!", "is_array", "(", "$", "entities", ")", ")", "{", "$", "entities", "=", "array", "(", "$", "entities", "->", "getId", "(", ")", "=>", "$", "entities", ")", ";", "}", "foreach", "(", "$", "entities", "as", "$", "entity", ")", "{", "if", "(", "$", "entity", "instanceof", "\\", "Application", "\\", "Togu", "\\", "ApplicationModelsBundle", "\\", "Document", "\\", "Page", ")", "{", "foreach", "(", "$", "entity", "->", "getAllSections", "(", ")", "as", "$", "section", ")", "{", "$", "entities", "[", "$", "section", "->", "getId", "(", ")", "]", "=", "$", "section", ";", "}", "}", "}", "foreach", "(", "$", "entities", "as", "$", "entity", ")", "{", "$", "this", "->", "processor", "->", "getAllObjects", "(", "$", "entity", ",", "$", "data", "[", "'models'", "]", ")", ";", "$", "this", "->", "processor", "->", "getFieldValuesOfType", "(", "$", "entity", ",", "'image'", ",", "$", "data", "[", "'images'", "]", ")", ";", "$", "this", "->", "processor", "->", "getFieldValuesOfType", "(", "$", "entity", ",", "'link'", ",", "$", "data", "[", "'links'", "]", ")", ";", "}", "$", "this", "->", "convertLinks", "(", "$", "data", "[", "'links'", "]", ")", ";", "return", "$", "data", ";", "}" ]
Prepares the data to be serialized @param mixed $entity The entity to serialize @return string The serialized data
[ "Prepares", "the", "data", "to", "be", "serialized" ]
fd165aca0fb6498ce85b39c1ff536cc1bd8ba285
https://github.com/togucms/FrontendBundle/blob/fd165aca0fb6498ce85b39c1ff536cc1bd8ba285/Data/Formatter.php#L55-L83
train
Wedeto/HTTP
src/Forms/AddNonceToForm.php
AddNonceToForm.register
public function register() { $this->prepare_hook = $this->prepare_hook ?: Hook::subscribe('Wedeto.HTTP.Forms.Form.prepare', [$this, 'hookPrepareForm']); $this->validate_hook = $this->validate_hook ?: Hook::subscribe('Wedeto.HTTP.Forms.Form.isValid', [$this, 'hookIsValid']); }
php
public function register() { $this->prepare_hook = $this->prepare_hook ?: Hook::subscribe('Wedeto.HTTP.Forms.Form.prepare', [$this, 'hookPrepareForm']); $this->validate_hook = $this->validate_hook ?: Hook::subscribe('Wedeto.HTTP.Forms.Form.isValid', [$this, 'hookIsValid']); }
[ "public", "function", "register", "(", ")", "{", "$", "this", "->", "prepare_hook", "=", "$", "this", "->", "prepare_hook", "?", ":", "Hook", "::", "subscribe", "(", "'Wedeto.HTTP.Forms.Form.prepare'", ",", "[", "$", "this", ",", "'hookPrepareForm'", "]", ")", ";", "$", "this", "->", "validate_hook", "=", "$", "this", "->", "validate_hook", "?", ":", "Hook", "::", "subscribe", "(", "'Wedeto.HTTP.Forms.Form.isValid'", ",", "[", "$", "this", ",", "'hookIsValid'", "]", ")", ";", "}" ]
Subscribe to two hooks, prepare and isValid
[ "Subscribe", "to", "two", "hooks", "prepare", "and", "isValid" ]
7318eff1b81a3c103c4263466d09b7f3593b70b9
https://github.com/Wedeto/HTTP/blob/7318eff1b81a3c103c4263466d09b7f3593b70b9/src/Forms/AddNonceToForm.php#L56-L60
train
Wedeto/HTTP
src/Forms/AddNonceToForm.php
AddNonceToForm.unregister
public function unregister() { if ($this->prepare_hook) { Hook::unsubscribe('Wedeto.HTTP.Forms.Form.prepare', $this->prepare_hook); $this->prepare_hook = null; } if ($this->validate_hook) { Hook::unsubscribe('Wedeto.HTTP.Forms.Form.isValid', $this->validate_hook); $this->validate_hook = null; } }
php
public function unregister() { if ($this->prepare_hook) { Hook::unsubscribe('Wedeto.HTTP.Forms.Form.prepare', $this->prepare_hook); $this->prepare_hook = null; } if ($this->validate_hook) { Hook::unsubscribe('Wedeto.HTTP.Forms.Form.isValid', $this->validate_hook); $this->validate_hook = null; } }
[ "public", "function", "unregister", "(", ")", "{", "if", "(", "$", "this", "->", "prepare_hook", ")", "{", "Hook", "::", "unsubscribe", "(", "'Wedeto.HTTP.Forms.Form.prepare'", ",", "$", "this", "->", "prepare_hook", ")", ";", "$", "this", "->", "prepare_hook", "=", "null", ";", "}", "if", "(", "$", "this", "->", "validate_hook", ")", "{", "Hook", "::", "unsubscribe", "(", "'Wedeto.HTTP.Forms.Form.isValid'", ",", "$", "this", "->", "validate_hook", ")", ";", "$", "this", "->", "validate_hook", "=", "null", ";", "}", "}" ]
Unsubscribe from the two hooks
[ "Unsubscribe", "from", "the", "two", "hooks" ]
7318eff1b81a3c103c4263466d09b7f3593b70b9
https://github.com/Wedeto/HTTP/blob/7318eff1b81a3c103c4263466d09b7f3593b70b9/src/Forms/AddNonceToForm.php#L65-L78
train
Wedeto/HTTP
src/Forms/AddNonceToForm.php
AddNonceToForm.hookPrepareForm
public function hookPrepareForm(Dictionary $params) { $session = $params['session']; $form = $params['form']; if ($session !== null) { $nonce_name = Nonce::getParameterName(); if (!isset($form[$nonce_name])) { $context = []; $nonce = Nonce::getNonce($form->getName(), $session, $context); $form->add(new FormField($nonce_name, Type::STRING, "hidden", $nonce)); } } }
php
public function hookPrepareForm(Dictionary $params) { $session = $params['session']; $form = $params['form']; if ($session !== null) { $nonce_name = Nonce::getParameterName(); if (!isset($form[$nonce_name])) { $context = []; $nonce = Nonce::getNonce($form->getName(), $session, $context); $form->add(new FormField($nonce_name, Type::STRING, "hidden", $nonce)); } } }
[ "public", "function", "hookPrepareForm", "(", "Dictionary", "$", "params", ")", "{", "$", "session", "=", "$", "params", "[", "'session'", "]", ";", "$", "form", "=", "$", "params", "[", "'form'", "]", ";", "if", "(", "$", "session", "!==", "null", ")", "{", "$", "nonce_name", "=", "Nonce", "::", "getParameterName", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "form", "[", "$", "nonce_name", "]", ")", ")", "{", "$", "context", "=", "[", "]", ";", "$", "nonce", "=", "Nonce", "::", "getNonce", "(", "$", "form", "->", "getName", "(", ")", ",", "$", "session", ",", "$", "context", ")", ";", "$", "form", "->", "add", "(", "new", "FormField", "(", "$", "nonce_name", ",", "Type", "::", "STRING", ",", "\"hidden\"", ",", "$", "nonce", ")", ")", ";", "}", "}", "}" ]
The hook called when the form is being prepared. Is used to add the nonce field to the form.
[ "The", "hook", "called", "when", "the", "form", "is", "being", "prepared", ".", "Is", "used", "to", "add", "the", "nonce", "field", "to", "the", "form", "." ]
7318eff1b81a3c103c4263466d09b7f3593b70b9
https://github.com/Wedeto/HTTP/blob/7318eff1b81a3c103c4263466d09b7f3593b70b9/src/Forms/AddNonceToForm.php#L84-L98
train
Wedeto/HTTP
src/Forms/AddNonceToForm.php
AddNonceToForm.hookIsValid
public function hookIsValid(Dictionary $params) { // Validate nonce $form = $params['form']; $request = $params['request']; $arguments = $params['arguments']; $result = Nonce::validateNonce($form->getName(), $request->session, $arguments); $nonce_name = Nonce::getParameterName(); if ($result === null) { $params['errors'] = [$nonce_name => [[ 'msg' => 'Nonce was not submitted for form {form}', 'context' => ['form' => $form->getName()] ]]]; $params['valid'] = false; } elseif ($result === false) { $params['errors'] = [$nonce_name => [[ 'msg' => 'Nonce was invalid for form {form}', 'context' => ['form' => $form->getName()] ]]]; $params['valid'] = false; } }
php
public function hookIsValid(Dictionary $params) { // Validate nonce $form = $params['form']; $request = $params['request']; $arguments = $params['arguments']; $result = Nonce::validateNonce($form->getName(), $request->session, $arguments); $nonce_name = Nonce::getParameterName(); if ($result === null) { $params['errors'] = [$nonce_name => [[ 'msg' => 'Nonce was not submitted for form {form}', 'context' => ['form' => $form->getName()] ]]]; $params['valid'] = false; } elseif ($result === false) { $params['errors'] = [$nonce_name => [[ 'msg' => 'Nonce was invalid for form {form}', 'context' => ['form' => $form->getName()] ]]]; $params['valid'] = false; } }
[ "public", "function", "hookIsValid", "(", "Dictionary", "$", "params", ")", "{", "// Validate nonce", "$", "form", "=", "$", "params", "[", "'form'", "]", ";", "$", "request", "=", "$", "params", "[", "'request'", "]", ";", "$", "arguments", "=", "$", "params", "[", "'arguments'", "]", ";", "$", "result", "=", "Nonce", "::", "validateNonce", "(", "$", "form", "->", "getName", "(", ")", ",", "$", "request", "->", "session", ",", "$", "arguments", ")", ";", "$", "nonce_name", "=", "Nonce", "::", "getParameterName", "(", ")", ";", "if", "(", "$", "result", "===", "null", ")", "{", "$", "params", "[", "'errors'", "]", "=", "[", "$", "nonce_name", "=>", "[", "[", "'msg'", "=>", "'Nonce was not submitted for form {form}'", ",", "'context'", "=>", "[", "'form'", "=>", "$", "form", "->", "getName", "(", ")", "]", "]", "]", "]", ";", "$", "params", "[", "'valid'", "]", "=", "false", ";", "}", "elseif", "(", "$", "result", "===", "false", ")", "{", "$", "params", "[", "'errors'", "]", "=", "[", "$", "nonce_name", "=>", "[", "[", "'msg'", "=>", "'Nonce was invalid for form {form}'", ",", "'context'", "=>", "[", "'form'", "=>", "$", "form", "->", "getName", "(", ")", "]", "]", "]", "]", ";", "$", "params", "[", "'valid'", "]", "=", "false", ";", "}", "}" ]
The hook called when the form is validated. Is used to validate that the received nonce is valid.
[ "The", "hook", "called", "when", "the", "form", "is", "validated", ".", "Is", "used", "to", "validate", "that", "the", "received", "nonce", "is", "valid", "." ]
7318eff1b81a3c103c4263466d09b7f3593b70b9
https://github.com/Wedeto/HTTP/blob/7318eff1b81a3c103c4263466d09b7f3593b70b9/src/Forms/AddNonceToForm.php#L104-L129
train
FlorianWolters/PHP-Component-Util-Reflection
src/main/php/ReflectionUtils.php
ReflectionUtils.createNewInstanceWithoutConstructor
public static function createNewInstanceWithoutConstructor( $className, array $arguments = [] ) { $reflectedClass = new ReflectionClass($className); $newInstance = $reflectedClass->newInstanceWithoutConstructor(); $reflectedConstructor = $reflectedClass->getConstructor(); if (null !== $reflectedConstructor) { $reflectedConstructor->setAccessible(true); $reflectedConstructor->invokeArgs($newInstance, $arguments); } return $newInstance; }
php
public static function createNewInstanceWithoutConstructor( $className, array $arguments = [] ) { $reflectedClass = new ReflectionClass($className); $newInstance = $reflectedClass->newInstanceWithoutConstructor(); $reflectedConstructor = $reflectedClass->getConstructor(); if (null !== $reflectedConstructor) { $reflectedConstructor->setAccessible(true); $reflectedConstructor->invokeArgs($newInstance, $arguments); } return $newInstance; }
[ "public", "static", "function", "createNewInstanceWithoutConstructor", "(", "$", "className", ",", "array", "$", "arguments", "=", "[", "]", ")", "{", "$", "reflectedClass", "=", "new", "ReflectionClass", "(", "$", "className", ")", ";", "$", "newInstance", "=", "$", "reflectedClass", "->", "newInstanceWithoutConstructor", "(", ")", ";", "$", "reflectedConstructor", "=", "$", "reflectedClass", "->", "getConstructor", "(", ")", ";", "if", "(", "null", "!==", "$", "reflectedConstructor", ")", "{", "$", "reflectedConstructor", "->", "setAccessible", "(", "true", ")", ";", "$", "reflectedConstructor", "->", "invokeArgs", "(", "$", "newInstance", ",", "$", "arguments", ")", ";", "}", "return", "$", "newInstance", ";", "}" ]
Creates a new instance of the class with the specified class name without invoking its constructor. The constructor is set accessible if it is not declared with `public` visibility. The method `createNewInstanceWithoutConstructor` accepts a variable number of arguments which are passed to the constructor of the class. @param string $className The name of the class to reflect. @param mixed[] $arguments The optional arguments to be passed to the constructor. @return object A new instance of the class to reflect. @throws ReflectionException If the class with the specified class name does not exist.
[ "Creates", "a", "new", "instance", "of", "the", "class", "with", "the", "specified", "class", "name", "without", "invoking", "its", "constructor", "." ]
b905c0cd04fc9232da2456fd9eb09752680188dd
https://github.com/FlorianWolters/PHP-Component-Util-Reflection/blob/b905c0cd04fc9232da2456fd9eb09752680188dd/src/main/php/ReflectionUtils.php#L67-L81
train
FlorianWolters/PHP-Component-Util-Reflection
src/main/php/ReflectionUtils.php
ReflectionUtils.invokeMethod
public static function invokeMethod( $object, $methodName, array $arguments = [] ) { $reflectedObject = new ReflectionObject($object); $reflectedMethod = $reflectedObject->getMethod($methodName); $reflectedMethod->setAccessible(true); $reflectedMethod->invokeArgs($object, $arguments); }
php
public static function invokeMethod( $object, $methodName, array $arguments = [] ) { $reflectedObject = new ReflectionObject($object); $reflectedMethod = $reflectedObject->getMethod($methodName); $reflectedMethod->setAccessible(true); $reflectedMethod->invokeArgs($object, $arguments); }
[ "public", "static", "function", "invokeMethod", "(", "$", "object", ",", "$", "methodName", ",", "array", "$", "arguments", "=", "[", "]", ")", "{", "$", "reflectedObject", "=", "new", "ReflectionObject", "(", "$", "object", ")", ";", "$", "reflectedMethod", "=", "$", "reflectedObject", "->", "getMethod", "(", "$", "methodName", ")", ";", "$", "reflectedMethod", "->", "setAccessible", "(", "true", ")", ";", "$", "reflectedMethod", "->", "invokeArgs", "(", "$", "object", ",", "$", "arguments", ")", ";", "}" ]
Invokes the specified method on the specified object. The method `invokeMethod` accepts a variable number of arguments which are passed to the method of the object. @param object $object The object on which to invoke the method. @param strin $methodName The name of the method to invoke. @param mixed[] $arguments The optional arguments to be passed to the method. @return void
[ "Invokes", "the", "specified", "method", "on", "the", "specified", "object", "." ]
b905c0cd04fc9232da2456fd9eb09752680188dd
https://github.com/FlorianWolters/PHP-Component-Util-Reflection/blob/b905c0cd04fc9232da2456fd9eb09752680188dd/src/main/php/ReflectionUtils.php#L96-L105
train
ivopetkov/server-requests-bearframework-addon
classes/ServerRequests.php
ServerRequests.add
public function add(string $name, callable $callback): \IvoPetkov\BearFrameworkAddons\ServerRequests { $this->callbacks[$name] = $callback; return $this; }
php
public function add(string $name, callable $callback): \IvoPetkov\BearFrameworkAddons\ServerRequests { $this->callbacks[$name] = $callback; return $this; }
[ "public", "function", "add", "(", "string", "$", "name", ",", "callable", "$", "callback", ")", ":", "\\", "IvoPetkov", "\\", "BearFrameworkAddons", "\\", "ServerRequests", "{", "$", "this", "->", "callbacks", "[", "$", "name", "]", "=", "$", "callback", ";", "return", "$", "this", ";", "}" ]
Register a named callback @param string $name @param callable $callback @return IvoPetkov\BearFrameworkAddons\ServerRequests Returns a reference to the object itself.
[ "Register", "a", "named", "callback" ]
66d6a594557e988dc458d569c7e81ea6af60a58a
https://github.com/ivopetkov/server-requests-bearframework-addon/blob/66d6a594557e988dc458d569c7e81ea6af60a58a/classes/ServerRequests.php#L32-L36
train
ivopetkov/server-requests-bearframework-addon
classes/ServerRequests.php
ServerRequests.execute
public function execute(string $name, array $data, \BearFramework\App\Response $response): string { if (isset($this->callbacks[$name])) { return (string) call_user_func($this->callbacks[$name], $data, $response); } return ''; }
php
public function execute(string $name, array $data, \BearFramework\App\Response $response): string { if (isset($this->callbacks[$name])) { return (string) call_user_func($this->callbacks[$name], $data, $response); } return ''; }
[ "public", "function", "execute", "(", "string", "$", "name", ",", "array", "$", "data", ",", "\\", "BearFramework", "\\", "App", "\\", "Response", "$", "response", ")", ":", "string", "{", "if", "(", "isset", "(", "$", "this", "->", "callbacks", "[", "$", "name", "]", ")", ")", "{", "return", "(", "string", ")", "call_user_func", "(", "$", "this", "->", "callbacks", "[", "$", "name", "]", ",", "$", "data", ",", "$", "response", ")", ";", "}", "return", "''", ";", "}" ]
Executes the callback for the name specified @param string $name The name of the callback @param array $data The data that will be passed to the callback @param \BearFramework\App\Response $response The response object that will be passed to the callback @return string Returns the callback result
[ "Executes", "the", "callback", "for", "the", "name", "specified" ]
66d6a594557e988dc458d569c7e81ea6af60a58a
https://github.com/ivopetkov/server-requests-bearframework-addon/blob/66d6a594557e988dc458d569c7e81ea6af60a58a/classes/ServerRequests.php#L57-L63
train
Palmabit-IT/library
src/Palmabit/Library/Form/FormModel.php
FormModel.process
public function process(array $input) { try { $success = $this->v->validate($input); } catch(ValidationException $e) { $this->setErrorsAndThrowException(); } if( ! $success) { $this->setErrorsAndThrowException(); } Event::fire("form.processing", array($input)); return $this->callRepository($input); }
php
public function process(array $input) { try { $success = $this->v->validate($input); } catch(ValidationException $e) { $this->setErrorsAndThrowException(); } if( ! $success) { $this->setErrorsAndThrowException(); } Event::fire("form.processing", array($input)); return $this->callRepository($input); }
[ "public", "function", "process", "(", "array", "$", "input", ")", "{", "try", "{", "$", "success", "=", "$", "this", "->", "v", "->", "validate", "(", "$", "input", ")", ";", "}", "catch", "(", "ValidationException", "$", "e", ")", "{", "$", "this", "->", "setErrorsAndThrowException", "(", ")", ";", "}", "if", "(", "!", "$", "success", ")", "{", "$", "this", "->", "setErrorsAndThrowException", "(", ")", ";", "}", "Event", "::", "fire", "(", "\"form.processing\"", ",", "array", "(", "$", "input", ")", ")", ";", "return", "$", "this", "->", "callRepository", "(", "$", "input", ")", ";", "}" ]
Processa l'input e chiama create o opdate a seconda @param array $input @throws \Palmabit\Library\Exceptions\PalmabitExceptionsInterface
[ "Processa", "l", "input", "e", "chiama", "create", "o", "opdate", "a", "seconda" ]
ec49a3c333eb4e94d9610a0f58d82c9ea1ade4b9
https://github.com/Palmabit-IT/library/blob/ec49a3c333eb4e94d9610a0f58d82c9ea1ade4b9/src/Palmabit/Library/Form/FormModel.php#L52-L69
train
eureka-framework/component-response
src/Response/Html/Html.php
Html.renderContent
public function renderContent() { if (is_object($this->content) && !method_exists($this->content, '__toString')) { throw new \LogicException('Cannot render content: it is an object without __toString method!'); } if (is_array($this->content)) { throw new \LogicException('Cannot render content: it is an array!'); } return (string) $this->content; }
php
public function renderContent() { if (is_object($this->content) && !method_exists($this->content, '__toString')) { throw new \LogicException('Cannot render content: it is an object without __toString method!'); } if (is_array($this->content)) { throw new \LogicException('Cannot render content: it is an array!'); } return (string) $this->content; }
[ "public", "function", "renderContent", "(", ")", "{", "if", "(", "is_object", "(", "$", "this", "->", "content", ")", "&&", "!", "method_exists", "(", "$", "this", "->", "content", ",", "'__toString'", ")", ")", "{", "throw", "new", "\\", "LogicException", "(", "'Cannot render content: it is an object without __toString method!'", ")", ";", "}", "if", "(", "is_array", "(", "$", "this", "->", "content", ")", ")", "{", "throw", "new", "\\", "LogicException", "(", "'Cannot render content: it is an array!'", ")", ";", "}", "return", "(", "string", ")", "$", "this", "->", "content", ";", "}" ]
Render content. @return string @throws \LogicException
[ "Render", "content", "." ]
f34aea3a0aa67b88c5e7f8a3b86af29c550fa99a
https://github.com/eureka-framework/component-response/blob/f34aea3a0aa67b88c5e7f8a3b86af29c550fa99a/src/Response/Html/Html.php#L36-L47
train
ScaraMVC/Framework
src/Scara/Html/BaseBuilder.php
BaseBuilder.attributes
protected function attributes($attributes = []) { $ar = []; foreach ($attributes as $key => $value) { $element = $this->attribute($key, $value); if (!is_null($element)) { $ar[] = $element; } } return count($ar) > 0 ? ' '.implode(' ', $ar) : ''; }
php
protected function attributes($attributes = []) { $ar = []; foreach ($attributes as $key => $value) { $element = $this->attribute($key, $value); if (!is_null($element)) { $ar[] = $element; } } return count($ar) > 0 ? ' '.implode(' ', $ar) : ''; }
[ "protected", "function", "attributes", "(", "$", "attributes", "=", "[", "]", ")", "{", "$", "ar", "=", "[", "]", ";", "foreach", "(", "$", "attributes", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "element", "=", "$", "this", "->", "attribute", "(", "$", "key", ",", "$", "value", ")", ";", "if", "(", "!", "is_null", "(", "$", "element", ")", ")", "{", "$", "ar", "[", "]", "=", "$", "element", ";", "}", "}", "return", "count", "(", "$", "ar", ")", ">", "0", "?", "' '", ".", "implode", "(", "' '", ",", "$", "ar", ")", ":", "''", ";", "}" ]
Cycles through given attributes and sets them for the element. @param array $attributes - The elements given options (attributes) @return string
[ "Cycles", "through", "given", "attributes", "and", "sets", "them", "for", "the", "element", "." ]
199b08b45fadf5dae14ac4732af03b36e15bbef2
https://github.com/ScaraMVC/Framework/blob/199b08b45fadf5dae14ac4732af03b36e15bbef2/src/Scara/Html/BaseBuilder.php#L17-L29
train
ScaraMVC/Framework
src/Scara/Html/BaseBuilder.php
BaseBuilder.attribute
protected function attribute($key, $value) { if (is_numeric($key)) { $key = $value; } if (!is_null($value)) { return $key.'="'.$value.'"'; } }
php
protected function attribute($key, $value) { if (is_numeric($key)) { $key = $value; } if (!is_null($value)) { return $key.'="'.$value.'"'; } }
[ "protected", "function", "attribute", "(", "$", "key", ",", "$", "value", ")", "{", "if", "(", "is_numeric", "(", "$", "key", ")", ")", "{", "$", "key", "=", "$", "value", ";", "}", "if", "(", "!", "is_null", "(", "$", "value", ")", ")", "{", "return", "$", "key", ".", "'=\"'", ".", "$", "value", ".", "'\"'", ";", "}", "}" ]
Creates the attribute string. @param string $key - The attribute's key @param string $value - The $key's value @return string
[ "Creates", "the", "attribute", "string", "." ]
199b08b45fadf5dae14ac4732af03b36e15bbef2
https://github.com/ScaraMVC/Framework/blob/199b08b45fadf5dae14ac4732af03b36e15bbef2/src/Scara/Html/BaseBuilder.php#L39-L48
train
ScaraMVC/Framework
src/Scara/Html/BaseBuilder.php
BaseBuilder.obfuscate
public function obfuscate($value) { $safe = ''; foreach (str_split($value) as $letter) { if (ord($letter) > 128) { return $letter; } switch (rand(1, 3)) { case 1: $safe .= '&#'.ord($letter).';'; break; case 2: $safe .= '&#x'.dechex(ord($letter)).';'; break; case 3: $safe .= $letter; } } return $safe; }
php
public function obfuscate($value) { $safe = ''; foreach (str_split($value) as $letter) { if (ord($letter) > 128) { return $letter; } switch (rand(1, 3)) { case 1: $safe .= '&#'.ord($letter).';'; break; case 2: $safe .= '&#x'.dechex(ord($letter)).';'; break; case 3: $safe .= $letter; } } return $safe; }
[ "public", "function", "obfuscate", "(", "$", "value", ")", "{", "$", "safe", "=", "''", ";", "foreach", "(", "str_split", "(", "$", "value", ")", "as", "$", "letter", ")", "{", "if", "(", "ord", "(", "$", "letter", ")", ">", "128", ")", "{", "return", "$", "letter", ";", "}", "switch", "(", "rand", "(", "1", ",", "3", ")", ")", "{", "case", "1", ":", "$", "safe", ".=", "'&#'", ".", "ord", "(", "$", "letter", ")", ".", "';'", ";", "break", ";", "case", "2", ":", "$", "safe", ".=", "'&#x'", ".", "dechex", "(", "ord", "(", "$", "letter", ")", ")", ".", "';'", ";", "break", ";", "case", "3", ":", "$", "safe", ".=", "$", "letter", ";", "}", "}", "return", "$", "safe", ";", "}" ]
Obfuscates a string. @param string $value - The string to obfuscate @return string
[ "Obfuscates", "a", "string", "." ]
199b08b45fadf5dae14ac4732af03b36e15bbef2
https://github.com/ScaraMVC/Framework/blob/199b08b45fadf5dae14ac4732af03b36e15bbef2/src/Scara/Html/BaseBuilder.php#L82-L104
train
togucms/MediaBundle
Controller/MediaController.php
MediaController.postMediaAction
public function postMediaAction($provider, Request $request) { $pool = $this->get("sonata.media.pool"); $manager = $this->get("sonata.media.manager.media"); $formFactory = $this->get('form.factory'); try { $mediaProvider = $pool->getProvider($provider); } catch (\RuntimeException $ex) { throw new NotFoundHttpException($ex->getMessage(), $ex); } $medium = $manager->create(); $medium->setProviderName($provider); $form = $formFactory->createNamed(null, 'sonata_media_api_form_media', $medium, array( 'provider_name' => $mediaProvider->getName(), // 'csrf_protection' => false )); $form->bind($request); if ($form->isValid()) { try { $medium = $form->getData(); $manager->save($medium); } catch (DBALException $e) { return $this->handleView( View::create(array('errors'=>array($e->getMessage())), 400) ); } return $this->handleView( View::create($this->formatMedia($medium), 200, array('Location'=>$this->generateUrl( "_togu_media_rest_get_media", array('id'=>$medium->getId()), true )))->setSerializationContext($this->getSerializerContext(array('sonata_api_read'))) ); } else { return $this->handleView( View::create(array('errors'=>$form->getErrors()), 400) ); } }
php
public function postMediaAction($provider, Request $request) { $pool = $this->get("sonata.media.pool"); $manager = $this->get("sonata.media.manager.media"); $formFactory = $this->get('form.factory'); try { $mediaProvider = $pool->getProvider($provider); } catch (\RuntimeException $ex) { throw new NotFoundHttpException($ex->getMessage(), $ex); } $medium = $manager->create(); $medium->setProviderName($provider); $form = $formFactory->createNamed(null, 'sonata_media_api_form_media', $medium, array( 'provider_name' => $mediaProvider->getName(), // 'csrf_protection' => false )); $form->bind($request); if ($form->isValid()) { try { $medium = $form->getData(); $manager->save($medium); } catch (DBALException $e) { return $this->handleView( View::create(array('errors'=>array($e->getMessage())), 400) ); } return $this->handleView( View::create($this->formatMedia($medium), 200, array('Location'=>$this->generateUrl( "_togu_media_rest_get_media", array('id'=>$medium->getId()), true )))->setSerializationContext($this->getSerializerContext(array('sonata_api_read'))) ); } else { return $this->handleView( View::create(array('errors'=>$form->getErrors()), 400) ); } }
[ "public", "function", "postMediaAction", "(", "$", "provider", ",", "Request", "$", "request", ")", "{", "$", "pool", "=", "$", "this", "->", "get", "(", "\"sonata.media.pool\"", ")", ";", "$", "manager", "=", "$", "this", "->", "get", "(", "\"sonata.media.manager.media\"", ")", ";", "$", "formFactory", "=", "$", "this", "->", "get", "(", "'form.factory'", ")", ";", "try", "{", "$", "mediaProvider", "=", "$", "pool", "->", "getProvider", "(", "$", "provider", ")", ";", "}", "catch", "(", "\\", "RuntimeException", "$", "ex", ")", "{", "throw", "new", "NotFoundHttpException", "(", "$", "ex", "->", "getMessage", "(", ")", ",", "$", "ex", ")", ";", "}", "$", "medium", "=", "$", "manager", "->", "create", "(", ")", ";", "$", "medium", "->", "setProviderName", "(", "$", "provider", ")", ";", "$", "form", "=", "$", "formFactory", "->", "createNamed", "(", "null", ",", "'sonata_media_api_form_media'", ",", "$", "medium", ",", "array", "(", "'provider_name'", "=>", "$", "mediaProvider", "->", "getName", "(", ")", ",", "// \t\t\t'csrf_protection' => false", ")", ")", ";", "$", "form", "->", "bind", "(", "$", "request", ")", ";", "if", "(", "$", "form", "->", "isValid", "(", ")", ")", "{", "try", "{", "$", "medium", "=", "$", "form", "->", "getData", "(", ")", ";", "$", "manager", "->", "save", "(", "$", "medium", ")", ";", "}", "catch", "(", "DBALException", "$", "e", ")", "{", "return", "$", "this", "->", "handleView", "(", "View", "::", "create", "(", "array", "(", "'errors'", "=>", "array", "(", "$", "e", "->", "getMessage", "(", ")", ")", ")", ",", "400", ")", ")", ";", "}", "return", "$", "this", "->", "handleView", "(", "View", "::", "create", "(", "$", "this", "->", "formatMedia", "(", "$", "medium", ")", ",", "200", ",", "array", "(", "'Location'", "=>", "$", "this", "->", "generateUrl", "(", "\"_togu_media_rest_get_media\"", ",", "array", "(", "'id'", "=>", "$", "medium", "->", "getId", "(", ")", ")", ",", "true", ")", ")", ")", "->", "setSerializationContext", "(", "$", "this", "->", "getSerializerContext", "(", "array", "(", "'sonata_api_read'", ")", ")", ")", ")", ";", "}", "else", "{", "return", "$", "this", "->", "handleView", "(", "View", "::", "create", "(", "array", "(", "'errors'", "=>", "$", "form", "->", "getErrors", "(", ")", ")", ",", "400", ")", ")", ";", "}", "}" ]
Create a new media @Route(requirements={"provider"="[A-Za-z0-9.]*"}) @return \Symfony\Component\HttpFoundation\Response
[ "Create", "a", "new", "media" ]
42065d5fa419654540a52ae8f0047708eac9930b
https://github.com/togucms/MediaBundle/blob/42065d5fa419654540a52ae8f0047708eac9930b/Controller/MediaController.php#L66-L106
train
Krinkle/toollabs-base
src/BaseTool.php
BaseTool.addOut
public function addOut( $str, $wrapTag = 0, $attributes = array() ) { if ( is_string( $str ) ) { if ( is_string( $wrapTag ) ) { $str = Html::element( $wrapTag, $attributes, $str ); } $this->mainOutput['body'] .= $str; return true; } else { return false; } }
php
public function addOut( $str, $wrapTag = 0, $attributes = array() ) { if ( is_string( $str ) ) { if ( is_string( $wrapTag ) ) { $str = Html::element( $wrapTag, $attributes, $str ); } $this->mainOutput['body'] .= $str; return true; } else { return false; } }
[ "public", "function", "addOut", "(", "$", "str", ",", "$", "wrapTag", "=", "0", ",", "$", "attributes", "=", "array", "(", ")", ")", "{", "if", "(", "is_string", "(", "$", "str", ")", ")", "{", "if", "(", "is_string", "(", "$", "wrapTag", ")", ")", "{", "$", "str", "=", "Html", "::", "element", "(", "$", "wrapTag", ",", "$", "attributes", ",", "$", "str", ")", ";", "}", "$", "this", "->", "mainOutput", "[", "'body'", "]", ".=", "$", "str", ";", "return", "true", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
Add a string to the output memory @param $str string String to be added to the memory @param $wrapTag string (optional) Name of the tag to wrap the string in. If this is used the contents of $str will be html-escaped! @param $attributes string (optional) When using a wrapTag these attributes will be applied as well. Both the keys and the values will be escaped, don't do so they should be passed raw to addOut() @return boolean Returns true on success, false on failure
[ "Add", "a", "string", "to", "the", "output", "memory" ]
784150ca58f4b48cc89534fd6142c54b4f138cd2
https://github.com/Krinkle/toollabs-base/blob/784150ca58f4b48cc89534fd6142c54b4f138cd2/src/BaseTool.php#L234-L244
train
theomessin/ts-framework
src/Node/Server.php
Server.clientKick
public function clientKick($clid, $reasonid = Teamspeak::KICK_CHANNEL, $reasonmsg = null) { $this->clientListReset(); $this->execute("clientkick", array("clid" => $clid, "reasonid" => $reasonid, "reasonmsg" => $reasonmsg)); }
php
public function clientKick($clid, $reasonid = Teamspeak::KICK_CHANNEL, $reasonmsg = null) { $this->clientListReset(); $this->execute("clientkick", array("clid" => $clid, "reasonid" => $reasonid, "reasonmsg" => $reasonmsg)); }
[ "public", "function", "clientKick", "(", "$", "clid", ",", "$", "reasonid", "=", "Teamspeak", "::", "KICK_CHANNEL", ",", "$", "reasonmsg", "=", "null", ")", "{", "$", "this", "->", "clientListReset", "(", ")", ";", "$", "this", "->", "execute", "(", "\"clientkick\"", ",", "array", "(", "\"clid\"", "=>", "$", "clid", ",", "\"reasonid\"", "=>", "$", "reasonid", ",", "\"reasonmsg\"", "=>", "$", "reasonmsg", ")", ")", ";", "}" ]
Kicks one or more clients from their currently joined channel or from the server. @param integer $clid @param integer $reasonid @param string $reasonmsg @return void
[ "Kicks", "one", "or", "more", "clients", "from", "their", "currently", "joined", "channel", "or", "from", "the", "server", "." ]
d60e36553241db05cb05ef19e749866cc977437c
https://github.com/theomessin/ts-framework/blob/d60e36553241db05cb05ef19e749866cc977437c/src/Node/Server.php#L911-L916
train
theomessin/ts-framework
src/Node/Server.php
Server.channelGroupGetByName
public function channelGroupGetByName($name, $type = Teamspeak::GROUP_DBTYPE_REGULAR) { foreach ($this->channelGroupList() as $group) { if ($group["name"] == $name && $group["type"] == $type) { return $group; } } throw new Ts3Exception("invalid groupID", 0xA00); }
php
public function channelGroupGetByName($name, $type = Teamspeak::GROUP_DBTYPE_REGULAR) { foreach ($this->channelGroupList() as $group) { if ($group["name"] == $name && $group["type"] == $type) { return $group; } } throw new Ts3Exception("invalid groupID", 0xA00); }
[ "public", "function", "channelGroupGetByName", "(", "$", "name", ",", "$", "type", "=", "Teamspeak", "::", "GROUP_DBTYPE_REGULAR", ")", "{", "foreach", "(", "$", "this", "->", "channelGroupList", "(", ")", "as", "$", "group", ")", "{", "if", "(", "$", "group", "[", "\"name\"", "]", "==", "$", "name", "&&", "$", "group", "[", "\"type\"", "]", "==", "$", "type", ")", "{", "return", "$", "group", ";", "}", "}", "throw", "new", "Ts3Exception", "(", "\"invalid groupID\"", ",", "0xA00", ")", ";", "}" ]
Returns the Channelgroup object matching the given name. @param string $name @param integer $type @throws Ts3Exception @return Channelgroup
[ "Returns", "the", "Channelgroup", "object", "matching", "the", "given", "name", "." ]
d60e36553241db05cb05ef19e749866cc977437c
https://github.com/theomessin/ts-framework/blob/d60e36553241db05cb05ef19e749866cc977437c/src/Node/Server.php#L1507-L1516
train
theomessin/ts-framework
src/Node/Server.php
Server.snapshotCreate
public function snapshotCreate($mode = Teamspeak::SNAPSHOT_STRING) { $snapshot = $this->request("serversnapshotcreate")->toString(false); switch ($mode) { case Teamspeak::SNAPSHOT_BASE64: return $snapshot->toBase64(); break; case Teamspeak::SNAPSHOT_HEXDEC: return $snapshot->toHex(); break; default: return (string)$snapshot; break; } }
php
public function snapshotCreate($mode = Teamspeak::SNAPSHOT_STRING) { $snapshot = $this->request("serversnapshotcreate")->toString(false); switch ($mode) { case Teamspeak::SNAPSHOT_BASE64: return $snapshot->toBase64(); break; case Teamspeak::SNAPSHOT_HEXDEC: return $snapshot->toHex(); break; default: return (string)$snapshot; break; } }
[ "public", "function", "snapshotCreate", "(", "$", "mode", "=", "Teamspeak", "::", "SNAPSHOT_STRING", ")", "{", "$", "snapshot", "=", "$", "this", "->", "request", "(", "\"serversnapshotcreate\"", ")", "->", "toString", "(", "false", ")", ";", "switch", "(", "$", "mode", ")", "{", "case", "Teamspeak", "::", "SNAPSHOT_BASE64", ":", "return", "$", "snapshot", "->", "toBase64", "(", ")", ";", "break", ";", "case", "Teamspeak", "::", "SNAPSHOT_HEXDEC", ":", "return", "$", "snapshot", "->", "toHex", "(", ")", ";", "break", ";", "default", ":", "return", "(", "string", ")", "$", "snapshot", ";", "break", ";", "}", "}" ]
Creates and returns snapshot data for the selected virtual server. @param string $mode @return string
[ "Creates", "and", "returns", "snapshot", "data", "for", "the", "selected", "virtual", "server", "." ]
d60e36553241db05cb05ef19e749866cc977437c
https://github.com/theomessin/ts-framework/blob/d60e36553241db05cb05ef19e749866cc977437c/src/Node/Server.php#L1880-L1897
train
kaiohken1982/NeobazaarMailerModule
src/Mailer/Mail/ClassifiedActivation.php
ClassifiedActivation.checkData
public function checkData(array $data) { $keys = array('to', 'fullname', 'title', 'activationLink', 'siteurl', 'cdnurl', 'siteName'); foreach($keys as $key) { if(!array_key_exists($key, $data)) { throw new \Exception('Key not in data'); } } return $this; }
php
public function checkData(array $data) { $keys = array('to', 'fullname', 'title', 'activationLink', 'siteurl', 'cdnurl', 'siteName'); foreach($keys as $key) { if(!array_key_exists($key, $data)) { throw new \Exception('Key not in data'); } } return $this; }
[ "public", "function", "checkData", "(", "array", "$", "data", ")", "{", "$", "keys", "=", "array", "(", "'to'", ",", "'fullname'", ",", "'title'", ",", "'activationLink'", ",", "'siteurl'", ",", "'cdnurl'", ",", "'siteName'", ")", ";", "foreach", "(", "$", "keys", "as", "$", "key", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "key", ",", "$", "data", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'Key not in data'", ")", ";", "}", "}", "return", "$", "this", ";", "}" ]
Checks if data contains neede keye @param array $data @throws \Exception @return \Mailer\Mail\ClassifiedAnswer
[ "Checks", "if", "data", "contains", "neede", "keye" ]
0afc66196a0a392ecb4f052f483f2b5ff606bd8f
https://github.com/kaiohken1982/NeobazaarMailerModule/blob/0afc66196a0a392ecb4f052f483f2b5ff606bd8f/src/Mailer/Mail/ClassifiedActivation.php#L45-L56
train
FuzeWorks/Core
src/FuzeWorks/LoggerTracyBridge.php
LoggerTracyBridge.register
public static function register() { $class = new self(); Events::addListener(array($class, 'screenLogEventListener'), 'screenLogEvent', EventPriority::NORMAL); $bar = Debugger::getBar(); $bar->addPanel($class); }
php
public static function register() { $class = new self(); Events::addListener(array($class, 'screenLogEventListener'), 'screenLogEvent', EventPriority::NORMAL); $bar = Debugger::getBar(); $bar->addPanel($class); }
[ "public", "static", "function", "register", "(", ")", "{", "$", "class", "=", "new", "self", "(", ")", ";", "Events", "::", "addListener", "(", "array", "(", "$", "class", ",", "'screenLogEventListener'", ")", ",", "'screenLogEvent'", ",", "EventPriority", "::", "NORMAL", ")", ";", "$", "bar", "=", "Debugger", "::", "getBar", "(", ")", ";", "$", "bar", "->", "addPanel", "(", "$", "class", ")", ";", "}" ]
Register the bar and register the event which will block the screen log
[ "Register", "the", "bar", "and", "register", "the", "event", "which", "will", "block", "the", "screen", "log" ]
051c64fdaa3a648174cbd54557d05ad553dd826b
https://github.com/FuzeWorks/Core/blob/051c64fdaa3a648174cbd54557d05ad553dd826b/src/FuzeWorks/LoggerTracyBridge.php#L53-L59
train
net-tools/core
src/Helpers/SecurityHelper.php
SecurityHelper.cryptoJsAesDecrypt
static function cryptoJsAesDecrypt($passphrase, $jsonString){ $jsondata = json_decode($jsonString, true); try { $salt = hex2bin($jsondata["s"]); $iv = hex2bin($jsondata["iv"]); } catch(\Exception $e) { return null; } $ct = base64_decode($jsondata["ct"]); $concatedPassphrase = $passphrase.$salt; $md5 = array(); $md5[0] = md5($concatedPassphrase, true); $result = $md5[0]; for ($i = 1; $i < 3; $i++) { $md5[$i] = md5($md5[$i - 1].$concatedPassphrase, true); $result .= $md5[$i]; } $key = substr($result, 0, 32); $data = openssl_decrypt($ct, 'aes-256-cbc', $key, true, $iv); return json_decode($data, true); }
php
static function cryptoJsAesDecrypt($passphrase, $jsonString){ $jsondata = json_decode($jsonString, true); try { $salt = hex2bin($jsondata["s"]); $iv = hex2bin($jsondata["iv"]); } catch(\Exception $e) { return null; } $ct = base64_decode($jsondata["ct"]); $concatedPassphrase = $passphrase.$salt; $md5 = array(); $md5[0] = md5($concatedPassphrase, true); $result = $md5[0]; for ($i = 1; $i < 3; $i++) { $md5[$i] = md5($md5[$i - 1].$concatedPassphrase, true); $result .= $md5[$i]; } $key = substr($result, 0, 32); $data = openssl_decrypt($ct, 'aes-256-cbc', $key, true, $iv); return json_decode($data, true); }
[ "static", "function", "cryptoJsAesDecrypt", "(", "$", "passphrase", ",", "$", "jsonString", ")", "{", "$", "jsondata", "=", "json_decode", "(", "$", "jsonString", ",", "true", ")", ";", "try", "{", "$", "salt", "=", "hex2bin", "(", "$", "jsondata", "[", "\"s\"", "]", ")", ";", "$", "iv", "=", "hex2bin", "(", "$", "jsondata", "[", "\"iv\"", "]", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "return", "null", ";", "}", "$", "ct", "=", "base64_decode", "(", "$", "jsondata", "[", "\"ct\"", "]", ")", ";", "$", "concatedPassphrase", "=", "$", "passphrase", ".", "$", "salt", ";", "$", "md5", "=", "array", "(", ")", ";", "$", "md5", "[", "0", "]", "=", "md5", "(", "$", "concatedPassphrase", ",", "true", ")", ";", "$", "result", "=", "$", "md5", "[", "0", "]", ";", "for", "(", "$", "i", "=", "1", ";", "$", "i", "<", "3", ";", "$", "i", "++", ")", "{", "$", "md5", "[", "$", "i", "]", "=", "md5", "(", "$", "md5", "[", "$", "i", "-", "1", "]", ".", "$", "concatedPassphrase", ",", "true", ")", ";", "$", "result", ".=", "$", "md5", "[", "$", "i", "]", ";", "}", "$", "key", "=", "substr", "(", "$", "result", ",", "0", ",", "32", ")", ";", "$", "data", "=", "openssl_decrypt", "(", "$", "ct", ",", "'aes-256-cbc'", ",", "$", "key", ",", "true", ",", "$", "iv", ")", ";", "return", "json_decode", "(", "$", "data", ",", "true", ")", ";", "}" ]
Decrypt data from a CryptoJS json encoding string @param mixed $passphrase @param mixed $jsonString @return mixed
[ "Decrypt", "data", "from", "a", "CryptoJS", "json", "encoding", "string" ]
51446641cee22c0cf53d2b409c76cc8bd1a187e7
https://github.com/net-tools/core/blob/51446641cee22c0cf53d2b409c76cc8bd1a187e7/src/Helpers/SecurityHelper.php#L90-L108
train
net-tools/core
src/Helpers/SecurityHelper.php
SecurityHelper.cryptoJsAesEncrypt
static function cryptoJsAesEncrypt($passphrase, $value){ $salt = openssl_random_pseudo_bytes(8); $salted = ''; $dx = ''; while (strlen($salted) < 48) { $dx = md5($dx.$passphrase.$salt, true); $salted .= $dx; } $key = substr($salted, 0, 32); $iv = substr($salted, 32,16); $encrypted_data = openssl_encrypt(json_encode($value), 'aes-256-cbc', $key, true, $iv); $data = array("ct" => base64_encode($encrypted_data), "iv" => bin2hex($iv), "s" => bin2hex($salt)); return json_encode($data); }
php
static function cryptoJsAesEncrypt($passphrase, $value){ $salt = openssl_random_pseudo_bytes(8); $salted = ''; $dx = ''; while (strlen($salted) < 48) { $dx = md5($dx.$passphrase.$salt, true); $salted .= $dx; } $key = substr($salted, 0, 32); $iv = substr($salted, 32,16); $encrypted_data = openssl_encrypt(json_encode($value), 'aes-256-cbc', $key, true, $iv); $data = array("ct" => base64_encode($encrypted_data), "iv" => bin2hex($iv), "s" => bin2hex($salt)); return json_encode($data); }
[ "static", "function", "cryptoJsAesEncrypt", "(", "$", "passphrase", ",", "$", "value", ")", "{", "$", "salt", "=", "openssl_random_pseudo_bytes", "(", "8", ")", ";", "$", "salted", "=", "''", ";", "$", "dx", "=", "''", ";", "while", "(", "strlen", "(", "$", "salted", ")", "<", "48", ")", "{", "$", "dx", "=", "md5", "(", "$", "dx", ".", "$", "passphrase", ".", "$", "salt", ",", "true", ")", ";", "$", "salted", ".=", "$", "dx", ";", "}", "$", "key", "=", "substr", "(", "$", "salted", ",", "0", ",", "32", ")", ";", "$", "iv", "=", "substr", "(", "$", "salted", ",", "32", ",", "16", ")", ";", "$", "encrypted_data", "=", "openssl_encrypt", "(", "json_encode", "(", "$", "value", ")", ",", "'aes-256-cbc'", ",", "$", "key", ",", "true", ",", "$", "iv", ")", ";", "$", "data", "=", "array", "(", "\"ct\"", "=>", "base64_encode", "(", "$", "encrypted_data", ")", ",", "\"iv\"", "=>", "bin2hex", "(", "$", "iv", ")", ",", "\"s\"", "=>", "bin2hex", "(", "$", "salt", ")", ")", ";", "return", "json_encode", "(", "$", "data", ")", ";", "}" ]
Encrypt value to a cryptojs compatiable json encoding string @param mixed $passphrase @param mixed $value @return string
[ "Encrypt", "value", "to", "a", "cryptojs", "compatiable", "json", "encoding", "string" ]
51446641cee22c0cf53d2b409c76cc8bd1a187e7
https://github.com/net-tools/core/blob/51446641cee22c0cf53d2b409c76cc8bd1a187e7/src/Helpers/SecurityHelper.php#L118-L131
train
agentmedia/phine-builtin
src/BuiltIn/Modules/Frontend/Login.php
Login.Init
protected function Init() { $this->login = ContentLogin::Schema()->ByContent($this->Content()); $this->HandleLoggedIn(); $passwordUrl = $this->login->GetPasswordUrl(); $this->passwordUrl = $passwordUrl ? FrontendRouter::Url($passwordUrl) : ''; $this->AddNameField(); $this->AddPasswordField(); $this->AddUniqueSubmit('LoginSubmit'); $validator = new Access(self::Guard(), false, $this->ErrorPrefix('Access')); $this->Elements()->AddValidator($validator); return parent::Init(); }
php
protected function Init() { $this->login = ContentLogin::Schema()->ByContent($this->Content()); $this->HandleLoggedIn(); $passwordUrl = $this->login->GetPasswordUrl(); $this->passwordUrl = $passwordUrl ? FrontendRouter::Url($passwordUrl) : ''; $this->AddNameField(); $this->AddPasswordField(); $this->AddUniqueSubmit('LoginSubmit'); $validator = new Access(self::Guard(), false, $this->ErrorPrefix('Access')); $this->Elements()->AddValidator($validator); return parent::Init(); }
[ "protected", "function", "Init", "(", ")", "{", "$", "this", "->", "login", "=", "ContentLogin", "::", "Schema", "(", ")", "->", "ByContent", "(", "$", "this", "->", "Content", "(", ")", ")", ";", "$", "this", "->", "HandleLoggedIn", "(", ")", ";", "$", "passwordUrl", "=", "$", "this", "->", "login", "->", "GetPasswordUrl", "(", ")", ";", "$", "this", "->", "passwordUrl", "=", "$", "passwordUrl", "?", "FrontendRouter", "::", "Url", "(", "$", "passwordUrl", ")", ":", "''", ";", "$", "this", "->", "AddNameField", "(", ")", ";", "$", "this", "->", "AddPasswordField", "(", ")", ";", "$", "this", "->", "AddUniqueSubmit", "(", "'LoginSubmit'", ")", ";", "$", "validator", "=", "new", "Access", "(", "self", "::", "Guard", "(", ")", ",", "false", ",", "$", "this", "->", "ErrorPrefix", "(", "'Access'", ")", ")", ";", "$", "this", "->", "Elements", "(", ")", "->", "AddValidator", "(", "$", "validator", ")", ";", "return", "parent", "::", "Init", "(", ")", ";", "}" ]
Initializes the login element @return boolean Returns always true
[ "Initializes", "the", "login", "element" ]
4dd05bc406a71e997bd4eaa16b12e23dbe62a456
https://github.com/agentmedia/phine-builtin/blob/4dd05bc406a71e997bd4eaa16b12e23dbe62a456/src/BuiltIn/Modules/Frontend/Login.php#L45-L57
train
Montage-Inc/php-montage
src/Documents.php
Documents.getIterator
public function getIterator() { //Run the query $resp = $this->query->execute(); //Return the documents as an ArrayIterator to satisfy the requirements //of the getIterator function. foreach ($resp->data as $document) { yield $document; } while ($resp->cursors->next) { //send a new request, resetting $resp $resp = $this->query->execute($resp->cursors->next); foreach ($resp->data as $document) { yield $document; } } }
php
public function getIterator() { //Run the query $resp = $this->query->execute(); //Return the documents as an ArrayIterator to satisfy the requirements //of the getIterator function. foreach ($resp->data as $document) { yield $document; } while ($resp->cursors->next) { //send a new request, resetting $resp $resp = $this->query->execute($resp->cursors->next); foreach ($resp->data as $document) { yield $document; } } }
[ "public", "function", "getIterator", "(", ")", "{", "//Run the query", "$", "resp", "=", "$", "this", "->", "query", "->", "execute", "(", ")", ";", "//Return the documents as an ArrayIterator to satisfy the requirements", "//of the getIterator function.", "foreach", "(", "$", "resp", "->", "data", "as", "$", "document", ")", "{", "yield", "$", "document", ";", "}", "while", "(", "$", "resp", "->", "cursors", "->", "next", ")", "{", "//send a new request, resetting $resp", "$", "resp", "=", "$", "this", "->", "query", "->", "execute", "(", "$", "resp", "->", "cursors", "->", "next", ")", ";", "foreach", "(", "$", "resp", "->", "data", "as", "$", "document", ")", "{", "yield", "$", "document", ";", "}", "}", "}" ]
Required function for any class that implements IteratorAggregate. Will yield documents as they become available. If cursors are returned then subsequent requests will be made, yielding more documents. @return \Generator @throws MontageException
[ "Required", "function", "for", "any", "class", "that", "implements", "IteratorAggregate", ".", "Will", "yield", "documents", "as", "they", "become", "available", ".", "If", "cursors", "are", "returned", "then", "subsequent", "requests", "will", "be", "made", "yielding", "more", "documents", "." ]
bcd526985447a31c7e5b74555058e167242b23ed
https://github.com/Montage-Inc/php-montage/blob/bcd526985447a31c7e5b74555058e167242b23ed/src/Documents.php#L62-L83
train
Montage-Inc/php-montage
src/Documents.php
Documents.save
public function save($doc) { return $this->montage->request( 'post', $this->montage->url('document-save', $this->schema->name), ['body' => json_encode($doc)] ); }
php
public function save($doc) { return $this->montage->request( 'post', $this->montage->url('document-save', $this->schema->name), ['body' => json_encode($doc)] ); }
[ "public", "function", "save", "(", "$", "doc", ")", "{", "return", "$", "this", "->", "montage", "->", "request", "(", "'post'", ",", "$", "this", "->", "montage", "->", "url", "(", "'document-save'", ",", "$", "this", "->", "schema", "->", "name", ")", ",", "[", "'body'", "=>", "json_encode", "(", "$", "doc", ")", "]", ")", ";", "}" ]
Persist one or more document objects to montage. @param $doc @return mixed
[ "Persist", "one", "or", "more", "document", "objects", "to", "montage", "." ]
bcd526985447a31c7e5b74555058e167242b23ed
https://github.com/Montage-Inc/php-montage/blob/bcd526985447a31c7e5b74555058e167242b23ed/src/Documents.php#L91-L98
train
Montage-Inc/php-montage
src/Documents.php
Documents.get
public function get($docId) { return $this->montage->request( 'get', $this->montage->url('document-detail', $this->schema->name, $docId) ); }
php
public function get($docId) { return $this->montage->request( 'get', $this->montage->url('document-detail', $this->schema->name, $docId) ); }
[ "public", "function", "get", "(", "$", "docId", ")", "{", "return", "$", "this", "->", "montage", "->", "request", "(", "'get'", ",", "$", "this", "->", "montage", "->", "url", "(", "'document-detail'", ",", "$", "this", "->", "schema", "->", "name", ",", "$", "docId", ")", ")", ";", "}" ]
Get a single document by it's ID from montage. @param $docId @return mixed
[ "Get", "a", "single", "document", "by", "it", "s", "ID", "from", "montage", "." ]
bcd526985447a31c7e5b74555058e167242b23ed
https://github.com/Montage-Inc/php-montage/blob/bcd526985447a31c7e5b74555058e167242b23ed/src/Documents.php#L106-L112
train
Montage-Inc/php-montage
src/Documents.php
Documents.delete
public function delete($docId) { return $this->montage->request( 'delete', $this->montage->url('document-detail', $this->schema->name, $docId) ); }
php
public function delete($docId) { return $this->montage->request( 'delete', $this->montage->url('document-detail', $this->schema->name, $docId) ); }
[ "public", "function", "delete", "(", "$", "docId", ")", "{", "return", "$", "this", "->", "montage", "->", "request", "(", "'delete'", ",", "$", "this", "->", "montage", "->", "url", "(", "'document-detail'", ",", "$", "this", "->", "schema", "->", "name", ",", "$", "docId", ")", ")", ";", "}" ]
Delete a record with montage. @param $docId @return mixed
[ "Delete", "a", "record", "with", "montage", "." ]
bcd526985447a31c7e5b74555058e167242b23ed
https://github.com/Montage-Inc/php-montage/blob/bcd526985447a31c7e5b74555058e167242b23ed/src/Documents.php#L136-L142
train
SlabPHP/controllers
src/Traits/Sequenced.php
Sequenced.initializeCallQueues
protected function initializeCallQueues() { $this->inputs = new \Slab\Sequencer\CallQueue(); $this->operations = new \Slab\Sequencer\CallQueue(); $this->outputs = new \Slab\Sequencer\CallQueue(); }
php
protected function initializeCallQueues() { $this->inputs = new \Slab\Sequencer\CallQueue(); $this->operations = new \Slab\Sequencer\CallQueue(); $this->outputs = new \Slab\Sequencer\CallQueue(); }
[ "protected", "function", "initializeCallQueues", "(", ")", "{", "$", "this", "->", "inputs", "=", "new", "\\", "Slab", "\\", "Sequencer", "\\", "CallQueue", "(", ")", ";", "$", "this", "->", "operations", "=", "new", "\\", "Slab", "\\", "Sequencer", "\\", "CallQueue", "(", ")", ";", "$", "this", "->", "outputs", "=", "new", "\\", "Slab", "\\", "Sequencer", "\\", "CallQueue", "(", ")", ";", "}" ]
Sequenced constructor.
[ "Sequenced", "constructor", "." ]
a1c4fded0265100a85904dd664b972a7f8687652
https://github.com/SlabPHP/controllers/blob/a1c4fded0265100a85904dd664b972a7f8687652/src/Traits/Sequenced.php#L36-L41
train
SlabPHP/controllers
src/Traits/Sequenced.php
Sequenced.executeCallQueues
protected function executeCallQueues() { foreach ($this->inputs->getEntries() as $entry) { $this->executeCallQueueEntry($entry); if (!$this->executeQueues) return; } foreach ($this->operations->getEntries() as $entry) { $this->executeCallQueueEntry($entry); if (!$this->executeQueues) return; } foreach ($this->outputs->getEntries() as $entry) { $this->executeCallQueueEntry($entry); if (!$this->executeQueues) return; } }
php
protected function executeCallQueues() { foreach ($this->inputs->getEntries() as $entry) { $this->executeCallQueueEntry($entry); if (!$this->executeQueues) return; } foreach ($this->operations->getEntries() as $entry) { $this->executeCallQueueEntry($entry); if (!$this->executeQueues) return; } foreach ($this->outputs->getEntries() as $entry) { $this->executeCallQueueEntry($entry); if (!$this->executeQueues) return; } }
[ "protected", "function", "executeCallQueues", "(", ")", "{", "foreach", "(", "$", "this", "->", "inputs", "->", "getEntries", "(", ")", "as", "$", "entry", ")", "{", "$", "this", "->", "executeCallQueueEntry", "(", "$", "entry", ")", ";", "if", "(", "!", "$", "this", "->", "executeQueues", ")", "return", ";", "}", "foreach", "(", "$", "this", "->", "operations", "->", "getEntries", "(", ")", "as", "$", "entry", ")", "{", "$", "this", "->", "executeCallQueueEntry", "(", "$", "entry", ")", ";", "if", "(", "!", "$", "this", "->", "executeQueues", ")", "return", ";", "}", "foreach", "(", "$", "this", "->", "outputs", "->", "getEntries", "(", ")", "as", "$", "entry", ")", "{", "$", "this", "->", "executeCallQueueEntry", "(", "$", "entry", ")", ";", "if", "(", "!", "$", "this", "->", "executeQueues", ")", "return", ";", "}", "}" ]
Execute call queues @throws \Exception
[ "Execute", "call", "queues" ]
a1c4fded0265100a85904dd664b972a7f8687652
https://github.com/SlabPHP/controllers/blob/a1c4fded0265100a85904dd664b972a7f8687652/src/Traits/Sequenced.php#L47-L66
train
SlabPHP/controllers
src/Traits/Sequenced.php
Sequenced.stopCallQueues
protected function stopCallQueues() { $this->executeQueues = false; $this->inputs->stopExecution(); $this->operations->stopExecution(); $this->outputs->stopExecution(); }
php
protected function stopCallQueues() { $this->executeQueues = false; $this->inputs->stopExecution(); $this->operations->stopExecution(); $this->outputs->stopExecution(); }
[ "protected", "function", "stopCallQueues", "(", ")", "{", "$", "this", "->", "executeQueues", "=", "false", ";", "$", "this", "->", "inputs", "->", "stopExecution", "(", ")", ";", "$", "this", "->", "operations", "->", "stopExecution", "(", ")", ";", "$", "this", "->", "outputs", "->", "stopExecution", "(", ")", ";", "}" ]
Stop call queues
[ "Stop", "call", "queues" ]
a1c4fded0265100a85904dd664b972a7f8687652
https://github.com/SlabPHP/controllers/blob/a1c4fded0265100a85904dd664b972a7f8687652/src/Traits/Sequenced.php#L85-L91
train
kaiohken1982/Thumbnailer
src/Thumbnailer/Thumbnailer/Thumbnailer.php
Thumbnailer.initSourceImageResource
protected function initSourceImageResource() { $ext = $this->getExtension(); switch($ext) { case 'gif': $this->sourceImageResource = ImageCreateFromGif($this->sourceImagePath); break; case 'jpg': $this->sourceImageResource = ImageCreateFromJpeg($this->sourceImagePath); break; case 'png': $this->sourceImageResource = ImageCreateFromPng($this->sourceImagePath); break; default: throw new \RuntimeException("An error occurred trying to create the image, extension '" . $ext. "' is not supported"); break; } return $this; }
php
protected function initSourceImageResource() { $ext = $this->getExtension(); switch($ext) { case 'gif': $this->sourceImageResource = ImageCreateFromGif($this->sourceImagePath); break; case 'jpg': $this->sourceImageResource = ImageCreateFromJpeg($this->sourceImagePath); break; case 'png': $this->sourceImageResource = ImageCreateFromPng($this->sourceImagePath); break; default: throw new \RuntimeException("An error occurred trying to create the image, extension '" . $ext. "' is not supported"); break; } return $this; }
[ "protected", "function", "initSourceImageResource", "(", ")", "{", "$", "ext", "=", "$", "this", "->", "getExtension", "(", ")", ";", "switch", "(", "$", "ext", ")", "{", "case", "'gif'", ":", "$", "this", "->", "sourceImageResource", "=", "ImageCreateFromGif", "(", "$", "this", "->", "sourceImagePath", ")", ";", "break", ";", "case", "'jpg'", ":", "$", "this", "->", "sourceImageResource", "=", "ImageCreateFromJpeg", "(", "$", "this", "->", "sourceImagePath", ")", ";", "break", ";", "case", "'png'", ":", "$", "this", "->", "sourceImageResource", "=", "ImageCreateFromPng", "(", "$", "this", "->", "sourceImagePath", ")", ";", "break", ";", "default", ":", "throw", "new", "\\", "RuntimeException", "(", "\"An error occurred trying to create the image, extension '\"", ".", "$", "ext", ".", "\"' is not supported\"", ")", ";", "break", ";", "}", "return", "$", "this", ";", "}" ]
Init the source image resource @throws \RuntimeException @return \Thumbnailer\Thumbnailer\Thumbnailer
[ "Init", "the", "source", "image", "resource" ]
8625d41c153fef41979d402837335b1c2320077d
https://github.com/kaiohken1982/Thumbnailer/blob/8625d41c153fef41979d402837335b1c2320077d/src/Thumbnailer/Thumbnailer/Thumbnailer.php#L238-L261
train
kaiohken1982/Thumbnailer
src/Thumbnailer/Thumbnailer/Thumbnailer.php
Thumbnailer.initDestImageResource
protected function initDestImageResource() { // gif does not supports truecolor for resize if (function_exists("ImageCreateTrueColor") && $this->getExtension() != 'gif') { $this->destImageResource = ImageCreateTrueColor($this->destImageWidth, $this->destImageHeight); } else { $this->destImageResource = ImageCreate($this->destImageWidth, $this->destImageHeight); } return $this; }
php
protected function initDestImageResource() { // gif does not supports truecolor for resize if (function_exists("ImageCreateTrueColor") && $this->getExtension() != 'gif') { $this->destImageResource = ImageCreateTrueColor($this->destImageWidth, $this->destImageHeight); } else { $this->destImageResource = ImageCreate($this->destImageWidth, $this->destImageHeight); } return $this; }
[ "protected", "function", "initDestImageResource", "(", ")", "{", "// gif does not supports truecolor for resize", "if", "(", "function_exists", "(", "\"ImageCreateTrueColor\"", ")", "&&", "$", "this", "->", "getExtension", "(", ")", "!=", "'gif'", ")", "{", "$", "this", "->", "destImageResource", "=", "ImageCreateTrueColor", "(", "$", "this", "->", "destImageWidth", ",", "$", "this", "->", "destImageHeight", ")", ";", "}", "else", "{", "$", "this", "->", "destImageResource", "=", "ImageCreate", "(", "$", "this", "->", "destImageWidth", ",", "$", "this", "->", "destImageHeight", ")", ";", "}", "return", "$", "this", ";", "}" ]
Init the destination resource image. This is an empty image and use the width and height values of the source image if resize is not called by the user @throws \RuntimeException @return resource
[ "Init", "the", "destination", "resource", "image", ".", "This", "is", "an", "empty", "image", "and", "use", "the", "width", "and", "height", "values", "of", "the", "source", "image", "if", "resize", "is", "not", "called", "by", "the", "user" ]
8625d41c153fef41979d402837335b1c2320077d
https://github.com/kaiohken1982/Thumbnailer/blob/8625d41c153fef41979d402837335b1c2320077d/src/Thumbnailer/Thumbnailer/Thumbnailer.php#L271-L281
train
libreworks/microformats
src/GeoFormatter.php
GeoFormatter.format
public function format(Geo $geo) { return '<span class="h-geo">' . '<span class="p-latitude">' . (string)$geo->getLatitude() . '</span>, ' . '<span class="p-longitude">' . (string)$geo->getLongitude() . '</span>' . ($geo->getAltitude() === null ? '' : ' (elevation <span class="p-altitude">' . (string)$geo->getAltitude() . '</span>)') . '</span>'; }
php
public function format(Geo $geo) { return '<span class="h-geo">' . '<span class="p-latitude">' . (string)$geo->getLatitude() . '</span>, ' . '<span class="p-longitude">' . (string)$geo->getLongitude() . '</span>' . ($geo->getAltitude() === null ? '' : ' (elevation <span class="p-altitude">' . (string)$geo->getAltitude() . '</span>)') . '</span>'; }
[ "public", "function", "format", "(", "Geo", "$", "geo", ")", "{", "return", "'<span class=\"h-geo\">'", ".", "'<span class=\"p-latitude\">'", ".", "(", "string", ")", "$", "geo", "->", "getLatitude", "(", ")", ".", "'</span>, '", ".", "'<span class=\"p-longitude\">'", ".", "(", "string", ")", "$", "geo", "->", "getLongitude", "(", ")", ".", "'</span>'", ".", "(", "$", "geo", "->", "getAltitude", "(", ")", "===", "null", "?", "''", ":", "' (elevation <span class=\"p-altitude\">'", ".", "(", "string", ")", "$", "geo", "->", "getAltitude", "(", ")", ".", "'</span>)'", ")", ".", "'</span>'", ";", "}" ]
Formats a geo. @param \Libreworks\Microformats\Geo $geo The geo coordinates @return string The HTML markup
[ "Formats", "a", "geo", "." ]
f208650cb83e8711f5f35878cfa285b7cb505d3d
https://github.com/libreworks/microformats/blob/f208650cb83e8711f5f35878cfa285b7cb505d3d/src/GeoFormatter.php#L36-L43
train
agentmedia/phine-core
src/Core/Snippets/BackendRights/SiteRights.php
SiteRights.Save
function Save() { $this->pageRights->Save(); if (!$this->rights) { $this->rights = new BackendSiteRights(); } $this->rights->SetEdit($this->Value('Edit')); $this->rights->SetRemove($this->Value('Remove')); $this->rights->SetPageRights($this->pageRights->Rights()); $this->rights->Save(); }
php
function Save() { $this->pageRights->Save(); if (!$this->rights) { $this->rights = new BackendSiteRights(); } $this->rights->SetEdit($this->Value('Edit')); $this->rights->SetRemove($this->Value('Remove')); $this->rights->SetPageRights($this->pageRights->Rights()); $this->rights->Save(); }
[ "function", "Save", "(", ")", "{", "$", "this", "->", "pageRights", "->", "Save", "(", ")", ";", "if", "(", "!", "$", "this", "->", "rights", ")", "{", "$", "this", "->", "rights", "=", "new", "BackendSiteRights", "(", ")", ";", "}", "$", "this", "->", "rights", "->", "SetEdit", "(", "$", "this", "->", "Value", "(", "'Edit'", ")", ")", ";", "$", "this", "->", "rights", "->", "SetRemove", "(", "$", "this", "->", "Value", "(", "'Remove'", ")", ")", ";", "$", "this", "->", "rights", "->", "SetPageRights", "(", "$", "this", "->", "pageRights", "->", "Rights", "(", ")", ")", ";", "$", "this", "->", "rights", "->", "Save", "(", ")", ";", "}" ]
Saves the site rights
[ "Saves", "the", "site", "rights" ]
38c1be8d03ebffae950d00a96da3c612aff67832
https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Snippets/BackendRights/SiteRights.php#L41-L53
train
SergioMadness/pwf-helpers
src/ConvertHelper.php
ConvertHelper.XML2Array
public static function XML2Array($xmlString) { try { $xml = simplexml_load_string($xmlString, "SimpleXMLElement", LIBXML_NOCDATA); $json = json_encode($xml); $result = json_decode($json, TRUE); } catch (\Exception $ex) { $result = ''; } return $result; }
php
public static function XML2Array($xmlString) { try { $xml = simplexml_load_string($xmlString, "SimpleXMLElement", LIBXML_NOCDATA); $json = json_encode($xml); $result = json_decode($json, TRUE); } catch (\Exception $ex) { $result = ''; } return $result; }
[ "public", "static", "function", "XML2Array", "(", "$", "xmlString", ")", "{", "try", "{", "$", "xml", "=", "simplexml_load_string", "(", "$", "xmlString", ",", "\"SimpleXMLElement\"", ",", "LIBXML_NOCDATA", ")", ";", "$", "json", "=", "json_encode", "(", "$", "xml", ")", ";", "$", "result", "=", "json_decode", "(", "$", "json", ",", "TRUE", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "ex", ")", "{", "$", "result", "=", "''", ";", "}", "return", "$", "result", ";", "}" ]
Convert XML to array @param string $xmlString @return string
[ "Convert", "XML", "to", "array" ]
d6cd44807c120356d60618cb08f237841c35e293
https://github.com/SergioMadness/pwf-helpers/blob/d6cd44807c120356d60618cb08f237841c35e293/src/ConvertHelper.php#L14-L25
train
SergioMadness/pwf-helpers
src/ConvertHelper.php
ConvertHelper.array2XML
public static function array2XML($haystack, $rootElementName = '') { $args = func_get_args(); $isRoot = !isset($args[2]); $root = isset($args[3]) ? $args[3] : new \DOMDocument('1.0', 'utf-8'); $parent = isset($args[2]) ? $args[2] : ($rootElementName !== '' ? $root->createElement($rootElementName) : null); foreach ($haystack as $key => $val) { if (is_array($val)) { $parent = $root->createElement($key); self::array2xml($val, $rootElementName, $parent, $root); } elseif ($parent === null) { $parent = $root->createElement($key, $val); } else { $parent->appendChild($root->createElement($key, $val)); } } if ($isRoot && $parent !== null) { $root->appendChild($parent); } return $root; }
php
public static function array2XML($haystack, $rootElementName = '') { $args = func_get_args(); $isRoot = !isset($args[2]); $root = isset($args[3]) ? $args[3] : new \DOMDocument('1.0', 'utf-8'); $parent = isset($args[2]) ? $args[2] : ($rootElementName !== '' ? $root->createElement($rootElementName) : null); foreach ($haystack as $key => $val) { if (is_array($val)) { $parent = $root->createElement($key); self::array2xml($val, $rootElementName, $parent, $root); } elseif ($parent === null) { $parent = $root->createElement($key, $val); } else { $parent->appendChild($root->createElement($key, $val)); } } if ($isRoot && $parent !== null) { $root->appendChild($parent); } return $root; }
[ "public", "static", "function", "array2XML", "(", "$", "haystack", ",", "$", "rootElementName", "=", "''", ")", "{", "$", "args", "=", "func_get_args", "(", ")", ";", "$", "isRoot", "=", "!", "isset", "(", "$", "args", "[", "2", "]", ")", ";", "$", "root", "=", "isset", "(", "$", "args", "[", "3", "]", ")", "?", "$", "args", "[", "3", "]", ":", "new", "\\", "DOMDocument", "(", "'1.0'", ",", "'utf-8'", ")", ";", "$", "parent", "=", "isset", "(", "$", "args", "[", "2", "]", ")", "?", "$", "args", "[", "2", "]", ":", "(", "$", "rootElementName", "!==", "''", "?", "$", "root", "->", "createElement", "(", "$", "rootElementName", ")", ":", "null", ")", ";", "foreach", "(", "$", "haystack", "as", "$", "key", "=>", "$", "val", ")", "{", "if", "(", "is_array", "(", "$", "val", ")", ")", "{", "$", "parent", "=", "$", "root", "->", "createElement", "(", "$", "key", ")", ";", "self", "::", "array2xml", "(", "$", "val", ",", "$", "rootElementName", ",", "$", "parent", ",", "$", "root", ")", ";", "}", "elseif", "(", "$", "parent", "===", "null", ")", "{", "$", "parent", "=", "$", "root", "->", "createElement", "(", "$", "key", ",", "$", "val", ")", ";", "}", "else", "{", "$", "parent", "->", "appendChild", "(", "$", "root", "->", "createElement", "(", "$", "key", ",", "$", "val", ")", ")", ";", "}", "}", "if", "(", "$", "isRoot", "&&", "$", "parent", "!==", "null", ")", "{", "$", "root", "->", "appendChild", "(", "$", "parent", ")", ";", "}", "return", "$", "root", ";", "}" ]
Convert array to XML object @param array $haystack @param string $rootElementName @return DOMDocument
[ "Convert", "array", "to", "XML", "object" ]
d6cd44807c120356d60618cb08f237841c35e293
https://github.com/SergioMadness/pwf-helpers/blob/d6cd44807c120356d60618cb08f237841c35e293/src/ConvertHelper.php#L34-L57
train
PuKoren/php-inline-images
src/Fetcher.php
Fetcher.fetchLocal
private function fetchLocal() { $finfo = finfo_open(FILEINFO_MIME_TYPE); $this->mime = finfo_file($finfo, $this->path); finfo_close($finfo); $this->data = file_get_contents($this->path, FILE_USE_INCLUDE_PATH); }
php
private function fetchLocal() { $finfo = finfo_open(FILEINFO_MIME_TYPE); $this->mime = finfo_file($finfo, $this->path); finfo_close($finfo); $this->data = file_get_contents($this->path, FILE_USE_INCLUDE_PATH); }
[ "private", "function", "fetchLocal", "(", ")", "{", "$", "finfo", "=", "finfo_open", "(", "FILEINFO_MIME_TYPE", ")", ";", "$", "this", "->", "mime", "=", "finfo_file", "(", "$", "finfo", ",", "$", "this", "->", "path", ")", ";", "finfo_close", "(", "$", "finfo", ")", ";", "$", "this", "->", "data", "=", "file_get_contents", "(", "$", "this", "->", "path", ",", "FILE_USE_INCLUDE_PATH", ")", ";", "}" ]
Fetch a local file and grab its mime type and file content @return void
[ "Fetch", "a", "local", "file", "and", "grab", "its", "mime", "type", "and", "file", "content" ]
22df5d37ad766d06552121d4422d97edc6608c5d
https://github.com/PuKoren/php-inline-images/blob/22df5d37ad766d06552121d4422d97edc6608c5d/src/Fetcher.php#L45-L50
train
DzikuVx/phpCache
src/PhpCache.php
PhpCache.create
public function create($sMethod = null) { /* * If no method passed, use default */ if (empty($sMethod)) { $sMethod = self::$sDefaultMechanism; } /* * check if passed name is an registered method */ if (array_search($sMethod, $this->aRegisteredMechanisms) === false) { throw new Exception('Unknown caching mechanism'); } /* * If caching mechanism not initialised, create new */ if (!isset($this->aCacheInstance[$sMethod])) { /** @noinspection PhpIncludeInspection */ require_once dirname ( __FILE__ ) . '/' . $sMethod . '.php'; $sClassName = '\phpCache\\' . $sMethod; /** @noinspection PhpUndefinedMethodInspection */ $this->aCacheInstance[$sMethod] = new $sClassName(); } return $this->aCacheInstance[$sMethod]; }
php
public function create($sMethod = null) { /* * If no method passed, use default */ if (empty($sMethod)) { $sMethod = self::$sDefaultMechanism; } /* * check if passed name is an registered method */ if (array_search($sMethod, $this->aRegisteredMechanisms) === false) { throw new Exception('Unknown caching mechanism'); } /* * If caching mechanism not initialised, create new */ if (!isset($this->aCacheInstance[$sMethod])) { /** @noinspection PhpIncludeInspection */ require_once dirname ( __FILE__ ) . '/' . $sMethod . '.php'; $sClassName = '\phpCache\\' . $sMethod; /** @noinspection PhpUndefinedMethodInspection */ $this->aCacheInstance[$sMethod] = new $sClassName(); } return $this->aCacheInstance[$sMethod]; }
[ "public", "function", "create", "(", "$", "sMethod", "=", "null", ")", "{", "/*\n\t\t * If no method passed, use default\n\t\t */", "if", "(", "empty", "(", "$", "sMethod", ")", ")", "{", "$", "sMethod", "=", "self", "::", "$", "sDefaultMechanism", ";", "}", "/*\n\t\t * check if passed name is an registered method\n\t\t */", "if", "(", "array_search", "(", "$", "sMethod", ",", "$", "this", "->", "aRegisteredMechanisms", ")", "===", "false", ")", "{", "throw", "new", "Exception", "(", "'Unknown caching mechanism'", ")", ";", "}", "/*\n\t\t * If caching mechanism not initialised, create new\n\t\t */", "if", "(", "!", "isset", "(", "$", "this", "->", "aCacheInstance", "[", "$", "sMethod", "]", ")", ")", "{", "/** @noinspection PhpIncludeInspection */", "require_once", "dirname", "(", "__FILE__", ")", ".", "'/'", ".", "$", "sMethod", ".", "'.php'", ";", "$", "sClassName", "=", "'\\phpCache\\\\'", ".", "$", "sMethod", ";", "/** @noinspection PhpUndefinedMethodInspection */", "$", "this", "->", "aCacheInstance", "[", "$", "sMethod", "]", "=", "new", "$", "sClassName", "(", ")", ";", "}", "return", "$", "this", "->", "aCacheInstance", "[", "$", "sMethod", "]", ";", "}" ]
Create and return caching mechanism object according to passed name @param string $sMethod @return Apc,File,Memcached,Session,Variable @throws Exception
[ "Create", "and", "return", "caching", "mechanism", "object", "according", "to", "passed", "name" ]
faf3003795ab21913e7ebb02fb04d6a480b7786c
https://github.com/DzikuVx/phpCache/blob/faf3003795ab21913e7ebb02fb04d6a480b7786c/src/PhpCache.php#L52-L84
train
DzikuVx/phpCache
src/PhpCache.php
CacheKey.setModule
public function setModule($value) { if (is_object($value)) { $this->module = get_class($value); }else { $this->module = (string) $value; } }
php
public function setModule($value) { if (is_object($value)) { $this->module = get_class($value); }else { $this->module = (string) $value; } }
[ "public", "function", "setModule", "(", "$", "value", ")", "{", "if", "(", "is_object", "(", "$", "value", ")", ")", "{", "$", "this", "->", "module", "=", "get_class", "(", "$", "value", ")", ";", "}", "else", "{", "$", "this", "->", "module", "=", "(", "string", ")", "$", "value", ";", "}", "}" ]
Set module property @param mixed $value
[ "Set", "module", "property" ]
faf3003795ab21913e7ebb02fb04d6a480b7786c
https://github.com/DzikuVx/phpCache/blob/faf3003795ab21913e7ebb02fb04d6a480b7786c/src/PhpCache.php#L133-L139
train
aztech-digital/phinject
src/Config/AbstractConfig.php
AbstractConfig.compile
public function compile() { $this->doLoad(); $data = (array) $this->data; $this->removeKey($data, 'include'); $this->removeKey($data, '__META__'); return var_export($data, true); }
php
public function compile() { $this->doLoad(); $data = (array) $this->data; $this->removeKey($data, 'include'); $this->removeKey($data, '__META__'); return var_export($data, true); }
[ "public", "function", "compile", "(", ")", "{", "$", "this", "->", "doLoad", "(", ")", ";", "$", "data", "=", "(", "array", ")", "$", "this", "->", "data", ";", "$", "this", "->", "removeKey", "(", "$", "data", ",", "'include'", ")", ";", "$", "this", "->", "removeKey", "(", "$", "data", ",", "'__META__'", ")", ";", "return", "var_export", "(", "$", "data", ",", "true", ")", ";", "}" ]
Compiles the current configuration to a valid PHP snippet. @return string
[ "Compiles", "the", "current", "configuration", "to", "a", "valid", "PHP", "snippet", "." ]
1bb2fb3b5ef44e62f168af71134c613c48b58d95
https://github.com/aztech-digital/phinject/blob/1bb2fb3b5ef44e62f168af71134c613c48b58d95/src/Config/AbstractConfig.php#L28-L38
train
aztech-digital/phinject
src/Config/AbstractConfig.php
AbstractConfig.load
public function load() { if (empty($this->data)) { $this->data = $this->doLoad(); } return $this->data; }
php
public function load() { if (empty($this->data)) { $this->data = $this->doLoad(); } return $this->data; }
[ "public", "function", "load", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "data", ")", ")", "{", "$", "this", "->", "data", "=", "$", "this", "->", "doLoad", "(", ")", ";", "}", "return", "$", "this", "->", "data", ";", "}" ]
Loads and returns the configuration data. @return ArrayResolver
[ "Loads", "and", "returns", "the", "configuration", "data", "." ]
1bb2fb3b5ef44e62f168af71134c613c48b58d95
https://github.com/aztech-digital/phinject/blob/1bb2fb3b5ef44e62f168af71134c613c48b58d95/src/Config/AbstractConfig.php#L58-L65
train
agentmedia/phine-builtin
src/BuiltIn/Logic/Registration/Confirmer.php
Confirmer.CalcKey
private static function CalcKey(Member $member) { return sha1($member->GetPasswordSalt() . $member->GetConfirmed() . $member->GetName()); }
php
private static function CalcKey(Member $member) { return sha1($member->GetPasswordSalt() . $member->GetConfirmed() . $member->GetName()); }
[ "private", "static", "function", "CalcKey", "(", "Member", "$", "member", ")", "{", "return", "sha1", "(", "$", "member", "->", "GetPasswordSalt", "(", ")", ".", "$", "member", "->", "GetConfirmed", "(", ")", ".", "$", "member", "->", "GetName", "(", ")", ")", ";", "}" ]
Returns the password key @param Member $member @return string Returns the calculated key for the member
[ "Returns", "the", "password", "key" ]
4dd05bc406a71e997bd4eaa16b12e23dbe62a456
https://github.com/agentmedia/phine-builtin/blob/4dd05bc406a71e997bd4eaa16b12e23dbe62a456/src/BuiltIn/Logic/Registration/Confirmer.php#L77-L80
train
Wedeto/DB
src/Query/Parameters.php
Parameters.assign
public function assign($value, int $type = PDO::PARAM_STR) { $key = $this->getNextKey(); $this->params[$key] = $value; $this->param_types[$key] = $type; return $key; }
php
public function assign($value, int $type = PDO::PARAM_STR) { $key = $this->getNextKey(); $this->params[$key] = $value; $this->param_types[$key] = $type; return $key; }
[ "public", "function", "assign", "(", "$", "value", ",", "int", "$", "type", "=", "PDO", "::", "PARAM_STR", ")", "{", "$", "key", "=", "$", "this", "->", "getNextKey", "(", ")", ";", "$", "this", "->", "params", "[", "$", "key", "]", "=", "$", "value", ";", "$", "this", "->", "param_types", "[", "$", "key", "]", "=", "$", "type", ";", "return", "$", "key", ";", "}" ]
Set a value for the next parameters in the query @param mixed $value The value to set @param int $type The parameter type, one of PDO::PARAM_* @return string The assigned key
[ "Set", "a", "value", "for", "the", "next", "parameters", "in", "the", "query" ]
715f8f2e3ae6b53c511c40b620921cb9c87e6f62
https://github.com/Wedeto/DB/blob/715f8f2e3ae6b53c511c40b620921cb9c87e6f62/src/Query/Parameters.php#L77-L83
train
Wedeto/DB
src/Query/Parameters.php
Parameters.getParameterType
public function getParameterType(string $key) { if (!array_key_exists($key, $this->params)) throw new OutOfRangeException("Invalid key: $key"); return $this->param_types[$key]; }
php
public function getParameterType(string $key) { if (!array_key_exists($key, $this->params)) throw new OutOfRangeException("Invalid key: $key"); return $this->param_types[$key]; }
[ "public", "function", "getParameterType", "(", "string", "$", "key", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "params", ")", ")", "throw", "new", "OutOfRangeException", "(", "\"Invalid key: $key\"", ")", ";", "return", "$", "this", "->", "param_types", "[", "$", "key", "]", ";", "}" ]
Get the type of parameter the key is set to @param string $key The key to get the parameter type for @return int The parameter type, one of PDO::PARAM_*
[ "Get", "the", "type", "of", "parameter", "the", "key", "is", "set", "to" ]
715f8f2e3ae6b53c511c40b620921cb9c87e6f62
https://github.com/Wedeto/DB/blob/715f8f2e3ae6b53c511c40b620921cb9c87e6f62/src/Query/Parameters.php#L102-L108
train
Wedeto/DB
src/Query/Parameters.php
Parameters.set
public function set(string $key, $value, int $type = PDO::PARAM_STR) { $this->params[$key] = $value; $this->param_types[$key] = $type; return $this; }
php
public function set(string $key, $value, int $type = PDO::PARAM_STR) { $this->params[$key] = $value; $this->param_types[$key] = $type; return $this; }
[ "public", "function", "set", "(", "string", "$", "key", ",", "$", "value", ",", "int", "$", "type", "=", "PDO", "::", "PARAM_STR", ")", "{", "$", "this", "->", "params", "[", "$", "key", "]", "=", "$", "value", ";", "$", "this", "->", "param_types", "[", "$", "key", "]", "=", "$", "type", ";", "return", "$", "this", ";", "}" ]
Set the value for an existing parameters. @param string $key The key to set @param mixed $value The value to set it to @param int $type The parameter type, one of PDO::PARAM_*
[ "Set", "the", "value", "for", "an", "existing", "parameters", "." ]
715f8f2e3ae6b53c511c40b620921cb9c87e6f62
https://github.com/Wedeto/DB/blob/715f8f2e3ae6b53c511c40b620921cb9c87e6f62/src/Query/Parameters.php#L116-L121
train
Wedeto/DB
src/Query/Parameters.php
Parameters.registerTable
public function registerTable($name, $alias) { if (!empty($alias) && empty($name)) return; if (!empty($alias) && !empty($this->parent_scope)) { $table = $this->parent_scope->resolveAlias($alias); if (!empty($table)) throw new QueryException("Duplicate alias \"$alias\" - was already bound to \"$table\" in parent scope"); } if (isset($this->tables[$name])) { if (empty($alias)) throw new QueryException("Duplicate table without an alias: \"$name\""); if (isset($this->tables[$name][$alias])) throw new QueryException("Duplicate alias \"$alias\" for table \"$name\""); if (isset($this->tables[$name][$name])) throw new QueryException("All instances of a table reference must be aliased if used more than once"); $this->tables[$name][$alias] = true; $this->aliases[$alias] = $name; } elseif (!empty($alias) && is_string($alias)) { if (isset($this->aliases[$alias])) throw new QueryException("Duplicate alias \"$alias\" for table \"$name\" - also referring to \"{$this->aliases[$alias]}\""); $this->aliases[$alias] = $name; $this->tables[$name][$alias] = true; } else { $this->tables[$name][$name] = true; } return $this; }
php
public function registerTable($name, $alias) { if (!empty($alias) && empty($name)) return; if (!empty($alias) && !empty($this->parent_scope)) { $table = $this->parent_scope->resolveAlias($alias); if (!empty($table)) throw new QueryException("Duplicate alias \"$alias\" - was already bound to \"$table\" in parent scope"); } if (isset($this->tables[$name])) { if (empty($alias)) throw new QueryException("Duplicate table without an alias: \"$name\""); if (isset($this->tables[$name][$alias])) throw new QueryException("Duplicate alias \"$alias\" for table \"$name\""); if (isset($this->tables[$name][$name])) throw new QueryException("All instances of a table reference must be aliased if used more than once"); $this->tables[$name][$alias] = true; $this->aliases[$alias] = $name; } elseif (!empty($alias) && is_string($alias)) { if (isset($this->aliases[$alias])) throw new QueryException("Duplicate alias \"$alias\" for table \"$name\" - also referring to \"{$this->aliases[$alias]}\""); $this->aliases[$alias] = $name; $this->tables[$name][$alias] = true; } else { $this->tables[$name][$name] = true; } return $this; }
[ "public", "function", "registerTable", "(", "$", "name", ",", "$", "alias", ")", "{", "if", "(", "!", "empty", "(", "$", "alias", ")", "&&", "empty", "(", "$", "name", ")", ")", "return", ";", "if", "(", "!", "empty", "(", "$", "alias", ")", "&&", "!", "empty", "(", "$", "this", "->", "parent_scope", ")", ")", "{", "$", "table", "=", "$", "this", "->", "parent_scope", "->", "resolveAlias", "(", "$", "alias", ")", ";", "if", "(", "!", "empty", "(", "$", "table", ")", ")", "throw", "new", "QueryException", "(", "\"Duplicate alias \\\"$alias\\\" - was already bound to \\\"$table\\\" in parent scope\"", ")", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "tables", "[", "$", "name", "]", ")", ")", "{", "if", "(", "empty", "(", "$", "alias", ")", ")", "throw", "new", "QueryException", "(", "\"Duplicate table without an alias: \\\"$name\\\"\"", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "tables", "[", "$", "name", "]", "[", "$", "alias", "]", ")", ")", "throw", "new", "QueryException", "(", "\"Duplicate alias \\\"$alias\\\" for table \\\"$name\\\"\"", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "tables", "[", "$", "name", "]", "[", "$", "name", "]", ")", ")", "throw", "new", "QueryException", "(", "\"All instances of a table reference must be aliased if used more than once\"", ")", ";", "$", "this", "->", "tables", "[", "$", "name", "]", "[", "$", "alias", "]", "=", "true", ";", "$", "this", "->", "aliases", "[", "$", "alias", "]", "=", "$", "name", ";", "}", "elseif", "(", "!", "empty", "(", "$", "alias", ")", "&&", "is_string", "(", "$", "alias", ")", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "aliases", "[", "$", "alias", "]", ")", ")", "throw", "new", "QueryException", "(", "\"Duplicate alias \\\"$alias\\\" for table \\\"$name\\\" - also referring to \\\"{$this->aliases[$alias]}\\\"\"", ")", ";", "$", "this", "->", "aliases", "[", "$", "alias", "]", "=", "$", "name", ";", "$", "this", "->", "tables", "[", "$", "name", "]", "[", "$", "alias", "]", "=", "true", ";", "}", "else", "{", "$", "this", "->", "tables", "[", "$", "name", "]", "[", "$", "name", "]", "=", "true", ";", "}", "return", "$", "this", ";", "}" ]
Register a table used in the query @param string $name The name of the table @param string $alias The alias for the table @return $this Provides fluent interface
[ "Register", "a", "table", "used", "in", "the", "query" ]
715f8f2e3ae6b53c511c40b620921cb9c87e6f62
https://github.com/Wedeto/DB/blob/715f8f2e3ae6b53c511c40b620921cb9c87e6f62/src/Query/Parameters.php#L172-L208
train
Wedeto/DB
src/Query/Parameters.php
Parameters.resolveAlias
public function resolveAlias(string $alias) { if (isset($this->aliases[$alias])) return $this->aliases[$alias]; if (empty($this->parent_scope)) return null; return $this->parent_scope->resolveAlias($alias); }
php
public function resolveAlias(string $alias) { if (isset($this->aliases[$alias])) return $this->aliases[$alias]; if (empty($this->parent_scope)) return null; return $this->parent_scope->resolveAlias($alias); }
[ "public", "function", "resolveAlias", "(", "string", "$", "alias", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "aliases", "[", "$", "alias", "]", ")", ")", "return", "$", "this", "->", "aliases", "[", "$", "alias", "]", ";", "if", "(", "empty", "(", "$", "this", "->", "parent_scope", ")", ")", "return", "null", ";", "return", "$", "this", "->", "parent_scope", "->", "resolveAlias", "(", "$", "alias", ")", ";", "}" ]
Find a table by its alias @param string $alias The alias to find @return TableClause The table the alias refers to - can be from an outer scope
[ "Find", "a", "table", "by", "its", "alias" ]
715f8f2e3ae6b53c511c40b620921cb9c87e6f62
https://github.com/Wedeto/DB/blob/715f8f2e3ae6b53c511c40b620921cb9c87e6f62/src/Query/Parameters.php#L215-L224
train
Wedeto/DB
src/Query/Parameters.php
Parameters.resolveTable
public function resolveTable(string $name) { if (!empty($name) && is_string($name)) { if (isset($this->aliases[$name])) return array($this->aliases[$name], $name); if (isset($this->tables[$name])) { if (count($this->tables[$name]) === 1) return array($name, null); throw new QueryException("Multiple references to $name, use the appropriate alias"); } if (!empty($this->parent_scope)) return $this->parent_scope->resolveTable($name); throw new QueryException("Unknown source table $name"); } throw new QueryException("No table identifier provided"); }
php
public function resolveTable(string $name) { if (!empty($name) && is_string($name)) { if (isset($this->aliases[$name])) return array($this->aliases[$name], $name); if (isset($this->tables[$name])) { if (count($this->tables[$name]) === 1) return array($name, null); throw new QueryException("Multiple references to $name, use the appropriate alias"); } if (!empty($this->parent_scope)) return $this->parent_scope->resolveTable($name); throw new QueryException("Unknown source table $name"); } throw new QueryException("No table identifier provided"); }
[ "public", "function", "resolveTable", "(", "string", "$", "name", ")", "{", "if", "(", "!", "empty", "(", "$", "name", ")", "&&", "is_string", "(", "$", "name", ")", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "aliases", "[", "$", "name", "]", ")", ")", "return", "array", "(", "$", "this", "->", "aliases", "[", "$", "name", "]", ",", "$", "name", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "tables", "[", "$", "name", "]", ")", ")", "{", "if", "(", "count", "(", "$", "this", "->", "tables", "[", "$", "name", "]", ")", "===", "1", ")", "return", "array", "(", "$", "name", ",", "null", ")", ";", "throw", "new", "QueryException", "(", "\"Multiple references to $name, use the appropriate alias\"", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "this", "->", "parent_scope", ")", ")", "return", "$", "this", "->", "parent_scope", "->", "resolveTable", "(", "$", "name", ")", ";", "throw", "new", "QueryException", "(", "\"Unknown source table $name\"", ")", ";", "}", "throw", "new", "QueryException", "(", "\"No table identifier provided\"", ")", ";", "}" ]
Find a table by its name @param string $name The name of the table @return TableClause The table searched for - can be from an outer scope
[ "Find", "a", "table", "by", "its", "name" ]
715f8f2e3ae6b53c511c40b620921cb9c87e6f62
https://github.com/Wedeto/DB/blob/715f8f2e3ae6b53c511c40b620921cb9c87e6f62/src/Query/Parameters.php#L231-L252
train
Wedeto/DB
src/Query/Parameters.php
Parameters.bindParameters
public function bindParameters(\PDOStatement $statement) { foreach (array_keys($this->params) as $key) { $type = $this->param_types[$key]; $statement->bindParam($key, $this->params[$key], $type); } return $this; }
php
public function bindParameters(\PDOStatement $statement) { foreach (array_keys($this->params) as $key) { $type = $this->param_types[$key]; $statement->bindParam($key, $this->params[$key], $type); } return $this; }
[ "public", "function", "bindParameters", "(", "\\", "PDOStatement", "$", "statement", ")", "{", "foreach", "(", "array_keys", "(", "$", "this", "->", "params", ")", "as", "$", "key", ")", "{", "$", "type", "=", "$", "this", "->", "param_types", "[", "$", "key", "]", ";", "$", "statement", "->", "bindParam", "(", "$", "key", ",", "$", "this", "->", "params", "[", "$", "key", "]", ",", "$", "type", ")", ";", "}", "return", "$", "this", ";", "}" ]
Bind the paramters to a PDOStatement @param PDOStatement $statement The statement to bind to @return $this Provides fluent interface
[ "Bind", "the", "paramters", "to", "a", "PDOStatement" ]
715f8f2e3ae6b53c511c40b620921cb9c87e6f62
https://github.com/Wedeto/DB/blob/715f8f2e3ae6b53c511c40b620921cb9c87e6f62/src/Query/Parameters.php#L348-L356
train
Wedeto/DB
src/Query/Parameters.php
Parameters.generateAlias
public function generateAlias(Clause $clause) { if ($clause instanceof FieldName) { $table = $clause->getTable(); if (empty($table)) { // When no table is defined, it means only one table is being // used in the query. Aliases will not be required return ""; } $prefix = $table->getPrefix(); $alias = $prefix . '_' . $clause->getField(); } elseif ($clause instanceof SQLFunction) { $func = $clause->getFunction(); $alias = strtolower($func); } else throw new ImplementationException("No alias generation implemented for: " . get_class($clause)); $cnt = 1; $base_alias = $alias; while (isset($this->field_aliases[$alias])) $alias = $base_alias . (++$cnt); $this->field_aliases[$alias] = true; return $alias; }
php
public function generateAlias(Clause $clause) { if ($clause instanceof FieldName) { $table = $clause->getTable(); if (empty($table)) { // When no table is defined, it means only one table is being // used in the query. Aliases will not be required return ""; } $prefix = $table->getPrefix(); $alias = $prefix . '_' . $clause->getField(); } elseif ($clause instanceof SQLFunction) { $func = $clause->getFunction(); $alias = strtolower($func); } else throw new ImplementationException("No alias generation implemented for: " . get_class($clause)); $cnt = 1; $base_alias = $alias; while (isset($this->field_aliases[$alias])) $alias = $base_alias . (++$cnt); $this->field_aliases[$alias] = true; return $alias; }
[ "public", "function", "generateAlias", "(", "Clause", "$", "clause", ")", "{", "if", "(", "$", "clause", "instanceof", "FieldName", ")", "{", "$", "table", "=", "$", "clause", "->", "getTable", "(", ")", ";", "if", "(", "empty", "(", "$", "table", ")", ")", "{", "// When no table is defined, it means only one table is being", "// used in the query. Aliases will not be required", "return", "\"\"", ";", "}", "$", "prefix", "=", "$", "table", "->", "getPrefix", "(", ")", ";", "$", "alias", "=", "$", "prefix", ".", "'_'", ".", "$", "clause", "->", "getField", "(", ")", ";", "}", "elseif", "(", "$", "clause", "instanceof", "SQLFunction", ")", "{", "$", "func", "=", "$", "clause", "->", "getFunction", "(", ")", ";", "$", "alias", "=", "strtolower", "(", "$", "func", ")", ";", "}", "else", "throw", "new", "ImplementationException", "(", "\"No alias generation implemented for: \"", ".", "get_class", "(", "$", "clause", ")", ")", ";", "$", "cnt", "=", "1", ";", "$", "base_alias", "=", "$", "alias", ";", "while", "(", "isset", "(", "$", "this", "->", "field_aliases", "[", "$", "alias", "]", ")", ")", "$", "alias", "=", "$", "base_alias", ".", "(", "++", "$", "cnt", ")", ";", "$", "this", "->", "field_aliases", "[", "$", "alias", "]", "=", "true", ";", "return", "$", "alias", ";", "}" ]
Generate an alias for a table @param Clause $clause The field or sub query to refer to @return string The alias for the table
[ "Generate", "an", "alias", "for", "a", "table" ]
715f8f2e3ae6b53c511c40b620921cb9c87e6f62
https://github.com/Wedeto/DB/blob/715f8f2e3ae6b53c511c40b620921cb9c87e6f62/src/Query/Parameters.php#L363-L393
train
Wedeto/DB
src/Query/Parameters.php
Parameters.getSubScope
public function getSubScope(int $num = null) { // Resolve an existing scope if ($num !== null) { if (!isset($this->scopes[$num])) throw new QueryException("Invalid scope number: $num"); return $this->scopes[$num]; } $scope = new Parameters($this->driver); // Alias most fields $scope->params = &$this->params; $scope->param_types = &$this->param_types; $scope->column_counter = &$this->column_counter; $scope->table_counter = &$this->table_counter; $scope->scope_counter = &$this->scope_counter; $scope->scopes = &$this->scopes; // Assign a scope number $id = ++$this->scope_counter; $scope->parent_scope = $this; $scope->scope_id = $id; // Store the scope reference $this->scopes[$id] = $scope; return $scope; }
php
public function getSubScope(int $num = null) { // Resolve an existing scope if ($num !== null) { if (!isset($this->scopes[$num])) throw new QueryException("Invalid scope number: $num"); return $this->scopes[$num]; } $scope = new Parameters($this->driver); // Alias most fields $scope->params = &$this->params; $scope->param_types = &$this->param_types; $scope->column_counter = &$this->column_counter; $scope->table_counter = &$this->table_counter; $scope->scope_counter = &$this->scope_counter; $scope->scopes = &$this->scopes; // Assign a scope number $id = ++$this->scope_counter; $scope->parent_scope = $this; $scope->scope_id = $id; // Store the scope reference $this->scopes[$id] = $scope; return $scope; }
[ "public", "function", "getSubScope", "(", "int", "$", "num", "=", "null", ")", "{", "// Resolve an existing scope", "if", "(", "$", "num", "!==", "null", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "scopes", "[", "$", "num", "]", ")", ")", "throw", "new", "QueryException", "(", "\"Invalid scope number: $num\"", ")", ";", "return", "$", "this", "->", "scopes", "[", "$", "num", "]", ";", "}", "$", "scope", "=", "new", "Parameters", "(", "$", "this", "->", "driver", ")", ";", "// Alias most fields", "$", "scope", "->", "params", "=", "&", "$", "this", "->", "params", ";", "$", "scope", "->", "param_types", "=", "&", "$", "this", "->", "param_types", ";", "$", "scope", "->", "column_counter", "=", "&", "$", "this", "->", "column_counter", ";", "$", "scope", "->", "table_counter", "=", "&", "$", "this", "->", "table_counter", ";", "$", "scope", "->", "scope_counter", "=", "&", "$", "this", "->", "scope_counter", ";", "$", "scope", "->", "scopes", "=", "&", "$", "this", "->", "scopes", ";", "// Assign a scope number", "$", "id", "=", "++", "$", "this", "->", "scope_counter", ";", "$", "scope", "->", "parent_scope", "=", "$", "this", ";", "$", "scope", "->", "scope_id", "=", "$", "id", ";", "// Store the scope reference", "$", "this", "->", "scopes", "[", "$", "id", "]", "=", "$", "scope", ";", "return", "$", "scope", ";", "}" ]
Create a sub scope for a nester query @param int $num The scope level @return Parameters A nested parameters object
[ "Create", "a", "sub", "scope", "for", "a", "nester", "query" ]
715f8f2e3ae6b53c511c40b620921cb9c87e6f62
https://github.com/Wedeto/DB/blob/715f8f2e3ae6b53c511c40b620921cb9c87e6f62/src/Query/Parameters.php#L401-L430
train
praxigento/mobi_mod_pv
Helper/PvProvider.php
PvProvider.loadPvForQuote
private function loadPvForQuote($quoteId) { if (!isset($this->cachePvQuote[$quoteId])) { $found = $this->daoPvQuote->getById((int)$quoteId); $this->cachePvQuote[$quoteId] = $found; } return $this->cachePvQuote[$quoteId]; }
php
private function loadPvForQuote($quoteId) { if (!isset($this->cachePvQuote[$quoteId])) { $found = $this->daoPvQuote->getById((int)$quoteId); $this->cachePvQuote[$quoteId] = $found; } return $this->cachePvQuote[$quoteId]; }
[ "private", "function", "loadPvForQuote", "(", "$", "quoteId", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "cachePvQuote", "[", "$", "quoteId", "]", ")", ")", "{", "$", "found", "=", "$", "this", "->", "daoPvQuote", "->", "getById", "(", "(", "int", ")", "$", "quoteId", ")", ";", "$", "this", "->", "cachePvQuote", "[", "$", "quoteId", "]", "=", "$", "found", ";", "}", "return", "$", "this", "->", "cachePvQuote", "[", "$", "quoteId", "]", ";", "}" ]
Cacheable loader for quote's PV. @param int $quoteId @return \Praxigento\Pv\Repo\Data\Quote
[ "Cacheable", "loader", "for", "quote", "s", "PV", "." ]
d1540b7e94264527006e8b9fa68904a72a63928e
https://github.com/praxigento/mobi_mod_pv/blob/d1540b7e94264527006e8b9fa68904a72a63928e/Helper/PvProvider.php#L123-L130
train
praxigento/mobi_mod_pv
Helper/PvProvider.php
PvProvider.loadPvForQuoteItem
private function loadPvForQuoteItem($itemId) { if (!isset($this->cachePvQuoteItem[$itemId])) { $found = $this->daoPvQuoteItem->getById((int)$itemId); $this->cachePvQuoteItem[$itemId] = $found; } return $this->cachePvQuoteItem[$itemId]; }
php
private function loadPvForQuoteItem($itemId) { if (!isset($this->cachePvQuoteItem[$itemId])) { $found = $this->daoPvQuoteItem->getById((int)$itemId); $this->cachePvQuoteItem[$itemId] = $found; } return $this->cachePvQuoteItem[$itemId]; }
[ "private", "function", "loadPvForQuoteItem", "(", "$", "itemId", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "cachePvQuoteItem", "[", "$", "itemId", "]", ")", ")", "{", "$", "found", "=", "$", "this", "->", "daoPvQuoteItem", "->", "getById", "(", "(", "int", ")", "$", "itemId", ")", ";", "$", "this", "->", "cachePvQuoteItem", "[", "$", "itemId", "]", "=", "$", "found", ";", "}", "return", "$", "this", "->", "cachePvQuoteItem", "[", "$", "itemId", "]", ";", "}" ]
Cacheable loader for quote item's PV. @param int $itemId @return \Praxigento\Pv\Repo\Data\Quote\Item
[ "Cacheable", "loader", "for", "quote", "item", "s", "PV", "." ]
d1540b7e94264527006e8b9fa68904a72a63928e
https://github.com/praxigento/mobi_mod_pv/blob/d1540b7e94264527006e8b9fa68904a72a63928e/Helper/PvProvider.php#L138-L145
train
dmitrya2e/filtration-bundle
Filter/Collection/BaseCollection.php
BaseCollection.remove
protected function remove($filterOrName) { $name = $this->getNameByFilter($filterOrName); if ($this->has($name)) { unset($this->collection[$name]); return true; } return false; }
php
protected function remove($filterOrName) { $name = $this->getNameByFilter($filterOrName); if ($this->has($name)) { unset($this->collection[$name]); return true; } return false; }
[ "protected", "function", "remove", "(", "$", "filterOrName", ")", "{", "$", "name", "=", "$", "this", "->", "getNameByFilter", "(", "$", "filterOrName", ")", ";", "if", "(", "$", "this", "->", "has", "(", "$", "name", ")", ")", "{", "unset", "(", "$", "this", "->", "collection", "[", "$", "name", "]", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Removes a filter from the collection. @param string|FilterInterface $filterOrName @return bool True on success, false on failure (if the filter is not found in the collection)
[ "Removes", "a", "filter", "from", "the", "collection", "." ]
fed5764af4e43871835744fb84957b2a76e9a215
https://github.com/dmitrya2e/filtration-bundle/blob/fed5764af4e43871835744fb84957b2a76e9a215/Filter/Collection/BaseCollection.php#L91-L102
train
phpguard/listen
src/PhpGuard/Listen/Util/PathUtil.php
PathUtil.createSplFileInfo
static public function createSplFileInfo($baseDir, $path) { $absPath = realpath($path); $baseDirLen = strlen($baseDir); if($baseDir === substr($absPath,0,$baseDirLen)){ $subPathName = ltrim(substr($absPath,$baseDirLen),'\\/'); $dir = dirname($subPathName); $subPath = '.' === $dir ? '':$dir; }else{ $subPath = $subPathName = ''; } return new SplFileInfo($absPath,$subPath,$subPathName); }
php
static public function createSplFileInfo($baseDir, $path) { $absPath = realpath($path); $baseDirLen = strlen($baseDir); if($baseDir === substr($absPath,0,$baseDirLen)){ $subPathName = ltrim(substr($absPath,$baseDirLen),'\\/'); $dir = dirname($subPathName); $subPath = '.' === $dir ? '':$dir; }else{ $subPath = $subPathName = ''; } return new SplFileInfo($absPath,$subPath,$subPathName); }
[ "static", "public", "function", "createSplFileInfo", "(", "$", "baseDir", ",", "$", "path", ")", "{", "$", "absPath", "=", "realpath", "(", "$", "path", ")", ";", "$", "baseDirLen", "=", "strlen", "(", "$", "baseDir", ")", ";", "if", "(", "$", "baseDir", "===", "substr", "(", "$", "absPath", ",", "0", ",", "$", "baseDirLen", ")", ")", "{", "$", "subPathName", "=", "ltrim", "(", "substr", "(", "$", "absPath", ",", "$", "baseDirLen", ")", ",", "'\\\\/'", ")", ";", "$", "dir", "=", "dirname", "(", "$", "subPathName", ")", ";", "$", "subPath", "=", "'.'", "===", "$", "dir", "?", "''", ":", "$", "dir", ";", "}", "else", "{", "$", "subPath", "=", "$", "subPathName", "=", "''", ";", "}", "return", "new", "SplFileInfo", "(", "$", "absPath", ",", "$", "subPath", ",", "$", "subPathName", ")", ";", "}" ]
Generate SplFileInfo from base dir @param string $baseDir Base dir for path @param string $path A file/directory name @return SplFileInfo
[ "Generate", "SplFileInfo", "from", "base", "dir" ]
cd0cda150858d6d85deb025a72996873d2af3532
https://github.com/phpguard/listen/blob/cd0cda150858d6d85deb025a72996873d2af3532/src/PhpGuard/Listen/Util/PathUtil.php#L29-L43
train
miguelibero/meinhof
src/Meinhof/Config/Loader/TemplateMatterLoader.php
TemplateMatterLoader.loadStorage
protected function loadStorage($resource) { $template = $this->parser->parse($resource); $key = $template->getLogicalName(); if (isset($this->cache[$key])) { return $this->cache[$key]; } $storage = $this->template_loader->load($template); if (!$storage instanceof MatterStorage) { throw new \RuntimeException(sprintf('The template "%s" does not have matter.', $template)); } return $this->cache[$key] = $storage; }
php
protected function loadStorage($resource) { $template = $this->parser->parse($resource); $key = $template->getLogicalName(); if (isset($this->cache[$key])) { return $this->cache[$key]; } $storage = $this->template_loader->load($template); if (!$storage instanceof MatterStorage) { throw new \RuntimeException(sprintf('The template "%s" does not have matter.', $template)); } return $this->cache[$key] = $storage; }
[ "protected", "function", "loadStorage", "(", "$", "resource", ")", "{", "$", "template", "=", "$", "this", "->", "parser", "->", "parse", "(", "$", "resource", ")", ";", "$", "key", "=", "$", "template", "->", "getLogicalName", "(", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "cache", "[", "$", "key", "]", ")", ")", "{", "return", "$", "this", "->", "cache", "[", "$", "key", "]", ";", "}", "$", "storage", "=", "$", "this", "->", "template_loader", "->", "load", "(", "$", "template", ")", ";", "if", "(", "!", "$", "storage", "instanceof", "MatterStorage", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "sprintf", "(", "'The template \"%s\" does not have matter.'", ",", "$", "template", ")", ")", ";", "}", "return", "$", "this", "->", "cache", "[", "$", "key", "]", "=", "$", "storage", ";", "}" ]
Loads a resource from the template loader @param string $resource the name of the resource to load @throws \RuntimeException if the template loader does not return a MatterStorage
[ "Loads", "a", "resource", "from", "the", "template", "loader" ]
3a090f08485dc0da3e27463cf349dba374201072
https://github.com/miguelibero/meinhof/blob/3a090f08485dc0da3e27463cf349dba374201072/src/Meinhof/Config/Loader/TemplateMatterLoader.php#L83-L98
train
ZFrapid/zfrapid-core
src/Console/Console.php
Console.write
public function write($text, $color = null, $bgColor = null) { $this->adapter->write($text, $color, $bgColor); }
php
public function write($text, $color = null, $bgColor = null) { $this->adapter->write($text, $color, $bgColor); }
[ "public", "function", "write", "(", "$", "text", ",", "$", "color", "=", "null", ",", "$", "bgColor", "=", "null", ")", "{", "$", "this", "->", "adapter", "->", "write", "(", "$", "text", ",", "$", "color", ",", "$", "bgColor", ")", ";", "}" ]
Write a chunk of text to console. @param string $text @param null|int $color @param null|int $bgColor @return void
[ "Write", "a", "chunk", "of", "text", "to", "console", "." ]
8be56b82f9f5a687619a2b2175fcaa66ad3d2233
https://github.com/ZFrapid/zfrapid-core/blob/8be56b82f9f5a687619a2b2175fcaa66ad3d2233/src/Console/Console.php#L71-L74
train
ZFrapid/zfrapid-core
src/Console/Console.php
Console.writeLine
public function writeLine($text = "", $color = null, $bgColor = null) { $this->adapter->writeLine($text, $color, $bgColor); }
php
public function writeLine($text = "", $color = null, $bgColor = null) { $this->adapter->writeLine($text, $color, $bgColor); }
[ "public", "function", "writeLine", "(", "$", "text", "=", "\"\"", ",", "$", "color", "=", "null", ",", "$", "bgColor", "=", "null", ")", "{", "$", "this", "->", "adapter", "->", "writeLine", "(", "$", "text", ",", "$", "color", ",", "$", "bgColor", ")", ";", "}" ]
Write a single line of text to console and advance cursor to the next line. If the text is longer than console width it will be truncated. @param string $text @param null|int $color @param null|int $bgColor @return void
[ "Write", "a", "single", "line", "of", "text", "to", "console", "and", "advance", "cursor", "to", "the", "next", "line", ".", "If", "the", "text", "is", "longer", "than", "console", "width", "it", "will", "be", "truncated", "." ]
8be56b82f9f5a687619a2b2175fcaa66ad3d2233
https://github.com/ZFrapid/zfrapid-core/blob/8be56b82f9f5a687619a2b2175fcaa66ad3d2233/src/Console/Console.php#L100-L103
train
ZFrapid/zfrapid-core
src/Console/Console.php
Console.writeTextBlock
public function writeTextBlock( $text, $width, $height = null, $x = 0, $y = 0, $color = null, $bgColor = null ) { $this->adapter->writeTextBlock( $text, $width, $height, $x, $y, $color, $bgColor ); }
php
public function writeTextBlock( $text, $width, $height = null, $x = 0, $y = 0, $color = null, $bgColor = null ) { $this->adapter->writeTextBlock( $text, $width, $height, $x, $y, $color, $bgColor ); }
[ "public", "function", "writeTextBlock", "(", "$", "text", ",", "$", "width", ",", "$", "height", "=", "null", ",", "$", "x", "=", "0", ",", "$", "y", "=", "0", ",", "$", "color", "=", "null", ",", "$", "bgColor", "=", "null", ")", "{", "$", "this", "->", "adapter", "->", "writeTextBlock", "(", "$", "text", ",", "$", "width", ",", "$", "height", ",", "$", "x", ",", "$", "y", ",", "$", "color", ",", "$", "bgColor", ")", ";", "}" ]
Write a block of text at the given coordinates, matching the supplied width and height. In case a line of text does not fit desired width, it will be wrapped to the next line. In case the whole text does not fit in desired height, it will be truncated. @param string $text Text to write @param int $width Maximum block width. Negative value means distance from right edge. @param int|null $height Maximum block height. Negative value means distance from bottom edge. @param int $x Block X coordinate (column) @param int $y Block Y coordinate (row) @param null|int $color (optional) Text color @param null|int $bgColor (optional) Text background color @return void
[ "Write", "a", "block", "of", "text", "at", "the", "given", "coordinates", "matching", "the", "supplied", "width", "and", "height", ".", "In", "case", "a", "line", "of", "text", "does", "not", "fit", "desired", "width", "it", "will", "be", "wrapped", "to", "the", "next", "line", ".", "In", "case", "the", "whole", "text", "does", "not", "fit", "in", "desired", "height", "it", "will", "be", "truncated", "." ]
8be56b82f9f5a687619a2b2175fcaa66ad3d2233
https://github.com/ZFrapid/zfrapid-core/blob/8be56b82f9f5a687619a2b2175fcaa66ad3d2233/src/Console/Console.php#L172-L184
train
ZFrapid/zfrapid-core
src/Console/Console.php
Console.colorize
public function colorize($string, $color = null, $bgColor = null) { return $this->adapter->colorize($string, $color, $bgColor); }
php
public function colorize($string, $color = null, $bgColor = null) { return $this->adapter->colorize($string, $color, $bgColor); }
[ "public", "function", "colorize", "(", "$", "string", ",", "$", "color", "=", "null", ",", "$", "bgColor", "=", "null", ")", "{", "return", "$", "this", "->", "adapter", "->", "colorize", "(", "$", "string", ",", "$", "color", ",", "$", "bgColor", ")", ";", "}" ]
Prepare a string that will be rendered in color. @param string $string @param null|int $color Foreground color @param null|int $bgColor Background color @return string
[ "Prepare", "a", "string", "that", "will", "be", "rendered", "in", "color", "." ]
8be56b82f9f5a687619a2b2175fcaa66ad3d2233
https://github.com/ZFrapid/zfrapid-core/blob/8be56b82f9f5a687619a2b2175fcaa66ad3d2233/src/Console/Console.php#L278-L281
train
ZFrapid/zfrapid-core
src/Console/Console.php
Console.writeSelectPrompt
public function writeSelectPrompt($message, &$options) { $this->writeLine(); // translate options foreach ($options as $optionKey => $optionValue) { $options[$optionKey] = $this->translator->translate($optionValue); } // write prompt badge $this->writeBadge('badge_pick', Color::RED); // output prompt $prompt = new Select( $this->translator->translate($message), $options, false, false ); $answer = $prompt->show(); $this->writeLine(); return strtolower($answer); }
php
public function writeSelectPrompt($message, &$options) { $this->writeLine(); // translate options foreach ($options as $optionKey => $optionValue) { $options[$optionKey] = $this->translator->translate($optionValue); } // write prompt badge $this->writeBadge('badge_pick', Color::RED); // output prompt $prompt = new Select( $this->translator->translate($message), $options, false, false ); $answer = $prompt->show(); $this->writeLine(); return strtolower($answer); }
[ "public", "function", "writeSelectPrompt", "(", "$", "message", ",", "&", "$", "options", ")", "{", "$", "this", "->", "writeLine", "(", ")", ";", "// translate options", "foreach", "(", "$", "options", "as", "$", "optionKey", "=>", "$", "optionValue", ")", "{", "$", "options", "[", "$", "optionKey", "]", "=", "$", "this", "->", "translator", "->", "translate", "(", "$", "optionValue", ")", ";", "}", "// write prompt badge", "$", "this", "->", "writeBadge", "(", "'badge_pick'", ",", "Color", "::", "RED", ")", ";", "// output prompt", "$", "prompt", "=", "new", "Select", "(", "$", "this", "->", "translator", "->", "translate", "(", "$", "message", ")", ",", "$", "options", ",", "false", ",", "false", ")", ";", "$", "answer", "=", "$", "prompt", "->", "show", "(", ")", ";", "$", "this", "->", "writeLine", "(", ")", ";", "return", "strtolower", "(", "$", "answer", ")", ";", "}" ]
Write a customizable prompt @param $message @param $options @return string
[ "Write", "a", "customizable", "prompt" ]
8be56b82f9f5a687619a2b2175fcaa66ad3d2233
https://github.com/ZFrapid/zfrapid-core/blob/8be56b82f9f5a687619a2b2175fcaa66ad3d2233/src/Console/Console.php#L409-L434
train
ZFrapid/zfrapid-core
src/Console/Console.php
Console.writeLinePrompt
public function writeLinePrompt($message) { $this->writeLine(); // write prompt badge $this->writeBadge('badge_pick', Color::RED); // output prompt $prompt = new Line( $this->translator->translate($message), false ); $answer = $prompt->show(); $this->writeLine(); return $answer; }
php
public function writeLinePrompt($message) { $this->writeLine(); // write prompt badge $this->writeBadge('badge_pick', Color::RED); // output prompt $prompt = new Line( $this->translator->translate($message), false ); $answer = $prompt->show(); $this->writeLine(); return $answer; }
[ "public", "function", "writeLinePrompt", "(", "$", "message", ")", "{", "$", "this", "->", "writeLine", "(", ")", ";", "// write prompt badge", "$", "this", "->", "writeBadge", "(", "'badge_pick'", ",", "Color", "::", "RED", ")", ";", "// output prompt", "$", "prompt", "=", "new", "Line", "(", "$", "this", "->", "translator", "->", "translate", "(", "$", "message", ")", ",", "false", ")", ";", "$", "answer", "=", "$", "prompt", "->", "show", "(", ")", ";", "$", "this", "->", "writeLine", "(", ")", ";", "return", "$", "answer", ";", "}" ]
Write a customizable line prompt @param $message @return string
[ "Write", "a", "customizable", "line", "prompt" ]
8be56b82f9f5a687619a2b2175fcaa66ad3d2233
https://github.com/ZFrapid/zfrapid-core/blob/8be56b82f9f5a687619a2b2175fcaa66ad3d2233/src/Console/Console.php#L443-L461
train
ZFrapid/zfrapid-core
src/Console/Console.php
Console.writeConfirmPrompt
public function writeConfirmPrompt($message, $yes, $no) { $this->writeLine(); // write prompt badge $this->writeBadge('badge_pick', Color::RED); // output prompt $prompt = new Confirm( $this->translator->translate($message), $this->translator->translate($yes), $this->translator->translate($no) ); $answer = $prompt->show(); return $answer; }
php
public function writeConfirmPrompt($message, $yes, $no) { $this->writeLine(); // write prompt badge $this->writeBadge('badge_pick', Color::RED); // output prompt $prompt = new Confirm( $this->translator->translate($message), $this->translator->translate($yes), $this->translator->translate($no) ); $answer = $prompt->show(); return $answer; }
[ "public", "function", "writeConfirmPrompt", "(", "$", "message", ",", "$", "yes", ",", "$", "no", ")", "{", "$", "this", "->", "writeLine", "(", ")", ";", "// write prompt badge", "$", "this", "->", "writeBadge", "(", "'badge_pick'", ",", "Color", "::", "RED", ")", ";", "// output prompt", "$", "prompt", "=", "new", "Confirm", "(", "$", "this", "->", "translator", "->", "translate", "(", "$", "message", ")", ",", "$", "this", "->", "translator", "->", "translate", "(", "$", "yes", ")", ",", "$", "this", "->", "translator", "->", "translate", "(", "$", "no", ")", ")", ";", "$", "answer", "=", "$", "prompt", "->", "show", "(", ")", ";", "return", "$", "answer", ";", "}" ]
Write a customizable confirm prompt @param string $message @param string $yes @param string $no @return bool
[ "Write", "a", "customizable", "confirm", "prompt" ]
8be56b82f9f5a687619a2b2175fcaa66ad3d2233
https://github.com/ZFrapid/zfrapid-core/blob/8be56b82f9f5a687619a2b2175fcaa66ad3d2233/src/Console/Console.php#L472-L489
train
ZFrapid/zfrapid-core
src/Console/Console.php
Console.writeBadge
public function writeBadge($badgeText, $badgeColor) { $this->adapter->write( $this->translator->translate($badgeText), Color::NORMAL, $badgeColor ); $this->adapter->write(' '); }
php
public function writeBadge($badgeText, $badgeColor) { $this->adapter->write( $this->translator->translate($badgeText), Color::NORMAL, $badgeColor ); $this->adapter->write(' '); }
[ "public", "function", "writeBadge", "(", "$", "badgeText", ",", "$", "badgeColor", ")", "{", "$", "this", "->", "adapter", "->", "write", "(", "$", "this", "->", "translator", "->", "translate", "(", "$", "badgeText", ")", ",", "Color", "::", "NORMAL", ",", "$", "badgeColor", ")", ";", "$", "this", "->", "adapter", "->", "write", "(", "' '", ")", ";", "}" ]
Write a customizable badge @param string $badgeText @param string $badgeColor
[ "Write", "a", "customizable", "badge" ]
8be56b82f9f5a687619a2b2175fcaa66ad3d2233
https://github.com/ZFrapid/zfrapid-core/blob/8be56b82f9f5a687619a2b2175fcaa66ad3d2233/src/Console/Console.php#L497-L505
train
ZFrapid/zfrapid-core
src/Console/Console.php
Console.writeBadgeLine
public function writeBadgeLine( $message, array $placeholders = [], $badgeText, $badgeColor, $preNewLine = false, $postNewLine = false ) { if ($preNewLine) { $this->adapter->writeLine(); } $this->adapter->write( $this->translator->translate($badgeText), Color::NORMAL, $badgeColor ); $this->adapter->write(' '); $this->adapter->writeLine( vsprintf($this->translator->translate($message), $placeholders) ); if ($postNewLine) { $this->adapter->writeLine(); } }
php
public function writeBadgeLine( $message, array $placeholders = [], $badgeText, $badgeColor, $preNewLine = false, $postNewLine = false ) { if ($preNewLine) { $this->adapter->writeLine(); } $this->adapter->write( $this->translator->translate($badgeText), Color::NORMAL, $badgeColor ); $this->adapter->write(' '); $this->adapter->writeLine( vsprintf($this->translator->translate($message), $placeholders) ); if ($postNewLine) { $this->adapter->writeLine(); } }
[ "public", "function", "writeBadgeLine", "(", "$", "message", ",", "array", "$", "placeholders", "=", "[", "]", ",", "$", "badgeText", ",", "$", "badgeColor", ",", "$", "preNewLine", "=", "false", ",", "$", "postNewLine", "=", "false", ")", "{", "if", "(", "$", "preNewLine", ")", "{", "$", "this", "->", "adapter", "->", "writeLine", "(", ")", ";", "}", "$", "this", "->", "adapter", "->", "write", "(", "$", "this", "->", "translator", "->", "translate", "(", "$", "badgeText", ")", ",", "Color", "::", "NORMAL", ",", "$", "badgeColor", ")", ";", "$", "this", "->", "adapter", "->", "write", "(", "' '", ")", ";", "$", "this", "->", "adapter", "->", "writeLine", "(", "vsprintf", "(", "$", "this", "->", "translator", "->", "translate", "(", "$", "message", ")", ",", "$", "placeholders", ")", ")", ";", "if", "(", "$", "postNewLine", ")", "{", "$", "this", "->", "adapter", "->", "writeLine", "(", ")", ";", "}", "}" ]
Write a line with customizable badge @param string $message @param array $placeholders @param string $badgeText @param string $badgeColor @param bool $preNewLine @param bool $postNewLine
[ "Write", "a", "line", "with", "customizable", "badge" ]
8be56b82f9f5a687619a2b2175fcaa66ad3d2233
https://github.com/ZFrapid/zfrapid-core/blob/8be56b82f9f5a687619a2b2175fcaa66ad3d2233/src/Console/Console.php#L517-L539
train
ZFrapid/zfrapid-core
src/Console/Console.php
Console.writeListItemLineLevel3
public function writeListItemLineLevel3($message, array $placeholders = []) { $this->adapter->write(' * '); $this->adapter->writeLine( vsprintf($this->translator->translate($message), $placeholders) ); }
php
public function writeListItemLineLevel3($message, array $placeholders = []) { $this->adapter->write(' * '); $this->adapter->writeLine( vsprintf($this->translator->translate($message), $placeholders) ); }
[ "public", "function", "writeListItemLineLevel3", "(", "$", "message", ",", "array", "$", "placeholders", "=", "[", "]", ")", "{", "$", "this", "->", "adapter", "->", "write", "(", "' * '", ")", ";", "$", "this", "->", "adapter", "->", "writeLine", "(", "vsprintf", "(", "$", "this", "->", "translator", "->", "translate", "(", "$", "message", ")", ",", "$", "placeholders", ")", ")", ";", "}" ]
Write a list item line for third level @param string $message @param array $placeholders
[ "Write", "a", "list", "item", "line", "for", "third", "level" ]
8be56b82f9f5a687619a2b2175fcaa66ad3d2233
https://github.com/ZFrapid/zfrapid-core/blob/8be56b82f9f5a687619a2b2175fcaa66ad3d2233/src/Console/Console.php#L590-L596
train
ZFrapid/zfrapid-core
src/Console/Console.php
Console.writeGoLine
public function writeGoLine($message, array $placeholders = []) { $this->writeBadgeLine( $message, $placeholders, 'badge_go', Color::YELLOW, false, true ); }
php
public function writeGoLine($message, array $placeholders = []) { $this->writeBadgeLine( $message, $placeholders, 'badge_go', Color::YELLOW, false, true ); }
[ "public", "function", "writeGoLine", "(", "$", "message", ",", "array", "$", "placeholders", "=", "[", "]", ")", "{", "$", "this", "->", "writeBadgeLine", "(", "$", "message", ",", "$", "placeholders", ",", "'badge_go'", ",", "Color", "::", "YELLOW", ",", "false", ",", "true", ")", ";", "}" ]
Write a line with a yellow GO badge @param string $message @param array $placeholders
[ "Write", "a", "line", "with", "a", "yellow", "GO", "badge" ]
8be56b82f9f5a687619a2b2175fcaa66ad3d2233
https://github.com/ZFrapid/zfrapid-core/blob/8be56b82f9f5a687619a2b2175fcaa66ad3d2233/src/Console/Console.php#L604-L609
train
ZFrapid/zfrapid-core
src/Console/Console.php
Console.writeTaskLine
public function writeTaskLine($message, array $placeholders = []) { $this->writeBadgeLine( $message, $placeholders, 'badge_task', Color::BLUE, false, false ); }
php
public function writeTaskLine($message, array $placeholders = []) { $this->writeBadgeLine( $message, $placeholders, 'badge_task', Color::BLUE, false, false ); }
[ "public", "function", "writeTaskLine", "(", "$", "message", ",", "array", "$", "placeholders", "=", "[", "]", ")", "{", "$", "this", "->", "writeBadgeLine", "(", "$", "message", ",", "$", "placeholders", ",", "'badge_task'", ",", "Color", "::", "BLUE", ",", "false", ",", "false", ")", ";", "}" ]
Write a line with a Blue Done badge @param string $message @param array $placeholders
[ "Write", "a", "line", "with", "a", "Blue", "Done", "badge" ]
8be56b82f9f5a687619a2b2175fcaa66ad3d2233
https://github.com/ZFrapid/zfrapid-core/blob/8be56b82f9f5a687619a2b2175fcaa66ad3d2233/src/Console/Console.php#L617-L622
train
ZFrapid/zfrapid-core
src/Console/Console.php
Console.writeOkLine
public function writeOkLine($message, array $placeholders = []) { $this->writeBadgeLine( $message, $placeholders, 'badge_ok', Color::GREEN, true, true ); }
php
public function writeOkLine($message, array $placeholders = []) { $this->writeBadgeLine( $message, $placeholders, 'badge_ok', Color::GREEN, true, true ); }
[ "public", "function", "writeOkLine", "(", "$", "message", ",", "array", "$", "placeholders", "=", "[", "]", ")", "{", "$", "this", "->", "writeBadgeLine", "(", "$", "message", ",", "$", "placeholders", ",", "'badge_ok'", ",", "Color", "::", "GREEN", ",", "true", ",", "true", ")", ";", "}" ]
Write a line with a green OK badge @param string $message @param array $placeholders
[ "Write", "a", "line", "with", "a", "green", "OK", "badge" ]
8be56b82f9f5a687619a2b2175fcaa66ad3d2233
https://github.com/ZFrapid/zfrapid-core/blob/8be56b82f9f5a687619a2b2175fcaa66ad3d2233/src/Console/Console.php#L630-L635
train
ZFrapid/zfrapid-core
src/Console/Console.php
Console.writeFailLine
public function writeFailLine($message, array $placeholders = []) { $this->writeBadgeLine( $message, $placeholders, 'badge_fail', Color::RED, true, true ); }
php
public function writeFailLine($message, array $placeholders = []) { $this->writeBadgeLine( $message, $placeholders, 'badge_fail', Color::RED, true, true ); }
[ "public", "function", "writeFailLine", "(", "$", "message", ",", "array", "$", "placeholders", "=", "[", "]", ")", "{", "$", "this", "->", "writeBadgeLine", "(", "$", "message", ",", "$", "placeholders", ",", "'badge_fail'", ",", "Color", "::", "RED", ",", "true", ",", "true", ")", ";", "}" ]
Write a line with a red Fail badge @param string $message @param array $placeholders
[ "Write", "a", "line", "with", "a", "red", "Fail", "badge" ]
8be56b82f9f5a687619a2b2175fcaa66ad3d2233
https://github.com/ZFrapid/zfrapid-core/blob/8be56b82f9f5a687619a2b2175fcaa66ad3d2233/src/Console/Console.php#L643-L648
train
ZFrapid/zfrapid-core
src/Console/Console.php
Console.writeWarnLine
public function writeWarnLine($message, array $placeholders = []) { $this->writeBadgeLine( $message, $placeholders, 'badge_warning', Color::RED, true, true ); }
php
public function writeWarnLine($message, array $placeholders = []) { $this->writeBadgeLine( $message, $placeholders, 'badge_warning', Color::RED, true, true ); }
[ "public", "function", "writeWarnLine", "(", "$", "message", ",", "array", "$", "placeholders", "=", "[", "]", ")", "{", "$", "this", "->", "writeBadgeLine", "(", "$", "message", ",", "$", "placeholders", ",", "'badge_warning'", ",", "Color", "::", "RED", ",", "true", ",", "true", ")", ";", "}" ]
Write a line with a red Warn badge @param string $message @param array $placeholders
[ "Write", "a", "line", "with", "a", "red", "Warn", "badge" ]
8be56b82f9f5a687619a2b2175fcaa66ad3d2233
https://github.com/ZFrapid/zfrapid-core/blob/8be56b82f9f5a687619a2b2175fcaa66ad3d2233/src/Console/Console.php#L656-L661
train
ZFrapid/zfrapid-core
src/Console/Console.php
Console.writeTodoLine
public function writeTodoLine($message, array $placeholders = []) { $this->writeBadgeLine( $message, $placeholders, 'badge_todo', Color::GREEN, false, true ); }
php
public function writeTodoLine($message, array $placeholders = []) { $this->writeBadgeLine( $message, $placeholders, 'badge_todo', Color::GREEN, false, true ); }
[ "public", "function", "writeTodoLine", "(", "$", "message", ",", "array", "$", "placeholders", "=", "[", "]", ")", "{", "$", "this", "->", "writeBadgeLine", "(", "$", "message", ",", "$", "placeholders", ",", "'badge_todo'", ",", "Color", "::", "GREEN", ",", "false", ",", "true", ")", ";", "}" ]
Write a line with a yellow to-do badge @param string $message @param array $placeholders
[ "Write", "a", "line", "with", "a", "yellow", "to", "-", "do", "badge" ]
8be56b82f9f5a687619a2b2175fcaa66ad3d2233
https://github.com/ZFrapid/zfrapid-core/blob/8be56b82f9f5a687619a2b2175fcaa66ad3d2233/src/Console/Console.php#L669-L674
train
mitogh/Katana
src/Helpers/Formatter.php
Formatter.katana_filter
public static function katana_filter( $param = '' ) { if ( $param ) { $param = trim( $param, ' _' ); return sprintf( '%s_%s', Config::KATANA_FILTER, $param ); } else { return Config::KATANA_FILTER; } }
php
public static function katana_filter( $param = '' ) { if ( $param ) { $param = trim( $param, ' _' ); return sprintf( '%s_%s', Config::KATANA_FILTER, $param ); } else { return Config::KATANA_FILTER; } }
[ "public", "static", "function", "katana_filter", "(", "$", "param", "=", "''", ")", "{", "if", "(", "$", "param", ")", "{", "$", "param", "=", "trim", "(", "$", "param", ",", "' _'", ")", ";", "return", "sprintf", "(", "'%s_%s'", ",", "Config", "::", "KATANA_FILTER", ",", "$", "param", ")", ";", "}", "else", "{", "return", "Config", "::", "KATANA_FILTER", ";", "}", "}" ]
Creates a specific katana filter based on a param, like a post_id, a page template name or similar. @param string $param The suffix of the filter. @return string KATANA_FILTER by default and adding a suffix is param is provided. @since 2.0.0
[ "Creates", "a", "specific", "katana", "filter", "based", "on", "a", "param", "like", "a", "post_id", "a", "page", "template", "name", "or", "similar", "." ]
9eb7267f061fbe555dbe9c12461650bb4153915f
https://github.com/mitogh/Katana/blob/9eb7267f061fbe555dbe9c12461650bb4153915f/src/Helpers/Formatter.php#L40-L47
train
eliasis-framework/wp-plugin-info
src/controller/class-main.php
Main.get
public function get( $option, $slug ) { if ( $this->is_active() ) { $this->prepare( $slug ); $slug = $this->slug; if ( isset( $this->plugin[ $slug ][ $option ] ) ) { return $this->plugin[ $slug ][ $option ]; } elseif ( '*' == $option && isset( $this->plugin[ $slug ] ) ) { return $this->plugin[ $slug ]; } return false; } }
php
public function get( $option, $slug ) { if ( $this->is_active() ) { $this->prepare( $slug ); $slug = $this->slug; if ( isset( $this->plugin[ $slug ][ $option ] ) ) { return $this->plugin[ $slug ][ $option ]; } elseif ( '*' == $option && isset( $this->plugin[ $slug ] ) ) { return $this->plugin[ $slug ]; } return false; } }
[ "public", "function", "get", "(", "$", "option", ",", "$", "slug", ")", "{", "if", "(", "$", "this", "->", "is_active", "(", ")", ")", "{", "$", "this", "->", "prepare", "(", "$", "slug", ")", ";", "$", "slug", "=", "$", "this", "->", "slug", ";", "if", "(", "isset", "(", "$", "this", "->", "plugin", "[", "$", "slug", "]", "[", "$", "option", "]", ")", ")", "{", "return", "$", "this", "->", "plugin", "[", "$", "slug", "]", "[", "$", "option", "]", ";", "}", "elseif", "(", "'*'", "==", "$", "option", "&&", "isset", "(", "$", "this", "->", "plugin", "[", "$", "slug", "]", ")", ")", "{", "return", "$", "this", "->", "plugin", "[", "$", "slug", "]", ";", "}", "return", "false", ";", "}", "}" ]
Get plugin options. @param string $option → option to get. @param string $slug → WordPress plugin slug. @return mixed → value or false
[ "Get", "plugin", "options", "." ]
052843260394a457c9f8336a07d1a986cfbc5860
https://github.com/eliasis-framework/wp-plugin-info/blob/052843260394a457c9f8336a07d1a986cfbc5860/src/controller/class-main.php#L45-L61
train
eliasis-framework/wp-plugin-info
src/controller/class-main.php
Main.is_updated
protected function is_updated() { if ( $this->is_active() && isset( $this->plugin[ $this->slug ]['last-update'] ) ) { $interval = Plugin::WP_Plugin_Info()->getOption( 'interval' ); $last_update = $this->plugin[ $this->slug ]['last-update']; if ( ( time() - $last_update ) < $interval ) { return true; } } return false; }
php
protected function is_updated() { if ( $this->is_active() && isset( $this->plugin[ $this->slug ]['last-update'] ) ) { $interval = Plugin::WP_Plugin_Info()->getOption( 'interval' ); $last_update = $this->plugin[ $this->slug ]['last-update']; if ( ( time() - $last_update ) < $interval ) { return true; } } return false; }
[ "protected", "function", "is_updated", "(", ")", "{", "if", "(", "$", "this", "->", "is_active", "(", ")", "&&", "isset", "(", "$", "this", "->", "plugin", "[", "$", "this", "->", "slug", "]", "[", "'last-update'", "]", ")", ")", "{", "$", "interval", "=", "Plugin", "::", "WP_Plugin_Info", "(", ")", "->", "getOption", "(", "'interval'", ")", ";", "$", "last_update", "=", "$", "this", "->", "plugin", "[", "$", "this", "->", "slug", "]", "[", "'last-update'", "]", ";", "if", "(", "(", "time", "(", ")", "-", "$", "last_update", ")", "<", "$", "interval", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Check the last update. @return bool
[ "Check", "the", "last", "update", "." ]
052843260394a457c9f8336a07d1a986cfbc5860
https://github.com/eliasis-framework/wp-plugin-info/blob/052843260394a457c9f8336a07d1a986cfbc5860/src/controller/class-main.php#L68-L81
train
eliasis-framework/wp-plugin-info
src/controller/class-main.php
Main.prepare
protected function prepare( $slug ) { $this->slug = $slug; $file = Plugin::WP_Plugin_Info()->getOption( 'file', 'plugins' ); if ( empty( $this->plugin ) ) { $this->plugin = $this->model->get_plugins_info( $file ); } if ( ! $this->is_updated() ) { $this->plugin[ $slug ] = $this->get_plugin_info( $slug ); $this->plugin[ $slug ]['last-update'] = time(); $this->model->set_plugins_info( $this->plugin, $file ); } }
php
protected function prepare( $slug ) { $this->slug = $slug; $file = Plugin::WP_Plugin_Info()->getOption( 'file', 'plugins' ); if ( empty( $this->plugin ) ) { $this->plugin = $this->model->get_plugins_info( $file ); } if ( ! $this->is_updated() ) { $this->plugin[ $slug ] = $this->get_plugin_info( $slug ); $this->plugin[ $slug ]['last-update'] = time(); $this->model->set_plugins_info( $this->plugin, $file ); } }
[ "protected", "function", "prepare", "(", "$", "slug", ")", "{", "$", "this", "->", "slug", "=", "$", "slug", ";", "$", "file", "=", "Plugin", "::", "WP_Plugin_Info", "(", ")", "->", "getOption", "(", "'file'", ",", "'plugins'", ")", ";", "if", "(", "empty", "(", "$", "this", "->", "plugin", ")", ")", "{", "$", "this", "->", "plugin", "=", "$", "this", "->", "model", "->", "get_plugins_info", "(", "$", "file", ")", ";", "}", "if", "(", "!", "$", "this", "->", "is_updated", "(", ")", ")", "{", "$", "this", "->", "plugin", "[", "$", "slug", "]", "=", "$", "this", "->", "get_plugin_info", "(", "$", "slug", ")", ";", "$", "this", "->", "plugin", "[", "$", "slug", "]", "[", "'last-update'", "]", "=", "time", "(", ")", ";", "$", "this", "->", "model", "->", "set_plugins_info", "(", "$", "this", "->", "plugin", ",", "$", "file", ")", ";", "}", "}" ]
Get plugin info. @param string $slug → WordPress plugin slug.
[ "Get", "plugin", "info", "." ]
052843260394a457c9f8336a07d1a986cfbc5860
https://github.com/eliasis-framework/wp-plugin-info/blob/052843260394a457c9f8336a07d1a986cfbc5860/src/controller/class-main.php#L98-L117
train
eliasis-framework/wp-plugin-info
src/controller/class-main.php
Main.get_plugin_info
protected function get_plugin_info( $slug ) { $args = (object) [ 'slug' => $slug ]; $request = [ 'action' => 'plugin_information', 'timeout' => 15, 'request' => serialize( $args ), ]; $url = Plugin::WP_Plugin_Info()->getOption( 'url', 'wp-api' ); $resp = wp_remote_post( $url, [ 'body' => $request ] ); $resp = isset( $resp['body'] ) ? unserialize( $resp['body'] ) : []; unset( $resp->sections, $resp->versions, $resp->screenshots ); return (array) $resp; }
php
protected function get_plugin_info( $slug ) { $args = (object) [ 'slug' => $slug ]; $request = [ 'action' => 'plugin_information', 'timeout' => 15, 'request' => serialize( $args ), ]; $url = Plugin::WP_Plugin_Info()->getOption( 'url', 'wp-api' ); $resp = wp_remote_post( $url, [ 'body' => $request ] ); $resp = isset( $resp['body'] ) ? unserialize( $resp['body'] ) : []; unset( $resp->sections, $resp->versions, $resp->screenshots ); return (array) $resp; }
[ "protected", "function", "get_plugin_info", "(", "$", "slug", ")", "{", "$", "args", "=", "(", "object", ")", "[", "'slug'", "=>", "$", "slug", "]", ";", "$", "request", "=", "[", "'action'", "=>", "'plugin_information'", ",", "'timeout'", "=>", "15", ",", "'request'", "=>", "serialize", "(", "$", "args", ")", ",", "]", ";", "$", "url", "=", "Plugin", "::", "WP_Plugin_Info", "(", ")", "->", "getOption", "(", "'url'", ",", "'wp-api'", ")", ";", "$", "resp", "=", "wp_remote_post", "(", "$", "url", ",", "[", "'body'", "=>", "$", "request", "]", ")", ";", "$", "resp", "=", "isset", "(", "$", "resp", "[", "'body'", "]", ")", "?", "unserialize", "(", "$", "resp", "[", "'body'", "]", ")", ":", "[", "]", ";", "unset", "(", "$", "resp", "->", "sections", ",", "$", "resp", "->", "versions", ",", "$", "resp", "->", "screenshots", ")", ";", "return", "(", "array", ")", "$", "resp", ";", "}" ]
Get plugin info in WordPress API. @param string $slug → WordPress plugin slug. @return array → plugin info
[ "Get", "plugin", "info", "in", "WordPress", "API", "." ]
052843260394a457c9f8336a07d1a986cfbc5860
https://github.com/eliasis-framework/wp-plugin-info/blob/052843260394a457c9f8336a07d1a986cfbc5860/src/controller/class-main.php#L126-L145
train
cloudtek/dynamodm
lib/Cloudtek/DynamoDM/Hydrator/HydratorFactory.php
HydratorFactory.hydrate
public function hydrate($document, $data, $readOnly = false) { $metadata = $this->dm->getClassMetadata(get_class($document)); // Invoke preLoad lifecycle events and listeners if (!empty($metadata->lifecycleCallbacks[Event::preLoad])) { $args = [new PreLoadEventArgs($document, $this->dm, $data)]; $metadata->invokeLifecycleCallbacks(Event::preLoad, $document, $args); } if ($this->evm->hasListeners(Event::preLoad)) { $this->evm->dispatchEvent(Event::preLoad, new PreLoadEventArgs($document, $this->dm, $data)); } // alsoLoadMethods may transform the document before hydration if (!empty($metadata->alsoLoadMethods)) { foreach ($metadata->alsoLoadMethods as $method => $attributeNames) { foreach ($attributeNames as $attributeName) { // Invoke the method only once for the first attribute we find if (array_key_exists($attributeName, $data)) { $value = Type::convertUnmappedToPHPValue($data[$attributeName]); $document->$method($value); continue 2; } } } } if ($document instanceof Proxy) { $document->__isInitialized__ = true; $document->__setInitializer(null); $document->__setCloner(null); } $data = $this->getHydratorFor($metadata->name)->hydrate($document, $data, $readOnly); if ($document instanceof Proxy) { // lazy properties may be left uninitialized $properties = $document->__getLazyProperties(); foreach ($properties as $propertyName => $property) { if (!isset($document->$propertyName)) { $document->$propertyName = $properties[$propertyName]; } } } // Invoke the postLoad lifecycle callbacks and listeners if (!empty($metadata->lifecycleCallbacks[Event::postLoad])) { $metadata->invokeLifecycleCallbacks(Event::postLoad, $document, [new LifecycleEventArgs($document, $this->dm)]); } if ($this->evm->hasListeners(Event::postLoad)) { $this->evm->dispatchEvent(Event::postLoad, new LifecycleEventArgs($document, $this->dm)); } return $data; }
php
public function hydrate($document, $data, $readOnly = false) { $metadata = $this->dm->getClassMetadata(get_class($document)); // Invoke preLoad lifecycle events and listeners if (!empty($metadata->lifecycleCallbacks[Event::preLoad])) { $args = [new PreLoadEventArgs($document, $this->dm, $data)]; $metadata->invokeLifecycleCallbacks(Event::preLoad, $document, $args); } if ($this->evm->hasListeners(Event::preLoad)) { $this->evm->dispatchEvent(Event::preLoad, new PreLoadEventArgs($document, $this->dm, $data)); } // alsoLoadMethods may transform the document before hydration if (!empty($metadata->alsoLoadMethods)) { foreach ($metadata->alsoLoadMethods as $method => $attributeNames) { foreach ($attributeNames as $attributeName) { // Invoke the method only once for the first attribute we find if (array_key_exists($attributeName, $data)) { $value = Type::convertUnmappedToPHPValue($data[$attributeName]); $document->$method($value); continue 2; } } } } if ($document instanceof Proxy) { $document->__isInitialized__ = true; $document->__setInitializer(null); $document->__setCloner(null); } $data = $this->getHydratorFor($metadata->name)->hydrate($document, $data, $readOnly); if ($document instanceof Proxy) { // lazy properties may be left uninitialized $properties = $document->__getLazyProperties(); foreach ($properties as $propertyName => $property) { if (!isset($document->$propertyName)) { $document->$propertyName = $properties[$propertyName]; } } } // Invoke the postLoad lifecycle callbacks and listeners if (!empty($metadata->lifecycleCallbacks[Event::postLoad])) { $metadata->invokeLifecycleCallbacks(Event::postLoad, $document, [new LifecycleEventArgs($document, $this->dm)]); } if ($this->evm->hasListeners(Event::postLoad)) { $this->evm->dispatchEvent(Event::postLoad, new LifecycleEventArgs($document, $this->dm)); } return $data; }
[ "public", "function", "hydrate", "(", "$", "document", ",", "$", "data", ",", "$", "readOnly", "=", "false", ")", "{", "$", "metadata", "=", "$", "this", "->", "dm", "->", "getClassMetadata", "(", "get_class", "(", "$", "document", ")", ")", ";", "// Invoke preLoad lifecycle events and listeners", "if", "(", "!", "empty", "(", "$", "metadata", "->", "lifecycleCallbacks", "[", "Event", "::", "preLoad", "]", ")", ")", "{", "$", "args", "=", "[", "new", "PreLoadEventArgs", "(", "$", "document", ",", "$", "this", "->", "dm", ",", "$", "data", ")", "]", ";", "$", "metadata", "->", "invokeLifecycleCallbacks", "(", "Event", "::", "preLoad", ",", "$", "document", ",", "$", "args", ")", ";", "}", "if", "(", "$", "this", "->", "evm", "->", "hasListeners", "(", "Event", "::", "preLoad", ")", ")", "{", "$", "this", "->", "evm", "->", "dispatchEvent", "(", "Event", "::", "preLoad", ",", "new", "PreLoadEventArgs", "(", "$", "document", ",", "$", "this", "->", "dm", ",", "$", "data", ")", ")", ";", "}", "// alsoLoadMethods may transform the document before hydration", "if", "(", "!", "empty", "(", "$", "metadata", "->", "alsoLoadMethods", ")", ")", "{", "foreach", "(", "$", "metadata", "->", "alsoLoadMethods", "as", "$", "method", "=>", "$", "attributeNames", ")", "{", "foreach", "(", "$", "attributeNames", "as", "$", "attributeName", ")", "{", "// Invoke the method only once for the first attribute we find", "if", "(", "array_key_exists", "(", "$", "attributeName", ",", "$", "data", ")", ")", "{", "$", "value", "=", "Type", "::", "convertUnmappedToPHPValue", "(", "$", "data", "[", "$", "attributeName", "]", ")", ";", "$", "document", "->", "$", "method", "(", "$", "value", ")", ";", "continue", "2", ";", "}", "}", "}", "}", "if", "(", "$", "document", "instanceof", "Proxy", ")", "{", "$", "document", "->", "__isInitialized__", "=", "true", ";", "$", "document", "->", "__setInitializer", "(", "null", ")", ";", "$", "document", "->", "__setCloner", "(", "null", ")", ";", "}", "$", "data", "=", "$", "this", "->", "getHydratorFor", "(", "$", "metadata", "->", "name", ")", "->", "hydrate", "(", "$", "document", ",", "$", "data", ",", "$", "readOnly", ")", ";", "if", "(", "$", "document", "instanceof", "Proxy", ")", "{", "// lazy properties may be left uninitialized", "$", "properties", "=", "$", "document", "->", "__getLazyProperties", "(", ")", ";", "foreach", "(", "$", "properties", "as", "$", "propertyName", "=>", "$", "property", ")", "{", "if", "(", "!", "isset", "(", "$", "document", "->", "$", "propertyName", ")", ")", "{", "$", "document", "->", "$", "propertyName", "=", "$", "properties", "[", "$", "propertyName", "]", ";", "}", "}", "}", "// Invoke the postLoad lifecycle callbacks and listeners", "if", "(", "!", "empty", "(", "$", "metadata", "->", "lifecycleCallbacks", "[", "Event", "::", "postLoad", "]", ")", ")", "{", "$", "metadata", "->", "invokeLifecycleCallbacks", "(", "Event", "::", "postLoad", ",", "$", "document", ",", "[", "new", "LifecycleEventArgs", "(", "$", "document", ",", "$", "this", "->", "dm", ")", "]", ")", ";", "}", "if", "(", "$", "this", "->", "evm", "->", "hasListeners", "(", "Event", "::", "postLoad", ")", ")", "{", "$", "this", "->", "evm", "->", "dispatchEvent", "(", "Event", "::", "postLoad", ",", "new", "LifecycleEventArgs", "(", "$", "document", ",", "$", "this", "->", "dm", ")", ")", ";", "}", "return", "$", "data", ";", "}" ]
Hydrate array of DynamoDB document data into the given document object. @param object $document The document object to hydrate the data into. @param array $data The array of document data. @param bool $readOnly @return array $values The array of hydrated values.
[ "Hydrate", "array", "of", "DynamoDB", "document", "data", "into", "the", "given", "document", "object", "." ]
119d355e2c5cbaef1f867970349b4432f5704fcd
https://github.com/cloudtek/dynamodm/blob/119d355e2c5cbaef1f867970349b4432f5704fcd/lib/Cloudtek/DynamoDM/Hydrator/HydratorFactory.php#L384-L437
train
anime-db/catalog-bundle
src/Service/Item/Search/Selector/Builder.php
Builder.addLabels
public function addLabels(Search $entity) { if ($entity->getLabels()->count()) { $this->add(function (QueryBuilder $query) use ($entity) { $ids = []; foreach ($entity->getLabels() as $label) { $ids[] = (int) $label->getId(); } $query ->innerJoin('i.labels', 'l') ->andWhere('l.id IN ('.implode(',', $ids).')'); }); $this->select->andHaving('COUNT(i.id) = '.$entity->getLabels()->count()); } return $this; }
php
public function addLabels(Search $entity) { if ($entity->getLabels()->count()) { $this->add(function (QueryBuilder $query) use ($entity) { $ids = []; foreach ($entity->getLabels() as $label) { $ids[] = (int) $label->getId(); } $query ->innerJoin('i.labels', 'l') ->andWhere('l.id IN ('.implode(',', $ids).')'); }); $this->select->andHaving('COUNT(i.id) = '.$entity->getLabels()->count()); } return $this; }
[ "public", "function", "addLabels", "(", "Search", "$", "entity", ")", "{", "if", "(", "$", "entity", "->", "getLabels", "(", ")", "->", "count", "(", ")", ")", "{", "$", "this", "->", "add", "(", "function", "(", "QueryBuilder", "$", "query", ")", "use", "(", "$", "entity", ")", "{", "$", "ids", "=", "[", "]", ";", "foreach", "(", "$", "entity", "->", "getLabels", "(", ")", "as", "$", "label", ")", "{", "$", "ids", "[", "]", "=", "(", "int", ")", "$", "label", "->", "getId", "(", ")", ";", "}", "$", "query", "->", "innerJoin", "(", "'i.labels'", ",", "'l'", ")", "->", "andWhere", "(", "'l.id IN ('", ".", "implode", "(", "','", ",", "$", "ids", ")", ".", "')'", ")", ";", "}", ")", ";", "$", "this", "->", "select", "->", "andHaving", "(", "'COUNT(i.id) = '", ".", "$", "entity", "->", "getLabels", "(", ")", "->", "count", "(", ")", ")", ";", "}", "return", "$", "this", ";", "}" ]
Add labels. @param Search $entity @return Builder
[ "Add", "labels", "." ]
631b6f92a654e91bee84f46218c52cf42bdb8606
https://github.com/anime-db/catalog-bundle/blob/631b6f92a654e91bee84f46218c52cf42bdb8606/src/Service/Item/Search/Selector/Builder.php#L224-L240
train
pixelpolishers/makedocs
src/MakeDocs/WebHook/GitHub/GitHub.php
GitHub.listen
public function listen() { if ($_SERVER['REQUEST_METHOD'] != 'POST') { throw new InvalidRequestException('Expected a POST request.'); } $remoteAddress = $this->getRemoteAddress(); if (!$this->isValidRemoteAddress($remoteAddress)) { throw new InvalidRequestException('Invalid remote address.'); } if (empty($_POST[$this->parameter])) { throw new InvalidRequestException('Expected the parameter ' . $this->parameter); } $payload = new Payload($_POST['payload']); $configuration = $this->getConfiguration($payload->getRepository()); if (!$configuration) { throw new InvalidRequestException('Invalid repository: ' . $payload->getRepository()); } if ($configuration->getDriver() != 'git') { throw new InvalidRequestException('Project is not a git repository but ' . $configuration->getDriver()); } $driverConfig = new DriverConfig(); $driverConfig->setDirectory($configuration->getSource()); $driverConfig->setBranch($payload->getBranch()); $driverConfig->setRepository($configuration->getRepository()); $driver = new GitDriver(); $driver->install($driverConfig); $generator = $this->configureGenerator($configuration, $payload); $generator->generate(); }
php
public function listen() { if ($_SERVER['REQUEST_METHOD'] != 'POST') { throw new InvalidRequestException('Expected a POST request.'); } $remoteAddress = $this->getRemoteAddress(); if (!$this->isValidRemoteAddress($remoteAddress)) { throw new InvalidRequestException('Invalid remote address.'); } if (empty($_POST[$this->parameter])) { throw new InvalidRequestException('Expected the parameter ' . $this->parameter); } $payload = new Payload($_POST['payload']); $configuration = $this->getConfiguration($payload->getRepository()); if (!$configuration) { throw new InvalidRequestException('Invalid repository: ' . $payload->getRepository()); } if ($configuration->getDriver() != 'git') { throw new InvalidRequestException('Project is not a git repository but ' . $configuration->getDriver()); } $driverConfig = new DriverConfig(); $driverConfig->setDirectory($configuration->getSource()); $driverConfig->setBranch($payload->getBranch()); $driverConfig->setRepository($configuration->getRepository()); $driver = new GitDriver(); $driver->install($driverConfig); $generator = $this->configureGenerator($configuration, $payload); $generator->generate(); }
[ "public", "function", "listen", "(", ")", "{", "if", "(", "$", "_SERVER", "[", "'REQUEST_METHOD'", "]", "!=", "'POST'", ")", "{", "throw", "new", "InvalidRequestException", "(", "'Expected a POST request.'", ")", ";", "}", "$", "remoteAddress", "=", "$", "this", "->", "getRemoteAddress", "(", ")", ";", "if", "(", "!", "$", "this", "->", "isValidRemoteAddress", "(", "$", "remoteAddress", ")", ")", "{", "throw", "new", "InvalidRequestException", "(", "'Invalid remote address.'", ")", ";", "}", "if", "(", "empty", "(", "$", "_POST", "[", "$", "this", "->", "parameter", "]", ")", ")", "{", "throw", "new", "InvalidRequestException", "(", "'Expected the parameter '", ".", "$", "this", "->", "parameter", ")", ";", "}", "$", "payload", "=", "new", "Payload", "(", "$", "_POST", "[", "'payload'", "]", ")", ";", "$", "configuration", "=", "$", "this", "->", "getConfiguration", "(", "$", "payload", "->", "getRepository", "(", ")", ")", ";", "if", "(", "!", "$", "configuration", ")", "{", "throw", "new", "InvalidRequestException", "(", "'Invalid repository: '", ".", "$", "payload", "->", "getRepository", "(", ")", ")", ";", "}", "if", "(", "$", "configuration", "->", "getDriver", "(", ")", "!=", "'git'", ")", "{", "throw", "new", "InvalidRequestException", "(", "'Project is not a git repository but '", ".", "$", "configuration", "->", "getDriver", "(", ")", ")", ";", "}", "$", "driverConfig", "=", "new", "DriverConfig", "(", ")", ";", "$", "driverConfig", "->", "setDirectory", "(", "$", "configuration", "->", "getSource", "(", ")", ")", ";", "$", "driverConfig", "->", "setBranch", "(", "$", "payload", "->", "getBranch", "(", ")", ")", ";", "$", "driverConfig", "->", "setRepository", "(", "$", "configuration", "->", "getRepository", "(", ")", ")", ";", "$", "driver", "=", "new", "GitDriver", "(", ")", ";", "$", "driver", "->", "install", "(", "$", "driverConfig", ")", ";", "$", "generator", "=", "$", "this", "->", "configureGenerator", "(", "$", "configuration", ",", "$", "payload", ")", ";", "$", "generator", "->", "generate", "(", ")", ";", "}" ]
Listens for incoming requests. @throws InvalidRequestException
[ "Listens", "for", "incoming", "requests", "." ]
1fa243b52565b5de417ef2dbdfbcae9896b6b483
https://github.com/pixelpolishers/makedocs/blob/1fa243b52565b5de417ef2dbdfbcae9896b6b483/src/MakeDocs/WebHook/GitHub/GitHub.php#L155-L190
train
jamset/process-load-manager
src/TerminatorPauseStander.php
TerminatorPauseStander.checkSubscription
public function checkSubscription() { if (!$this->subscriberSocket) { $this->subscriberSocket = $this->context->getSocket(\ZMQ::SOCKET_SUB); $this->subscriberSocket->connect($this->publisherPmSocketAddress); $this->subscriberSocket->setSockOpt(\ZMQ::SOCKOPT_SUBSCRIBE, ""); } $this->subscriptionMessage = @json_decode($this->subscriberSocket->recv(\ZMQ::MODE_DONTWAIT), true); if (($this->subscriptionMessage !== false) && ($this->subscriptionMessage !== null) && (is_array($this->subscriptionMessage) === false) ) { throw new ProcessManagerException("Not correct param from ProcessManager to TerminatorPauseStander: " . serialize($this->subscriptionMessage)); } if (isset($this->subscriptionMessage)) { $this->logger->info("Receive subscription message: " . serialize($this->subscriptionMessage)); $this->resolveAction(); } return null; }
php
public function checkSubscription() { if (!$this->subscriberSocket) { $this->subscriberSocket = $this->context->getSocket(\ZMQ::SOCKET_SUB); $this->subscriberSocket->connect($this->publisherPmSocketAddress); $this->subscriberSocket->setSockOpt(\ZMQ::SOCKOPT_SUBSCRIBE, ""); } $this->subscriptionMessage = @json_decode($this->subscriberSocket->recv(\ZMQ::MODE_DONTWAIT), true); if (($this->subscriptionMessage !== false) && ($this->subscriptionMessage !== null) && (is_array($this->subscriptionMessage) === false) ) { throw new ProcessManagerException("Not correct param from ProcessManager to TerminatorPauseStander: " . serialize($this->subscriptionMessage)); } if (isset($this->subscriptionMessage)) { $this->logger->info("Receive subscription message: " . serialize($this->subscriptionMessage)); $this->resolveAction(); } return null; }
[ "public", "function", "checkSubscription", "(", ")", "{", "if", "(", "!", "$", "this", "->", "subscriberSocket", ")", "{", "$", "this", "->", "subscriberSocket", "=", "$", "this", "->", "context", "->", "getSocket", "(", "\\", "ZMQ", "::", "SOCKET_SUB", ")", ";", "$", "this", "->", "subscriberSocket", "->", "connect", "(", "$", "this", "->", "publisherPmSocketAddress", ")", ";", "$", "this", "->", "subscriberSocket", "->", "setSockOpt", "(", "\\", "ZMQ", "::", "SOCKOPT_SUBSCRIBE", ",", "\"\"", ")", ";", "}", "$", "this", "->", "subscriptionMessage", "=", "@", "json_decode", "(", "$", "this", "->", "subscriberSocket", "->", "recv", "(", "\\", "ZMQ", "::", "MODE_DONTWAIT", ")", ",", "true", ")", ";", "if", "(", "(", "$", "this", "->", "subscriptionMessage", "!==", "false", ")", "&&", "(", "$", "this", "->", "subscriptionMessage", "!==", "null", ")", "&&", "(", "is_array", "(", "$", "this", "->", "subscriptionMessage", ")", "===", "false", ")", ")", "{", "throw", "new", "ProcessManagerException", "(", "\"Not correct param from ProcessManager to TerminatorPauseStander: \"", ".", "serialize", "(", "$", "this", "->", "subscriptionMessage", ")", ")", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "subscriptionMessage", ")", ")", "{", "$", "this", "->", "logger", "->", "info", "(", "\"Receive subscription message: \"", ".", "serialize", "(", "$", "this", "->", "subscriptionMessage", ")", ")", ";", "$", "this", "->", "resolveAction", "(", ")", ";", "}", "return", "null", ";", "}" ]
Check if subscription contain pid of process @return mixed
[ "Check", "if", "subscription", "contain", "pid", "of", "process" ]
cffed6ff73bf66617565707ec4f2c9251a497cc6
https://github.com/jamset/process-load-manager/blob/cffed6ff73bf66617565707ec4f2c9251a497cc6/src/TerminatorPauseStander.php#L115-L138
train
jamset/process-load-manager
src/TerminatorPauseStander.php
TerminatorPauseStander.standOnPauseIfMust
public function standOnPauseIfMust() { if ($this->mustStandOnPause) { $this->iAmInPause = true; while ($this->canContinue === false) { $this->logger->info(getmypid() . " come to usleep for microseconds: " . $this->uSleepTime); usleep($this->uSleepTime); $this->logger->info(getmypid() . " wake up and start check subscription."); $this->checkSubscription(); $this->logger->info(getmypid() . " _CONTINUE_ from infinity while. CanContinue: " . serialize($this->canContinue)); } $this->continueExecution(); } return null; }
php
public function standOnPauseIfMust() { if ($this->mustStandOnPause) { $this->iAmInPause = true; while ($this->canContinue === false) { $this->logger->info(getmypid() . " come to usleep for microseconds: " . $this->uSleepTime); usleep($this->uSleepTime); $this->logger->info(getmypid() . " wake up and start check subscription."); $this->checkSubscription(); $this->logger->info(getmypid() . " _CONTINUE_ from infinity while. CanContinue: " . serialize($this->canContinue)); } $this->continueExecution(); } return null; }
[ "public", "function", "standOnPauseIfMust", "(", ")", "{", "if", "(", "$", "this", "->", "mustStandOnPause", ")", "{", "$", "this", "->", "iAmInPause", "=", "true", ";", "while", "(", "$", "this", "->", "canContinue", "===", "false", ")", "{", "$", "this", "->", "logger", "->", "info", "(", "getmypid", "(", ")", ".", "\" come to usleep for microseconds: \"", ".", "$", "this", "->", "uSleepTime", ")", ";", "usleep", "(", "$", "this", "->", "uSleepTime", ")", ";", "$", "this", "->", "logger", "->", "info", "(", "getmypid", "(", ")", ".", "\" wake up and start check subscription.\"", ")", ";", "$", "this", "->", "checkSubscription", "(", ")", ";", "$", "this", "->", "logger", "->", "info", "(", "getmypid", "(", ")", ".", "\" _CONTINUE_ from infinity while. CanContinue: \"", ".", "serialize", "(", "$", "this", "->", "canContinue", ")", ")", ";", "}", "$", "this", "->", "continueExecution", "(", ")", ";", "}", "return", "null", ";", "}" ]
Go into infinite loop with periodic checking of the subscription if it allows to continue @return mixed
[ "Go", "into", "infinite", "loop", "with", "periodic", "checking", "of", "the", "subscription", "if", "it", "allows", "to", "continue" ]
cffed6ff73bf66617565707ec4f2c9251a497cc6
https://github.com/jamset/process-load-manager/blob/cffed6ff73bf66617565707ec4f2c9251a497cc6/src/TerminatorPauseStander.php#L143-L164
train
jamset/process-load-manager
src/TerminatorPauseStander.php
TerminatorPauseStander.continueExecution
public function continueExecution() { $this->logger->info("TerminatorPauseStander " . getmypid() . " CONTINUED."); $this->iAmInPause = false; $this->mustStandOnPause = false; $this->canContinue = false; return null; }
php
public function continueExecution() { $this->logger->info("TerminatorPauseStander " . getmypid() . " CONTINUED."); $this->iAmInPause = false; $this->mustStandOnPause = false; $this->canContinue = false; return null; }
[ "public", "function", "continueExecution", "(", ")", "{", "$", "this", "->", "logger", "->", "info", "(", "\"TerminatorPauseStander \"", ".", "getmypid", "(", ")", ".", "\" CONTINUED.\"", ")", ";", "$", "this", "->", "iAmInPause", "=", "false", ";", "$", "this", "->", "mustStandOnPause", "=", "false", ";", "$", "this", "->", "canContinue", "=", "false", ";", "return", "null", ";", "}" ]
Exit from infinite loop @return mixed
[ "Exit", "from", "infinite", "loop" ]
cffed6ff73bf66617565707ec4f2c9251a497cc6
https://github.com/jamset/process-load-manager/blob/cffed6ff73bf66617565707ec4f2c9251a497cc6/src/TerminatorPauseStander.php#L169-L178
train
Fulfillment-dot-com/api-wrapper-php
src/Utilities/RequestParser.php
RequestParser.parseError
public static function parseError(RequestException $requestException, $isAssoc = true) { $error = $error = json_decode($requestException->getResponse()->getBody(), $isAssoc); if (!is_null($error)) { return $error; } else { return $requestException->getMessage(); } }
php
public static function parseError(RequestException $requestException, $isAssoc = true) { $error = $error = json_decode($requestException->getResponse()->getBody(), $isAssoc); if (!is_null($error)) { return $error; } else { return $requestException->getMessage(); } }
[ "public", "static", "function", "parseError", "(", "RequestException", "$", "requestException", ",", "$", "isAssoc", "=", "true", ")", "{", "$", "error", "=", "$", "error", "=", "json_decode", "(", "$", "requestException", "->", "getResponse", "(", ")", "->", "getBody", "(", ")", ",", "$", "isAssoc", ")", ";", "if", "(", "!", "is_null", "(", "$", "error", ")", ")", "{", "return", "$", "error", ";", "}", "else", "{", "return", "$", "requestException", "->", "getMessage", "(", ")", ";", "}", "}" ]
Returns an object or array of the FDC error parsed from the Guzzle Request exception @param RequestException $requestException @param bool $isAssoc @return string
[ "Returns", "an", "object", "or", "array", "of", "the", "FDC", "error", "parsed", "from", "the", "Guzzle", "Request", "exception" ]
f4352843d060bc1b460c1283f25c210c9b94d324
https://github.com/Fulfillment-dot-com/api-wrapper-php/blob/f4352843d060bc1b460c1283f25c210c9b94d324/src/Utilities/RequestParser.php#L23-L36
train
gplcart/cli
controllers/commands/Alias.php
Alias.cmdGetAlias
public function cmdGetAlias() { $result = $this->getListAlias(); $this->outputFormat($result); $this->outputFormatTableAlias($result); $this->output(); }
php
public function cmdGetAlias() { $result = $this->getListAlias(); $this->outputFormat($result); $this->outputFormatTableAlias($result); $this->output(); }
[ "public", "function", "cmdGetAlias", "(", ")", "{", "$", "result", "=", "$", "this", "->", "getListAlias", "(", ")", ";", "$", "this", "->", "outputFormat", "(", "$", "result", ")", ";", "$", "this", "->", "outputFormatTableAlias", "(", "$", "result", ")", ";", "$", "this", "->", "output", "(", ")", ";", "}" ]
Callback for "alias-get" command
[ "Callback", "for", "alias", "-", "get", "command" ]
e57dba53e291a225b4bff0c0d9b23d685dd1c125
https://github.com/gplcart/cli/blob/e57dba53e291a225b4bff0c0d9b23d685dd1c125/controllers/commands/Alias.php#L42-L48
train
gplcart/cli
controllers/commands/Alias.php
Alias.cmdAddAlias
public function cmdAddAlias() { $params = $this->getParam(); if (count($params) != 3) { $this->errorAndExit($this->text('Invalid command')); } list($entity, $entity_id, $alias) = $params; if (empty($entity) || empty($entity_id) || empty($alias) || !is_numeric($entity_id)) { $this->errorAndExit($this->text('Invalid argument')); } if (!$this->alias->loadEntity($entity, $entity_id)) { $this->errorAndExit($this->text('Invalid argument')); } $result = $this->addAlias($entity, $entity_id, $alias); if (empty($result)) { $this->errorAndExit($this->text('Unexpected result')); } $this->line($result); $this->output(); }
php
public function cmdAddAlias() { $params = $this->getParam(); if (count($params) != 3) { $this->errorAndExit($this->text('Invalid command')); } list($entity, $entity_id, $alias) = $params; if (empty($entity) || empty($entity_id) || empty($alias) || !is_numeric($entity_id)) { $this->errorAndExit($this->text('Invalid argument')); } if (!$this->alias->loadEntity($entity, $entity_id)) { $this->errorAndExit($this->text('Invalid argument')); } $result = $this->addAlias($entity, $entity_id, $alias); if (empty($result)) { $this->errorAndExit($this->text('Unexpected result')); } $this->line($result); $this->output(); }
[ "public", "function", "cmdAddAlias", "(", ")", "{", "$", "params", "=", "$", "this", "->", "getParam", "(", ")", ";", "if", "(", "count", "(", "$", "params", ")", "!=", "3", ")", "{", "$", "this", "->", "errorAndExit", "(", "$", "this", "->", "text", "(", "'Invalid command'", ")", ")", ";", "}", "list", "(", "$", "entity", ",", "$", "entity_id", ",", "$", "alias", ")", "=", "$", "params", ";", "if", "(", "empty", "(", "$", "entity", ")", "||", "empty", "(", "$", "entity_id", ")", "||", "empty", "(", "$", "alias", ")", "||", "!", "is_numeric", "(", "$", "entity_id", ")", ")", "{", "$", "this", "->", "errorAndExit", "(", "$", "this", "->", "text", "(", "'Invalid argument'", ")", ")", ";", "}", "if", "(", "!", "$", "this", "->", "alias", "->", "loadEntity", "(", "$", "entity", ",", "$", "entity_id", ")", ")", "{", "$", "this", "->", "errorAndExit", "(", "$", "this", "->", "text", "(", "'Invalid argument'", ")", ")", ";", "}", "$", "result", "=", "$", "this", "->", "addAlias", "(", "$", "entity", ",", "$", "entity_id", ",", "$", "alias", ")", ";", "if", "(", "empty", "(", "$", "result", ")", ")", "{", "$", "this", "->", "errorAndExit", "(", "$", "this", "->", "text", "(", "'Unexpected result'", ")", ")", ";", "}", "$", "this", "->", "line", "(", "$", "result", ")", ";", "$", "this", "->", "output", "(", ")", ";", "}" ]
Callback for "alias-add" command
[ "Callback", "for", "alias", "-", "add", "command" ]
e57dba53e291a225b4bff0c0d9b23d685dd1c125
https://github.com/gplcart/cli/blob/e57dba53e291a225b4bff0c0d9b23d685dd1c125/controllers/commands/Alias.php#L53-L79
train
gplcart/cli
controllers/commands/Alias.php
Alias.cmdGenerateAlias
public function cmdGenerateAlias() { $entity = $this->getParam(0); $entity_id = $this->getParam(1); $all = $this->getParam('all'); if (empty($entity)) { $this->errorAndExit($this->text('Invalid command')); } if (!isset($entity_id) && empty($all)) { $this->errorAndExit($this->text('Invalid command')); } $result = false; if (isset($entity_id)) { if (!is_numeric($entity_id)) { $this->errorAndExit($this->text('Invalid argument')); } $data = $this->alias->loadEntity($entity, $entity_id); if (empty($data)) { $this->errorAndExit($this->text('Invalid argument')); } $alias = $this->alias->generateEntity($entity, $data); if (empty($alias)) { $this->errorAndExit($this->text('Unexpected result')); } $result = $this->addAlias($entity, $entity_id, $alias); } else if (!empty($all)) { $result = $this->generateListAlias($entity); } if (empty($result)) { $this->errorAndExit($this->text('Unexpected result')); } $this->output(); }
php
public function cmdGenerateAlias() { $entity = $this->getParam(0); $entity_id = $this->getParam(1); $all = $this->getParam('all'); if (empty($entity)) { $this->errorAndExit($this->text('Invalid command')); } if (!isset($entity_id) && empty($all)) { $this->errorAndExit($this->text('Invalid command')); } $result = false; if (isset($entity_id)) { if (!is_numeric($entity_id)) { $this->errorAndExit($this->text('Invalid argument')); } $data = $this->alias->loadEntity($entity, $entity_id); if (empty($data)) { $this->errorAndExit($this->text('Invalid argument')); } $alias = $this->alias->generateEntity($entity, $data); if (empty($alias)) { $this->errorAndExit($this->text('Unexpected result')); } $result = $this->addAlias($entity, $entity_id, $alias); } else if (!empty($all)) { $result = $this->generateListAlias($entity); } if (empty($result)) { $this->errorAndExit($this->text('Unexpected result')); } $this->output(); }
[ "public", "function", "cmdGenerateAlias", "(", ")", "{", "$", "entity", "=", "$", "this", "->", "getParam", "(", "0", ")", ";", "$", "entity_id", "=", "$", "this", "->", "getParam", "(", "1", ")", ";", "$", "all", "=", "$", "this", "->", "getParam", "(", "'all'", ")", ";", "if", "(", "empty", "(", "$", "entity", ")", ")", "{", "$", "this", "->", "errorAndExit", "(", "$", "this", "->", "text", "(", "'Invalid command'", ")", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "entity_id", ")", "&&", "empty", "(", "$", "all", ")", ")", "{", "$", "this", "->", "errorAndExit", "(", "$", "this", "->", "text", "(", "'Invalid command'", ")", ")", ";", "}", "$", "result", "=", "false", ";", "if", "(", "isset", "(", "$", "entity_id", ")", ")", "{", "if", "(", "!", "is_numeric", "(", "$", "entity_id", ")", ")", "{", "$", "this", "->", "errorAndExit", "(", "$", "this", "->", "text", "(", "'Invalid argument'", ")", ")", ";", "}", "$", "data", "=", "$", "this", "->", "alias", "->", "loadEntity", "(", "$", "entity", ",", "$", "entity_id", ")", ";", "if", "(", "empty", "(", "$", "data", ")", ")", "{", "$", "this", "->", "errorAndExit", "(", "$", "this", "->", "text", "(", "'Invalid argument'", ")", ")", ";", "}", "$", "alias", "=", "$", "this", "->", "alias", "->", "generateEntity", "(", "$", "entity", ",", "$", "data", ")", ";", "if", "(", "empty", "(", "$", "alias", ")", ")", "{", "$", "this", "->", "errorAndExit", "(", "$", "this", "->", "text", "(", "'Unexpected result'", ")", ")", ";", "}", "$", "result", "=", "$", "this", "->", "addAlias", "(", "$", "entity", ",", "$", "entity_id", ",", "$", "alias", ")", ";", "}", "else", "if", "(", "!", "empty", "(", "$", "all", ")", ")", "{", "$", "result", "=", "$", "this", "->", "generateListAlias", "(", "$", "entity", ")", ";", "}", "if", "(", "empty", "(", "$", "result", ")", ")", "{", "$", "this", "->", "errorAndExit", "(", "$", "this", "->", "text", "(", "'Unexpected result'", ")", ")", ";", "}", "$", "this", "->", "output", "(", ")", ";", "}" ]
Callback for "alias-generate" command
[ "Callback", "for", "alias", "-", "generate", "command" ]
e57dba53e291a225b4bff0c0d9b23d685dd1c125
https://github.com/gplcart/cli/blob/e57dba53e291a225b4bff0c0d9b23d685dd1c125/controllers/commands/Alias.php#L84-L129
train
gplcart/cli
controllers/commands/Alias.php
Alias.addAlias
protected function addAlias($entity, $entity_id, $alias) { $this->alias->delete(array('entity' => $entity, 'entity_id' => $entity_id)); $data = array( 'alias' => $alias, 'entity' => $entity, 'entity_id' => $entity_id ); return $this->alias->add($data); }
php
protected function addAlias($entity, $entity_id, $alias) { $this->alias->delete(array('entity' => $entity, 'entity_id' => $entity_id)); $data = array( 'alias' => $alias, 'entity' => $entity, 'entity_id' => $entity_id ); return $this->alias->add($data); }
[ "protected", "function", "addAlias", "(", "$", "entity", ",", "$", "entity_id", ",", "$", "alias", ")", "{", "$", "this", "->", "alias", "->", "delete", "(", "array", "(", "'entity'", "=>", "$", "entity", ",", "'entity_id'", "=>", "$", "entity_id", ")", ")", ";", "$", "data", "=", "array", "(", "'alias'", "=>", "$", "alias", ",", "'entity'", "=>", "$", "entity", ",", "'entity_id'", "=>", "$", "entity_id", ")", ";", "return", "$", "this", "->", "alias", "->", "add", "(", "$", "data", ")", ";", "}" ]
Add a URL alias @param string $entity @param int $entity_id @param string $alias @return int
[ "Add", "a", "URL", "alias" ]
e57dba53e291a225b4bff0c0d9b23d685dd1c125
https://github.com/gplcart/cli/blob/e57dba53e291a225b4bff0c0d9b23d685dd1c125/controllers/commands/Alias.php#L137-L148
train
gplcart/cli
controllers/commands/Alias.php
Alias.generateListAlias
protected function generateListAlias($entity) { if (!$this->alias->isSupportedEntity($entity)) { $this->errorAndExit($this->text('Invalid argument')); } $model = gplcart_instance_model($entity); if (!$model instanceof CrudInterface) { $this->errorAndExit($this->text('Invalid argument')); } ini_set('memory_limit', '-1'); $added = $count = 0; foreach ($model->getList() as $item) { if (empty($item["{$entity}_id"])) { continue; } $count++; $entity_id = $item["{$entity}_id"]; $this->alias->delete(array('entity' => $entity, 'entity_id' => $entity_id)); $data = array( 'entity' => $entity, 'entity_id' => $entity_id, 'alias' => $this->alias->generateEntity($entity, $item) ); if ($this->alias->add($data)) { $added++; } } return $count && $count == $added; }
php
protected function generateListAlias($entity) { if (!$this->alias->isSupportedEntity($entity)) { $this->errorAndExit($this->text('Invalid argument')); } $model = gplcart_instance_model($entity); if (!$model instanceof CrudInterface) { $this->errorAndExit($this->text('Invalid argument')); } ini_set('memory_limit', '-1'); $added = $count = 0; foreach ($model->getList() as $item) { if (empty($item["{$entity}_id"])) { continue; } $count++; $entity_id = $item["{$entity}_id"]; $this->alias->delete(array('entity' => $entity, 'entity_id' => $entity_id)); $data = array( 'entity' => $entity, 'entity_id' => $entity_id, 'alias' => $this->alias->generateEntity($entity, $item) ); if ($this->alias->add($data)) { $added++; } } return $count && $count == $added; }
[ "protected", "function", "generateListAlias", "(", "$", "entity", ")", "{", "if", "(", "!", "$", "this", "->", "alias", "->", "isSupportedEntity", "(", "$", "entity", ")", ")", "{", "$", "this", "->", "errorAndExit", "(", "$", "this", "->", "text", "(", "'Invalid argument'", ")", ")", ";", "}", "$", "model", "=", "gplcart_instance_model", "(", "$", "entity", ")", ";", "if", "(", "!", "$", "model", "instanceof", "CrudInterface", ")", "{", "$", "this", "->", "errorAndExit", "(", "$", "this", "->", "text", "(", "'Invalid argument'", ")", ")", ";", "}", "ini_set", "(", "'memory_limit'", ",", "'-1'", ")", ";", "$", "added", "=", "$", "count", "=", "0", ";", "foreach", "(", "$", "model", "->", "getList", "(", ")", "as", "$", "item", ")", "{", "if", "(", "empty", "(", "$", "item", "[", "\"{$entity}_id\"", "]", ")", ")", "{", "continue", ";", "}", "$", "count", "++", ";", "$", "entity_id", "=", "$", "item", "[", "\"{$entity}_id\"", "]", ";", "$", "this", "->", "alias", "->", "delete", "(", "array", "(", "'entity'", "=>", "$", "entity", ",", "'entity_id'", "=>", "$", "entity_id", ")", ")", ";", "$", "data", "=", "array", "(", "'entity'", "=>", "$", "entity", ",", "'entity_id'", "=>", "$", "entity_id", ",", "'alias'", "=>", "$", "this", "->", "alias", "->", "generateEntity", "(", "$", "entity", ",", "$", "item", ")", ")", ";", "if", "(", "$", "this", "->", "alias", "->", "add", "(", "$", "data", ")", ")", "{", "$", "added", "++", ";", "}", "}", "return", "$", "count", "&&", "$", "count", "==", "$", "added", ";", "}" ]
Mass generate URL aliases for the given entity @param string $entity @return bool
[ "Mass", "generate", "URL", "aliases", "for", "the", "given", "entity" ]
e57dba53e291a225b4bff0c0d9b23d685dd1c125
https://github.com/gplcart/cli/blob/e57dba53e291a225b4bff0c0d9b23d685dd1c125/controllers/commands/Alias.php#L155-L194
train