id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
sequence
docstring
stringlengths
3
47.2k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
91
247
10,600
jaztec/jaztec-admin
src/JaztecAdmin/Direct/Framework.php
Framework.getViews
public function getViews(array $values) { $config = $this->getServiceLocator()->get('Config'); if (!isset($values['controller'])) { throw new Exception('No controller data received.'); } $controller = $values['controller']; if (!isset($config['jaztec_admin']['modules']['views'][$controller])) { return array(); } $paths = $config['jaztec_admin']['modules']['views'][$controller]['paths']; return $this->getFiles($paths, 'view'); }
php
public function getViews(array $values) { $config = $this->getServiceLocator()->get('Config'); if (!isset($values['controller'])) { throw new Exception('No controller data received.'); } $controller = $values['controller']; if (!isset($config['jaztec_admin']['modules']['views'][$controller])) { return array(); } $paths = $config['jaztec_admin']['modules']['views'][$controller]['paths']; return $this->getFiles($paths, 'view'); }
[ "public", "function", "getViews", "(", "array", "$", "values", ")", "{", "$", "config", "=", "$", "this", "->", "getServiceLocator", "(", ")", "->", "get", "(", "'Config'", ")", ";", "if", "(", "!", "isset", "(", "$", "values", "[", "'controller'", "]", ")", ")", "{", "throw", "new", "Exception", "(", "'No controller data received.'", ")", ";", "}", "$", "controller", "=", "$", "values", "[", "'controller'", "]", ";", "if", "(", "!", "isset", "(", "$", "config", "[", "'jaztec_admin'", "]", "[", "'modules'", "]", "[", "'views'", "]", "[", "$", "controller", "]", ")", ")", "{", "return", "array", "(", ")", ";", "}", "$", "paths", "=", "$", "config", "[", "'jaztec_admin'", "]", "[", "'modules'", "]", "[", "'views'", "]", "[", "$", "controller", "]", "[", "'paths'", "]", ";", "return", "$", "this", "->", "getFiles", "(", "$", "paths", ",", "'view'", ")", ";", "}" ]
Returns all views connected to a controller. @param array $values @return array An array with the allowed views.
[ "Returns", "all", "views", "connected", "to", "a", "controller", "." ]
c05b84077f05ed26529e2795f6adfe7b4ebd0edf
https://github.com/jaztec/jaztec-admin/blob/c05b84077f05ed26529e2795f6adfe7b4ebd0edf/src/JaztecAdmin/Direct/Framework.php#L53-L66
10,601
jaztec/jaztec-admin
src/JaztecAdmin/Direct/Framework.php
Framework.getFiles
protected function getFiles(array $paths, $aclNamespace) { $result = array(); $object = ''; foreach ($paths as $namespace => $path) { foreach ($this->rglob('*.js', 0, "$path/") as $entry) { $entry = pathinfo($entry); $extraNs = str_replace('/', '.', str_replace($path, '', $entry['dirname'])); $object = $namespace . $extraNs . '.' . $entry['filename']; // Validate against the ACL. if ($this->checkAcl("extjs-$aclNamespace-" . $object)) { $result[] = $object; } } } return $result; }
php
protected function getFiles(array $paths, $aclNamespace) { $result = array(); $object = ''; foreach ($paths as $namespace => $path) { foreach ($this->rglob('*.js', 0, "$path/") as $entry) { $entry = pathinfo($entry); $extraNs = str_replace('/', '.', str_replace($path, '', $entry['dirname'])); $object = $namespace . $extraNs . '.' . $entry['filename']; // Validate against the ACL. if ($this->checkAcl("extjs-$aclNamespace-" . $object)) { $result[] = $object; } } } return $result; }
[ "protected", "function", "getFiles", "(", "array", "$", "paths", ",", "$", "aclNamespace", ")", "{", "$", "result", "=", "array", "(", ")", ";", "$", "object", "=", "''", ";", "foreach", "(", "$", "paths", "as", "$", "namespace", "=>", "$", "path", ")", "{", "foreach", "(", "$", "this", "->", "rglob", "(", "'*.js'", ",", "0", ",", "\"$path/\"", ")", "as", "$", "entry", ")", "{", "$", "entry", "=", "pathinfo", "(", "$", "entry", ")", ";", "$", "extraNs", "=", "str_replace", "(", "'/'", ",", "'.'", ",", "str_replace", "(", "$", "path", ",", "''", ",", "$", "entry", "[", "'dirname'", "]", ")", ")", ";", "$", "object", "=", "$", "namespace", ".", "$", "extraNs", ".", "'.'", ".", "$", "entry", "[", "'filename'", "]", ";", "// Validate against the ACL.", "if", "(", "$", "this", "->", "checkAcl", "(", "\"extjs-$aclNamespace-\"", ".", "$", "object", ")", ")", "{", "$", "result", "[", "]", "=", "$", "object", ";", "}", "}", "}", "return", "$", "result", ";", "}" ]
Returns all the ExtJS objects in a given path and checks it against the ACL settings. @param array $paths @param string $aclNamespace @return array
[ "Returns", "all", "the", "ExtJS", "objects", "in", "a", "given", "path", "and", "checks", "it", "against", "the", "ACL", "settings", "." ]
c05b84077f05ed26529e2795f6adfe7b4ebd0edf
https://github.com/jaztec/jaztec-admin/blob/c05b84077f05ed26529e2795f6adfe7b4ebd0edf/src/JaztecAdmin/Direct/Framework.php#L97-L114
10,602
jaztec/jaztec-admin
src/JaztecAdmin/Direct/Framework.php
Framework.rglob
protected function rglob($pattern = '*', $flags = 0, $path = '') { $paths = glob($path . '*', GLOB_MARK | GLOB_ONLYDIR | GLOB_NOSORT); $files = glob($path . $pattern, $flags); foreach ($paths as $path) { $files = array_merge( $files, $this->rglob($pattern, $flags, $path) ); } return $files; }
php
protected function rglob($pattern = '*', $flags = 0, $path = '') { $paths = glob($path . '*', GLOB_MARK | GLOB_ONLYDIR | GLOB_NOSORT); $files = glob($path . $pattern, $flags); foreach ($paths as $path) { $files = array_merge( $files, $this->rglob($pattern, $flags, $path) ); } return $files; }
[ "protected", "function", "rglob", "(", "$", "pattern", "=", "'*'", ",", "$", "flags", "=", "0", ",", "$", "path", "=", "''", ")", "{", "$", "paths", "=", "glob", "(", "$", "path", ".", "'*'", ",", "GLOB_MARK", "|", "GLOB_ONLYDIR", "|", "GLOB_NOSORT", ")", ";", "$", "files", "=", "glob", "(", "$", "path", ".", "$", "pattern", ",", "$", "flags", ")", ";", "foreach", "(", "$", "paths", "as", "$", "path", ")", "{", "$", "files", "=", "array_merge", "(", "$", "files", ",", "$", "this", "->", "rglob", "(", "$", "pattern", ",", "$", "flags", ",", "$", "path", ")", ")", ";", "}", "return", "$", "files", ";", "}" ]
Recursive glob function. @param int $pattern the pattern passed to glob() @param int $flags the flags passed to glob() @param string $path the path to scan @return mixed an array of files in the given path matching the pattern.
[ "Recursive", "glob", "function", "." ]
c05b84077f05ed26529e2795f6adfe7b4ebd0edf
https://github.com/jaztec/jaztec-admin/blob/c05b84077f05ed26529e2795f6adfe7b4ebd0edf/src/JaztecAdmin/Direct/Framework.php#L124-L136
10,603
graze/xml-utils
src/XmlFormatter.php
XmlFormatter.format
public function format($xml) { $dom = new DOMDocument('1.0'); $dom->preserveWhiteSpace = false; $dom->formatOutput = true; $dom->loadXML($xml); $formatted = $dom->saveXML(); if (!$formatted) { throw new Exception("An error occurred while formatting the XML"); } return $formatted; }
php
public function format($xml) { $dom = new DOMDocument('1.0'); $dom->preserveWhiteSpace = false; $dom->formatOutput = true; $dom->loadXML($xml); $formatted = $dom->saveXML(); if (!$formatted) { throw new Exception("An error occurred while formatting the XML"); } return $formatted; }
[ "public", "function", "format", "(", "$", "xml", ")", "{", "$", "dom", "=", "new", "DOMDocument", "(", "'1.0'", ")", ";", "$", "dom", "->", "preserveWhiteSpace", "=", "false", ";", "$", "dom", "->", "formatOutput", "=", "true", ";", "$", "dom", "->", "loadXML", "(", "$", "xml", ")", ";", "$", "formatted", "=", "$", "dom", "->", "saveXML", "(", ")", ";", "if", "(", "!", "$", "formatted", ")", "{", "throw", "new", "Exception", "(", "\"An error occurred while formatting the XML\"", ")", ";", "}", "return", "$", "formatted", ";", "}" ]
Return the XML with correct indentation. @param string $xml @return string @throws Exception
[ "Return", "the", "XML", "with", "correct", "indentation", "." ]
0527e312518bc41e44018c29ea394bc4c6a2e7d7
https://github.com/graze/xml-utils/blob/0527e312518bc41e44018c29ea394bc4c6a2e7d7/src/XmlFormatter.php#L28-L41
10,604
synapsestudios/synapse-base
src/Synapse/Resque/ResqueCommand.php
ResqueCommand.shutdownWorkers
protected function shutdownWorkers() { $workers = Resque_Worker::all(); foreach ($workers as $worker) { list($name, $pid, $queues) = explode(':', (string) $worker); posix_kill((int) $pid, SIGQUIT); } $this->output->writeln('<info>SIGQUIT sent to '.count($workers).' workers.</info>'); }
php
protected function shutdownWorkers() { $workers = Resque_Worker::all(); foreach ($workers as $worker) { list($name, $pid, $queues) = explode(':', (string) $worker); posix_kill((int) $pid, SIGQUIT); } $this->output->writeln('<info>SIGQUIT sent to '.count($workers).' workers.</info>'); }
[ "protected", "function", "shutdownWorkers", "(", ")", "{", "$", "workers", "=", "Resque_Worker", "::", "all", "(", ")", ";", "foreach", "(", "$", "workers", "as", "$", "worker", ")", "{", "list", "(", "$", "name", ",", "$", "pid", ",", "$", "queues", ")", "=", "explode", "(", "':'", ",", "(", "string", ")", "$", "worker", ")", ";", "posix_kill", "(", "(", "int", ")", "$", "pid", ",", "SIGQUIT", ")", ";", "}", "$", "this", "->", "output", "->", "writeln", "(", "'<info>SIGQUIT sent to '", ".", "count", "(", "$", "workers", ")", ".", "' workers.</info>'", ")", ";", "}" ]
Shutdown all workers
[ "Shutdown", "all", "workers" ]
60c830550491742a077ab063f924e2f0b63825da
https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/Resque/ResqueCommand.php#L91-L101
10,605
Puzzlout/FrameworkMvcLegacy
src/Core/User.php
User.getAttribute
public function getAttribute($sessionKey) { return isset($_SESSION[$this->GetKey($sessionKey)]) ? $_SESSION[$this->GetKey($sessionKey)] : false; }
php
public function getAttribute($sessionKey) { return isset($_SESSION[$this->GetKey($sessionKey)]) ? $_SESSION[$this->GetKey($sessionKey)] : false; }
[ "public", "function", "getAttribute", "(", "$", "sessionKey", ")", "{", "return", "isset", "(", "$", "_SESSION", "[", "$", "this", "->", "GetKey", "(", "$", "sessionKey", ")", "]", ")", "?", "$", "_SESSION", "[", "$", "this", "->", "GetKey", "(", "$", "sessionKey", ")", "]", ":", "false", ";", "}" ]
Get a value in current session from a given key. @param sring $sessionKey The key to use to find the associated value. The set of values is found in the class(es) \Puzzlout\Framework\Enums\SessionKeys (Framework) or \Application\YourApp\Resources\Enums\SessionKeys (Application) @return mixed The value can any type: int, string, array, object instance of any class. If value is not set, then return false.
[ "Get", "a", "value", "in", "current", "session", "from", "a", "given", "key", "." ]
14e0fc5b16978cbd209f552ee9c649f66a0dfc6e
https://github.com/Puzzlout/FrameworkMvcLegacy/blob/14e0fc5b16978cbd209f552ee9c649f66a0dfc6e/src/Core/User.php#L53-L58
10,606
sebardo/ecommerce
EcommerceBundle/Entity/CheckoutAddressable.php
CheckoutAddressable.setDeliveryAddressInfo
public function setDeliveryAddressInfo(Address $address) { $this->setDeliveryAddress($address->getAddress()); $this->setDeliveryPostalCode($address->getPostalCode()); $this->setDeliveryCity($address->getCity()); $this->setDeliveryState($address->getState()); $this->setDeliveryCountry($address->getCountry()); }
php
public function setDeliveryAddressInfo(Address $address) { $this->setDeliveryAddress($address->getAddress()); $this->setDeliveryPostalCode($address->getPostalCode()); $this->setDeliveryCity($address->getCity()); $this->setDeliveryState($address->getState()); $this->setDeliveryCountry($address->getCountry()); }
[ "public", "function", "setDeliveryAddressInfo", "(", "Address", "$", "address", ")", "{", "$", "this", "->", "setDeliveryAddress", "(", "$", "address", "->", "getAddress", "(", ")", ")", ";", "$", "this", "->", "setDeliveryPostalCode", "(", "$", "address", "->", "getPostalCode", "(", ")", ")", ";", "$", "this", "->", "setDeliveryCity", "(", "$", "address", "->", "getCity", "(", ")", ")", ";", "$", "this", "->", "setDeliveryState", "(", "$", "address", "->", "getState", "(", ")", ")", ";", "$", "this", "->", "setDeliveryCountry", "(", "$", "address", "->", "getCountry", "(", ")", ")", ";", "}" ]
Set delivery address information @param Address $address
[ "Set", "delivery", "address", "information" ]
3e17545e69993f10a1df17f9887810c7378fc7f9
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Entity/CheckoutAddressable.php#L92-L99
10,607
sebardo/ecommerce
EcommerceBundle/Entity/CheckoutAddressable.php
CheckoutAddressable.getDeliveryAddressInfo
public function getDeliveryAddressInfo() { $address = new Address(); $address->setAddress($this->getDeliveryAddress()); $address->setPostalCode($this->getDeliveryPostalCode()); $address->setCity($this->getDeliveryCity()); $address->setState($this->getDeliveryState()); $address->setCountry($this->getDeliveryCountry()); return $address; }
php
public function getDeliveryAddressInfo() { $address = new Address(); $address->setAddress($this->getDeliveryAddress()); $address->setPostalCode($this->getDeliveryPostalCode()); $address->setCity($this->getDeliveryCity()); $address->setState($this->getDeliveryState()); $address->setCountry($this->getDeliveryCountry()); return $address; }
[ "public", "function", "getDeliveryAddressInfo", "(", ")", "{", "$", "address", "=", "new", "Address", "(", ")", ";", "$", "address", "->", "setAddress", "(", "$", "this", "->", "getDeliveryAddress", "(", ")", ")", ";", "$", "address", "->", "setPostalCode", "(", "$", "this", "->", "getDeliveryPostalCode", "(", ")", ")", ";", "$", "address", "->", "setCity", "(", "$", "this", "->", "getDeliveryCity", "(", ")", ")", ";", "$", "address", "->", "setState", "(", "$", "this", "->", "getDeliveryState", "(", ")", ")", ";", "$", "address", "->", "setCountry", "(", "$", "this", "->", "getDeliveryCountry", "(", ")", ")", ";", "return", "$", "address", ";", "}" ]
Get delivery address information @return Address
[ "Get", "delivery", "address", "information" ]
3e17545e69993f10a1df17f9887810c7378fc7f9
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Entity/CheckoutAddressable.php#L106-L117
10,608
sebardo/ecommerce
EcommerceBundle/Entity/CheckoutAddressable.php
CheckoutAddressable.validateDeliveryDni
public function validateDeliveryDni(ExecutionContextInterface $context) { $dni = $this->getDeliveryDni(); if (is_null($dni)) { return; } // check format if (0 === preg_match("/\d{1,8}[a-z]/i", $dni)) { $context->addViolationAt('dni', 'Invalid DNI number'); return; } // check letter $number = substr($dni, 0, -1); $letter = strtoupper(substr($dni, -1)); if ($letter != substr("TRWAGMYFPDXBNJZSQVHLCKE", strtr($number, "XYZ", "012")%23, 1)) { $context->addViolationAt('dni', 'Invalid DNI letter'); } }
php
public function validateDeliveryDni(ExecutionContextInterface $context) { $dni = $this->getDeliveryDni(); if (is_null($dni)) { return; } // check format if (0 === preg_match("/\d{1,8}[a-z]/i", $dni)) { $context->addViolationAt('dni', 'Invalid DNI number'); return; } // check letter $number = substr($dni, 0, -1); $letter = strtoupper(substr($dni, -1)); if ($letter != substr("TRWAGMYFPDXBNJZSQVHLCKE", strtr($number, "XYZ", "012")%23, 1)) { $context->addViolationAt('dni', 'Invalid DNI letter'); } }
[ "public", "function", "validateDeliveryDni", "(", "ExecutionContextInterface", "$", "context", ")", "{", "$", "dni", "=", "$", "this", "->", "getDeliveryDni", "(", ")", ";", "if", "(", "is_null", "(", "$", "dni", ")", ")", "{", "return", ";", "}", "// check format", "if", "(", "0", "===", "preg_match", "(", "\"/\\d{1,8}[a-z]/i\"", ",", "$", "dni", ")", ")", "{", "$", "context", "->", "addViolationAt", "(", "'dni'", ",", "'Invalid DNI number'", ")", ";", "return", ";", "}", "// check letter", "$", "number", "=", "substr", "(", "$", "dni", ",", "0", ",", "-", "1", ")", ";", "$", "letter", "=", "strtoupper", "(", "substr", "(", "$", "dni", ",", "-", "1", ")", ")", ";", "if", "(", "$", "letter", "!=", "substr", "(", "\"TRWAGMYFPDXBNJZSQVHLCKE\"", ",", "strtr", "(", "$", "number", ",", "\"XYZ\"", ",", "\"012\"", ")", "%", "23", ",", "1", ")", ")", "{", "$", "context", "->", "addViolationAt", "(", "'dni'", ",", "'Invalid DNI letter'", ")", ";", "}", "}" ]
Custom validator to check delivery Dni @param ExecutionContextInterface $context
[ "Custom", "validator", "to", "check", "delivery", "Dni" ]
3e17545e69993f10a1df17f9887810c7378fc7f9
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Entity/CheckoutAddressable.php#L244-L265
10,609
tweedegolf/generator
src/TweedeGolf/Generator/Util/PregErrorToString.php
PregErrorToString.getString
public static function getString($error) { if (!is_int($error)) { throw new \BadMethodCallException("Invalid type, expected integer, got {$error}."); } switch ($error) { case PREG_NO_ERROR: return 'PREG_NO_ERROR'; case PREG_INTERNAL_ERROR: return 'PREG_INTERNAL_ERROR'; case PREG_BACKTRACK_LIMIT_ERROR: return 'PREG_BACKTRACK_LIMIT_ERROR'; case PREG_BAD_UTF8_ERROR: return 'PREG_BAD_UTF8_ERROR'; case PREG_RECURSION_LIMIT_ERROR: return 'PREG_RECURSION_LIMIT_ERROR'; case PREG_BAD_UTF8_OFFSET_ERROR: return 'PREG_BAD_UTF8_OFFSET_ERROR'; default: throw new \BadMethodCallException("Tried to convert unknown PREG error {$error} to string"); } }
php
public static function getString($error) { if (!is_int($error)) { throw new \BadMethodCallException("Invalid type, expected integer, got {$error}."); } switch ($error) { case PREG_NO_ERROR: return 'PREG_NO_ERROR'; case PREG_INTERNAL_ERROR: return 'PREG_INTERNAL_ERROR'; case PREG_BACKTRACK_LIMIT_ERROR: return 'PREG_BACKTRACK_LIMIT_ERROR'; case PREG_BAD_UTF8_ERROR: return 'PREG_BAD_UTF8_ERROR'; case PREG_RECURSION_LIMIT_ERROR: return 'PREG_RECURSION_LIMIT_ERROR'; case PREG_BAD_UTF8_OFFSET_ERROR: return 'PREG_BAD_UTF8_OFFSET_ERROR'; default: throw new \BadMethodCallException("Tried to convert unknown PREG error {$error} to string"); } }
[ "public", "static", "function", "getString", "(", "$", "error", ")", "{", "if", "(", "!", "is_int", "(", "$", "error", ")", ")", "{", "throw", "new", "\\", "BadMethodCallException", "(", "\"Invalid type, expected integer, got {$error}.\"", ")", ";", "}", "switch", "(", "$", "error", ")", "{", "case", "PREG_NO_ERROR", ":", "return", "'PREG_NO_ERROR'", ";", "case", "PREG_INTERNAL_ERROR", ":", "return", "'PREG_INTERNAL_ERROR'", ";", "case", "PREG_BACKTRACK_LIMIT_ERROR", ":", "return", "'PREG_BACKTRACK_LIMIT_ERROR'", ";", "case", "PREG_BAD_UTF8_ERROR", ":", "return", "'PREG_BAD_UTF8_ERROR'", ";", "case", "PREG_RECURSION_LIMIT_ERROR", ":", "return", "'PREG_RECURSION_LIMIT_ERROR'", ";", "case", "PREG_BAD_UTF8_OFFSET_ERROR", ":", "return", "'PREG_BAD_UTF8_OFFSET_ERROR'", ";", "default", ":", "throw", "new", "\\", "BadMethodCallException", "(", "\"Tried to convert unknown PREG error {$error} to string\"", ")", ";", "}", "}" ]
Convert a PREG error message id to its string equivalent. @param int $error @return string @throws \BadMethodCallException
[ "Convert", "a", "PREG", "error", "message", "id", "to", "its", "string", "equivalent", "." ]
f931d659ddf6a531ebf00bbfc11d417c527cd21b
https://github.com/tweedegolf/generator/blob/f931d659ddf6a531ebf00bbfc11d417c527cd21b/src/TweedeGolf/Generator/Util/PregErrorToString.php#L13-L29
10,610
shov/wpci-core
Flow/ServiceRegistrator.php
ServiceRegistrator.prepareArguments
public function prepareArguments(string $id, array $resolvingReferences) { if(!isset($this->serviceArguments[$id])) $this->serviceArguments[$id] = []; $this->serviceArguments[$id] = array_merge($this->serviceArguments[$id], $resolvingReferences); }
php
public function prepareArguments(string $id, array $resolvingReferences) { if(!isset($this->serviceArguments[$id])) $this->serviceArguments[$id] = []; $this->serviceArguments[$id] = array_merge($this->serviceArguments[$id], $resolvingReferences); }
[ "public", "function", "prepareArguments", "(", "string", "$", "id", ",", "array", "$", "resolvingReferences", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "serviceArguments", "[", "$", "id", "]", ")", ")", "$", "this", "->", "serviceArguments", "[", "$", "id", "]", "=", "[", "]", ";", "$", "this", "->", "serviceArguments", "[", "$", "id", "]", "=", "array_merge", "(", "$", "this", "->", "serviceArguments", "[", "$", "id", "]", ",", "$", "resolvingReferences", ")", ";", "}" ]
Add arguments to entity before register it @param string $id @param array $resolvingReferences
[ "Add", "arguments", "to", "entity", "before", "register", "it" ]
e31084cbc2f310882df2b9b0548330ea5fdb4f26
https://github.com/shov/wpci-core/blob/e31084cbc2f310882df2b9b0548330ea5fdb4f26/Flow/ServiceRegistrator.php#L49-L53
10,611
wakerscz/cms-category-module
src/Component/Frontend/Modal/Modal.php
Modal.handleEdit
public function handleEdit(int $id) { if ($this->presenter->isAjax()) { $this->categoryId = $id; $this->onOpen(); } }
php
public function handleEdit(int $id) { if ($this->presenter->isAjax()) { $this->categoryId = $id; $this->onOpen(); } }
[ "public", "function", "handleEdit", "(", "int", "$", "id", ")", "{", "if", "(", "$", "this", "->", "presenter", "->", "isAjax", "(", ")", ")", "{", "$", "this", "->", "categoryId", "=", "$", "id", ";", "$", "this", "->", "onOpen", "(", ")", ";", "}", "}" ]
Handler pro editaci @param int $id
[ "Handler", "pro", "editaci" ]
6f5f8c366af0157e333e19abf18b6a3e346b127e
https://github.com/wakerscz/cms-category-module/blob/6f5f8c366af0157e333e19abf18b6a3e346b127e/src/Component/Frontend/Modal/Modal.php#L288-L295
10,612
canis-io/yii2-key-provider
lib/providers/BaseProvider.php
BaseProvider.init
public function init() { foreach (static::defaultConfig() as $key => $value) { if (!isset($this->{$key})) { $this->{$key} = $value; } } foreach (static::requiredConfig() as $key) { if (!isset($this->{$key})) { throw new InvalidConfigException(get_class($this) . " key provider requires '{$key}' config key"); } } KeyProviderCollector::internalRegisterProvider($this); }
php
public function init() { foreach (static::defaultConfig() as $key => $value) { if (!isset($this->{$key})) { $this->{$key} = $value; } } foreach (static::requiredConfig() as $key) { if (!isset($this->{$key})) { throw new InvalidConfigException(get_class($this) . " key provider requires '{$key}' config key"); } } KeyProviderCollector::internalRegisterProvider($this); }
[ "public", "function", "init", "(", ")", "{", "foreach", "(", "static", "::", "defaultConfig", "(", ")", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "{", "$", "key", "}", ")", ")", "{", "$", "this", "->", "{", "$", "key", "}", "=", "$", "value", ";", "}", "}", "foreach", "(", "static", "::", "requiredConfig", "(", ")", "as", "$", "key", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "{", "$", "key", "}", ")", ")", "{", "throw", "new", "InvalidConfigException", "(", "get_class", "(", "$", "this", ")", ".", "\" key provider requires '{$key}' config key\"", ")", ";", "}", "}", "KeyProviderCollector", "::", "internalRegisterProvider", "(", "$", "this", ")", ";", "}" ]
Initializes the object and registers the provider @throws InvalidConfigException When a required configuration prarameter is not set @see \yii\base\Object
[ "Initializes", "the", "object", "and", "registers", "the", "provider" ]
c54f1c8af812bddf48872a05bc1d1e02112decc9
https://github.com/canis-io/yii2-key-provider/blob/c54f1c8af812bddf48872a05bc1d1e02112decc9/lib/providers/BaseProvider.php#L42-L55
10,613
canis-io/yii2-key-provider
lib/providers/BaseProvider.php
BaseProvider.setMasterKeyPairProvider
public function setMasterKeyPairProvider($provider) { if (isset($this->masterKeyPairProvider)) { throw new InvalidCallException('Setting read-only property: ' . get_class($this) . '::masterKeyPairProvider'); } if (is_array($provider)) { $provider = Yii::createObject($provider); } $this->masterKeyPairProvider = $provider; }
php
public function setMasterKeyPairProvider($provider) { if (isset($this->masterKeyPairProvider)) { throw new InvalidCallException('Setting read-only property: ' . get_class($this) . '::masterKeyPairProvider'); } if (is_array($provider)) { $provider = Yii::createObject($provider); } $this->masterKeyPairProvider = $provider; }
[ "public", "function", "setMasterKeyPairProvider", "(", "$", "provider", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "masterKeyPairProvider", ")", ")", "{", "throw", "new", "InvalidCallException", "(", "'Setting read-only property: '", ".", "get_class", "(", "$", "this", ")", ".", "'::masterKeyPairProvider'", ")", ";", "}", "if", "(", "is_array", "(", "$", "provider", ")", ")", "{", "$", "provider", "=", "Yii", "::", "createObject", "(", "$", "provider", ")", ";", "}", "$", "this", "->", "masterKeyPairProvider", "=", "$", "provider", ";", "}" ]
Sets the master key pair provider for use in secure key pairs @param ProviderInterface|array $provider The key pair provider for the master key
[ "Sets", "the", "master", "key", "pair", "provider", "for", "use", "in", "secure", "key", "pairs" ]
c54f1c8af812bddf48872a05bc1d1e02112decc9
https://github.com/canis-io/yii2-key-provider/blob/c54f1c8af812bddf48872a05bc1d1e02112decc9/lib/providers/BaseProvider.php#L62-L72
10,614
canis-io/yii2-key-provider
lib/providers/BaseProvider.php
BaseProvider.afterRetrieveKeyPair
protected function afterRetrieveKeyPair(KeyPairInterface $keyPair) { if ($keyPair instanceof SecureKeyPairInterface) { $masterKeyPairProvider = $this->getMasterKeyPairProvider(); $masterKeyName = $this->getMasterKeyName(); if ($masterKeyPairProvider === null || !$masterKeyPairProvider->has($masterKeyName)) { throw new InaccessibleKeyPairException('Provider has an invalid master key provider specified for its secure keys'); } $masterKey= $masterKeyPairProvider->get($masterKeyName); $keyPair->unlock($masterKey); } return $keyPair; }
php
protected function afterRetrieveKeyPair(KeyPairInterface $keyPair) { if ($keyPair instanceof SecureKeyPairInterface) { $masterKeyPairProvider = $this->getMasterKeyPairProvider(); $masterKeyName = $this->getMasterKeyName(); if ($masterKeyPairProvider === null || !$masterKeyPairProvider->has($masterKeyName)) { throw new InaccessibleKeyPairException('Provider has an invalid master key provider specified for its secure keys'); } $masterKey= $masterKeyPairProvider->get($masterKeyName); $keyPair->unlock($masterKey); } return $keyPair; }
[ "protected", "function", "afterRetrieveKeyPair", "(", "KeyPairInterface", "$", "keyPair", ")", "{", "if", "(", "$", "keyPair", "instanceof", "SecureKeyPairInterface", ")", "{", "$", "masterKeyPairProvider", "=", "$", "this", "->", "getMasterKeyPairProvider", "(", ")", ";", "$", "masterKeyName", "=", "$", "this", "->", "getMasterKeyName", "(", ")", ";", "if", "(", "$", "masterKeyPairProvider", "===", "null", "||", "!", "$", "masterKeyPairProvider", "->", "has", "(", "$", "masterKeyName", ")", ")", "{", "throw", "new", "InaccessibleKeyPairException", "(", "'Provider has an invalid master key provider specified for its secure keys'", ")", ";", "}", "$", "masterKey", "=", "$", "masterKeyPairProvider", "->", "get", "(", "$", "masterKeyName", ")", ";", "$", "keyPair", "->", "unlock", "(", "$", "masterKey", ")", ";", "}", "return", "$", "keyPair", ";", "}" ]
Process a key pair object after it was retrieved from the provider. Purpose is to unlock secure key pairs. @param KeyPairInterface $keyPair Key pair object that was just retrieved @return KeyPairInterface Original instance of the key pair
[ "Process", "a", "key", "pair", "object", "after", "it", "was", "retrieved", "from", "the", "provider", ".", "Purpose", "is", "to", "unlock", "secure", "key", "pairs", "." ]
c54f1c8af812bddf48872a05bc1d1e02112decc9
https://github.com/canis-io/yii2-key-provider/blob/c54f1c8af812bddf48872a05bc1d1e02112decc9/lib/providers/BaseProvider.php#L126-L138
10,615
canis-io/yii2-key-provider
lib/providers/BaseProvider.php
BaseProvider.afterGenerateKeyPair
protected function afterGenerateKeyPair(KeyPairInterface $keyPair) { if ($keyPair instanceof SecureKeyPairInterface) { $masterKeyPairProvider = $this->getMasterKeyPairProvider(); $masterKeyName = $this->getMasterKeyName(); if ($masterKeyPairProvider === null) { throw new InaccessibleKeyPairException('Provider has an invalid master key provider specified for its secure keys'); } if (!$masterKeyPairProvider->has($masterKeyName)) { $masterKey = $masterKeyPairProvider->generate($masterKeyName); } else { $masterKey = $masterKeyPairProvider->get($masterKeyName); } $keyPair->lock($masterKey); } return $keyPair; }
php
protected function afterGenerateKeyPair(KeyPairInterface $keyPair) { if ($keyPair instanceof SecureKeyPairInterface) { $masterKeyPairProvider = $this->getMasterKeyPairProvider(); $masterKeyName = $this->getMasterKeyName(); if ($masterKeyPairProvider === null) { throw new InaccessibleKeyPairException('Provider has an invalid master key provider specified for its secure keys'); } if (!$masterKeyPairProvider->has($masterKeyName)) { $masterKey = $masterKeyPairProvider->generate($masterKeyName); } else { $masterKey = $masterKeyPairProvider->get($masterKeyName); } $keyPair->lock($masterKey); } return $keyPair; }
[ "protected", "function", "afterGenerateKeyPair", "(", "KeyPairInterface", "$", "keyPair", ")", "{", "if", "(", "$", "keyPair", "instanceof", "SecureKeyPairInterface", ")", "{", "$", "masterKeyPairProvider", "=", "$", "this", "->", "getMasterKeyPairProvider", "(", ")", ";", "$", "masterKeyName", "=", "$", "this", "->", "getMasterKeyName", "(", ")", ";", "if", "(", "$", "masterKeyPairProvider", "===", "null", ")", "{", "throw", "new", "InaccessibleKeyPairException", "(", "'Provider has an invalid master key provider specified for its secure keys'", ")", ";", "}", "if", "(", "!", "$", "masterKeyPairProvider", "->", "has", "(", "$", "masterKeyName", ")", ")", "{", "$", "masterKey", "=", "$", "masterKeyPairProvider", "->", "generate", "(", "$", "masterKeyName", ")", ";", "}", "else", "{", "$", "masterKey", "=", "$", "masterKeyPairProvider", "->", "get", "(", "$", "masterKeyName", ")", ";", "}", "$", "keyPair", "->", "lock", "(", "$", "masterKey", ")", ";", "}", "return", "$", "keyPair", ";", "}" ]
Process a key pair object after it was generated @param KeyPairInterface $keyPair Key pair object that was just generated @return KeyPairInterface Original instance of the key pair
[ "Process", "a", "key", "pair", "object", "after", "it", "was", "generated" ]
c54f1c8af812bddf48872a05bc1d1e02112decc9
https://github.com/canis-io/yii2-key-provider/blob/c54f1c8af812bddf48872a05bc1d1e02112decc9/lib/providers/BaseProvider.php#L146-L162
10,616
canis-io/yii2-key-provider
lib/providers/BaseProvider.php
BaseProvider.setId
public function setId($id) { if (isset($this->id)) { throw new InvalidCallException('Setting read-only property: ' . get_class($this) . '::id'); } $this->id = $id; }
php
public function setId($id) { if (isset($this->id)) { throw new InvalidCallException('Setting read-only property: ' . get_class($this) . '::id'); } $this->id = $id; }
[ "public", "function", "setId", "(", "$", "id", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "id", ")", ")", "{", "throw", "new", "InvalidCallException", "(", "'Setting read-only property: '", ".", "get_class", "(", "$", "this", ")", ".", "'::id'", ")", ";", "}", "$", "this", "->", "id", "=", "$", "id", ";", "}" ]
Sets the provider ID @param string $id the ID of the provider @throws InvalidCallException when the ID is already set
[ "Sets", "the", "provider", "ID" ]
c54f1c8af812bddf48872a05bc1d1e02112decc9
https://github.com/canis-io/yii2-key-provider/blob/c54f1c8af812bddf48872a05bc1d1e02112decc9/lib/providers/BaseProvider.php#L178-L184
10,617
rawphp/RawApplication
src/RawPHP/RawApplication/Application.php
Application.init
public function init( $config = [ ] ) { $this->initDefaults(); $this->initMail( $config ); $this->initLog( $config ); $this->initDatabase( $config ); $this->initRequest( $config ); $this->initRouter( $config ); $this->initSession( $config ); $this->initAppName( $config ); $this->initDefaultLanguage( $config ); // $this->_initMaintenanceMode( $config ); }
php
public function init( $config = [ ] ) { $this->initDefaults(); $this->initMail( $config ); $this->initLog( $config ); $this->initDatabase( $config ); $this->initRequest( $config ); $this->initRouter( $config ); $this->initSession( $config ); $this->initAppName( $config ); $this->initDefaultLanguage( $config ); // $this->_initMaintenanceMode( $config ); }
[ "public", "function", "init", "(", "$", "config", "=", "[", "]", ")", "{", "$", "this", "->", "initDefaults", "(", ")", ";", "$", "this", "->", "initMail", "(", "$", "config", ")", ";", "$", "this", "->", "initLog", "(", "$", "config", ")", ";", "$", "this", "->", "initDatabase", "(", "$", "config", ")", ";", "$", "this", "->", "initRequest", "(", "$", "config", ")", ";", "$", "this", "->", "initRouter", "(", "$", "config", ")", ";", "$", "this", "->", "initSession", "(", "$", "config", ")", ";", "$", "this", "->", "initAppName", "(", "$", "config", ")", ";", "$", "this", "->", "initDefaultLanguage", "(", "$", "config", ")", ";", "// $this->_initMaintenanceMode( $config );", "}" ]
Initialises the application. @param array $config configuration array
[ "Initialises", "the", "application", "." ]
66e1afc693c4512354cc74087989b81d1b600d00
https://github.com/rawphp/RawApplication/blob/66e1afc693c4512354cc74087989b81d1b600d00/src/RawPHP/RawApplication/Application.php#L100-L121
10,618
rawphp/RawApplication
src/RawPHP/RawApplication/Application.php
Application.initDefaults
protected function initDefaults() { $this->bindShared( 'RawPHP\RawDispatcher\Contract\IDispatcher', function () { return new Dispatcher(); } ); $this->bindShared( 'RawPHP\RawFileSystem\Contract\IFileSystem', function () { return new FileSystem(); } ); $this->alias( 'RawPHP\RawDispatcher\Contract\IDispatcher', 'dispatcher' ); $this->alias( 'RawPHP\RawFileSystem\Contract\IFileSystem', 'files' ); }
php
protected function initDefaults() { $this->bindShared( 'RawPHP\RawDispatcher\Contract\IDispatcher', function () { return new Dispatcher(); } ); $this->bindShared( 'RawPHP\RawFileSystem\Contract\IFileSystem', function () { return new FileSystem(); } ); $this->alias( 'RawPHP\RawDispatcher\Contract\IDispatcher', 'dispatcher' ); $this->alias( 'RawPHP\RawFileSystem\Contract\IFileSystem', 'files' ); }
[ "protected", "function", "initDefaults", "(", ")", "{", "$", "this", "->", "bindShared", "(", "'RawPHP\\RawDispatcher\\Contract\\IDispatcher'", ",", "function", "(", ")", "{", "return", "new", "Dispatcher", "(", ")", ";", "}", ")", ";", "$", "this", "->", "bindShared", "(", "'RawPHP\\RawFileSystem\\Contract\\IFileSystem'", ",", "function", "(", ")", "{", "return", "new", "FileSystem", "(", ")", ";", "}", ")", ";", "$", "this", "->", "alias", "(", "'RawPHP\\RawDispatcher\\Contract\\IDispatcher'", ",", "'dispatcher'", ")", ";", "$", "this", "->", "alias", "(", "'RawPHP\\RawFileSystem\\Contract\\IFileSystem'", ",", "'files'", ")", ";", "}" ]
Initialise default services.
[ "Initialise", "default", "services", "." ]
66e1afc693c4512354cc74087989b81d1b600d00
https://github.com/rawphp/RawApplication/blob/66e1afc693c4512354cc74087989b81d1b600d00/src/RawPHP/RawApplication/Application.php#L136-L152
10,619
rawphp/RawApplication
src/RawPHP/RawApplication/Application.php
Application.initMail
protected function initMail( array $config ) { if ( isset( $config[ 'mail' ] ) ) { if ( isset( $config[ 'mail' ][ 'class' ] ) ) { $this->bindShared( 'RawPHP\RawMail\Contract\IMail', function () use ( $config ) { $class = $config[ 'mail' ][ 'class' ]; return new $class( $config ); } ); } else { $this->bindShared( 'RawPHP\RawMail\Contract\IMail', function () use ( $config ) { return new Mail( $config ); } ); } } else { $this->bindShared( 'RawPHP\RawMail\Contract\IMail', function () { return new Mail(); } ); } $this->alias( 'RawPHP\RawMail\Contract\IMail', 'mail' ); }
php
protected function initMail( array $config ) { if ( isset( $config[ 'mail' ] ) ) { if ( isset( $config[ 'mail' ][ 'class' ] ) ) { $this->bindShared( 'RawPHP\RawMail\Contract\IMail', function () use ( $config ) { $class = $config[ 'mail' ][ 'class' ]; return new $class( $config ); } ); } else { $this->bindShared( 'RawPHP\RawMail\Contract\IMail', function () use ( $config ) { return new Mail( $config ); } ); } } else { $this->bindShared( 'RawPHP\RawMail\Contract\IMail', function () { return new Mail(); } ); } $this->alias( 'RawPHP\RawMail\Contract\IMail', 'mail' ); }
[ "protected", "function", "initMail", "(", "array", "$", "config", ")", "{", "if", "(", "isset", "(", "$", "config", "[", "'mail'", "]", ")", ")", "{", "if", "(", "isset", "(", "$", "config", "[", "'mail'", "]", "[", "'class'", "]", ")", ")", "{", "$", "this", "->", "bindShared", "(", "'RawPHP\\RawMail\\Contract\\IMail'", ",", "function", "(", ")", "use", "(", "$", "config", ")", "{", "$", "class", "=", "$", "config", "[", "'mail'", "]", "[", "'class'", "]", ";", "return", "new", "$", "class", "(", "$", "config", ")", ";", "}", ")", ";", "}", "else", "{", "$", "this", "->", "bindShared", "(", "'RawPHP\\RawMail\\Contract\\IMail'", ",", "function", "(", ")", "use", "(", "$", "config", ")", "{", "return", "new", "Mail", "(", "$", "config", ")", ";", "}", ")", ";", "}", "}", "else", "{", "$", "this", "->", "bindShared", "(", "'RawPHP\\RawMail\\Contract\\IMail'", ",", "function", "(", ")", "{", "return", "new", "Mail", "(", ")", ";", "}", ")", ";", "}", "$", "this", "->", "alias", "(", "'RawPHP\\RawMail\\Contract\\IMail'", ",", "'mail'", ")", ";", "}" ]
Initialise the mail service. @param array $config
[ "Initialise", "the", "mail", "service", "." ]
66e1afc693c4512354cc74087989b81d1b600d00
https://github.com/rawphp/RawApplication/blob/66e1afc693c4512354cc74087989b81d1b600d00/src/RawPHP/RawApplication/Application.php#L159-L192
10,620
rawphp/RawApplication
src/RawPHP/RawApplication/Application.php
Application.initLog
protected function initLog( array $config ) { if ( isset( $config[ 'log' ] ) ) { if ( isset( $config[ 'log' ][ 'class' ] ) ) { $this->bindShared( 'RawPHP\RawLog\Contract\ILog', function () use ( $config ) { $class = $config[ 'log' ][ 'class' ]; return new $class( $config[ 'log' ] ); } ); } else { $this->bindShared( 'RawPHP\RawLog\Contract\ILog', function () use ( $config ) { return new Log( $config[ 'log' ] ); } ); } } else { $this->bindShared( 'RawPHP\RawLog\Contract\ILog', function () { return new Log(); } ); } $this->alias( 'RawPHP\RawLog\Contract\ILog', 'log' ); }
php
protected function initLog( array $config ) { if ( isset( $config[ 'log' ] ) ) { if ( isset( $config[ 'log' ][ 'class' ] ) ) { $this->bindShared( 'RawPHP\RawLog\Contract\ILog', function () use ( $config ) { $class = $config[ 'log' ][ 'class' ]; return new $class( $config[ 'log' ] ); } ); } else { $this->bindShared( 'RawPHP\RawLog\Contract\ILog', function () use ( $config ) { return new Log( $config[ 'log' ] ); } ); } } else { $this->bindShared( 'RawPHP\RawLog\Contract\ILog', function () { return new Log(); } ); } $this->alias( 'RawPHP\RawLog\Contract\ILog', 'log' ); }
[ "protected", "function", "initLog", "(", "array", "$", "config", ")", "{", "if", "(", "isset", "(", "$", "config", "[", "'log'", "]", ")", ")", "{", "if", "(", "isset", "(", "$", "config", "[", "'log'", "]", "[", "'class'", "]", ")", ")", "{", "$", "this", "->", "bindShared", "(", "'RawPHP\\RawLog\\Contract\\ILog'", ",", "function", "(", ")", "use", "(", "$", "config", ")", "{", "$", "class", "=", "$", "config", "[", "'log'", "]", "[", "'class'", "]", ";", "return", "new", "$", "class", "(", "$", "config", "[", "'log'", "]", ")", ";", "}", ")", ";", "}", "else", "{", "$", "this", "->", "bindShared", "(", "'RawPHP\\RawLog\\Contract\\ILog'", ",", "function", "(", ")", "use", "(", "$", "config", ")", "{", "return", "new", "Log", "(", "$", "config", "[", "'log'", "]", ")", ";", "}", ")", ";", "}", "}", "else", "{", "$", "this", "->", "bindShared", "(", "'RawPHP\\RawLog\\Contract\\ILog'", ",", "function", "(", ")", "{", "return", "new", "Log", "(", ")", ";", "}", ")", ";", "}", "$", "this", "->", "alias", "(", "'RawPHP\\RawLog\\Contract\\ILog'", ",", "'log'", ")", ";", "}" ]
Initialise the logger. @param array $config
[ "Initialise", "the", "logger", "." ]
66e1afc693c4512354cc74087989b81d1b600d00
https://github.com/rawphp/RawApplication/blob/66e1afc693c4512354cc74087989b81d1b600d00/src/RawPHP/RawApplication/Application.php#L199-L232
10,621
rawphp/RawApplication
src/RawPHP/RawApplication/Application.php
Application.initDatabase
protected function initDatabase( array $config ) { if ( isset( $config[ 'db' ] ) ) { if ( isset( $config[ 'db' ][ 'class' ] ) ) { $this->bindShared( 'RawPHP\RawDatabase\Contract\IDatabase', function () use ( $config ) { $class = $config[ 'db' ][ 'class' ]; return new $class( $config[ 'db' ] ); } ); } else { $this->bindShared( 'RawPHP\RawDatabase\Contract\IDatabase', function () use ( $config ) { return new Database( $config[ 'db' ] ); } ); } } $this->alias( 'RawPHP\RawDatabase\Contract\IDatabase', 'db' ); }
php
protected function initDatabase( array $config ) { if ( isset( $config[ 'db' ] ) ) { if ( isset( $config[ 'db' ][ 'class' ] ) ) { $this->bindShared( 'RawPHP\RawDatabase\Contract\IDatabase', function () use ( $config ) { $class = $config[ 'db' ][ 'class' ]; return new $class( $config[ 'db' ] ); } ); } else { $this->bindShared( 'RawPHP\RawDatabase\Contract\IDatabase', function () use ( $config ) { return new Database( $config[ 'db' ] ); } ); } } $this->alias( 'RawPHP\RawDatabase\Contract\IDatabase', 'db' ); }
[ "protected", "function", "initDatabase", "(", "array", "$", "config", ")", "{", "if", "(", "isset", "(", "$", "config", "[", "'db'", "]", ")", ")", "{", "if", "(", "isset", "(", "$", "config", "[", "'db'", "]", "[", "'class'", "]", ")", ")", "{", "$", "this", "->", "bindShared", "(", "'RawPHP\\RawDatabase\\Contract\\IDatabase'", ",", "function", "(", ")", "use", "(", "$", "config", ")", "{", "$", "class", "=", "$", "config", "[", "'db'", "]", "[", "'class'", "]", ";", "return", "new", "$", "class", "(", "$", "config", "[", "'db'", "]", ")", ";", "}", ")", ";", "}", "else", "{", "$", "this", "->", "bindShared", "(", "'RawPHP\\RawDatabase\\Contract\\IDatabase'", ",", "function", "(", ")", "use", "(", "$", "config", ")", "{", "return", "new", "Database", "(", "$", "config", "[", "'db'", "]", ")", ";", "}", ")", ";", "}", "}", "$", "this", "->", "alias", "(", "'RawPHP\\RawDatabase\\Contract\\IDatabase'", ",", "'db'", ")", ";", "}" ]
Initialise the database. @param array $config
[ "Initialise", "the", "database", "." ]
66e1afc693c4512354cc74087989b81d1b600d00
https://github.com/rawphp/RawApplication/blob/66e1afc693c4512354cc74087989b81d1b600d00/src/RawPHP/RawApplication/Application.php#L239-L264
10,622
rawphp/RawApplication
src/RawPHP/RawApplication/Application.php
Application.initRequest
protected function initRequest( array $config ) { if ( isset( $config[ 'request' ] ) ) { if ( isset( $config[ 'request' ][ 'class' ] ) ) { $this->bindShared( 'RawPHP\RawRequest\Contract\IRequest', function () use ( $config ) { $class = $config[ 'request' ][ 'class' ]; return new $class( $config[ 'request' ] ); } ); } else { $this->bindShared( 'RawPHP\RawRequest\Contract\IRequest', function () use ( $config ) { return new Request( $config[ 'request' ] ); } ); } } else { $this->bindShared( 'RawPHP\RawRequest\Contract\IRequest', function () { $request = new Request(); $request->init(); return $request; } ); } $this->alias( 'RawPHP\RawRequest\Contract\IRequest', 'request' ); }
php
protected function initRequest( array $config ) { if ( isset( $config[ 'request' ] ) ) { if ( isset( $config[ 'request' ][ 'class' ] ) ) { $this->bindShared( 'RawPHP\RawRequest\Contract\IRequest', function () use ( $config ) { $class = $config[ 'request' ][ 'class' ]; return new $class( $config[ 'request' ] ); } ); } else { $this->bindShared( 'RawPHP\RawRequest\Contract\IRequest', function () use ( $config ) { return new Request( $config[ 'request' ] ); } ); } } else { $this->bindShared( 'RawPHP\RawRequest\Contract\IRequest', function () { $request = new Request(); $request->init(); return $request; } ); } $this->alias( 'RawPHP\RawRequest\Contract\IRequest', 'request' ); }
[ "protected", "function", "initRequest", "(", "array", "$", "config", ")", "{", "if", "(", "isset", "(", "$", "config", "[", "'request'", "]", ")", ")", "{", "if", "(", "isset", "(", "$", "config", "[", "'request'", "]", "[", "'class'", "]", ")", ")", "{", "$", "this", "->", "bindShared", "(", "'RawPHP\\RawRequest\\Contract\\IRequest'", ",", "function", "(", ")", "use", "(", "$", "config", ")", "{", "$", "class", "=", "$", "config", "[", "'request'", "]", "[", "'class'", "]", ";", "return", "new", "$", "class", "(", "$", "config", "[", "'request'", "]", ")", ";", "}", ")", ";", "}", "else", "{", "$", "this", "->", "bindShared", "(", "'RawPHP\\RawRequest\\Contract\\IRequest'", ",", "function", "(", ")", "use", "(", "$", "config", ")", "{", "return", "new", "Request", "(", "$", "config", "[", "'request'", "]", ")", ";", "}", ")", ";", "}", "}", "else", "{", "$", "this", "->", "bindShared", "(", "'RawPHP\\RawRequest\\Contract\\IRequest'", ",", "function", "(", ")", "{", "$", "request", "=", "new", "Request", "(", ")", ";", "$", "request", "->", "init", "(", ")", ";", "return", "$", "request", ";", "}", ")", ";", "}", "$", "this", "->", "alias", "(", "'RawPHP\\RawRequest\\Contract\\IRequest'", ",", "'request'", ")", ";", "}" ]
Initialises the request instance. @param array $config configuration array
[ "Initialises", "the", "request", "instance", "." ]
66e1afc693c4512354cc74087989b81d1b600d00
https://github.com/rawphp/RawApplication/blob/66e1afc693c4512354cc74087989b81d1b600d00/src/RawPHP/RawApplication/Application.php#L271-L307
10,623
rawphp/RawApplication
src/RawPHP/RawApplication/Application.php
Application.initRouter
protected function initRouter( array $config ) { if ( isset( $config[ 'router' ] ) ) { if ( isset( $config[ 'router' ][ 'class' ] ) ) { $this->bindShared( 'RawPHP\RawRouter\Contract\IRouter', function () use ( $config ) { $class = $config[ 'router' ][ 'class' ]; return new $class( $config[ 'router' ] ); } ); } else { $this->bindShared( 'RawPHP\RawRouter\Contract\IRouter', function () use ( $config ) { return new Router( $config[ 'router' ] ); } ); } } else { $this->bindShared( 'RawPHP\RawRouter\Contract\IRouter', function () { return new Router(); } ); } $this->alias( 'RawPHP\RawRouter\Contract\IRouter', 'RawPHP\RawRouter\Router' ); $this->alias( 'RawPHP\RawRouter\Contract\IRouter', 'router' ); $this[ 'router' ]->setDispatcher( $this[ 'dispatcher' ] ); $this->defaultController = $this[ 'router' ]->getDefaultController(); $this->defaultAction = $this[ 'router' ]->getDefaultAction(); }
php
protected function initRouter( array $config ) { if ( isset( $config[ 'router' ] ) ) { if ( isset( $config[ 'router' ][ 'class' ] ) ) { $this->bindShared( 'RawPHP\RawRouter\Contract\IRouter', function () use ( $config ) { $class = $config[ 'router' ][ 'class' ]; return new $class( $config[ 'router' ] ); } ); } else { $this->bindShared( 'RawPHP\RawRouter\Contract\IRouter', function () use ( $config ) { return new Router( $config[ 'router' ] ); } ); } } else { $this->bindShared( 'RawPHP\RawRouter\Contract\IRouter', function () { return new Router(); } ); } $this->alias( 'RawPHP\RawRouter\Contract\IRouter', 'RawPHP\RawRouter\Router' ); $this->alias( 'RawPHP\RawRouter\Contract\IRouter', 'router' ); $this[ 'router' ]->setDispatcher( $this[ 'dispatcher' ] ); $this->defaultController = $this[ 'router' ]->getDefaultController(); $this->defaultAction = $this[ 'router' ]->getDefaultAction(); }
[ "protected", "function", "initRouter", "(", "array", "$", "config", ")", "{", "if", "(", "isset", "(", "$", "config", "[", "'router'", "]", ")", ")", "{", "if", "(", "isset", "(", "$", "config", "[", "'router'", "]", "[", "'class'", "]", ")", ")", "{", "$", "this", "->", "bindShared", "(", "'RawPHP\\RawRouter\\Contract\\IRouter'", ",", "function", "(", ")", "use", "(", "$", "config", ")", "{", "$", "class", "=", "$", "config", "[", "'router'", "]", "[", "'class'", "]", ";", "return", "new", "$", "class", "(", "$", "config", "[", "'router'", "]", ")", ";", "}", ")", ";", "}", "else", "{", "$", "this", "->", "bindShared", "(", "'RawPHP\\RawRouter\\Contract\\IRouter'", ",", "function", "(", ")", "use", "(", "$", "config", ")", "{", "return", "new", "Router", "(", "$", "config", "[", "'router'", "]", ")", ";", "}", ")", ";", "}", "}", "else", "{", "$", "this", "->", "bindShared", "(", "'RawPHP\\RawRouter\\Contract\\IRouter'", ",", "function", "(", ")", "{", "return", "new", "Router", "(", ")", ";", "}", ")", ";", "}", "$", "this", "->", "alias", "(", "'RawPHP\\RawRouter\\Contract\\IRouter'", ",", "'RawPHP\\RawRouter\\Router'", ")", ";", "$", "this", "->", "alias", "(", "'RawPHP\\RawRouter\\Contract\\IRouter'", ",", "'router'", ")", ";", "$", "this", "[", "'router'", "]", "->", "setDispatcher", "(", "$", "this", "[", "'dispatcher'", "]", ")", ";", "$", "this", "->", "defaultController", "=", "$", "this", "[", "'router'", "]", "->", "getDefaultController", "(", ")", ";", "$", "this", "->", "defaultAction", "=", "$", "this", "[", "'router'", "]", "->", "getDefaultAction", "(", ")", ";", "}" ]
Initialises the router. @param array $config configuration array
[ "Initialises", "the", "router", "." ]
66e1afc693c4512354cc74087989b81d1b600d00
https://github.com/rawphp/RawApplication/blob/66e1afc693c4512354cc74087989b81d1b600d00/src/RawPHP/RawApplication/Application.php#L314-L353
10,624
rawphp/RawApplication
src/RawPHP/RawApplication/Application.php
Application.initAppName
protected function initAppName( array $config ) { $appName = 'Application'; if ( isset( $config[ 'app' ][ 'name' ] ) ) { $appName = $config[ 'app' ][ 'name' ]; } $this->appName = $appName; }
php
protected function initAppName( array $config ) { $appName = 'Application'; if ( isset( $config[ 'app' ][ 'name' ] ) ) { $appName = $config[ 'app' ][ 'name' ]; } $this->appName = $appName; }
[ "protected", "function", "initAppName", "(", "array", "$", "config", ")", "{", "$", "appName", "=", "'Application'", ";", "if", "(", "isset", "(", "$", "config", "[", "'app'", "]", "[", "'name'", "]", ")", ")", "{", "$", "appName", "=", "$", "config", "[", "'app'", "]", "[", "'name'", "]", ";", "}", "$", "this", "->", "appName", "=", "$", "appName", ";", "}" ]
Initialises the application name. @param array $config configuration array
[ "Initialises", "the", "application", "name", "." ]
66e1afc693c4512354cc74087989b81d1b600d00
https://github.com/rawphp/RawApplication/blob/66e1afc693c4512354cc74087989b81d1b600d00/src/RawPHP/RawApplication/Application.php#L410-L420
10,625
rawphp/RawApplication
src/RawPHP/RawApplication/Application.php
Application.initDefaultLanguage
protected function initDefaultLanguage( array $config ) { $language = 'en_US'; if ( isset( $config[ 'default_language' ] ) ) { $language = $config[ 'default_language' ]; } $this->defaultLanguage = $language; }
php
protected function initDefaultLanguage( array $config ) { $language = 'en_US'; if ( isset( $config[ 'default_language' ] ) ) { $language = $config[ 'default_language' ]; } $this->defaultLanguage = $language; }
[ "protected", "function", "initDefaultLanguage", "(", "array", "$", "config", ")", "{", "$", "language", "=", "'en_US'", ";", "if", "(", "isset", "(", "$", "config", "[", "'default_language'", "]", ")", ")", "{", "$", "language", "=", "$", "config", "[", "'default_language'", "]", ";", "}", "$", "this", "->", "defaultLanguage", "=", "$", "language", ";", "}" ]
Initialises the default language used in the app. @param array $config configuration array
[ "Initialises", "the", "default", "language", "used", "in", "the", "app", "." ]
66e1afc693c4512354cc74087989b81d1b600d00
https://github.com/rawphp/RawApplication/blob/66e1afc693c4512354cc74087989b81d1b600d00/src/RawPHP/RawApplication/Application.php#L427-L437
10,626
rawphp/RawApplication
src/RawPHP/RawApplication/Application.php
Application.processRequest
protected function processRequest() { $route = $this[ 'request' ]->getRoute(); $params = $this[ 'request' ]->getParams(); $controller = $this[ 'router' ]->createController( $route, $params ); if ( NULL === $controller ) { throw new RawException( 'Failed to Initialise Controller', 404 ); } $this->controller = $controller; /** @var IController $controller */ $controller->run(); }
php
protected function processRequest() { $route = $this[ 'request' ]->getRoute(); $params = $this[ 'request' ]->getParams(); $controller = $this[ 'router' ]->createController( $route, $params ); if ( NULL === $controller ) { throw new RawException( 'Failed to Initialise Controller', 404 ); } $this->controller = $controller; /** @var IController $controller */ $controller->run(); }
[ "protected", "function", "processRequest", "(", ")", "{", "$", "route", "=", "$", "this", "[", "'request'", "]", "->", "getRoute", "(", ")", ";", "$", "params", "=", "$", "this", "[", "'request'", "]", "->", "getParams", "(", ")", ";", "$", "controller", "=", "$", "this", "[", "'router'", "]", "->", "createController", "(", "$", "route", ",", "$", "params", ")", ";", "if", "(", "NULL", "===", "$", "controller", ")", "{", "throw", "new", "RawException", "(", "'Failed to Initialise Controller'", ",", "404", ")", ";", "}", "$", "this", "->", "controller", "=", "$", "controller", ";", "/** @var IController $controller */", "$", "controller", "->", "run", "(", ")", ";", "}" ]
Processes the HTTP request. @throws RawException
[ "Processes", "the", "HTTP", "request", "." ]
66e1afc693c4512354cc74087989b81d1b600d00
https://github.com/rawphp/RawApplication/blob/66e1afc693c4512354cc74087989b81d1b600d00/src/RawPHP/RawApplication/Application.php#L496-L512
10,627
rawphp/RawApplication
src/RawPHP/RawApplication/Application.php
Application.createUrl
public function createUrl( $route, $params = [ ], $absolute = FALSE ) { return $this[ 'request' ]->createUrl( $route, $params, $absolute ); }
php
public function createUrl( $route, $params = [ ], $absolute = FALSE ) { return $this[ 'request' ]->createUrl( $route, $params, $absolute ); }
[ "public", "function", "createUrl", "(", "$", "route", ",", "$", "params", "=", "[", "]", ",", "$", "absolute", "=", "FALSE", ")", "{", "return", "$", "this", "[", "'request'", "]", "->", "createUrl", "(", "$", "route", ",", "$", "params", ",", "$", "absolute", ")", ";", "}" ]
Creates a new url. @param string $route controller/method route @param array $params list of parameters @param bool $absolute whether it should be an absolute url @return string the url
[ "Creates", "a", "new", "url", "." ]
66e1afc693c4512354cc74087989b81d1b600d00
https://github.com/rawphp/RawApplication/blob/66e1afc693c4512354cc74087989b81d1b600d00/src/RawPHP/RawApplication/Application.php#L523-L526
10,628
rawphp/RawApplication
src/RawPHP/RawApplication/Application.php
Application.addFlash
public function addFlash( $message, $type = 'error' ) { if ( 'error' === $type ) { $this->flash[ 'errors' ][ ] = $message; } else { $this->flash[ 'success' ][ ] = $message; } //$this[ 'session' ]->add( 'messages', $this->flash ); }
php
public function addFlash( $message, $type = 'error' ) { if ( 'error' === $type ) { $this->flash[ 'errors' ][ ] = $message; } else { $this->flash[ 'success' ][ ] = $message; } //$this[ 'session' ]->add( 'messages', $this->flash ); }
[ "public", "function", "addFlash", "(", "$", "message", ",", "$", "type", "=", "'error'", ")", "{", "if", "(", "'error'", "===", "$", "type", ")", "{", "$", "this", "->", "flash", "[", "'errors'", "]", "[", "]", "=", "$", "message", ";", "}", "else", "{", "$", "this", "->", "flash", "[", "'success'", "]", "[", "]", "=", "$", "message", ";", "}", "//$this[ 'session' ]->add( 'messages', $this->flash );", "}" ]
Adds a flash message to appear on the next page. Error => 'error' ( default ) Success => 'success' @param string $message success or error message @param string $type the type of message
[ "Adds", "a", "flash", "message", "to", "appear", "on", "the", "next", "page", "." ]
66e1afc693c4512354cc74087989b81d1b600d00
https://github.com/rawphp/RawApplication/blob/66e1afc693c4512354cc74087989b81d1b600d00/src/RawPHP/RawApplication/Application.php#L537-L549
10,629
cyberspectrum/i18n-xliff
src/Xml/XliffFile.php
XliffFile.setDate
public function setDate(\DateTime $date): void { $this->getFileElement()->setAttributeNS(static::XLIFF_NS, 'date', $date->format(\DateTime::ATOM)); }
php
public function setDate(\DateTime $date): void { $this->getFileElement()->setAttributeNS(static::XLIFF_NS, 'date', $date->format(\DateTime::ATOM)); }
[ "public", "function", "setDate", "(", "\\", "DateTime", "$", "date", ")", ":", "void", "{", "$", "this", "->", "getFileElement", "(", ")", "->", "setAttributeNS", "(", "static", "::", "XLIFF_NS", ",", "'date'", ",", "$", "date", "->", "format", "(", "\\", "DateTime", "::", "ATOM", ")", ")", ";", "}" ]
Sets the last modification time in this file. @param \DateTime $date The date. @return void
[ "Sets", "the", "last", "modification", "time", "in", "this", "file", "." ]
9d03f85a33c8f6fc9acd99770f23800679f130b3
https://github.com/cyberspectrum/i18n-xliff/blob/9d03f85a33c8f6fc9acd99770f23800679f130b3/src/Xml/XliffFile.php#L114-L117
10,630
cyberspectrum/i18n-xliff
src/Xml/XliffFile.php
XliffFile.setSourceLanguage
public function setSourceLanguage($sourceLanguage): void { if (!preg_match('#[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*#', $sourceLanguage)) { throw new \InvalidArgumentException('Invalid language string: "' . $sourceLanguage . '"'); } $this->getFileElement()->setAttributeNS(static::XLIFF_NS, 'source-language', $sourceLanguage); }
php
public function setSourceLanguage($sourceLanguage): void { if (!preg_match('#[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*#', $sourceLanguage)) { throw new \InvalidArgumentException('Invalid language string: "' . $sourceLanguage . '"'); } $this->getFileElement()->setAttributeNS(static::XLIFF_NS, 'source-language', $sourceLanguage); }
[ "public", "function", "setSourceLanguage", "(", "$", "sourceLanguage", ")", ":", "void", "{", "if", "(", "!", "preg_match", "(", "'#[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*#'", ",", "$", "sourceLanguage", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Invalid language string: \"'", ".", "$", "sourceLanguage", ".", "'\"'", ")", ";", "}", "$", "this", "->", "getFileElement", "(", ")", "->", "setAttributeNS", "(", "static", "::", "XLIFF_NS", ",", "'source-language'", ",", "$", "sourceLanguage", ")", ";", "}" ]
Set the source language for this file. @param string $sourceLanguage The language code from ISO 639-1. @return void @throws \InvalidArgumentException When the language string is invalid.
[ "Set", "the", "source", "language", "for", "this", "file", "." ]
9d03f85a33c8f6fc9acd99770f23800679f130b3
https://github.com/cyberspectrum/i18n-xliff/blob/9d03f85a33c8f6fc9acd99770f23800679f130b3/src/Xml/XliffFile.php#L162-L168
10,631
cyberspectrum/i18n-xliff
src/Xml/XliffFile.php
XliffFile.setTargetLanguage
public function setTargetLanguage($targetLanguage): void { if (!preg_match('#[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*#', $targetLanguage)) { throw new \InvalidArgumentException('Invalid language string: "' . $targetLanguage . '"'); } $this->getFileElement()->setAttributeNS(static::XLIFF_NS, 'target-language', $targetLanguage); }
php
public function setTargetLanguage($targetLanguage): void { if (!preg_match('#[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*#', $targetLanguage)) { throw new \InvalidArgumentException('Invalid language string: "' . $targetLanguage . '"'); } $this->getFileElement()->setAttributeNS(static::XLIFF_NS, 'target-language', $targetLanguage); }
[ "public", "function", "setTargetLanguage", "(", "$", "targetLanguage", ")", ":", "void", "{", "if", "(", "!", "preg_match", "(", "'#[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*#'", ",", "$", "targetLanguage", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Invalid language string: \"'", ".", "$", "targetLanguage", ".", "'\"'", ")", ";", "}", "$", "this", "->", "getFileElement", "(", ")", "->", "setAttributeNS", "(", "static", "::", "XLIFF_NS", ",", "'target-language'", ",", "$", "targetLanguage", ")", ";", "}" ]
Set the target language for this file. @param string $targetLanguage The language code from ISO 639-1. @return void @throws \InvalidArgumentException When the language string is invalid.
[ "Set", "the", "target", "language", "for", "this", "file", "." ]
9d03f85a33c8f6fc9acd99770f23800679f130b3
https://github.com/cyberspectrum/i18n-xliff/blob/9d03f85a33c8f6fc9acd99770f23800679f130b3/src/Xml/XliffFile.php#L189-L195
10,632
cyberspectrum/i18n-xliff
src/Xml/XliffFile.php
XliffFile.createTranslationUnit
public function createTranslationUnit(string $identifier, string $sourceValue = null): XmlElement { if (null === $body = $this->getXPathFirstItem('/xlf:xliff/xlf:file/xlf:body')) { throw new \InvalidArgumentException('Could not find the xliff body element'); } /** @var XmlElement $transUnit */ $transUnit = $this->createElementNS(self::XLIFF_NS, 'trans-unit'); $body->appendChild($transUnit); $transUnit->setAttributeNS(self::XLIFF_NS, 'id', $identifier); $source = $transUnit->appendChild($this->createElementNS(self::XLIFF_NS, 'source')); if (null !== $sourceValue) { $source->appendChild($this->createTextNode($sourceValue)); } return $transUnit; }
php
public function createTranslationUnit(string $identifier, string $sourceValue = null): XmlElement { if (null === $body = $this->getXPathFirstItem('/xlf:xliff/xlf:file/xlf:body')) { throw new \InvalidArgumentException('Could not find the xliff body element'); } /** @var XmlElement $transUnit */ $transUnit = $this->createElementNS(self::XLIFF_NS, 'trans-unit'); $body->appendChild($transUnit); $transUnit->setAttributeNS(self::XLIFF_NS, 'id', $identifier); $source = $transUnit->appendChild($this->createElementNS(self::XLIFF_NS, 'source')); if (null !== $sourceValue) { $source->appendChild($this->createTextNode($sourceValue)); } return $transUnit; }
[ "public", "function", "createTranslationUnit", "(", "string", "$", "identifier", ",", "string", "$", "sourceValue", "=", "null", ")", ":", "XmlElement", "{", "if", "(", "null", "===", "$", "body", "=", "$", "this", "->", "getXPathFirstItem", "(", "'/xlf:xliff/xlf:file/xlf:body'", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Could not find the xliff body element'", ")", ";", "}", "/** @var XmlElement $transUnit */", "$", "transUnit", "=", "$", "this", "->", "createElementNS", "(", "self", "::", "XLIFF_NS", ",", "'trans-unit'", ")", ";", "$", "body", "->", "appendChild", "(", "$", "transUnit", ")", ";", "$", "transUnit", "->", "setAttributeNS", "(", "self", "::", "XLIFF_NS", ",", "'id'", ",", "$", "identifier", ")", ";", "$", "source", "=", "$", "transUnit", "->", "appendChild", "(", "$", "this", "->", "createElementNS", "(", "self", "::", "XLIFF_NS", ",", "'source'", ")", ")", ";", "if", "(", "null", "!==", "$", "sourceValue", ")", "{", "$", "source", "->", "appendChild", "(", "$", "this", "->", "createTextNode", "(", "$", "sourceValue", ")", ")", ";", "}", "return", "$", "transUnit", ";", "}" ]
Append a translation unit. @param string $identifier The identifier to set. @param string $sourceValue The content for the source value to set. @return XmlElement @throws \InvalidArgumentException When the body element can not be found.
[ "Append", "a", "translation", "unit", "." ]
9d03f85a33c8f6fc9acd99770f23800679f130b3
https://github.com/cyberspectrum/i18n-xliff/blob/9d03f85a33c8f6fc9acd99770f23800679f130b3/src/Xml/XliffFile.php#L253-L271
10,633
cyberspectrum/i18n-xliff
src/Xml/XliffFile.php
XliffFile.extractTranslationKeys
public function extractTranslationKeys(): \Generator { /** @var \DOMNodeList $tmp */ $transUnits = $this->getXPath()->query('/xlf:xliff/xlf:file/xlf:body/xlf:trans-unit'); if ($transUnits->length > 0) { /** @var \DOMElement $element */ foreach ($transUnits as $element) { if ('' === $key = $element->getAttributeNS(self::XLIFF_NS, 'id')) { throw new \RuntimeException('Empty Id: ' . var_export($element, true)); } yield $key; } } }
php
public function extractTranslationKeys(): \Generator { /** @var \DOMNodeList $tmp */ $transUnits = $this->getXPath()->query('/xlf:xliff/xlf:file/xlf:body/xlf:trans-unit'); if ($transUnits->length > 0) { /** @var \DOMElement $element */ foreach ($transUnits as $element) { if ('' === $key = $element->getAttributeNS(self::XLIFF_NS, 'id')) { throw new \RuntimeException('Empty Id: ' . var_export($element, true)); } yield $key; } } }
[ "public", "function", "extractTranslationKeys", "(", ")", ":", "\\", "Generator", "{", "/** @var \\DOMNodeList $tmp */", "$", "transUnits", "=", "$", "this", "->", "getXPath", "(", ")", "->", "query", "(", "'/xlf:xliff/xlf:file/xlf:body/xlf:trans-unit'", ")", ";", "if", "(", "$", "transUnits", "->", "length", ">", "0", ")", "{", "/** @var \\DOMElement $element */", "foreach", "(", "$", "transUnits", "as", "$", "element", ")", "{", "if", "(", "''", "===", "$", "key", "=", "$", "element", "->", "getAttributeNS", "(", "self", "::", "XLIFF_NS", ",", "'id'", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'Empty Id: '", ".", "var_export", "(", "$", "element", ",", "true", ")", ")", ";", "}", "yield", "$", "key", ";", "}", "}", "}" ]
Obtain all keys within the dictionary. @return \Generator @throws \RuntimeException When the id is empty.
[ "Obtain", "all", "keys", "within", "the", "dictionary", "." ]
9d03f85a33c8f6fc9acd99770f23800679f130b3
https://github.com/cyberspectrum/i18n-xliff/blob/9d03f85a33c8f6fc9acd99770f23800679f130b3/src/Xml/XliffFile.php#L280-L294
10,634
cyberspectrum/i18n-xliff
src/Xml/XliffFile.php
XliffFile.getXPathFirstItem
private function getXPathFirstItem($query, $contextNode = null) { /** @var \DOMNodeList $tmp */ $tmp = $this->getXPath()->query($query, $contextNode); return $tmp->length ? $tmp->item(0) : null; }
php
private function getXPathFirstItem($query, $contextNode = null) { /** @var \DOMNodeList $tmp */ $tmp = $this->getXPath()->query($query, $contextNode); return $tmp->length ? $tmp->item(0) : null; }
[ "private", "function", "getXPathFirstItem", "(", "$", "query", ",", "$", "contextNode", "=", "null", ")", "{", "/** @var \\DOMNodeList $tmp */", "$", "tmp", "=", "$", "this", "->", "getXPath", "(", ")", "->", "query", "(", "$", "query", ",", "$", "contextNode", ")", ";", "return", "$", "tmp", "->", "length", "?", "$", "tmp", "->", "item", "(", "0", ")", ":", "null", ";", "}" ]
Perform a Xpath search with the given query and return the first match if found. @param string $query The query to use. @param null $contextNode The context node to apply. @return \DOMElement|\DOMNode|null
[ "Perform", "a", "Xpath", "search", "with", "the", "given", "query", "and", "return", "the", "first", "match", "if", "found", "." ]
9d03f85a33c8f6fc9acd99770f23800679f130b3
https://github.com/cyberspectrum/i18n-xliff/blob/9d03f85a33c8f6fc9acd99770f23800679f130b3/src/Xml/XliffFile.php#L317-L323
10,635
MinyFramework/Miny-Templating
src/Module.php
Module.setupEnvironment
public function setupEnvironment(Container $container) { $env = new Environment( $container->get('Minty\\AbstractTemplateLoader'), $this->getConfiguration('options') ); /** @var $request \Miny\HTTP\Request */ $request = $container->get('Miny\\HTTP\\Request'); $env->addGlobalVariable('is_ajax', $request->isAjax()); $env->addGlobalVariable('is_internal_request', $request->isSubRequest()); $env->addExtension(new Core()); $env->addExtension(new Optimizer()); $env->addExtension($container->get(__NAMESPACE__ . '\\Extensions\\Miny')); if ($env->getOption('debug')) { $env->addExtension(new Debug()); if ($this->getConfiguration('enable_node_tree_visualizer')) { $env->addExtension($container->get(__NAMESPACE__ . '\\Extensions\\Visualizer')); } } return $env; }
php
public function setupEnvironment(Container $container) { $env = new Environment( $container->get('Minty\\AbstractTemplateLoader'), $this->getConfiguration('options') ); /** @var $request \Miny\HTTP\Request */ $request = $container->get('Miny\\HTTP\\Request'); $env->addGlobalVariable('is_ajax', $request->isAjax()); $env->addGlobalVariable('is_internal_request', $request->isSubRequest()); $env->addExtension(new Core()); $env->addExtension(new Optimizer()); $env->addExtension($container->get(__NAMESPACE__ . '\\Extensions\\Miny')); if ($env->getOption('debug')) { $env->addExtension(new Debug()); if ($this->getConfiguration('enable_node_tree_visualizer')) { $env->addExtension($container->get(__NAMESPACE__ . '\\Extensions\\Visualizer')); } } return $env; }
[ "public", "function", "setupEnvironment", "(", "Container", "$", "container", ")", "{", "$", "env", "=", "new", "Environment", "(", "$", "container", "->", "get", "(", "'Minty\\\\AbstractTemplateLoader'", ")", ",", "$", "this", "->", "getConfiguration", "(", "'options'", ")", ")", ";", "/** @var $request \\Miny\\HTTP\\Request */", "$", "request", "=", "$", "container", "->", "get", "(", "'Miny\\\\HTTP\\\\Request'", ")", ";", "$", "env", "->", "addGlobalVariable", "(", "'is_ajax'", ",", "$", "request", "->", "isAjax", "(", ")", ")", ";", "$", "env", "->", "addGlobalVariable", "(", "'is_internal_request'", ",", "$", "request", "->", "isSubRequest", "(", ")", ")", ";", "$", "env", "->", "addExtension", "(", "new", "Core", "(", ")", ")", ";", "$", "env", "->", "addExtension", "(", "new", "Optimizer", "(", ")", ")", ";", "$", "env", "->", "addExtension", "(", "$", "container", "->", "get", "(", "__NAMESPACE__", ".", "'\\\\Extensions\\\\Miny'", ")", ")", ";", "if", "(", "$", "env", "->", "getOption", "(", "'debug'", ")", ")", "{", "$", "env", "->", "addExtension", "(", "new", "Debug", "(", ")", ")", ";", "if", "(", "$", "this", "->", "getConfiguration", "(", "'enable_node_tree_visualizer'", ")", ")", "{", "$", "env", "->", "addExtension", "(", "$", "container", "->", "get", "(", "__NAMESPACE__", ".", "'\\\\Extensions\\\\Visualizer'", ")", ")", ";", "}", "}", "return", "$", "env", ";", "}" ]
This method is responsible for initializing the Environment. Called by Container. @param Container $container @return Environment
[ "This", "method", "is", "responsible", "for", "initializing", "the", "Environment", ".", "Called", "by", "Container", "." ]
bdd5dc2956a8e009cedc18745f5c4f498941a591
https://github.com/MinyFramework/Miny-Templating/blob/bdd5dc2956a8e009cedc18745f5c4f498941a591/src/Module.php#L68-L94
10,636
atelierspierrot/validators
src/Validator/EmailValidator.php
EmailValidator.validateLocalPart
public function validateLocalPart($value, $send_errors=false) { // check for local part length compliance (max 64 chars.) $lengthValidator = new StringLengthValidator(0, 64); try { if (false===$local_length_valid = $lengthValidator->validate($value, false)) { if (true===$send_errors) { throw new \Exception(sprintf('The local part of the email address [%s] must not be up to 64 characters!', $value)); } return false; } } catch (\Exception $e) { throw $e; } // check for dots in local part // => not the first character if (substr($value, 0, 1)=='.') { if (true===$send_errors) { throw new \Exception(sprintf('The local part of the email address [%s] must not begin with a dot!', $value)); } return false; } // => not the last character if (substr($value, -1, 1)=='.') { if (true===$send_errors) { throw new \Exception(sprintf('The local part of the email address [%s] must not end with a dot!', $value)); } return false; } // => no double-dots if (false!==strpos($value, '..')) { if (true===$send_errors) { throw new \Exception(sprintf('The local part of the email address [%s] must not contain double-dots!', $value)); } return false; } // the local part must match the standards as wanted $last=0; foreach (self::$standards_list as $standard) { if (1===$last) { continue; } if ($standard==$this->must_pass) { $last=1; } $maskValidator = new StringMaskValidator( '^' . $this->getMask($standard) . '$', $standard ); try { if (false===$local_part_mask_valid = $maskValidator->validate($value, $send_errors)) { return false; } } catch (\Exception $e) { throw $e; } } return true; }
php
public function validateLocalPart($value, $send_errors=false) { // check for local part length compliance (max 64 chars.) $lengthValidator = new StringLengthValidator(0, 64); try { if (false===$local_length_valid = $lengthValidator->validate($value, false)) { if (true===$send_errors) { throw new \Exception(sprintf('The local part of the email address [%s] must not be up to 64 characters!', $value)); } return false; } } catch (\Exception $e) { throw $e; } // check for dots in local part // => not the first character if (substr($value, 0, 1)=='.') { if (true===$send_errors) { throw new \Exception(sprintf('The local part of the email address [%s] must not begin with a dot!', $value)); } return false; } // => not the last character if (substr($value, -1, 1)=='.') { if (true===$send_errors) { throw new \Exception(sprintf('The local part of the email address [%s] must not end with a dot!', $value)); } return false; } // => no double-dots if (false!==strpos($value, '..')) { if (true===$send_errors) { throw new \Exception(sprintf('The local part of the email address [%s] must not contain double-dots!', $value)); } return false; } // the local part must match the standards as wanted $last=0; foreach (self::$standards_list as $standard) { if (1===$last) { continue; } if ($standard==$this->must_pass) { $last=1; } $maskValidator = new StringMaskValidator( '^' . $this->getMask($standard) . '$', $standard ); try { if (false===$local_part_mask_valid = $maskValidator->validate($value, $send_errors)) { return false; } } catch (\Exception $e) { throw $e; } } return true; }
[ "public", "function", "validateLocalPart", "(", "$", "value", ",", "$", "send_errors", "=", "false", ")", "{", "// check for local part length compliance (max 64 chars.)", "$", "lengthValidator", "=", "new", "StringLengthValidator", "(", "0", ",", "64", ")", ";", "try", "{", "if", "(", "false", "===", "$", "local_length_valid", "=", "$", "lengthValidator", "->", "validate", "(", "$", "value", ",", "false", ")", ")", "{", "if", "(", "true", "===", "$", "send_errors", ")", "{", "throw", "new", "\\", "Exception", "(", "sprintf", "(", "'The local part of the email address [%s] must not be up to 64 characters!'", ",", "$", "value", ")", ")", ";", "}", "return", "false", ";", "}", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "throw", "$", "e", ";", "}", "// check for dots in local part", "// => not the first character", "if", "(", "substr", "(", "$", "value", ",", "0", ",", "1", ")", "==", "'.'", ")", "{", "if", "(", "true", "===", "$", "send_errors", ")", "{", "throw", "new", "\\", "Exception", "(", "sprintf", "(", "'The local part of the email address [%s] must not begin with a dot!'", ",", "$", "value", ")", ")", ";", "}", "return", "false", ";", "}", "// => not the last character", "if", "(", "substr", "(", "$", "value", ",", "-", "1", ",", "1", ")", "==", "'.'", ")", "{", "if", "(", "true", "===", "$", "send_errors", ")", "{", "throw", "new", "\\", "Exception", "(", "sprintf", "(", "'The local part of the email address [%s] must not end with a dot!'", ",", "$", "value", ")", ")", ";", "}", "return", "false", ";", "}", "// => no double-dots", "if", "(", "false", "!==", "strpos", "(", "$", "value", ",", "'..'", ")", ")", "{", "if", "(", "true", "===", "$", "send_errors", ")", "{", "throw", "new", "\\", "Exception", "(", "sprintf", "(", "'The local part of the email address [%s] must not contain double-dots!'", ",", "$", "value", ")", ")", ";", "}", "return", "false", ";", "}", "// the local part must match the standards as wanted", "$", "last", "=", "0", ";", "foreach", "(", "self", "::", "$", "standards_list", "as", "$", "standard", ")", "{", "if", "(", "1", "===", "$", "last", ")", "{", "continue", ";", "}", "if", "(", "$", "standard", "==", "$", "this", "->", "must_pass", ")", "{", "$", "last", "=", "1", ";", "}", "$", "maskValidator", "=", "new", "StringMaskValidator", "(", "'^'", ".", "$", "this", "->", "getMask", "(", "$", "standard", ")", ".", "'$'", ",", "$", "standard", ")", ";", "try", "{", "if", "(", "false", "===", "$", "local_part_mask_valid", "=", "$", "maskValidator", "->", "validate", "(", "$", "value", ",", "$", "send_errors", ")", ")", "{", "return", "false", ";", "}", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "throw", "$", "e", ";", "}", "}", "return", "true", ";", "}" ]
Process local part validation @param string $value The local part of an email address to validate @param bool $send_errors Does the function must throw exceptions on validation failures ? @return bool TRUE if `$value` pass the Email validation @throws \Exception for each invalid part if `$send_errors` is true
[ "Process", "local", "part", "validation" ]
6c97b10bfe8324b33771f24cee8c722d7bc3bb15
https://github.com/atelierspierrot/validators/blob/6c97b10bfe8324b33771f24cee8c722d7bc3bb15/src/Validator/EmailValidator.php#L129-L190
10,637
atelierspierrot/validators
src/Validator/EmailValidator.php
EmailValidator.validateDomainPart
public function validateDomainPart($value, $send_errors = false) { // the domain name must be an IP address between brackets ... if ( substr($value, 0, 1)=='[' && substr($value, -1, 1)==']' ) { $ip_domain_part = substr($value, 1, strlen($value)-2); // is it an IPv6 if (substr($ip_domain_part, 0, strlen('IPv6:'))=='IPv6:') { $ip6_domain_part = substr($ip_domain_part, strlen('IPv6:')); $ip6HostnameValidator = new InternetProtocolValidator('v6'); try { if (false===$ip6domain_name_valid = $ip6HostnameValidator->validate($ip6_domain_part, $send_errors)) { return false; } } catch (\Exception $e) { throw $e; } } // otherwise IPv4 else { $ip4HostnameValidator = new InternetProtocolValidator; try { if (false===$ip4domain_name_valid = $ip4HostnameValidator->validate($ip_domain_part, $send_errors)) { return false; } } catch (\Exception $e) { throw $e; } } } // ... or a valid hostname else { $hostnameValidator = new HostnameValidator; try { if (false===$hostdomain_name_valid = $hostnameValidator->validate($value, $send_errors)) { return false; } } catch (\Exception $e) { throw $e; } } return true; }
php
public function validateDomainPart($value, $send_errors = false) { // the domain name must be an IP address between brackets ... if ( substr($value, 0, 1)=='[' && substr($value, -1, 1)==']' ) { $ip_domain_part = substr($value, 1, strlen($value)-2); // is it an IPv6 if (substr($ip_domain_part, 0, strlen('IPv6:'))=='IPv6:') { $ip6_domain_part = substr($ip_domain_part, strlen('IPv6:')); $ip6HostnameValidator = new InternetProtocolValidator('v6'); try { if (false===$ip6domain_name_valid = $ip6HostnameValidator->validate($ip6_domain_part, $send_errors)) { return false; } } catch (\Exception $e) { throw $e; } } // otherwise IPv4 else { $ip4HostnameValidator = new InternetProtocolValidator; try { if (false===$ip4domain_name_valid = $ip4HostnameValidator->validate($ip_domain_part, $send_errors)) { return false; } } catch (\Exception $e) { throw $e; } } } // ... or a valid hostname else { $hostnameValidator = new HostnameValidator; try { if (false===$hostdomain_name_valid = $hostnameValidator->validate($value, $send_errors)) { return false; } } catch (\Exception $e) { throw $e; } } return true; }
[ "public", "function", "validateDomainPart", "(", "$", "value", ",", "$", "send_errors", "=", "false", ")", "{", "// the domain name must be an IP address between brackets ...", "if", "(", "substr", "(", "$", "value", ",", "0", ",", "1", ")", "==", "'['", "&&", "substr", "(", "$", "value", ",", "-", "1", ",", "1", ")", "==", "']'", ")", "{", "$", "ip_domain_part", "=", "substr", "(", "$", "value", ",", "1", ",", "strlen", "(", "$", "value", ")", "-", "2", ")", ";", "// is it an IPv6", "if", "(", "substr", "(", "$", "ip_domain_part", ",", "0", ",", "strlen", "(", "'IPv6:'", ")", ")", "==", "'IPv6:'", ")", "{", "$", "ip6_domain_part", "=", "substr", "(", "$", "ip_domain_part", ",", "strlen", "(", "'IPv6:'", ")", ")", ";", "$", "ip6HostnameValidator", "=", "new", "InternetProtocolValidator", "(", "'v6'", ")", ";", "try", "{", "if", "(", "false", "===", "$", "ip6domain_name_valid", "=", "$", "ip6HostnameValidator", "->", "validate", "(", "$", "ip6_domain_part", ",", "$", "send_errors", ")", ")", "{", "return", "false", ";", "}", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "throw", "$", "e", ";", "}", "}", "// otherwise IPv4", "else", "{", "$", "ip4HostnameValidator", "=", "new", "InternetProtocolValidator", ";", "try", "{", "if", "(", "false", "===", "$", "ip4domain_name_valid", "=", "$", "ip4HostnameValidator", "->", "validate", "(", "$", "ip_domain_part", ",", "$", "send_errors", ")", ")", "{", "return", "false", ";", "}", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "throw", "$", "e", ";", "}", "}", "}", "// ... or a valid hostname", "else", "{", "$", "hostnameValidator", "=", "new", "HostnameValidator", ";", "try", "{", "if", "(", "false", "===", "$", "hostdomain_name_valid", "=", "$", "hostnameValidator", "->", "validate", "(", "$", "value", ",", "$", "send_errors", ")", ")", "{", "return", "false", ";", "}", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "throw", "$", "e", ";", "}", "}", "return", "true", ";", "}" ]
Process domain part validation @param string $value The domain part of an email address to validate @param bool $send_errors Does the function must throw exceptions on validation failures ? @return bool TRUE if $value pass the Email validation @throws \Exception for each invalid part if `$send_errors` is true
[ "Process", "domain", "part", "validation" ]
6c97b10bfe8324b33771f24cee8c722d7bc3bb15
https://github.com/atelierspierrot/validators/blob/6c97b10bfe8324b33771f24cee8c722d7bc3bb15/src/Validator/EmailValidator.php#L200-L245
10,638
chipaau/support
src/Support/Illuminate/Database/SeederTrait.php
SeederTrait.getForeignKeyCheck
protected function getForeignKeyCheck($enable = true) { $default = Config::get('database.default'); switch ($default) { case 'sqlite': $string = 'PRAGMA foreign_keys = ' . ($enable ? 'ON' : 'OFF'); break; default: $string = 'SET FOREIGN_KEY_CHECKS = ' . ($enable ? '1' : '0'); break; } return $string; }
php
protected function getForeignKeyCheck($enable = true) { $default = Config::get('database.default'); switch ($default) { case 'sqlite': $string = 'PRAGMA foreign_keys = ' . ($enable ? 'ON' : 'OFF'); break; default: $string = 'SET FOREIGN_KEY_CHECKS = ' . ($enable ? '1' : '0'); break; } return $string; }
[ "protected", "function", "getForeignKeyCheck", "(", "$", "enable", "=", "true", ")", "{", "$", "default", "=", "Config", "::", "get", "(", "'database.default'", ")", ";", "switch", "(", "$", "default", ")", "{", "case", "'sqlite'", ":", "$", "string", "=", "'PRAGMA foreign_keys = '", ".", "(", "$", "enable", "?", "'ON'", ":", "'OFF'", ")", ";", "break", ";", "default", ":", "$", "string", "=", "'SET FOREIGN_KEY_CHECKS = '", ".", "(", "$", "enable", "?", "'1'", ":", "'0'", ")", ";", "break", ";", "}", "return", "$", "string", ";", "}" ]
enable and disable foreign key constraints @param boolean $enable [description] @return string db statement
[ "enable", "and", "disable", "foreign", "key", "constraints" ]
2fe3673ed2330bd064d37b2f0bac3e02ca110bef
https://github.com/chipaau/support/blob/2fe3673ed2330bd064d37b2f0bac3e02ca110bef/src/Support/Illuminate/Database/SeederTrait.php#L19-L31
10,639
chipaau/support
src/Support/Illuminate/Database/SeederTrait.php
SeederTrait.cleanDatabase
protected function cleanDatabase(array $tables) { DB::statement($this->getForeignKeyCheck(false)); foreach ($tables as $table) { if (Schema::hasTable($table)) { DB::table($table)->truncate(); } } DB::statement($this->getForeignKeyCheck(true)); }
php
protected function cleanDatabase(array $tables) { DB::statement($this->getForeignKeyCheck(false)); foreach ($tables as $table) { if (Schema::hasTable($table)) { DB::table($table)->truncate(); } } DB::statement($this->getForeignKeyCheck(true)); }
[ "protected", "function", "cleanDatabase", "(", "array", "$", "tables", ")", "{", "DB", "::", "statement", "(", "$", "this", "->", "getForeignKeyCheck", "(", "false", ")", ")", ";", "foreach", "(", "$", "tables", "as", "$", "table", ")", "{", "if", "(", "Schema", "::", "hasTable", "(", "$", "table", ")", ")", "{", "DB", "::", "table", "(", "$", "table", ")", "->", "truncate", "(", ")", ";", "}", "}", "DB", "::", "statement", "(", "$", "this", "->", "getForeignKeyCheck", "(", "true", ")", ")", ";", "}" ]
cleaning process of tables @return [type] [description]
[ "cleaning", "process", "of", "tables" ]
2fe3673ed2330bd064d37b2f0bac3e02ca110bef
https://github.com/chipaau/support/blob/2fe3673ed2330bd064d37b2f0bac3e02ca110bef/src/Support/Illuminate/Database/SeederTrait.php#L37-L46
10,640
Dhii/expression-renderer-abstract
src/DelegateRenderTermCapableTrait.php
DelegateRenderTermCapableTrait._delegateRenderTerm
protected function _delegateRenderTerm(TermInterface $term, $context = null) { try { $childCtx = $context; $childCtx[ExprCtx::K_EXPRESSION] = $term; return $this->_getTermDelegateRenderer($term, $context) ->render($childCtx); } catch (OutOfRangeException $outOfRangeException) { $this->_throwRendererException( $this->__('Could not find a delegate renderer for the given term.'), null, $outOfRangeException ); } }
php
protected function _delegateRenderTerm(TermInterface $term, $context = null) { try { $childCtx = $context; $childCtx[ExprCtx::K_EXPRESSION] = $term; return $this->_getTermDelegateRenderer($term, $context) ->render($childCtx); } catch (OutOfRangeException $outOfRangeException) { $this->_throwRendererException( $this->__('Could not find a delegate renderer for the given term.'), null, $outOfRangeException ); } }
[ "protected", "function", "_delegateRenderTerm", "(", "TermInterface", "$", "term", ",", "$", "context", "=", "null", ")", "{", "try", "{", "$", "childCtx", "=", "$", "context", ";", "$", "childCtx", "[", "ExprCtx", "::", "K_EXPRESSION", "]", "=", "$", "term", ";", "return", "$", "this", "->", "_getTermDelegateRenderer", "(", "$", "term", ",", "$", "context", ")", "->", "render", "(", "$", "childCtx", ")", ";", "}", "catch", "(", "OutOfRangeException", "$", "outOfRangeException", ")", "{", "$", "this", "->", "_throwRendererException", "(", "$", "this", "->", "__", "(", "'Could not find a delegate renderer for the given term.'", ")", ",", "null", ",", "$", "outOfRangeException", ")", ";", "}", "}" ]
Delegates the rendering for the given term to another renderer. @since [*next-version*] @param TermInterface $term The term to render. @param array|ArrayAccess|stdClass|ContainerInterface|null $context The context. @throws RendererExceptionInterface If the renderer encountered an error. @throws TemplateRenderExceptionInterface If the renderer failed to render the term. @return string|Stringable The rendered term.
[ "Delegates", "the", "rendering", "for", "the", "given", "term", "to", "another", "renderer", "." ]
8c315e1d034b4198a89e0157f045e4a0d6cc8de8
https://github.com/Dhii/expression-renderer-abstract/blob/8c315e1d034b4198a89e0157f045e4a0d6cc8de8/src/DelegateRenderTermCapableTrait.php#L37-L52
10,641
c0dehulk/package-tools
src/Package/Finder.php
Finder.scanNamespaceForPackages
private function scanNamespaceForPackages(NamespaceInterface $root, PackageInterface $parent = null): Generator { foreach ($root->iterateNamespaces() as $namespace) { yield from $this->loadPackage($namespace, $parent); } }
php
private function scanNamespaceForPackages(NamespaceInterface $root, PackageInterface $parent = null): Generator { foreach ($root->iterateNamespaces() as $namespace) { yield from $this->loadPackage($namespace, $parent); } }
[ "private", "function", "scanNamespaceForPackages", "(", "NamespaceInterface", "$", "root", ",", "PackageInterface", "$", "parent", "=", "null", ")", ":", "Generator", "{", "foreach", "(", "$", "root", "->", "iterateNamespaces", "(", ")", "as", "$", "namespace", ")", "{", "yield", "from", "$", "this", "->", "loadPackage", "(", "$", "namespace", ",", "$", "parent", ")", ";", "}", "}" ]
Finds all packages in a namespace. @param NamespaceInterface $root The namespace to search. @param PackageInterface|null $parent The parent package currently being searched, or null if none. @return Generator|PackageInterface[]
[ "Finds", "all", "packages", "in", "a", "namespace", "." ]
786af97eb05179beb468c5575ecfea9f5a139e0b
https://github.com/c0dehulk/package-tools/blob/786af97eb05179beb468c5575ecfea9f5a139e0b/src/Package/Finder.php#L119-L124
10,642
c0dehulk/package-tools
src/Package/Finder.php
Finder.loadPackage
private function loadPackage(NamespaceInterface $namespace, PackageInterface $parent = null): Generator { $package = new Package($namespace, $parent); yield $package; // Packages can have a single tier of sub-packages. If we don't have a parent, search our namespace for any // children we might have. If we have a parent, they caused enough psychological damage that we don't want kids. if (!$parent) { yield from $this->findSubPackages($package); } }
php
private function loadPackage(NamespaceInterface $namespace, PackageInterface $parent = null): Generator { $package = new Package($namespace, $parent); yield $package; // Packages can have a single tier of sub-packages. If we don't have a parent, search our namespace for any // children we might have. If we have a parent, they caused enough psychological damage that we don't want kids. if (!$parent) { yield from $this->findSubPackages($package); } }
[ "private", "function", "loadPackage", "(", "NamespaceInterface", "$", "namespace", ",", "PackageInterface", "$", "parent", "=", "null", ")", ":", "Generator", "{", "$", "package", "=", "new", "Package", "(", "$", "namespace", ",", "$", "parent", ")", ";", "yield", "$", "package", ";", "// Packages can have a single tier of sub-packages. If we don't have a parent, search our namespace for any", "// children we might have. If we have a parent, they caused enough psychological damage that we don't want kids.", "if", "(", "!", "$", "parent", ")", "{", "yield", "from", "$", "this", "->", "findSubPackages", "(", "$", "package", ")", ";", "}", "}" ]
Loads a package from a namespace. @param NamespaceInterface $namespace The namespace to load the package with. @param PackageInterface|null $parent This package's parent, implying it is a sub-package. Null if none. @return Generator|PackageInterface[]
[ "Loads", "a", "package", "from", "a", "namespace", "." ]
786af97eb05179beb468c5575ecfea9f5a139e0b
https://github.com/c0dehulk/package-tools/blob/786af97eb05179beb468c5575ecfea9f5a139e0b/src/Package/Finder.php#L134-L144
10,643
c0dehulk/package-tools
src/Package/Finder.php
Finder.findSubPackages
private function findSubPackages(PackageInterface $package): Generator { $readMes = new \Symfony\Component\Finder\Finder(); $readMes->files() ->in($package->getPaths()) ->depth(1) ->name('readme.md'); // If no sub-folders have a readme, there aren't any sub-packages here. if (!$readMes->count()) { return; } yield from $this->scanNamespaceForPackages($package, $package); }
php
private function findSubPackages(PackageInterface $package): Generator { $readMes = new \Symfony\Component\Finder\Finder(); $readMes->files() ->in($package->getPaths()) ->depth(1) ->name('readme.md'); // If no sub-folders have a readme, there aren't any sub-packages here. if (!$readMes->count()) { return; } yield from $this->scanNamespaceForPackages($package, $package); }
[ "private", "function", "findSubPackages", "(", "PackageInterface", "$", "package", ")", ":", "Generator", "{", "$", "readMes", "=", "new", "\\", "Symfony", "\\", "Component", "\\", "Finder", "\\", "Finder", "(", ")", ";", "$", "readMes", "->", "files", "(", ")", "->", "in", "(", "$", "package", "->", "getPaths", "(", ")", ")", "->", "depth", "(", "1", ")", "->", "name", "(", "'readme.md'", ")", ";", "// If no sub-folders have a readme, there aren't any sub-packages here.", "if", "(", "!", "$", "readMes", "->", "count", "(", ")", ")", "{", "return", ";", "}", "yield", "from", "$", "this", "->", "scanNamespaceForPackages", "(", "$", "package", ",", "$", "package", ")", ";", "}" ]
Finds all sub-packages in a package. @param PackageInterface $package The package to search. @return Generator|PackageInterface[]
[ "Finds", "all", "sub", "-", "packages", "in", "a", "package", "." ]
786af97eb05179beb468c5575ecfea9f5a139e0b
https://github.com/c0dehulk/package-tools/blob/786af97eb05179beb468c5575ecfea9f5a139e0b/src/Package/Finder.php#L153-L166
10,644
unclecheese/silverstripe-green
code/GreenExtension.php
GreenExtension.DesignModule
public function DesignModule() { $module = $this->getModule(); if (!$module) { return; } $module->loadRequirements(); $viewer = SSViewer::fromString($module->getTemplateContents()); return $viewer->process($this->toViewableData()); }
php
public function DesignModule() { $module = $this->getModule(); if (!$module) { return; } $module->loadRequirements(); $viewer = SSViewer::fromString($module->getTemplateContents()); return $viewer->process($this->toViewableData()); }
[ "public", "function", "DesignModule", "(", ")", "{", "$", "module", "=", "$", "this", "->", "getModule", "(", ")", ";", "if", "(", "!", "$", "module", ")", "{", "return", ";", "}", "$", "module", "->", "loadRequirements", "(", ")", ";", "$", "viewer", "=", "SSViewer", "::", "fromString", "(", "$", "module", "->", "getTemplateContents", "(", ")", ")", ";", "return", "$", "viewer", "->", "process", "(", "$", "this", "->", "toViewableData", "(", ")", ")", ";", "}" ]
Renders the design module @return HTMLText
[ "Renders", "the", "design", "module" ]
4395dcef5f4efd5a2c67e0bba3ab5cc583e3fdd4
https://github.com/unclecheese/silverstripe-green/blob/4395dcef5f4efd5a2c67e0bba3ab5cc583e3fdd4/code/GreenExtension.php#L111-L124
10,645
unclecheese/silverstripe-green
code/GreenExtension.php
GreenExtension.getModule
public function getModule() { if ($this->owner->DesignModule) { return Green::inst()->getDesignModule($this->owner->DesignModule); } return null; }
php
public function getModule() { if ($this->owner->DesignModule) { return Green::inst()->getDesignModule($this->owner->DesignModule); } return null; }
[ "public", "function", "getModule", "(", ")", "{", "if", "(", "$", "this", "->", "owner", "->", "DesignModule", ")", "{", "return", "Green", "::", "inst", "(", ")", "->", "getDesignModule", "(", "$", "this", "->", "owner", "->", "DesignModule", ")", ";", "}", "return", "null", ";", "}" ]
Gets the design module that the DataObject is mapped to @return DesignModule|null
[ "Gets", "the", "design", "module", "that", "the", "DataObject", "is", "mapped", "to" ]
4395dcef5f4efd5a2c67e0bba3ab5cc583e3fdd4
https://github.com/unclecheese/silverstripe-green/blob/4395dcef5f4efd5a2c67e0bba3ab5cc583e3fdd4/code/GreenExtension.php#L148-L155
10,646
webforge-labs/webforge-utils
src/php/Webforge/Common/System/Dir.php
Dir.createTemporary
public static function createTemporary() { $file = File::createTemporary(); $tempname = $file->getName(); $file->delete(); $dir = $file->getDirectory()->sub($tempname.'/'); $dir->make(); return $dir; }
php
public static function createTemporary() { $file = File::createTemporary(); $tempname = $file->getName(); $file->delete(); $dir = $file->getDirectory()->sub($tempname.'/'); $dir->make(); return $dir; }
[ "public", "static", "function", "createTemporary", "(", ")", "{", "$", "file", "=", "File", "::", "createTemporary", "(", ")", ";", "$", "tempname", "=", "$", "file", "->", "getName", "(", ")", ";", "$", "file", "->", "delete", "(", ")", ";", "$", "dir", "=", "$", "file", "->", "getDirectory", "(", ")", "->", "sub", "(", "$", "tempname", ".", "'/'", ")", ";", "$", "dir", "->", "make", "(", ")", ";", "return", "$", "dir", ";", "}" ]
Creates a temporary Directory
[ "Creates", "a", "temporary", "Directory" ]
a476eeec046c22ad91794b0ab9fe15a1d3f92bfc
https://github.com/webforge-labs/webforge-utils/blob/a476eeec046c22ad91794b0ab9fe15a1d3f92bfc/src/php/Webforge/Common/System/Dir.php#L147-L155
10,647
webforge-labs/webforge-utils
src/php/Webforge/Common/System/Dir.php
Dir.wrapWith
public function wrapWith($wrapperName, $driveStyle = NULL) { $this->wrapper = $wrapperName; $this->prefix = $this->wrapper.'://'.$this->getOSPrefix(self::UNIX, $driveStyle ?: self::WINDOWS_DRIVE_WINDOWS_STYLE); return $this; }
php
public function wrapWith($wrapperName, $driveStyle = NULL) { $this->wrapper = $wrapperName; $this->prefix = $this->wrapper.'://'.$this->getOSPrefix(self::UNIX, $driveStyle ?: self::WINDOWS_DRIVE_WINDOWS_STYLE); return $this; }
[ "public", "function", "wrapWith", "(", "$", "wrapperName", ",", "$", "driveStyle", "=", "NULL", ")", "{", "$", "this", "->", "wrapper", "=", "$", "wrapperName", ";", "$", "this", "->", "prefix", "=", "$", "this", "->", "wrapper", ".", "'://'", ".", "$", "this", "->", "getOSPrefix", "(", "self", "::", "UNIX", ",", "$", "driveStyle", "?", ":", "self", "::", "WINDOWS_DRIVE_WINDOWS_STYLE", ")", ";", "return", "$", "this", ";", "}" ]
Wraps the dir with the wrapper and converts windows paths @param string only the name of the wrapper like file or vfs or phar
[ "Wraps", "the", "dir", "with", "the", "wrapper", "and", "converts", "windows", "paths" ]
a476eeec046c22ad91794b0ab9fe15a1d3f92bfc
https://github.com/webforge-labs/webforge-utils/blob/a476eeec046c22ad91794b0ab9fe15a1d3f92bfc/src/php/Webforge/Common/System/Dir.php#L324-L330
10,648
webforge-labs/webforge-utils
src/php/Webforge/Common/System/Dir.php
Dir.resolvePath
public function resolvePath() { if (count($this->path) == 0) { return $this; } if ($this->isRelative()) { /* wir ermitteln das aktuelle working directory und fügen dieses vor unserem bisherigen Pfad hinzu * den . am anfang brauchen wir nicht wegmachen, das wird nachher normalisiert */ $cwd = self::factory(getcwd().DIRECTORY_SEPARATOR); $this->prefix = $cwd->getPrefix($this); $this->path = array_merge( $cwd->getPathArray(), $this->path ); } /* pfad normalisieren */ $newPath = array(); foreach ($this->path as $dir) { if ($dir !== '.') { // dir2/dir1/./dir4/dir3 den . ignorieren if ($dir == '..') { // ../ auflösen dadurch, dass wir ein verzeichnis zurückgehen array_pop($newPath); } else { $newPath[] = $dir; } } } $this->path = $newPath; return $this; }
php
public function resolvePath() { if (count($this->path) == 0) { return $this; } if ($this->isRelative()) { /* wir ermitteln das aktuelle working directory und fügen dieses vor unserem bisherigen Pfad hinzu * den . am anfang brauchen wir nicht wegmachen, das wird nachher normalisiert */ $cwd = self::factory(getcwd().DIRECTORY_SEPARATOR); $this->prefix = $cwd->getPrefix($this); $this->path = array_merge( $cwd->getPathArray(), $this->path ); } /* pfad normalisieren */ $newPath = array(); foreach ($this->path as $dir) { if ($dir !== '.') { // dir2/dir1/./dir4/dir3 den . ignorieren if ($dir == '..') { // ../ auflösen dadurch, dass wir ein verzeichnis zurückgehen array_pop($newPath); } else { $newPath[] = $dir; } } } $this->path = $newPath; return $this; }
[ "public", "function", "resolvePath", "(", ")", "{", "if", "(", "count", "(", "$", "this", "->", "path", ")", "==", "0", ")", "{", "return", "$", "this", ";", "}", "if", "(", "$", "this", "->", "isRelative", "(", ")", ")", "{", "/* wir ermitteln das aktuelle working directory und fügen dieses vor unserem bisherigen Pfad hinzu\n * den . am anfang brauchen wir nicht wegmachen, das wird nachher normalisiert\n */", "$", "cwd", "=", "self", "::", "factory", "(", "getcwd", "(", ")", ".", "DIRECTORY_SEPARATOR", ")", ";", "$", "this", "->", "prefix", "=", "$", "cwd", "->", "getPrefix", "(", "$", "this", ")", ";", "$", "this", "->", "path", "=", "array_merge", "(", "$", "cwd", "->", "getPathArray", "(", ")", ",", "$", "this", "->", "path", ")", ";", "}", "/* pfad normalisieren */", "$", "newPath", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "path", "as", "$", "dir", ")", "{", "if", "(", "$", "dir", "!==", "'.'", ")", "{", "// dir2/dir1/./dir4/dir3 den . ignorieren", "if", "(", "$", "dir", "==", "'..'", ")", "{", "// ../ auflösen dadurch, dass wir ein verzeichnis zurückgehen", "array_pop", "(", "$", "newPath", ")", ";", "}", "else", "{", "$", "newPath", "[", "]", "=", "$", "dir", ";", "}", "}", "}", "$", "this", "->", "path", "=", "$", "newPath", ";", "return", "$", "this", ";", "}" ]
Resolves relative parts of the path an normalizes if path is relative its resolved to the current working directory the type of the path of getcwd will be used. So this might change the prefix-type of directory! if dir is not relative this works like realpath with directories that do not exist @uses PHP::getcwd() @chainable
[ "Resolves", "relative", "parts", "of", "the", "path", "an", "normalizes" ]
a476eeec046c22ad91794b0ab9fe15a1d3f92bfc
https://github.com/webforge-labs/webforge-utils/blob/a476eeec046c22ad91794b0ab9fe15a1d3f92bfc/src/php/Webforge/Common/System/Dir.php#L349-L382
10,649
webforge-labs/webforge-utils
src/php/Webforge/Common/System/Dir.php
Dir.move
public function move(Dir $destination) { $ret = @rename((string) $this,(string) $destination); $errInfo = 'Kann Verzeichnis '.$this.' nicht nach '.$destination.' verschieben / umbenennen.'; if (!$ret) { if ($destination->exists()) throw new Exception($errInfo.' Das Zielverzeichnis existiert.'); if (!$this->exists()) throw new Exception($errInfo.' Das Quellverzeichnis existiert nicht.'); else throw new Exception($errInfo); } /* wir übernehmen die Pfade von $destination */ $this->path = $destination->getPathArray(); return $this; }
php
public function move(Dir $destination) { $ret = @rename((string) $this,(string) $destination); $errInfo = 'Kann Verzeichnis '.$this.' nicht nach '.$destination.' verschieben / umbenennen.'; if (!$ret) { if ($destination->exists()) throw new Exception($errInfo.' Das Zielverzeichnis existiert.'); if (!$this->exists()) throw new Exception($errInfo.' Das Quellverzeichnis existiert nicht.'); else throw new Exception($errInfo); } /* wir übernehmen die Pfade von $destination */ $this->path = $destination->getPathArray(); return $this; }
[ "public", "function", "move", "(", "Dir", "$", "destination", ")", "{", "$", "ret", "=", "@", "rename", "(", "(", "string", ")", "$", "this", ",", "(", "string", ")", "$", "destination", ")", ";", "$", "errInfo", "=", "'Kann Verzeichnis '", ".", "$", "this", ".", "' nicht nach '", ".", "$", "destination", ".", "' verschieben / umbenennen.'", ";", "if", "(", "!", "$", "ret", ")", "{", "if", "(", "$", "destination", "->", "exists", "(", ")", ")", "throw", "new", "Exception", "(", "$", "errInfo", ".", "' Das Zielverzeichnis existiert.'", ")", ";", "if", "(", "!", "$", "this", "->", "exists", "(", ")", ")", "throw", "new", "Exception", "(", "$", "errInfo", ".", "' Das Quellverzeichnis existiert nicht.'", ")", ";", "else", "throw", "new", "Exception", "(", "$", "errInfo", ")", ";", "}", "/* wir übernehmen die Pfade von $destination */", "$", "this", "->", "path", "=", "$", "destination", "->", "getPathArray", "(", ")", ";", "return", "$", "this", ";", "}" ]
Moves the directory and changes its internal state @param Dir $destination @chainable
[ "Moves", "the", "directory", "and", "changes", "its", "internal", "state" ]
a476eeec046c22ad91794b0ab9fe15a1d3f92bfc
https://github.com/webforge-labs/webforge-utils/blob/a476eeec046c22ad91794b0ab9fe15a1d3f92bfc/src/php/Webforge/Common/System/Dir.php#L838-L857
10,650
webforge-labs/webforge-utils
src/php/Webforge/Common/System/Dir.php
Dir.make
public function make($options=NULL) { if (is_int($options)) { $parent = ($options & self::PARENT) == self::PARENT; $assert = ($options & self::ASSERT_EXISTS) == self::ASSERT_EXISTS; } else { // legacy option $parent = (mb_strpos($options,'-p') !== FALSE); $assert = FALSE; } if (!$this->exists()) { $ret = @mkdir((string) $this, $this->getDefaultMod(), $parent); if ($ret == FALSE) { throw new Exception('Fehler beim erstellen des Verzeichnisses: '.$this); } } else { if (!$assert) { throw new Exception('Verzeichnis '.$this.' kann nicht erstellt werden, da es schon existiert'); } } return $this; }
php
public function make($options=NULL) { if (is_int($options)) { $parent = ($options & self::PARENT) == self::PARENT; $assert = ($options & self::ASSERT_EXISTS) == self::ASSERT_EXISTS; } else { // legacy option $parent = (mb_strpos($options,'-p') !== FALSE); $assert = FALSE; } if (!$this->exists()) { $ret = @mkdir((string) $this, $this->getDefaultMod(), $parent); if ($ret == FALSE) { throw new Exception('Fehler beim erstellen des Verzeichnisses: '.$this); } } else { if (!$assert) { throw new Exception('Verzeichnis '.$this.' kann nicht erstellt werden, da es schon existiert'); } } return $this; }
[ "public", "function", "make", "(", "$", "options", "=", "NULL", ")", "{", "if", "(", "is_int", "(", "$", "options", ")", ")", "{", "$", "parent", "=", "(", "$", "options", "&", "self", "::", "PARENT", ")", "==", "self", "::", "PARENT", ";", "$", "assert", "=", "(", "$", "options", "&", "self", "::", "ASSERT_EXISTS", ")", "==", "self", "::", "ASSERT_EXISTS", ";", "}", "else", "{", "// legacy option", "$", "parent", "=", "(", "mb_strpos", "(", "$", "options", ",", "'-p'", ")", "!==", "FALSE", ")", ";", "$", "assert", "=", "FALSE", ";", "}", "if", "(", "!", "$", "this", "->", "exists", "(", ")", ")", "{", "$", "ret", "=", "@", "mkdir", "(", "(", "string", ")", "$", "this", ",", "$", "this", "->", "getDefaultMod", "(", ")", ",", "$", "parent", ")", ";", "if", "(", "$", "ret", "==", "FALSE", ")", "{", "throw", "new", "Exception", "(", "'Fehler beim erstellen des Verzeichnisses: '", ".", "$", "this", ")", ";", "}", "}", "else", "{", "if", "(", "!", "$", "assert", ")", "{", "throw", "new", "Exception", "(", "'Verzeichnis '", ".", "$", "this", ".", "' kann nicht erstellt werden, da es schon existiert'", ")", ";", "}", "}", "return", "$", "this", ";", "}" ]
Creates the Directory @param bitmap $options self::PARENT to create the full path of the directory @chainable
[ "Creates", "the", "Directory" ]
a476eeec046c22ad91794b0ab9fe15a1d3f92bfc
https://github.com/webforge-labs/webforge-utils/blob/a476eeec046c22ad91794b0ab9fe15a1d3f92bfc/src/php/Webforge/Common/System/Dir.php#L875-L897
10,651
webforge-labs/webforge-utils
src/php/Webforge/Common/System/Dir.php
Dir.getPath
public function getPath($flags = 0x000000) { $ds = $this->getDS(); $trail = $flags & self::WITHOUT_TRAILINGSLASH ? '' : $ds; return $this->prefix.(empty($this->path) ? '' : implode($ds, $this->path).$trail); }
php
public function getPath($flags = 0x000000) { $ds = $this->getDS(); $trail = $flags & self::WITHOUT_TRAILINGSLASH ? '' : $ds; return $this->prefix.(empty($this->path) ? '' : implode($ds, $this->path).$trail); }
[ "public", "function", "getPath", "(", "$", "flags", "=", "0x000000", ")", "{", "$", "ds", "=", "$", "this", "->", "getDS", "(", ")", ";", "$", "trail", "=", "$", "flags", "&", "self", "::", "WITHOUT_TRAILINGSLASH", "?", "''", ":", "$", "ds", ";", "return", "$", "this", "->", "prefix", ".", "(", "empty", "(", "$", "this", "->", "path", ")", "?", "''", ":", "implode", "(", "$", "ds", ",", "$", "this", "->", "path", ")", ".", "$", "trail", ")", ";", "}" ]
Returns the Path as string the path is returned for the current Operating System @return string
[ "Returns", "the", "Path", "as", "string" ]
a476eeec046c22ad91794b0ab9fe15a1d3f92bfc
https://github.com/webforge-labs/webforge-utils/blob/a476eeec046c22ad91794b0ab9fe15a1d3f92bfc/src/php/Webforge/Common/System/Dir.php#L1027-L1033
10,652
webforge-labs/webforge-utils
src/php/Webforge/Common/System/Dir.php
Dir.getOSPath
public function getOSPath($os, $flags = 0x000000) { $osDS = $this->getOSDS($os, $flags); return $this->getOSPrefix($os,$flags).(empty($this->path) ? '' : implode($osDS, $this->path).$osDS); }
php
public function getOSPath($os, $flags = 0x000000) { $osDS = $this->getOSDS($os, $flags); return $this->getOSPrefix($os,$flags).(empty($this->path) ? '' : implode($osDS, $this->path).$osDS); }
[ "public", "function", "getOSPath", "(", "$", "os", ",", "$", "flags", "=", "0x000000", ")", "{", "$", "osDS", "=", "$", "this", "->", "getOSDS", "(", "$", "os", ",", "$", "flags", ")", ";", "return", "$", "this", "->", "getOSPrefix", "(", "$", "os", ",", "$", "flags", ")", ".", "(", "empty", "(", "$", "this", "->", "path", ")", "?", "''", ":", "implode", "(", "$", "osDS", ",", "$", "this", "->", "path", ")", ".", "$", "osDS", ")", ";", "}" ]
Returns the path of the directory converted to specific OS some edge cases will throw an LogicException because they cannot be converted: D:\\windows is on unix: /D:/windows/ (like mozilla does it with file://) /var/local/www/ is on windows?? @return string @param const $os self::WINDOWS|self::UNIX
[ "Returns", "the", "path", "of", "the", "directory", "converted", "to", "specific", "OS" ]
a476eeec046c22ad91794b0ab9fe15a1d3f92bfc
https://github.com/webforge-labs/webforge-utils/blob/a476eeec046c22ad91794b0ab9fe15a1d3f92bfc/src/php/Webforge/Common/System/Dir.php#L1053-L1057
10,653
webforge-labs/webforge-utils
src/php/Webforge/Common/System/Dir.php
Dir.getOSPrefix
protected function getOSPrefix($os, $flags = 0x000000) { $letter = NULL; if ($this->isWindowsDrivePrefix($letter)) { $osPrefix = ''; if (($flags & self::WINDOWS_WITH_CYGWIN) && $os === self::WINDOWS) { $osPrefix .= '/cygdrive/'.mb_strtolower($letter).'/'; } else { if (!($flags & self::WINDOWS_DRIVE_WINDOWS_STYLE) && $os === self::UNIX) { $osPrefix .= '/'; } $osPrefix .= $letter.':'.$this->getOSDS($os); } } else { $osPrefix = $this->prefix; } return $osPrefix; }
php
protected function getOSPrefix($os, $flags = 0x000000) { $letter = NULL; if ($this->isWindowsDrivePrefix($letter)) { $osPrefix = ''; if (($flags & self::WINDOWS_WITH_CYGWIN) && $os === self::WINDOWS) { $osPrefix .= '/cygdrive/'.mb_strtolower($letter).'/'; } else { if (!($flags & self::WINDOWS_DRIVE_WINDOWS_STYLE) && $os === self::UNIX) { $osPrefix .= '/'; } $osPrefix .= $letter.':'.$this->getOSDS($os); } } else { $osPrefix = $this->prefix; } return $osPrefix; }
[ "protected", "function", "getOSPrefix", "(", "$", "os", ",", "$", "flags", "=", "0x000000", ")", "{", "$", "letter", "=", "NULL", ";", "if", "(", "$", "this", "->", "isWindowsDrivePrefix", "(", "$", "letter", ")", ")", "{", "$", "osPrefix", "=", "''", ";", "if", "(", "(", "$", "flags", "&", "self", "::", "WINDOWS_WITH_CYGWIN", ")", "&&", "$", "os", "===", "self", "::", "WINDOWS", ")", "{", "$", "osPrefix", ".=", "'/cygdrive/'", ".", "mb_strtolower", "(", "$", "letter", ")", ".", "'/'", ";", "}", "else", "{", "if", "(", "!", "(", "$", "flags", "&", "self", "::", "WINDOWS_DRIVE_WINDOWS_STYLE", ")", "&&", "$", "os", "===", "self", "::", "UNIX", ")", "{", "$", "osPrefix", ".=", "'/'", ";", "}", "$", "osPrefix", ".=", "$", "letter", ".", "':'", ".", "$", "this", "->", "getOSDS", "(", "$", "os", ")", ";", "}", "}", "else", "{", "$", "osPrefix", "=", "$", "this", "->", "prefix", ";", "}", "return", "$", "osPrefix", ";", "}" ]
Returns a prefix which is converted to the specific os if prefix is absolute this ends with a slash or backslash @return string
[ "Returns", "a", "prefix", "which", "is", "converted", "to", "the", "specific", "os" ]
a476eeec046c22ad91794b0ab9fe15a1d3f92bfc
https://github.com/webforge-labs/webforge-utils/blob/a476eeec046c22ad91794b0ab9fe15a1d3f92bfc/src/php/Webforge/Common/System/Dir.php#L1065-L1087
10,654
webforge-labs/webforge-utils
src/php/Webforge/Common/System/Dir.php
Dir.getOSDS
public function getOSDS($os, $flags = 0x000000) { return ($this->isWrapped() || $this->isCygwin() || ($flags & self::WINDOWS_WITH_CYGWIN) || $os === self::UNIX) ? '/' : '\\'; }
php
public function getOSDS($os, $flags = 0x000000) { return ($this->isWrapped() || $this->isCygwin() || ($flags & self::WINDOWS_WITH_CYGWIN) || $os === self::UNIX) ? '/' : '\\'; }
[ "public", "function", "getOSDS", "(", "$", "os", ",", "$", "flags", "=", "0x000000", ")", "{", "return", "(", "$", "this", "->", "isWrapped", "(", ")", "||", "$", "this", "->", "isCygwin", "(", ")", "||", "(", "$", "flags", "&", "self", "::", "WINDOWS_WITH_CYGWIN", ")", "||", "$", "os", "===", "self", "::", "UNIX", ")", "?", "'/'", ":", "'\\\\'", ";", "}" ]
Returns the DirectorySeperator for a specific operating system @return \ or /
[ "Returns", "the", "DirectorySeperator", "for", "a", "specific", "operating", "system" ]
a476eeec046c22ad91794b0ab9fe15a1d3f92bfc
https://github.com/webforge-labs/webforge-utils/blob/a476eeec046c22ad91794b0ab9fe15a1d3f92bfc/src/php/Webforge/Common/System/Dir.php#L1103-L1105
10,655
webforge-labs/webforge-utils
src/php/Webforge/Common/System/Dir.php
Dir.extract
public static function extract($string) { if (mb_strlen($string) == 0) { throw new Exception('String ist leer, kann kein Verzeichnis extrahieren'); } $path = dirname($string).DIRECTORY_SEPARATOR; try { $dir = new Dir($path); } catch (Exception $e) { throw new Exception('kann kein Verzeichnis aus dem extrahierten Verzeichnis "'.$path.'" erstellen: '.$e->getMessage()); } return $dir; }
php
public static function extract($string) { if (mb_strlen($string) == 0) { throw new Exception('String ist leer, kann kein Verzeichnis extrahieren'); } $path = dirname($string).DIRECTORY_SEPARATOR; try { $dir = new Dir($path); } catch (Exception $e) { throw new Exception('kann kein Verzeichnis aus dem extrahierten Verzeichnis "'.$path.'" erstellen: '.$e->getMessage()); } return $dir; }
[ "public", "static", "function", "extract", "(", "$", "string", ")", "{", "if", "(", "mb_strlen", "(", "$", "string", ")", "==", "0", ")", "{", "throw", "new", "Exception", "(", "'String ist leer, kann kein Verzeichnis extrahieren'", ")", ";", "}", "$", "path", "=", "dirname", "(", "$", "string", ")", ".", "DIRECTORY_SEPARATOR", ";", "try", "{", "$", "dir", "=", "new", "Dir", "(", "$", "path", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "throw", "new", "Exception", "(", "'kann kein Verzeichnis aus dem extrahierten Verzeichnis \"'", ".", "$", "path", ".", "'\" erstellen: '", ".", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "return", "$", "dir", ";", "}" ]
Extrahiert das Verzeichnis aus einer Angabe zu einer Datei @param string $string der zu untersuchende string @return Dir
[ "Extrahiert", "das", "Verzeichnis", "aus", "einer", "Angabe", "zu", "einer", "Datei" ]
a476eeec046c22ad91794b0ab9fe15a1d3f92bfc
https://github.com/webforge-labs/webforge-utils/blob/a476eeec046c22ad91794b0ab9fe15a1d3f92bfc/src/php/Webforge/Common/System/Dir.php#L1214-L1227
10,656
fastdlabs/annotation
src/Parser/ClassParser.php
ClassParser.extendsParents
protected function extendsParents(ReflectionClass $reflectionClass) { $annotation = $this->parse($reflectionClass->getDocComment()); $annotation['class'] = $reflectionClass->getName(); array_unshift($this->parentAnnotations, $annotation); if (false !== $reflectionClass->getParentClass()) { $this->extendsParents($reflectionClass->getParentClass()); } }
php
protected function extendsParents(ReflectionClass $reflectionClass) { $annotation = $this->parse($reflectionClass->getDocComment()); $annotation['class'] = $reflectionClass->getName(); array_unshift($this->parentAnnotations, $annotation); if (false !== $reflectionClass->getParentClass()) { $this->extendsParents($reflectionClass->getParentClass()); } }
[ "protected", "function", "extendsParents", "(", "ReflectionClass", "$", "reflectionClass", ")", "{", "$", "annotation", "=", "$", "this", "->", "parse", "(", "$", "reflectionClass", "->", "getDocComment", "(", ")", ")", ";", "$", "annotation", "[", "'class'", "]", "=", "$", "reflectionClass", "->", "getName", "(", ")", ";", "array_unshift", "(", "$", "this", "->", "parentAnnotations", ",", "$", "annotation", ")", ";", "if", "(", "false", "!==", "$", "reflectionClass", "->", "getParentClass", "(", ")", ")", "{", "$", "this", "->", "extendsParents", "(", "$", "reflectionClass", "->", "getParentClass", "(", ")", ")", ";", "}", "}" ]
Recursive reflection. @param ReflectionClass $reflectionClass @return void
[ "Recursive", "reflection", "." ]
72f359bd741e935b4afd0a3b94d80bc30500a052
https://github.com/fastdlabs/annotation/blob/72f359bd741e935b4afd0a3b94d80bc30500a052/src/Parser/ClassParser.php#L87-L98
10,657
fazland/elastica-odm
src/Search/Search.php
Search.count
public function count(): int { $collection = $this->documentManager->getCollection($this->documentClass); return $collection->count($this->query); }
php
public function count(): int { $collection = $this->documentManager->getCollection($this->documentClass); return $collection->count($this->query); }
[ "public", "function", "count", "(", ")", ":", "int", "{", "$", "collection", "=", "$", "this", "->", "documentManager", "->", "getCollection", "(", "$", "this", "->", "documentClass", ")", ";", "return", "$", "collection", "->", "count", "(", "$", "this", "->", "query", ")", ";", "}" ]
Get the total hits of the current query. @return int
[ "Get", "the", "total", "hits", "of", "the", "current", "query", "." ]
9d7276ea9ea9103c670f13f889bf59568ff35274
https://github.com/fazland/elastica-odm/blob/9d7276ea9ea9103c670f13f889bf59568ff35274/src/Search/Search.php#L121-L126
10,658
fazland/elastica-odm
src/Search/Search.php
Search.getIterator
public function getIterator(): \Iterator { $hydrator = $this->documentManager->newHydrator($this->hydrationMode); $query = clone $this->query; if (! $query->hasParam('_source')) { /** @var DocumentMetadata $class */ $class = $this->documentManager->getClassMetadata($this->documentClass); $query->setSource($class->eagerFieldNames); } if (null !== $this->sort) { $query->setSort($this->sort); } if (null !== $this->limit) { $query->setSize($this->limit); } if (null !== $this->offset) { $query->setFrom($this->offset); } $generator = null !== $this->cacheProfile ? $this->_doExecuteCached($query) : $this->_doExecute($query); foreach ($generator as $resultSet) { yield from $hydrator->hydrateAll($resultSet, $this->documentClass); } }
php
public function getIterator(): \Iterator { $hydrator = $this->documentManager->newHydrator($this->hydrationMode); $query = clone $this->query; if (! $query->hasParam('_source')) { /** @var DocumentMetadata $class */ $class = $this->documentManager->getClassMetadata($this->documentClass); $query->setSource($class->eagerFieldNames); } if (null !== $this->sort) { $query->setSort($this->sort); } if (null !== $this->limit) { $query->setSize($this->limit); } if (null !== $this->offset) { $query->setFrom($this->offset); } $generator = null !== $this->cacheProfile ? $this->_doExecuteCached($query) : $this->_doExecute($query); foreach ($generator as $resultSet) { yield from $hydrator->hydrateAll($resultSet, $this->documentClass); } }
[ "public", "function", "getIterator", "(", ")", ":", "\\", "Iterator", "{", "$", "hydrator", "=", "$", "this", "->", "documentManager", "->", "newHydrator", "(", "$", "this", "->", "hydrationMode", ")", ";", "$", "query", "=", "clone", "$", "this", "->", "query", ";", "if", "(", "!", "$", "query", "->", "hasParam", "(", "'_source'", ")", ")", "{", "/** @var DocumentMetadata $class */", "$", "class", "=", "$", "this", "->", "documentManager", "->", "getClassMetadata", "(", "$", "this", "->", "documentClass", ")", ";", "$", "query", "->", "setSource", "(", "$", "class", "->", "eagerFieldNames", ")", ";", "}", "if", "(", "null", "!==", "$", "this", "->", "sort", ")", "{", "$", "query", "->", "setSort", "(", "$", "this", "->", "sort", ")", ";", "}", "if", "(", "null", "!==", "$", "this", "->", "limit", ")", "{", "$", "query", "->", "setSize", "(", "$", "this", "->", "limit", ")", ";", "}", "if", "(", "null", "!==", "$", "this", "->", "offset", ")", "{", "$", "query", "->", "setFrom", "(", "$", "this", "->", "offset", ")", ";", "}", "$", "generator", "=", "null", "!==", "$", "this", "->", "cacheProfile", "?", "$", "this", "->", "_doExecuteCached", "(", "$", "query", ")", ":", "$", "this", "->", "_doExecute", "(", "$", "query", ")", ";", "foreach", "(", "$", "generator", "as", "$", "resultSet", ")", "{", "yield", "from", "$", "hydrator", "->", "hydrateAll", "(", "$", "resultSet", ",", "$", "this", "->", "documentClass", ")", ";", "}", "}" ]
Iterate over the query results. @return \Iterator
[ "Iterate", "over", "the", "query", "results", "." ]
9d7276ea9ea9103c670f13f889bf59568ff35274
https://github.com/fazland/elastica-odm/blob/9d7276ea9ea9103c670f13f889bf59568ff35274/src/Search/Search.php#L133-L160
10,659
fazland/elastica-odm
src/Search/Search.php
Search.setSort
public function setSort($fieldName, $order = 'asc'): self { if (null !== $fieldName) { $sort = []; $fields = is_array($fieldName) ? $fieldName : [$fieldName => $order]; foreach ($fields as $fieldName => $order) { $sort[] = [$fieldName => $order]; } } else { $sort = null; } $this->sort = $sort; return $this; }
php
public function setSort($fieldName, $order = 'asc'): self { if (null !== $fieldName) { $sort = []; $fields = is_array($fieldName) ? $fieldName : [$fieldName => $order]; foreach ($fields as $fieldName => $order) { $sort[] = [$fieldName => $order]; } } else { $sort = null; } $this->sort = $sort; return $this; }
[ "public", "function", "setSort", "(", "$", "fieldName", ",", "$", "order", "=", "'asc'", ")", ":", "self", "{", "if", "(", "null", "!==", "$", "fieldName", ")", "{", "$", "sort", "=", "[", "]", ";", "$", "fields", "=", "is_array", "(", "$", "fieldName", ")", "?", "$", "fieldName", ":", "[", "$", "fieldName", "=>", "$", "order", "]", ";", "foreach", "(", "$", "fields", "as", "$", "fieldName", "=>", "$", "order", ")", "{", "$", "sort", "[", "]", "=", "[", "$", "fieldName", "=>", "$", "order", "]", ";", "}", "}", "else", "{", "$", "sort", "=", "null", ";", "}", "$", "this", "->", "sort", "=", "$", "sort", ";", "return", "$", "this", ";", "}" ]
Sets the sort fields and directions. @param array|string $fieldName @param string $order @return Search
[ "Sets", "the", "sort", "fields", "and", "directions", "." ]
9d7276ea9ea9103c670f13f889bf59568ff35274
https://github.com/fazland/elastica-odm/blob/9d7276ea9ea9103c670f13f889bf59568ff35274/src/Search/Search.php#L194-L210
10,660
fazland/elastica-odm
src/Search/Search.php
Search.useResultCache
public function useResultCache(string $cacheKey = null, int $ttl = 0): self { if (null === $cacheKey) { $this->cacheProfile = null; } else { $this->cacheProfile = new SearchCacheProfile($cacheKey, $ttl); } return $this; }
php
public function useResultCache(string $cacheKey = null, int $ttl = 0): self { if (null === $cacheKey) { $this->cacheProfile = null; } else { $this->cacheProfile = new SearchCacheProfile($cacheKey, $ttl); } return $this; }
[ "public", "function", "useResultCache", "(", "string", "$", "cacheKey", "=", "null", ",", "int", "$", "ttl", "=", "0", ")", ":", "self", "{", "if", "(", "null", "===", "$", "cacheKey", ")", "{", "$", "this", "->", "cacheProfile", "=", "null", ";", "}", "else", "{", "$", "this", "->", "cacheProfile", "=", "new", "SearchCacheProfile", "(", "$", "cacheKey", ",", "$", "ttl", ")", ";", "}", "return", "$", "this", ";", "}" ]
Instructs the executor to use a result cache. @param string $cacheKey @param int $ttl @return $this|self
[ "Instructs", "the", "executor", "to", "use", "a", "result", "cache", "." ]
9d7276ea9ea9103c670f13f889bf59568ff35274
https://github.com/fazland/elastica-odm/blob/9d7276ea9ea9103c670f13f889bf59568ff35274/src/Search/Search.php#L298-L307
10,661
fazland/elastica-odm
src/Search/Search.php
Search._doExecute
private function _doExecute(Query $query) { $collection = $this->documentManager->getCollection($this->documentClass); if ($this->isScroll()) { $scroll = $collection->scroll($query); foreach ($scroll as $resultSet) { yield $resultSet; } } else { yield $collection->search($query); } }
php
private function _doExecute(Query $query) { $collection = $this->documentManager->getCollection($this->documentClass); if ($this->isScroll()) { $scroll = $collection->scroll($query); foreach ($scroll as $resultSet) { yield $resultSet; } } else { yield $collection->search($query); } }
[ "private", "function", "_doExecute", "(", "Query", "$", "query", ")", "{", "$", "collection", "=", "$", "this", "->", "documentManager", "->", "getCollection", "(", "$", "this", "->", "documentClass", ")", ";", "if", "(", "$", "this", "->", "isScroll", "(", ")", ")", "{", "$", "scroll", "=", "$", "collection", "->", "scroll", "(", "$", "query", ")", ";", "foreach", "(", "$", "scroll", "as", "$", "resultSet", ")", "{", "yield", "$", "resultSet", ";", "}", "}", "else", "{", "yield", "$", "collection", "->", "search", "(", "$", "query", ")", ";", "}", "}" ]
Executes the search action, yield all the result sets. @param Query $query @return \Generator|ResultSet[]
[ "Executes", "the", "search", "action", "yield", "all", "the", "result", "sets", "." ]
9d7276ea9ea9103c670f13f889bf59568ff35274
https://github.com/fazland/elastica-odm/blob/9d7276ea9ea9103c670f13f889bf59568ff35274/src/Search/Search.php#L326-L339
10,662
fazland/elastica-odm
src/Search/Search.php
Search._doExecuteCached
private function _doExecuteCached(Query $query) { if (null !== $resultCache = $this->documentManager->getResultCache()) { $item = $resultCache->getItem($this->cacheProfile->getCacheKey()); if ($item->isHit()) { yield from $item->get(); return; } } $resultSets = iterator_to_array($this->_doExecute($query)); if (isset($item)) { $item->set($resultSets); $item->expiresAfter($this->cacheProfile->getTtl()); $resultCache->save($item); } yield from $resultSets; }
php
private function _doExecuteCached(Query $query) { if (null !== $resultCache = $this->documentManager->getResultCache()) { $item = $resultCache->getItem($this->cacheProfile->getCacheKey()); if ($item->isHit()) { yield from $item->get(); return; } } $resultSets = iterator_to_array($this->_doExecute($query)); if (isset($item)) { $item->set($resultSets); $item->expiresAfter($this->cacheProfile->getTtl()); $resultCache->save($item); } yield from $resultSets; }
[ "private", "function", "_doExecuteCached", "(", "Query", "$", "query", ")", "{", "if", "(", "null", "!==", "$", "resultCache", "=", "$", "this", "->", "documentManager", "->", "getResultCache", "(", ")", ")", "{", "$", "item", "=", "$", "resultCache", "->", "getItem", "(", "$", "this", "->", "cacheProfile", "->", "getCacheKey", "(", ")", ")", ";", "if", "(", "$", "item", "->", "isHit", "(", ")", ")", "{", "yield", "from", "$", "item", "->", "get", "(", ")", ";", "return", ";", "}", "}", "$", "resultSets", "=", "iterator_to_array", "(", "$", "this", "->", "_doExecute", "(", "$", "query", ")", ")", ";", "if", "(", "isset", "(", "$", "item", ")", ")", "{", "$", "item", "->", "set", "(", "$", "resultSets", ")", ";", "$", "item", "->", "expiresAfter", "(", "$", "this", "->", "cacheProfile", "->", "getTtl", "(", ")", ")", ";", "$", "resultCache", "->", "save", "(", "$", "item", ")", ";", "}", "yield", "from", "$", "resultSets", ";", "}" ]
Executes a cached query. @param Query $query @return \Generator|ResultSet[]
[ "Executes", "a", "cached", "query", "." ]
9d7276ea9ea9103c670f13f889bf59568ff35274
https://github.com/fazland/elastica-odm/blob/9d7276ea9ea9103c670f13f889bf59568ff35274/src/Search/Search.php#L348-L369
10,663
uthando-cms/uthando-common
src/UthandoCommon/Form/Element/LibPhoneNumberCountryList.php
LibPhoneNumberCountryList.init
public function init() { $libPhoneNumber = PhoneNumberUtil::getInstance(); $optionsList = []; foreach ($libPhoneNumber->getSupportedRegions() as $code) { $fullTextCountry = \Locale::getDisplayRegion('en_' . $code, 'en'); $optionsList[$code] = $fullTextCountry; } asort($optionsList); $this->setValueOptions($optionsList); }
php
public function init() { $libPhoneNumber = PhoneNumberUtil::getInstance(); $optionsList = []; foreach ($libPhoneNumber->getSupportedRegions() as $code) { $fullTextCountry = \Locale::getDisplayRegion('en_' . $code, 'en'); $optionsList[$code] = $fullTextCountry; } asort($optionsList); $this->setValueOptions($optionsList); }
[ "public", "function", "init", "(", ")", "{", "$", "libPhoneNumber", "=", "PhoneNumberUtil", "::", "getInstance", "(", ")", ";", "$", "optionsList", "=", "[", "]", ";", "foreach", "(", "$", "libPhoneNumber", "->", "getSupportedRegions", "(", ")", "as", "$", "code", ")", "{", "$", "fullTextCountry", "=", "\\", "Locale", "::", "getDisplayRegion", "(", "'en_'", ".", "$", "code", ",", "'en'", ")", ";", "$", "optionsList", "[", "$", "code", "]", "=", "$", "fullTextCountry", ";", "}", "asort", "(", "$", "optionsList", ")", ";", "$", "this", "->", "setValueOptions", "(", "$", "optionsList", ")", ";", "}" ]
set up option list
[ "set", "up", "option", "list" ]
feb915da5d26b60f536282e1bc3ad5c22e53f485
https://github.com/uthando-cms/uthando-common/blob/feb915da5d26b60f536282e1bc3ad5c22e53f485/src/UthandoCommon/Form/Element/LibPhoneNumberCountryList.php#L31-L44
10,664
walmsles/event-dispatch
src/EventDispatch/Dispatcher.php
Dispatcher.subscribe
public function subscribe($eventName, $callable, $priority = 0) { if (!is_callable($callable)) { throw new SubscriberNotCallable(); } $this->eventList[$eventName][$priority][] = $callable; /* * Clear cached sorted array */ unset($this->sorted[$eventName]); return $this; }
php
public function subscribe($eventName, $callable, $priority = 0) { if (!is_callable($callable)) { throw new SubscriberNotCallable(); } $this->eventList[$eventName][$priority][] = $callable; /* * Clear cached sorted array */ unset($this->sorted[$eventName]); return $this; }
[ "public", "function", "subscribe", "(", "$", "eventName", ",", "$", "callable", ",", "$", "priority", "=", "0", ")", "{", "if", "(", "!", "is_callable", "(", "$", "callable", ")", ")", "{", "throw", "new", "SubscriberNotCallable", "(", ")", ";", "}", "$", "this", "->", "eventList", "[", "$", "eventName", "]", "[", "$", "priority", "]", "[", "]", "=", "$", "callable", ";", "/*\n * Clear cached sorted array\n */", "unset", "(", "$", "this", "->", "sorted", "[", "$", "eventName", "]", ")", ";", "return", "$", "this", ";", "}" ]
Subscribe to an Event with either a closure or callable structure @param $eventName @param $callable @param int $priority - highest number highest priority @return $this @throws \EventDispatch\Exception\SubscriberNotCallable
[ "Subscribe", "to", "an", "Event", "with", "either", "a", "closure", "or", "callable", "structure" ]
00f1ee2c1b6dc802639eb3e776d6590a23ad93d6
https://github.com/walmsles/event-dispatch/blob/00f1ee2c1b6dc802639eb3e776d6590a23ad93d6/src/EventDispatch/Dispatcher.php#L43-L57
10,665
walmsles/event-dispatch
src/EventDispatch/Dispatcher.php
Dispatcher.sortSubscribers
public function sortSubscribers($eventName) { $this->sorted[$eventName] = array(); if (isset($this->eventList[$eventName])) { krsort($this->eventList[$eventName]); $this->sorted[$eventName] = call_user_func_array('array_merge', $this->eventList[$eventName]); } return $this->sorted[$eventName]; }
php
public function sortSubscribers($eventName) { $this->sorted[$eventName] = array(); if (isset($this->eventList[$eventName])) { krsort($this->eventList[$eventName]); $this->sorted[$eventName] = call_user_func_array('array_merge', $this->eventList[$eventName]); } return $this->sorted[$eventName]; }
[ "public", "function", "sortSubscribers", "(", "$", "eventName", ")", "{", "$", "this", "->", "sorted", "[", "$", "eventName", "]", "=", "array", "(", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "eventList", "[", "$", "eventName", "]", ")", ")", "{", "krsort", "(", "$", "this", "->", "eventList", "[", "$", "eventName", "]", ")", ";", "$", "this", "->", "sorted", "[", "$", "eventName", "]", "=", "call_user_func_array", "(", "'array_merge'", ",", "$", "this", "->", "eventList", "[", "$", "eventName", "]", ")", ";", "}", "return", "$", "this", "->", "sorted", "[", "$", "eventName", "]", ";", "}" ]
Sort Subscribers in reverse priority order - higher priority first @param $eventName @return mixed
[ "Sort", "Subscribers", "in", "reverse", "priority", "order", "-", "higher", "priority", "first" ]
00f1ee2c1b6dc802639eb3e776d6590a23ad93d6
https://github.com/walmsles/event-dispatch/blob/00f1ee2c1b6dc802639eb3e776d6590a23ad93d6/src/EventDispatch/Dispatcher.php#L81-L90
10,666
walmsles/event-dispatch
src/EventDispatch/Dispatcher.php
Dispatcher.queue
public function queue($eventName, $payload = array()) { $me = $this; $this->subscribe($eventName . self::QUEUE_NAME, function () use ($me, $eventName, $payload) { return $me->dispatch($eventName, $payload); }); }
php
public function queue($eventName, $payload = array()) { $me = $this; $this->subscribe($eventName . self::QUEUE_NAME, function () use ($me, $eventName, $payload) { return $me->dispatch($eventName, $payload); }); }
[ "public", "function", "queue", "(", "$", "eventName", ",", "$", "payload", "=", "array", "(", ")", ")", "{", "$", "me", "=", "$", "this", ";", "$", "this", "->", "subscribe", "(", "$", "eventName", ".", "self", "::", "QUEUE_NAME", ",", "function", "(", ")", "use", "(", "$", "me", ",", "$", "eventName", ",", "$", "payload", ")", "{", "return", "$", "me", "->", "dispatch", "(", "$", "eventName", ",", "$", "payload", ")", ";", "}", ")", ";", "}" ]
Defer dispatching of an event or events until flush is called. @param $eventName @param array $payload @throws \EventDispatch\Exception\SubscriberNotCallable
[ "Defer", "dispatching", "of", "an", "event", "or", "events", "until", "flush", "is", "called", "." ]
00f1ee2c1b6dc802639eb3e776d6590a23ad93d6
https://github.com/walmsles/event-dispatch/blob/00f1ee2c1b6dc802639eb3e776d6590a23ad93d6/src/EventDispatch/Dispatcher.php#L164-L171
10,667
walmsles/event-dispatch
src/EventDispatch/Dispatcher.php
Dispatcher.flush
public function flush($eventName) { $result = $this->dispatch($eventName . self::QUEUE_NAME); // If result is an array then need to merge or will end up with array of arrays. if (is_array($result)) { $result = call_user_func_array('array_merge', $result); } return $result; }
php
public function flush($eventName) { $result = $this->dispatch($eventName . self::QUEUE_NAME); // If result is an array then need to merge or will end up with array of arrays. if (is_array($result)) { $result = call_user_func_array('array_merge', $result); } return $result; }
[ "public", "function", "flush", "(", "$", "eventName", ")", "{", "$", "result", "=", "$", "this", "->", "dispatch", "(", "$", "eventName", ".", "self", "::", "QUEUE_NAME", ")", ";", "// If result is an array then need to merge or will end up with array of arrays.", "if", "(", "is_array", "(", "$", "result", ")", ")", "{", "$", "result", "=", "call_user_func_array", "(", "'array_merge'", ",", "$", "result", ")", ";", "}", "return", "$", "result", ";", "}" ]
Flush Event Queue @param $eventName
[ "Flush", "Event", "Queue" ]
00f1ee2c1b6dc802639eb3e776d6590a23ad93d6
https://github.com/walmsles/event-dispatch/blob/00f1ee2c1b6dc802639eb3e776d6590a23ad93d6/src/EventDispatch/Dispatcher.php#L178-L187
10,668
silverorange/Net_Notifier
Net/Notifier/Client.php
Net_Notifier_Client.parseAddress
public function parseAddress($address) { $exp = '!^wss?://([\w-.]+?)(?::(\d+))?(/.*)?$!'; $matches = array(); if (!preg_match($exp, $address, $matches)) { throw new Net_Notifier_ClientException( sprintf( 'Invalid WebSocket address: %s. Should be in the form ' . 'ws://host[:port][/resource]', $address ) ); } if (isset($matches[1])) { $this->setHost($matches[1]); } if (isset($matches[2])) { $this->setPort($matches[2]); } if (isset($matches[3])) { $this->setResource($matches[3]); } return $this; }
php
public function parseAddress($address) { $exp = '!^wss?://([\w-.]+?)(?::(\d+))?(/.*)?$!'; $matches = array(); if (!preg_match($exp, $address, $matches)) { throw new Net_Notifier_ClientException( sprintf( 'Invalid WebSocket address: %s. Should be in the form ' . 'ws://host[:port][/resource]', $address ) ); } if (isset($matches[1])) { $this->setHost($matches[1]); } if (isset($matches[2])) { $this->setPort($matches[2]); } if (isset($matches[3])) { $this->setResource($matches[3]); } return $this; }
[ "public", "function", "parseAddress", "(", "$", "address", ")", "{", "$", "exp", "=", "'!^wss?://([\\w-.]+?)(?::(\\d+))?(/.*)?$!'", ";", "$", "matches", "=", "array", "(", ")", ";", "if", "(", "!", "preg_match", "(", "$", "exp", ",", "$", "address", ",", "$", "matches", ")", ")", "{", "throw", "new", "Net_Notifier_ClientException", "(", "sprintf", "(", "'Invalid WebSocket address: %s. Should be in the form '", ".", "'ws://host[:port][/resource]'", ",", "$", "address", ")", ")", ";", "}", "if", "(", "isset", "(", "$", "matches", "[", "1", "]", ")", ")", "{", "$", "this", "->", "setHost", "(", "$", "matches", "[", "1", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "matches", "[", "2", "]", ")", ")", "{", "$", "this", "->", "setPort", "(", "$", "matches", "[", "2", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "matches", "[", "3", "]", ")", ")", "{", "$", "this", "->", "setResource", "(", "$", "matches", "[", "3", "]", ")", ";", "}", "return", "$", "this", ";", "}" ]
Parses a WebSocket address and sets the constituent parts for this client A WebSocket address looks like 'ws://hostname:port/resource-name'. If present, the host, port and resource of this client are set from the parsed values. @param string $address the address to parse. @return Net_Notifier_Client the current object, for fluent interface. @throws Net_Notifier_ClientException if the specified address is not a properly formatted WebSocket address.
[ "Parses", "a", "WebSocket", "address", "and", "sets", "the", "constituent", "parts", "for", "this", "client" ]
b446e27cd1bebd58ba89243cde1272c5d281d3fb
https://github.com/silverorange/Net_Notifier/blob/b446e27cd1bebd58ba89243cde1272c5d281d3fb/Net/Notifier/Client.php#L166-L193
10,669
silverorange/Net_Notifier
Net/Notifier/Client.php
Net_Notifier_Client.connect
protected function connect() { $this->socket = new Net_Notifier_Socket_Client( sprintf( 'tcp://%s:%s', $this->host, $this->port ), $this->timeout / 1000 ); $this->connection = new Net_Notifier_WebSocket_Connection( $this->socket ); $this->connection->startHandshake( $this->host, $this->port, $this->resource, array(Net_Notifier_WebSocket::PROTOCOL) ); // read handshake response $state = $this->connection->getState(); while ($state < Net_Notifier_WebSocket_Connection::STATE_OPEN) { $read = array($this->socket->getRawSocket()); $result = stream_select( $read, $write = null, $except = null, null ); if ($result === 1) { $this->connection->read(self::READ_BUFFER_LENGTH); } $state = $this->connection->getState(); } }
php
protected function connect() { $this->socket = new Net_Notifier_Socket_Client( sprintf( 'tcp://%s:%s', $this->host, $this->port ), $this->timeout / 1000 ); $this->connection = new Net_Notifier_WebSocket_Connection( $this->socket ); $this->connection->startHandshake( $this->host, $this->port, $this->resource, array(Net_Notifier_WebSocket::PROTOCOL) ); // read handshake response $state = $this->connection->getState(); while ($state < Net_Notifier_WebSocket_Connection::STATE_OPEN) { $read = array($this->socket->getRawSocket()); $result = stream_select( $read, $write = null, $except = null, null ); if ($result === 1) { $this->connection->read(self::READ_BUFFER_LENGTH); } $state = $this->connection->getState(); } }
[ "protected", "function", "connect", "(", ")", "{", "$", "this", "->", "socket", "=", "new", "Net_Notifier_Socket_Client", "(", "sprintf", "(", "'tcp://%s:%s'", ",", "$", "this", "->", "host", ",", "$", "this", "->", "port", ")", ",", "$", "this", "->", "timeout", "/", "1000", ")", ";", "$", "this", "->", "connection", "=", "new", "Net_Notifier_WebSocket_Connection", "(", "$", "this", "->", "socket", ")", ";", "$", "this", "->", "connection", "->", "startHandshake", "(", "$", "this", "->", "host", ",", "$", "this", "->", "port", ",", "$", "this", "->", "resource", ",", "array", "(", "Net_Notifier_WebSocket", "::", "PROTOCOL", ")", ")", ";", "// read handshake response", "$", "state", "=", "$", "this", "->", "connection", "->", "getState", "(", ")", ";", "while", "(", "$", "state", "<", "Net_Notifier_WebSocket_Connection", "::", "STATE_OPEN", ")", "{", "$", "read", "=", "array", "(", "$", "this", "->", "socket", "->", "getRawSocket", "(", ")", ")", ";", "$", "result", "=", "stream_select", "(", "$", "read", ",", "$", "write", "=", "null", ",", "$", "except", "=", "null", ",", "null", ")", ";", "if", "(", "$", "result", "===", "1", ")", "{", "$", "this", "->", "connection", "->", "read", "(", "self", "::", "READ_BUFFER_LENGTH", ")", ";", "}", "$", "state", "=", "$", "this", "->", "connection", "->", "getState", "(", ")", ";", "}", "}" ]
Connects this client to the cha-ching server A socket connection is opened and the WebSocket handshake is initiated. @return void @throws Net_Notifier_ClientException if there is an error connecting to the notification server.
[ "Connects", "this", "client", "to", "the", "cha", "-", "ching", "server" ]
b446e27cd1bebd58ba89243cde1272c5d281d3fb
https://github.com/silverorange/Net_Notifier/blob/b446e27cd1bebd58ba89243cde1272c5d281d3fb/Net/Notifier/Client.php#L272-L313
10,670
silverorange/Net_Notifier
Net/Notifier/Client.php
Net_Notifier_Client.disconnect
protected function disconnect() { // Initiate connection close. The WebSockets RFC recomends against // clients initiating the close handshake but we want to ensure the // connection is closed as soon as possible. $this->connection->startClose( Net_Notifier_WebSocket_Connection::CLOSE_GOING_AWAY, 'Client sent message.' ); // read server close frame $state = $this->connection->getState(); $sec = intval($this->timeout / 1000); $usec = ($this->timeout % 1000) * 1000; while ($state < Net_Notifier_WebSocket_Connection::STATE_CLOSED) { $read = array($this->socket->getRawSocket()); $result = stream_select( $read, $write = null, $except = null, $sec, $usec ); if ($result === 1) { $this->connection->read(self::READ_BUFFER_LENGTH); } else { // read timed out, just close the connection $this->connection->close(); } $state = $this->connection->getState(); } $this->connection = null; }
php
protected function disconnect() { // Initiate connection close. The WebSockets RFC recomends against // clients initiating the close handshake but we want to ensure the // connection is closed as soon as possible. $this->connection->startClose( Net_Notifier_WebSocket_Connection::CLOSE_GOING_AWAY, 'Client sent message.' ); // read server close frame $state = $this->connection->getState(); $sec = intval($this->timeout / 1000); $usec = ($this->timeout % 1000) * 1000; while ($state < Net_Notifier_WebSocket_Connection::STATE_CLOSED) { $read = array($this->socket->getRawSocket()); $result = stream_select( $read, $write = null, $except = null, $sec, $usec ); if ($result === 1) { $this->connection->read(self::READ_BUFFER_LENGTH); } else { // read timed out, just close the connection $this->connection->close(); } $state = $this->connection->getState(); } $this->connection = null; }
[ "protected", "function", "disconnect", "(", ")", "{", "// Initiate connection close. The WebSockets RFC recomends against", "// clients initiating the close handshake but we want to ensure the", "// connection is closed as soon as possible.", "$", "this", "->", "connection", "->", "startClose", "(", "Net_Notifier_WebSocket_Connection", "::", "CLOSE_GOING_AWAY", ",", "'Client sent message.'", ")", ";", "// read server close frame", "$", "state", "=", "$", "this", "->", "connection", "->", "getState", "(", ")", ";", "$", "sec", "=", "intval", "(", "$", "this", "->", "timeout", "/", "1000", ")", ";", "$", "usec", "=", "(", "$", "this", "->", "timeout", "%", "1000", ")", "*", "1000", ";", "while", "(", "$", "state", "<", "Net_Notifier_WebSocket_Connection", "::", "STATE_CLOSED", ")", "{", "$", "read", "=", "array", "(", "$", "this", "->", "socket", "->", "getRawSocket", "(", ")", ")", ";", "$", "result", "=", "stream_select", "(", "$", "read", ",", "$", "write", "=", "null", ",", "$", "except", "=", "null", ",", "$", "sec", ",", "$", "usec", ")", ";", "if", "(", "$", "result", "===", "1", ")", "{", "$", "this", "->", "connection", "->", "read", "(", "self", "::", "READ_BUFFER_LENGTH", ")", ";", "}", "else", "{", "// read timed out, just close the connection", "$", "this", "->", "connection", "->", "close", "(", ")", ";", "}", "$", "state", "=", "$", "this", "->", "connection", "->", "getState", "(", ")", ";", "}", "$", "this", "->", "connection", "=", "null", ";", "}" ]
Disconnects this client from the server @return void
[ "Disconnects", "this", "client", "from", "the", "server" ]
b446e27cd1bebd58ba89243cde1272c5d281d3fb
https://github.com/silverorange/Net_Notifier/blob/b446e27cd1bebd58ba89243cde1272c5d281d3fb/Net/Notifier/Client.php#L323-L361
10,671
Erebot/Styling
src/Styling.php
Styling.getClass
public function getClass($type) { if (!isset($this->cls[$type])) { throw new \InvalidArgumentException('Invalid type'); } return $this->cls[$type]; }
php
public function getClass($type) { if (!isset($this->cls[$type])) { throw new \InvalidArgumentException('Invalid type'); } return $this->cls[$type]; }
[ "public", "function", "getClass", "(", "$", "type", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "cls", "[", "$", "type", "]", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Invalid type'", ")", ";", "}", "return", "$", "this", "->", "cls", "[", "$", "type", "]", ";", "}" ]
Returns the class used to wrap scalar types. \param string $type Name of a scalar type that can be wrapped by this class automatically. Must be one of "int", "string" or "float". \retval string Name of the class that can be used to wrap variables of the given type.
[ "Returns", "the", "class", "used", "to", "wrap", "scalar", "types", "." ]
e7340a98e89b15f2596a08683ad17fe2e6a85d30
https://github.com/Erebot/Styling/blob/e7340a98e89b15f2596a08683ad17fe2e6a85d30/src/Styling.php#L150-L156
10,672
Erebot/Styling
src/Styling.php
Styling.setClass
public function setClass($type, $cls) { if (!isset($this->cls[$type])) { throw new \InvalidArgumentException('Invalid type'); } if (!is_string($cls)) { throw new \InvalidArgumentException( 'Expected a string for the class' ); } if (!class_exists($cls)) { throw new \InvalidArgumentException('Class not found'); } if (!($cls instanceof \Erebot\Styling\VariableInterface)) { throw new \InvalidArgumentException( 'Must be a subclass of \\Erebot\\Styling\\VariableInterface' ); } $this->cls[$type] = $cls; }
php
public function setClass($type, $cls) { if (!isset($this->cls[$type])) { throw new \InvalidArgumentException('Invalid type'); } if (!is_string($cls)) { throw new \InvalidArgumentException( 'Expected a string for the class' ); } if (!class_exists($cls)) { throw new \InvalidArgumentException('Class not found'); } if (!($cls instanceof \Erebot\Styling\VariableInterface)) { throw new \InvalidArgumentException( 'Must be a subclass of \\Erebot\\Styling\\VariableInterface' ); } $this->cls[$type] = $cls; }
[ "public", "function", "setClass", "(", "$", "type", ",", "$", "cls", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "cls", "[", "$", "type", "]", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Invalid type'", ")", ";", "}", "if", "(", "!", "is_string", "(", "$", "cls", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Expected a string for the class'", ")", ";", "}", "if", "(", "!", "class_exists", "(", "$", "cls", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Class not found'", ")", ";", "}", "if", "(", "!", "(", "$", "cls", "instanceof", "\\", "Erebot", "\\", "Styling", "\\", "VariableInterface", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Must be a subclass of \\\\Erebot\\\\Styling\\\\VariableInterface'", ")", ";", "}", "$", "this", "->", "cls", "[", "$", "type", "]", "=", "$", "cls", ";", "}" ]
Sets the class to use to wrap a certain scalar type. \param string $type Name of a scalar type that can be wrapped by this class automatically. Must be one of "int", "string" or "float". \param string $cls Name of the class that can be used to wrap variables of the given type.
[ "Sets", "the", "class", "to", "use", "to", "wrap", "a", "certain", "scalar", "type", "." ]
e7340a98e89b15f2596a08683ad17fe2e6a85d30
https://github.com/Erebot/Styling/blob/e7340a98e89b15f2596a08683ad17fe2e6a85d30/src/Styling.php#L170-L189
10,673
Erebot/Styling
src/Styling.php
Styling.wrapScalar
protected function wrapScalar($var, $name) { self::checkVariableName($name); if (is_object($var)) { if ($var instanceof \Erebot\Styling\VariableInterface) { return $var; } if (!is_callable(array($var, '__toString'), false)) { throw new \InvalidArgumentException( $name.' must be a scalar or an instance of '. '\\Erebot\\Styling\\VariableInterface' ); } } if (is_array($var)) { return $var; } if (is_string($var) || is_callable(array($var, '__toString'), false)) { $cls = $this->cls['string']; } elseif (is_int($var)) { $cls = $this->cls['int']; } elseif (is_float($var)) { $cls = $this->cls['float']; } else { throw new \InvalidArgumentException( 'Unsupported scalar type ('.gettype($var).') for "'.$name.'"' ); } return new $cls($var); }
php
protected function wrapScalar($var, $name) { self::checkVariableName($name); if (is_object($var)) { if ($var instanceof \Erebot\Styling\VariableInterface) { return $var; } if (!is_callable(array($var, '__toString'), false)) { throw new \InvalidArgumentException( $name.' must be a scalar or an instance of '. '\\Erebot\\Styling\\VariableInterface' ); } } if (is_array($var)) { return $var; } if (is_string($var) || is_callable(array($var, '__toString'), false)) { $cls = $this->cls['string']; } elseif (is_int($var)) { $cls = $this->cls['int']; } elseif (is_float($var)) { $cls = $this->cls['float']; } else { throw new \InvalidArgumentException( 'Unsupported scalar type ('.gettype($var).') for "'.$name.'"' ); } return new $cls($var); }
[ "protected", "function", "wrapScalar", "(", "$", "var", ",", "$", "name", ")", "{", "self", "::", "checkVariableName", "(", "$", "name", ")", ";", "if", "(", "is_object", "(", "$", "var", ")", ")", "{", "if", "(", "$", "var", "instanceof", "\\", "Erebot", "\\", "Styling", "\\", "VariableInterface", ")", "{", "return", "$", "var", ";", "}", "if", "(", "!", "is_callable", "(", "array", "(", "$", "var", ",", "'__toString'", ")", ",", "false", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "$", "name", ".", "' must be a scalar or an instance of '", ".", "'\\\\Erebot\\\\Styling\\\\VariableInterface'", ")", ";", "}", "}", "if", "(", "is_array", "(", "$", "var", ")", ")", "{", "return", "$", "var", ";", "}", "if", "(", "is_string", "(", "$", "var", ")", "||", "is_callable", "(", "array", "(", "$", "var", ",", "'__toString'", ")", ",", "false", ")", ")", "{", "$", "cls", "=", "$", "this", "->", "cls", "[", "'string'", "]", ";", "}", "elseif", "(", "is_int", "(", "$", "var", ")", ")", "{", "$", "cls", "=", "$", "this", "->", "cls", "[", "'int'", "]", ";", "}", "elseif", "(", "is_float", "(", "$", "var", ")", ")", "{", "$", "cls", "=", "$", "this", "->", "cls", "[", "'float'", "]", ";", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Unsupported scalar type ('", ".", "gettype", "(", "$", "var", ")", ".", "') for \"'", ".", "$", "name", ".", "'\"'", ")", ";", "}", "return", "new", "$", "cls", "(", "$", "var", ")", ";", "}" ]
Wraps a scalar into the appropriate styling object. \param mixed $var Either a scalar, an array or an object implementing the ::Erebot::Styling::VariableInterface interface. Scalar values will be wrapped with the appropriate object while arrays and objects are returned untouched. \param string $name Name of given variable. \retval array If \a $var referred to an array, it is returned without any modification. \retval ::Erebot::Styling::VariableInterface_Variable Objects that implement ::Erebot::Styling::VariableInterface are returned without any modification. Scalar values are wrapped into the appropriate object implementing the ::Erebot::Styling::VariableInterface interface and the resulting object is returned. \throw ::InvalidArgumentException Either the given name is invalid, or the given value was not a scalar. \note In the context of this method, objects that can be converted to a string (ie. implement __toString()) are treated as if they were a string (and thus, are considered as scalar values).
[ "Wraps", "a", "scalar", "into", "the", "appropriate", "styling", "object", "." ]
e7340a98e89b15f2596a08683ad17fe2e6a85d30
https://github.com/Erebot/Styling/blob/e7340a98e89b15f2596a08683ad17fe2e6a85d30/src/Styling.php#L304-L337
10,674
Erebot/Styling
src/Styling.php
Styling.parseTemplate
protected static function parseTemplate($source) { $source = '<msg xmlns="http://www.erebot.net/xmlns/erebot/styling">'. $source. '</msg>'; $schema = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'styling.rng'; $dom = new \Erebot\DOM(); $dom->substituteEntities = true; $dom->resolveExternals = false; $dom->recover = true; $ue = libxml_use_internal_errors(true); $dom->loadXML($source); $valid = $dom->relaxNGValidate($schema); $errors = $dom->getErrors(); libxml_use_internal_errors($ue); if (!$valid || count($errors)) { // Some unpredicted error occurred, // show some (hopefully) useful information. if (class_exists('\\Plop\\Plop')) { $logger = \Plop\Plop::getInstance(); $logger->error(print_r($errors, true)); } throw new \InvalidArgumentException( 'Error while validating the message' ); } return $dom; }
php
protected static function parseTemplate($source) { $source = '<msg xmlns="http://www.erebot.net/xmlns/erebot/styling">'. $source. '</msg>'; $schema = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'styling.rng'; $dom = new \Erebot\DOM(); $dom->substituteEntities = true; $dom->resolveExternals = false; $dom->recover = true; $ue = libxml_use_internal_errors(true); $dom->loadXML($source); $valid = $dom->relaxNGValidate($schema); $errors = $dom->getErrors(); libxml_use_internal_errors($ue); if (!$valid || count($errors)) { // Some unpredicted error occurred, // show some (hopefully) useful information. if (class_exists('\\Plop\\Plop')) { $logger = \Plop\Plop::getInstance(); $logger->error(print_r($errors, true)); } throw new \InvalidArgumentException( 'Error while validating the message' ); } return $dom; }
[ "protected", "static", "function", "parseTemplate", "(", "$", "source", ")", "{", "$", "source", "=", "'<msg xmlns=\"http://www.erebot.net/xmlns/erebot/styling\">'", ".", "$", "source", ".", "'</msg>'", ";", "$", "schema", "=", "dirname", "(", "__DIR__", ")", ".", "DIRECTORY_SEPARATOR", ".", "'data'", ".", "DIRECTORY_SEPARATOR", ".", "'styling.rng'", ";", "$", "dom", "=", "new", "\\", "Erebot", "\\", "DOM", "(", ")", ";", "$", "dom", "->", "substituteEntities", "=", "true", ";", "$", "dom", "->", "resolveExternals", "=", "false", ";", "$", "dom", "->", "recover", "=", "true", ";", "$", "ue", "=", "libxml_use_internal_errors", "(", "true", ")", ";", "$", "dom", "->", "loadXML", "(", "$", "source", ")", ";", "$", "valid", "=", "$", "dom", "->", "relaxNGValidate", "(", "$", "schema", ")", ";", "$", "errors", "=", "$", "dom", "->", "getErrors", "(", ")", ";", "libxml_use_internal_errors", "(", "$", "ue", ")", ";", "if", "(", "!", "$", "valid", "||", "count", "(", "$", "errors", ")", ")", "{", "// Some unpredicted error occurred,", "// show some (hopefully) useful information.", "if", "(", "class_exists", "(", "'\\\\Plop\\\\Plop'", ")", ")", "{", "$", "logger", "=", "\\", "Plop", "\\", "Plop", "::", "getInstance", "(", ")", ";", "$", "logger", "->", "error", "(", "print_r", "(", "$", "errors", ",", "true", ")", ")", ";", "}", "throw", "new", "\\", "InvalidArgumentException", "(", "'Error while validating the message'", ")", ";", "}", "return", "$", "dom", ";", "}" ]
Parses a template into a DOM. \param string $source Template to parse. \retval Erebot::DOM DOM object constructed from the template. \throw ::InvalidArgumentException The template was malformed or invalid.
[ "Parses", "a", "template", "into", "a", "DOM", "." ]
e7340a98e89b15f2596a08683ad17fe2e6a85d30
https://github.com/Erebot/Styling/blob/e7340a98e89b15f2596a08683ad17fe2e6a85d30/src/Styling.php#L353-L384
10,675
Erebot/Styling
src/Styling.php
Styling.parseChildren
private function parseChildren($node, &$attributes, $vars) { $result = ''; for ($child = $node->firstChild; $child != null; $child = $child->nextSibling) { $result .= $this->parseNode($child, $attributes, $vars); } return $result; }
php
private function parseChildren($node, &$attributes, $vars) { $result = ''; for ($child = $node->firstChild; $child != null; $child = $child->nextSibling) { $result .= $this->parseNode($child, $attributes, $vars); } return $result; }
[ "private", "function", "parseChildren", "(", "$", "node", ",", "&", "$", "attributes", ",", "$", "vars", ")", "{", "$", "result", "=", "''", ";", "for", "(", "$", "child", "=", "$", "node", "->", "firstChild", ";", "$", "child", "!=", "null", ";", "$", "child", "=", "$", "child", "->", "nextSibling", ")", "{", "$", "result", ".=", "$", "this", "->", "parseNode", "(", "$", "child", ",", "$", "attributes", ",", "$", "vars", ")", ";", "}", "return", "$", "result", ";", "}" ]
This method is used to apply the parsing method to children of an XML node. \param DOMNode $node The node being parsed. \param array $attributes Array of styling attributes. \param array $vars Template variables that can be injected in the result. \retval string Parsing result, with styles applied as appropriate.
[ "This", "method", "is", "used", "to", "apply", "the", "parsing", "method", "to", "children", "of", "an", "XML", "node", "." ]
e7340a98e89b15f2596a08683ad17fe2e6a85d30
https://github.com/Erebot/Styling/blob/e7340a98e89b15f2596a08683ad17fe2e6a85d30/src/Styling.php#L650-L657
10,676
bishopb/vanilla
library/core/class.statistics.php
Gdn_Statistics.BasicParameters
public function BasicParameters(&$Request) { $Request = array_merge($Request, array( 'ServerHostname' => Url('/', TRUE), 'ServerType' => Gdn::Request()->GetValue('SERVER_SOFTWARE'), 'PHPVersion' => phpversion(), 'VanillaVersion' => APPLICATION_VERSION )); }
php
public function BasicParameters(&$Request) { $Request = array_merge($Request, array( 'ServerHostname' => Url('/', TRUE), 'ServerType' => Gdn::Request()->GetValue('SERVER_SOFTWARE'), 'PHPVersion' => phpversion(), 'VanillaVersion' => APPLICATION_VERSION )); }
[ "public", "function", "BasicParameters", "(", "&", "$", "Request", ")", "{", "$", "Request", "=", "array_merge", "(", "$", "Request", ",", "array", "(", "'ServerHostname'", "=>", "Url", "(", "'/'", ",", "TRUE", ")", ",", "'ServerType'", "=>", "Gdn", "::", "Request", "(", ")", "->", "GetValue", "(", "'SERVER_SOFTWARE'", ")", ",", "'PHPVersion'", "=>", "phpversion", "(", ")", ",", "'VanillaVersion'", "=>", "APPLICATION_VERSION", ")", ")", ";", "}" ]
Automatically configures a ProxyRequest array with basic parameters such as IP, VanillaVersion, RequestTime, Hostname, PHPVersion, ServerType. @param array $Request Reference to the existing request array @return void
[ "Automatically", "configures", "a", "ProxyRequest", "array", "with", "basic", "parameters", "such", "as", "IP", "VanillaVersion", "RequestTime", "Hostname", "PHPVersion", "ServerType", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.statistics.php#L121-L128
10,677
bishopb/vanilla
library/core/class.statistics.php
Gdn_Statistics.Check
public function Check() { // If we're hitting an exception app, short circuit here if (!self::CheckIsAllowed()) { return; } Gdn::Controller()->AddDefinition('AnalyticsTask', 'tick'); if (self::CheckIsEnabled()) { // At this point there is nothing preventing stats from working, so queue a tick. Gdn::Controller()->AddDefinition('TickExtra', $this->GetEncodedTickExtra()); } }
php
public function Check() { // If we're hitting an exception app, short circuit here if (!self::CheckIsAllowed()) { return; } Gdn::Controller()->AddDefinition('AnalyticsTask', 'tick'); if (self::CheckIsEnabled()) { // At this point there is nothing preventing stats from working, so queue a tick. Gdn::Controller()->AddDefinition('TickExtra', $this->GetEncodedTickExtra()); } }
[ "public", "function", "Check", "(", ")", "{", "// If we're hitting an exception app, short circuit here", "if", "(", "!", "self", "::", "CheckIsAllowed", "(", ")", ")", "{", "return", ";", "}", "Gdn", "::", "Controller", "(", ")", "->", "AddDefinition", "(", "'AnalyticsTask'", ",", "'tick'", ")", ";", "if", "(", "self", "::", "CheckIsEnabled", "(", ")", ")", "{", "// At this point there is nothing preventing stats from working, so queue a tick.", "Gdn", "::", "Controller", "(", ")", "->", "AddDefinition", "(", "'TickExtra'", ",", "$", "this", "->", "GetEncodedTickExtra", "(", ")", ")", ";", "}", "}" ]
This method is called each page request and checks the environment. If a stats send is warranted, tells the browser to ping us back. If the site is not registered at the analytics server (does not contain a guid), have the browser request a register instead and defer stats until next request. @return void
[ "This", "method", "is", "called", "each", "page", "request", "and", "checks", "the", "environment", ".", "If", "a", "stats", "send", "is", "warranted", "tells", "the", "browser", "to", "ping", "us", "back", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.statistics.php#L140-L151
10,678
bishopb/vanilla
library/core/class.statistics.php
Gdn_Statistics.Sign
public function Sign(&$Request, $Modify = FALSE) { // Fail if no ID is present $VanillaID = GetValue('VanillaID', $Request, FALSE); if (empty($VanillaID)) return FALSE; if ($VanillaID != Gdn::InstallationID()) return FALSE; // We're going to work on a copy for now $SignatureArray = $Request; // Build the request time $RequestTime = Gdn_Statistics::Time(); // Get the secret key $RequestSecret = Gdn::InstallationSecret(); // Remove the hash from the request data before checking or building the signature unset($SignatureArray['SecurityHash']); // Add the real secret and request time $SignatureArray['Secret'] = $RequestSecret; $SignatureArray['RequestTime'] = $RequestTime; $SignData = array_intersect_key($SignatureArray, array_fill_keys(array( 'VanillaID', 'Secret', 'RequestTime', 'TimeSlot' ), NULL)); // ksort the array to preserve a known order $SignData = array_change_key_case($SignData, CASE_LOWER); ksort($SignData); // Calculate the hash $RealHash = sha1(http_build_query($SignData)); if ($Modify) { $Request['RequestTime'] = $RequestTime; $Request['SecurityHash'] = $RealHash; ksort($Request); } return $RealHash; }
php
public function Sign(&$Request, $Modify = FALSE) { // Fail if no ID is present $VanillaID = GetValue('VanillaID', $Request, FALSE); if (empty($VanillaID)) return FALSE; if ($VanillaID != Gdn::InstallationID()) return FALSE; // We're going to work on a copy for now $SignatureArray = $Request; // Build the request time $RequestTime = Gdn_Statistics::Time(); // Get the secret key $RequestSecret = Gdn::InstallationSecret(); // Remove the hash from the request data before checking or building the signature unset($SignatureArray['SecurityHash']); // Add the real secret and request time $SignatureArray['Secret'] = $RequestSecret; $SignatureArray['RequestTime'] = $RequestTime; $SignData = array_intersect_key($SignatureArray, array_fill_keys(array( 'VanillaID', 'Secret', 'RequestTime', 'TimeSlot' ), NULL)); // ksort the array to preserve a known order $SignData = array_change_key_case($SignData, CASE_LOWER); ksort($SignData); // Calculate the hash $RealHash = sha1(http_build_query($SignData)); if ($Modify) { $Request['RequestTime'] = $RequestTime; $Request['SecurityHash'] = $RealHash; ksort($Request); } return $RealHash; }
[ "public", "function", "Sign", "(", "&", "$", "Request", ",", "$", "Modify", "=", "FALSE", ")", "{", "// Fail if no ID is present", "$", "VanillaID", "=", "GetValue", "(", "'VanillaID'", ",", "$", "Request", ",", "FALSE", ")", ";", "if", "(", "empty", "(", "$", "VanillaID", ")", ")", "return", "FALSE", ";", "if", "(", "$", "VanillaID", "!=", "Gdn", "::", "InstallationID", "(", ")", ")", "return", "FALSE", ";", "// We're going to work on a copy for now", "$", "SignatureArray", "=", "$", "Request", ";", "// Build the request time", "$", "RequestTime", "=", "Gdn_Statistics", "::", "Time", "(", ")", ";", "// Get the secret key", "$", "RequestSecret", "=", "Gdn", "::", "InstallationSecret", "(", ")", ";", "// Remove the hash from the request data before checking or building the signature", "unset", "(", "$", "SignatureArray", "[", "'SecurityHash'", "]", ")", ";", "// Add the real secret and request time", "$", "SignatureArray", "[", "'Secret'", "]", "=", "$", "RequestSecret", ";", "$", "SignatureArray", "[", "'RequestTime'", "]", "=", "$", "RequestTime", ";", "$", "SignData", "=", "array_intersect_key", "(", "$", "SignatureArray", ",", "array_fill_keys", "(", "array", "(", "'VanillaID'", ",", "'Secret'", ",", "'RequestTime'", ",", "'TimeSlot'", ")", ",", "NULL", ")", ")", ";", "// ksort the array to preserve a known order", "$", "SignData", "=", "array_change_key_case", "(", "$", "SignData", ",", "CASE_LOWER", ")", ";", "ksort", "(", "$", "SignData", ")", ";", "// Calculate the hash", "$", "RealHash", "=", "sha1", "(", "http_build_query", "(", "$", "SignData", ")", ")", ";", "if", "(", "$", "Modify", ")", "{", "$", "Request", "[", "'RequestTime'", "]", "=", "$", "RequestTime", ";", "$", "Request", "[", "'SecurityHash'", "]", "=", "$", "RealHash", ";", "ksort", "(", "$", "Request", ")", ";", "}", "return", "$", "RealHash", ";", "}" ]
Sign a request or response Uses the known site secret to sign the given request or response. The request/response is passed in by reference so that it can be augmented with the signature. @param array $Request The request array to be signed @param boolean $Modify Optional whether or not to modify the request in place (default false)
[ "Sign", "a", "request", "or", "response" ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.statistics.php#L407-L452
10,679
bishopb/vanilla
library/core/class.statistics.php
Gdn_Statistics.Tick
public function Tick() { // Fire an event for plugins to track their own stats. // TODO: Make this analyze the path and throw a specific event (this event will change in future versions). $this->EventArguments['Path'] = Gdn::Request()->Post('Path'); $this->FireEvent('Tick'); // Store the view, using denormalization if enabled $ViewType = 'normal'; if (preg_match('`discussion/embed`', Gdn::Request()->Post('ResolvedPath', ''))) $ViewType = 'embed'; $this->AddView($ViewType); if (!self::CheckIsEnabled()) return; if (Gdn::Session()->CheckPermission('Garden.Settings.Manage')) { if (Gdn::Get('Garden.Analytics.Notify', FALSE) !== FALSE) { $CallMessage = Sprite('Bandaid', 'InformSprite'); $CallMessage .= sprintf(T("There's a problem with Vanilla Analytics that needs your attention.<br/> Handle it <a href=\"%s\">here &raquo;</a>"), Url('dashboard/statistics')); Gdn::Controller()->InformMessage($CallMessage, array('CssClass' => 'HasSprite')); } } $InstallationID = Gdn::InstallationID(); // Check if we're registered with the central server already. If not, this request is // hijacked and used to perform that task instead of sending stats or recording a tick. if (is_null($InstallationID)) { // If the config file is not writable, gtfo $ConfFile = PATH_CONF . '/config.php'; if (!is_writable($ConfFile)) { // Admins see a helpful notice if (Gdn::Session()->CheckPermission('Garden.Settings.Manage')) { $Warning = Sprite('Sliders', 'InformSprite'); $Warning .= T('Your config.php file is not writable.<br/> Find out <a href="http://vanillaforums.org/docs/vanillastatistics">how to fix this &raquo;</a>'); Gdn::Controller()->InformMessage($Warning, array('CssClass' => 'HasSprite')); } return; } $AttemptedRegistration = Gdn::Get('Garden.Analytics.Registering', FALSE); // If we last attempted to register less than 60 seconds ago, do nothing. Could still be working. if ($AttemptedRegistration !== FALSE && (time() - $AttemptedRegistration) < 60) return; return $this->Register(); } // If we get here, the installation is registered and we can decide on whether or not to send stats now. $LastSentDate = self::LastSentDate(); if (empty($LastSentDate) || $LastSentDate < date('Ymd', strtotime('-1 day'))) return $this->Stats(); }
php
public function Tick() { // Fire an event for plugins to track their own stats. // TODO: Make this analyze the path and throw a specific event (this event will change in future versions). $this->EventArguments['Path'] = Gdn::Request()->Post('Path'); $this->FireEvent('Tick'); // Store the view, using denormalization if enabled $ViewType = 'normal'; if (preg_match('`discussion/embed`', Gdn::Request()->Post('ResolvedPath', ''))) $ViewType = 'embed'; $this->AddView($ViewType); if (!self::CheckIsEnabled()) return; if (Gdn::Session()->CheckPermission('Garden.Settings.Manage')) { if (Gdn::Get('Garden.Analytics.Notify', FALSE) !== FALSE) { $CallMessage = Sprite('Bandaid', 'InformSprite'); $CallMessage .= sprintf(T("There's a problem with Vanilla Analytics that needs your attention.<br/> Handle it <a href=\"%s\">here &raquo;</a>"), Url('dashboard/statistics')); Gdn::Controller()->InformMessage($CallMessage, array('CssClass' => 'HasSprite')); } } $InstallationID = Gdn::InstallationID(); // Check if we're registered with the central server already. If not, this request is // hijacked and used to perform that task instead of sending stats or recording a tick. if (is_null($InstallationID)) { // If the config file is not writable, gtfo $ConfFile = PATH_CONF . '/config.php'; if (!is_writable($ConfFile)) { // Admins see a helpful notice if (Gdn::Session()->CheckPermission('Garden.Settings.Manage')) { $Warning = Sprite('Sliders', 'InformSprite'); $Warning .= T('Your config.php file is not writable.<br/> Find out <a href="http://vanillaforums.org/docs/vanillastatistics">how to fix this &raquo;</a>'); Gdn::Controller()->InformMessage($Warning, array('CssClass' => 'HasSprite')); } return; } $AttemptedRegistration = Gdn::Get('Garden.Analytics.Registering', FALSE); // If we last attempted to register less than 60 seconds ago, do nothing. Could still be working. if ($AttemptedRegistration !== FALSE && (time() - $AttemptedRegistration) < 60) return; return $this->Register(); } // If we get here, the installation is registered and we can decide on whether or not to send stats now. $LastSentDate = self::LastSentDate(); if (empty($LastSentDate) || $LastSentDate < date('Ymd', strtotime('-1 day'))) return $this->Stats(); }
[ "public", "function", "Tick", "(", ")", "{", "// Fire an event for plugins to track their own stats.", "// TODO: Make this analyze the path and throw a specific event (this event will change in future versions).", "$", "this", "->", "EventArguments", "[", "'Path'", "]", "=", "Gdn", "::", "Request", "(", ")", "->", "Post", "(", "'Path'", ")", ";", "$", "this", "->", "FireEvent", "(", "'Tick'", ")", ";", "// Store the view, using denormalization if enabled", "$", "ViewType", "=", "'normal'", ";", "if", "(", "preg_match", "(", "'`discussion/embed`'", ",", "Gdn", "::", "Request", "(", ")", "->", "Post", "(", "'ResolvedPath'", ",", "''", ")", ")", ")", "$", "ViewType", "=", "'embed'", ";", "$", "this", "->", "AddView", "(", "$", "ViewType", ")", ";", "if", "(", "!", "self", "::", "CheckIsEnabled", "(", ")", ")", "return", ";", "if", "(", "Gdn", "::", "Session", "(", ")", "->", "CheckPermission", "(", "'Garden.Settings.Manage'", ")", ")", "{", "if", "(", "Gdn", "::", "Get", "(", "'Garden.Analytics.Notify'", ",", "FALSE", ")", "!==", "FALSE", ")", "{", "$", "CallMessage", "=", "Sprite", "(", "'Bandaid'", ",", "'InformSprite'", ")", ";", "$", "CallMessage", ".=", "sprintf", "(", "T", "(", "\"There's a problem with Vanilla Analytics that needs your attention.<br/> Handle it <a href=\\\"%s\\\">here &raquo;</a>\"", ")", ",", "Url", "(", "'dashboard/statistics'", ")", ")", ";", "Gdn", "::", "Controller", "(", ")", "->", "InformMessage", "(", "$", "CallMessage", ",", "array", "(", "'CssClass'", "=>", "'HasSprite'", ")", ")", ";", "}", "}", "$", "InstallationID", "=", "Gdn", "::", "InstallationID", "(", ")", ";", "// Check if we're registered with the central server already. If not, this request is ", "// hijacked and used to perform that task instead of sending stats or recording a tick.", "if", "(", "is_null", "(", "$", "InstallationID", ")", ")", "{", "// If the config file is not writable, gtfo", "$", "ConfFile", "=", "PATH_CONF", ".", "'/config.php'", ";", "if", "(", "!", "is_writable", "(", "$", "ConfFile", ")", ")", "{", "// Admins see a helpful notice", "if", "(", "Gdn", "::", "Session", "(", ")", "->", "CheckPermission", "(", "'Garden.Settings.Manage'", ")", ")", "{", "$", "Warning", "=", "Sprite", "(", "'Sliders'", ",", "'InformSprite'", ")", ";", "$", "Warning", ".=", "T", "(", "'Your config.php file is not writable.<br/> Find out <a href=\"http://vanillaforums.org/docs/vanillastatistics\">how to fix this &raquo;</a>'", ")", ";", "Gdn", "::", "Controller", "(", ")", "->", "InformMessage", "(", "$", "Warning", ",", "array", "(", "'CssClass'", "=>", "'HasSprite'", ")", ")", ";", "}", "return", ";", "}", "$", "AttemptedRegistration", "=", "Gdn", "::", "Get", "(", "'Garden.Analytics.Registering'", ",", "FALSE", ")", ";", "// If we last attempted to register less than 60 seconds ago, do nothing. Could still be working.", "if", "(", "$", "AttemptedRegistration", "!==", "FALSE", "&&", "(", "time", "(", ")", "-", "$", "AttemptedRegistration", ")", "<", "60", ")", "return", ";", "return", "$", "this", "->", "Register", "(", ")", ";", "}", "// If we get here, the installation is registered and we can decide on whether or not to send stats now.", "$", "LastSentDate", "=", "self", "::", "LastSentDate", "(", ")", ";", "if", "(", "empty", "(", "$", "LastSentDate", ")", "||", "$", "LastSentDate", "<", "date", "(", "'Ymd'", ",", "strtotime", "(", "'-1 day'", ")", ")", ")", "return", "$", "this", "->", "Stats", "(", ")", ";", "}" ]
This is the asynchronous callback This method is triggerd on every page request via a callback AJAX request so that it may execute asychronously and reduce lag for users. It tracks views, handles registration for new installations, and sends stats every day as needed. @return void;
[ "This", "is", "the", "asynchronous", "callback" ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.statistics.php#L591-L644
10,680
bishopb/vanilla
library/core/class.statistics.php
Gdn_Statistics.AddView
public function AddView($ViewType = 'normal') { // Add a pageview entry. $TimeSlot = date('Ymd'); $Px = Gdn::Database()->DatabasePrefix; $Views = 1; $EmbedViews = 0; try { if (C('Garden.Analytics.Views.Denormalize', FALSE) && Gdn::Cache()->ActiveEnabled()) { $CacheKey = "QueryCache.Analytics.CountViews"; // Increment. If not success, create key. $Incremented = Gdn::Cache()->Increment($CacheKey); if ($Incremented === Gdn_Cache::CACHEOP_FAILURE) Gdn::Cache()->Store($CacheKey, 1); // Get current cache value $Views = Gdn::Cache()->Get($CacheKey); if ($ViewType == 'embed') { $EmbedCacheKey = "QueryCache.Analytics.CountEmbedViews"; // Increment. If not success, create key. $EmbedIncremented = Gdn::Cache()->Increment($EmbedCacheKey); if ($EmbedIncremented === Gdn_Cache::CACHEOP_FAILURE) Gdn::Cache()->Store($EmbedCacheKey, 1); // Get current cache value $EmbedViews = Gdn::Cache()->Get($EmbedCacheKey); } // Every X views, writeback to AnalyticsLocal $DenormalizeWriteback = C('Garden.Analytics.Views.DenormalizeWriteback', 10); if (($Views % $DenormalizeWriteback) == 0) { Gdn::Controller()->SetData('WritebackViews', $Views); Gdn::Controller()->SetData('WritebackEmbed', $EmbedViews); Gdn::Database()->Query("insert into {$Px}AnalyticsLocal (TimeSlot, Views, EmbedViews) values (:TimeSlot, {$Views}, {$EmbedViews}) on duplicate key update Views = COALESCE(Views, 0)+{$Views}, EmbedViews = COALESCE(EmbedViews, 0)+{$EmbedViews}", array( ':TimeSlot' => $TimeSlot )); // ... and get rid of those views from the keys if ($Views) Gdn::Cache()->Decrement($CacheKey, $Views); if ($EmbedViews) Gdn::Cache()->Decrement($EmbedCacheKey, $EmbedViews); } } else { $ExtraViews = 1; $ExtraEmbedViews = ($ViewType == 'embed') ? 1 : 0; Gdn::Database()->Query("insert into {$Px}AnalyticsLocal (TimeSlot, Views, EmbedViews) values (:TimeSlot, {$ExtraViews}, {$ExtraEmbedViews}) on duplicate key update Views = COALESCE(Views, 0)+{$ExtraViews}, EmbedViews = COALESCE(EmbedViews, 0)+{$ExtraEmbedViews}", array( ':TimeSlot' => $TimeSlot )); } } catch (Exception $Ex) { if (Gdn::Session()->CheckPermission('Garden.Settings.Manage')) throw $Ex; } }
php
public function AddView($ViewType = 'normal') { // Add a pageview entry. $TimeSlot = date('Ymd'); $Px = Gdn::Database()->DatabasePrefix; $Views = 1; $EmbedViews = 0; try { if (C('Garden.Analytics.Views.Denormalize', FALSE) && Gdn::Cache()->ActiveEnabled()) { $CacheKey = "QueryCache.Analytics.CountViews"; // Increment. If not success, create key. $Incremented = Gdn::Cache()->Increment($CacheKey); if ($Incremented === Gdn_Cache::CACHEOP_FAILURE) Gdn::Cache()->Store($CacheKey, 1); // Get current cache value $Views = Gdn::Cache()->Get($CacheKey); if ($ViewType == 'embed') { $EmbedCacheKey = "QueryCache.Analytics.CountEmbedViews"; // Increment. If not success, create key. $EmbedIncremented = Gdn::Cache()->Increment($EmbedCacheKey); if ($EmbedIncremented === Gdn_Cache::CACHEOP_FAILURE) Gdn::Cache()->Store($EmbedCacheKey, 1); // Get current cache value $EmbedViews = Gdn::Cache()->Get($EmbedCacheKey); } // Every X views, writeback to AnalyticsLocal $DenormalizeWriteback = C('Garden.Analytics.Views.DenormalizeWriteback', 10); if (($Views % $DenormalizeWriteback) == 0) { Gdn::Controller()->SetData('WritebackViews', $Views); Gdn::Controller()->SetData('WritebackEmbed', $EmbedViews); Gdn::Database()->Query("insert into {$Px}AnalyticsLocal (TimeSlot, Views, EmbedViews) values (:TimeSlot, {$Views}, {$EmbedViews}) on duplicate key update Views = COALESCE(Views, 0)+{$Views}, EmbedViews = COALESCE(EmbedViews, 0)+{$EmbedViews}", array( ':TimeSlot' => $TimeSlot )); // ... and get rid of those views from the keys if ($Views) Gdn::Cache()->Decrement($CacheKey, $Views); if ($EmbedViews) Gdn::Cache()->Decrement($EmbedCacheKey, $EmbedViews); } } else { $ExtraViews = 1; $ExtraEmbedViews = ($ViewType == 'embed') ? 1 : 0; Gdn::Database()->Query("insert into {$Px}AnalyticsLocal (TimeSlot, Views, EmbedViews) values (:TimeSlot, {$ExtraViews}, {$ExtraEmbedViews}) on duplicate key update Views = COALESCE(Views, 0)+{$ExtraViews}, EmbedViews = COALESCE(EmbedViews, 0)+{$ExtraEmbedViews}", array( ':TimeSlot' => $TimeSlot )); } } catch (Exception $Ex) { if (Gdn::Session()->CheckPermission('Garden.Settings.Manage')) throw $Ex; } }
[ "public", "function", "AddView", "(", "$", "ViewType", "=", "'normal'", ")", "{", "// Add a pageview entry.", "$", "TimeSlot", "=", "date", "(", "'Ymd'", ")", ";", "$", "Px", "=", "Gdn", "::", "Database", "(", ")", "->", "DatabasePrefix", ";", "$", "Views", "=", "1", ";", "$", "EmbedViews", "=", "0", ";", "try", "{", "if", "(", "C", "(", "'Garden.Analytics.Views.Denormalize'", ",", "FALSE", ")", "&&", "Gdn", "::", "Cache", "(", ")", "->", "ActiveEnabled", "(", ")", ")", "{", "$", "CacheKey", "=", "\"QueryCache.Analytics.CountViews\"", ";", "// Increment. If not success, create key.", "$", "Incremented", "=", "Gdn", "::", "Cache", "(", ")", "->", "Increment", "(", "$", "CacheKey", ")", ";", "if", "(", "$", "Incremented", "===", "Gdn_Cache", "::", "CACHEOP_FAILURE", ")", "Gdn", "::", "Cache", "(", ")", "->", "Store", "(", "$", "CacheKey", ",", "1", ")", ";", "// Get current cache value", "$", "Views", "=", "Gdn", "::", "Cache", "(", ")", "->", "Get", "(", "$", "CacheKey", ")", ";", "if", "(", "$", "ViewType", "==", "'embed'", ")", "{", "$", "EmbedCacheKey", "=", "\"QueryCache.Analytics.CountEmbedViews\"", ";", "// Increment. If not success, create key.", "$", "EmbedIncremented", "=", "Gdn", "::", "Cache", "(", ")", "->", "Increment", "(", "$", "EmbedCacheKey", ")", ";", "if", "(", "$", "EmbedIncremented", "===", "Gdn_Cache", "::", "CACHEOP_FAILURE", ")", "Gdn", "::", "Cache", "(", ")", "->", "Store", "(", "$", "EmbedCacheKey", ",", "1", ")", ";", "// Get current cache value", "$", "EmbedViews", "=", "Gdn", "::", "Cache", "(", ")", "->", "Get", "(", "$", "EmbedCacheKey", ")", ";", "}", "// Every X views, writeback to AnalyticsLocal", "$", "DenormalizeWriteback", "=", "C", "(", "'Garden.Analytics.Views.DenormalizeWriteback'", ",", "10", ")", ";", "if", "(", "(", "$", "Views", "%", "$", "DenormalizeWriteback", ")", "==", "0", ")", "{", "Gdn", "::", "Controller", "(", ")", "->", "SetData", "(", "'WritebackViews'", ",", "$", "Views", ")", ";", "Gdn", "::", "Controller", "(", ")", "->", "SetData", "(", "'WritebackEmbed'", ",", "$", "EmbedViews", ")", ";", "Gdn", "::", "Database", "(", ")", "->", "Query", "(", "\"insert into {$Px}AnalyticsLocal (TimeSlot, Views, EmbedViews) values (:TimeSlot, {$Views}, {$EmbedViews})\n on duplicate key update \n Views = COALESCE(Views, 0)+{$Views}, \n EmbedViews = COALESCE(EmbedViews, 0)+{$EmbedViews}\"", ",", "array", "(", "':TimeSlot'", "=>", "$", "TimeSlot", ")", ")", ";", "// ... and get rid of those views from the keys", "if", "(", "$", "Views", ")", "Gdn", "::", "Cache", "(", ")", "->", "Decrement", "(", "$", "CacheKey", ",", "$", "Views", ")", ";", "if", "(", "$", "EmbedViews", ")", "Gdn", "::", "Cache", "(", ")", "->", "Decrement", "(", "$", "EmbedCacheKey", ",", "$", "EmbedViews", ")", ";", "}", "}", "else", "{", "$", "ExtraViews", "=", "1", ";", "$", "ExtraEmbedViews", "=", "(", "$", "ViewType", "==", "'embed'", ")", "?", "1", ":", "0", ";", "Gdn", "::", "Database", "(", ")", "->", "Query", "(", "\"insert into {$Px}AnalyticsLocal (TimeSlot, Views, EmbedViews) values (:TimeSlot, {$ExtraViews}, {$ExtraEmbedViews})\n on duplicate key update \n Views = COALESCE(Views, 0)+{$ExtraViews}, \n EmbedViews = COALESCE(EmbedViews, 0)+{$ExtraEmbedViews}\"", ",", "array", "(", "':TimeSlot'", "=>", "$", "TimeSlot", ")", ")", ";", "}", "}", "catch", "(", "Exception", "$", "Ex", ")", "{", "if", "(", "Gdn", "::", "Session", "(", ")", "->", "CheckPermission", "(", "'Garden.Settings.Manage'", ")", ")", "throw", "$", "Ex", ";", "}", "}" ]
Increments overall pageview view count @since 2.1a @access public
[ "Increments", "overall", "pageview", "view", "count" ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.statistics.php#L652-L722
10,681
adrenth/tvrage
lib/Adrenth/Tvrage/Response/Traits/DenormalizesDetailedShow.php
DenormalizesDetailedShow.denormalizeDetailedShow
final protected function denormalizeDetailedShow(array $data) { $detailedShow = new DetailedShow(); $referenceMap = [ 'showid' => 'setShowId', 'name' => 'setName', 'showname' => 'setName', 'link' => 'setLink', 'image' => 'setImage', 'showlink' => 'setLink', 'ended' => 'setEnded', 'country' => 'setCountry', 'origin_country' => 'setOriginCountry', 'seasons' => 'setSeasonCount', 'totalseasons' => 'setSeasonCount', 'status' => 'setStatus', 'runtime' => 'setRuntime', 'classification' => 'setClassification', 'airtime' => 'setAirtime', 'airday' => 'setAirday', 'timezone' => 'setTimeZone' ]; $complexMap = [ 'akas' => 'handleAkas', 'genres' => 'handleGenres', 'network' => 'handleNetwork', 'Episodelist' => 'handleEpisodeList', ]; $ignore = [ 'startdate' => null, 'started' => null, ]; foreach ($data as $attribute => $value) { if (array_key_exists($attribute, $referenceMap)) { $detailedShow->$referenceMap[$attribute]($value); } elseif (array_key_exists($attribute, $complexMap)) { $this->$complexMap[$attribute]($detailedShow, $value); } elseif (!array_key_exists($attribute, $ignore)) { throw new UnimplementedAttributeException(sprintf( 'Attribute %s is not implemented', $attribute )); } } return $detailedShow; }
php
final protected function denormalizeDetailedShow(array $data) { $detailedShow = new DetailedShow(); $referenceMap = [ 'showid' => 'setShowId', 'name' => 'setName', 'showname' => 'setName', 'link' => 'setLink', 'image' => 'setImage', 'showlink' => 'setLink', 'ended' => 'setEnded', 'country' => 'setCountry', 'origin_country' => 'setOriginCountry', 'seasons' => 'setSeasonCount', 'totalseasons' => 'setSeasonCount', 'status' => 'setStatus', 'runtime' => 'setRuntime', 'classification' => 'setClassification', 'airtime' => 'setAirtime', 'airday' => 'setAirday', 'timezone' => 'setTimeZone' ]; $complexMap = [ 'akas' => 'handleAkas', 'genres' => 'handleGenres', 'network' => 'handleNetwork', 'Episodelist' => 'handleEpisodeList', ]; $ignore = [ 'startdate' => null, 'started' => null, ]; foreach ($data as $attribute => $value) { if (array_key_exists($attribute, $referenceMap)) { $detailedShow->$referenceMap[$attribute]($value); } elseif (array_key_exists($attribute, $complexMap)) { $this->$complexMap[$attribute]($detailedShow, $value); } elseif (!array_key_exists($attribute, $ignore)) { throw new UnimplementedAttributeException(sprintf( 'Attribute %s is not implemented', $attribute )); } } return $detailedShow; }
[ "final", "protected", "function", "denormalizeDetailedShow", "(", "array", "$", "data", ")", "{", "$", "detailedShow", "=", "new", "DetailedShow", "(", ")", ";", "$", "referenceMap", "=", "[", "'showid'", "=>", "'setShowId'", ",", "'name'", "=>", "'setName'", ",", "'showname'", "=>", "'setName'", ",", "'link'", "=>", "'setLink'", ",", "'image'", "=>", "'setImage'", ",", "'showlink'", "=>", "'setLink'", ",", "'ended'", "=>", "'setEnded'", ",", "'country'", "=>", "'setCountry'", ",", "'origin_country'", "=>", "'setOriginCountry'", ",", "'seasons'", "=>", "'setSeasonCount'", ",", "'totalseasons'", "=>", "'setSeasonCount'", ",", "'status'", "=>", "'setStatus'", ",", "'runtime'", "=>", "'setRuntime'", ",", "'classification'", "=>", "'setClassification'", ",", "'airtime'", "=>", "'setAirtime'", ",", "'airday'", "=>", "'setAirday'", ",", "'timezone'", "=>", "'setTimeZone'", "]", ";", "$", "complexMap", "=", "[", "'akas'", "=>", "'handleAkas'", ",", "'genres'", "=>", "'handleGenres'", ",", "'network'", "=>", "'handleNetwork'", ",", "'Episodelist'", "=>", "'handleEpisodeList'", ",", "]", ";", "$", "ignore", "=", "[", "'startdate'", "=>", "null", ",", "'started'", "=>", "null", ",", "]", ";", "foreach", "(", "$", "data", "as", "$", "attribute", "=>", "$", "value", ")", "{", "if", "(", "array_key_exists", "(", "$", "attribute", ",", "$", "referenceMap", ")", ")", "{", "$", "detailedShow", "->", "$", "referenceMap", "[", "$", "attribute", "]", "(", "$", "value", ")", ";", "}", "elseif", "(", "array_key_exists", "(", "$", "attribute", ",", "$", "complexMap", ")", ")", "{", "$", "this", "->", "$", "complexMap", "[", "$", "attribute", "]", "(", "$", "detailedShow", ",", "$", "value", ")", ";", "}", "elseif", "(", "!", "array_key_exists", "(", "$", "attribute", ",", "$", "ignore", ")", ")", "{", "throw", "new", "UnimplementedAttributeException", "(", "sprintf", "(", "'Attribute %s is not implemented'", ",", "$", "attribute", ")", ")", ";", "}", "}", "return", "$", "detailedShow", ";", "}" ]
Denormalize Detailed Show @param array $data @return DetailedShow @throws UnimplementedAttributeException
[ "Denormalize", "Detailed", "Show" ]
291043219e95689f609323f476a25293a53453b0
https://github.com/adrenth/tvrage/blob/291043219e95689f609323f476a25293a53453b0/lib/Adrenth/Tvrage/Response/Traits/DenormalizesDetailedShow.php#L35-L85
10,682
adrenth/tvrage
lib/Adrenth/Tvrage/Response/Traits/DenormalizesDetailedShow.php
DenormalizesDetailedShow.handleAkas
protected function handleAkas(DetailedShow $show, array $akas) { if (!array_key_exists('aka', $akas)) { return; } if (is_string($akas['aka'])) { $akas['aka'] = [['#' => $akas['aka']]]; } foreach ($akas['aka'] as $attributes) { $aka = new Aka(); if (is_string($attributes)) { $aka->setTitle($attributes); $show->addAka($aka); continue; } if (array_key_exists('@attr', $attributes)) { $aka->setAttr($attributes['@attr']); } if (array_key_exists('@country', $attributes)) { $aka->setCountry($attributes['@country']); } if (array_key_exists('#', $attributes)) { $aka->setTitle($attributes['#']); } $show->addAka($aka); } }
php
protected function handleAkas(DetailedShow $show, array $akas) { if (!array_key_exists('aka', $akas)) { return; } if (is_string($akas['aka'])) { $akas['aka'] = [['#' => $akas['aka']]]; } foreach ($akas['aka'] as $attributes) { $aka = new Aka(); if (is_string($attributes)) { $aka->setTitle($attributes); $show->addAka($aka); continue; } if (array_key_exists('@attr', $attributes)) { $aka->setAttr($attributes['@attr']); } if (array_key_exists('@country', $attributes)) { $aka->setCountry($attributes['@country']); } if (array_key_exists('#', $attributes)) { $aka->setTitle($attributes['#']); } $show->addAka($aka); } }
[ "protected", "function", "handleAkas", "(", "DetailedShow", "$", "show", ",", "array", "$", "akas", ")", "{", "if", "(", "!", "array_key_exists", "(", "'aka'", ",", "$", "akas", ")", ")", "{", "return", ";", "}", "if", "(", "is_string", "(", "$", "akas", "[", "'aka'", "]", ")", ")", "{", "$", "akas", "[", "'aka'", "]", "=", "[", "[", "'#'", "=>", "$", "akas", "[", "'aka'", "]", "]", "]", ";", "}", "foreach", "(", "$", "akas", "[", "'aka'", "]", "as", "$", "attributes", ")", "{", "$", "aka", "=", "new", "Aka", "(", ")", ";", "if", "(", "is_string", "(", "$", "attributes", ")", ")", "{", "$", "aka", "->", "setTitle", "(", "$", "attributes", ")", ";", "$", "show", "->", "addAka", "(", "$", "aka", ")", ";", "continue", ";", "}", "if", "(", "array_key_exists", "(", "'@attr'", ",", "$", "attributes", ")", ")", "{", "$", "aka", "->", "setAttr", "(", "$", "attributes", "[", "'@attr'", "]", ")", ";", "}", "if", "(", "array_key_exists", "(", "'@country'", ",", "$", "attributes", ")", ")", "{", "$", "aka", "->", "setCountry", "(", "$", "attributes", "[", "'@country'", "]", ")", ";", "}", "if", "(", "array_key_exists", "(", "'#'", ",", "$", "attributes", ")", ")", "{", "$", "aka", "->", "setTitle", "(", "$", "attributes", "[", "'#'", "]", ")", ";", "}", "$", "show", "->", "addAka", "(", "$", "aka", ")", ";", "}", "}" ]
Handle A.K.A's @param DetailedShow $show @param array $akas @return void
[ "Handle", "A", ".", "K", ".", "A", "s" ]
291043219e95689f609323f476a25293a53453b0
https://github.com/adrenth/tvrage/blob/291043219e95689f609323f476a25293a53453b0/lib/Adrenth/Tvrage/Response/Traits/DenormalizesDetailedShow.php#L94-L125
10,683
phlexible/phlexible
src/Phlexible/Component/MediaType/Model/IconResolver.php
IconResolver.resolve
public function resolve(MediaType $mediaType, $requestedSize = null) { $icons = $mediaType->getIcons(); if (!count($icons)) { return null; } ksort($icons); if (isset($icons[$requestedSize])) { $icon = $icons[$requestedSize]; } else { $icon = null; foreach ($icons as $size => $dummyIcon) { if ($size > $requestedSize) { $icon = $dummyIcon; break; } } if (!$icon) { $icon = end($icons); //return null; } } return $this->locator->locate($icon, null, true); }
php
public function resolve(MediaType $mediaType, $requestedSize = null) { $icons = $mediaType->getIcons(); if (!count($icons)) { return null; } ksort($icons); if (isset($icons[$requestedSize])) { $icon = $icons[$requestedSize]; } else { $icon = null; foreach ($icons as $size => $dummyIcon) { if ($size > $requestedSize) { $icon = $dummyIcon; break; } } if (!$icon) { $icon = end($icons); //return null; } } return $this->locator->locate($icon, null, true); }
[ "public", "function", "resolve", "(", "MediaType", "$", "mediaType", ",", "$", "requestedSize", "=", "null", ")", "{", "$", "icons", "=", "$", "mediaType", "->", "getIcons", "(", ")", ";", "if", "(", "!", "count", "(", "$", "icons", ")", ")", "{", "return", "null", ";", "}", "ksort", "(", "$", "icons", ")", ";", "if", "(", "isset", "(", "$", "icons", "[", "$", "requestedSize", "]", ")", ")", "{", "$", "icon", "=", "$", "icons", "[", "$", "requestedSize", "]", ";", "}", "else", "{", "$", "icon", "=", "null", ";", "foreach", "(", "$", "icons", "as", "$", "size", "=>", "$", "dummyIcon", ")", "{", "if", "(", "$", "size", ">", "$", "requestedSize", ")", "{", "$", "icon", "=", "$", "dummyIcon", ";", "break", ";", "}", "}", "if", "(", "!", "$", "icon", ")", "{", "$", "icon", "=", "end", "(", "$", "icons", ")", ";", "//return null;", "}", "}", "return", "$", "this", "->", "locator", "->", "locate", "(", "$", "icon", ",", "null", ",", "true", ")", ";", "}" ]
Resolve icon. @param MediaType $mediaType @param int $requestedSize @return string
[ "Resolve", "icon", "." ]
132f24924c9bb0dbb6c1ea84db0a463f97fa3893
https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Component/MediaType/Model/IconResolver.php#L44-L69
10,684
indigophp/robo-doctrine
src/Task/Doctrine/loadOrmTasks.php
loadOrmTasks.ormClearCacheMetadata
public function ormClearCacheMetadata($opt = ['flush' => false]) { $validOpts = ['flush']; $command = new Command\ClearCache\MetadataCommand; $this->runDoctrineCommand($command, $opt, $validOpts); }
php
public function ormClearCacheMetadata($opt = ['flush' => false]) { $validOpts = ['flush']; $command = new Command\ClearCache\MetadataCommand; $this->runDoctrineCommand($command, $opt, $validOpts); }
[ "public", "function", "ormClearCacheMetadata", "(", "$", "opt", "=", "[", "'flush'", "=>", "false", "]", ")", "{", "$", "validOpts", "=", "[", "'flush'", "]", ";", "$", "command", "=", "new", "Command", "\\", "ClearCache", "\\", "MetadataCommand", ";", "$", "this", "->", "runDoctrineCommand", "(", "$", "command", ",", "$", "opt", ",", "$", "validOpts", ")", ";", "}" ]
Clear all metadata cache of the various cache drivers @param array $opt @option $flush If defined, cache entries will be flushed instead of deleted/invalidated
[ "Clear", "all", "metadata", "cache", "of", "the", "various", "cache", "drivers" ]
dc7660aba5fd1bf3c3ef945bb4603da91c85bd05
https://github.com/indigophp/robo-doctrine/blob/dc7660aba5fd1bf3c3ef945bb4603da91c85bd05/src/Task/Doctrine/loadOrmTasks.php#L31-L37
10,685
indigophp/robo-doctrine
src/Task/Doctrine/loadOrmTasks.php
loadOrmTasks.ormClearCacheResult
public function ormClearCacheResult($opt = ['flush' => false]) { $validOpts = ['flush']; $command = new Command\ClearCache\ResultCommand; $this->runDoctrineCommand($command, $opt, $validOpts); }
php
public function ormClearCacheResult($opt = ['flush' => false]) { $validOpts = ['flush']; $command = new Command\ClearCache\ResultCommand; $this->runDoctrineCommand($command, $opt, $validOpts); }
[ "public", "function", "ormClearCacheResult", "(", "$", "opt", "=", "[", "'flush'", "=>", "false", "]", ")", "{", "$", "validOpts", "=", "[", "'flush'", "]", ";", "$", "command", "=", "new", "Command", "\\", "ClearCache", "\\", "ResultCommand", ";", "$", "this", "->", "runDoctrineCommand", "(", "$", "command", ",", "$", "opt", ",", "$", "validOpts", ")", ";", "}" ]
Clear all result cache of the various cache drivers @param array $opt @option $flush If defined, cache entries will be flushed instead of deleted/invalidated
[ "Clear", "all", "result", "cache", "of", "the", "various", "cache", "drivers" ]
dc7660aba5fd1bf3c3ef945bb4603da91c85bd05
https://github.com/indigophp/robo-doctrine/blob/dc7660aba5fd1bf3c3ef945bb4603da91c85bd05/src/Task/Doctrine/loadOrmTasks.php#L46-L52
10,686
indigophp/robo-doctrine
src/Task/Doctrine/loadOrmTasks.php
loadOrmTasks.ormClearCacheQuery
public function ormClearCacheQuery($opt = ['flush' => false]) { $validOpts = ['flush']; $command = new Command\ClearCache\QueryCommand; $this->runDoctrineCommand($command, $opt, $validOpts); }
php
public function ormClearCacheQuery($opt = ['flush' => false]) { $validOpts = ['flush']; $command = new Command\ClearCache\QueryCommand; $this->runDoctrineCommand($command, $opt, $validOpts); }
[ "public", "function", "ormClearCacheQuery", "(", "$", "opt", "=", "[", "'flush'", "=>", "false", "]", ")", "{", "$", "validOpts", "=", "[", "'flush'", "]", ";", "$", "command", "=", "new", "Command", "\\", "ClearCache", "\\", "QueryCommand", ";", "$", "this", "->", "runDoctrineCommand", "(", "$", "command", ",", "$", "opt", ",", "$", "validOpts", ")", ";", "}" ]
Clear all query cache of the various cache drivers @param array $opt @option $flush If defined, cache entries will be flushed instead of deleted/invalidated
[ "Clear", "all", "query", "cache", "of", "the", "various", "cache", "drivers" ]
dc7660aba5fd1bf3c3ef945bb4603da91c85bd05
https://github.com/indigophp/robo-doctrine/blob/dc7660aba5fd1bf3c3ef945bb4603da91c85bd05/src/Task/Doctrine/loadOrmTasks.php#L61-L67
10,687
indigophp/robo-doctrine
src/Task/Doctrine/loadOrmTasks.php
loadOrmTasks.ormSchemaCreate
public function ormSchemaCreate($opt = ['dump-sql' => false]) { $validOpts = ['dump-sql']; $command = new Command\SchemaTool\CreateCommand; $this->runDoctrineCommand($command, $opt, $validOpts); }
php
public function ormSchemaCreate($opt = ['dump-sql' => false]) { $validOpts = ['dump-sql']; $command = new Command\SchemaTool\CreateCommand; $this->runDoctrineCommand($command, $opt, $validOpts); }
[ "public", "function", "ormSchemaCreate", "(", "$", "opt", "=", "[", "'dump-sql'", "=>", "false", "]", ")", "{", "$", "validOpts", "=", "[", "'dump-sql'", "]", ";", "$", "command", "=", "new", "Command", "\\", "SchemaTool", "\\", "CreateCommand", ";", "$", "this", "->", "runDoctrineCommand", "(", "$", "command", ",", "$", "opt", ",", "$", "validOpts", ")", ";", "}" ]
Processes the schema and either create it directly on EntityManager Storage Connection or generate the SQL output @param array $opt @option $dump-sql Instead of try to apply generated SQLs into EntityManager Storage Connection, output them
[ "Processes", "the", "schema", "and", "either", "create", "it", "directly", "on", "EntityManager", "Storage", "Connection", "or", "generate", "the", "SQL", "output" ]
dc7660aba5fd1bf3c3ef945bb4603da91c85bd05
https://github.com/indigophp/robo-doctrine/blob/dc7660aba5fd1bf3c3ef945bb4603da91c85bd05/src/Task/Doctrine/loadOrmTasks.php#L76-L82
10,688
indigophp/robo-doctrine
src/Task/Doctrine/loadOrmTasks.php
loadOrmTasks.ormSchemaDrop
public function ormSchemaDrop($opt = ['dump-sql' => false, 'force' => false, 'full-database' => false]) { $validOpts = ['dump-sql', 'force', 'full-database']; $command = new Command\SchemaTool\DropCommand; $this->runDoctrineCommand($command, $opt, $validOpts); }
php
public function ormSchemaDrop($opt = ['dump-sql' => false, 'force' => false, 'full-database' => false]) { $validOpts = ['dump-sql', 'force', 'full-database']; $command = new Command\SchemaTool\DropCommand; $this->runDoctrineCommand($command, $opt, $validOpts); }
[ "public", "function", "ormSchemaDrop", "(", "$", "opt", "=", "[", "'dump-sql'", "=>", "false", ",", "'force'", "=>", "false", ",", "'full-database'", "=>", "false", "]", ")", "{", "$", "validOpts", "=", "[", "'dump-sql'", ",", "'force'", ",", "'full-database'", "]", ";", "$", "command", "=", "new", "Command", "\\", "SchemaTool", "\\", "DropCommand", ";", "$", "this", "->", "runDoctrineCommand", "(", "$", "command", ",", "$", "opt", ",", "$", "validOpts", ")", ";", "}" ]
Drop the complete database schema of EntityManager Storage Connection or generate the corresponding SQL output @param array $opt @option $dump-sql Instead of try to apply generated SQLs into EntityManager Storage Connection, output them @option $force Don't ask for the deletion of the database, but force the operation to run @option $complete Instead of using the Class Metadata to detect the database table schema, drop ALL assets that the database contains
[ "Drop", "the", "complete", "database", "schema", "of", "EntityManager", "Storage", "Connection", "or", "generate", "the", "corresponding", "SQL", "output" ]
dc7660aba5fd1bf3c3ef945bb4603da91c85bd05
https://github.com/indigophp/robo-doctrine/blob/dc7660aba5fd1bf3c3ef945bb4603da91c85bd05/src/Task/Doctrine/loadOrmTasks.php#L110-L116
10,689
indigophp/robo-doctrine
src/Task/Doctrine/loadOrmTasks.php
loadOrmTasks.ormEnsureProductionSettings
public function ormEnsureProductionSettings($opt = ['complete' => false]) { $validOpts = ['complete']; $command = new Command\EnsureProductionSettingsCommand; $this->runDoctrineCommand($command, $opt, $validOpts); }
php
public function ormEnsureProductionSettings($opt = ['complete' => false]) { $validOpts = ['complete']; $command = new Command\EnsureProductionSettingsCommand; $this->runDoctrineCommand($command, $opt, $validOpts); }
[ "public", "function", "ormEnsureProductionSettings", "(", "$", "opt", "=", "[", "'complete'", "=>", "false", "]", ")", "{", "$", "validOpts", "=", "[", "'complete'", "]", ";", "$", "command", "=", "new", "Command", "\\", "EnsureProductionSettingsCommand", ";", "$", "this", "->", "runDoctrineCommand", "(", "$", "command", ",", "$", "opt", ",", "$", "validOpts", ")", ";", "}" ]
Verify that Doctrine is properly configured for a production environment @param array $opt @option $complete Flag to also inspect database connection existence
[ "Verify", "that", "Doctrine", "is", "properly", "configured", "for", "a", "production", "environment" ]
dc7660aba5fd1bf3c3ef945bb4603da91c85bd05
https://github.com/indigophp/robo-doctrine/blob/dc7660aba5fd1bf3c3ef945bb4603da91c85bd05/src/Task/Doctrine/loadOrmTasks.php#L125-L131
10,690
indigophp/robo-doctrine
src/Task/Doctrine/loadOrmTasks.php
loadOrmTasks.ormConvertD1Schema
public function ormConvertD1Schema( $fromPath, $toType, $destPath, $from, $to, $opt = ['extend' => null, 'num-spaces' => 4] ) { $validOpts = ['extend', 'num-spaces']; $command = new Command\ConvertDoctrine1SchemaCommand; $arg = [ 'from-path' => $fromPath, 'to-type' => $toType, 'dest-path' => $destPath, 'from' => $from, 'to' => $to, ]; $this->runDoctrineCommand($command, $opt, $validOpts, $arg); }
php
public function ormConvertD1Schema( $fromPath, $toType, $destPath, $from, $to, $opt = ['extend' => null, 'num-spaces' => 4] ) { $validOpts = ['extend', 'num-spaces']; $command = new Command\ConvertDoctrine1SchemaCommand; $arg = [ 'from-path' => $fromPath, 'to-type' => $toType, 'dest-path' => $destPath, 'from' => $from, 'to' => $to, ]; $this->runDoctrineCommand($command, $opt, $validOpts, $arg); }
[ "public", "function", "ormConvertD1Schema", "(", "$", "fromPath", ",", "$", "toType", ",", "$", "destPath", ",", "$", "from", ",", "$", "to", ",", "$", "opt", "=", "[", "'extend'", "=>", "null", ",", "'num-spaces'", "=>", "4", "]", ")", "{", "$", "validOpts", "=", "[", "'extend'", ",", "'num-spaces'", "]", ";", "$", "command", "=", "new", "Command", "\\", "ConvertDoctrine1SchemaCommand", ";", "$", "arg", "=", "[", "'from-path'", "=>", "$", "fromPath", ",", "'to-type'", "=>", "$", "toType", ",", "'dest-path'", "=>", "$", "destPath", ",", "'from'", "=>", "$", "from", ",", "'to'", "=>", "$", "to", ",", "]", ";", "$", "this", "->", "runDoctrineCommand", "(", "$", "command", ",", "$", "opt", ",", "$", "validOpts", ",", "$", "arg", ")", ";", "}" ]
Converts Doctrine 1.X schema into a Doctrine 2.X schema @param string $fromPath The path of Doctrine 1.X schema information @param string $toType The destination Doctrine 2.X mapping type @param string $destPath The path to generate your Doctrine 2.X mapping information @param array $from Optional paths of Doctrine 1.X schema information @param array $opt @option $extend Defines a base class to be extended by generated entity classes @option $num-spaces Defines the number of indentation spaces
[ "Converts", "Doctrine", "1", ".", "X", "schema", "into", "a", "Doctrine", "2", ".", "X", "schema" ]
dc7660aba5fd1bf3c3ef945bb4603da91c85bd05
https://github.com/indigophp/robo-doctrine/blob/dc7660aba5fd1bf3c3ef945bb4603da91c85bd05/src/Task/Doctrine/loadOrmTasks.php#L145-L165
10,691
indigophp/robo-doctrine
src/Task/Doctrine/loadOrmTasks.php
loadOrmTasks.ormGenerateRepositories
public function ormGenerateRepositories($destPath, $opt = ['filter' => null]) { $validOpts = ['filter']; $command = new Command\GenerateRepositoriesCommand; $arg = [ 'dest-path' => $destPath, ]; $this->runDoctrineCommand($command, $opt, $validOpts, $arg); }
php
public function ormGenerateRepositories($destPath, $opt = ['filter' => null]) { $validOpts = ['filter']; $command = new Command\GenerateRepositoriesCommand; $arg = [ 'dest-path' => $destPath, ]; $this->runDoctrineCommand($command, $opt, $validOpts, $arg); }
[ "public", "function", "ormGenerateRepositories", "(", "$", "destPath", ",", "$", "opt", "=", "[", "'filter'", "=>", "null", "]", ")", "{", "$", "validOpts", "=", "[", "'filter'", "]", ";", "$", "command", "=", "new", "Command", "\\", "GenerateRepositoriesCommand", ";", "$", "arg", "=", "[", "'dest-path'", "=>", "$", "destPath", ",", "]", ";", "$", "this", "->", "runDoctrineCommand", "(", "$", "command", ",", "$", "opt", ",", "$", "validOpts", ",", "$", "arg", ")", ";", "}" ]
Generate repository classes from your mapping information @param string $destPath The path to generate your repository classes @param array $opt @option $filter A string pattern used to match entities that should be processed
[ "Generate", "repository", "classes", "from", "your", "mapping", "information" ]
dc7660aba5fd1bf3c3ef945bb4603da91c85bd05
https://github.com/indigophp/robo-doctrine/blob/dc7660aba5fd1bf3c3ef945bb4603da91c85bd05/src/Task/Doctrine/loadOrmTasks.php#L175-L185
10,692
indigophp/robo-doctrine
src/Task/Doctrine/loadOrmTasks.php
loadOrmTasks.ormGenerateEntities
public function ormGenerateEntities( $destPath, $opt = [ 'filter' => null, 'generate-annotations' => false, 'generate-methods' => true, 'regenerate-entities' => false, 'update-entities' => true, 'extend' => false, 'num-spaces' => 4, ] ){ $validOpts = [ 'filter', 'generate-annotations', 'generate-methods', 'regenerate-entities', 'update-entities', 'extend', 'num-spaces', ]; $command = new Command\GenerateEntitiesCommand; $arg = [ 'dest-path' => $destPath, ]; $this->runDoctrineCommand($command, $opt, $validOpts, $arg); }
php
public function ormGenerateEntities( $destPath, $opt = [ 'filter' => null, 'generate-annotations' => false, 'generate-methods' => true, 'regenerate-entities' => false, 'update-entities' => true, 'extend' => false, 'num-spaces' => 4, ] ){ $validOpts = [ 'filter', 'generate-annotations', 'generate-methods', 'regenerate-entities', 'update-entities', 'extend', 'num-spaces', ]; $command = new Command\GenerateEntitiesCommand; $arg = [ 'dest-path' => $destPath, ]; $this->runDoctrineCommand($command, $opt, $validOpts, $arg); }
[ "public", "function", "ormGenerateEntities", "(", "$", "destPath", ",", "$", "opt", "=", "[", "'filter'", "=>", "null", ",", "'generate-annotations'", "=>", "false", ",", "'generate-methods'", "=>", "true", ",", "'regenerate-entities'", "=>", "false", ",", "'update-entities'", "=>", "true", ",", "'extend'", "=>", "false", ",", "'num-spaces'", "=>", "4", ",", "]", ")", "{", "$", "validOpts", "=", "[", "'filter'", ",", "'generate-annotations'", ",", "'generate-methods'", ",", "'regenerate-entities'", ",", "'update-entities'", ",", "'extend'", ",", "'num-spaces'", ",", "]", ";", "$", "command", "=", "new", "Command", "\\", "GenerateEntitiesCommand", ";", "$", "arg", "=", "[", "'dest-path'", "=>", "$", "destPath", ",", "]", ";", "$", "this", "->", "runDoctrineCommand", "(", "$", "command", ",", "$", "opt", ",", "$", "validOpts", ",", "$", "arg", ")", ";", "}" ]
Generate entity classes and method stubs from your mapping information @param string $destPath The path to generate your repository classes @param array $opt @option $filter A string pattern used to match entities that should be processed @option $generate-annotations Flag to define if generator should generate annotation metadata on entities @option $generate-methods Flag to define if generator should generate stub methods on entities @option $regenerate-entities Flag to define if generator should regenerate entity if it exists @option $update-entities Flag to define if generator should only update entity if it exists @option $extend Defines a base class to be extended by generated entity classes @option $num-spaces Defines the number of indentation spaces
[ "Generate", "entity", "classes", "and", "method", "stubs", "from", "your", "mapping", "information" ]
dc7660aba5fd1bf3c3ef945bb4603da91c85bd05
https://github.com/indigophp/robo-doctrine/blob/dc7660aba5fd1bf3c3ef945bb4603da91c85bd05/src/Task/Doctrine/loadOrmTasks.php#L201-L229
10,693
indigophp/robo-doctrine
src/Task/Doctrine/loadOrmTasks.php
loadOrmTasks.ormGenerateProxies
public function ormGenerateProxies($destPath = null, $opt = ['filter' => null]) { $validOpts = ['filter']; $command = new Command\GenerateProxiesCommand; $arg = [ 'dest-path' => $destPath, ]; $this->runDoctrineCommand($command, $opt, $validOpts, $arg); }
php
public function ormGenerateProxies($destPath = null, $opt = ['filter' => null]) { $validOpts = ['filter']; $command = new Command\GenerateProxiesCommand; $arg = [ 'dest-path' => $destPath, ]; $this->runDoctrineCommand($command, $opt, $validOpts, $arg); }
[ "public", "function", "ormGenerateProxies", "(", "$", "destPath", "=", "null", ",", "$", "opt", "=", "[", "'filter'", "=>", "null", "]", ")", "{", "$", "validOpts", "=", "[", "'filter'", "]", ";", "$", "command", "=", "new", "Command", "\\", "GenerateProxiesCommand", ";", "$", "arg", "=", "[", "'dest-path'", "=>", "$", "destPath", ",", "]", ";", "$", "this", "->", "runDoctrineCommand", "(", "$", "command", ",", "$", "opt", ",", "$", "validOpts", ",", "$", "arg", ")", ";", "}" ]
Generates proxy classes for entity classes @param string $destPath The path to generate your proxy classes. If none is provided, it will attempt to grab from configuration @param array $opt @option $filter A string pattern used to match entities that should be processed
[ "Generates", "proxy", "classes", "for", "entity", "classes" ]
dc7660aba5fd1bf3c3ef945bb4603da91c85bd05
https://github.com/indigophp/robo-doctrine/blob/dc7660aba5fd1bf3c3ef945bb4603da91c85bd05/src/Task/Doctrine/loadOrmTasks.php#L239-L249
10,694
indigophp/robo-doctrine
src/Task/Doctrine/loadOrmTasks.php
loadOrmTasks.ormConvertMapping
public function ormConvertMapping( $toType, $destPath, $opt = [ 'filter' => null, 'force' => null, 'from-database' => null, 'extend' => null, 'num-spaces' => 4, 'namespace' => null, ] ) { $validOpts = [ 'filter', 'force', 'from-database', 'extend', 'num-spaces', 'namespace', ]; $command = new Command\ConvertMappingCommand; $arg = [ 'to-type' => $toType, 'dest-path' => $destPath, ]; $this->runDoctrineCommand($command, $opt, $validOpts, $arg); }
php
public function ormConvertMapping( $toType, $destPath, $opt = [ 'filter' => null, 'force' => null, 'from-database' => null, 'extend' => null, 'num-spaces' => 4, 'namespace' => null, ] ) { $validOpts = [ 'filter', 'force', 'from-database', 'extend', 'num-spaces', 'namespace', ]; $command = new Command\ConvertMappingCommand; $arg = [ 'to-type' => $toType, 'dest-path' => $destPath, ]; $this->runDoctrineCommand($command, $opt, $validOpts, $arg); }
[ "public", "function", "ormConvertMapping", "(", "$", "toType", ",", "$", "destPath", ",", "$", "opt", "=", "[", "'filter'", "=>", "null", ",", "'force'", "=>", "null", ",", "'from-database'", "=>", "null", ",", "'extend'", "=>", "null", ",", "'num-spaces'", "=>", "4", ",", "'namespace'", "=>", "null", ",", "]", ")", "{", "$", "validOpts", "=", "[", "'filter'", ",", "'force'", ",", "'from-database'", ",", "'extend'", ",", "'num-spaces'", ",", "'namespace'", ",", "]", ";", "$", "command", "=", "new", "Command", "\\", "ConvertMappingCommand", ";", "$", "arg", "=", "[", "'to-type'", "=>", "$", "toType", ",", "'dest-path'", "=>", "$", "destPath", ",", "]", ";", "$", "this", "->", "runDoctrineCommand", "(", "$", "command", ",", "$", "opt", ",", "$", "validOpts", ",", "$", "arg", ")", ";", "}" ]
Convert mapping information between supported formats @param string $toType The mapping type to be converted @param string $destPath The path to generate your entities classes @param array $opt @option $filter A string pattern used to match entities that should be processed @option $force Force to overwrite existing mapping files @option $from-database Whether or not to convert mapping information from existing database @option $extend Defines a base class to be extended by generated entity classes @option $num-spaces Defines the number of indentation spaces @option $namespace Defines a namespace for the generated entity classes, if converted from database
[ "Convert", "mapping", "information", "between", "supported", "formats" ]
dc7660aba5fd1bf3c3ef945bb4603da91c85bd05
https://github.com/indigophp/robo-doctrine/blob/dc7660aba5fd1bf3c3ef945bb4603da91c85bd05/src/Task/Doctrine/loadOrmTasks.php#L265-L293
10,695
indigophp/robo-doctrine
src/Task/Doctrine/loadOrmTasks.php
loadOrmTasks.ormRunDql
public function ormRunDql( $dql, $opt = [ 'hydrate' => 'object', 'first-result' => null, 'max-result' => null, 'depth' => 7, ] ) { $validOpts = [ 'hydrate', 'first-result', 'max-result', 'depth', ]; $command = new Command\RunDqlCommand; $arg = [ 'dql' => $dql, ]; $this->runDoctrineCommand($command, $opt, $arg); }
php
public function ormRunDql( $dql, $opt = [ 'hydrate' => 'object', 'first-result' => null, 'max-result' => null, 'depth' => 7, ] ) { $validOpts = [ 'hydrate', 'first-result', 'max-result', 'depth', ]; $command = new Command\RunDqlCommand; $arg = [ 'dql' => $dql, ]; $this->runDoctrineCommand($command, $opt, $arg); }
[ "public", "function", "ormRunDql", "(", "$", "dql", ",", "$", "opt", "=", "[", "'hydrate'", "=>", "'object'", ",", "'first-result'", "=>", "null", ",", "'max-result'", "=>", "null", ",", "'depth'", "=>", "7", ",", "]", ")", "{", "$", "validOpts", "=", "[", "'hydrate'", ",", "'first-result'", ",", "'max-result'", ",", "'depth'", ",", "]", ";", "$", "command", "=", "new", "Command", "\\", "RunDqlCommand", ";", "$", "arg", "=", "[", "'dql'", "=>", "$", "dql", ",", "]", ";", "$", "this", "->", "runDoctrineCommand", "(", "$", "command", ",", "$", "opt", ",", "$", "arg", ")", ";", "}" ]
Executes arbitrary DQL directly from the command line @param string $dql The DQL to execute @param array $opt @option $hydrate Hydration mode of result set. Should be either: object, array, scalar or single-scalar @option $first-result The first result in the result set @option $max-result The maximum number of results in the result set @option $depth Dumping depth of Entity graph
[ "Executes", "arbitrary", "DQL", "directly", "from", "the", "command", "line" ]
dc7660aba5fd1bf3c3ef945bb4603da91c85bd05
https://github.com/indigophp/robo-doctrine/blob/dc7660aba5fd1bf3c3ef945bb4603da91c85bd05/src/Task/Doctrine/loadOrmTasks.php#L306-L328
10,696
indigophp/robo-doctrine
src/Task/Doctrine/loadOrmTasks.php
loadOrmTasks.runDoctrineCommand
protected function runDoctrineCommand(SymfonyCommand $command, array $opt = [], array $validOpts = [], array $arg = []) { $helperSet = $this->getEntityManagerHelperSet(); $command->setHelperSet($helperSet); $command = $this->taskSymfonyCommand($command); foreach ($opt as $key => $value) { if (!in_array($key, $validOpts)) { continue; } $command->opt($key, $value); } foreach ($arg as $key => $value) { $command->arg($key, $value); } $command->run(); }
php
protected function runDoctrineCommand(SymfonyCommand $command, array $opt = [], array $validOpts = [], array $arg = []) { $helperSet = $this->getEntityManagerHelperSet(); $command->setHelperSet($helperSet); $command = $this->taskSymfonyCommand($command); foreach ($opt as $key => $value) { if (!in_array($key, $validOpts)) { continue; } $command->opt($key, $value); } foreach ($arg as $key => $value) { $command->arg($key, $value); } $command->run(); }
[ "protected", "function", "runDoctrineCommand", "(", "SymfonyCommand", "$", "command", ",", "array", "$", "opt", "=", "[", "]", ",", "array", "$", "validOpts", "=", "[", "]", ",", "array", "$", "arg", "=", "[", "]", ")", "{", "$", "helperSet", "=", "$", "this", "->", "getEntityManagerHelperSet", "(", ")", ";", "$", "command", "->", "setHelperSet", "(", "$", "helperSet", ")", ";", "$", "command", "=", "$", "this", "->", "taskSymfonyCommand", "(", "$", "command", ")", ";", "foreach", "(", "$", "opt", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "!", "in_array", "(", "$", "key", ",", "$", "validOpts", ")", ")", "{", "continue", ";", "}", "$", "command", "->", "opt", "(", "$", "key", ",", "$", "value", ")", ";", "}", "foreach", "(", "$", "arg", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "command", "->", "arg", "(", "$", "key", ",", "$", "value", ")", ";", "}", "$", "command", "->", "run", "(", ")", ";", "}" ]
Adds options to a symfony command @param SymfonyCommand $command @param array $opt @param array $validOpts @param array $arg
[ "Adds", "options", "to", "a", "symfony", "command" ]
dc7660aba5fd1bf3c3ef945bb4603da91c85bd05
https://github.com/indigophp/robo-doctrine/blob/dc7660aba5fd1bf3c3ef945bb4603da91c85bd05/src/Task/Doctrine/loadOrmTasks.php#L358-L378
10,697
prastowoagungwidodo/mvc
src/Transformatika/MVC/RouteDispatcher.php
RouteDispatcher.setRedirectUrl
public function setRedirectUrl($options) { $this->redirectUrl = array( 404 => !isset($options[404]) ? '' : $options[404], 405 => !isset($options[405]) ? '' : $options[405] ); }
php
public function setRedirectUrl($options) { $this->redirectUrl = array( 404 => !isset($options[404]) ? '' : $options[404], 405 => !isset($options[405]) ? '' : $options[405] ); }
[ "public", "function", "setRedirectUrl", "(", "$", "options", ")", "{", "$", "this", "->", "redirectUrl", "=", "array", "(", "404", "=>", "!", "isset", "(", "$", "options", "[", "404", "]", ")", "?", "''", ":", "$", "options", "[", "404", "]", ",", "405", "=>", "!", "isset", "(", "$", "options", "[", "405", "]", ")", "?", "''", ":", "$", "options", "[", "405", "]", ")", ";", "}" ]
Ganti error page @param [type] $options [description]
[ "Ganti", "error", "page" ]
56ce9d4589e5951690388e0a115466750c148adb
https://github.com/prastowoagungwidodo/mvc/blob/56ce9d4589e5951690388e0a115466750c148adb/src/Transformatika/MVC/RouteDispatcher.php#L185-L191
10,698
AfterBug/afterbug-php
src/Config.php
Config.setUser
public function setUser(array $user) { $this->user = array_intersect_key( $user, array_flip($this->getUserAttributes()) ); return $this; }
php
public function setUser(array $user) { $this->user = array_intersect_key( $user, array_flip($this->getUserAttributes()) ); return $this; }
[ "public", "function", "setUser", "(", "array", "$", "user", ")", "{", "$", "this", "->", "user", "=", "array_intersect_key", "(", "$", "user", ",", "array_flip", "(", "$", "this", "->", "getUserAttributes", "(", ")", ")", ")", ";", "return", "$", "this", ";", "}" ]
Set user data. @param array $user @return $this
[ "Set", "user", "data", "." ]
3eba5ed782a5922b09170c0ae29679afea6839d8
https://github.com/AfterBug/afterbug-php/blob/3eba5ed782a5922b09170c0ae29679afea6839d8/src/Config.php#L133-L141
10,699
samsonos/cms_app_materialtable
src/App.php
App.getMaxPriority
public function getMaxPriority($materialId, $structureId) { // Get all table materials identifiers from current form material $tableMaterialIds = dbQuery('material') ->cond('parent_id', $materialId) ->cond('type', 3) ->cond('Active', 1) ->cond('Draft', 0) ->join('structurematerial') ->cond('structurematerial.StructureID', $structureId) ->fields('MaterialID'); $material = null; if ( dbQuery('material') ->cond('MaterialID', $tableMaterialIds) ->cond('Active', 1) ->order_by('priority', 'DESC') ->join('materialfield') ->first($material) ) { return $material->priority; } return 0; }
php
public function getMaxPriority($materialId, $structureId) { // Get all table materials identifiers from current form material $tableMaterialIds = dbQuery('material') ->cond('parent_id', $materialId) ->cond('type', 3) ->cond('Active', 1) ->cond('Draft', 0) ->join('structurematerial') ->cond('structurematerial.StructureID', $structureId) ->fields('MaterialID'); $material = null; if ( dbQuery('material') ->cond('MaterialID', $tableMaterialIds) ->cond('Active', 1) ->order_by('priority', 'DESC') ->join('materialfield') ->first($material) ) { return $material->priority; } return 0; }
[ "public", "function", "getMaxPriority", "(", "$", "materialId", ",", "$", "structureId", ")", "{", "// Get all table materials identifiers from current form material", "$", "tableMaterialIds", "=", "dbQuery", "(", "'material'", ")", "->", "cond", "(", "'parent_id'", ",", "$", "materialId", ")", "->", "cond", "(", "'type'", ",", "3", ")", "->", "cond", "(", "'Active'", ",", "1", ")", "->", "cond", "(", "'Draft'", ",", "0", ")", "->", "join", "(", "'structurematerial'", ")", "->", "cond", "(", "'structurematerial.StructureID'", ",", "$", "structureId", ")", "->", "fields", "(", "'MaterialID'", ")", ";", "$", "material", "=", "null", ";", "if", "(", "dbQuery", "(", "'material'", ")", "->", "cond", "(", "'MaterialID'", ",", "$", "tableMaterialIds", ")", "->", "cond", "(", "'Active'", ",", "1", ")", "->", "order_by", "(", "'priority'", ",", "'DESC'", ")", "->", "join", "(", "'materialfield'", ")", "->", "first", "(", "$", "material", ")", ")", "{", "return", "$", "material", "->", "priority", ";", "}", "return", "0", ";", "}" ]
Get max priority by current structure @param $materialId @param $structureId @return int
[ "Get", "max", "priority", "by", "current", "structure" ]
550fb1916070b6cf8cbd4fa7d61a19ca9a2d090e
https://github.com/samsonos/cms_app_materialtable/blob/550fb1916070b6cf8cbd4fa7d61a19ca9a2d090e/src/App.php#L69-L94