repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
neos/flow-development-collection
Neos.Eel/Classes/Helper/ArrayHelper.php
ArrayHelper.push
public function push(array $array, $element): array { $elements = func_get_args(); array_shift($elements); foreach ($elements as $element) { array_push($array, $element); } return $array; }
php
public function push(array $array, $element): array { $elements = func_get_args(); array_shift($elements); foreach ($elements as $element) { array_push($array, $element); } return $array; }
[ "public", "function", "push", "(", "array", "$", "array", ",", "$", "element", ")", ":", "array", "{", "$", "elements", "=", "func_get_args", "(", ")", ";", "array_shift", "(", "$", "elements", ")", ";", "foreach", "(", "$", "elements", "as", "$", "e...
Insert one or more elements at the end of an array Allows to push multiple elements at once:: Array.push(array, e1, e2) @param array $array @param mixed $element @return array The array with the inserted elements
[ "Insert", "one", "or", "more", "elements", "at", "the", "end", "of", "an", "array" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Eel/Classes/Helper/ArrayHelper.php#L271-L279
neos/flow-development-collection
Neos.Eel/Classes/Helper/ArrayHelper.php
ArrayHelper.unshift
public function unshift(array $array, $element): array { // get all elements that are supposed to be added $elements = func_get_args(); array_shift($elements); foreach ($elements as $element) { array_unshift($array, $element); } return $array; }
php
public function unshift(array $array, $element): array { // get all elements that are supposed to be added $elements = func_get_args(); array_shift($elements); foreach ($elements as $element) { array_unshift($array, $element); } return $array; }
[ "public", "function", "unshift", "(", "array", "$", "array", ",", "$", "element", ")", ":", "array", "{", "// get all elements that are supposed to be added", "$", "elements", "=", "func_get_args", "(", ")", ";", "array_shift", "(", "$", "elements", ")", ";", ...
Insert one or more elements at the beginning of an array Allows to insert multiple elements at once:: Array.unshift(array, e1, e2) @param array $array @param mixed $element @return array The array with the inserted elements
[ "Insert", "one", "or", "more", "elements", "at", "the", "beginning", "of", "an", "array" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Eel/Classes/Helper/ArrayHelper.php#L308-L317
neos/flow-development-collection
Neos.Eel/Classes/Helper/ArrayHelper.php
ArrayHelper.splice
public function splice(array $array, $offset, $length = 1, $replacements = null): array { $arguments = func_get_args(); $replacements = array_slice($arguments, 3); array_splice($array, $offset, $length, $replacements); return $array; }
php
public function splice(array $array, $offset, $length = 1, $replacements = null): array { $arguments = func_get_args(); $replacements = array_slice($arguments, 3); array_splice($array, $offset, $length, $replacements); return $array; }
[ "public", "function", "splice", "(", "array", "$", "array", ",", "$", "offset", ",", "$", "length", "=", "1", ",", "$", "replacements", "=", "null", ")", ":", "array", "{", "$", "arguments", "=", "func_get_args", "(", ")", ";", "$", "replacements", "...
Replaces a range of an array by the given replacements Allows to give multiple replacements at once:: Array.splice(array, 3, 2, 'a', 'b') @param array $array @param int $offset Index of the first element to remove @param int $length Number of elements to remove @param mixed $replacements Elements to insert instead of the removed range @return array The array with removed and replaced elements
[ "Replaces", "a", "range", "of", "an", "array", "by", "the", "given", "replacements" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Eel/Classes/Helper/ArrayHelper.php#L332-L338
neos/flow-development-collection
Neos.Eel/Classes/Helper/ArrayHelper.php
ArrayHelper.map
public function map(array $array, callable $callback): array { $result = []; foreach ($array as $key => $element) { $result[$key] = $callback($element, $key); } return $result; }
php
public function map(array $array, callable $callback): array { $result = []; foreach ($array as $key => $element) { $result[$key] = $callback($element, $key); } return $result; }
[ "public", "function", "map", "(", "array", "$", "array", ",", "callable", "$", "callback", ")", ":", "array", "{", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "array", "as", "$", "key", "=>", "$", "element", ")", "{", "$", "result", "...
Apply the callback to each element of the array, passing each element and key as arguments Examples:: Array.map([1, 2, 3, 4], x => x * x) Array.map([1, 2, 3, 4], (x, index) => x * index) @param array $array Array of elements to map @param callable $callback Callback to apply for each element, current value and key will be passed as arguments @return array The array with callback applied, keys will be preserved
[ "Apply", "the", "callback", "to", "each", "element", "of", "the", "array", "passing", "each", "element", "and", "key", "as", "arguments" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Eel/Classes/Helper/ArrayHelper.php#L396-L403
neos/flow-development-collection
Neos.Eel/Classes/Helper/ArrayHelper.php
ArrayHelper.reduce
public function reduce(array $array, callable $callback, $initialValue = null) { if ($initialValue !== null) { $accumulator = $initialValue; } else { $accumulator = array_shift($array); } foreach ($array as $key => $element) { $accumulator = $callback($accumulator, $element, $key); } return $accumulator; }
php
public function reduce(array $array, callable $callback, $initialValue = null) { if ($initialValue !== null) { $accumulator = $initialValue; } else { $accumulator = array_shift($array); } foreach ($array as $key => $element) { $accumulator = $callback($accumulator, $element, $key); } return $accumulator; }
[ "public", "function", "reduce", "(", "array", "$", "array", ",", "callable", "$", "callback", ",", "$", "initialValue", "=", "null", ")", "{", "if", "(", "$", "initialValue", "!==", "null", ")", "{", "$", "accumulator", "=", "$", "initialValue", ";", "...
Apply the callback to each element of the array and accumulate a single value Examples:: Array.reduce([1, 2, 3, 4], (accumulator, currentValue) => accumulator + currentValue) // == 10 Array.reduce([1, 2, 3, 4], (accumulator, currentValue) => accumulator + currentValue, 1) // == 11 @param array $array Array of elements to reduce to a value @param callable $callback Callback for accumulating values, accumulator, current value and key will be passed as arguments @param mixed $initialValue Initial value, defaults to first item in array and callback starts with second entry @return mixed
[ "Apply", "the", "callback", "to", "each", "element", "of", "the", "array", "and", "accumulate", "a", "single", "value" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Eel/Classes/Helper/ArrayHelper.php#L418-L429
neos/flow-development-collection
Neos.Eel/Classes/Helper/ArrayHelper.php
ArrayHelper.some
public function some(array $array, callable $callback): bool { foreach ($array as $key => $value) { if ($callback($value, $key)) { return true; } } return false; }
php
public function some(array $array, callable $callback): bool { foreach ($array as $key => $value) { if ($callback($value, $key)) { return true; } } return false; }
[ "public", "function", "some", "(", "array", "$", "array", ",", "callable", "$", "callback", ")", ":", "bool", "{", "foreach", "(", "$", "array", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "$", "callback", "(", "$", "value", ",", "...
Check if at least one element in an array passes a test given by the calback, passing each element and key as arguments Example:: Array.some([1, 2, 3, 4], x => x % 2 == 0) // == true Array.some([1, 2, 3, 4], x => x > 4) // == false @param array $array Array of elements to test @param callable $callback Callback for testing elements, current value and key will be passed as arguments @return bool True if at least one element passed the test
[ "Check", "if", "at", "least", "one", "element", "in", "an", "array", "passes", "a", "test", "given", "by", "the", "calback", "passing", "each", "element", "and", "key", "as", "arguments" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Eel/Classes/Helper/ArrayHelper.php#L461-L469
neos/flow-development-collection
Neos.Eel/Classes/Helper/ArrayHelper.php
ArrayHelper.every
public function every(array $array, callable $callback): bool { foreach ($array as $key => $value) { if (!$callback($value, $key)) { return false; } } return true; }
php
public function every(array $array, callable $callback): bool { foreach ($array as $key => $value) { if (!$callback($value, $key)) { return false; } } return true; }
[ "public", "function", "every", "(", "array", "$", "array", ",", "callable", "$", "callback", ")", ":", "bool", "{", "foreach", "(", "$", "array", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "!", "$", "callback", "(", "$", "value", ...
Check if all elements in an array pass a test given by the calback, passing each element and key as arguments Example:: Array.every([1, 2, 3, 4], x => x % 2 == 0) // == false Array.every([2, 4, 6, 8], x => x % 2) // == true @param array $array Array of elements to test @param callable $callback Callback for testing elements, current value and key will be passed as arguments @return bool True if all elements passed the test
[ "Check", "if", "all", "elements", "in", "an", "array", "pass", "a", "test", "given", "by", "the", "calback", "passing", "each", "element", "and", "key", "as", "arguments" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Eel/Classes/Helper/ArrayHelper.php#L484-L492
neos/flow-development-collection
Neos.FluidAdaptor/Classes/Service/XsdGenerator.php
XsdGenerator.generateXsd
public function generateXsd($viewHelperNamespace, $xsdNamespace) { if (substr($viewHelperNamespace, -1) !== '\\') { $viewHelperNamespace .= '\\'; } $classNames = $this->getClassNamesInNamespace($viewHelperNamespace); if (count($classNames) === 0) { throw new Exception(sprintf('No ViewHelpers found in namespace "%s"', $viewHelperNamespace), 1330029328); } $xmlRootNode = new \SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="' . $xsdNamespace . '"></xsd:schema>'); foreach ($classNames as $className) { $this->generateXmlForClassName($className, $viewHelperNamespace, $xmlRootNode); } return $xmlRootNode->asXML(); }
php
public function generateXsd($viewHelperNamespace, $xsdNamespace) { if (substr($viewHelperNamespace, -1) !== '\\') { $viewHelperNamespace .= '\\'; } $classNames = $this->getClassNamesInNamespace($viewHelperNamespace); if (count($classNames) === 0) { throw new Exception(sprintf('No ViewHelpers found in namespace "%s"', $viewHelperNamespace), 1330029328); } $xmlRootNode = new \SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="' . $xsdNamespace . '"></xsd:schema>'); foreach ($classNames as $className) { $this->generateXmlForClassName($className, $viewHelperNamespace, $xmlRootNode); } return $xmlRootNode->asXML(); }
[ "public", "function", "generateXsd", "(", "$", "viewHelperNamespace", ",", "$", "xsdNamespace", ")", "{", "if", "(", "substr", "(", "$", "viewHelperNamespace", ",", "-", "1", ")", "!==", "'\\\\'", ")", "{", "$", "viewHelperNamespace", ".=", "'\\\\'", ";", ...
Generate the XML Schema definition for a given namespace. It will generate an XSD file for all view helpers in this namespace. @param string $viewHelperNamespace Namespace identifier to generate the XSD for, without leading Backslash. @param string $xsdNamespace $xsdNamespace unique target namespace used in the XSD schema (for example "http://yourdomain.org/ns/viewhelpers") @return string XML Schema definition @throws Exception
[ "Generate", "the", "XML", "Schema", "definition", "for", "a", "given", "namespace", ".", "It", "will", "generate", "an", "XSD", "file", "for", "all", "view", "helpers", "in", "this", "namespace", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.FluidAdaptor/Classes/Service/XsdGenerator.php#L39-L58
neos/flow-development-collection
Neos.FluidAdaptor/Classes/Service/XsdGenerator.php
XsdGenerator.generateXmlForClassName
protected function generateXmlForClassName($className, $viewHelperNamespace, \SimpleXMLElement $xmlRootNode) { $reflectionClass = new ClassReflection($className); if (!$reflectionClass->isSubclassOf($this->abstractViewHelperReflectionClass)) { return; } $tagName = $this->getTagNameForClass($className, $viewHelperNamespace); $xsdElement = $xmlRootNode->addChild('xsd:element'); $xsdElement['name'] = $tagName; $this->docCommentParser->parseDocComment($reflectionClass->getDocComment()); $this->addDocumentation($this->docCommentParser->getDescription(), $xsdElement); $xsdComplexType = $xsdElement->addChild('xsd:complexType'); $xsdComplexType['mixed'] = 'true'; $xsdSequence = $xsdComplexType->addChild('xsd:sequence'); $xsdAny = $xsdSequence->addChild('xsd:any'); $xsdAny['minOccurs'] = '0'; $xsdAny['maxOccurs'] = 'unbounded'; $this->addAttributes($className, $xsdComplexType); }
php
protected function generateXmlForClassName($className, $viewHelperNamespace, \SimpleXMLElement $xmlRootNode) { $reflectionClass = new ClassReflection($className); if (!$reflectionClass->isSubclassOf($this->abstractViewHelperReflectionClass)) { return; } $tagName = $this->getTagNameForClass($className, $viewHelperNamespace); $xsdElement = $xmlRootNode->addChild('xsd:element'); $xsdElement['name'] = $tagName; $this->docCommentParser->parseDocComment($reflectionClass->getDocComment()); $this->addDocumentation($this->docCommentParser->getDescription(), $xsdElement); $xsdComplexType = $xsdElement->addChild('xsd:complexType'); $xsdComplexType['mixed'] = 'true'; $xsdSequence = $xsdComplexType->addChild('xsd:sequence'); $xsdAny = $xsdSequence->addChild('xsd:any'); $xsdAny['minOccurs'] = '0'; $xsdAny['maxOccurs'] = 'unbounded'; $this->addAttributes($className, $xsdComplexType); }
[ "protected", "function", "generateXmlForClassName", "(", "$", "className", ",", "$", "viewHelperNamespace", ",", "\\", "SimpleXMLElement", "$", "xmlRootNode", ")", "{", "$", "reflectionClass", "=", "new", "ClassReflection", "(", "$", "className", ")", ";", "if", ...
Generate the XML Schema for a given class name. @param string $className Class name to generate the schema for. @param string $viewHelperNamespace Namespace prefix. Used to split off the first parts of the class name. @param \SimpleXMLElement $xmlRootNode XML root node where the xsd:element is appended. @return void
[ "Generate", "the", "XML", "Schema", "for", "a", "given", "class", "name", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.FluidAdaptor/Classes/Service/XsdGenerator.php#L68-L90
neos/flow-development-collection
Neos.Flow/Classes/Persistence/Aspect/PersistenceMagicAspect.php
PersistenceMagicAspect.generateUuid
public function generateUuid(JoinPointInterface $joinPoint) { /** @var $proxy PersistenceMagicInterface */ $proxy = $joinPoint->getProxy(); ObjectAccess::setProperty($proxy, 'Persistence_Object_Identifier', Algorithms::generateUUID(), true); $this->persistenceManager->registerNewObject($proxy); }
php
public function generateUuid(JoinPointInterface $joinPoint) { /** @var $proxy PersistenceMagicInterface */ $proxy = $joinPoint->getProxy(); ObjectAccess::setProperty($proxy, 'Persistence_Object_Identifier', Algorithms::generateUUID(), true); $this->persistenceManager->registerNewObject($proxy); }
[ "public", "function", "generateUuid", "(", "JoinPointInterface", "$", "joinPoint", ")", "{", "/** @var $proxy PersistenceMagicInterface */", "$", "proxy", "=", "$", "joinPoint", "->", "getProxy", "(", ")", ";", "ObjectAccess", "::", "setProperty", "(", "$", "proxy",...
After returning advice, making sure we have an UUID for each and every entity. @param JoinPointInterface $joinPoint The current join point @return void @Flow\Before("Neos\Flow\Persistence\Aspect\PersistenceMagicAspect->isEntity && method(.*->(__construct|__clone)()) && filter(Neos\Flow\Persistence\Doctrine\Mapping\Driver\FlowAnnotationDriver)")
[ "After", "returning", "advice", "making", "sure", "we", "have", "an", "UUID", "for", "each", "and", "every", "entity", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Persistence/Aspect/PersistenceMagicAspect.php#L96-L102
neos/flow-development-collection
Neos.Flow/Classes/Persistence/Aspect/PersistenceMagicAspect.php
PersistenceMagicAspect.generateValueHash
public function generateValueHash(JoinPointInterface $joinPoint) { $proxy = $joinPoint->getProxy(); $proxyClassName = get_class($proxy); $hashSourceParts = []; $classSchema = $this->reflectionService->getClassSchema($proxyClassName); foreach ($classSchema->getProperties() as $property => $propertySchema) { // Currently, private properties are transient. Should this behaviour change, they need to be included // in the value hash generation if ($classSchema->isPropertyTransient($property) || $this->reflectionService->isPropertyPrivate($proxyClassName, $property)) { continue; } $propertyValue = ObjectAccess::getProperty($proxy, $property, true); if (is_object($propertyValue) === true) { // The persistence manager will return NULL if the given object is unknown to persistence $propertyValue = ($this->persistenceManager->getIdentifierByObject($propertyValue)) ?: $propertyValue; } $hashSourceParts[$property] = $propertyValue; } ksort($hashSourceParts); $hashSourceParts['__class_name__'] = $proxyClassName; $serializedSource = ($this->useIgBinary === true) ? igbinary_serialize($hashSourceParts) : serialize($hashSourceParts); $proxy = $joinPoint->getProxy(); ObjectAccess::setProperty($proxy, 'Persistence_Object_Identifier', sha1($serializedSource), true); }
php
public function generateValueHash(JoinPointInterface $joinPoint) { $proxy = $joinPoint->getProxy(); $proxyClassName = get_class($proxy); $hashSourceParts = []; $classSchema = $this->reflectionService->getClassSchema($proxyClassName); foreach ($classSchema->getProperties() as $property => $propertySchema) { // Currently, private properties are transient. Should this behaviour change, they need to be included // in the value hash generation if ($classSchema->isPropertyTransient($property) || $this->reflectionService->isPropertyPrivate($proxyClassName, $property)) { continue; } $propertyValue = ObjectAccess::getProperty($proxy, $property, true); if (is_object($propertyValue) === true) { // The persistence manager will return NULL if the given object is unknown to persistence $propertyValue = ($this->persistenceManager->getIdentifierByObject($propertyValue)) ?: $propertyValue; } $hashSourceParts[$property] = $propertyValue; } ksort($hashSourceParts); $hashSourceParts['__class_name__'] = $proxyClassName; $serializedSource = ($this->useIgBinary === true) ? igbinary_serialize($hashSourceParts) : serialize($hashSourceParts); $proxy = $joinPoint->getProxy(); ObjectAccess::setProperty($proxy, 'Persistence_Object_Identifier', sha1($serializedSource), true); }
[ "public", "function", "generateValueHash", "(", "JoinPointInterface", "$", "joinPoint", ")", "{", "$", "proxy", "=", "$", "joinPoint", "->", "getProxy", "(", ")", ";", "$", "proxyClassName", "=", "get_class", "(", "$", "proxy", ")", ";", "$", "hashSourcePart...
After returning advice, generates the value hash for the object @param JoinPointInterface $joinPoint The current join point @return void @Flow\After("Neos\Flow\Persistence\Aspect\PersistenceMagicAspect->isNonEmbeddedValueObject && method(.*->__construct()) && filter(Neos\Flow\Persistence\Doctrine\Mapping\Driver\FlowAnnotationDriver)")
[ "After", "returning", "advice", "generates", "the", "value", "hash", "for", "the", "object" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Persistence/Aspect/PersistenceMagicAspect.php#L111-L143
neos/flow-development-collection
Neos.Flow/Classes/I18n/Cldr/Reader/PluralsReader.php
PluralsReader.initializeObject
public function initializeObject() { if ($this->cache->has('rulesets') && $this->cache->has('rulesetsIndices')) { $this->rulesets = $this->cache->get('rulesets'); $this->rulesetsIndices = $this->cache->get('rulesetsIndices'); } else { $this->generateRulesets(); $this->cache->set('rulesets', $this->rulesets); $this->cache->set('rulesetsIndices', $this->rulesetsIndices); } }
php
public function initializeObject() { if ($this->cache->has('rulesets') && $this->cache->has('rulesetsIndices')) { $this->rulesets = $this->cache->get('rulesets'); $this->rulesetsIndices = $this->cache->get('rulesetsIndices'); } else { $this->generateRulesets(); $this->cache->set('rulesets', $this->rulesets); $this->cache->set('rulesetsIndices', $this->rulesetsIndices); } }
[ "public", "function", "initializeObject", "(", ")", "{", "if", "(", "$", "this", "->", "cache", "->", "has", "(", "'rulesets'", ")", "&&", "$", "this", "->", "cache", "->", "has", "(", "'rulesetsIndices'", ")", ")", "{", "$", "this", "->", "rulesets", ...
Constructs the reader, loading parsed data from cache if available. @return void
[ "Constructs", "the", "reader", "loading", "parsed", "data", "from", "cache", "if", "available", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/I18n/Cldr/Reader/PluralsReader.php#L124-L134
neos/flow-development-collection
Neos.Flow/Classes/I18n/Cldr/Reader/PluralsReader.php
PluralsReader.getPluralForm
public function getPluralForm($quantity, Locale $locale) { if (!isset($this->rulesetsIndices[$locale->getLanguage()])) { return self::RULE_OTHER; } $ruleset = $this->rulesets[$locale->getLanguage()][$this->rulesetsIndices[$locale->getLanguage()]] ?? null; if ($ruleset === null) { return self::RULE_OTHER; } foreach ($ruleset as $form => $rule) { foreach ($rule as $subrule) { $subrulePassed = false; $processedQuantity = $quantity; if ($subrule['modulo'] !== false) { $processedQuantity = fmod($processedQuantity, $subrule['modulo']); } if ($processedQuantity == floor($processedQuantity)) { $processedQuantity = (int)$processedQuantity; } $condition = $subrule['condition']; switch ($condition[0]) { case 'is': case 'isnot': if (is_int($processedQuantity) && $processedQuantity === $condition[1]) { $subrulePassed = true; } if ($condition[0] === 'isnot') { $subrulePassed = !$subrulePassed; } break; case 'in': case 'notin': if (is_int($processedQuantity) && $processedQuantity >= $condition[1] && $processedQuantity <= $condition[2]) { $subrulePassed = true; } if ($condition[0] === 'notin') { $subrulePassed = !$subrulePassed; } break; case 'within': case 'notwithin': if ($processedQuantity >= $condition[1] && $processedQuantity <= $condition[2]) { $subrulePassed = true; } if ($condition[0] === 'notwithin') { $subrulePassed = !$subrulePassed; } break; } if (($subrulePassed && $subrule['logicalOperator'] === 'or') || (!$subrulePassed && $subrule['logicalOperator'] === 'and')) { break; } } if ($subrulePassed) { return $form; } } return self::RULE_OTHER; }
php
public function getPluralForm($quantity, Locale $locale) { if (!isset($this->rulesetsIndices[$locale->getLanguage()])) { return self::RULE_OTHER; } $ruleset = $this->rulesets[$locale->getLanguage()][$this->rulesetsIndices[$locale->getLanguage()]] ?? null; if ($ruleset === null) { return self::RULE_OTHER; } foreach ($ruleset as $form => $rule) { foreach ($rule as $subrule) { $subrulePassed = false; $processedQuantity = $quantity; if ($subrule['modulo'] !== false) { $processedQuantity = fmod($processedQuantity, $subrule['modulo']); } if ($processedQuantity == floor($processedQuantity)) { $processedQuantity = (int)$processedQuantity; } $condition = $subrule['condition']; switch ($condition[0]) { case 'is': case 'isnot': if (is_int($processedQuantity) && $processedQuantity === $condition[1]) { $subrulePassed = true; } if ($condition[0] === 'isnot') { $subrulePassed = !$subrulePassed; } break; case 'in': case 'notin': if (is_int($processedQuantity) && $processedQuantity >= $condition[1] && $processedQuantity <= $condition[2]) { $subrulePassed = true; } if ($condition[0] === 'notin') { $subrulePassed = !$subrulePassed; } break; case 'within': case 'notwithin': if ($processedQuantity >= $condition[1] && $processedQuantity <= $condition[2]) { $subrulePassed = true; } if ($condition[0] === 'notwithin') { $subrulePassed = !$subrulePassed; } break; } if (($subrulePassed && $subrule['logicalOperator'] === 'or') || (!$subrulePassed && $subrule['logicalOperator'] === 'and')) { break; } } if ($subrulePassed) { return $form; } } return self::RULE_OTHER; }
[ "public", "function", "getPluralForm", "(", "$", "quantity", ",", "Locale", "$", "locale", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "rulesetsIndices", "[", "$", "locale", "->", "getLanguage", "(", ")", "]", ")", ")", "{", "return", ...
Returns matching plural form based on $quantity and $locale provided. Plural form is one of following: zero, one, two, few, many, other. Last one (other) is returned when number provided doesn't match any of the rules, or there is no rules for given locale. @param mixed $quantity A number to find plural form for (float or int) @param Locale $locale @return string One of plural form constants
[ "Returns", "matching", "plural", "form", "based", "on", "$quantity", "and", "$locale", "provided", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/I18n/Cldr/Reader/PluralsReader.php#L147-L215
neos/flow-development-collection
Neos.Flow/Classes/I18n/Cldr/Reader/PluralsReader.php
PluralsReader.getPluralForms
public function getPluralForms(Locale $locale) { if (!isset($this->rulesetsIndices[$locale->getLanguage()])) { return [self::RULE_OTHER]; } $ruleset = $this->rulesets[$locale->getLanguage()][$this->rulesetsIndices[$locale->getLanguage()]] ?? null; if ($ruleset === null) { return [self::RULE_OTHER]; } return array_merge(array_keys($ruleset), [self::RULE_OTHER]); }
php
public function getPluralForms(Locale $locale) { if (!isset($this->rulesetsIndices[$locale->getLanguage()])) { return [self::RULE_OTHER]; } $ruleset = $this->rulesets[$locale->getLanguage()][$this->rulesetsIndices[$locale->getLanguage()]] ?? null; if ($ruleset === null) { return [self::RULE_OTHER]; } return array_merge(array_keys($ruleset), [self::RULE_OTHER]); }
[ "public", "function", "getPluralForms", "(", "Locale", "$", "locale", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "rulesetsIndices", "[", "$", "locale", "->", "getLanguage", "(", ")", "]", ")", ")", "{", "return", "[", "self", "::", "R...
Returns array of plural forms available for particular locale. @param Locale $locale Locale to return plural forms for @return array Plural forms' names (one, zero, two, few, many, other) available for language set in this model
[ "Returns", "array", "of", "plural", "forms", "available", "for", "particular", "locale", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/I18n/Cldr/Reader/PluralsReader.php#L223-L236
neos/flow-development-collection
Neos.Flow/Classes/I18n/Cldr/Reader/PluralsReader.php
PluralsReader.generateRulesets
protected function generateRulesets() { $model = $this->cldrRepository->getModel('supplemental/plurals'); $pluralRulesSet = $model->getRawArray('plurals'); $index = 0; foreach ($pluralRulesSet as $pluralRulesNodeString => $pluralRules) { $localeLanguages = $model->getAttributeValue($pluralRulesNodeString, 'locales'); foreach (explode(' ', $localeLanguages) as $localeLanguage) { $this->rulesetsIndices[$localeLanguage] = $index; } if (is_array($pluralRules)) { $ruleset = []; foreach ($pluralRules as $pluralRuleNodeString => $pluralRule) { $pluralForm = $model->getAttributeValue($pluralRuleNodeString, 'count'); $ruleset[$pluralForm] = $this->parseRule($pluralRule); } foreach (explode(' ', $localeLanguages) as $localeLanguage) { $this->rulesets[$localeLanguage][$index] = $ruleset; } } ++$index; } }
php
protected function generateRulesets() { $model = $this->cldrRepository->getModel('supplemental/plurals'); $pluralRulesSet = $model->getRawArray('plurals'); $index = 0; foreach ($pluralRulesSet as $pluralRulesNodeString => $pluralRules) { $localeLanguages = $model->getAttributeValue($pluralRulesNodeString, 'locales'); foreach (explode(' ', $localeLanguages) as $localeLanguage) { $this->rulesetsIndices[$localeLanguage] = $index; } if (is_array($pluralRules)) { $ruleset = []; foreach ($pluralRules as $pluralRuleNodeString => $pluralRule) { $pluralForm = $model->getAttributeValue($pluralRuleNodeString, 'count'); $ruleset[$pluralForm] = $this->parseRule($pluralRule); } foreach (explode(' ', $localeLanguages) as $localeLanguage) { $this->rulesets[$localeLanguage][$index] = $ruleset; } } ++$index; } }
[ "protected", "function", "generateRulesets", "(", ")", "{", "$", "model", "=", "$", "this", "->", "cldrRepository", "->", "getModel", "(", "'supplemental/plurals'", ")", ";", "$", "pluralRulesSet", "=", "$", "model", "->", "getRawArray", "(", "'plurals'", ")",...
Generates an internal representation of plural rules which can be found in plurals.xml CLDR file. The properties $rulesets and $rulesetsIndices should be empty before running this method. @return void @see PluralsReader::$rulesets
[ "Generates", "an", "internal", "representation", "of", "plural", "rules", "which", "can", "be", "found", "in", "plurals", ".", "xml", "CLDR", "file", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/I18n/Cldr/Reader/PluralsReader.php#L248-L275
neos/flow-development-collection
Neos.Flow/Classes/I18n/Cldr/Reader/PluralsReader.php
PluralsReader.parseRule
protected function parseRule($rule) { $parsedRule = []; if (preg_match_all(self::PATTERN_MATCH_SUBRULE, strtolower(str_replace(' ', '', $rule)), $matches, \PREG_SET_ORDER)) { foreach ($matches as $matchedSubrule) { $subrule = []; if ($matchedSubrule[1] === 'nmod') { $subrule['modulo'] = (int)$matchedSubrule[2]; } else { $subrule['modulo'] = false; } $condition = [$matchedSubrule[3], (int)$matchedSubrule[4]]; if (!in_array($matchedSubrule[3], ['is', 'isnot'], true)) { $condition[2] = (int)$matchedSubrule[5]; } $subrule['condition'] = $condition; if (isset($matchedSubrule[6]) && ($matchedSubrule[6] === 'and' || $matchedSubrule[6] === 'or')) { $subrule['logicalOperator'] = $matchedSubrule[6]; } else { $subrule['logicalOperator'] = false; } $parsedRule[] = $subrule; } } else { throw new Exception\InvalidPluralRuleException('A plural rule string is invalid. CLDR files might be corrupted.', 1275493982); } return $parsedRule; }
php
protected function parseRule($rule) { $parsedRule = []; if (preg_match_all(self::PATTERN_MATCH_SUBRULE, strtolower(str_replace(' ', '', $rule)), $matches, \PREG_SET_ORDER)) { foreach ($matches as $matchedSubrule) { $subrule = []; if ($matchedSubrule[1] === 'nmod') { $subrule['modulo'] = (int)$matchedSubrule[2]; } else { $subrule['modulo'] = false; } $condition = [$matchedSubrule[3], (int)$matchedSubrule[4]]; if (!in_array($matchedSubrule[3], ['is', 'isnot'], true)) { $condition[2] = (int)$matchedSubrule[5]; } $subrule['condition'] = $condition; if (isset($matchedSubrule[6]) && ($matchedSubrule[6] === 'and' || $matchedSubrule[6] === 'or')) { $subrule['logicalOperator'] = $matchedSubrule[6]; } else { $subrule['logicalOperator'] = false; } $parsedRule[] = $subrule; } } else { throw new Exception\InvalidPluralRuleException('A plural rule string is invalid. CLDR files might be corrupted.', 1275493982); } return $parsedRule; }
[ "protected", "function", "parseRule", "(", "$", "rule", ")", "{", "$", "parsedRule", "=", "[", "]", ";", "if", "(", "preg_match_all", "(", "self", "::", "PATTERN_MATCH_SUBRULE", ",", "strtolower", "(", "str_replace", "(", "' '", ",", "''", ",", "$", "rul...
Parses a plural rule from CLDR. A plural rule in CLDR is a string with one or more test conditions, with 'and' or 'or' logical operators between them. Whole expression can look like this: n is 0 OR n is not 1 AND n mod 100 in 1..19 As CLDR documentation says, following test conditions can be used: - is x, is not x: $n is (not) equal $x - in x..y, not in x..y: $n is (not) one of integers from range <$x, $y> - within x..y, not within x..y: $n is (not) any number from range <$x, $y> Where $n can be a number (also float) as is, or a result of $n mod $x. Array returned follows simple internal format (see documentation for $rulesets property for details). @param string $rule @return array Parsed rule @throws Exception\InvalidPluralRuleException When plural rule does not match regexp pattern
[ "Parses", "a", "plural", "rule", "from", "CLDR", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/I18n/Cldr/Reader/PluralsReader.php#L300-L334
neos/flow-development-collection
Neos.Flow/Classes/Mvc/Routing/IdentityRoutePart.php
IdentityRoutePart.getUriPattern
public function getUriPattern() { if ($this->uriPattern === null) { $classSchema = $this->reflectionService->getClassSchema($this->objectType); $identityProperties = $classSchema->getIdentityProperties(); if (count($identityProperties) === 0) { $this->uriPattern = ''; } else { $this->uriPattern = '{' . implode('}/{', array_keys($identityProperties)) . '}'; } } return $this->uriPattern; }
php
public function getUriPattern() { if ($this->uriPattern === null) { $classSchema = $this->reflectionService->getClassSchema($this->objectType); $identityProperties = $classSchema->getIdentityProperties(); if (count($identityProperties) === 0) { $this->uriPattern = ''; } else { $this->uriPattern = '{' . implode('}/{', array_keys($identityProperties)) . '}'; } } return $this->uriPattern; }
[ "public", "function", "getUriPattern", "(", ")", "{", "if", "(", "$", "this", "->", "uriPattern", "===", "null", ")", "{", "$", "classSchema", "=", "$", "this", "->", "reflectionService", "->", "getClassSchema", "(", "$", "this", "->", "objectType", ")", ...
If $this->uriPattern is specified, this will be returned, otherwise identity properties of $this->objectType are returned in the format {property1}/{property2}/{property3}. If $this->objectType does not contain identity properties, an empty string is returned. @return string
[ "If", "$this", "-", ">", "uriPattern", "is", "specified", "this", "will", "be", "returned", "otherwise", "identity", "properties", "of", "$this", "-", ">", "objectType", "are", "returned", "in", "the", "format", "{", "property1", "}", "/", "{", "property2", ...
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Mvc/Routing/IdentityRoutePart.php#L102-L114
neos/flow-development-collection
Neos.Flow/Classes/Mvc/Routing/IdentityRoutePart.php
IdentityRoutePart.matchValue
protected function matchValue($value) { if ($value === null || $value === '') { return false; } $identifier = $this->getObjectIdentifierFromPathSegment($value); if ($identifier === null) { return false; } $this->value = ['__identity' => $identifier]; return true; }
php
protected function matchValue($value) { if ($value === null || $value === '') { return false; } $identifier = $this->getObjectIdentifierFromPathSegment($value); if ($identifier === null) { return false; } $this->value = ['__identity' => $identifier]; return true; }
[ "protected", "function", "matchValue", "(", "$", "value", ")", "{", "if", "(", "$", "value", "===", "null", "||", "$", "value", "===", "''", ")", "{", "return", "false", ";", "}", "$", "identifier", "=", "$", "this", "->", "getObjectIdentifierFromPathSeg...
Checks, whether given value can be matched. If the value is empty, false is returned. Otherwise the ObjectPathMappingRepository is asked for a matching ObjectPathMapping. If that is found the identifier is stored in $this->value, otherwise this route part does not match. @param string $value value to match, usually the current query path segment(s) @return boolean true if value could be matched successfully, otherwise false @api
[ "Checks", "whether", "given", "value", "can", "be", "matched", ".", "If", "the", "value", "is", "empty", "false", "is", "returned", ".", "Otherwise", "the", "ObjectPathMappingRepository", "is", "asked", "for", "a", "matching", "ObjectPathMapping", ".", "If", "...
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Mvc/Routing/IdentityRoutePart.php#L126-L137
neos/flow-development-collection
Neos.Flow/Classes/Mvc/Routing/IdentityRoutePart.php
IdentityRoutePart.getObjectIdentifierFromPathSegment
protected function getObjectIdentifierFromPathSegment($pathSegment) { if ($this->getUriPattern() === '') { $identifier = rawurldecode($pathSegment); $object = $this->persistenceManager->getObjectByIdentifier($identifier, $this->objectType); if ($object !== null) { return $identifier; } } else { $objectPathMapping = $this->objectPathMappingRepository->findOneByObjectTypeUriPatternAndPathSegment($this->objectType, $this->getUriPattern(), $pathSegment, !$this->lowerCase); if ($objectPathMapping !== null) { return $objectPathMapping->getIdentifier(); } } return null; }
php
protected function getObjectIdentifierFromPathSegment($pathSegment) { if ($this->getUriPattern() === '') { $identifier = rawurldecode($pathSegment); $object = $this->persistenceManager->getObjectByIdentifier($identifier, $this->objectType); if ($object !== null) { return $identifier; } } else { $objectPathMapping = $this->objectPathMappingRepository->findOneByObjectTypeUriPatternAndPathSegment($this->objectType, $this->getUriPattern(), $pathSegment, !$this->lowerCase); if ($objectPathMapping !== null) { return $objectPathMapping->getIdentifier(); } } return null; }
[ "protected", "function", "getObjectIdentifierFromPathSegment", "(", "$", "pathSegment", ")", "{", "if", "(", "$", "this", "->", "getUriPattern", "(", ")", "===", "''", ")", "{", "$", "identifier", "=", "rawurldecode", "(", "$", "pathSegment", ")", ";", "$", ...
Retrieves the object identifier from the given $pathSegment. If no UriPattern is set, the $pathSegment is expected to be the (URL-encoded) identifier otherwise a matching ObjectPathMapping fetched from persistence If no matching ObjectPathMapping was found or the given $pathSegment is no valid identifier NULL is returned. @param string $pathSegment the query path segment to convert @return string|integer the technical identifier of the object or NULL if it couldn't be found
[ "Retrieves", "the", "object", "identifier", "from", "the", "given", "$pathSegment", ".", "If", "no", "UriPattern", "is", "set", "the", "$pathSegment", "is", "expected", "to", "be", "the", "(", "URL", "-", "encoded", ")", "identifier", "otherwise", "a", "matc...
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Mvc/Routing/IdentityRoutePart.php#L147-L162
neos/flow-development-collection
Neos.Flow/Classes/Mvc/Routing/IdentityRoutePart.php
IdentityRoutePart.findValueToMatch
protected function findValueToMatch($routePath) { if (!isset($routePath) || $routePath === '' || $routePath[0] === '/') { return ''; } if ($this->getUriPattern() === '') { return parent::findValueToMatch($routePath); } $regexPattern = preg_quote($this->getUriPattern(), '/'); $regexPattern = preg_replace('/\\\\{[^}]+\\\\}/', '[^\/]+', $regexPattern); if ($this->splitString !== '') { $regexPattern .= '(?=' . preg_quote($this->splitString, '/') . ')'; } $matches = []; preg_match('/^' . $regexPattern . '/', trim($routePath, '/'), $matches); return isset($matches[0]) ? $matches[0] : ''; }
php
protected function findValueToMatch($routePath) { if (!isset($routePath) || $routePath === '' || $routePath[0] === '/') { return ''; } if ($this->getUriPattern() === '') { return parent::findValueToMatch($routePath); } $regexPattern = preg_quote($this->getUriPattern(), '/'); $regexPattern = preg_replace('/\\\\{[^}]+\\\\}/', '[^\/]+', $regexPattern); if ($this->splitString !== '') { $regexPattern .= '(?=' . preg_quote($this->splitString, '/') . ')'; } $matches = []; preg_match('/^' . $regexPattern . '/', trim($routePath, '/'), $matches); return isset($matches[0]) ? $matches[0] : ''; }
[ "protected", "function", "findValueToMatch", "(", "$", "routePath", ")", "{", "if", "(", "!", "isset", "(", "$", "routePath", ")", "||", "$", "routePath", "===", "''", "||", "$", "routePath", "[", "0", "]", "===", "'/'", ")", "{", "return", "''", ";"...
Returns the first part of $routePath that should be evaluated in matchValue(). If no split string is set (route part is the last in the routes uriPattern), the complete $routePart is returned. Otherwise the part is returned that matches the specified uriPattern of this route part. @param string $routePath The request path to be matched @return string value to match, or an empty string if $routePath is empty, split string was not found or uriPattern could not be matched @api
[ "Returns", "the", "first", "part", "of", "$routePath", "that", "should", "be", "evaluated", "in", "matchValue", "()", ".", "If", "no", "split", "string", "is", "set", "(", "route", "part", "is", "the", "last", "in", "the", "routes", "uriPattern", ")", "t...
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Mvc/Routing/IdentityRoutePart.php#L173-L189
neos/flow-development-collection
Neos.Flow/Classes/Mvc/Routing/IdentityRoutePart.php
IdentityRoutePart.resolveValue
protected function resolveValue($value) { $identifier = null; if (is_array($value) && isset($value['__identity'])) { $identifier = $value['__identity']; } elseif ($value instanceof $this->objectType) { $identifier = $this->persistenceManager->getIdentifierByObject($value); } if ($identifier === null || (!is_string($identifier) && !is_integer($identifier))) { return false; } $pathSegment = $this->getPathSegmentByIdentifier($identifier); if ($pathSegment === null) { return false; } $this->value = $pathSegment; return true; }
php
protected function resolveValue($value) { $identifier = null; if (is_array($value) && isset($value['__identity'])) { $identifier = $value['__identity']; } elseif ($value instanceof $this->objectType) { $identifier = $this->persistenceManager->getIdentifierByObject($value); } if ($identifier === null || (!is_string($identifier) && !is_integer($identifier))) { return false; } $pathSegment = $this->getPathSegmentByIdentifier($identifier); if ($pathSegment === null) { return false; } $this->value = $pathSegment; return true; }
[ "protected", "function", "resolveValue", "(", "$", "value", ")", "{", "$", "identifier", "=", "null", ";", "if", "(", "is_array", "(", "$", "value", ")", "&&", "isset", "(", "$", "value", "[", "'__identity'", "]", ")", ")", "{", "$", "identifier", "=...
Resolves the given entity and sets the value to a URI representation (path segment) that matches $this->uriPattern and is unique for the given object. @param mixed $value @return boolean true if the object could be resolved and stored in $this->value, otherwise false.
[ "Resolves", "the", "given", "entity", "and", "sets", "the", "value", "to", "a", "URI", "representation", "(", "path", "segment", ")", "that", "matches", "$this", "-", ">", "uriPattern", "and", "is", "unique", "for", "the", "given", "object", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Mvc/Routing/IdentityRoutePart.php#L197-L214
neos/flow-development-collection
Neos.Flow/Classes/Mvc/Routing/IdentityRoutePart.php
IdentityRoutePart.getPathSegmentByIdentifier
protected function getPathSegmentByIdentifier($identifier) { if ($this->getUriPattern() === '') { return rawurlencode($identifier); } $objectPathMapping = $this->objectPathMappingRepository->findOneByObjectTypeUriPatternAndIdentifier($this->objectType, $this->getUriPattern(), $identifier); if ($objectPathMapping !== null) { return $this->lowerCase ? strtolower($objectPathMapping->getPathSegment()) : $objectPathMapping->getPathSegment(); } $object = $this->persistenceManager->getObjectByIdentifier($identifier, $this->objectType); $pathSegment = $uniquePathSegment = $this->createPathSegmentForObject($object); $pathSegmentLoopCount = 0; do { if ($pathSegmentLoopCount++ > 99) { throw new InfiniteLoopException('No unique path segment could be found after ' . ($pathSegmentLoopCount - 1) . ' iterations.', 1316441798); } if ($uniquePathSegment !== '') { $objectPathMapping = $this->objectPathMappingRepository->findOneByObjectTypeUriPatternAndPathSegment($this->objectType, $this->getUriPattern(), $uniquePathSegment, !$this->lowerCase); if ($objectPathMapping === null) { $this->storeObjectPathMapping($uniquePathSegment, $identifier); break; } } $uniquePathSegment = sprintf('%s-%d', $pathSegment, $pathSegmentLoopCount); } while (true); return $this->lowerCase ? strtolower($uniquePathSegment) : $uniquePathSegment; }
php
protected function getPathSegmentByIdentifier($identifier) { if ($this->getUriPattern() === '') { return rawurlencode($identifier); } $objectPathMapping = $this->objectPathMappingRepository->findOneByObjectTypeUriPatternAndIdentifier($this->objectType, $this->getUriPattern(), $identifier); if ($objectPathMapping !== null) { return $this->lowerCase ? strtolower($objectPathMapping->getPathSegment()) : $objectPathMapping->getPathSegment(); } $object = $this->persistenceManager->getObjectByIdentifier($identifier, $this->objectType); $pathSegment = $uniquePathSegment = $this->createPathSegmentForObject($object); $pathSegmentLoopCount = 0; do { if ($pathSegmentLoopCount++ > 99) { throw new InfiniteLoopException('No unique path segment could be found after ' . ($pathSegmentLoopCount - 1) . ' iterations.', 1316441798); } if ($uniquePathSegment !== '') { $objectPathMapping = $this->objectPathMappingRepository->findOneByObjectTypeUriPatternAndPathSegment($this->objectType, $this->getUriPattern(), $uniquePathSegment, !$this->lowerCase); if ($objectPathMapping === null) { $this->storeObjectPathMapping($uniquePathSegment, $identifier); break; } } $uniquePathSegment = sprintf('%s-%d', $pathSegment, $pathSegmentLoopCount); } while (true); return $this->lowerCase ? strtolower($uniquePathSegment) : $uniquePathSegment; }
[ "protected", "function", "getPathSegmentByIdentifier", "(", "$", "identifier", ")", "{", "if", "(", "$", "this", "->", "getUriPattern", "(", ")", "===", "''", ")", "{", "return", "rawurlencode", "(", "$", "identifier", ")", ";", "}", "$", "objectPathMapping"...
Generates a unique string for the given identifier according to $this->uriPattern. If no UriPattern is set, the path segment is equal to the (URL-encoded) $identifier - otherwise a matching ObjectPathMapping is fetched from persistence. If no ObjectPathMapping exists for the given identifier, a new ObjectPathMapping is created. @param string $identifier the technical identifier of the object @return string|integer the resolved path segment(s) @throws InfiniteLoopException if no unique path segment could be found after 100 iterations
[ "Generates", "a", "unique", "string", "for", "the", "given", "identifier", "according", "to", "$this", "-", ">", "uriPattern", ".", "If", "no", "UriPattern", "is", "set", "the", "path", "segment", "is", "equal", "to", "the", "(", "URL", "-", "encoded", "...
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Mvc/Routing/IdentityRoutePart.php#L226-L254
neos/flow-development-collection
Neos.Flow/Classes/Mvc/Routing/IdentityRoutePart.php
IdentityRoutePart.createPathSegmentForObject
protected function createPathSegmentForObject($object) { $matches = []; preg_match_all('/(?P<dynamic>{?)(?P<content>[^}{]+)}?/', $this->getUriPattern(), $matches, PREG_SET_ORDER); $pathSegment = ''; foreach ($matches as $match) { if (empty($match['dynamic'])) { $pathSegment .= $match['content']; } else { $dynamicPathSegmentParts = explode(':', $match['content']); $propertyPath = $dynamicPathSegmentParts[0]; $dynamicPathSegment = ObjectAccess::getPropertyPath($object, $propertyPath); if (is_object($dynamicPathSegment)) { if ($dynamicPathSegment instanceof \DateTimeInterface) { $dateFormat = isset($dynamicPathSegmentParts[1]) ? trim($dynamicPathSegmentParts[1]) : 'Y-m-d'; $pathSegment .= $this->rewriteForUri($dynamicPathSegment->format($dateFormat)); } else { throw new InvalidUriPatternException(sprintf('Invalid uriPattern "%s" for route part "%s". Property "%s" must be of type string or \DateTime. "%s" given.', $this->getUriPattern(), $this->getName(), $propertyPath, is_object($dynamicPathSegment) ? get_class($dynamicPathSegment) : gettype($dynamicPathSegment)), 1316442409); } } else { $pathSegment .= $this->rewriteForUri($dynamicPathSegment); } } } return $pathSegment; }
php
protected function createPathSegmentForObject($object) { $matches = []; preg_match_all('/(?P<dynamic>{?)(?P<content>[^}{]+)}?/', $this->getUriPattern(), $matches, PREG_SET_ORDER); $pathSegment = ''; foreach ($matches as $match) { if (empty($match['dynamic'])) { $pathSegment .= $match['content']; } else { $dynamicPathSegmentParts = explode(':', $match['content']); $propertyPath = $dynamicPathSegmentParts[0]; $dynamicPathSegment = ObjectAccess::getPropertyPath($object, $propertyPath); if (is_object($dynamicPathSegment)) { if ($dynamicPathSegment instanceof \DateTimeInterface) { $dateFormat = isset($dynamicPathSegmentParts[1]) ? trim($dynamicPathSegmentParts[1]) : 'Y-m-d'; $pathSegment .= $this->rewriteForUri($dynamicPathSegment->format($dateFormat)); } else { throw new InvalidUriPatternException(sprintf('Invalid uriPattern "%s" for route part "%s". Property "%s" must be of type string or \DateTime. "%s" given.', $this->getUriPattern(), $this->getName(), $propertyPath, is_object($dynamicPathSegment) ? get_class($dynamicPathSegment) : gettype($dynamicPathSegment)), 1316442409); } } else { $pathSegment .= $this->rewriteForUri($dynamicPathSegment); } } } return $pathSegment; }
[ "protected", "function", "createPathSegmentForObject", "(", "$", "object", ")", "{", "$", "matches", "=", "[", "]", ";", "preg_match_all", "(", "'/(?P<dynamic>{?)(?P<content>[^}{]+)}?/'", ",", "$", "this", "->", "getUriPattern", "(", ")", ",", "$", "matches", ",...
Creates a URI representation (path segment) for the given object matching $this->uriPattern. @param mixed $object object of type $this->objectType @return string URI representation (path segment) of the given object @throws InvalidUriPatternException
[ "Creates", "a", "URI", "representation", "(", "path", "segment", ")", "for", "the", "given", "object", "matching", "$this", "-", ">", "uriPattern", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Mvc/Routing/IdentityRoutePart.php#L263-L288
neos/flow-development-collection
Neos.Flow/Classes/Mvc/Routing/IdentityRoutePart.php
IdentityRoutePart.storeObjectPathMapping
protected function storeObjectPathMapping($pathSegment, $identifier) { $objectPathMapping = new ObjectPathMapping(); $objectPathMapping->setObjectType($this->objectType); $objectPathMapping->setUriPattern($this->getUriPattern()); $objectPathMapping->setPathSegment($pathSegment); $objectPathMapping->setIdentifier($identifier); $this->objectPathMappingRepository->add($objectPathMapping); $this->objectPathMappingRepository->persistEntities(); }
php
protected function storeObjectPathMapping($pathSegment, $identifier) { $objectPathMapping = new ObjectPathMapping(); $objectPathMapping->setObjectType($this->objectType); $objectPathMapping->setUriPattern($this->getUriPattern()); $objectPathMapping->setPathSegment($pathSegment); $objectPathMapping->setIdentifier($identifier); $this->objectPathMappingRepository->add($objectPathMapping); $this->objectPathMappingRepository->persistEntities(); }
[ "protected", "function", "storeObjectPathMapping", "(", "$", "pathSegment", ",", "$", "identifier", ")", "{", "$", "objectPathMapping", "=", "new", "ObjectPathMapping", "(", ")", ";", "$", "objectPathMapping", "->", "setObjectType", "(", "$", "this", "->", "obje...
Creates a new ObjectPathMapping and stores it in the repository @param string $pathSegment @param string|integer $identifier @return void
[ "Creates", "a", "new", "ObjectPathMapping", "and", "stores", "it", "in", "the", "repository" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Mvc/Routing/IdentityRoutePart.php#L297-L306
neos/flow-development-collection
Neos.Flow/Classes/Mvc/Routing/IdentityRoutePart.php
IdentityRoutePart.rewriteForUri
protected function rewriteForUri($value) { $transliteration = [ 'ä' => 'ae', 'Ä' => 'Ae', 'ö' => 'oe', 'Ö' => 'Oe', 'ü' => 'ue', 'Ü' => 'Ue', 'ß' => 'ss', ]; $value = strtr($value, $transliteration); $spaceCharacter = '-'; $value = preg_replace('/[ \-+_]+/', $spaceCharacter, $value); $value = preg_replace('/[^-a-z0-9.\\' . $spaceCharacter . ']/i', '', $value); $value = preg_replace('/\\' . $spaceCharacter . '{2,}/', $spaceCharacter, $value); $value = trim($value, $spaceCharacter); return $value; }
php
protected function rewriteForUri($value) { $transliteration = [ 'ä' => 'ae', 'Ä' => 'Ae', 'ö' => 'oe', 'Ö' => 'Oe', 'ü' => 'ue', 'Ü' => 'Ue', 'ß' => 'ss', ]; $value = strtr($value, $transliteration); $spaceCharacter = '-'; $value = preg_replace('/[ \-+_]+/', $spaceCharacter, $value); $value = preg_replace('/[^-a-z0-9.\\' . $spaceCharacter . ']/i', '', $value); $value = preg_replace('/\\' . $spaceCharacter . '{2,}/', $spaceCharacter, $value); $value = trim($value, $spaceCharacter); return $value; }
[ "protected", "function", "rewriteForUri", "(", "$", "value", ")", "{", "$", "transliteration", "=", "[", "'ä' ", "> ", "ae',", "", "'Ä' ", "> ", "Ae',", "", "'ö' ", "> ", "oe',", "", "'Ö' ", "> ", "Oe',", "", "'ü' ", "> ", "ue',", "", "'Ü' ", "> ", ...
Transforms the given string into a URI compatible format without special characters. In the long term this should be done with proper transliteration @param string $value @return string @todo use transliteration of the I18n sub package
[ "Transforms", "the", "given", "string", "into", "a", "URI", "compatible", "format", "without", "special", "characters", ".", "In", "the", "long", "term", "this", "should", "be", "done", "with", "proper", "transliteration" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Mvc/Routing/IdentityRoutePart.php#L316-L338
neos/flow-development-collection
Neos.Flow/Classes/Security/RequestPattern/ControllerObjectName.php
ControllerObjectName.matchRequest
public function matchRequest(RequestInterface $request) { if (!isset($this->options['controllerObjectNamePattern'])) { throw new InvalidRequestPatternException('Missing option "controllerObjectNamePattern" in the ControllerObjectName request pattern configuration', 1446224501); } return (boolean)preg_match('/^' . str_replace('\\', '\\\\', $this->options['controllerObjectNamePattern']) . '$/', $request->getControllerObjectName()); }
php
public function matchRequest(RequestInterface $request) { if (!isset($this->options['controllerObjectNamePattern'])) { throw new InvalidRequestPatternException('Missing option "controllerObjectNamePattern" in the ControllerObjectName request pattern configuration', 1446224501); } return (boolean)preg_match('/^' . str_replace('\\', '\\\\', $this->options['controllerObjectNamePattern']) . '$/', $request->getControllerObjectName()); }
[ "public", "function", "matchRequest", "(", "RequestInterface", "$", "request", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "options", "[", "'controllerObjectNamePattern'", "]", ")", ")", "{", "throw", "new", "InvalidRequestPatternException", "(", ...
Matches a \Neos\Flow\Mvc\RequestInterface against its set controller object name pattern rules @param RequestInterface $request The request that should be matched @return boolean true if the pattern matched, false otherwise @throws InvalidRequestPatternException
[ "Matches", "a", "\\", "Neos", "\\", "Flow", "\\", "Mvc", "\\", "RequestInterface", "against", "its", "set", "controller", "object", "name", "pattern", "rules" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/RequestPattern/ControllerObjectName.php#L45-L51
neos/flow-development-collection
Neos.Flow/Classes/Mvc/Routing/Route.php
Route.setUriPattern
public function setUriPattern($uriPattern) { if (!is_string($uriPattern)) { throw new \InvalidArgumentException(sprintf('URI Pattern must be of type string, %s given.', gettype($uriPattern)), 1223499724); } $this->uriPattern = $uriPattern; $this->isParsed = false; }
php
public function setUriPattern($uriPattern) { if (!is_string($uriPattern)) { throw new \InvalidArgumentException(sprintf('URI Pattern must be of type string, %s given.', gettype($uriPattern)), 1223499724); } $this->uriPattern = $uriPattern; $this->isParsed = false; }
[ "public", "function", "setUriPattern", "(", "$", "uriPattern", ")", "{", "if", "(", "!", "is_string", "(", "$", "uriPattern", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'URI Pattern must be of type string, %s given.'", "...
Sets the URI pattern this route should match with @param string $uriPattern @return void @throws \InvalidArgumentException
[ "Sets", "the", "URI", "pattern", "this", "route", "should", "match", "with" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Mvc/Routing/Route.php#L194-L201
neos/flow-development-collection
Neos.Flow/Classes/Mvc/Routing/Route.php
Route.matches
public function matches(RouteContext $routeContext) { $httpRequest = $routeContext->getHttpRequest(); $routePath = $httpRequest->getRelativePath(); $this->matchResults = null; $this->matchedTags = RouteTags::createEmpty(); if ($this->uriPattern === null) { return false; } if (!$this->isParsed) { $this->parse(); } if ($this->hasHttpMethodConstraints() && (!in_array($httpRequest->getMethod(), $this->httpMethods))) { return false; } $matchResults = []; $routePath = trim($routePath, '/'); $skipOptionalParts = false; $optionalPartCount = 0; /** @var $routePart RoutePartInterface */ foreach ($this->routeParts as $routePart) { if ($routePart->isOptional()) { $optionalPartCount++; if ($skipOptionalParts) { if ($routePart->getDefaultValue() === null) { return false; } continue; } } else { $optionalPartCount = 0; $skipOptionalParts = false; } if ($routePart instanceof ParameterAwareRoutePartInterface) { $matchResult = $routePart->matchWithParameters($routePath, $routeContext->getParameters()); } else { $matchResult = $routePart->match($routePath); } if ($matchResult instanceof MatchResult) { $routeMatches = true; $routePartValue = $matchResult->getMatchedValue(); if ($matchResult->hasTags()) { $this->matchedTags = $this->matchedTags->merge($matchResult->getTags()); } } else { $routeMatches = $matchResult === true; $routePartValue = $routeMatches ? $routePart->getValue() : null; } if ($routeMatches !== true) { if ($routePart->isOptional() && $optionalPartCount === 1) { if ($routePart->getDefaultValue() === null) { return false; } $skipOptionalParts = true; } else { return false; } } if ($routePartValue !== null) { if ($this->containsObject($routePartValue)) { throw new InvalidRoutePartValueException('RoutePart::getValue() must only return simple types after calling RoutePart::match(). RoutePart "' . get_class($routePart) . '" returned one or more objects in Route "' . $this->getName() . '".'); } $matchResults = Arrays::setValueByPath($matchResults, $routePart->getName(), $routePartValue); } } if (strlen($routePath) > 0) { return false; } $this->matchResults = Arrays::arrayMergeRecursiveOverrule($this->defaults, $matchResults); return true; }
php
public function matches(RouteContext $routeContext) { $httpRequest = $routeContext->getHttpRequest(); $routePath = $httpRequest->getRelativePath(); $this->matchResults = null; $this->matchedTags = RouteTags::createEmpty(); if ($this->uriPattern === null) { return false; } if (!$this->isParsed) { $this->parse(); } if ($this->hasHttpMethodConstraints() && (!in_array($httpRequest->getMethod(), $this->httpMethods))) { return false; } $matchResults = []; $routePath = trim($routePath, '/'); $skipOptionalParts = false; $optionalPartCount = 0; /** @var $routePart RoutePartInterface */ foreach ($this->routeParts as $routePart) { if ($routePart->isOptional()) { $optionalPartCount++; if ($skipOptionalParts) { if ($routePart->getDefaultValue() === null) { return false; } continue; } } else { $optionalPartCount = 0; $skipOptionalParts = false; } if ($routePart instanceof ParameterAwareRoutePartInterface) { $matchResult = $routePart->matchWithParameters($routePath, $routeContext->getParameters()); } else { $matchResult = $routePart->match($routePath); } if ($matchResult instanceof MatchResult) { $routeMatches = true; $routePartValue = $matchResult->getMatchedValue(); if ($matchResult->hasTags()) { $this->matchedTags = $this->matchedTags->merge($matchResult->getTags()); } } else { $routeMatches = $matchResult === true; $routePartValue = $routeMatches ? $routePart->getValue() : null; } if ($routeMatches !== true) { if ($routePart->isOptional() && $optionalPartCount === 1) { if ($routePart->getDefaultValue() === null) { return false; } $skipOptionalParts = true; } else { return false; } } if ($routePartValue !== null) { if ($this->containsObject($routePartValue)) { throw new InvalidRoutePartValueException('RoutePart::getValue() must only return simple types after calling RoutePart::match(). RoutePart "' . get_class($routePart) . '" returned one or more objects in Route "' . $this->getName() . '".'); } $matchResults = Arrays::setValueByPath($matchResults, $routePart->getName(), $routePartValue); } } if (strlen($routePath) > 0) { return false; } $this->matchResults = Arrays::arrayMergeRecursiveOverrule($this->defaults, $matchResults); return true; }
[ "public", "function", "matches", "(", "RouteContext", "$", "routeContext", ")", "{", "$", "httpRequest", "=", "$", "routeContext", "->", "getHttpRequest", "(", ")", ";", "$", "routePath", "=", "$", "httpRequest", "->", "getRelativePath", "(", ")", ";", "$", ...
Checks whether $routeContext corresponds to this Route. If all Route Parts match successfully true is returned an $this->matchResults contains an array combining Route default values and calculated matchResults from the individual Route Parts. @param RouteContext $routeContext The Route Context containing the current HTTP request object and, optional, Routing RouteParameters @return boolean true if this Route corresponds to the given $routeContext, otherwise false @throws InvalidRoutePartValueException @see getMatchResults()
[ "Checks", "whether", "$routeContext", "corresponds", "to", "this", "Route", ".", "If", "all", "Route", "Parts", "match", "successfully", "true", "is", "returned", "an", "$this", "-", ">", "matchResults", "contains", "an", "array", "combining", "Route", "default"...
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Mvc/Routing/Route.php#L370-L442
neos/flow-development-collection
Neos.Flow/Classes/Mvc/Routing/Route.php
Route.resolves
public function resolves(array $routeValues) { $this->resolvedUriConstraints = UriConstraints::create(); $this->resolvedTags = RouteTags::createEmpty(); if ($this->uriPattern === null) { return false; } if (!$this->isParsed) { $this->parse(); } $resolvedUriPath = ''; $remainingDefaults = $this->defaults; $requireOptionalRouteParts = false; $matchingOptionalUriPortion = ''; /** @var $routePart RoutePartInterface */ foreach ($this->routeParts as $routePart) { $resolveResult = $routePart->resolve($routeValues); if (!$resolveResult) { if (!$routePart->hasDefaultValue()) { return false; } } if ($resolveResult instanceof ResolveResult) { $hasRoutePartValue = true; $routePartValue = $resolveResult->getResolvedValue(); if ($resolveResult->hasUriConstraints()) { $this->resolvedUriConstraints = $this->resolvedUriConstraints->merge($resolveResult->getUriConstraints()); } if ($resolveResult->hasTags()) { $this->resolvedTags = $this->resolvedTags->merge($resolveResult->getTags()); } } else { $hasRoutePartValue = $routePart->hasValue(); $routePartValue = $hasRoutePartValue ? $routePart->getValue() : null; } if ($routePart->getName() !== null) { $remainingDefaults = Arrays::unsetValueByPath($remainingDefaults, $routePart->getName()); } if ($hasRoutePartValue && !is_string($routePartValue)) { throw new InvalidRoutePartValueException('RoutePart::getValue() must return a string after calling RoutePart::resolve(), got ' . (is_object($routePartValue) ? get_class($routePartValue) : gettype($routePartValue)) . ' for RoutePart "' . get_class($routePart) . '" in Route "' . $this->getName() . '".'); } $routePartDefaultValue = $routePart->getDefaultValue(); if ($routePartDefaultValue !== null && !is_string($routePartDefaultValue)) { throw new InvalidRoutePartValueException('RoutePart::getDefaultValue() must return a string, got ' . (is_object($routePartDefaultValue) ? get_class($routePartDefaultValue) : gettype($routePartDefaultValue)) . ' for RoutePart "' . get_class($routePart) . '" in Route "' . $this->getName() . '".'); } if (!$routePart->isOptional()) { $resolvedUriPath .= $hasRoutePartValue ? $routePartValue : $routePartDefaultValue; $requireOptionalRouteParts = false; continue; } if ($hasRoutePartValue && strtolower($routePartValue) !== strtolower($routePartDefaultValue)) { $matchingOptionalUriPortion .= $routePartValue; $requireOptionalRouteParts = true; } else { $matchingOptionalUriPortion .= $routePartDefaultValue; } if ($requireOptionalRouteParts) { $resolvedUriPath .= $matchingOptionalUriPortion; $matchingOptionalUriPortion = ''; } } if ($this->compareAndRemoveMatchingDefaultValues($remainingDefaults, $routeValues) !== true) { return false; } if (isset($routeValues['@format']) && $routeValues['@format'] === '') { unset($routeValues['@format']); } // add query string if (count($routeValues) > 0) { $routeValues = Arrays::removeEmptyElementsRecursively($routeValues); $routeValues = $this->persistenceManager->convertObjectsToIdentityArrays($routeValues); if (!$this->appendExceedingArguments) { $internalArguments = $this->extractInternalArguments($routeValues); if ($routeValues !== []) { return false; } $routeValues = $internalArguments; } $queryString = http_build_query($routeValues, null, '&'); if ($queryString !== '') { $resolvedUriPath .= strpos($resolvedUriPath, '?') !== false ? '&' . $queryString : '?' . $queryString; } } $this->resolvedUriConstraints = $this->resolvedUriConstraints->withPath($resolvedUriPath); return true; }
php
public function resolves(array $routeValues) { $this->resolvedUriConstraints = UriConstraints::create(); $this->resolvedTags = RouteTags::createEmpty(); if ($this->uriPattern === null) { return false; } if (!$this->isParsed) { $this->parse(); } $resolvedUriPath = ''; $remainingDefaults = $this->defaults; $requireOptionalRouteParts = false; $matchingOptionalUriPortion = ''; /** @var $routePart RoutePartInterface */ foreach ($this->routeParts as $routePart) { $resolveResult = $routePart->resolve($routeValues); if (!$resolveResult) { if (!$routePart->hasDefaultValue()) { return false; } } if ($resolveResult instanceof ResolveResult) { $hasRoutePartValue = true; $routePartValue = $resolveResult->getResolvedValue(); if ($resolveResult->hasUriConstraints()) { $this->resolvedUriConstraints = $this->resolvedUriConstraints->merge($resolveResult->getUriConstraints()); } if ($resolveResult->hasTags()) { $this->resolvedTags = $this->resolvedTags->merge($resolveResult->getTags()); } } else { $hasRoutePartValue = $routePart->hasValue(); $routePartValue = $hasRoutePartValue ? $routePart->getValue() : null; } if ($routePart->getName() !== null) { $remainingDefaults = Arrays::unsetValueByPath($remainingDefaults, $routePart->getName()); } if ($hasRoutePartValue && !is_string($routePartValue)) { throw new InvalidRoutePartValueException('RoutePart::getValue() must return a string after calling RoutePart::resolve(), got ' . (is_object($routePartValue) ? get_class($routePartValue) : gettype($routePartValue)) . ' for RoutePart "' . get_class($routePart) . '" in Route "' . $this->getName() . '".'); } $routePartDefaultValue = $routePart->getDefaultValue(); if ($routePartDefaultValue !== null && !is_string($routePartDefaultValue)) { throw new InvalidRoutePartValueException('RoutePart::getDefaultValue() must return a string, got ' . (is_object($routePartDefaultValue) ? get_class($routePartDefaultValue) : gettype($routePartDefaultValue)) . ' for RoutePart "' . get_class($routePart) . '" in Route "' . $this->getName() . '".'); } if (!$routePart->isOptional()) { $resolvedUriPath .= $hasRoutePartValue ? $routePartValue : $routePartDefaultValue; $requireOptionalRouteParts = false; continue; } if ($hasRoutePartValue && strtolower($routePartValue) !== strtolower($routePartDefaultValue)) { $matchingOptionalUriPortion .= $routePartValue; $requireOptionalRouteParts = true; } else { $matchingOptionalUriPortion .= $routePartDefaultValue; } if ($requireOptionalRouteParts) { $resolvedUriPath .= $matchingOptionalUriPortion; $matchingOptionalUriPortion = ''; } } if ($this->compareAndRemoveMatchingDefaultValues($remainingDefaults, $routeValues) !== true) { return false; } if (isset($routeValues['@format']) && $routeValues['@format'] === '') { unset($routeValues['@format']); } // add query string if (count($routeValues) > 0) { $routeValues = Arrays::removeEmptyElementsRecursively($routeValues); $routeValues = $this->persistenceManager->convertObjectsToIdentityArrays($routeValues); if (!$this->appendExceedingArguments) { $internalArguments = $this->extractInternalArguments($routeValues); if ($routeValues !== []) { return false; } $routeValues = $internalArguments; } $queryString = http_build_query($routeValues, null, '&'); if ($queryString !== '') { $resolvedUriPath .= strpos($resolvedUriPath, '?') !== false ? '&' . $queryString : '?' . $queryString; } } $this->resolvedUriConstraints = $this->resolvedUriConstraints->withPath($resolvedUriPath); return true; }
[ "public", "function", "resolves", "(", "array", "$", "routeValues", ")", "{", "$", "this", "->", "resolvedUriConstraints", "=", "UriConstraints", "::", "create", "(", ")", ";", "$", "this", "->", "resolvedTags", "=", "RouteTags", "::", "createEmpty", "(", ")...
Checks whether $routeValues can be resolved to a corresponding uri. If all Route Parts can resolve one or more of the $routeValues, true is returned and $this->resolvedUriConstraints contains an instance of UriConstraints that can be applied to a template URI transforming it accordingly (@see Router::resolve()) @param array $routeValues An array containing key/value pairs to be resolved to uri segments @return boolean true if this Route corresponds to the given $routeValues, otherwise false @throws InvalidRoutePartValueException
[ "Checks", "whether", "$routeValues", "can", "be", "resolved", "to", "a", "corresponding", "uri", ".", "If", "all", "Route", "Parts", "can", "resolve", "one", "or", "more", "of", "the", "$routeValues", "true", "is", "returned", "and", "$this", "-", ">", "re...
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Mvc/Routing/Route.php#L454-L542
neos/flow-development-collection
Neos.Flow/Classes/Mvc/Routing/Route.php
Route.compareAndRemoveMatchingDefaultValues
protected function compareAndRemoveMatchingDefaultValues(array $defaults, array &$routeValues) { foreach ($defaults as $key => $defaultValue) { if (!isset($routeValues[$key])) { if ($defaultValue === '' || ($key === '@format' && strtolower($defaultValue) === 'html')) { continue; } return false; } if (is_array($defaultValue)) { if (!is_array($routeValues[$key])) { return false; } if ($this->compareAndRemoveMatchingDefaultValues($defaultValue, $routeValues[$key]) === false) { return false; } continue; } elseif (is_array($routeValues[$key])) { return false; } if (strtolower($routeValues[$key]) !== strtolower($defaultValue)) { return false; } unset($routeValues[$key]); } return true; }
php
protected function compareAndRemoveMatchingDefaultValues(array $defaults, array &$routeValues) { foreach ($defaults as $key => $defaultValue) { if (!isset($routeValues[$key])) { if ($defaultValue === '' || ($key === '@format' && strtolower($defaultValue) === 'html')) { continue; } return false; } if (is_array($defaultValue)) { if (!is_array($routeValues[$key])) { return false; } if ($this->compareAndRemoveMatchingDefaultValues($defaultValue, $routeValues[$key]) === false) { return false; } continue; } elseif (is_array($routeValues[$key])) { return false; } if (strtolower($routeValues[$key]) !== strtolower($defaultValue)) { return false; } unset($routeValues[$key]); } return true; }
[ "protected", "function", "compareAndRemoveMatchingDefaultValues", "(", "array", "$", "defaults", ",", "array", "&", "$", "routeValues", ")", "{", "foreach", "(", "$", "defaults", "as", "$", "key", "=>", "$", "defaultValue", ")", "{", "if", "(", "!", "isset",...
Recursively iterates through the defaults of this route. If a route value is equal to a default value, it's removed from $routeValues. If a value exists but is not equal to is corresponding default, iteration is interrupted and false is returned. @param array $defaults @param array $routeValues @return boolean false if one of the $routeValues is not equal to it's default value. Otherwise true
[ "Recursively", "iterates", "through", "the", "defaults", "of", "this", "route", ".", "If", "a", "route", "value", "is", "equal", "to", "a", "default", "value", "it", "s", "removed", "from", "$routeValues", ".", "If", "a", "value", "exists", "but", "is", ...
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Mvc/Routing/Route.php#L555-L581
neos/flow-development-collection
Neos.Flow/Classes/Mvc/Routing/Route.php
Route.extractInternalArguments
protected function extractInternalArguments(array &$arguments) { $internalArguments = []; foreach ($arguments as $argumentKey => &$argumentValue) { if (substr($argumentKey, 0, 2) === '__') { $internalArguments[$argumentKey] = $argumentValue; unset($arguments[$argumentKey]); continue; } if (substr($argumentKey, 0, 2) === '--' && is_array($argumentValue)) { $internalArguments[$argumentKey] = $this->extractInternalArguments($argumentValue); if ($internalArguments[$argumentKey] === []) { unset($internalArguments[$argumentKey]); } if ($argumentValue === []) { unset($arguments[$argumentKey]); } } } return $internalArguments; }
php
protected function extractInternalArguments(array &$arguments) { $internalArguments = []; foreach ($arguments as $argumentKey => &$argumentValue) { if (substr($argumentKey, 0, 2) === '__') { $internalArguments[$argumentKey] = $argumentValue; unset($arguments[$argumentKey]); continue; } if (substr($argumentKey, 0, 2) === '--' && is_array($argumentValue)) { $internalArguments[$argumentKey] = $this->extractInternalArguments($argumentValue); if ($internalArguments[$argumentKey] === []) { unset($internalArguments[$argumentKey]); } if ($argumentValue === []) { unset($arguments[$argumentKey]); } } } return $internalArguments; }
[ "protected", "function", "extractInternalArguments", "(", "array", "&", "$", "arguments", ")", "{", "$", "internalArguments", "=", "[", "]", ";", "foreach", "(", "$", "arguments", "as", "$", "argumentKey", "=>", "&", "$", "argumentValue", ")", "{", "if", "...
Removes all internal arguments (prefixed with two underscores) from the given $arguments and returns them as array @param array $arguments @return array the internal arguments
[ "Removes", "all", "internal", "arguments", "(", "prefixed", "with", "two", "underscores", ")", "from", "the", "given", "$arguments", "and", "returns", "them", "as", "array" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Mvc/Routing/Route.php#L590-L610
neos/flow-development-collection
Neos.Flow/Classes/Mvc/Routing/Route.php
Route.containsObject
protected function containsObject($subject) { if (is_object($subject)) { return true; } if (!is_array($subject)) { return false; } foreach ($subject as $value) { if ($this->containsObject($value)) { return true; } } return false; }
php
protected function containsObject($subject) { if (is_object($subject)) { return true; } if (!is_array($subject)) { return false; } foreach ($subject as $value) { if ($this->containsObject($value)) { return true; } } return false; }
[ "protected", "function", "containsObject", "(", "$", "subject", ")", "{", "if", "(", "is_object", "(", "$", "subject", ")", ")", "{", "return", "true", ";", "}", "if", "(", "!", "is_array", "(", "$", "subject", ")", ")", "{", "return", "false", ";", ...
Checks if the given subject contains an object @param mixed $subject @return boolean If it contains an object or not
[ "Checks", "if", "the", "given", "subject", "contains", "an", "object" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Mvc/Routing/Route.php#L618-L632
neos/flow-development-collection
Neos.Flow/Classes/Mvc/Routing/Route.php
Route.parse
public function parse() { if ($this->isParsed || $this->uriPattern === null || $this->uriPattern === '') { return; } $this->routeParts = []; $currentRoutePartIsOptional = false; if (substr($this->uriPattern, -1) === '/') { throw new InvalidUriPatternException('The URI pattern "' . $this->uriPattern . '" of route "' . $this->getName() . '" ends with a slash, which is not allowed. You can put the trailing slash in brackets to make it optional.', 1234782997); } if ($this->uriPattern[0] === '/') { throw new InvalidUriPatternException('The URI pattern "' . $this->uriPattern . '" of route "' . $this->getName() . '" starts with a slash, which is not allowed.', 1234782983); } $matches = []; preg_match_all(self::PATTERN_EXTRACTROUTEPARTS, $this->uriPattern, $matches, PREG_SET_ORDER); /** @var $lastRoutePart RoutePartInterface */ $lastRoutePart = null; foreach ($matches as $match) { $routePartType = empty($match['dynamic']) ? self::ROUTEPART_TYPE_STATIC : self::ROUTEPART_TYPE_DYNAMIC; $routePartName = $match['content']; if (!empty($match['optionalStart'])) { if ($lastRoutePart !== null && $lastRoutePart->isOptional()) { throw new InvalidUriPatternException('the URI pattern "' . $this->uriPattern . '" of route "' . $this->getName() . '" contains successive optional Route sections, which is not allowed.', 1234562050); } $currentRoutePartIsOptional = true; } $routePart = null; switch ($routePartType) { case self::ROUTEPART_TYPE_DYNAMIC: if ($lastRoutePart instanceof DynamicRoutePartInterface) { throw new InvalidUriPatternException('the URI pattern "' . $this->uriPattern . '" of route "' . $this->getName() . '" contains successive Dynamic Route Parts, which is not allowed.', 1218446975); } if (isset($this->routePartsConfiguration[$routePartName]['handler'])) { $routePart = $this->objectManager->get($this->routePartsConfiguration[$routePartName]['handler']); if (!$routePart instanceof DynamicRoutePartInterface) { throw new InvalidRoutePartHandlerException(sprintf('routePart handlers must implement "%s" in route "%s"', DynamicRoutePartInterface::class, $this->getName()), 1218480972); } } elseif (isset($this->routePartsConfiguration[$routePartName]['objectType'])) { $routePart = new IdentityRoutePart(); $routePart->setObjectType($this->routePartsConfiguration[$routePartName]['objectType']); if (isset($this->routePartsConfiguration[$routePartName]['uriPattern'])) { $routePart->setUriPattern($this->routePartsConfiguration[$routePartName]['uriPattern']); } } else { $routePart = new DynamicRoutePart(); } $routePartDefaultValue = ObjectAccess::getPropertyPath($this->defaults, $routePartName); if ($routePartDefaultValue !== null) { $routePart->setDefaultValue($routePartDefaultValue); } break; case self::ROUTEPART_TYPE_STATIC: $routePart = new StaticRoutePart(); if ($lastRoutePart !== null && $lastRoutePart instanceof DynamicRoutePartInterface) { /** @var DynamicRoutePartInterface $lastRoutePart */ $lastRoutePart->setSplitString($routePartName); } } $routePart->setName($routePartName); if ($currentRoutePartIsOptional) { $routePart->setOptional(true); if ($routePart instanceof DynamicRoutePartInterface && !$routePart->hasDefaultValue()) { throw new InvalidRouteSetupException(sprintf('There is no default value specified for the optional route part "{%s}" of route "%s", but all dynamic optional route parts need a default.', $routePartName, $this->getName()), 1477140679); } } $routePart->setLowerCase($this->lowerCase); if (isset($this->routePartsConfiguration[$routePartName]['options'])) { $routePart->setOptions($this->routePartsConfiguration[$routePartName]['options']); } if (isset($this->routePartsConfiguration[$routePartName]['toLowerCase'])) { $routePart->setLowerCase($this->routePartsConfiguration[$routePartName]['toLowerCase']); } $this->routeParts[] = $routePart; if (!empty($match['optionalEnd'])) { if (!$currentRoutePartIsOptional) { throw new InvalidUriPatternException('The URI pattern "' . $this->uriPattern . '" of route "' . $this->getName() . '" contains an unopened optional section.', 1234564495); } $currentRoutePartIsOptional = false; } $lastRoutePart = $routePart; } if ($currentRoutePartIsOptional) { throw new InvalidUriPatternException('The URI pattern "' . $this->uriPattern . '" of route "' . $this->getName() . '" contains an unterminated optional section.', 1234563922); } $this->isParsed = true; }
php
public function parse() { if ($this->isParsed || $this->uriPattern === null || $this->uriPattern === '') { return; } $this->routeParts = []; $currentRoutePartIsOptional = false; if (substr($this->uriPattern, -1) === '/') { throw new InvalidUriPatternException('The URI pattern "' . $this->uriPattern . '" of route "' . $this->getName() . '" ends with a slash, which is not allowed. You can put the trailing slash in brackets to make it optional.', 1234782997); } if ($this->uriPattern[0] === '/') { throw new InvalidUriPatternException('The URI pattern "' . $this->uriPattern . '" of route "' . $this->getName() . '" starts with a slash, which is not allowed.', 1234782983); } $matches = []; preg_match_all(self::PATTERN_EXTRACTROUTEPARTS, $this->uriPattern, $matches, PREG_SET_ORDER); /** @var $lastRoutePart RoutePartInterface */ $lastRoutePart = null; foreach ($matches as $match) { $routePartType = empty($match['dynamic']) ? self::ROUTEPART_TYPE_STATIC : self::ROUTEPART_TYPE_DYNAMIC; $routePartName = $match['content']; if (!empty($match['optionalStart'])) { if ($lastRoutePart !== null && $lastRoutePart->isOptional()) { throw new InvalidUriPatternException('the URI pattern "' . $this->uriPattern . '" of route "' . $this->getName() . '" contains successive optional Route sections, which is not allowed.', 1234562050); } $currentRoutePartIsOptional = true; } $routePart = null; switch ($routePartType) { case self::ROUTEPART_TYPE_DYNAMIC: if ($lastRoutePart instanceof DynamicRoutePartInterface) { throw new InvalidUriPatternException('the URI pattern "' . $this->uriPattern . '" of route "' . $this->getName() . '" contains successive Dynamic Route Parts, which is not allowed.', 1218446975); } if (isset($this->routePartsConfiguration[$routePartName]['handler'])) { $routePart = $this->objectManager->get($this->routePartsConfiguration[$routePartName]['handler']); if (!$routePart instanceof DynamicRoutePartInterface) { throw new InvalidRoutePartHandlerException(sprintf('routePart handlers must implement "%s" in route "%s"', DynamicRoutePartInterface::class, $this->getName()), 1218480972); } } elseif (isset($this->routePartsConfiguration[$routePartName]['objectType'])) { $routePart = new IdentityRoutePart(); $routePart->setObjectType($this->routePartsConfiguration[$routePartName]['objectType']); if (isset($this->routePartsConfiguration[$routePartName]['uriPattern'])) { $routePart->setUriPattern($this->routePartsConfiguration[$routePartName]['uriPattern']); } } else { $routePart = new DynamicRoutePart(); } $routePartDefaultValue = ObjectAccess::getPropertyPath($this->defaults, $routePartName); if ($routePartDefaultValue !== null) { $routePart->setDefaultValue($routePartDefaultValue); } break; case self::ROUTEPART_TYPE_STATIC: $routePart = new StaticRoutePart(); if ($lastRoutePart !== null && $lastRoutePart instanceof DynamicRoutePartInterface) { /** @var DynamicRoutePartInterface $lastRoutePart */ $lastRoutePart->setSplitString($routePartName); } } $routePart->setName($routePartName); if ($currentRoutePartIsOptional) { $routePart->setOptional(true); if ($routePart instanceof DynamicRoutePartInterface && !$routePart->hasDefaultValue()) { throw new InvalidRouteSetupException(sprintf('There is no default value specified for the optional route part "{%s}" of route "%s", but all dynamic optional route parts need a default.', $routePartName, $this->getName()), 1477140679); } } $routePart->setLowerCase($this->lowerCase); if (isset($this->routePartsConfiguration[$routePartName]['options'])) { $routePart->setOptions($this->routePartsConfiguration[$routePartName]['options']); } if (isset($this->routePartsConfiguration[$routePartName]['toLowerCase'])) { $routePart->setLowerCase($this->routePartsConfiguration[$routePartName]['toLowerCase']); } $this->routeParts[] = $routePart; if (!empty($match['optionalEnd'])) { if (!$currentRoutePartIsOptional) { throw new InvalidUriPatternException('The URI pattern "' . $this->uriPattern . '" of route "' . $this->getName() . '" contains an unopened optional section.', 1234564495); } $currentRoutePartIsOptional = false; } $lastRoutePart = $routePart; } if ($currentRoutePartIsOptional) { throw new InvalidUriPatternException('The URI pattern "' . $this->uriPattern . '" of route "' . $this->getName() . '" contains an unterminated optional section.', 1234563922); } $this->isParsed = true; }
[ "public", "function", "parse", "(", ")", "{", "if", "(", "$", "this", "->", "isParsed", "||", "$", "this", "->", "uriPattern", "===", "null", "||", "$", "this", "->", "uriPattern", "===", "''", ")", "{", "return", ";", "}", "$", "this", "->", "rout...
Iterates through all segments in $this->uriPattern and creates appropriate RoutePart instances. @return void @throws InvalidRoutePartHandlerException|InvalidRouteSetupException|InvalidUriPatternException
[ "Iterates", "through", "all", "segments", "in", "$this", "-", ">", "uriPattern", "and", "creates", "appropriate", "RoutePart", "instances", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Mvc/Routing/Route.php#L641-L729
neos/flow-development-collection
Neos.Flow/Classes/Property/TypeConverter/ArrayConverter.php
ArrayConverter.convertFrom
public function convertFrom($source, $targetType, array $convertedChildProperties = [], PropertyMappingConfigurationInterface $configuration = null) { if (is_array($source)) { return $source; } if (is_string($source)) { if ($source === '') { return []; } else { $stringFormat = $this->getStringFormat($configuration); switch ($stringFormat) { case self::STRING_FORMAT_CSV: return explode($this->getStringDelimiter($configuration), $source); case self::STRING_FORMAT_JSON: return json_decode($source, true); default: throw new InvalidPropertyMappingConfigurationException(sprintf('Conversion from string to array failed due to invalid string format setting "%s"', $stringFormat), 1404903208); } } } if ($source instanceof PersistentResource) { $exportType = $this->getResourceExportType($configuration); switch ($exportType) { case self::RESOURCE_EXPORT_TYPE_BASE64: return [ 'filename' => $source->getFilename(), 'data' => base64_encode(file_get_contents('resource://' . $source->getSha1())), 'collectionName' => $source->getCollectionName(), 'relativePublicationPath' => $source->getRelativePublicationPath(), 'mediaType' => $source->getMediaType(), 'sha1' => $source->getSha1() // to avoid having to compute it from the data and/or for checking transmitted data ]; case self::RESOURCE_EXPORT_TYPE_FILE: $sourceStream = $source->getStream(); if ($sourceStream === false) { throw new InvalidSourceException(sprintf('Could not get stream of resource "%s" (%s). This might be caused by a broken resource object and can be fixed by running the "resource:clean" command.', $source->getFilename(), $source->getSha1()), 1435842312); } $targetStream = fopen($configuration->getConfigurationValue(ArrayConverter::class, self::CONFIGURATION_RESOURCE_SAVE_PATH) . '/' . $source->getSha1(), 'w'); stream_copy_to_stream($sourceStream, $targetStream); fclose($targetStream); fclose($sourceStream); return [ 'filename' => $source->getFilename(), 'collectionName' => $source->getCollectionName(), 'relativePublicationPath' => $source->getRelativePublicationPath(), 'mediaType' => $source->getMediaType(), 'sha1' => $source->getSha1(), // to avoid having to compute it from the data and/or for checking transmitted data 'hash' => $source->getSha1() ]; default: throw new InvalidPropertyMappingConfigurationException(sprintf('Conversion from PersistentResource to array failed due to invalid resource export type setting "%s"', $exportType), 1404903210); } } throw new TypeConverterException('Conversion to array failed for unknown reason', 1404903387); }
php
public function convertFrom($source, $targetType, array $convertedChildProperties = [], PropertyMappingConfigurationInterface $configuration = null) { if (is_array($source)) { return $source; } if (is_string($source)) { if ($source === '') { return []; } else { $stringFormat = $this->getStringFormat($configuration); switch ($stringFormat) { case self::STRING_FORMAT_CSV: return explode($this->getStringDelimiter($configuration), $source); case self::STRING_FORMAT_JSON: return json_decode($source, true); default: throw new InvalidPropertyMappingConfigurationException(sprintf('Conversion from string to array failed due to invalid string format setting "%s"', $stringFormat), 1404903208); } } } if ($source instanceof PersistentResource) { $exportType = $this->getResourceExportType($configuration); switch ($exportType) { case self::RESOURCE_EXPORT_TYPE_BASE64: return [ 'filename' => $source->getFilename(), 'data' => base64_encode(file_get_contents('resource://' . $source->getSha1())), 'collectionName' => $source->getCollectionName(), 'relativePublicationPath' => $source->getRelativePublicationPath(), 'mediaType' => $source->getMediaType(), 'sha1' => $source->getSha1() // to avoid having to compute it from the data and/or for checking transmitted data ]; case self::RESOURCE_EXPORT_TYPE_FILE: $sourceStream = $source->getStream(); if ($sourceStream === false) { throw new InvalidSourceException(sprintf('Could not get stream of resource "%s" (%s). This might be caused by a broken resource object and can be fixed by running the "resource:clean" command.', $source->getFilename(), $source->getSha1()), 1435842312); } $targetStream = fopen($configuration->getConfigurationValue(ArrayConverter::class, self::CONFIGURATION_RESOURCE_SAVE_PATH) . '/' . $source->getSha1(), 'w'); stream_copy_to_stream($sourceStream, $targetStream); fclose($targetStream); fclose($sourceStream); return [ 'filename' => $source->getFilename(), 'collectionName' => $source->getCollectionName(), 'relativePublicationPath' => $source->getRelativePublicationPath(), 'mediaType' => $source->getMediaType(), 'sha1' => $source->getSha1(), // to avoid having to compute it from the data and/or for checking transmitted data 'hash' => $source->getSha1() ]; default: throw new InvalidPropertyMappingConfigurationException(sprintf('Conversion from PersistentResource to array failed due to invalid resource export type setting "%s"', $exportType), 1404903210); } } throw new TypeConverterException('Conversion to array failed for unknown reason', 1404903387); }
[ "public", "function", "convertFrom", "(", "$", "source", ",", "$", "targetType", ",", "array", "$", "convertedChildProperties", "=", "[", "]", ",", "PropertyMappingConfigurationInterface", "$", "configuration", "=", "null", ")", "{", "if", "(", "is_array", "(", ...
Convert from $source to $targetType, a noop if the source is an array. If it is a string it will be converted according to the configured string format. @param mixed $source @param string $targetType @param array $convertedChildProperties @param PropertyMappingConfigurationInterface $configuration @return array @throws InvalidPropertyMappingConfigurationException @throws InvalidSourceException @throws TypeConverterException @api
[ "Convert", "from", "$source", "to", "$targetType", "a", "noop", "if", "the", "source", "is", "an", "array", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Property/TypeConverter/ArrayConverter.php#L123-L181
neos/flow-development-collection
Neos.Flow/Classes/Session/TransientSession.php
TransientSession.getData
public function getData($key) { if ($this->started !== true) { throw new Exception\SessionNotStartedException('The session has not been started yet.', 1218034660); } return (array_key_exists($key, $this->data)) ? $this->data[$key] : null; }
php
public function getData($key) { if ($this->started !== true) { throw new Exception\SessionNotStartedException('The session has not been started yet.', 1218034660); } return (array_key_exists($key, $this->data)) ? $this->data[$key] : null; }
[ "public", "function", "getData", "(", "$", "key", ")", "{", "if", "(", "$", "this", "->", "started", "!==", "true", ")", "{", "throw", "new", "Exception", "\\", "SessionNotStartedException", "(", "'The session has not been started yet.'", ",", "1218034660", ")",...
Returns the data associated with the given key. @param string $key An identifier for the content stored in the session. @return mixed The data associated with the given key or NULL @throws Exception\SessionNotStartedException
[ "Returns", "the", "data", "associated", "with", "the", "given", "key", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Session/TransientSession.php#L135-L141
neos/flow-development-collection
Neos.Flow/Classes/Session/TransientSession.php
TransientSession.putData
public function putData($key, $data) { if ($this->started !== true) { throw new Exception\SessionNotStartedException('The session has not been started yet.', 1218034661); } $this->data[$key] = $data; }
php
public function putData($key, $data) { if ($this->started !== true) { throw new Exception\SessionNotStartedException('The session has not been started yet.', 1218034661); } $this->data[$key] = $data; }
[ "public", "function", "putData", "(", "$", "key", ",", "$", "data", ")", "{", "if", "(", "$", "this", "->", "started", "!==", "true", ")", "{", "throw", "new", "Exception", "\\", "SessionNotStartedException", "(", "'The session has not been started yet.'", ","...
Stores the given data under the given key in the session @param string $key The key under which the data should be stored @param object $data The data to be stored @return void @throws Exception\SessionNotStartedException
[ "Stores", "the", "given", "data", "under", "the", "given", "key", "in", "the", "session" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Session/TransientSession.php#L162-L168
neos/flow-development-collection
Neos.Flow/Classes/Session/TransientSession.php
TransientSession.destroy
public function destroy($reason = null) { if ($this->started !== true) { throw new Exception\SessionNotStartedException('The session has not been started yet.', 1218034663); } $this->data = []; $this->started = false; }
php
public function destroy($reason = null) { if ($this->started !== true) { throw new Exception\SessionNotStartedException('The session has not been started yet.', 1218034663); } $this->data = []; $this->started = false; }
[ "public", "function", "destroy", "(", "$", "reason", "=", "null", ")", "{", "if", "(", "$", "this", "->", "started", "!==", "true", ")", "{", "throw", "new", "Exception", "\\", "SessionNotStartedException", "(", "'The session has not been started yet.'", ",", ...
Explicitly destroys all session data @param string $reason A reason for destroying the session – used by the LoggingAspect @return void @throws Exception\SessionNotStartedException
[ "Explicitly", "destroys", "all", "session", "data" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Session/TransientSession.php#L191-L198
neos/flow-development-collection
Neos.Flow/Classes/Session/TransientSession.php
TransientSession.addTag
public function addTag($tag) { if ($this->started !== true) { throw new Exception\SessionNotStartedException('The session has not been started yet.', 1422551048); } $this->tags[$tag] = true; }
php
public function addTag($tag) { if ($this->started !== true) { throw new Exception\SessionNotStartedException('The session has not been started yet.', 1422551048); } $this->tags[$tag] = true; }
[ "public", "function", "addTag", "(", "$", "tag", ")", "{", "if", "(", "$", "this", "->", "started", "!==", "true", ")", "{", "throw", "new", "Exception", "\\", "SessionNotStartedException", "(", "'The session has not been started yet.'", ",", "1422551048", ")", ...
Tags this session with the given tag. Note that third-party libraries might also tag your session. Therefore it is recommended to use namespaced tags such as "Acme-Demo-MySpecialTag". @param string $tag The tag – must match be a valid cache frontend tag @return void @throws Exception\SessionNotStartedException @throws \InvalidArgumentException @api
[ "Tags", "this", "session", "with", "the", "given", "tag", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Session/TransientSession.php#L255-L261
neos/flow-development-collection
Neos.Flow/Classes/Session/TransientSession.php
TransientSession.removeTag
public function removeTag($tag) { if ($this->started !== true) { throw new Exception\SessionNotStartedException('The session has not been started yet.', 1422551049); } if (isset($this->tags[$tag])) { unset($this->tags[$tag]); } }
php
public function removeTag($tag) { if ($this->started !== true) { throw new Exception\SessionNotStartedException('The session has not been started yet.', 1422551049); } if (isset($this->tags[$tag])) { unset($this->tags[$tag]); } }
[ "public", "function", "removeTag", "(", "$", "tag", ")", "{", "if", "(", "$", "this", "->", "started", "!==", "true", ")", "{", "throw", "new", "Exception", "\\", "SessionNotStartedException", "(", "'The session has not been started yet.'", ",", "1422551049", ")...
Removes the specified tag from this session. @param string $tag The tag – must match be a valid cache frontend tag @return void @throws Exception\SessionNotStartedException @api
[ "Removes", "the", "specified", "tag", "from", "this", "session", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Session/TransientSession.php#L271-L279
neos/flow-development-collection
Neos.Flow/Classes/Core/LockManager.php
LockManager.lockSiteOrExit
public function lockSiteOrExit() { touch($this->lockFlagPathAndFilename); $this->lockResource = fopen($this->lockPathAndFilename, 'w+'); if (!flock($this->lockResource, LOCK_EX | LOCK_NB)) { fclose($this->lockResource); $this->doExit(); } }
php
public function lockSiteOrExit() { touch($this->lockFlagPathAndFilename); $this->lockResource = fopen($this->lockPathAndFilename, 'w+'); if (!flock($this->lockResource, LOCK_EX | LOCK_NB)) { fclose($this->lockResource); $this->doExit(); } }
[ "public", "function", "lockSiteOrExit", "(", ")", "{", "touch", "(", "$", "this", "->", "lockFlagPathAndFilename", ")", ";", "$", "this", "->", "lockResource", "=", "fopen", "(", "$", "this", "->", "lockPathAndFilename", ",", "'w+'", ")", ";", "if", "(", ...
Locks the site for further requests. @return void @api
[ "Locks", "the", "site", "for", "further", "requests", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Core/LockManager.php#L115-L123
neos/flow-development-collection
Neos.Flow/Classes/Core/LockManager.php
LockManager.unlockSite
public function unlockSite() { if (is_resource($this->lockResource)) { flock($this->lockResource, LOCK_UN); fclose($this->lockResource); unlink($this->lockPathAndFilename); } @unlink($this->lockFlagPathAndFilename); }
php
public function unlockSite() { if (is_resource($this->lockResource)) { flock($this->lockResource, LOCK_UN); fclose($this->lockResource); unlink($this->lockPathAndFilename); } @unlink($this->lockFlagPathAndFilename); }
[ "public", "function", "unlockSite", "(", ")", "{", "if", "(", "is_resource", "(", "$", "this", "->", "lockResource", ")", ")", "{", "flock", "(", "$", "this", "->", "lockResource", ",", "LOCK_UN", ")", ";", "fclose", "(", "$", "this", "->", "lockResour...
Unlocks the site if this request has locked it. @return void @api
[ "Unlocks", "the", "site", "if", "this", "request", "has", "locked", "it", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Core/LockManager.php#L131-L139
neos/flow-development-collection
Neos.Flow/Classes/Core/LockManager.php
LockManager.doExit
protected function doExit() { if (FLOW_SAPITYPE === 'Web') { header('HTTP/1.1 503 Service Temporarily Unavailable'); readfile($this->lockHoldingPage); } else { $expiresIn = abs((time() - self::LOCKFILE_MAXIMUM_AGE - filemtime($this->lockFlagPathAndFilename))); echo 'Site is currently locked, exiting.' . PHP_EOL . 'The current lock will expire after ' . $expiresIn . ' seconds.' . PHP_EOL; } exit(1); }
php
protected function doExit() { if (FLOW_SAPITYPE === 'Web') { header('HTTP/1.1 503 Service Temporarily Unavailable'); readfile($this->lockHoldingPage); } else { $expiresIn = abs((time() - self::LOCKFILE_MAXIMUM_AGE - filemtime($this->lockFlagPathAndFilename))); echo 'Site is currently locked, exiting.' . PHP_EOL . 'The current lock will expire after ' . $expiresIn . ' seconds.' . PHP_EOL; } exit(1); }
[ "protected", "function", "doExit", "(", ")", "{", "if", "(", "FLOW_SAPITYPE", "===", "'Web'", ")", "{", "header", "(", "'HTTP/1.1 503 Service Temporarily Unavailable'", ")", ";", "readfile", "(", "$", "this", "->", "lockHoldingPage", ")", ";", "}", "else", "{"...
Exit and emit a message about the reason. @return void
[ "Exit", "and", "emit", "a", "message", "about", "the", "reason", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Core/LockManager.php#L146-L156
neos/flow-development-collection
Neos.Flow/Classes/Security/Authorization/PrivilegeManager.php
PrivilegeManager.isGranted
public function isGranted($privilegeType, $subject, &$reason = '') { return $this->isGrantedForRoles($this->securityContext->getRoles(), $privilegeType, $subject, $reason); }
php
public function isGranted($privilegeType, $subject, &$reason = '') { return $this->isGrantedForRoles($this->securityContext->getRoles(), $privilegeType, $subject, $reason); }
[ "public", "function", "isGranted", "(", "$", "privilegeType", ",", "$", "subject", ",", "&", "$", "reason", "=", "''", ")", "{", "return", "$", "this", "->", "isGrantedForRoles", "(", "$", "this", "->", "securityContext", "->", "getRoles", "(", ")", ",",...
Returns true, if the given privilege type is granted for the given subject based on the current security context. @param string $privilegeType The type of privilege that should be evaluated @param mixed $subject The subject to check privileges for @param string $reason This variable will be filled by a message giving information about the reasons for the result of this method @return boolean
[ "Returns", "true", "if", "the", "given", "privilege", "type", "is", "granted", "for", "the", "given", "subject", "based", "on", "the", "current", "security", "context", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Authorization/PrivilegeManager.php#L64-L67
neos/flow-development-collection
Neos.Flow/Classes/Security/Authorization/PrivilegeManager.php
PrivilegeManager.isGrantedForRoles
public function isGrantedForRoles(array $roles, $privilegeType, $subject, &$reason = '') { $availablePrivileges = array_reduce($roles, $this->getPrivilegeByTypeReducer($privilegeType), []); $effectivePrivileges = array_filter($availablePrivileges, $this->getPrivilegeSubjectFilter($subject)); /** @var PrivilegePermissionResult $result */ $result = array_reduce($effectivePrivileges, [$this, 'applyPrivilegeToResult'], new PrivilegePermissionResult()); $effectivePrivilegeIdentifiersWithPermission = $result->getEffectivePrivilegeIdentifiersWithPermission(); if ($effectivePrivilegeIdentifiersWithPermission === []) { $reason = sprintf('No privilege of type "%s" matched.', $privilegeType); return true; } $reason = sprintf('Evaluated following %d privilege target(s):' . chr(10) . '%s' . chr(10) . '(%d granted, %d denied, %d abstained)', count($effectivePrivilegeIdentifiersWithPermission), implode(chr(10), $effectivePrivilegeIdentifiersWithPermission), $result->getGrants(), $result->getDenies(), $result->getAbstains() ); if ($result->getDenies() > 0) { return false; } if ($result->getGrants() > 0) { return true; } return false; }
php
public function isGrantedForRoles(array $roles, $privilegeType, $subject, &$reason = '') { $availablePrivileges = array_reduce($roles, $this->getPrivilegeByTypeReducer($privilegeType), []); $effectivePrivileges = array_filter($availablePrivileges, $this->getPrivilegeSubjectFilter($subject)); /** @var PrivilegePermissionResult $result */ $result = array_reduce($effectivePrivileges, [$this, 'applyPrivilegeToResult'], new PrivilegePermissionResult()); $effectivePrivilegeIdentifiersWithPermission = $result->getEffectivePrivilegeIdentifiersWithPermission(); if ($effectivePrivilegeIdentifiersWithPermission === []) { $reason = sprintf('No privilege of type "%s" matched.', $privilegeType); return true; } $reason = sprintf('Evaluated following %d privilege target(s):' . chr(10) . '%s' . chr(10) . '(%d granted, %d denied, %d abstained)', count($effectivePrivilegeIdentifiersWithPermission), implode(chr(10), $effectivePrivilegeIdentifiersWithPermission), $result->getGrants(), $result->getDenies(), $result->getAbstains() ); if ($result->getDenies() > 0) { return false; } if ($result->getGrants() > 0) { return true; } return false; }
[ "public", "function", "isGrantedForRoles", "(", "array", "$", "roles", ",", "$", "privilegeType", ",", "$", "subject", ",", "&", "$", "reason", "=", "''", ")", "{", "$", "availablePrivileges", "=", "array_reduce", "(", "$", "roles", ",", "$", "this", "->...
Returns true, if the given privilege type would be granted for the given roles and subject @param array<Role> $roles The roles that should be evaluated @param string $privilegeType The type of privilege that should be evaluated @param mixed $subject The subject to check privileges for @param string $reason This variable will be filled by a message giving information about the reasons for the result of this method @return boolean
[ "Returns", "true", "if", "the", "given", "privilege", "type", "would", "be", "granted", "for", "the", "given", "roles", "and", "subject" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Authorization/PrivilegeManager.php#L78-L107
neos/flow-development-collection
Neos.Flow/Classes/Security/Authorization/PrivilegeManager.php
PrivilegeManager.isPrivilegeTargetGranted
public function isPrivilegeTargetGranted($privilegeTargetIdentifier, array $privilegeParameters = []) { return $this->isPrivilegeTargetGrantedForRoles($this->securityContext->getRoles(), $privilegeTargetIdentifier, $privilegeParameters); }
php
public function isPrivilegeTargetGranted($privilegeTargetIdentifier, array $privilegeParameters = []) { return $this->isPrivilegeTargetGrantedForRoles($this->securityContext->getRoles(), $privilegeTargetIdentifier, $privilegeParameters); }
[ "public", "function", "isPrivilegeTargetGranted", "(", "$", "privilegeTargetIdentifier", ",", "array", "$", "privilegeParameters", "=", "[", "]", ")", "{", "return", "$", "this", "->", "isPrivilegeTargetGrantedForRoles", "(", "$", "this", "->", "securityContext", "-...
Returns true if access is granted on the given privilege target in the current security context @param string $privilegeTargetIdentifier The identifier of the privilege target to decide on @param array $privilegeParameters Optional array of privilege parameters (simple key => value array) @return boolean true if access is granted, false otherwise
[ "Returns", "true", "if", "access", "is", "granted", "on", "the", "given", "privilege", "target", "in", "the", "current", "security", "context" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Authorization/PrivilegeManager.php#L116-L119
neos/flow-development-collection
Neos.Flow/Classes/Security/Authorization/PrivilegeManager.php
PrivilegeManager.isPrivilegeTargetGrantedForRoles
public function isPrivilegeTargetGrantedForRoles(array $roles, $privilegeTargetIdentifier, array $privilegeParameters = []) { $privilegeMapper = function (Role $role) use ($privilegeTargetIdentifier, $privilegeParameters) { return $role->getPrivilegeForTarget($privilegeTargetIdentifier, $privilegeParameters); }; $privileges = array_map($privilegeMapper, $roles); /** @var PrivilegePermissionResult $result */ $result = array_reduce($privileges, [$this, 'applyPrivilegeToResult'], new PrivilegePermissionResult()); if ($result->getDenies() === 0 && $result->getGrants() > 0) { return true; } $privilegeFound = $privileges !== []; if ($result->getDenies() === 0 && $result->getGrants() === 0 && $privilegeFound === true && $this->allowAccessIfAllAbstain === true) { return true; } return false; }
php
public function isPrivilegeTargetGrantedForRoles(array $roles, $privilegeTargetIdentifier, array $privilegeParameters = []) { $privilegeMapper = function (Role $role) use ($privilegeTargetIdentifier, $privilegeParameters) { return $role->getPrivilegeForTarget($privilegeTargetIdentifier, $privilegeParameters); }; $privileges = array_map($privilegeMapper, $roles); /** @var PrivilegePermissionResult $result */ $result = array_reduce($privileges, [$this, 'applyPrivilegeToResult'], new PrivilegePermissionResult()); if ($result->getDenies() === 0 && $result->getGrants() > 0) { return true; } $privilegeFound = $privileges !== []; if ($result->getDenies() === 0 && $result->getGrants() === 0 && $privilegeFound === true && $this->allowAccessIfAllAbstain === true) { return true; } return false; }
[ "public", "function", "isPrivilegeTargetGrantedForRoles", "(", "array", "$", "roles", ",", "$", "privilegeTargetIdentifier", ",", "array", "$", "privilegeParameters", "=", "[", "]", ")", "{", "$", "privilegeMapper", "=", "function", "(", "Role", "$", "role", ")"...
Returns true if access is granted on the given privilege target in the current security context @param array<Role> $roles The roles that should be evaluated @param string $privilegeTargetIdentifier The identifier of the privilege target to decide on @param array $privilegeParameters Optional array of privilege parameters (simple key => value array) @return boolean true if access is granted, false otherwise
[ "Returns", "true", "if", "access", "is", "granted", "on", "the", "given", "privilege", "target", "in", "the", "current", "security", "context" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Authorization/PrivilegeManager.php#L129-L149
neos/flow-development-collection
Neos.Eel/Classes/FlowQuery/Operations/LastOperation.php
LastOperation.evaluate
public function evaluate(FlowQuery $flowQuery, array $arguments) { $context = $flowQuery->getContext(); if (count($context) > 0) { $flowQuery->setContext([end($context)]); } else { $flowQuery->setContext([]); } }
php
public function evaluate(FlowQuery $flowQuery, array $arguments) { $context = $flowQuery->getContext(); if (count($context) > 0) { $flowQuery->setContext([end($context)]); } else { $flowQuery->setContext([]); } }
[ "public", "function", "evaluate", "(", "FlowQuery", "$", "flowQuery", ",", "array", "$", "arguments", ")", "{", "$", "context", "=", "$", "flowQuery", "->", "getContext", "(", ")", ";", "if", "(", "count", "(", "$", "context", ")", ">", "0", ")", "{"...
{@inheritdoc} @param FlowQuery $flowQuery the FlowQuery object @param array $arguments Ignored for this operation @return void
[ "{", "@inheritdoc", "}" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Eel/Classes/FlowQuery/Operations/LastOperation.php#L35-L43
neos/flow-development-collection
Neos.Flow/Classes/Http/AbstractMessage.php
AbstractMessage.setHeader
public function setHeader($name, $values, $replaceExistingHeader = true) { switch ($name) { case 'Content-Type': if (is_array($values)) { if (count($values) !== 1) { throw new \InvalidArgumentException('The "Content-Type" header must be unique and thus only one field value may be specified.', 1454949291); } $values = (string) $values[0]; } if (stripos($values, 'charset') === false && stripos($values, 'text/') === 0) { $values .= '; charset=' . $this->charset; } break; } $this->headers->set($name, $values, $replaceExistingHeader); return $this; }
php
public function setHeader($name, $values, $replaceExistingHeader = true) { switch ($name) { case 'Content-Type': if (is_array($values)) { if (count($values) !== 1) { throw new \InvalidArgumentException('The "Content-Type" header must be unique and thus only one field value may be specified.', 1454949291); } $values = (string) $values[0]; } if (stripos($values, 'charset') === false && stripos($values, 'text/') === 0) { $values .= '; charset=' . $this->charset; } break; } $this->headers->set($name, $values, $replaceExistingHeader); return $this; }
[ "public", "function", "setHeader", "(", "$", "name", ",", "$", "values", ",", "$", "replaceExistingHeader", "=", "true", ")", "{", "switch", "(", "$", "name", ")", "{", "case", "'Content-Type'", ":", "if", "(", "is_array", "(", "$", "values", ")", ")",...
Sets the specified HTTP header DateTime objects will be converted to a string representation internally but will be returned as DateTime objects on calling getHeader(). Please note that dates are normalized to GMT internally, so that getHeader() will return the same point in time, but not necessarily in the same timezone, if it was not GMT previously. GMT is used synonymously with UTC as per RFC 2616 3.3.1. @param string $name Name of the header, for example "Location", "Content-Description" etc. @param array|string|\DateTime $values An array of values or a single value for the specified header field @param boolean $replaceExistingHeader If a header with the same name should be replaced. Default is true. @return self This message, for method chaining @throws \InvalidArgumentException @deprecated Since Flow 5.1, use withHeader or withAddedHeader instead @see withHeader() @see withAddedHeader()
[ "Sets", "the", "specified", "HTTP", "header" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Http/AbstractMessage.php#L122-L140
neos/flow-development-collection
Neos.Flow/Classes/Http/AbstractMessage.php
AbstractMessage.setContent
public function setContent($content) { $this->content = null; if ($content === null) { return; } if (TypeHandling::isSimpleType(gettype($content)) && !is_array($content)) { $this->content = (string)$content; } if (is_resource($content)) { $this->content = $content; } return $this; }
php
public function setContent($content) { $this->content = null; if ($content === null) { return; } if (TypeHandling::isSimpleType(gettype($content)) && !is_array($content)) { $this->content = (string)$content; } if (is_resource($content)) { $this->content = $content; } return $this; }
[ "public", "function", "setContent", "(", "$", "content", ")", "{", "$", "this", "->", "content", "=", "null", ";", "if", "(", "$", "content", "===", "null", ")", "{", "return", ";", "}", "if", "(", "TypeHandling", "::", "isSimpleType", "(", "gettype", ...
Explicitly sets the content of the message body @param string $content The body content @return self This message, for method chaining @see withBody()
[ "Explicitly", "sets", "the", "content", "of", "the", "message", "body" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Http/AbstractMessage.php#L149-L165
neos/flow-development-collection
Neos.Flow/Classes/Http/AbstractMessage.php
AbstractMessage.setCharset
public function setCharset($charset) { $this->charset = $charset; if ($this->headers->has('Content-Type')) { $contentType = $this->headers->get('Content-Type'); if (stripos($contentType, 'text/') === 0) { $matches = []; if (preg_match('/(?P<contenttype>.*); ?charset[^;]+(?P<extra>;.*)?/iu', $contentType, $matches)) { $contentType = $matches['contenttype']; } $contentType .= '; charset=' . $this->charset . (isset($matches['extra']) ? $matches['extra'] : ''); $this->setHeader('Content-Type', $contentType, true); } } return $this; }
php
public function setCharset($charset) { $this->charset = $charset; if ($this->headers->has('Content-Type')) { $contentType = $this->headers->get('Content-Type'); if (stripos($contentType, 'text/') === 0) { $matches = []; if (preg_match('/(?P<contenttype>.*); ?charset[^;]+(?P<extra>;.*)?/iu', $contentType, $matches)) { $contentType = $matches['contenttype']; } $contentType .= '; charset=' . $this->charset . (isset($matches['extra']) ? $matches['extra'] : ''); $this->setHeader('Content-Type', $contentType, true); } } return $this; }
[ "public", "function", "setCharset", "(", "$", "charset", ")", "{", "$", "this", "->", "charset", "=", "$", "charset", ";", "if", "(", "$", "this", "->", "headers", "->", "has", "(", "'Content-Type'", ")", ")", "{", "$", "contentType", "=", "$", "this...
Sets the character set for this message. If the content type of this message is a text/* media type, the character set in the respective Content-Type header will be updated by this method. @param string $charset A valid IANA character set identifier @return self This message, for method chaining @see http://www.iana.org/assignments/character-sets @deprecated Since Flow 5.1, just set the full Content-Type header
[ "Sets", "the", "character", "set", "for", "this", "message", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Http/AbstractMessage.php#L190-L206
neos/flow-development-collection
Neos.Flow/Classes/Http/AbstractMessage.php
AbstractMessage.getHeaderLine
public function getHeaderLine($name) { $headerLine = $this->headers->get($name); if ($headerLine === null) { $headerLine = ''; } if (is_array($headerLine)) { $headerLine = implode(', ', $headerLine); } return $headerLine; }
php
public function getHeaderLine($name) { $headerLine = $this->headers->get($name); if ($headerLine === null) { $headerLine = ''; } if (is_array($headerLine)) { $headerLine = implode(', ', $headerLine); } return $headerLine; }
[ "public", "function", "getHeaderLine", "(", "$", "name", ")", "{", "$", "headerLine", "=", "$", "this", "->", "headers", "->", "get", "(", "$", "name", ")", ";", "if", "(", "$", "headerLine", "===", "null", ")", "{", "$", "headerLine", "=", "''", "...
Retrieves a comma-separated string of the values for a single header. This method returns all of the header values of the given case-insensitive header name as a string concatenated together using a comma. NOTE: Not all header values may be appropriately represented using comma concatenation. For such headers, use getHeader() instead and supply your own delimiter when concatenating. If the header does not appear in the message, this method MUST return an empty string. @param string $name Case-insensitive header field name. @return string A string of values as provided for the given header concatenated together using a comma. If the header does not appear in the message, this method MUST return an empty string.
[ "Retrieves", "a", "comma", "-", "separated", "string", "of", "the", "values", "for", "a", "single", "header", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Http/AbstractMessage.php#L382-L394
neos/flow-development-collection
Neos.Flow/Classes/Http/AbstractMessage.php
AbstractMessage.withHeader
public function withHeader($name, $value) { $newMessage = clone $this; $newMessage->setHeader($name, $value, true); return $newMessage; }
php
public function withHeader($name, $value) { $newMessage = clone $this; $newMessage->setHeader($name, $value, true); return $newMessage; }
[ "public", "function", "withHeader", "(", "$", "name", ",", "$", "value", ")", "{", "$", "newMessage", "=", "clone", "$", "this", ";", "$", "newMessage", "->", "setHeader", "(", "$", "name", ",", "$", "value", ",", "true", ")", ";", "return", "$", "...
Return an instance with the provided value replacing the specified header. While header names are case-insensitive, the casing of the header will be preserved by this function, and returned from getHeaders(). This method MUST be implemented in such a way as to retain the immutability of the message, and MUST return an instance that has the new and/or updated header and value. @param string $name Case-insensitive header field name. @param string|string[] $value Header value(s). @return self @throws \InvalidArgumentException for invalid header names or values.
[ "Return", "an", "instance", "with", "the", "provided", "value", "replacing", "the", "specified", "header", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Http/AbstractMessage.php#L411-L416
neos/flow-development-collection
Neos.Flow/Classes/Http/AbstractMessage.php
AbstractMessage.withAddedHeader
public function withAddedHeader($name, $value) { $newMessage = clone $this; $newMessage->setHeader($name, $value); return $newMessage; }
php
public function withAddedHeader($name, $value) { $newMessage = clone $this; $newMessage->setHeader($name, $value); return $newMessage; }
[ "public", "function", "withAddedHeader", "(", "$", "name", ",", "$", "value", ")", "{", "$", "newMessage", "=", "clone", "$", "this", ";", "$", "newMessage", "->", "setHeader", "(", "$", "name", ",", "$", "value", ")", ";", "return", "$", "newMessage",...
Return an instance with the specified header appended with the given value. Existing values for the specified header will be maintained. The new value(s) will be appended to the existing list. If the header did not exist previously, it will be added. This method MUST be implemented in such a way as to retain the immutability of the message, and MUST return an instance that has the new header and/or value. @param string $name Case-insensitive header field name to add. @param string|string[] $value Header value(s). @return self @throws \InvalidArgumentException for invalid header names or values.
[ "Return", "an", "instance", "with", "the", "specified", "header", "appended", "with", "the", "given", "value", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Http/AbstractMessage.php#L434-L440
neos/flow-development-collection
Neos.Flow/Classes/Http/AbstractMessage.php
AbstractMessage.getBody
public function getBody() { $streamResource = fopen('php://memory', 'r+'); if (is_resource($this->content)) { stream_copy_to_stream($this->content, $streamResource); } else { fwrite($streamResource, $this->content); } rewind($streamResource); return new ContentStream($streamResource); }
php
public function getBody() { $streamResource = fopen('php://memory', 'r+'); if (is_resource($this->content)) { stream_copy_to_stream($this->content, $streamResource); } else { fwrite($streamResource, $this->content); } rewind($streamResource); return new ContentStream($streamResource); }
[ "public", "function", "getBody", "(", ")", "{", "$", "streamResource", "=", "fopen", "(", "'php://memory'", ",", "'r+'", ")", ";", "if", "(", "is_resource", "(", "$", "this", "->", "content", ")", ")", "{", "stream_copy_to_stream", "(", "$", "this", "->"...
Gets the body of the message. @return StreamInterface Returns the body as a stream.
[ "Gets", "the", "body", "of", "the", "message", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Http/AbstractMessage.php#L467-L478
neos/flow-development-collection
Neos.Flow/Classes/Http/AbstractMessage.php
AbstractMessage.withBody
public function withBody(StreamInterface $body) { $newMessage = clone $this; $newMessage->setContent($body->getContents()); return $newMessage; }
php
public function withBody(StreamInterface $body) { $newMessage = clone $this; $newMessage->setContent($body->getContents()); return $newMessage; }
[ "public", "function", "withBody", "(", "StreamInterface", "$", "body", ")", "{", "$", "newMessage", "=", "clone", "$", "this", ";", "$", "newMessage", "->", "setContent", "(", "$", "body", "->", "getContents", "(", ")", ")", ";", "return", "$", "newMessa...
Return an instance with the specified message body. The body MUST be a StreamInterface object. This method MUST be implemented in such a way as to retain the immutability of the message, and MUST return a new instance that has the new body stream. @param StreamInterface $body Body. @return self @throws \InvalidArgumentException When the body is not valid.
[ "Return", "an", "instance", "with", "the", "specified", "message", "body", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Http/AbstractMessage.php#L493-L499
neos/flow-development-collection
Neos.FluidAdaptor/Classes/ViewHelpers/Format/CaseViewHelper.php
CaseViewHelper.initializeArguments
public function initializeArguments() { $this->registerArgument('value', 'string', 'The input value. If not given, the evaluated child nodes will be used', false, null); $this->registerArgument('mode', 'string', 'The case to apply, must be one of this\' CASE_* constants. Defaults to uppercase application', false, self::CASE_UPPER); }
php
public function initializeArguments() { $this->registerArgument('value', 'string', 'The input value. If not given, the evaluated child nodes will be used', false, null); $this->registerArgument('mode', 'string', 'The case to apply, must be one of this\' CASE_* constants. Defaults to uppercase application', false, self::CASE_UPPER); }
[ "public", "function", "initializeArguments", "(", ")", "{", "$", "this", "->", "registerArgument", "(", "'value'", ",", "'string'", ",", "'The input value. If not given, the evaluated child nodes will be used'", ",", "false", ",", "null", ")", ";", "$", "this", "->", ...
Initialize the arguments. @return void @api
[ "Initialize", "the", "arguments", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.FluidAdaptor/Classes/ViewHelpers/Format/CaseViewHelper.php#L107-L111
neos/flow-development-collection
Neos.FluidAdaptor/Classes/ViewHelpers/Format/CaseViewHelper.php
CaseViewHelper.render
public function render() { return self::renderStatic(['value' => $this->arguments['value'], 'mode' => $this->arguments['mode']], $this->buildRenderChildrenClosure(), $this->renderingContext); }
php
public function render() { return self::renderStatic(['value' => $this->arguments['value'], 'mode' => $this->arguments['mode']], $this->buildRenderChildrenClosure(), $this->renderingContext); }
[ "public", "function", "render", "(", ")", "{", "return", "self", "::", "renderStatic", "(", "[", "'value'", "=>", "$", "this", "->", "arguments", "[", "'value'", "]", ",", "'mode'", "=>", "$", "this", "->", "arguments", "[", "'mode'", "]", "]", ",", ...
Changes the case of the input string @return string the altered string. @throws InvalidVariableException @api
[ "Changes", "the", "case", "of", "the", "input", "string" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.FluidAdaptor/Classes/ViewHelpers/Format/CaseViewHelper.php#L120-L123
neos/flow-development-collection
Neos.Flow/Classes/Aop/Pointcut/PointcutClassNameFilter.php
PointcutClassNameFilter.matches
public function matches($className, $methodName, $methodDeclaringClassName, $pointcutQueryIdentifier): bool { try { $matchResult = preg_match($this->classFilterExpression, $className); } catch (\Exception $exception) { throw new Exception('Error in regular expression "' . $this->classFilterExpression . '" in pointcut class filter', 1292324509, $exception); } if ($matchResult === false) { throw new Exception('Error in regular expression "' . $this->classFilterExpression . '" in pointcut class filter', 1168876955); } return ($matchResult === 1); }
php
public function matches($className, $methodName, $methodDeclaringClassName, $pointcutQueryIdentifier): bool { try { $matchResult = preg_match($this->classFilterExpression, $className); } catch (\Exception $exception) { throw new Exception('Error in regular expression "' . $this->classFilterExpression . '" in pointcut class filter', 1292324509, $exception); } if ($matchResult === false) { throw new Exception('Error in regular expression "' . $this->classFilterExpression . '" in pointcut class filter', 1168876955); } return ($matchResult === 1); }
[ "public", "function", "matches", "(", "$", "className", ",", "$", "methodName", ",", "$", "methodDeclaringClassName", ",", "$", "pointcutQueryIdentifier", ")", ":", "bool", "{", "try", "{", "$", "matchResult", "=", "preg_match", "(", "$", "this", "->", "clas...
Checks if the specified class matches with the class filter pattern @param string $className Name of the class to check against @param string $methodName Name of the method - not used here @param string $methodDeclaringClassName Name of the class the method was originally declared in - not used here @param mixed $pointcutQueryIdentifier Some identifier for this query - must at least differ from a previous identifier. Used for circular reference detection. @return boolean true if the class matches, otherwise false @throws Exception
[ "Checks", "if", "the", "specified", "class", "matches", "with", "the", "class", "filter", "pattern" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Aop/Pointcut/PointcutClassNameFilter.php#L74-L85
neos/flow-development-collection
Neos.Flow/Classes/Aop/Pointcut/PointcutClassNameFilter.php
PointcutClassNameFilter.reduceTargetClassNames
public function reduceTargetClassNames(ClassNameIndex $classNameIndex): ClassNameIndex { if (!preg_match('/^([^\.\(\)\{\}\[\]\?\+\$\!\|]+)/', $this->originalExpressionString, $matches)) { return $classNameIndex; } $prefixFilter = $matches[1]; // We sort here to make sure the index is okay $classNameIndex->sort(); return $classNameIndex->filterByPrefix($prefixFilter); }
php
public function reduceTargetClassNames(ClassNameIndex $classNameIndex): ClassNameIndex { if (!preg_match('/^([^\.\(\)\{\}\[\]\?\+\$\!\|]+)/', $this->originalExpressionString, $matches)) { return $classNameIndex; } $prefixFilter = $matches[1]; // We sort here to make sure the index is okay $classNameIndex->sort(); return $classNameIndex->filterByPrefix($prefixFilter); }
[ "public", "function", "reduceTargetClassNames", "(", "ClassNameIndex", "$", "classNameIndex", ")", ":", "ClassNameIndex", "{", "if", "(", "!", "preg_match", "(", "'/^([^\\.\\(\\)\\{\\}\\[\\]\\?\\+\\$\\!\\|]+)/'", ",", "$", "this", "->", "originalExpressionString", ",", ...
This method is used to optimize the matching process. @param ClassNameIndex $classNameIndex @return ClassNameIndex
[ "This", "method", "is", "used", "to", "optimize", "the", "matching", "process", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Aop/Pointcut/PointcutClassNameFilter.php#L113-L124
neos/flow-development-collection
Neos.FluidAdaptor/Classes/Core/Widget/AjaxWidgetComponent.php
AjaxWidgetComponent.handle
public function handle(ComponentContext $componentContext) { $httpRequest = $componentContext->getHttpRequest(); $widgetContext = $this->extractWidgetContext($httpRequest); if ($widgetContext === null) { return; } $componentContext = $this->prepareActionRequest($componentContext); /** @var $actionRequest ActionRequest */ $actionRequest = $componentContext->getParameter(DispatchComponent::class, 'actionRequest'); $actionRequest->setArgument('__widgetContext', $widgetContext); $actionRequest->setControllerObjectName($widgetContext->getControllerObjectName()); $this->setDefaultControllerAndActionNameIfNoneSpecified($actionRequest); $actionResponse = new ActionResponse($componentContext->getHttpResponse()); $this->dispatcher->dispatch($actionRequest, $actionResponse); $componentContext->replaceHttpResponse($actionResponse); // stop processing the current component chain $componentContext->setParameter(\Neos\Flow\Http\Component\ComponentChain::class, 'cancel', true); }
php
public function handle(ComponentContext $componentContext) { $httpRequest = $componentContext->getHttpRequest(); $widgetContext = $this->extractWidgetContext($httpRequest); if ($widgetContext === null) { return; } $componentContext = $this->prepareActionRequest($componentContext); /** @var $actionRequest ActionRequest */ $actionRequest = $componentContext->getParameter(DispatchComponent::class, 'actionRequest'); $actionRequest->setArgument('__widgetContext', $widgetContext); $actionRequest->setControllerObjectName($widgetContext->getControllerObjectName()); $this->setDefaultControllerAndActionNameIfNoneSpecified($actionRequest); $actionResponse = new ActionResponse($componentContext->getHttpResponse()); $this->dispatcher->dispatch($actionRequest, $actionResponse); $componentContext->replaceHttpResponse($actionResponse); // stop processing the current component chain $componentContext->setParameter(\Neos\Flow\Http\Component\ComponentChain::class, 'cancel', true); }
[ "public", "function", "handle", "(", "ComponentContext", "$", "componentContext", ")", "{", "$", "httpRequest", "=", "$", "componentContext", "->", "getHttpRequest", "(", ")", ";", "$", "widgetContext", "=", "$", "this", "->", "extractWidgetContext", "(", "$", ...
Check if the current request contains a widget context. If so dispatch it directly, otherwise continue with the next HTTP component. @param ComponentContext $componentContext @return void @throws ComponentException
[ "Check", "if", "the", "current", "request", "contains", "a", "widget", "context", ".", "If", "so", "dispatch", "it", "directly", "otherwise", "continue", "with", "the", "next", "HTTP", "component", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.FluidAdaptor/Classes/Core/Widget/AjaxWidgetComponent.php#L50-L71
neos/flow-development-collection
Neos.FluidAdaptor/Classes/Core/Widget/AjaxWidgetComponent.php
AjaxWidgetComponent.extractWidgetContext
protected function extractWidgetContext(Request $httpRequest) { if ($httpRequest->hasArgument('__widgetId')) { return $this->ajaxWidgetContextHolder->get($httpRequest->getArgument('__widgetId')); } elseif ($httpRequest->hasArgument('__widgetContext')) { $serializedWidgetContextWithHmac = $httpRequest->getArgument('__widgetContext'); $serializedWidgetContext = $this->hashService->validateAndStripHmac($serializedWidgetContextWithHmac); return unserialize(base64_decode($serializedWidgetContext)); } return null; }
php
protected function extractWidgetContext(Request $httpRequest) { if ($httpRequest->hasArgument('__widgetId')) { return $this->ajaxWidgetContextHolder->get($httpRequest->getArgument('__widgetId')); } elseif ($httpRequest->hasArgument('__widgetContext')) { $serializedWidgetContextWithHmac = $httpRequest->getArgument('__widgetContext'); $serializedWidgetContext = $this->hashService->validateAndStripHmac($serializedWidgetContextWithHmac); return unserialize(base64_decode($serializedWidgetContext)); } return null; }
[ "protected", "function", "extractWidgetContext", "(", "Request", "$", "httpRequest", ")", "{", "if", "(", "$", "httpRequest", "->", "hasArgument", "(", "'__widgetId'", ")", ")", "{", "return", "$", "this", "->", "ajaxWidgetContextHolder", "->", "get", "(", "$"...
Extracts the WidgetContext from the given $httpRequest. If the request contains an argument "__widgetId" the context is fetched from the session (AjaxWidgetContextHolder). Otherwise the argument "__widgetContext" is expected to contain the serialized WidgetContext (protected by a HMAC suffix) @param Request $httpRequest @return WidgetContext
[ "Extracts", "the", "WidgetContext", "from", "the", "given", "$httpRequest", ".", "If", "the", "request", "contains", "an", "argument", "__widgetId", "the", "context", "is", "fetched", "from", "the", "session", "(", "AjaxWidgetContextHolder", ")", ".", "Otherwise",...
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.FluidAdaptor/Classes/Core/Widget/AjaxWidgetComponent.php#L81-L91
neos/flow-development-collection
Neos.Flow/Classes/Security/Authentication/Token/UsernamePassword.php
UsernamePassword.updateCredentials
public function updateCredentials(ActionRequest $actionRequest) { $httpRequest = $actionRequest->getHttpRequest(); if ($httpRequest->getMethod() !== 'POST') { return; } $arguments = $actionRequest->getInternalArguments(); $username = ObjectAccess::getPropertyPath($arguments, '__authentication.Neos.Flow.Security.Authentication.Token.UsernamePassword.username'); $password = ObjectAccess::getPropertyPath($arguments, '__authentication.Neos.Flow.Security.Authentication.Token.UsernamePassword.password'); if (!empty($username) && !empty($password)) { $this->credentials['username'] = $username; $this->credentials['password'] = $password; $this->setAuthenticationStatus(self::AUTHENTICATION_NEEDED); } }
php
public function updateCredentials(ActionRequest $actionRequest) { $httpRequest = $actionRequest->getHttpRequest(); if ($httpRequest->getMethod() !== 'POST') { return; } $arguments = $actionRequest->getInternalArguments(); $username = ObjectAccess::getPropertyPath($arguments, '__authentication.Neos.Flow.Security.Authentication.Token.UsernamePassword.username'); $password = ObjectAccess::getPropertyPath($arguments, '__authentication.Neos.Flow.Security.Authentication.Token.UsernamePassword.password'); if (!empty($username) && !empty($password)) { $this->credentials['username'] = $username; $this->credentials['password'] = $password; $this->setAuthenticationStatus(self::AUTHENTICATION_NEEDED); } }
[ "public", "function", "updateCredentials", "(", "ActionRequest", "$", "actionRequest", ")", "{", "$", "httpRequest", "=", "$", "actionRequest", "->", "getHttpRequest", "(", ")", ";", "if", "(", "$", "httpRequest", "->", "getMethod", "(", ")", "!==", "'POST'", ...
Updates the username and password credentials from the POST vars, if the POST parameters are available. Sets the authentication status to REAUTHENTICATION_NEEDED, if credentials have been sent. Note: You need to send the username and password in these two POST parameters: __authentication[Neos][Flow][Security][Authentication][Token][UsernamePassword][username] and __authentication[Neos][Flow][Security][Authentication][Token][UsernamePassword][password] @param ActionRequest $actionRequest The current action request @return void
[ "Updates", "the", "username", "and", "password", "credentials", "from", "the", "POST", "vars", "if", "the", "POST", "parameters", "are", "available", ".", "Sets", "the", "authentication", "status", "to", "REAUTHENTICATION_NEEDED", "if", "credentials", "have", "bee...
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Authentication/Token/UsernamePassword.php#L41-L57
neos/flow-development-collection
Neos.Flow/Classes/I18n/Cldr/Reader/CurrencyReader.php
CurrencyReader.initializeObject
public function initializeObject() { if ($this->cache->has('fractions')) { $this->fractions = $this->cache->get('fractions'); } else { $this->generateFractions(); $this->cache->set('fractions', $this->fractions); } }
php
public function initializeObject() { if ($this->cache->has('fractions')) { $this->fractions = $this->cache->get('fractions'); } else { $this->generateFractions(); $this->cache->set('fractions', $this->fractions); } }
[ "public", "function", "initializeObject", "(", ")", "{", "if", "(", "$", "this", "->", "cache", "->", "has", "(", "'fractions'", ")", ")", "{", "$", "this", "->", "fractions", "=", "$", "this", "->", "cache", "->", "get", "(", "'fractions'", ")", ";"...
Constructs the reader, loading parsed data from cache if available. @return void
[ "Constructs", "the", "reader", "loading", "parsed", "data", "from", "cache", "if", "available", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/I18n/Cldr/Reader/CurrencyReader.php#L67-L75
neos/flow-development-collection
Neos.Flow/Classes/I18n/Cldr/Reader/CurrencyReader.php
CurrencyReader.getFraction
public function getFraction($currencyCode) { if (array_key_exists($currencyCode, $this->fractions)) { return $this->fractions[$currencyCode]; } return $this->fractions['DEFAULT']; }
php
public function getFraction($currencyCode) { if (array_key_exists($currencyCode, $this->fractions)) { return $this->fractions[$currencyCode]; } return $this->fractions['DEFAULT']; }
[ "public", "function", "getFraction", "(", "$", "currencyCode", ")", "{", "if", "(", "array_key_exists", "(", "$", "currencyCode", ",", "$", "this", "->", "fractions", ")", ")", "{", "return", "$", "this", "->", "fractions", "[", "$", "currencyCode", "]", ...
Returns an array with keys "digits" and "rounding", each an integer. @param string $currencyCode @return array ['digits' => int, 'rounding => int]
[ "Returns", "an", "array", "with", "keys", "digits", "and", "rounding", "each", "an", "integer", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/I18n/Cldr/Reader/CurrencyReader.php#L83-L90
neos/flow-development-collection
Neos.Flow/Classes/I18n/Cldr/Reader/CurrencyReader.php
CurrencyReader.generateFractions
protected function generateFractions() { $model = $this->cldrRepository->getModel('supplemental/supplementalData'); $currencyData = $model->getRawArray('currencyData'); foreach ($currencyData['fractions'] as $fractionString) { $currencyCode = $model->getAttributeValue($fractionString, 'iso4217'); $this->fractions[$currencyCode] = [ 'digits' => (int)$model->getAttributeValue($fractionString, 'digits'), 'rounding' => (int)$model->getAttributeValue($fractionString, 'rounding') ]; } }
php
protected function generateFractions() { $model = $this->cldrRepository->getModel('supplemental/supplementalData'); $currencyData = $model->getRawArray('currencyData'); foreach ($currencyData['fractions'] as $fractionString) { $currencyCode = $model->getAttributeValue($fractionString, 'iso4217'); $this->fractions[$currencyCode] = [ 'digits' => (int)$model->getAttributeValue($fractionString, 'digits'), 'rounding' => (int)$model->getAttributeValue($fractionString, 'rounding') ]; } }
[ "protected", "function", "generateFractions", "(", ")", "{", "$", "model", "=", "$", "this", "->", "cldrRepository", "->", "getModel", "(", "'supplemental/supplementalData'", ")", ";", "$", "currencyData", "=", "$", "model", "->", "getRawArray", "(", "'currencyD...
Generates an internal representation of currency fractions which can be found in supplementalData.xml CLDR file. @return void @see CurrencyReader::$fractions
[ "Generates", "an", "internal", "representation", "of", "currency", "fractions", "which", "can", "be", "found", "in", "supplementalData", ".", "xml", "CLDR", "file", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/I18n/Cldr/Reader/CurrencyReader.php#L99-L111
neos/flow-development-collection
Neos.Flow/Classes/Validation/Validator/ConjunctionValidator.php
ConjunctionValidator.validate
public function validate($value) { $validators = $this->getValidators(); if ($validators->count() > 0) { $result = null; foreach ($validators as $validator) { if ($result === null) { $result = $validator->validate($value); } else { $result->merge($validator->validate($value)); } } } else { $result = new ErrorResult(); } return $result; }
php
public function validate($value) { $validators = $this->getValidators(); if ($validators->count() > 0) { $result = null; foreach ($validators as $validator) { if ($result === null) { $result = $validator->validate($value); } else { $result->merge($validator->validate($value)); } } } else { $result = new ErrorResult(); } return $result; }
[ "public", "function", "validate", "(", "$", "value", ")", "{", "$", "validators", "=", "$", "this", "->", "getValidators", "(", ")", ";", "if", "(", "$", "validators", "->", "count", "(", ")", ">", "0", ")", "{", "$", "result", "=", "null", ";", ...
Checks if the given value is valid according to the validators of the conjunction. Every validator has to be valid, to make the whole conjunction valid. @param mixed $value The value that should be validated @return ErrorResult @api
[ "Checks", "if", "the", "given", "value", "is", "valid", "according", "to", "the", "validators", "of", "the", "conjunction", ".", "Every", "validator", "has", "to", "be", "valid", "to", "make", "the", "whole", "conjunction", "valid", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Validation/Validator/ConjunctionValidator.php#L31-L48
neos/flow-development-collection
Neos.Flow/Classes/Persistence/Generic/Qom/QueryObjectModelFactory.php
QueryObjectModelFactory.comparison
public function comparison(DynamicOperand $operand1, $operator, $operand2 = null) { return new Comparison($operand1, $operator, $operand2); }
php
public function comparison(DynamicOperand $operand1, $operator, $operand2 = null) { return new Comparison($operand1, $operator, $operand2); }
[ "public", "function", "comparison", "(", "DynamicOperand", "$", "operand1", ",", "$", "operator", ",", "$", "operand2", "=", "null", ")", "{", "return", "new", "Comparison", "(", "$", "operand1", ",", "$", "operator", ",", "$", "operand2", ")", ";", "}" ...
Filters tuples based on the outcome of a binary operation. @param DynamicOperand $operand1 the first operand; non-null @param string $operator the operator; one of QueryObjectModelConstants.JCR_OPERATOR_* @param mixed $operand2 the second operand; non-null @return Comparison the constraint; non-null @api
[ "Filters", "tuples", "based", "on", "the", "outcome", "of", "a", "binary", "operation", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Persistence/Generic/Qom/QueryObjectModelFactory.php#L86-L89
neos/flow-development-collection
Neos.Flow/Classes/Security/Cryptography/Algorithms.php
Algorithms.pbkdf2
public static function pbkdf2($password, $salt, $iterationCount, $derivedKeyLength, $algorithm = 'sha256') { $hashLength = strlen(hash($algorithm, null, true)); $keyBlocksToCompute = ceil($derivedKeyLength / $hashLength); $derivedKey = ''; for ($block = 1; $block <= $keyBlocksToCompute; $block++) { $iteratedBlock = hash_hmac($algorithm, $salt . pack('N', $block), $password, true); for ($iteration = 1, $iteratedHash = $iteratedBlock; $iteration < $iterationCount; $iteration++) { $iteratedHash = hash_hmac($algorithm, $iteratedHash, $password, true); $iteratedBlock ^= $iteratedHash; } $derivedKey .= $iteratedBlock; } return substr($derivedKey, 0, $derivedKeyLength); }
php
public static function pbkdf2($password, $salt, $iterationCount, $derivedKeyLength, $algorithm = 'sha256') { $hashLength = strlen(hash($algorithm, null, true)); $keyBlocksToCompute = ceil($derivedKeyLength / $hashLength); $derivedKey = ''; for ($block = 1; $block <= $keyBlocksToCompute; $block++) { $iteratedBlock = hash_hmac($algorithm, $salt . pack('N', $block), $password, true); for ($iteration = 1, $iteratedHash = $iteratedBlock; $iteration < $iterationCount; $iteration++) { $iteratedHash = hash_hmac($algorithm, $iteratedHash, $password, true); $iteratedBlock ^= $iteratedHash; } $derivedKey .= $iteratedBlock; } return substr($derivedKey, 0, $derivedKeyLength); }
[ "public", "static", "function", "pbkdf2", "(", "$", "password", ",", "$", "salt", ",", "$", "iterationCount", ",", "$", "derivedKeyLength", ",", "$", "algorithm", "=", "'sha256'", ")", "{", "$", "hashLength", "=", "strlen", "(", "hash", "(", "$", "algori...
Compute a derived key from a password based on PBKDF2 See PKCS #5 v2.0 http://tools.ietf.org/html/rfc2898 for implementation details. The implementation is tested with test vectors from http://tools.ietf.org/html/rfc6070 . If https://wiki.php.net/rfc/hash_pbkdf2 is ever part of PHP we should check for the existence of hash_pbkdf2() and use it if available. @param string $password Input string / password @param string $salt The salt @param integer $iterationCount Hash iteration count @param integer $derivedKeyLength Derived key length @param string $algorithm Hash algorithm to use, see hash_algos(), defaults to sha256 @return string The computed derived key as raw binary data
[ "Compute", "a", "derived", "key", "from", "a", "password", "based", "on", "PBKDF2" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Cryptography/Algorithms.php#L38-L56
neos/flow-development-collection
Neos.Flow/Scripts/Migrations/Tools.php
Tools.getPackagesData
public static function getPackagesData($packagesPath) { $packagesData = array(); $packagesDirectoryIterator = new \DirectoryIterator($packagesPath); foreach ($packagesDirectoryIterator as $categoryFileInfo) { $category = $categoryFileInfo->getFilename(); if (!$categoryFileInfo->isDir() || $category[0] === '.' || $category === 'Libraries') { continue; } $categoryDirectoryIterator = new \DirectoryIterator($categoryFileInfo->getPathname()); foreach ($categoryDirectoryIterator as $packageFileInfo) { $packageKey = $packageFileInfo->getFilename(); if (!$packageFileInfo->isDir() || $packageKey[0] === '.') { continue; } $meta = self::readPackageMetaData(Files::concatenatePaths(array($packageFileInfo->getPathname(), 'Meta/Package.xml'))); $composerManifest = self::readComposerManifest(Files::concatenatePaths(array($packageFileInfo->getPathname(), 'composer.json'))); $packagesData[$packageKey] = array( 'packageKey' => $packageKey, 'category' => $category, 'path' => $packageFileInfo->getPathname(), 'meta' => $meta, 'composerManifest' => $composerManifest ); } } return $packagesData; }
php
public static function getPackagesData($packagesPath) { $packagesData = array(); $packagesDirectoryIterator = new \DirectoryIterator($packagesPath); foreach ($packagesDirectoryIterator as $categoryFileInfo) { $category = $categoryFileInfo->getFilename(); if (!$categoryFileInfo->isDir() || $category[0] === '.' || $category === 'Libraries') { continue; } $categoryDirectoryIterator = new \DirectoryIterator($categoryFileInfo->getPathname()); foreach ($categoryDirectoryIterator as $packageFileInfo) { $packageKey = $packageFileInfo->getFilename(); if (!$packageFileInfo->isDir() || $packageKey[0] === '.') { continue; } $meta = self::readPackageMetaData(Files::concatenatePaths(array($packageFileInfo->getPathname(), 'Meta/Package.xml'))); $composerManifest = self::readComposerManifest(Files::concatenatePaths(array($packageFileInfo->getPathname(), 'composer.json'))); $packagesData[$packageKey] = array( 'packageKey' => $packageKey, 'category' => $category, 'path' => $packageFileInfo->getPathname(), 'meta' => $meta, 'composerManifest' => $composerManifest ); } } return $packagesData; }
[ "public", "static", "function", "getPackagesData", "(", "$", "packagesPath", ")", "{", "$", "packagesData", "=", "array", "(", ")", ";", "$", "packagesDirectoryIterator", "=", "new", "\\", "DirectoryIterator", "(", "$", "packagesPath", ")", ";", "foreach", "("...
Will return an array with all available packages. The data for each entry will be an array with the key, full path to the package (index 'path') and a category (the packages subfolder, index 'category'). The array is indexed by package key. @param string $packagesPath @return array
[ "Will", "return", "an", "array", "with", "all", "available", "packages", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Scripts/Migrations/Tools.php#L31-L61
neos/flow-development-collection
Neos.Flow/Scripts/Migrations/Tools.php
Tools.readComposerManifest
public static function readComposerManifest($pathAndFileName) { if (file_exists($pathAndFileName)) { $json = file_get_contents($pathAndFileName); return json_decode($json, true); } else { return null; } }
php
public static function readComposerManifest($pathAndFileName) { if (file_exists($pathAndFileName)) { $json = file_get_contents($pathAndFileName); return json_decode($json, true); } else { return null; } }
[ "public", "static", "function", "readComposerManifest", "(", "$", "pathAndFileName", ")", "{", "if", "(", "file_exists", "(", "$", "pathAndFileName", ")", ")", "{", "$", "json", "=", "file_get_contents", "(", "$", "pathAndFileName", ")", ";", "return", "json_d...
Read the package manifest from the composer.json file at $pathAndFileName @param string $pathAndFileName @return array
[ "Read", "the", "package", "manifest", "from", "the", "composer", ".", "json", "file", "at", "$pathAndFileName" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Scripts/Migrations/Tools.php#L69-L77
neos/flow-development-collection
Neos.Flow/Scripts/Migrations/Tools.php
Tools.writeComposerManifest
public static function writeComposerManifest(array $manifest, $pathAndFilename) { file_put_contents($pathAndFilename, json_encode($manifest, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE)); }
php
public static function writeComposerManifest(array $manifest, $pathAndFilename) { file_put_contents($pathAndFilename, json_encode($manifest, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE)); }
[ "public", "static", "function", "writeComposerManifest", "(", "array", "$", "manifest", ",", "$", "pathAndFilename", ")", "{", "file_put_contents", "(", "$", "pathAndFilename", ",", "json_encode", "(", "$", "manifest", ",", "JSON_UNESCAPED_SLASHES", "|", "JSON_PRETT...
Write the manifest to the given file. @param array $manifest @param string $pathAndFilename @return void
[ "Write", "the", "manifest", "to", "the", "given", "file", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Scripts/Migrations/Tools.php#L86-L89
neos/flow-development-collection
Neos.Flow/Scripts/Migrations/Tools.php
Tools.readPackageMetaData
protected static function readPackageMetaData($pathAndFileName) { if (file_exists($pathAndFileName)) { $xml = simplexml_load_file($pathAndFileName); $meta = array(); if ($xml === false) { $meta['description'] = '[Package.xml could not be read.]'; } else { $meta['version'] = (string)$xml->version; $meta['title'] = (string)$xml->title; $meta['description'] = (string)$xml->description; } return $meta; } else { return null; } }
php
protected static function readPackageMetaData($pathAndFileName) { if (file_exists($pathAndFileName)) { $xml = simplexml_load_file($pathAndFileName); $meta = array(); if ($xml === false) { $meta['description'] = '[Package.xml could not be read.]'; } else { $meta['version'] = (string)$xml->version; $meta['title'] = (string)$xml->title; $meta['description'] = (string)$xml->description; } return $meta; } else { return null; } }
[ "protected", "static", "function", "readPackageMetaData", "(", "$", "pathAndFileName", ")", "{", "if", "(", "file_exists", "(", "$", "pathAndFileName", ")", ")", "{", "$", "xml", "=", "simplexml_load_file", "(", "$", "pathAndFileName", ")", ";", "$", "meta", ...
Read the package metadata from the Package.xml file at $pathAndFileName @param string $pathAndFileName @return array|NULL
[ "Read", "the", "package", "metadata", "from", "the", "Package", ".", "xml", "file", "at", "$pathAndFileName" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Scripts/Migrations/Tools.php#L97-L114
neos/flow-development-collection
Neos.Flow/Scripts/Migrations/Tools.php
Tools.searchAndReplace
public static function searchAndReplace($search, $replace, $pathAndFilename, $regularExpression = false) { $pathInfo = pathinfo($pathAndFilename); if (!isset($pathInfo['filename']) || $pathAndFilename === __FILE__) { return false; } $file = file_get_contents($pathAndFilename); $fileBackup = $file; if ($regularExpression === true) { if ($replace instanceof \Closure) { $file = preg_replace_callback($search, $replace, $file); } else { $file = preg_replace($search, $replace, $file); } } else { $file = str_replace($search, $replace, $file); } if ($file !== $fileBackup) { file_put_contents($pathAndFilename, $file); return true; } return null; }
php
public static function searchAndReplace($search, $replace, $pathAndFilename, $regularExpression = false) { $pathInfo = pathinfo($pathAndFilename); if (!isset($pathInfo['filename']) || $pathAndFilename === __FILE__) { return false; } $file = file_get_contents($pathAndFilename); $fileBackup = $file; if ($regularExpression === true) { if ($replace instanceof \Closure) { $file = preg_replace_callback($search, $replace, $file); } else { $file = preg_replace($search, $replace, $file); } } else { $file = str_replace($search, $replace, $file); } if ($file !== $fileBackup) { file_put_contents($pathAndFilename, $file); return true; } return null; }
[ "public", "static", "function", "searchAndReplace", "(", "$", "search", ",", "$", "replace", ",", "$", "pathAndFilename", ",", "$", "regularExpression", "=", "false", ")", "{", "$", "pathInfo", "=", "pathinfo", "(", "$", "pathAndFilename", ")", ";", "if", ...
Does a search and replace operation on the given file. A simple str_replace is used, unless $regularExpression is set to true. In that case preg_replace is used. The given patterns are used as given, no quoting is applied! In case $regularExpression is true, a closure can be given for the $replace variable. It should return a string and is given an array of matches as parameter. @param string $search @param string|\Closure $replace @param string $pathAndFilename @param boolean $regularExpression @return boolean|NULL false on errors, NULL on skip, true on success
[ "Does", "a", "search", "and", "replace", "operation", "on", "the", "given", "file", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Scripts/Migrations/Tools.php#L133-L156
neos/flow-development-collection
Neos.Flow/Classes/ResourceManagement/Streams/StreamWrapperAdapter.php
StreamWrapperAdapter.initializeStreamWrapper
public static function initializeStreamWrapper($objectManager) { $streamWrapperClassNames = static::getStreamWrapperImplementationClassNames($objectManager); /** @var StreamWrapperInterface $streamWrapperClassName */ foreach ($streamWrapperClassNames as $streamWrapperClassName) { $scheme = $streamWrapperClassName::getScheme(); if (in_array($scheme, stream_get_wrappers())) { stream_wrapper_unregister($scheme); } stream_wrapper_register($scheme, StreamWrapperAdapter::class); static::registerStreamWrapper($scheme, $streamWrapperClassName); } }
php
public static function initializeStreamWrapper($objectManager) { $streamWrapperClassNames = static::getStreamWrapperImplementationClassNames($objectManager); /** @var StreamWrapperInterface $streamWrapperClassName */ foreach ($streamWrapperClassNames as $streamWrapperClassName) { $scheme = $streamWrapperClassName::getScheme(); if (in_array($scheme, stream_get_wrappers())) { stream_wrapper_unregister($scheme); } stream_wrapper_register($scheme, StreamWrapperAdapter::class); static::registerStreamWrapper($scheme, $streamWrapperClassName); } }
[ "public", "static", "function", "initializeStreamWrapper", "(", "$", "objectManager", ")", "{", "$", "streamWrapperClassNames", "=", "static", "::", "getStreamWrapperImplementationClassNames", "(", "$", "objectManager", ")", ";", "/** @var StreamWrapperInterface $streamWrappe...
Initialize StreamWrappers with this adapter @param ObjectManagerInterface $objectManager @return void
[ "Initialize", "StreamWrappers", "with", "this", "adapter" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ResourceManagement/Streams/StreamWrapperAdapter.php#L51-L63
neos/flow-development-collection
Neos.Flow/Classes/ResourceManagement/Streams/StreamWrapperAdapter.php
StreamWrapperAdapter.createStreamWrapper
protected function createStreamWrapper($path) { if ($this->streamWrapper === null) { $explodedPath = explode(':', $path, 2); $scheme = array_shift($explodedPath); $registeredStreamWrappers = self::$registeredStreamWrappers; $registeredStreamWrapperForScheme = $registeredStreamWrappers[$scheme]; $this->streamWrapper = new $registeredStreamWrapperForScheme(); } }
php
protected function createStreamWrapper($path) { if ($this->streamWrapper === null) { $explodedPath = explode(':', $path, 2); $scheme = array_shift($explodedPath); $registeredStreamWrappers = self::$registeredStreamWrappers; $registeredStreamWrapperForScheme = $registeredStreamWrappers[$scheme]; $this->streamWrapper = new $registeredStreamWrapperForScheme(); } }
[ "protected", "function", "createStreamWrapper", "(", "$", "path", ")", "{", "if", "(", "$", "this", "->", "streamWrapper", "===", "null", ")", "{", "$", "explodedPath", "=", "explode", "(", "':'", ",", "$", "path", ",", "2", ")", ";", "$", "scheme", ...
Create the internal stream wrapper if needed. @param string $path The path to fetch the scheme from. @return void
[ "Create", "the", "internal", "stream", "wrapper", "if", "needed", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ResourceManagement/Streams/StreamWrapperAdapter.php#L94-L103
neos/flow-development-collection
Neos.Flow/Classes/ResourceManagement/Streams/StreamWrapperAdapter.php
StreamWrapperAdapter.dir_opendir
public function dir_opendir($path, $options) { $this->createStreamWrapper($path); return $this->streamWrapper->openDirectory($path, $options); }
php
public function dir_opendir($path, $options) { $this->createStreamWrapper($path); return $this->streamWrapper->openDirectory($path, $options); }
[ "public", "function", "dir_opendir", "(", "$", "path", ",", "$", "options", ")", "{", "$", "this", "->", "createStreamWrapper", "(", "$", "path", ")", ";", "return", "$", "this", "->", "streamWrapper", "->", "openDirectory", "(", "$", "path", ",", "$", ...
Open directory handle. This method is called in response to opendir(). @param string $path Specifies the URL that was passed to opendir(). @param int $options Whether or not to enforce safe_mode (0x04). @return boolean true on success or false on failure.
[ "Open", "directory", "handle", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ResourceManagement/Streams/StreamWrapperAdapter.php#L129-L133
neos/flow-development-collection
Neos.Flow/Classes/ResourceManagement/Streams/StreamWrapperAdapter.php
StreamWrapperAdapter.mkdir
public function mkdir($path, $mode, $options) { $this->createStreamWrapper($path); return $this->streamWrapper->makeDirectory($path, $mode, $options); }
php
public function mkdir($path, $mode, $options) { $this->createStreamWrapper($path); return $this->streamWrapper->makeDirectory($path, $mode, $options); }
[ "public", "function", "mkdir", "(", "$", "path", ",", "$", "mode", ",", "$", "options", ")", "{", "$", "this", "->", "createStreamWrapper", "(", "$", "path", ")", ";", "return", "$", "this", "->", "streamWrapper", "->", "makeDirectory", "(", "$", "path...
Create a directory. This method is called in response to mkdir(). Note: In order for the appropriate error message to be returned this method should not be defined if the wrapper does not support creating directories. @param string $path Directory which should be created. @param integer $mode The value passed to mkdir(). @param integer $options A bitwise mask of values, such as STREAM_MKDIR_RECURSIVE. @return boolean true on success or false on failure.
[ "Create", "a", "directory", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ResourceManagement/Streams/StreamWrapperAdapter.php#L177-L181
neos/flow-development-collection
Neos.Flow/Classes/ResourceManagement/Streams/StreamWrapperAdapter.php
StreamWrapperAdapter.rename
public function rename($path_from, $path_to) { $this->createStreamWrapper($path_from); return $this->streamWrapper->rename($path_from, $path_to); }
php
public function rename($path_from, $path_to) { $this->createStreamWrapper($path_from); return $this->streamWrapper->rename($path_from, $path_to); }
[ "public", "function", "rename", "(", "$", "path_from", ",", "$", "path_to", ")", "{", "$", "this", "->", "createStreamWrapper", "(", "$", "path_from", ")", ";", "return", "$", "this", "->", "streamWrapper", "->", "rename", "(", "$", "path_from", ",", "$"...
Renames a file or directory. This method is called in response to rename(). Should attempt to rename path_from to path_to. Note: In order for the appropriate error message to be returned this method should not be defined if the wrapper does not support creating directories. @param string $path_from The URL to the current file. @param string $path_to The URL which the path_from should be renamed to. @return boolean true on success or false on failure.
[ "Renames", "a", "file", "or", "directory", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ResourceManagement/Streams/StreamWrapperAdapter.php#L198-L202
neos/flow-development-collection
Neos.Flow/Classes/ResourceManagement/Streams/StreamWrapperAdapter.php
StreamWrapperAdapter.rmdir
public function rmdir($path, $options) { $this->createStreamWrapper($path); return $this->streamWrapper->removeDirectory($path, $options); }
php
public function rmdir($path, $options) { $this->createStreamWrapper($path); return $this->streamWrapper->removeDirectory($path, $options); }
[ "public", "function", "rmdir", "(", "$", "path", ",", "$", "options", ")", "{", "$", "this", "->", "createStreamWrapper", "(", "$", "path", ")", ";", "return", "$", "this", "->", "streamWrapper", "->", "removeDirectory", "(", "$", "path", ",", "$", "op...
Removes a directory. This method is called in response to rmdir(). Note: In order for the appropriate error message to be returned this method should not be defined if the wrapper does not support creating directories. @param string $path The directory URL which should be removed. @param integer $options A bitwise mask of values, such as STREAM_MKDIR_RECURSIVE. @return boolean true on success or false on failure.
[ "Removes", "a", "directory", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ResourceManagement/Streams/StreamWrapperAdapter.php#L217-L221
neos/flow-development-collection
Neos.Flow/Classes/ResourceManagement/Streams/StreamWrapperAdapter.php
StreamWrapperAdapter.stream_lock
public function stream_lock($operation) { if ($operation === LOCK_UN) { return $this->streamWrapper->unlock(); } else { return $this->streamWrapper->lock($operation); } }
php
public function stream_lock($operation) { if ($operation === LOCK_UN) { return $this->streamWrapper->unlock(); } else { return $this->streamWrapper->lock($operation); } }
[ "public", "function", "stream_lock", "(", "$", "operation", ")", "{", "if", "(", "$", "operation", "===", "LOCK_UN", ")", "{", "return", "$", "this", "->", "streamWrapper", "->", "unlock", "(", ")", ";", "}", "else", "{", "return", "$", "this", "->", ...
Advisory file locking. This method is called in response to flock(), when file_put_contents() (when flags contains LOCK_EX), stream_set_blocking() and when closing the stream (LOCK_UN). $operation is one of the following: LOCK_SH to acquire a shared lock (reader). LOCK_EX to acquire an exclusive lock (writer). LOCK_UN to release a lock (shared or exclusive). LOCK_NB if you don't want flock() to block while locking. @param integer $operation One of the LOCK_* constants @return boolean true on success or false on failure.
[ "Advisory", "file", "locking", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ResourceManagement/Streams/StreamWrapperAdapter.php#L296-L303
neos/flow-development-collection
Neos.Flow/Classes/ResourceManagement/Streams/StreamWrapperAdapter.php
StreamWrapperAdapter.stream_open
public function stream_open($path, $mode, $options, &$opened_path) { $this->createStreamWrapper($path); return $this->streamWrapper->open($path, $mode, $options, $opened_path); }
php
public function stream_open($path, $mode, $options, &$opened_path) { $this->createStreamWrapper($path); return $this->streamWrapper->open($path, $mode, $options, $opened_path); }
[ "public", "function", "stream_open", "(", "$", "path", ",", "$", "mode", ",", "$", "options", ",", "&", "$", "opened_path", ")", "{", "$", "this", "->", "createStreamWrapper", "(", "$", "path", ")", ";", "return", "$", "this", "->", "streamWrapper", "-...
Opens file or URL. This method is called immediately after the wrapper is initialized (f.e. by fopen() and file_get_contents()). $options can hold one of the following values OR'd together: STREAM_USE_PATH If path is relative, search for the resource using the include_path. STREAM_REPORT_ERRORS If this flag is set, you are responsible for raising errors using trigger_error() during opening of the stream. If this flag is not set, you should not raise any errors. @param string $path Specifies the URL that was passed to the original function. @param string $mode The mode used to open the file, as detailed for fopen(). @param integer $options Holds additional flags set by the streams API. @param string &$opened_path path If the path is opened successfully, and STREAM_USE_PATH is set in options, opened_path should be set to the full path of the file/resource that was actually opened. @return boolean true on success or false on failure.
[ "Opens", "file", "or", "URL", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ResourceManagement/Streams/StreamWrapperAdapter.php#L325-L329
neos/flow-development-collection
Neos.Flow/Classes/ResourceManagement/Streams/StreamWrapperAdapter.php
StreamWrapperAdapter.stream_set_option
public function stream_set_option($option, $arg1, $arg2) { return $this->streamWrapper->setOption($option, $arg1, $arg2); }
php
public function stream_set_option($option, $arg1, $arg2) { return $this->streamWrapper->setOption($option, $arg1, $arg2); }
[ "public", "function", "stream_set_option", "(", "$", "option", ",", "$", "arg1", ",", "$", "arg2", ")", "{", "return", "$", "this", "->", "streamWrapper", "->", "setOption", "(", "$", "option", ",", "$", "arg1", ",", "$", "arg2", ")", ";", "}" ]
Change stream options. This method is called to set options on the stream. $option can be one of: STREAM_OPTION_BLOCKING (The method was called in response to stream_set_blocking()) STREAM_OPTION_READ_TIMEOUT (The method was called in response to stream_set_timeout()) STREAM_OPTION_WRITE_BUFFER (The method was called in response to stream_set_write_buffer()) If $option is ... then $arg1 is set to: STREAM_OPTION_BLOCKING: requested blocking mode (1 meaning block 0 not blocking). STREAM_OPTION_READ_TIMEOUT: the timeout in seconds. STREAM_OPTION_WRITE_BUFFER: buffer mode (STREAM_BUFFER_NONE or STREAM_BUFFER_FULL). If $option is ... then $arg2 is set to: STREAM_OPTION_BLOCKING: This option is not set. STREAM_OPTION_READ_TIMEOUT: the timeout in microseconds. STREAM_OPTION_WRITE_BUFFER: the requested buffer size. @param integer $option @param integer $arg1 @param integer $arg2 @return boolean true on success or false on failure. If option is not implemented, false should be returned.
[ "Change", "stream", "options", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ResourceManagement/Streams/StreamWrapperAdapter.php#L394-L397
neos/flow-development-collection
Neos.Flow/Classes/ResourceManagement/Streams/StreamWrapperAdapter.php
StreamWrapperAdapter.url_stat
public function url_stat($path, $flags) { $this->createStreamWrapper($path); return $this->streamWrapper->pathStat($path, $flags); }
php
public function url_stat($path, $flags) { $this->createStreamWrapper($path); return $this->streamWrapper->pathStat($path, $flags); }
[ "public", "function", "url_stat", "(", "$", "path", ",", "$", "flags", ")", "{", "$", "this", "->", "createStreamWrapper", "(", "$", "path", ")", ";", "return", "$", "this", "->", "streamWrapper", "->", "pathStat", "(", "$", "path", ",", "$", "flags", ...
Retrieve information about a file. This method is called in response to all stat() related functions. $flags can hold one or more of the following values OR'd together: STREAM_URL_STAT_LINK For resources with the ability to link to other resource (such as an HTTP Location: forward, or a filesystem symlink). This flag specified that only information about the link itself should be returned, not the resource pointed to by the link. This flag is set in response to calls to lstat(), is_link(), or filetype(). STREAM_URL_STAT_QUIET If this flag is set, your wrapper should not raise any errors. If this flag is not set, you are responsible for reporting errors using the trigger_error() function during stating of the path. @param string $path The file path or URL to stat. Note that in the case of a URL, it must be a :// delimited URL. Other URL forms are not supported. @param integer $flags Holds additional flags set by the streams API. @return array Should return as many elements as stat() does. Unknown or unavailable values should be set to a rational value (usually 0).
[ "Retrieve", "information", "about", "a", "file", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ResourceManagement/Streams/StreamWrapperAdapter.php#L481-L485
neos/flow-development-collection
Neos.Flow/Classes/Validation/Validator/UuidValidator.php
UuidValidator.isValid
protected function isValid($value) { if (!is_string($value) || !preg_match(self::PATTERN_MATCH_UUID, $value)) { $this->addError('The given subject was not a valid UUID.', 1221565853); } }
php
protected function isValid($value) { if (!is_string($value) || !preg_match(self::PATTERN_MATCH_UUID, $value)) { $this->addError('The given subject was not a valid UUID.', 1221565853); } }
[ "protected", "function", "isValid", "(", "$", "value", ")", "{", "if", "(", "!", "is_string", "(", "$", "value", ")", "||", "!", "preg_match", "(", "self", "::", "PATTERN_MATCH_UUID", ",", "$", "value", ")", ")", "{", "$", "this", "->", "addError", "...
Checks if the given value is a syntactically valid UUID. @param mixed $value The value that should be validated @return void @api
[ "Checks", "if", "the", "given", "value", "is", "a", "syntactically", "valid", "UUID", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Validation/Validator/UuidValidator.php#L37-L42
neos/flow-development-collection
Neos.Flow/Classes/Persistence/Doctrine/Logging/SqlLogger.php
SqlLogger.startQuery
public function startQuery($sql, array $params = null, array $types = null) { // this is a safeguard for when no logger might be available... if ($this->logger !== null) { $this->logger->log($sql, LOG_DEBUG, ['params' => $params, 'types' => $types]); } }
php
public function startQuery($sql, array $params = null, array $types = null) { // this is a safeguard for when no logger might be available... if ($this->logger !== null) { $this->logger->log($sql, LOG_DEBUG, ['params' => $params, 'types' => $types]); } }
[ "public", "function", "startQuery", "(", "$", "sql", ",", "array", "$", "params", "=", "null", ",", "array", "$", "types", "=", "null", ")", "{", "// this is a safeguard for when no logger might be available...", "if", "(", "$", "this", "->", "logger", "!==", ...
Logs a SQL statement to the system logger (DEBUG priority). @param string $sql The SQL to be executed @param array $params The SQL parameters @param array $types The SQL parameter types. @return void
[ "Logs", "a", "SQL", "statement", "to", "the", "system", "logger", "(", "DEBUG", "priority", ")", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Persistence/Doctrine/Logging/SqlLogger.php#L35-L41
neos/flow-development-collection
Neos.Flow/Migrations/Code/Version20141113121400.php
Version20141113121400.processRoles
public function processRoles(array &$configuration) { if (!isset($configuration['roles'])) { return; } $newRolesConfiguration = array(); foreach ($configuration['roles'] as $roleIdentifier => $roleConfiguration) { $roleIdentifier = $this->expandRoleIdentifier($roleIdentifier); $newRolesConfiguration[$roleIdentifier] = array(); if (!is_array($roleConfiguration) || $roleConfiguration === array()) { continue; } if (isset($roleConfiguration['privileges'])) { $newRolesConfiguration[$roleIdentifier] = $roleConfiguration; continue; } $newRolesConfiguration[$roleIdentifier]['parentRoles'] = array(); foreach ($roleConfiguration as $parentRoleIdentifier) { if (strpos($parentRoleIdentifier, ':') === false) { $parentRoleIdentifier = $this->expandRoleIdentifier($parentRoleIdentifier); } $newRolesConfiguration[$roleIdentifier]['parentRoles'][] = $parentRoleIdentifier; } } $configuration['roles'] = $newRolesConfiguration; }
php
public function processRoles(array &$configuration) { if (!isset($configuration['roles'])) { return; } $newRolesConfiguration = array(); foreach ($configuration['roles'] as $roleIdentifier => $roleConfiguration) { $roleIdentifier = $this->expandRoleIdentifier($roleIdentifier); $newRolesConfiguration[$roleIdentifier] = array(); if (!is_array($roleConfiguration) || $roleConfiguration === array()) { continue; } if (isset($roleConfiguration['privileges'])) { $newRolesConfiguration[$roleIdentifier] = $roleConfiguration; continue; } $newRolesConfiguration[$roleIdentifier]['parentRoles'] = array(); foreach ($roleConfiguration as $parentRoleIdentifier) { if (strpos($parentRoleIdentifier, ':') === false) { $parentRoleIdentifier = $this->expandRoleIdentifier($parentRoleIdentifier); } $newRolesConfiguration[$roleIdentifier]['parentRoles'][] = $parentRoleIdentifier; } } $configuration['roles'] = $newRolesConfiguration; }
[ "public", "function", "processRoles", "(", "array", "&", "$", "configuration", ")", "{", "if", "(", "!", "isset", "(", "$", "configuration", "[", "'roles'", "]", ")", ")", "{", "return", ";", "}", "$", "newRolesConfiguration", "=", "array", "(", ")", "...
Replaces local role identifiers ("SomeRole") by their global representation ("Current.Package:SomeRole") and sets "parentRoles" @param array $configuration @return void
[ "Replaces", "local", "role", "identifiers", "(", "SomeRole", ")", "by", "their", "global", "representation", "(", "Current", ".", "Package", ":", "SomeRole", ")", "and", "sets", "parentRoles" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Migrations/Code/Version20141113121400.php#L60-L85
neos/flow-development-collection
Neos.Flow/Migrations/Code/Version20141113121400.php
Version20141113121400.processResources
public function processResources(array &$configuration) { if (!isset($configuration['resources']) || !is_array($configuration['resources'])) { return; } $newPrivilegeTargetConfiguration = array(); foreach ($configuration['resources'] as $resourceType => $resourceConfiguration) { switch ($resourceType) { case 'methods': $privilegeClassName = 'TYPO3\\Flow\\Security\\Authorization\\Privilege\\Method\MethodPrivilege'; if (!isset($newPrivilegeTargetConfiguration[$privilegeClassName])) { $newPrivilegeTargetConfiguration[$privilegeClassName] = array(); } foreach ($resourceConfiguration as $resourceName => $resourceMatcher) { $newPrivilegeTargetConfiguration[$privilegeClassName][$resourceName] = array( 'matcher' => $resourceMatcher, ); } break; case 'entities': $privilegeClassName = 'TYPO3\\Flow\\Security\\Authorization\\Privilege\\Entity\\Doctrine\\EntityPrivilege'; foreach ($resourceConfiguration as $entityType => $entityConfiguration) { if (!isset($newPrivilegeTargetConfiguration[$privilegeClassName])) { $newPrivilegeTargetConfiguration[$privilegeClassName] = array(); } foreach ($entityConfiguration as $resourceName => $resourceMatcher) { $newPrivilegeTargetConfiguration[$privilegeClassName][$resourceName] = array( 'matcher' => $this->convertEntityResourceMatcher($entityType, $resourceMatcher) ); } } break; default: $this->showWarning('Resource type "' . $resourceType . '" is not supported...'); } } unset($configuration['resources']); $configuration['privilegeTargets'] = $newPrivilegeTargetConfiguration; }
php
public function processResources(array &$configuration) { if (!isset($configuration['resources']) || !is_array($configuration['resources'])) { return; } $newPrivilegeTargetConfiguration = array(); foreach ($configuration['resources'] as $resourceType => $resourceConfiguration) { switch ($resourceType) { case 'methods': $privilegeClassName = 'TYPO3\\Flow\\Security\\Authorization\\Privilege\\Method\MethodPrivilege'; if (!isset($newPrivilegeTargetConfiguration[$privilegeClassName])) { $newPrivilegeTargetConfiguration[$privilegeClassName] = array(); } foreach ($resourceConfiguration as $resourceName => $resourceMatcher) { $newPrivilegeTargetConfiguration[$privilegeClassName][$resourceName] = array( 'matcher' => $resourceMatcher, ); } break; case 'entities': $privilegeClassName = 'TYPO3\\Flow\\Security\\Authorization\\Privilege\\Entity\\Doctrine\\EntityPrivilege'; foreach ($resourceConfiguration as $entityType => $entityConfiguration) { if (!isset($newPrivilegeTargetConfiguration[$privilegeClassName])) { $newPrivilegeTargetConfiguration[$privilegeClassName] = array(); } foreach ($entityConfiguration as $resourceName => $resourceMatcher) { $newPrivilegeTargetConfiguration[$privilegeClassName][$resourceName] = array( 'matcher' => $this->convertEntityResourceMatcher($entityType, $resourceMatcher) ); } } break; default: $this->showWarning('Resource type "' . $resourceType . '" is not supported...'); } } unset($configuration['resources']); $configuration['privilegeTargets'] = $newPrivilegeTargetConfiguration; }
[ "public", "function", "processResources", "(", "array", "&", "$", "configuration", ")", "{", "if", "(", "!", "isset", "(", "$", "configuration", "[", "'resources'", "]", ")", "||", "!", "is_array", "(", "$", "configuration", "[", "'resources'", "]", ")", ...
Replaces the "resource" configuration by the new "privilegeTargets" syntax @param array $configuration @return void
[ "Replaces", "the", "resource", "configuration", "by", "the", "new", "privilegeTargets", "syntax" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Migrations/Code/Version20141113121400.php#L93-L131
neos/flow-development-collection
Neos.Flow/Migrations/Code/Version20141113121400.php
Version20141113121400.convertEntityResourceMatcher
protected function convertEntityResourceMatcher($entityType, $resourceMatcher) { $newMatcher = 'isType("' . $entityType . '")'; if (trim($resourceMatcher) !== 'ANY') { $newMatcher .= ' && ' . preg_replace(array('/\bcurrent\./', '/\bthis\.([^\s]+)/'), array('context.', 'property("$1")'), $resourceMatcher); } return $newMatcher; }
php
protected function convertEntityResourceMatcher($entityType, $resourceMatcher) { $newMatcher = 'isType("' . $entityType . '")'; if (trim($resourceMatcher) !== 'ANY') { $newMatcher .= ' && ' . preg_replace(array('/\bcurrent\./', '/\bthis\.([^\s]+)/'), array('context.', 'property("$1")'), $resourceMatcher); } return $newMatcher; }
[ "protected", "function", "convertEntityResourceMatcher", "(", "$", "entityType", ",", "$", "resourceMatcher", ")", "{", "$", "newMatcher", "=", "'isType(\"'", ".", "$", "entityType", ".", "'\")'", ";", "if", "(", "trim", "(", "$", "resourceMatcher", ")", "!=="...
Converts the given $resourceMatcher string to the new syntax @param string $entityType @param string $resourceMatcher @return string
[ "Converts", "the", "given", "$resourceMatcher", "string", "to", "the", "new", "syntax" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Migrations/Code/Version20141113121400.php#L140-L147
neos/flow-development-collection
Neos.Flow/Migrations/Code/Version20141113121400.php
Version20141113121400.processAcls
public function processAcls(array &$configuration) { if (!isset($configuration['acls'])) { return; } $newRolesConfiguration = isset($configuration['roles']) ? $configuration['roles'] : array(); foreach ($configuration['acls'] as $roleIdentifier => $aclConfiguration) { $roleIdentifier = $this->expandRoleIdentifier($roleIdentifier); if (!isset($newRolesConfiguration[$roleIdentifier])) { $newRolesConfiguration[$roleIdentifier] = array(); } if (!isset($newRolesConfiguration[$roleIdentifier]['privileges'])) { $newRolesConfiguration[$roleIdentifier]['privileges'] = array(); } foreach ($aclConfiguration as $resourceType => $permissions) { if ($resourceType !== 'methods' && $resourceType !== 'entities') { $this->showWarning('Resource type "' . $resourceType . '" is not supported...'); continue; } foreach ($permissions as $resourceName => $permission) { $newRolesConfiguration[$roleIdentifier]['privileges'][] = array('privilegeTarget' => $resourceName, 'permission' => $permission); } } } unset($configuration['acls']); $configuration['roles'] = $newRolesConfiguration; }
php
public function processAcls(array &$configuration) { if (!isset($configuration['acls'])) { return; } $newRolesConfiguration = isset($configuration['roles']) ? $configuration['roles'] : array(); foreach ($configuration['acls'] as $roleIdentifier => $aclConfiguration) { $roleIdentifier = $this->expandRoleIdentifier($roleIdentifier); if (!isset($newRolesConfiguration[$roleIdentifier])) { $newRolesConfiguration[$roleIdentifier] = array(); } if (!isset($newRolesConfiguration[$roleIdentifier]['privileges'])) { $newRolesConfiguration[$roleIdentifier]['privileges'] = array(); } foreach ($aclConfiguration as $resourceType => $permissions) { if ($resourceType !== 'methods' && $resourceType !== 'entities') { $this->showWarning('Resource type "' . $resourceType . '" is not supported...'); continue; } foreach ($permissions as $resourceName => $permission) { $newRolesConfiguration[$roleIdentifier]['privileges'][] = array('privilegeTarget' => $resourceName, 'permission' => $permission); } } } unset($configuration['acls']); $configuration['roles'] = $newRolesConfiguration; }
[ "public", "function", "processAcls", "(", "array", "&", "$", "configuration", ")", "{", "if", "(", "!", "isset", "(", "$", "configuration", "[", "'acls'", "]", ")", ")", "{", "return", ";", "}", "$", "newRolesConfiguration", "=", "isset", "(", "$", "co...
Removes the "acls" configuration and adds privileges to related roles @param array $configuration @return void
[ "Removes", "the", "acls", "configuration", "and", "adds", "privileges", "to", "related", "roles" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Migrations/Code/Version20141113121400.php#L155-L181
neos/flow-development-collection
Neos.Flow/Migrations/Code/Version20141113121400.php
Version20141113121400.expandRoleIdentifier
protected function expandRoleIdentifier($roleIdentifier) { if (strpos($roleIdentifier, ':') !== false) { return $roleIdentifier; } if (in_array($roleIdentifier, array('Everybody', 'Anonymous', 'AuthenticatedUser'))) { return 'Neos.Flow:' . $roleIdentifier; } return $this->targetPackageData['packageKey'] . ':' . $roleIdentifier; }
php
protected function expandRoleIdentifier($roleIdentifier) { if (strpos($roleIdentifier, ':') !== false) { return $roleIdentifier; } if (in_array($roleIdentifier, array('Everybody', 'Anonymous', 'AuthenticatedUser'))) { return 'Neos.Flow:' . $roleIdentifier; } return $this->targetPackageData['packageKey'] . ':' . $roleIdentifier; }
[ "protected", "function", "expandRoleIdentifier", "(", "$", "roleIdentifier", ")", "{", "if", "(", "strpos", "(", "$", "roleIdentifier", ",", "':'", ")", "!==", "false", ")", "{", "return", "$", "roleIdentifier", ";", "}", "if", "(", "in_array", "(", "$", ...
Convert a "relative" role identifier to one that includes the package key @param string $roleIdentifier @return string
[ "Convert", "a", "relative", "role", "identifier", "to", "one", "that", "includes", "the", "package", "key" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Migrations/Code/Version20141113121400.php#L189-L198
neos/flow-development-collection
Neos.Eel/Classes/Helper/DateHelper.php
DateHelper.format
public function format($date, $format) { if ($date instanceof \DateTimeInterface) { return $date->format($format); } elseif ($date instanceof \DateInterval) { return $date->format($format); } elseif ($date === 'now') { return date($format); } else { $timestamp = (integer)$date; return date($format, $timestamp); } }
php
public function format($date, $format) { if ($date instanceof \DateTimeInterface) { return $date->format($format); } elseif ($date instanceof \DateInterval) { return $date->format($format); } elseif ($date === 'now') { return date($format); } else { $timestamp = (integer)$date; return date($format, $timestamp); } }
[ "public", "function", "format", "(", "$", "date", ",", "$", "format", ")", "{", "if", "(", "$", "date", "instanceof", "\\", "DateTimeInterface", ")", "{", "return", "$", "date", "->", "format", "(", "$", "format", ")", ";", "}", "elseif", "(", "$", ...
Format a date (or interval) to a string with a given format See formatting options as in PHP date() @param integer|string|\DateTime|\DateInterval $date @param string $format @return string
[ "Format", "a", "date", "(", "or", "interval", ")", "to", "a", "string", "with", "a", "given", "format" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Eel/Classes/Helper/DateHelper.php#L58-L70
neos/flow-development-collection
Neos.Eel/Classes/Helper/DateHelper.php
DateHelper.formatCldr
public function formatCldr($date, $cldrFormat, $locale = null) { if ($date === 'now') { $date = new \DateTime(); } elseif (is_int($date)) { $timestamp = $date; $date = new \DateTime(); $date->setTimestamp($timestamp); } elseif (!$date instanceof \DateTimeInterface) { throw new \InvalidArgumentException('The given date "' . $date . '" was neither an integer, "now" or a \DateTimeInterface instance.'); } if (empty($cldrFormat)) { throw new \InvalidArgumentException('CLDR date formatting parameter not passed.'); } if ($locale === null) { $useLocale = $this->localizationService->getConfiguration()->getCurrentLocale(); } else { $useLocale = new Locale($locale); } return $this->datetimeFormatter->formatDateTimeWithCustomPattern($date, $cldrFormat, $useLocale); }
php
public function formatCldr($date, $cldrFormat, $locale = null) { if ($date === 'now') { $date = new \DateTime(); } elseif (is_int($date)) { $timestamp = $date; $date = new \DateTime(); $date->setTimestamp($timestamp); } elseif (!$date instanceof \DateTimeInterface) { throw new \InvalidArgumentException('The given date "' . $date . '" was neither an integer, "now" or a \DateTimeInterface instance.'); } if (empty($cldrFormat)) { throw new \InvalidArgumentException('CLDR date formatting parameter not passed.'); } if ($locale === null) { $useLocale = $this->localizationService->getConfiguration()->getCurrentLocale(); } else { $useLocale = new Locale($locale); } return $this->datetimeFormatter->formatDateTimeWithCustomPattern($date, $cldrFormat, $useLocale); }
[ "public", "function", "formatCldr", "(", "$", "date", ",", "$", "cldrFormat", ",", "$", "locale", "=", "null", ")", "{", "if", "(", "$", "date", "===", "'now'", ")", "{", "$", "date", "=", "new", "\\", "DateTime", "(", ")", ";", "}", "elseif", "(...
Format a date to a string with a given cldr format @param integer|string|\DateTime $date @param string $cldrFormat Format string in CLDR format (see http://cldr.unicode.org/translation/date-time) @param null|string $locale String locale - example (de|en|ru_RU) @return string
[ "Format", "a", "date", "to", "a", "string", "with", "a", "given", "cldr", "format" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Eel/Classes/Helper/DateHelper.php#L80-L100
neos/flow-development-collection
Neos.Eel/Classes/Helper/DateHelper.php
DateHelper.add
public function add($date, $interval) { if (!$interval instanceof \DateInterval) { $interval = new \DateInterval($interval); } $result = clone $date; return $result->add($interval); }
php
public function add($date, $interval) { if (!$interval instanceof \DateInterval) { $interval = new \DateInterval($interval); } $result = clone $date; return $result->add($interval); }
[ "public", "function", "add", "(", "$", "date", ",", "$", "interval", ")", "{", "if", "(", "!", "$", "interval", "instanceof", "\\", "DateInterval", ")", "{", "$", "interval", "=", "new", "\\", "DateInterval", "(", "$", "interval", ")", ";", "}", "$",...
Add an interval to a date and return a new DateTime object @param \DateTime $date @param string|\DateInterval $interval @return \DateTime
[ "Add", "an", "interval", "to", "a", "date", "and", "return", "a", "new", "DateTime", "object" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Eel/Classes/Helper/DateHelper.php#L149-L156
neos/flow-development-collection
Neos.Eel/Classes/Helper/DateHelper.php
DateHelper.subtract
public function subtract($date, $interval) { if (!$interval instanceof \DateInterval) { $interval = new \DateInterval($interval); } $result = clone $date; return $result->sub($interval); }
php
public function subtract($date, $interval) { if (!$interval instanceof \DateInterval) { $interval = new \DateInterval($interval); } $result = clone $date; return $result->sub($interval); }
[ "public", "function", "subtract", "(", "$", "date", ",", "$", "interval", ")", "{", "if", "(", "!", "$", "interval", "instanceof", "\\", "DateInterval", ")", "{", "$", "interval", "=", "new", "\\", "DateInterval", "(", "$", "interval", ")", ";", "}", ...
Subtract an interval from a date and return a new DateTime object @param \DateTime $date @param string|\DateInterval $interval @return \DateTime
[ "Subtract", "an", "interval", "from", "a", "date", "and", "return", "a", "new", "DateTime", "object" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Eel/Classes/Helper/DateHelper.php#L165-L172
neos/flow-development-collection
Neos.Cache/Classes/Backend/ApcuBackend.php
ApcuBackend.setCache
public function setCache(FrontendInterface $cache) { parent::setCache($cache); $pathHash = substr(md5($this->environmentConfiguration->getApplicationIdentifier() . $cache->getIdentifier()), 0, 12); $this->identifierPrefix = 'Flow_' . $pathHash . '_'; }
php
public function setCache(FrontendInterface $cache) { parent::setCache($cache); $pathHash = substr(md5($this->environmentConfiguration->getApplicationIdentifier() . $cache->getIdentifier()), 0, 12); $this->identifierPrefix = 'Flow_' . $pathHash . '_'; }
[ "public", "function", "setCache", "(", "FrontendInterface", "$", "cache", ")", "{", "parent", "::", "setCache", "(", "$", "cache", ")", ";", "$", "pathHash", "=", "substr", "(", "md5", "(", "$", "this", "->", "environmentConfiguration", "->", "getApplication...
Initializes the identifier prefix when setting the cache. @param FrontendInterface $cache @return void
[ "Initializes", "the", "identifier", "prefix", "when", "setting", "the", "cache", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Cache/Classes/Backend/ApcuBackend.php#L80-L86
neos/flow-development-collection
Neos.Cache/Classes/Backend/ApcuBackend.php
ApcuBackend.set
public function set(string $entryIdentifier, string $data, array $tags = [], int $lifetime = null) { if (!$this->cache instanceof FrontendInterface) { throw new Exception('No cache frontend has been set yet via setCache().', 1232986818); } $tags[] = '%APCUBE%' . $this->cacheIdentifier; $expiration = $lifetime !== null ? $lifetime : $this->defaultLifetime; $success = apcu_store($this->identifierPrefix . 'entry_' . $entryIdentifier, $data, $expiration); if ($success === true) { $this->removeIdentifierFromAllTags($entryIdentifier); $this->addIdentifierToTags($entryIdentifier, $tags); } else { throw new Exception('Could not set value.', 1232986877); } }
php
public function set(string $entryIdentifier, string $data, array $tags = [], int $lifetime = null) { if (!$this->cache instanceof FrontendInterface) { throw new Exception('No cache frontend has been set yet via setCache().', 1232986818); } $tags[] = '%APCUBE%' . $this->cacheIdentifier; $expiration = $lifetime !== null ? $lifetime : $this->defaultLifetime; $success = apcu_store($this->identifierPrefix . 'entry_' . $entryIdentifier, $data, $expiration); if ($success === true) { $this->removeIdentifierFromAllTags($entryIdentifier); $this->addIdentifierToTags($entryIdentifier, $tags); } else { throw new Exception('Could not set value.', 1232986877); } }
[ "public", "function", "set", "(", "string", "$", "entryIdentifier", ",", "string", "$", "data", ",", "array", "$", "tags", "=", "[", "]", ",", "int", "$", "lifetime", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->", "cache", "instanceof", ...
Saves data in the cache. @param string $entryIdentifier An identifier for this specific cache entry @param string $data The data to be stored @param array $tags Tags to associate with this cache entry @param integer $lifetime Lifetime of this cache entry in seconds. If NULL is specified, the default lifetime is used. "0" means unlimited lifetime. @return void @throws Exception if no cache frontend has been set. @throws \InvalidArgumentException if the identifier is not valid @api
[ "Saves", "data", "in", "the", "cache", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Cache/Classes/Backend/ApcuBackend.php#L118-L134
neos/flow-development-collection
Neos.Cache/Classes/Backend/ApcuBackend.php
ApcuBackend.get
public function get(string $entryIdentifier) { $success = false; $value = apcu_fetch($this->identifierPrefix . 'entry_' . $entryIdentifier, $success); return ($success ? $value : $success); }
php
public function get(string $entryIdentifier) { $success = false; $value = apcu_fetch($this->identifierPrefix . 'entry_' . $entryIdentifier, $success); return ($success ? $value : $success); }
[ "public", "function", "get", "(", "string", "$", "entryIdentifier", ")", "{", "$", "success", "=", "false", ";", "$", "value", "=", "apcu_fetch", "(", "$", "this", "->", "identifierPrefix", ".", "'entry_'", ".", "$", "entryIdentifier", ",", "$", "success",...
Loads data from the cache. @param string $entryIdentifier An identifier which describes the cache entry to load @return mixed The cache entry's content as a string or false if the cache entry could not be loaded @api
[ "Loads", "data", "from", "the", "cache", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Cache/Classes/Backend/ApcuBackend.php#L143-L148
neos/flow-development-collection
Neos.Cache/Classes/Backend/ApcuBackend.php
ApcuBackend.has
public function has(string $entryIdentifier): bool { $success = false; apcu_fetch($this->identifierPrefix . 'entry_' . $entryIdentifier, $success); return $success; }
php
public function has(string $entryIdentifier): bool { $success = false; apcu_fetch($this->identifierPrefix . 'entry_' . $entryIdentifier, $success); return $success; }
[ "public", "function", "has", "(", "string", "$", "entryIdentifier", ")", ":", "bool", "{", "$", "success", "=", "false", ";", "apcu_fetch", "(", "$", "this", "->", "identifierPrefix", ".", "'entry_'", ".", "$", "entryIdentifier", ",", "$", "success", ")", ...
Checks if a cache entry with the specified identifier exists. @param string $entryIdentifier An identifier specifying the cache entry @return boolean true if such an entry exists, false if not @api
[ "Checks", "if", "a", "cache", "entry", "with", "the", "specified", "identifier", "exists", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Cache/Classes/Backend/ApcuBackend.php#L157-L162
neos/flow-development-collection
Neos.Cache/Classes/Backend/ApcuBackend.php
ApcuBackend.remove
public function remove(string $entryIdentifier): bool { $this->removeIdentifierFromAllTags($entryIdentifier); return apcu_delete($this->identifierPrefix . 'entry_' . $entryIdentifier); }
php
public function remove(string $entryIdentifier): bool { $this->removeIdentifierFromAllTags($entryIdentifier); return apcu_delete($this->identifierPrefix . 'entry_' . $entryIdentifier); }
[ "public", "function", "remove", "(", "string", "$", "entryIdentifier", ")", ":", "bool", "{", "$", "this", "->", "removeIdentifierFromAllTags", "(", "$", "entryIdentifier", ")", ";", "return", "apcu_delete", "(", "$", "this", "->", "identifierPrefix", ".", "'e...
Removes all cache entries matching the specified identifier. Usually this only affects one entry but if - for what reason ever - old entries for the identifier still exist, they are removed as well. @param string $entryIdentifier Specifies the cache entry to remove @return boolean true if (at least) an entry could be removed or false if no entry was found @api
[ "Removes", "all", "cache", "entries", "matching", "the", "specified", "identifier", ".", "Usually", "this", "only", "affects", "one", "entry", "but", "if", "-", "for", "what", "reason", "ever", "-", "old", "entries", "for", "the", "identifier", "still", "exi...
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Cache/Classes/Backend/ApcuBackend.php#L173-L177
neos/flow-development-collection
Neos.Cache/Classes/Backend/ApcuBackend.php
ApcuBackend.findIdentifiersByTag
public function findIdentifiersByTag(string $tag): array { $success = false; $identifiers = apcu_fetch($this->identifierPrefix . 'tag_' . $tag, $success); if ($success === false) { return []; } return (array) $identifiers; }
php
public function findIdentifiersByTag(string $tag): array { $success = false; $identifiers = apcu_fetch($this->identifierPrefix . 'tag_' . $tag, $success); if ($success === false) { return []; } return (array) $identifiers; }
[ "public", "function", "findIdentifiersByTag", "(", "string", "$", "tag", ")", ":", "array", "{", "$", "success", "=", "false", ";", "$", "identifiers", "=", "apcu_fetch", "(", "$", "this", "->", "identifierPrefix", ".", "'tag_'", ".", "$", "tag", ",", "$...
Finds and returns all cache entry identifiers which are tagged by the specified tag. @param string $tag The tag to search for @return array An array with identifiers of all matching entries. An empty array if no entries matched @api
[ "Finds", "and", "returns", "all", "cache", "entry", "identifiers", "which", "are", "tagged", "by", "the", "specified", "tag", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Cache/Classes/Backend/ApcuBackend.php#L187-L195