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.Cache/Classes/Backend/ApcuBackend.php
ApcuBackend.findTagsByIdentifier
protected function findTagsByIdentifier(string $identifier): array { $success = false; $tags = apcu_fetch($this->identifierPrefix . 'ident_' . $identifier, $success); return ($success ? (array)$tags : []); }
php
protected function findTagsByIdentifier(string $identifier): array { $success = false; $tags = apcu_fetch($this->identifierPrefix . 'ident_' . $identifier, $success); return ($success ? (array)$tags : []); }
[ "protected", "function", "findTagsByIdentifier", "(", "string", "$", "identifier", ")", ":", "array", "{", "$", "success", "=", "false", ";", "$", "tags", "=", "apcu_fetch", "(", "$", "this", "->", "identifierPrefix", ".", "'ident_'", ".", "$", "identifier",...
Finds all tags for the given identifier. This function uses reverse tag index to search for tags. @param string $identifier Identifier to find tags by @return array Array with tags
[ "Finds", "all", "tags", "for", "the", "given", "identifier", ".", "This", "function", "uses", "reverse", "tag", "index", "to", "search", "for", "tags", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Cache/Classes/Backend/ApcuBackend.php#L204-L209
neos/flow-development-collection
Neos.Cache/Classes/Backend/ApcuBackend.php
ApcuBackend.removeIdentifierFromAllTags
protected function removeIdentifierFromAllTags(string $entryIdentifier) { // Get tags for this identifier $tags = $this->findTagsByIdentifier($entryIdentifier); // Deassociate tags with this identifier foreach ($tags as $tag) { $identifiers = $this->findIdentifiersByTag($tag); // Formally array_search() below should never return false due to // the behavior of findTagsByIdentifier(). But if reverse index is // corrupted, we still can get 'false' from array_search(). This is // not a problem because we are removing this identifier from // anywhere. if (($key = array_search($entryIdentifier, $identifiers)) === false) { continue; } unset($identifiers[$key]); if (count($identifiers)) { apcu_store($this->identifierPrefix . 'tag_' . $tag, $identifiers); } else { apcu_delete($this->identifierPrefix . 'tag_' . $tag); } } // Clear reverse tag index for this identifier apcu_delete($this->identifierPrefix . 'ident_' . $entryIdentifier); }
php
protected function removeIdentifierFromAllTags(string $entryIdentifier) { // Get tags for this identifier $tags = $this->findTagsByIdentifier($entryIdentifier); // Deassociate tags with this identifier foreach ($tags as $tag) { $identifiers = $this->findIdentifiersByTag($tag); // Formally array_search() below should never return false due to // the behavior of findTagsByIdentifier(). But if reverse index is // corrupted, we still can get 'false' from array_search(). This is // not a problem because we are removing this identifier from // anywhere. if (($key = array_search($entryIdentifier, $identifiers)) === false) { continue; } unset($identifiers[$key]); if (count($identifiers)) { apcu_store($this->identifierPrefix . 'tag_' . $tag, $identifiers); } else { apcu_delete($this->identifierPrefix . 'tag_' . $tag); } } // Clear reverse tag index for this identifier apcu_delete($this->identifierPrefix . 'ident_' . $entryIdentifier); }
[ "protected", "function", "removeIdentifierFromAllTags", "(", "string", "$", "entryIdentifier", ")", "{", "// Get tags for this identifier", "$", "tags", "=", "$", "this", "->", "findTagsByIdentifier", "(", "$", "entryIdentifier", ")", ";", "// Deassociate tags with this i...
Removes association of the identifier with the given tags @param string $entryIdentifier @return void
[ "Removes", "association", "of", "the", "identifier", "with", "the", "given", "tags" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Cache/Classes/Backend/ApcuBackend.php#L273-L297
neos/flow-development-collection
Neos.Cache/Classes/Backend/ApcuBackend.php
ApcuBackend.key
public function key(): string { if ($this->cacheEntriesIterator === null) { $this->rewind(); } return substr($this->cacheEntriesIterator->key(), strlen($this->identifierPrefix . 'entry_')); }
php
public function key(): string { if ($this->cacheEntriesIterator === null) { $this->rewind(); } return substr($this->cacheEntriesIterator->key(), strlen($this->identifierPrefix . 'entry_')); }
[ "public", "function", "key", "(", ")", ":", "string", "{", "if", "(", "$", "this", "->", "cacheEntriesIterator", "===", "null", ")", "{", "$", "this", "->", "rewind", "(", ")", ";", "}", "return", "substr", "(", "$", "this", "->", "cacheEntriesIterator...
Returns the identifier of the current cache entry pointed to by the cache entry iterator. @return string @api
[ "Returns", "the", "identifier", "of", "the", "current", "cache", "entry", "pointed", "to", "by", "the", "cache", "entry", "iterator", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Cache/Classes/Backend/ApcuBackend.php#L345-L351
neos/flow-development-collection
Neos.Cache/Classes/Backend/ApcuBackend.php
ApcuBackend.rewind
public function rewind() { if ($this->cacheEntriesIterator === null) { $this->cacheEntriesIterator = new \APCUIterator('/^' . $this->identifierPrefix . 'entry_.*/'); } else { $this->cacheEntriesIterator->rewind(); } }
php
public function rewind() { if ($this->cacheEntriesIterator === null) { $this->cacheEntriesIterator = new \APCUIterator('/^' . $this->identifierPrefix . 'entry_.*/'); } else { $this->cacheEntriesIterator->rewind(); } }
[ "public", "function", "rewind", "(", ")", "{", "if", "(", "$", "this", "->", "cacheEntriesIterator", "===", "null", ")", "{", "$", "this", "->", "cacheEntriesIterator", "=", "new", "\\", "APCUIterator", "(", "'/^'", ".", "$", "this", "->", "identifierPrefi...
Rewinds the cache entry iterator to the first element @return void @api
[ "Rewinds", "the", "cache", "entry", "iterator", "to", "the", "first", "element" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Cache/Classes/Backend/ApcuBackend.php#L373-L380
neos/flow-development-collection
Neos.Flow/Classes/Mvc/View/SimpleTemplateView.php
SimpleTemplateView.render
public function render() { $source = $this->getOption('templateSource'); $templatePathAndFilename = $this->getOption('templatePathAndFilename'); if ($templatePathAndFilename !== null) { $source = file_get_contents($templatePathAndFilename); } return preg_replace_callback('/\{([a-zA-Z0-9\-_.]+)\}/', function ($matches) { return ObjectAccess::getPropertyPath($this->variables, $matches[1]); }, $source); }
php
public function render() { $source = $this->getOption('templateSource'); $templatePathAndFilename = $this->getOption('templatePathAndFilename'); if ($templatePathAndFilename !== null) { $source = file_get_contents($templatePathAndFilename); } return preg_replace_callback('/\{([a-zA-Z0-9\-_.]+)\}/', function ($matches) { return ObjectAccess::getPropertyPath($this->variables, $matches[1]); }, $source); }
[ "public", "function", "render", "(", ")", "{", "$", "source", "=", "$", "this", "->", "getOption", "(", "'templateSource'", ")", ";", "$", "templatePathAndFilename", "=", "$", "this", "->", "getOption", "(", "'templatePathAndFilename'", ")", ";", "if", "(", ...
Renders the view @return string The rendered view @api
[ "Renders", "the", "view" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Mvc/View/SimpleTemplateView.php#L37-L48
neos/flow-development-collection
Neos.Flow/Classes/Security/Authorization/Privilege/Method/MethodPrivilegePointcutFilter.php
MethodPrivilegePointcutFilter.injectObjectManager
public function injectObjectManager(ObjectManagerInterface $objectManager) { $this->objectManager = $objectManager; /** @var CacheManager $cacheManager */ $cacheManager = $this->objectManager->get(CacheManager::class); $this->methodPermissionCache = $cacheManager->getCache('Flow_Security_Authorization_Privilege_Method'); $this->runtimeExpressionEvaluator = $this->objectManager->get(RuntimeExpressionEvaluator::class); }
php
public function injectObjectManager(ObjectManagerInterface $objectManager) { $this->objectManager = $objectManager; /** @var CacheManager $cacheManager */ $cacheManager = $this->objectManager->get(CacheManager::class); $this->methodPermissionCache = $cacheManager->getCache('Flow_Security_Authorization_Privilege_Method'); $this->runtimeExpressionEvaluator = $this->objectManager->get(RuntimeExpressionEvaluator::class); }
[ "public", "function", "injectObjectManager", "(", "ObjectManagerInterface", "$", "objectManager", ")", "{", "$", "this", "->", "objectManager", "=", "$", "objectManager", ";", "/** @var CacheManager $cacheManager */", "$", "cacheManager", "=", "$", "this", "->", "obje...
This object is created very early so we can't rely on AOP for the property injection @param ObjectManagerInterface $objectManager @return void @throws \Neos\Cache\Exception\NoSuchCacheException
[ "This", "object", "is", "created", "very", "early", "so", "we", "can", "t", "rely", "on", "AOP", "for", "the", "property", "injection" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Authorization/Privilege/Method/MethodPrivilegePointcutFilter.php#L63-L70
neos/flow-development-collection
Neos.Flow/Classes/Security/Authorization/Privilege/Method/MethodPrivilegePointcutFilter.php
MethodPrivilegePointcutFilter.matches
public function matches($className, $methodName, $methodDeclaringClassName, $pointcutQueryIdentifier): bool { if ($this->filters === null) { $this->buildPointcutFilters(); } $matchingFilters = array_filter($this->filters, $this->getFilterEvaluator($className, $methodName, $methodDeclaringClassName, $pointcutQueryIdentifier)); if ($matchingFilters === []) { return false; } /** @var PointcutFilterComposite $filter */ foreach ($matchingFilters as $privilegeIdentifier => $filter) { $methodIdentifier = strtolower($className . '->' . $methodName); $hasRuntimeEvaluations = false; if ($filter->hasRuntimeEvaluationsDefinition() === true) { $hasRuntimeEvaluations = true; $this->runtimeExpressionEvaluator->addExpression($privilegeIdentifier, $filter->getRuntimeEvaluationsClosureCode()); } $this->methodPermissions[$methodIdentifier][$privilegeIdentifier]['privilegeMatchesMethod'] = true; $this->methodPermissions[$methodIdentifier][$privilegeIdentifier]['hasRuntimeEvaluations'] = $hasRuntimeEvaluations; } return true; }
php
public function matches($className, $methodName, $methodDeclaringClassName, $pointcutQueryIdentifier): bool { if ($this->filters === null) { $this->buildPointcutFilters(); } $matchingFilters = array_filter($this->filters, $this->getFilterEvaluator($className, $methodName, $methodDeclaringClassName, $pointcutQueryIdentifier)); if ($matchingFilters === []) { return false; } /** @var PointcutFilterComposite $filter */ foreach ($matchingFilters as $privilegeIdentifier => $filter) { $methodIdentifier = strtolower($className . '->' . $methodName); $hasRuntimeEvaluations = false; if ($filter->hasRuntimeEvaluationsDefinition() === true) { $hasRuntimeEvaluations = true; $this->runtimeExpressionEvaluator->addExpression($privilegeIdentifier, $filter->getRuntimeEvaluationsClosureCode()); } $this->methodPermissions[$methodIdentifier][$privilegeIdentifier]['privilegeMatchesMethod'] = true; $this->methodPermissions[$methodIdentifier][$privilegeIdentifier]['hasRuntimeEvaluations'] = $hasRuntimeEvaluations; } return true; }
[ "public", "function", "matches", "(", "$", "className", ",", "$", "methodName", ",", "$", "methodDeclaringClassName", ",", "$", "pointcutQueryIdentifier", ")", ":", "bool", "{", "if", "(", "$", "this", "->", "filters", "===", "null", ")", "{", "$", "this",...
Checks if the specified class and method matches against the filter, i.e. if there is a policy entry to intercept this method. This method also creates a cache entry for every method, to cache the associated roles and privileges. @param string $className Name of the class to check the name of @param string $methodName Name of the method to check the name of @param string $methodDeclaringClassName Name of the class the method was originally declared in @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 names match, otherwise false
[ "Checks", "if", "the", "specified", "class", "and", "method", "matches", "against", "the", "filter", "i", ".", "e", ".", "if", "there", "is", "a", "policy", "entry", "to", "intercept", "this", "method", ".", "This", "method", "also", "creates", "a", "cac...
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Authorization/Privilege/Method/MethodPrivilegePointcutFilter.php#L92-L119
neos/flow-development-collection
Neos.Flow/Classes/Security/Authorization/Privilege/Method/MethodPrivilegePointcutFilter.php
MethodPrivilegePointcutFilter.reduceTargetClassNames
public function reduceTargetClassNames(ClassNameIndex $classNameIndex): ClassNameIndex { if ($this->filters === null) { $this->buildPointcutFilters(); } $result = new ClassNameIndex(); foreach ($this->filters as $filter) { $result->applyUnion($filter->reduceTargetClassNames($classNameIndex)); } return $result; }
php
public function reduceTargetClassNames(ClassNameIndex $classNameIndex): ClassNameIndex { if ($this->filters === null) { $this->buildPointcutFilters(); } $result = new ClassNameIndex(); foreach ($this->filters as $filter) { $result->applyUnion($filter->reduceTargetClassNames($classNameIndex)); } return $result; }
[ "public", "function", "reduceTargetClassNames", "(", "ClassNameIndex", "$", "classNameIndex", ")", ":", "ClassNameIndex", "{", "if", "(", "$", "this", "->", "filters", "===", "null", ")", "{", "$", "this", "->", "buildPointcutFilters", "(", ")", ";", "}", "$...
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/Security/Authorization/Privilege/Method/MethodPrivilegePointcutFilter.php#L147-L158
neos/flow-development-collection
Neos.Flow/Classes/Security/Authorization/Privilege/Method/MethodPrivilegePointcutFilter.php
MethodPrivilegePointcutFilter.buildPointcutFilters
protected function buildPointcutFilters() { $this->filters = []; /** @var PolicyService $policyService */ $policyService = $this->objectManager->get(PolicyService::class); /** @var MethodPrivilegeInterface[] $methodPrivileges */ $methodPrivileges = $policyService->getAllPrivilegesByType(MethodPrivilegeInterface::class); foreach ($methodPrivileges as $privilege) { $this->filters[$privilege->getCacheEntryIdentifier()] = $privilege->getPointcutFilterComposite(); } }
php
protected function buildPointcutFilters() { $this->filters = []; /** @var PolicyService $policyService */ $policyService = $this->objectManager->get(PolicyService::class); /** @var MethodPrivilegeInterface[] $methodPrivileges */ $methodPrivileges = $policyService->getAllPrivilegesByType(MethodPrivilegeInterface::class); foreach ($methodPrivileges as $privilege) { $this->filters[$privilege->getCacheEntryIdentifier()] = $privilege->getPointcutFilterComposite(); } }
[ "protected", "function", "buildPointcutFilters", "(", ")", "{", "$", "this", "->", "filters", "=", "[", "]", ";", "/** @var PolicyService $policyService */", "$", "policyService", "=", "$", "this", "->", "objectManager", "->", "get", "(", "PolicyService", "::", ...
Builds the needed pointcut filters for matching the policy privileges @return void
[ "Builds", "the", "needed", "pointcut", "filters", "for", "matching", "the", "policy", "privileges" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Authorization/Privilege/Method/MethodPrivilegePointcutFilter.php#L179-L189
neos/flow-development-collection
Neos.Flow/Classes/Security/Authorization/Privilege/Method/MethodPrivilegePointcutFilter.php
MethodPrivilegePointcutFilter.savePolicyCache
public function savePolicyCache() { $tags = ['Neos_Flow_Aop']; if (!$this->methodPermissionCache->has('methodPermission')) { $this->methodPermissionCache->set('methodPermission', $this->methodPermissions, $tags); } }
php
public function savePolicyCache() { $tags = ['Neos_Flow_Aop']; if (!$this->methodPermissionCache->has('methodPermission')) { $this->methodPermissionCache->set('methodPermission', $this->methodPermissions, $tags); } }
[ "public", "function", "savePolicyCache", "(", ")", "{", "$", "tags", "=", "[", "'Neos_Flow_Aop'", "]", ";", "if", "(", "!", "$", "this", "->", "methodPermissionCache", "->", "has", "(", "'methodPermission'", ")", ")", "{", "$", "this", "->", "methodPermiss...
Save the found matches to the cache. @return void
[ "Save", "the", "found", "matches", "to", "the", "cache", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Authorization/Privilege/Method/MethodPrivilegePointcutFilter.php#L196-L202
neos/flow-development-collection
Neos.Flow/Classes/Property/PropertyMappingConfiguration.php
PropertyMappingConfiguration.shouldMap
public function shouldMap($propertyName) { if (isset($this->propertiesNotToBeMapped[$propertyName])) { return false; } if (isset($this->propertiesToBeMapped[$propertyName])) { return true; } if (isset($this->subConfigurationForProperty[self::PROPERTY_PATH_PLACEHOLDER])) { return true; } return $this->mapUnknownProperties; }
php
public function shouldMap($propertyName) { if (isset($this->propertiesNotToBeMapped[$propertyName])) { return false; } if (isset($this->propertiesToBeMapped[$propertyName])) { return true; } if (isset($this->subConfigurationForProperty[self::PROPERTY_PATH_PLACEHOLDER])) { return true; } return $this->mapUnknownProperties; }
[ "public", "function", "shouldMap", "(", "$", "propertyName", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "propertiesNotToBeMapped", "[", "$", "propertyName", "]", ")", ")", "{", "return", "false", ";", "}", "if", "(", "isset", "(", "$", "this...
The behavior is as follows: - if a property has been explicitly forbidden using allowAllPropertiesExcept(...), it is directly rejected - if a property has been allowed using allowProperties(...), it is directly allowed. - if allowAllProperties* has been called, we allow unknown properties - else, return false. @param string $propertyName @return boolean true if the given propertyName should be mapped, false otherwise.
[ "The", "behavior", "is", "as", "follows", ":" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Property/PropertyMappingConfiguration.php#L101-L116
neos/flow-development-collection
Neos.Flow/Classes/Property/PropertyMappingConfiguration.php
PropertyMappingConfiguration.allowProperties
public function allowProperties(string ...$propertyNames) { foreach ($propertyNames as $propertyName) { $this->propertiesToBeMapped[$propertyName] = $propertyName; } return $this; }
php
public function allowProperties(string ...$propertyNames) { foreach ($propertyNames as $propertyName) { $this->propertiesToBeMapped[$propertyName] = $propertyName; } return $this; }
[ "public", "function", "allowProperties", "(", "string", "...", "$", "propertyNames", ")", "{", "foreach", "(", "$", "propertyNames", "as", "$", "propertyName", ")", "{", "$", "this", "->", "propertiesToBeMapped", "[", "$", "propertyName", "]", "=", "$", "pro...
Allow a list of specific properties. All arguments of allowProperties are used here (varargs). Example: allowProperties('title', 'content', 'author') @param string ...$propertyNames @return PropertyMappingConfiguration this @api
[ "Allow", "a", "list", "of", "specific", "properties", ".", "All", "arguments", "of", "allowProperties", "are", "used", "here", "(", "varargs", ")", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Property/PropertyMappingConfiguration.php#L152-L158
neos/flow-development-collection
Neos.Flow/Classes/Property/PropertyMappingConfiguration.php
PropertyMappingConfiguration.skipProperties
public function skipProperties(string ...$propertyNames) { foreach ($propertyNames as $propertyName) { $this->propertiesToSkip[$propertyName] = $propertyName; } return $this; }
php
public function skipProperties(string ...$propertyNames) { foreach ($propertyNames as $propertyName) { $this->propertiesToSkip[$propertyName] = $propertyName; } return $this; }
[ "public", "function", "skipProperties", "(", "string", "...", "$", "propertyNames", ")", "{", "foreach", "(", "$", "propertyNames", "as", "$", "propertyName", ")", "{", "$", "this", "->", "propertiesToSkip", "[", "$", "propertyName", "]", "=", "$", "property...
Skip a list of specific properties. All arguments of skipProperties are used here (varargs). Example: skipProperties('unused', 'dummy') @param string ...$propertyNames @return PropertyMappingConfiguration this @api
[ "Skip", "a", "list", "of", "specific", "properties", ".", "All", "arguments", "of", "skipProperties", "are", "used", "here", "(", "varargs", ")", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Property/PropertyMappingConfiguration.php#L170-L176
neos/flow-development-collection
Neos.Flow/Classes/Property/PropertyMappingConfiguration.php
PropertyMappingConfiguration.allowAllPropertiesExcept
public function allowAllPropertiesExcept(string ...$propertyNames) { $this->mapUnknownProperties = true; foreach ($propertyNames as $propertyName) { $this->propertiesNotToBeMapped[$propertyName] = $propertyName; } return $this; }
php
public function allowAllPropertiesExcept(string ...$propertyNames) { $this->mapUnknownProperties = true; foreach ($propertyNames as $propertyName) { $this->propertiesNotToBeMapped[$propertyName] = $propertyName; } return $this; }
[ "public", "function", "allowAllPropertiesExcept", "(", "string", "...", "$", "propertyNames", ")", "{", "$", "this", "->", "mapUnknownProperties", "=", "true", ";", "foreach", "(", "$", "propertyNames", "as", "$", "propertyName", ")", "{", "$", "this", "->", ...
Allow all properties during property mapping, but reject a few selected ones (blacklist). Example: allowAllPropertiesExcept('password', 'userGroup') @param string ...$propertyNames @return PropertyMappingConfiguration this @api
[ "Allow", "all", "properties", "during", "property", "mapping", "but", "reject", "a", "few", "selected", "ones", "(", "blacklist", ")", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Property/PropertyMappingConfiguration.php#L188-L196
neos/flow-development-collection
Neos.Flow/Classes/Property/PropertyMappingConfiguration.php
PropertyMappingConfiguration.getConfigurationFor
public function getConfigurationFor($propertyName) { if (isset($this->subConfigurationForProperty[$propertyName])) { return $this->subConfigurationForProperty[$propertyName]; } elseif (isset($this->subConfigurationForProperty[self::PROPERTY_PATH_PLACEHOLDER])) { return $this->subConfigurationForProperty[self::PROPERTY_PATH_PLACEHOLDER]; } return new PropertyMappingConfiguration(); }
php
public function getConfigurationFor($propertyName) { if (isset($this->subConfigurationForProperty[$propertyName])) { return $this->subConfigurationForProperty[$propertyName]; } elseif (isset($this->subConfigurationForProperty[self::PROPERTY_PATH_PLACEHOLDER])) { return $this->subConfigurationForProperty[self::PROPERTY_PATH_PLACEHOLDER]; } return new PropertyMappingConfiguration(); }
[ "public", "function", "getConfigurationFor", "(", "$", "propertyName", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "subConfigurationForProperty", "[", "$", "propertyName", "]", ")", ")", "{", "return", "$", "this", "->", "subConfigurationForProperty", ...
Returns the sub-configuration for the passed $propertyName. Must ALWAYS return a valid configuration object! @param string $propertyName @return PropertyMappingConfigurationInterface the property mapping configuration for the given $propertyName. @api
[ "Returns", "the", "sub", "-", "configuration", "for", "the", "passed", "$propertyName", ".", "Must", "ALWAYS", "return", "a", "valid", "configuration", "object!" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Property/PropertyMappingConfiguration.php#L230-L239
neos/flow-development-collection
Neos.Flow/Classes/Property/PropertyMappingConfiguration.php
PropertyMappingConfiguration.getTargetPropertyName
public function getTargetPropertyName($sourcePropertyName) { if (isset($this->mapping[$sourcePropertyName])) { return $this->mapping[$sourcePropertyName]; } return $sourcePropertyName; }
php
public function getTargetPropertyName($sourcePropertyName) { if (isset($this->mapping[$sourcePropertyName])) { return $this->mapping[$sourcePropertyName]; } return $sourcePropertyName; }
[ "public", "function", "getTargetPropertyName", "(", "$", "sourcePropertyName", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "mapping", "[", "$", "sourcePropertyName", "]", ")", ")", "{", "return", "$", "this", "->", "mapping", "[", "$", "sourcePro...
Maps the given $sourcePropertyName to a target property name. @param string $sourcePropertyName @return string property name of target @api
[ "Maps", "the", "given", "$sourcePropertyName", "to", "a", "target", "property", "name", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Property/PropertyMappingConfiguration.php#L248-L254
neos/flow-development-collection
Neos.Flow/Classes/Property/PropertyMappingConfiguration.php
PropertyMappingConfiguration.setTypeConverterOptions
public function setTypeConverterOptions($typeConverter, array $options) { foreach ($this->getTypeConvertersWithParentClasses($typeConverter) as $typeConverter) { $this->configuration[$typeConverter] = $options; } return $this; }
php
public function setTypeConverterOptions($typeConverter, array $options) { foreach ($this->getTypeConvertersWithParentClasses($typeConverter) as $typeConverter) { $this->configuration[$typeConverter] = $options; } return $this; }
[ "public", "function", "setTypeConverterOptions", "(", "$", "typeConverter", ",", "array", "$", "options", ")", "{", "foreach", "(", "$", "this", "->", "getTypeConvertersWithParentClasses", "(", "$", "typeConverter", ")", "as", "$", "typeConverter", ")", "{", "$"...
Set all options for the given $typeConverter. @param string $typeConverter class name of type converter @param array $options @return PropertyMappingConfiguration this @api
[ "Set", "all", "options", "for", "the", "given", "$typeConverter", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Property/PropertyMappingConfiguration.php#L293-L299
neos/flow-development-collection
Neos.Flow/Classes/Property/PropertyMappingConfiguration.php
PropertyMappingConfiguration.setTypeConverterOption
public function setTypeConverterOption($typeConverter, $optionKey, $optionValue) { foreach ($this->getTypeConvertersWithParentClasses($typeConverter) as $typeConverter) { $this->configuration[$typeConverter][$optionKey] = $optionValue; } return $this; }
php
public function setTypeConverterOption($typeConverter, $optionKey, $optionValue) { foreach ($this->getTypeConvertersWithParentClasses($typeConverter) as $typeConverter) { $this->configuration[$typeConverter][$optionKey] = $optionValue; } return $this; }
[ "public", "function", "setTypeConverterOption", "(", "$", "typeConverter", ",", "$", "optionKey", ",", "$", "optionValue", ")", "{", "foreach", "(", "$", "this", "->", "getTypeConvertersWithParentClasses", "(", "$", "typeConverter", ")", "as", "$", "typeConverter"...
Set a single option (denoted by $optionKey) for the given $typeConverter. @param string $typeConverter class name of type converter @param string $optionKey @param mixed $optionValue @return PropertyMappingConfiguration this @api
[ "Set", "a", "single", "option", "(", "denoted", "by", "$optionKey", ")", "for", "the", "given", "$typeConverter", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Property/PropertyMappingConfiguration.php#L310-L316
neos/flow-development-collection
Neos.Flow/Classes/Property/PropertyMappingConfiguration.php
PropertyMappingConfiguration.getTypeConvertersWithParentClasses
protected function getTypeConvertersWithParentClasses($typeConverter) { $typeConverterClasses = class_parents($typeConverter); $typeConverterClasses = $typeConverterClasses === false ? [] : $typeConverterClasses; $typeConverterClasses[] = $typeConverter; return $typeConverterClasses; }
php
protected function getTypeConvertersWithParentClasses($typeConverter) { $typeConverterClasses = class_parents($typeConverter); $typeConverterClasses = $typeConverterClasses === false ? [] : $typeConverterClasses; $typeConverterClasses[] = $typeConverter; return $typeConverterClasses; }
[ "protected", "function", "getTypeConvertersWithParentClasses", "(", "$", "typeConverter", ")", "{", "$", "typeConverterClasses", "=", "class_parents", "(", "$", "typeConverter", ")", ";", "$", "typeConverterClasses", "=", "$", "typeConverterClasses", "===", "false", "...
Get type converter classes including parents for the given type converter When setting an option on a subclassed type converter, this option must also be set on all its parent type converters. @param string $typeConverter The type converter class @return array Class names of type converters
[ "Get", "type", "converter", "classes", "including", "parents", "for", "the", "given", "type", "converter" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Property/PropertyMappingConfiguration.php#L327-L333
neos/flow-development-collection
Neos.Flow/Classes/Property/PropertyMappingConfiguration.php
PropertyMappingConfiguration.traverseProperties
public function traverseProperties(array $splittedPropertyPath) { if (count($splittedPropertyPath) === 0) { return $this; } $currentProperty = array_shift($splittedPropertyPath); if (!isset($this->subConfigurationForProperty[$currentProperty])) { $type = get_class($this); if (isset($this->subConfigurationForProperty[self::PROPERTY_PATH_PLACEHOLDER])) { $this->subConfigurationForProperty[$currentProperty] = clone $this->subConfigurationForProperty[self::PROPERTY_PATH_PLACEHOLDER]; } else { $this->subConfigurationForProperty[$currentProperty] = new $type; } } return $this->subConfigurationForProperty[$currentProperty]->traverseProperties($splittedPropertyPath); }
php
public function traverseProperties(array $splittedPropertyPath) { if (count($splittedPropertyPath) === 0) { return $this; } $currentProperty = array_shift($splittedPropertyPath); if (!isset($this->subConfigurationForProperty[$currentProperty])) { $type = get_class($this); if (isset($this->subConfigurationForProperty[self::PROPERTY_PATH_PLACEHOLDER])) { $this->subConfigurationForProperty[$currentProperty] = clone $this->subConfigurationForProperty[self::PROPERTY_PATH_PLACEHOLDER]; } else { $this->subConfigurationForProperty[$currentProperty] = new $type; } } return $this->subConfigurationForProperty[$currentProperty]->traverseProperties($splittedPropertyPath); }
[ "public", "function", "traverseProperties", "(", "array", "$", "splittedPropertyPath", ")", "{", "if", "(", "count", "(", "$", "splittedPropertyPath", ")", "===", "0", ")", "{", "return", "$", "this", ";", "}", "$", "currentProperty", "=", "array_shift", "("...
Traverse the property configuration. Only used by forProperty(). @param array $splittedPropertyPath @return PropertyMappingConfiguration (or a subclass thereof)
[ "Traverse", "the", "property", "configuration", ".", "Only", "used", "by", "forProperty", "()", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Property/PropertyMappingConfiguration.php#L356-L372
neos/flow-development-collection
Neos.Flow/Classes/Error/ErrorHandler.php
ErrorHandler.handleError
public function handleError(int $errorLevel, string $errorMessage, string $errorFile, int $errorLine) { if (error_reporting() === 0) { return; } $errorLevels = [ E_WARNING => 'Warning', E_NOTICE => 'Notice', E_USER_ERROR => 'User Error', E_USER_WARNING => 'User Warning', E_USER_NOTICE => 'User Notice', E_STRICT => 'Runtime Notice', E_RECOVERABLE_ERROR => 'Catchable Fatal Error' ]; if (in_array($errorLevel, (array)$this->exceptionalErrors)) { if (class_exists(FlowError\Exception::class)) { throw new FlowError\Exception($errorLevels[$errorLevel] . ': ' . $errorMessage . ' in ' . $errorFile . ' line ' . $errorLine, 1); } else { throw new \Exception($errorLevels[$errorLevel] . ': ' . $errorMessage . ' in ' . $errorFile . ' line ' . $errorLine, 1); } } }
php
public function handleError(int $errorLevel, string $errorMessage, string $errorFile, int $errorLine) { if (error_reporting() === 0) { return; } $errorLevels = [ E_WARNING => 'Warning', E_NOTICE => 'Notice', E_USER_ERROR => 'User Error', E_USER_WARNING => 'User Warning', E_USER_NOTICE => 'User Notice', E_STRICT => 'Runtime Notice', E_RECOVERABLE_ERROR => 'Catchable Fatal Error' ]; if (in_array($errorLevel, (array)$this->exceptionalErrors)) { if (class_exists(FlowError\Exception::class)) { throw new FlowError\Exception($errorLevels[$errorLevel] . ': ' . $errorMessage . ' in ' . $errorFile . ' line ' . $errorLine, 1); } else { throw new \Exception($errorLevels[$errorLevel] . ': ' . $errorMessage . ' in ' . $errorFile . ' line ' . $errorLine, 1); } } }
[ "public", "function", "handleError", "(", "int", "$", "errorLevel", ",", "string", "$", "errorMessage", ",", "string", "$", "errorFile", ",", "int", "$", "errorLine", ")", "{", "if", "(", "error_reporting", "(", ")", "===", "0", ")", "{", "return", ";", ...
Handles an error by converting it into an exception. If error reporting is disabled, either in the php.ini or temporarily through the shut-up operator "@", no exception will be thrown. @param integer $errorLevel The error level - one of the E_* constants @param string $errorMessage The error message @param string $errorFile Name of the file the error occurred in @param integer $errorLine Line number where the error occurred @return void @throws FlowError\Exception with the data passed to this method @throws \Exception
[ "Handles", "an", "error", "by", "converting", "it", "into", "an", "exception", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Error/ErrorHandler.php#L63-L86
neos/flow-development-collection
Neos.Kickstarter/Classes/Utility/Inflector.php
Inflector.humanizeCamelCase
public function humanizeCamelCase($camelCased, $lowercase = false) { $spacified = $this->spacify($camelCased); $result = strtolower($spacified); if (!$lowercase) { $result = ucfirst($result); } return $result; }
php
public function humanizeCamelCase($camelCased, $lowercase = false) { $spacified = $this->spacify($camelCased); $result = strtolower($spacified); if (!$lowercase) { $result = ucfirst($result); } return $result; }
[ "public", "function", "humanizeCamelCase", "(", "$", "camelCased", ",", "$", "lowercase", "=", "false", ")", "{", "$", "spacified", "=", "$", "this", "->", "spacify", "(", "$", "camelCased", ")", ";", "$", "result", "=", "strtolower", "(", "$", "spacifie...
Convert a model class name like "BlogAuthor" or a field name like "blogAuthor" to a humanized version like "Blog author" for better readability. @param string $camelCased The camel cased value @param boolean $lowercase Return lowercase value @return string The humanized value
[ "Convert", "a", "model", "class", "name", "like", "BlogAuthor", "or", "a", "field", "name", "like", "blogAuthor", "to", "a", "humanized", "version", "like", "Blog", "author", "for", "better", "readability", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Kickstarter/Classes/Utility/Inflector.php#L38-L46
neos/flow-development-collection
Neos.Flow/Classes/Mvc/Routing/StaticRoutePart.php
StaticRoutePart.match
public function match(&$routePath) { $this->value = null; if ($this->name === null || $this->name === '') { return false; } if ($routePath === '') { return false; } $valueToMatch = substr($routePath, 0, strlen($this->name)); if ($valueToMatch !== $this->name) { return false; } $shortenedRequestPath = substr($routePath, strlen($valueToMatch)); $routePath = ($shortenedRequestPath !== false) ? $shortenedRequestPath : ''; return true; }
php
public function match(&$routePath) { $this->value = null; if ($this->name === null || $this->name === '') { return false; } if ($routePath === '') { return false; } $valueToMatch = substr($routePath, 0, strlen($this->name)); if ($valueToMatch !== $this->name) { return false; } $shortenedRequestPath = substr($routePath, strlen($valueToMatch)); $routePath = ($shortenedRequestPath !== false) ? $shortenedRequestPath : ''; return true; }
[ "public", "function", "match", "(", "&", "$", "routePath", ")", "{", "$", "this", "->", "value", "=", "null", ";", "if", "(", "$", "this", "->", "name", "===", "null", "||", "$", "this", "->", "name", "===", "''", ")", "{", "return", "false", ";"...
Checks whether this Static Route Part correspond to the given $routePath. This is true if $routePath is not empty and the first part is equal to the Route Part name. @param string $routePath The request path to be matched - without query parameters, host and fragment. @return boolean true if Route Part matched $routePath, otherwise false.
[ "Checks", "whether", "this", "Static", "Route", "Part", "correspond", "to", "the", "given", "$routePath", ".", "This", "is", "true", "if", "$routePath", "is", "not", "empty", "and", "the", "first", "part", "is", "equal", "to", "the", "Route", "Part", "name...
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Mvc/Routing/StaticRoutePart.php#L38-L55
neos/flow-development-collection
Neos.Flow/Classes/Mvc/Routing/StaticRoutePart.php
StaticRoutePart.resolve
public function resolve(array &$routeValues) { if ($this->name === null || $this->name === '') { return false; } $this->value = $this->name; if ($this->lowerCase) { $this->value = strtolower($this->value); } return true; }
php
public function resolve(array &$routeValues) { if ($this->name === null || $this->name === '') { return false; } $this->value = $this->name; if ($this->lowerCase) { $this->value = strtolower($this->value); } return true; }
[ "public", "function", "resolve", "(", "array", "&", "$", "routeValues", ")", "{", "if", "(", "$", "this", "->", "name", "===", "null", "||", "$", "this", "->", "name", "===", "''", ")", "{", "return", "false", ";", "}", "$", "this", "->", "value", ...
Sets the Route Part value to the Route Part name and returns true if successful. @param array $routeValues not used but needed to implement \Neos\Flow\Mvc\Routing\AbstractRoutePart @return boolean
[ "Sets", "the", "Route", "Part", "value", "to", "the", "Route", "Part", "name", "and", "returns", "true", "if", "successful", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Mvc/Routing/StaticRoutePart.php#L63-L73
neos/flow-development-collection
Neos.Flow/Classes/Command/SchemaCommandController.php
SchemaCommandController.validateCommand
public function validateCommand(string $configurationFile = null, string $schemaFile = 'resource://Neos.Flow/Private/Schema/Schema.schema.yaml', bool $verbose = false) { $this->outputLine('Validating <b>' . $configurationFile . '</b> with schema <b>' . $schemaFile . '</b>'); $this->outputLine(); $schema = Yaml::parseFile($schemaFile); if (is_null($configurationFile)) { $result = new Result(); $activePackages = $this->packageManager->getAvailablePackages(); foreach ($activePackages as $package) { $packageKey = $package->getPackageKey(); $packageSchemaPath = Files::concatenatePaths([$package->getResourcesPath(), 'Private/Schema']); if (is_dir($packageSchemaPath) && $packageKey !== 'Neos.Utility.Schema') { foreach (Files::getRecursiveDirectoryGenerator($packageSchemaPath, '.schema.yaml') as $schemaFile) { $configuration = Yaml::parseFile($schemaFile); $schemaPath = str_replace(FLOW_PATH_ROOT, '', $schemaFile); $configurationResult = $this->schemaValidator->validate($configuration, $schema); $result->forProperty($schemaPath)->merge($configurationResult); } } } } else { $configuration = Yaml::parseFile($configurationFile); $result = $this->schemaValidator->validate($configuration, $schema); } if ($verbose) { $this->outputLine(); if ($result->hasNotices()) { $notices = $result->getFlattenedNotices(); $this->outputLine('<b>%d notices:</b>', [count($notices)]); /** @var Notice $notice */ foreach ($notices as $path => $pathNotices) { foreach ($pathNotices as $notice) { $this->outputLine(' - %s -> %s', [$path, $notice->render()]); } } $this->outputLine(); } } if ($result->hasErrors()) { $errors = $result->getFlattenedErrors(); $this->outputLine('<b>%d errors were found:</b>', [count($errors)]); /** @var Error $error */ foreach ($errors as $path => $pathErrors) { foreach ($pathErrors as $error) { $this->outputLine(' - %s -> %s', [$path, $error->render()]); } } $this->quit(1); } else { $this->outputLine('<b>All Valid!</b>'); } }
php
public function validateCommand(string $configurationFile = null, string $schemaFile = 'resource://Neos.Flow/Private/Schema/Schema.schema.yaml', bool $verbose = false) { $this->outputLine('Validating <b>' . $configurationFile . '</b> with schema <b>' . $schemaFile . '</b>'); $this->outputLine(); $schema = Yaml::parseFile($schemaFile); if (is_null($configurationFile)) { $result = new Result(); $activePackages = $this->packageManager->getAvailablePackages(); foreach ($activePackages as $package) { $packageKey = $package->getPackageKey(); $packageSchemaPath = Files::concatenatePaths([$package->getResourcesPath(), 'Private/Schema']); if (is_dir($packageSchemaPath) && $packageKey !== 'Neos.Utility.Schema') { foreach (Files::getRecursiveDirectoryGenerator($packageSchemaPath, '.schema.yaml') as $schemaFile) { $configuration = Yaml::parseFile($schemaFile); $schemaPath = str_replace(FLOW_PATH_ROOT, '', $schemaFile); $configurationResult = $this->schemaValidator->validate($configuration, $schema); $result->forProperty($schemaPath)->merge($configurationResult); } } } } else { $configuration = Yaml::parseFile($configurationFile); $result = $this->schemaValidator->validate($configuration, $schema); } if ($verbose) { $this->outputLine(); if ($result->hasNotices()) { $notices = $result->getFlattenedNotices(); $this->outputLine('<b>%d notices:</b>', [count($notices)]); /** @var Notice $notice */ foreach ($notices as $path => $pathNotices) { foreach ($pathNotices as $notice) { $this->outputLine(' - %s -> %s', [$path, $notice->render()]); } } $this->outputLine(); } } if ($result->hasErrors()) { $errors = $result->getFlattenedErrors(); $this->outputLine('<b>%d errors were found:</b>', [count($errors)]); /** @var Error $error */ foreach ($errors as $path => $pathErrors) { foreach ($pathErrors as $error) { $this->outputLine(' - %s -> %s', [$path, $error->render()]); } } $this->quit(1); } else { $this->outputLine('<b>All Valid!</b>'); } }
[ "public", "function", "validateCommand", "(", "string", "$", "configurationFile", "=", "null", ",", "string", "$", "schemaFile", "=", "'resource://Neos.Flow/Private/Schema/Schema.schema.yaml'", ",", "bool", "$", "verbose", "=", "false", ")", "{", "$", "this", "->", ...
Validate the given configurationfile againt a schema file @param string $configurationFile path to the validated configuration file @param string $schemaFile path to the schema file @param boolean $verbose if true, output more verbose information on the schema files which were used @return void
[ "Validate", "the", "given", "configurationfile", "againt", "a", "schema", "file" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Command/SchemaCommandController.php#L52-L107
neos/flow-development-collection
Neos.Flow/Classes/Command/SchemaCommandController.php
SchemaCommandController.validateSchemaCommand
public function validateSchemaCommand(string $configurationFile, string $schemaFile = 'resource://Neos.Flow/Private/Schema/Schema.schema.yaml', bool $verbose = false) { $this->outputLine('Validating <b>' . $configurationFile . '</b> with schema <b>' . $schemaFile . '</b>'); $this->outputLine(); $configuration = Yaml::parseFile($configurationFile); $schema = Yaml::parseFile($schemaFile); $result = $this->schemaValidator->validate($configuration, $schema); if ($verbose) { $this->outputLine(); if ($result->hasNotices()) { $notices = $result->getFlattenedNotices(); $this->outputLine('<b>%d notices:</b>', [count($notices)]); /** @var Notice $notice */ foreach ($notices as $path => $pathNotices) { foreach ($pathNotices as $notice) { $this->outputLine(' - %s -> %s', [$path, $notice->render()]); } } $this->outputLine(); } } if ($result->hasErrors()) { $errors = $result->getFlattenedErrors(); $this->outputLine('<b>%d errors were found:</b>', [count($errors)]); /** @var Error $error */ foreach ($errors as $path => $pathErrors) { foreach ($pathErrors as $error) { $this->outputLine(' - %s', [$error->render()]); } } $this->quit(1); } else { $this->outputLine('<b>All Valid!</b>'); } }
php
public function validateSchemaCommand(string $configurationFile, string $schemaFile = 'resource://Neos.Flow/Private/Schema/Schema.schema.yaml', bool $verbose = false) { $this->outputLine('Validating <b>' . $configurationFile . '</b> with schema <b>' . $schemaFile . '</b>'); $this->outputLine(); $configuration = Yaml::parseFile($configurationFile); $schema = Yaml::parseFile($schemaFile); $result = $this->schemaValidator->validate($configuration, $schema); if ($verbose) { $this->outputLine(); if ($result->hasNotices()) { $notices = $result->getFlattenedNotices(); $this->outputLine('<b>%d notices:</b>', [count($notices)]); /** @var Notice $notice */ foreach ($notices as $path => $pathNotices) { foreach ($pathNotices as $notice) { $this->outputLine(' - %s -> %s', [$path, $notice->render()]); } } $this->outputLine(); } } if ($result->hasErrors()) { $errors = $result->getFlattenedErrors(); $this->outputLine('<b>%d errors were found:</b>', [count($errors)]); /** @var Error $error */ foreach ($errors as $path => $pathErrors) { foreach ($pathErrors as $error) { $this->outputLine(' - %s', [$error->render()]); } } $this->quit(1); } else { $this->outputLine('<b>All Valid!</b>'); } }
[ "public", "function", "validateSchemaCommand", "(", "string", "$", "configurationFile", ",", "string", "$", "schemaFile", "=", "'resource://Neos.Flow/Private/Schema/Schema.schema.yaml'", ",", "bool", "$", "verbose", "=", "false", ")", "{", "$", "this", "->", "outputLi...
Validate the given configurationfile againt a schema file @param string $configurationFile path to the validated configuration file @param string $schemaFile path to the schema file @param boolean $verbose if true, output more verbose information on the schema files which were used @return void
[ "Validate", "the", "given", "configurationfile", "againt", "a", "schema", "file" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Command/SchemaCommandController.php#L117-L155
neos/flow-development-collection
Neos.Flow/Classes/ObjectManagement/DependencyInjection/PropertyInjectionTrait.php
PropertyInjectionTrait.Flow_Proxy_LazyPropertyInjection
private function Flow_Proxy_LazyPropertyInjection($propertyObjectName, $propertyClassName, $propertyName, $setterArgumentHash, callable $lazyInjectionResolver) { $injection_reference = &$this->$propertyName; $this->$propertyName = \Neos\Flow\Core\Bootstrap::$staticObjectManager->getInstance($propertyObjectName); if ($this->$propertyName === null) { $this->$propertyName = \Neos\Flow\Core\Bootstrap::$staticObjectManager->getLazyDependencyByHash($setterArgumentHash, $injection_reference); if ($this->$propertyName === null) { $this->$propertyName = \Neos\Flow\Core\Bootstrap::$staticObjectManager->createLazyDependency($setterArgumentHash, $injection_reference, $propertyClassName, $lazyInjectionResolver); } } }
php
private function Flow_Proxy_LazyPropertyInjection($propertyObjectName, $propertyClassName, $propertyName, $setterArgumentHash, callable $lazyInjectionResolver) { $injection_reference = &$this->$propertyName; $this->$propertyName = \Neos\Flow\Core\Bootstrap::$staticObjectManager->getInstance($propertyObjectName); if ($this->$propertyName === null) { $this->$propertyName = \Neos\Flow\Core\Bootstrap::$staticObjectManager->getLazyDependencyByHash($setterArgumentHash, $injection_reference); if ($this->$propertyName === null) { $this->$propertyName = \Neos\Flow\Core\Bootstrap::$staticObjectManager->createLazyDependency($setterArgumentHash, $injection_reference, $propertyClassName, $lazyInjectionResolver); } } }
[ "private", "function", "Flow_Proxy_LazyPropertyInjection", "(", "$", "propertyObjectName", ",", "$", "propertyClassName", ",", "$", "propertyName", ",", "$", "setterArgumentHash", ",", "callable", "$", "lazyInjectionResolver", ")", "{", "$", "injection_reference", "=", ...
Does a property injection lazily with fallbacks. Used in proxy classes. @param string $propertyObjectName @param string $propertyClassName @param string $propertyName @param string $setterArgumentHash @param callable $lazyInjectionResolver @return void
[ "Does", "a", "property", "injection", "lazily", "with", "fallbacks", ".", "Used", "in", "proxy", "classes", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ObjectManagement/DependencyInjection/PropertyInjectionTrait.php#L30-L40
neos/flow-development-collection
Neos.Flow.Log/Classes/Backend/AnsiConsoleBackend.php
AnsiConsoleBackend.open
public function open() { parent::open(); $this->tagFormats = [ 'emergency' => self::FG_BLACK . self::BG_RED . '|' . self::END, 'alert' => self::FG_BLACK . self::BG_YELLOW . '|' . self::END, 'critical' => self::FG_BLACK . self::BG_CYAN . '|' . self::END, 'error' => self::FG_RED . '|' . self::END, 'warning' => self::FG_YELLOW . '|' . self::END, 'notice' => self::FG_WHITE . '|' . self::END, 'info' => self::FG_GREEN . '|' . self::END, 'debug' => self::FG_BLUE . '|' . self::END, ]; }
php
public function open() { parent::open(); $this->tagFormats = [ 'emergency' => self::FG_BLACK . self::BG_RED . '|' . self::END, 'alert' => self::FG_BLACK . self::BG_YELLOW . '|' . self::END, 'critical' => self::FG_BLACK . self::BG_CYAN . '|' . self::END, 'error' => self::FG_RED . '|' . self::END, 'warning' => self::FG_YELLOW . '|' . self::END, 'notice' => self::FG_WHITE . '|' . self::END, 'info' => self::FG_GREEN . '|' . self::END, 'debug' => self::FG_BLUE . '|' . self::END, ]; }
[ "public", "function", "open", "(", ")", "{", "parent", "::", "open", "(", ")", ";", "$", "this", "->", "tagFormats", "=", "[", "'emergency'", "=>", "self", "::", "FG_BLACK", ".", "self", "::", "BG_RED", ".", "'|'", ".", "self", "::", "END", ",", "'...
Open the log backend Initializes tag formats. @return void
[ "Open", "the", "log", "backend" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow.Log/Classes/Backend/AnsiConsoleBackend.php#L55-L68
neos/flow-development-collection
Neos.Flow.Log/Classes/Backend/AnsiConsoleBackend.php
AnsiConsoleBackend.append
public function append($message, $severity = LOG_INFO, $additionalData = null, $packageKey = null, $className = null, $methodName = null) { if ($severity > $this->severityThreshold) { return; } $severityName = strtolower(trim($this->severityLabels[$severity])); $output = '<' . $severityName. '>' . $message . '</' . $severityName . '>'; $output = $this->formatOutput($output); if (is_resource($this->streamHandle)) { fputs($this->streamHandle, $output . PHP_EOL); } }
php
public function append($message, $severity = LOG_INFO, $additionalData = null, $packageKey = null, $className = null, $methodName = null) { if ($severity > $this->severityThreshold) { return; } $severityName = strtolower(trim($this->severityLabels[$severity])); $output = '<' . $severityName. '>' . $message . '</' . $severityName . '>'; $output = $this->formatOutput($output); if (is_resource($this->streamHandle)) { fputs($this->streamHandle, $output . PHP_EOL); } }
[ "public", "function", "append", "(", "$", "message", ",", "$", "severity", "=", "LOG_INFO", ",", "$", "additionalData", "=", "null", ",", "$", "packageKey", "=", "null", ",", "$", "className", "=", "null", ",", "$", "methodName", "=", "null", ")", "{",...
Appends the given message along with the additional information into the log. @param string $message @param integer $severity @param array $additionalData @param string $packageKey @param string $className @param string $methodName @return void
[ "Appends", "the", "given", "message", "along", "with", "the", "additional", "information", "into", "the", "log", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow.Log/Classes/Backend/AnsiConsoleBackend.php#L81-L95
neos/flow-development-collection
Neos.Flow.Log/Classes/Backend/AnsiConsoleBackend.php
AnsiConsoleBackend.formatOutput
protected function formatOutput($output) { $tagFormats = $this->tagFormats; $disableAnsi = $this->disableAnsi; do { $lastOutput = $output; $output = preg_replace_callback('|(<([^>]+?)>(.*?)</\2>)|s', function ($matches) use ($tagFormats, $disableAnsi) { $format = isset($tagFormats[$matches[2]]) ? $tagFormats[$matches[2]] : '|'; if ($disableAnsi) { return $matches[3]; } else { return str_replace('|', $matches[3], $format); } }, $output); } while ($lastOutput !== $output); return $output; }
php
protected function formatOutput($output) { $tagFormats = $this->tagFormats; $disableAnsi = $this->disableAnsi; do { $lastOutput = $output; $output = preg_replace_callback('|(<([^>]+?)>(.*?)</\2>)|s', function ($matches) use ($tagFormats, $disableAnsi) { $format = isset($tagFormats[$matches[2]]) ? $tagFormats[$matches[2]] : '|'; if ($disableAnsi) { return $matches[3]; } else { return str_replace('|', $matches[3], $format); } }, $output); } while ($lastOutput !== $output); return $output; }
[ "protected", "function", "formatOutput", "(", "$", "output", ")", "{", "$", "tagFormats", "=", "$", "this", "->", "tagFormats", ";", "$", "disableAnsi", "=", "$", "this", "->", "disableAnsi", ";", "do", "{", "$", "lastOutput", "=", "$", "output", ";", ...
Apply ansi formatting to output according to tags @param string $output @return string
[ "Apply", "ansi", "formatting", "to", "output", "according", "to", "tags" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow.Log/Classes/Backend/AnsiConsoleBackend.php#L103-L119
neos/flow-development-collection
Neos.Flow/Classes/Cli/CommandManager.php
CommandManager.getAvailableCommands
public function getAvailableCommands(): array { if ($this->availableCommands === null) { $this->availableCommands = []; foreach (static::getCommandControllerMethodArguments($this->objectManager) as $className => $methods) { foreach (array_keys($methods) as $methodName) { $this->availableCommands[] = new Command($className, substr($methodName, 0, -7)); } } } return $this->availableCommands; }
php
public function getAvailableCommands(): array { if ($this->availableCommands === null) { $this->availableCommands = []; foreach (static::getCommandControllerMethodArguments($this->objectManager) as $className => $methods) { foreach (array_keys($methods) as $methodName) { $this->availableCommands[] = new Command($className, substr($methodName, 0, -7)); } } } return $this->availableCommands; }
[ "public", "function", "getAvailableCommands", "(", ")", ":", "array", "{", "if", "(", "$", "this", "->", "availableCommands", "===", "null", ")", "{", "$", "this", "->", "availableCommands", "=", "[", "]", ";", "foreach", "(", "static", "::", "getCommandCo...
Returns an array of all commands @return array<Command> @api
[ "Returns", "an", "array", "of", "all", "commands" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Cli/CommandManager.php#L73-L86
neos/flow-development-collection
Neos.Flow/Classes/Cli/CommandManager.php
CommandManager.getCommandByIdentifier
public function getCommandByIdentifier(string $commandIdentifier): Command { $commandIdentifier = strtolower(trim($commandIdentifier)); if ($commandIdentifier === 'help') { $commandIdentifier = 'neos.flow:help:help'; } if ($commandIdentifier === 'sys') { $commandIdentifier = 'neos.flow:cache:sys'; } $matchedCommands = $this->getCommandsByIdentifier($commandIdentifier); if (count($matchedCommands) === 0) { throw new NoSuchCommandException('No command could be found that matches the command identifier "' . $commandIdentifier . '".', 1310556663); } if (count($matchedCommands) > 1) { throw new AmbiguousCommandIdentifierException('More than one command matches the command identifier "' . $commandIdentifier . '"', 1310557169, null, $matchedCommands); } return current($matchedCommands); }
php
public function getCommandByIdentifier(string $commandIdentifier): Command { $commandIdentifier = strtolower(trim($commandIdentifier)); if ($commandIdentifier === 'help') { $commandIdentifier = 'neos.flow:help:help'; } if ($commandIdentifier === 'sys') { $commandIdentifier = 'neos.flow:cache:sys'; } $matchedCommands = $this->getCommandsByIdentifier($commandIdentifier); if (count($matchedCommands) === 0) { throw new NoSuchCommandException('No command could be found that matches the command identifier "' . $commandIdentifier . '".', 1310556663); } if (count($matchedCommands) > 1) { throw new AmbiguousCommandIdentifierException('More than one command matches the command identifier "' . $commandIdentifier . '"', 1310557169, null, $matchedCommands); } return current($matchedCommands); }
[ "public", "function", "getCommandByIdentifier", "(", "string", "$", "commandIdentifier", ")", ":", "Command", "{", "$", "commandIdentifier", "=", "strtolower", "(", "trim", "(", "$", "commandIdentifier", ")", ")", ";", "if", "(", "$", "commandIdentifier", "===",...
Returns a Command that matches the given identifier. If no Command could be found a CommandNotFoundException is thrown If more than one Command matches an AmbiguousCommandIdentifierException is thrown that contains the matched Commands @param string $commandIdentifier command identifier in the format foo:bar:baz @return Command @throws NoSuchCommandException if no matching command is available @throws AmbiguousCommandIdentifierException if more than one Command matches the identifier (the exception contains the matched commands) @api
[ "Returns", "a", "Command", "that", "matches", "the", "given", "identifier", ".", "If", "no", "Command", "could", "be", "found", "a", "CommandNotFoundException", "is", "thrown", "If", "more", "than", "one", "Command", "matches", "an", "AmbiguousCommandIdentifierExc...
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Cli/CommandManager.php#L99-L118
neos/flow-development-collection
Neos.Flow/Classes/Cli/CommandManager.php
CommandManager.getCommandsByIdentifier
public function getCommandsByIdentifier(string $commandIdentifier): array { $availableCommands = $this->getAvailableCommands(); $matchedCommands = []; foreach ($availableCommands as $command) { if ($this->commandMatchesIdentifier($command, $commandIdentifier)) { $matchedCommands[] = $command; } } return $matchedCommands; }
php
public function getCommandsByIdentifier(string $commandIdentifier): array { $availableCommands = $this->getAvailableCommands(); $matchedCommands = []; foreach ($availableCommands as $command) { if ($this->commandMatchesIdentifier($command, $commandIdentifier)) { $matchedCommands[] = $command; } } return $matchedCommands; }
[ "public", "function", "getCommandsByIdentifier", "(", "string", "$", "commandIdentifier", ")", ":", "array", "{", "$", "availableCommands", "=", "$", "this", "->", "getAvailableCommands", "(", ")", ";", "$", "matchedCommands", "=", "[", "]", ";", "foreach", "(...
Returns an array of Commands that matches the given identifier. If no Command could be found, an empty array is returned @param string $commandIdentifier command identifier in the format foo:bar:baz @return array<Command> @api
[ "Returns", "an", "array", "of", "Commands", "that", "matches", "the", "given", "identifier", ".", "If", "no", "Command", "could", "be", "found", "an", "empty", "array", "is", "returned" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Cli/CommandManager.php#L128-L139
neos/flow-development-collection
Neos.Flow/Classes/Cli/CommandManager.php
CommandManager.getShortCommandIdentifiers
protected function getShortCommandIdentifiers(): array { if ($this->shortCommandIdentifiers === null) { $this->shortCommandIdentifiers = []; $commandsByCommandName = []; /** @var Command $availableCommand */ foreach ($this->getAvailableCommands() as $availableCommand) { list($packageKey, $controllerName, $commandName) = explode(':', $availableCommand->getCommandIdentifier()); if (!isset($commandsByCommandName[$commandName])) { $commandsByCommandName[$commandName] = []; } if (!isset($commandsByCommandName[$commandName][$controllerName])) { $commandsByCommandName[$commandName][$controllerName] = []; } $commandsByCommandName[$commandName][$controllerName][] = $packageKey; } foreach ($this->getAvailableCommands() as $availableCommand) { list($packageKey, $controllerName, $commandName) = explode(':', $availableCommand->getCommandIdentifier()); if (count($commandsByCommandName[$commandName][$controllerName]) > 1 || $this->bootstrap->isCompiletimeCommand($availableCommand->getCommandIdentifier())) { $packageKeyParts = array_reverse(explode('.', $packageKey)); for ($i = 1; $i <= count($packageKeyParts); $i++) { $shortCommandIdentifier = implode('.', array_slice($packageKeyParts, 0, $i)) . ':' . $controllerName . ':' . $commandName; try { $this->getCommandByIdentifier($shortCommandIdentifier); $this->shortCommandIdentifiers[$availableCommand->getCommandIdentifier()] = $shortCommandIdentifier; break; } catch (CommandException $exception) { } } } else { $this->shortCommandIdentifiers[$availableCommand->getCommandIdentifier()] = sprintf('%s:%s', $controllerName, $commandName); } } } return $this->shortCommandIdentifiers; }
php
protected function getShortCommandIdentifiers(): array { if ($this->shortCommandIdentifiers === null) { $this->shortCommandIdentifiers = []; $commandsByCommandName = []; /** @var Command $availableCommand */ foreach ($this->getAvailableCommands() as $availableCommand) { list($packageKey, $controllerName, $commandName) = explode(':', $availableCommand->getCommandIdentifier()); if (!isset($commandsByCommandName[$commandName])) { $commandsByCommandName[$commandName] = []; } if (!isset($commandsByCommandName[$commandName][$controllerName])) { $commandsByCommandName[$commandName][$controllerName] = []; } $commandsByCommandName[$commandName][$controllerName][] = $packageKey; } foreach ($this->getAvailableCommands() as $availableCommand) { list($packageKey, $controllerName, $commandName) = explode(':', $availableCommand->getCommandIdentifier()); if (count($commandsByCommandName[$commandName][$controllerName]) > 1 || $this->bootstrap->isCompiletimeCommand($availableCommand->getCommandIdentifier())) { $packageKeyParts = array_reverse(explode('.', $packageKey)); for ($i = 1; $i <= count($packageKeyParts); $i++) { $shortCommandIdentifier = implode('.', array_slice($packageKeyParts, 0, $i)) . ':' . $controllerName . ':' . $commandName; try { $this->getCommandByIdentifier($shortCommandIdentifier); $this->shortCommandIdentifiers[$availableCommand->getCommandIdentifier()] = $shortCommandIdentifier; break; } catch (CommandException $exception) { } } } else { $this->shortCommandIdentifiers[$availableCommand->getCommandIdentifier()] = sprintf('%s:%s', $controllerName, $commandName); } } } return $this->shortCommandIdentifiers; }
[ "protected", "function", "getShortCommandIdentifiers", "(", ")", ":", "array", "{", "if", "(", "$", "this", "->", "shortCommandIdentifiers", "===", "null", ")", "{", "$", "this", "->", "shortCommandIdentifiers", "=", "[", "]", ";", "$", "commandsByCommandName", ...
Returns an array that contains all available command identifiers and their shortest non-ambiguous alias @return array in the format array('full.command:identifier1' => 'alias1', 'full.command:identifier2' => 'alias2')
[ "Returns", "an", "array", "that", "contains", "all", "available", "command", "identifiers", "and", "their", "shortest", "non", "-", "ambiguous", "alias" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Cli/CommandManager.php#L166-L202
neos/flow-development-collection
Neos.Flow/Classes/Cli/CommandManager.php
CommandManager.commandMatchesIdentifier
protected function commandMatchesIdentifier(Command $command, string $commandIdentifier): bool { $commandIdentifierParts = explode(':', $command->getCommandIdentifier()); $searchedCommandIdentifierParts = explode(':', $commandIdentifier); $packageKey = array_shift($commandIdentifierParts); $searchedCommandIdentifierPartsCount = count($searchedCommandIdentifierParts); if ($searchedCommandIdentifierPartsCount === 3 || $searchedCommandIdentifierPartsCount === 1) { $searchedPackageKey = array_shift($searchedCommandIdentifierParts); if ($searchedPackageKey !== $packageKey && substr($packageKey, -(strlen($searchedPackageKey) + 1)) !== '.' . $searchedPackageKey ) { return false; } } if ($searchedCommandIdentifierPartsCount === 1) { return true; } elseif (count($searchedCommandIdentifierParts) !== 2) { return false; } return $searchedCommandIdentifierParts === $commandIdentifierParts; }
php
protected function commandMatchesIdentifier(Command $command, string $commandIdentifier): bool { $commandIdentifierParts = explode(':', $command->getCommandIdentifier()); $searchedCommandIdentifierParts = explode(':', $commandIdentifier); $packageKey = array_shift($commandIdentifierParts); $searchedCommandIdentifierPartsCount = count($searchedCommandIdentifierParts); if ($searchedCommandIdentifierPartsCount === 3 || $searchedCommandIdentifierPartsCount === 1) { $searchedPackageKey = array_shift($searchedCommandIdentifierParts); if ($searchedPackageKey !== $packageKey && substr($packageKey, -(strlen($searchedPackageKey) + 1)) !== '.' . $searchedPackageKey ) { return false; } } if ($searchedCommandIdentifierPartsCount === 1) { return true; } elseif (count($searchedCommandIdentifierParts) !== 2) { return false; } return $searchedCommandIdentifierParts === $commandIdentifierParts; }
[ "protected", "function", "commandMatchesIdentifier", "(", "Command", "$", "command", ",", "string", "$", "commandIdentifier", ")", ":", "bool", "{", "$", "commandIdentifierParts", "=", "explode", "(", "':'", ",", "$", "command", "->", "getCommandIdentifier", "(", ...
Returns true if the specified command identifier matches the identifier of the specified command. This is the case, if - the identifiers are the same - if at least the last two command parts match (case sensitive) or - if only the package key is specified and matches the commands package key The first part (package key) can be reduced to the last subpackage, as long as the result is unambiguous. @param Command $command @param string $commandIdentifier command identifier in the format foo:bar:baz (all lower case) @return boolean true if the specified command identifier matches this commands identifier
[ "Returns", "true", "if", "the", "specified", "command", "identifier", "matches", "the", "identifier", "of", "the", "specified", "command", ".", "This", "is", "the", "case", "if", "-", "the", "identifiers", "are", "the", "same", "-", "if", "at", "least", "t...
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Cli/CommandManager.php#L216-L237
neos/flow-development-collection
Neos.Flow/Classes/Cli/CommandManager.php
CommandManager.getCommandMethodParameters
public function getCommandMethodParameters(string $controllerObjectName, string $commandMethodName): array { $commandControllerMethodArgumentMap = static::getCommandControllerMethodArguments($this->objectManager); return isset($commandControllerMethodArgumentMap[$controllerObjectName][$commandMethodName]) ? $commandControllerMethodArgumentMap[$controllerObjectName][$commandMethodName] : []; }
php
public function getCommandMethodParameters(string $controllerObjectName, string $commandMethodName): array { $commandControllerMethodArgumentMap = static::getCommandControllerMethodArguments($this->objectManager); return isset($commandControllerMethodArgumentMap[$controllerObjectName][$commandMethodName]) ? $commandControllerMethodArgumentMap[$controllerObjectName][$commandMethodName] : []; }
[ "public", "function", "getCommandMethodParameters", "(", "string", "$", "controllerObjectName", ",", "string", "$", "commandMethodName", ")", ":", "array", "{", "$", "commandControllerMethodArgumentMap", "=", "static", "::", "getCommandControllerMethodArguments", "(", "$"...
Get the possible parameters for the command specified by CommandController and method name. @param string $controllerObjectName @param string $commandMethodName @return array
[ "Get", "the", "possible", "parameters", "for", "the", "command", "specified", "by", "CommandController", "and", "method", "name", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Cli/CommandManager.php#L246-L251
neos/flow-development-collection
Neos.Flow/Classes/Validation/Validator/DateTimeRangeValidator.php
DateTimeRangeValidator.isValid
protected function isValid($dateTime) { if (!$dateTime instanceof \DateTimeInterface) { $this->addError('The given value was not a valid date', 1324314378); return; } $earliestDate = isset($this->options['earliestDate']) ? $this->parseReferenceDate($this->options['earliestDate']) : null; $latestDate = isset($this->options['latestDate']) ? $this->parseReferenceDate($this->options['latestDate']) : null; if (isset($earliestDate) && isset($latestDate)) { if ($dateTime < $earliestDate || $dateTime > $latestDate) { $this->addError('The given date must be between %s and %s', 1325615630, [$earliestDate->format('Y-m-d H:i:s'), $latestDate->format('Y-m-d H:i:s')]); } } elseif (isset($earliestDate)) { if ($dateTime < $earliestDate) { $this->addError('The given date must be after %s', 1324315107, [$earliestDate->format('Y-m-d H:i:s')]); } } elseif (isset($latestDate)) { if ($dateTime > $latestDate) { $this->addError('The given date must be before %s', 1324315115, [$latestDate->format('Y-m-d H:i:s')]); } } }
php
protected function isValid($dateTime) { if (!$dateTime instanceof \DateTimeInterface) { $this->addError('The given value was not a valid date', 1324314378); return; } $earliestDate = isset($this->options['earliestDate']) ? $this->parseReferenceDate($this->options['earliestDate']) : null; $latestDate = isset($this->options['latestDate']) ? $this->parseReferenceDate($this->options['latestDate']) : null; if (isset($earliestDate) && isset($latestDate)) { if ($dateTime < $earliestDate || $dateTime > $latestDate) { $this->addError('The given date must be between %s and %s', 1325615630, [$earliestDate->format('Y-m-d H:i:s'), $latestDate->format('Y-m-d H:i:s')]); } } elseif (isset($earliestDate)) { if ($dateTime < $earliestDate) { $this->addError('The given date must be after %s', 1324315107, [$earliestDate->format('Y-m-d H:i:s')]); } } elseif (isset($latestDate)) { if ($dateTime > $latestDate) { $this->addError('The given date must be before %s', 1324315115, [$latestDate->format('Y-m-d H:i:s')]); } } }
[ "protected", "function", "isValid", "(", "$", "dateTime", ")", "{", "if", "(", "!", "$", "dateTime", "instanceof", "\\", "DateTimeInterface", ")", "{", "$", "this", "->", "addError", "(", "'The given value was not a valid date'", ",", "1324314378", ")", ";", "...
Adds errors if the given DateTime does not match the set boundaries. latestDate and earliestDate may be each <time>, <start>/<duration> or <duration>/<end>, where <duration> is an ISO 8601 duration and <start> or <end> or <time> may be 'now' or a PHP supported format. (1) In general, you are able to provide a timestamp or a timestamp with additional calculation. Calculations are done as described in ISO 8601 (2), with an introducing "P". P7MT2H30M for example mean a period of 7 months, 2 hours and 30 minutes (P introduces a period at all, while a following T introduces the time-section of a period. This is not at least in order not to confuse months and minutes, both represented as M). A period is separated from the timestamp with a forward slash "/". If the period follows the timestamp, that period is added to the timestamp; if the period precedes the timestamp, it's subtracted. The timestamp can be one of PHP's supported date formats (1), so also "now" is supported. Use cases: If you offer something that has to be manufactured and you ask for a delivery date, you might assure that this date is at least two weeks in advance; this could be done with the expression "now/P2W". If you have a library of ancient goods and want to track a production date that is at least 5 years ago, you can express it with "P5Y/now". Examples: If you want to test if a given date is at least five minutes ahead, use earliestDate: now/PT5M If you want to test if a given date was at least 10 days ago, use latestDate: P10D/now If you want to test if a given date is between two fix boundaries, just combine the latestDate and earliestDate-options: earliestDate: 2007-03-01T13:00:00Z latestDate: 2007-03-30T13:00:00Z Footnotes: http://de.php.net/manual/en/datetime.formats.compound.php (1) http://en.wikipedia.org/wiki/ISO_8601#Durations (2) http://en.wikipedia.org/wiki/ISO_8601#Time_intervals (3) @param mixed $dateTime The DateTime value that should be validated @return void @api
[ "Adds", "errors", "if", "the", "given", "DateTime", "does", "not", "match", "the", "set", "boundaries", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Validation/Validator/DateTimeRangeValidator.php#L72-L94
neos/flow-development-collection
Neos.Flow/Classes/Validation/Validator/DateTimeRangeValidator.php
DateTimeRangeValidator.parseReferenceDate
protected function parseReferenceDate($referenceDateString) { $referenceDateParts = explode('/', $referenceDateString, 2); if (count($referenceDateParts) === 1) { // assume a valid Date/Time string return new \DateTime($referenceDateParts[0]); } // check if the period (the interval) is the first or second item: if (strpos($referenceDateParts[0], 'P') === 0) { $interval = new \DateInterval($referenceDateParts[0]); $date = new \DateTime($referenceDateParts[1]); return $date->sub($interval); } elseif (strpos($referenceDateParts[1], 'P') === 0) { $interval = new \DateInterval($referenceDateParts[1]); $date = new \DateTime($referenceDateParts[0]); return $date->add($interval); } else { throw new InvalidValidationOptionsException(sprintf('There is no valid interval declaration in "%s". Exactly one part must begin with "P".', $referenceDateString), 1324314462); } }
php
protected function parseReferenceDate($referenceDateString) { $referenceDateParts = explode('/', $referenceDateString, 2); if (count($referenceDateParts) === 1) { // assume a valid Date/Time string return new \DateTime($referenceDateParts[0]); } // check if the period (the interval) is the first or second item: if (strpos($referenceDateParts[0], 'P') === 0) { $interval = new \DateInterval($referenceDateParts[0]); $date = new \DateTime($referenceDateParts[1]); return $date->sub($interval); } elseif (strpos($referenceDateParts[1], 'P') === 0) { $interval = new \DateInterval($referenceDateParts[1]); $date = new \DateTime($referenceDateParts[0]); return $date->add($interval); } else { throw new InvalidValidationOptionsException(sprintf('There is no valid interval declaration in "%s". Exactly one part must begin with "P".', $referenceDateString), 1324314462); } }
[ "protected", "function", "parseReferenceDate", "(", "$", "referenceDateString", ")", "{", "$", "referenceDateParts", "=", "explode", "(", "'/'", ",", "$", "referenceDateString", ",", "2", ")", ";", "if", "(", "count", "(", "$", "referenceDateParts", ")", "==="...
Calculates a DateTime object from a given Time interval @param string $referenceDateString being one of <time>, <start>/<offset> or <offset>/<end> @return \DateTime @throws InvalidValidationOptionsException @see isValid()
[ "Calculates", "a", "DateTime", "object", "from", "a", "given", "Time", "interval" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Validation/Validator/DateTimeRangeValidator.php#L104-L124
neos/flow-development-collection
Neos.Eel/Classes/Helper/StringHelper.php
StringHelper.substr
public function substr($string, $start, $length = null) { $string = (string)$string; if ($length === null) { $length = mb_strlen($string, 'UTF-8'); } $length = max(0, $length); return mb_substr($string, $start, $length, 'UTF-8'); }
php
public function substr($string, $start, $length = null) { $string = (string)$string; if ($length === null) { $length = mb_strlen($string, 'UTF-8'); } $length = max(0, $length); return mb_substr($string, $start, $length, 'UTF-8'); }
[ "public", "function", "substr", "(", "$", "string", ",", "$", "start", ",", "$", "length", "=", "null", ")", "{", "$", "string", "=", "(", "string", ")", "$", "string", ";", "if", "(", "$", "length", "===", "null", ")", "{", "$", "length", "=", ...
Return the characters in a string from start up to the given length This implementation follows the JavaScript specification for "substr". Examples:: String.substr('Hello, World!', 7, 5) == 'World' String.substr('Hello, World!', 7) == 'World!' String.substr('Hello, World!', -6) == 'World!' @param string $string A string @param integer $start Start offset @param integer $length Maximum length of the substring that is returned @return string The substring
[ "Return", "the", "characters", "in", "a", "string", "from", "start", "up", "to", "the", "given", "length" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Eel/Classes/Helper/StringHelper.php#L43-L52
neos/flow-development-collection
Neos.Eel/Classes/Helper/StringHelper.php
StringHelper.substring
public function substring($string, $start, $end = null) { $string = (string)$string; if ($end === null) { $end = mb_strlen($string, 'UTF-8'); } $start = max(0, $start); $end = max(0, $end); if ($start > $end) { $temp = $start; $start = $end; $end = $temp; } $length = $end - $start; return mb_substr($string, $start, $length, 'UTF-8'); }
php
public function substring($string, $start, $end = null) { $string = (string)$string; if ($end === null) { $end = mb_strlen($string, 'UTF-8'); } $start = max(0, $start); $end = max(0, $end); if ($start > $end) { $temp = $start; $start = $end; $end = $temp; } $length = $end - $start; return mb_substr($string, $start, $length, 'UTF-8'); }
[ "public", "function", "substring", "(", "$", "string", ",", "$", "start", ",", "$", "end", "=", "null", ")", "{", "$", "string", "=", "(", "string", ")", "$", "string", ";", "if", "(", "$", "end", "===", "null", ")", "{", "$", "end", "=", "mb_s...
Return the characters in a string from a start index to an end index This implementation follows the JavaScript specification for "substring". Examples:: String.substring('Hello, World!', 7, 12) == 'World' String.substring('Hello, World!', 7) == 'World!' @param string $string @param integer $start Start index @param integer $end End index @return string The substring
[ "Return", "the", "characters", "in", "a", "string", "from", "a", "start", "index", "to", "an", "end", "index" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Eel/Classes/Helper/StringHelper.php#L69-L85
neos/flow-development-collection
Neos.Eel/Classes/Helper/StringHelper.php
StringHelper.endsWith
public function endsWith($string, $search, $position = null) { $string = (string)$string; $position = $position !== null ? $position : mb_strlen($string, 'UTF-8'); $position = $position - mb_strlen($search, 'UTF-8'); return mb_strrpos($string, $search, null, 'UTF-8') === $position; }
php
public function endsWith($string, $search, $position = null) { $string = (string)$string; $position = $position !== null ? $position : mb_strlen($string, 'UTF-8'); $position = $position - mb_strlen($search, 'UTF-8'); return mb_strrpos($string, $search, null, 'UTF-8') === $position; }
[ "public", "function", "endsWith", "(", "$", "string", ",", "$", "search", ",", "$", "position", "=", "null", ")", "{", "$", "string", "=", "(", "string", ")", "$", "string", ";", "$", "position", "=", "$", "position", "!==", "null", "?", "$", "posi...
Test if a string ends with the given search string Example:: String.endsWith('Hello, World!', 'World!') == true @param string $string The string @param string $search A string to search @param integer $position Optional position for limiting the string @return boolean true if the string ends with the given search
[ "Test", "if", "a", "string", "ends", "with", "the", "given", "search", "string" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Eel/Classes/Helper/StringHelper.php#L118-L125
neos/flow-development-collection
Neos.Eel/Classes/Helper/StringHelper.php
StringHelper.indexOf
public function indexOf($string, $search, $fromIndex = null) { $string = (string)$string; $fromIndex = max(0, $fromIndex); if ($search === '') { return min(mb_strlen($string, 'UTF-8'), $fromIndex); } $index = mb_strpos($string, $search, $fromIndex, 'UTF-8'); if ($index === false) { return -1; } return (integer)$index; }
php
public function indexOf($string, $search, $fromIndex = null) { $string = (string)$string; $fromIndex = max(0, $fromIndex); if ($search === '') { return min(mb_strlen($string, 'UTF-8'), $fromIndex); } $index = mb_strpos($string, $search, $fromIndex, 'UTF-8'); if ($index === false) { return -1; } return (integer)$index; }
[ "public", "function", "indexOf", "(", "$", "string", ",", "$", "search", ",", "$", "fromIndex", "=", "null", ")", "{", "$", "string", "=", "(", "string", ")", "$", "string", ";", "$", "fromIndex", "=", "max", "(", "0", ",", "$", "fromIndex", ")", ...
Find the first position of a substring in the given string Example:: String.indexOf("Blue Whale", "Blue") == 0 @param string $string The input string @param string $search The substring to search for @param integer $fromIndex The index where the search should start, defaults to the beginning @return integer The index of the substring (>= 0) or -1 if the substring was not found
[ "Find", "the", "first", "position", "of", "a", "substring", "in", "the", "given", "string" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Eel/Classes/Helper/StringHelper.php#L175-L188
neos/flow-development-collection
Neos.Eel/Classes/Helper/StringHelper.php
StringHelper.lastIndexOf
public function lastIndexOf($string, $search, $toIndex = null) { $string = (string)$string; $length = mb_strlen($string, 'UTF-8'); if ($toIndex === null) { $toIndex = $length; } $toIndex = max(0, $toIndex); if ($search === '') { return min($length, $toIndex); } $string = mb_substr($string, 0, $toIndex, 'UTF-8'); $index = mb_strrpos($string, $search, 0, 'UTF-8'); if ($index === false) { return -1; } return (integer)$index; }
php
public function lastIndexOf($string, $search, $toIndex = null) { $string = (string)$string; $length = mb_strlen($string, 'UTF-8'); if ($toIndex === null) { $toIndex = $length; } $toIndex = max(0, $toIndex); if ($search === '') { return min($length, $toIndex); } $string = mb_substr($string, 0, $toIndex, 'UTF-8'); $index = mb_strrpos($string, $search, 0, 'UTF-8'); if ($index === false) { return -1; } return (integer)$index; }
[ "public", "function", "lastIndexOf", "(", "$", "string", ",", "$", "search", ",", "$", "toIndex", "=", "null", ")", "{", "$", "string", "=", "(", "string", ")", "$", "string", ";", "$", "length", "=", "mb_strlen", "(", "$", "string", ",", "'UTF-8'", ...
Find the last position of a substring in the given string Example:: String.lastIndexOf("Developers Developers Developers!", "Developers") == 22 @param string $string The input string @param string $search The substring to search for @param integer $toIndex The position where the backwards search should start, defaults to the end @return integer The last index of the substring (>=0) or -1 if the substring was not found
[ "Find", "the", "last", "position", "of", "a", "substring", "in", "the", "given", "string" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Eel/Classes/Helper/StringHelper.php#L202-L220
neos/flow-development-collection
Neos.Eel/Classes/Helper/StringHelper.php
StringHelper.pregMatch
public function pregMatch($string, $pattern) { $number = preg_match($pattern, (string)$string, $matches); if ($number === false) { throw new EvaluationException('Error evaluating regular expression ' . $pattern . ': ' . preg_last_error(), 1372793595); } if ($number === 0) { return null; } return $matches; }
php
public function pregMatch($string, $pattern) { $number = preg_match($pattern, (string)$string, $matches); if ($number === false) { throw new EvaluationException('Error evaluating regular expression ' . $pattern . ': ' . preg_last_error(), 1372793595); } if ($number === 0) { return null; } return $matches; }
[ "public", "function", "pregMatch", "(", "$", "string", ",", "$", "pattern", ")", "{", "$", "number", "=", "preg_match", "(", "$", "pattern", ",", "(", "string", ")", "$", "string", ",", "$", "matches", ")", ";", "if", "(", "$", "number", "===", "fa...
Match a string with a regular expression (PREG style) Example:: String.pregMatch("For more information, see Chapter 3.4.5.1", "/(chapter \d+(\.\d)*)/i") == ['Chapter 3.4.5.1', 'Chapter 3.4.5.1', '.1'] @param string $string The input string @param string $pattern A PREG pattern @return array The matches as array or NULL if not matched @throws EvaluationException
[ "Match", "a", "string", "with", "a", "regular", "expression", "(", "PREG", "style", ")" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Eel/Classes/Helper/StringHelper.php#L235-L245
neos/flow-development-collection
Neos.Eel/Classes/Helper/StringHelper.php
StringHelper.pregMatchAll
public function pregMatchAll($string, $pattern) { $number = preg_match_all($pattern, (string)$string, $matches); if ($number === false) { throw new EvaluationException('Error evaluating regular expression ' . $pattern . ': ' . preg_last_error(), 1372793595); } if ($number === 0) { return null; } return $matches; }
php
public function pregMatchAll($string, $pattern) { $number = preg_match_all($pattern, (string)$string, $matches); if ($number === false) { throw new EvaluationException('Error evaluating regular expression ' . $pattern . ': ' . preg_last_error(), 1372793595); } if ($number === 0) { return null; } return $matches; }
[ "public", "function", "pregMatchAll", "(", "$", "string", ",", "$", "pattern", ")", "{", "$", "number", "=", "preg_match_all", "(", "$", "pattern", ",", "(", "string", ")", "$", "string", ",", "$", "matches", ")", ";", "if", "(", "$", "number", "==="...
Perform a global regular expression match (PREG style) Example:: String.pregMatchAll("<hr id="icon-one" /><hr id="icon-two" />", '/id="icon-(.+?)"/') == [['id="icon-one"', 'id="icon-two"'],['one','two']] @param string $string The input string @param string $pattern A PREG pattern @return array The matches as array or NULL if not matched @throws EvaluationException
[ "Perform", "a", "global", "regular", "expression", "match", "(", "PREG", "style", ")" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Eel/Classes/Helper/StringHelper.php#L260-L270
neos/flow-development-collection
Neos.Eel/Classes/Helper/StringHelper.php
StringHelper.pregSplit
public function pregSplit($string, $pattern, $limit = null) { return preg_split($pattern, (string)$string, $limit); }
php
public function pregSplit($string, $pattern, $limit = null) { return preg_split($pattern, (string)$string, $limit); }
[ "public", "function", "pregSplit", "(", "$", "string", ",", "$", "pattern", ",", "$", "limit", "=", "null", ")", "{", "return", "preg_split", "(", "$", "pattern", ",", "(", "string", ")", "$", "string", ",", "$", "limit", ")", ";", "}" ]
Split a string by a separator using regular expression matching (PREG style) Examples:: String.pregSplit("foo bar baz", "/\s+/") == ['foo', 'bar', 'baz'] String.pregSplit("first second third", "/\s+/", 2) == ['first', 'second third'] @param string $string The input string @param string $pattern A PREG pattern @param integer $limit The maximum amount of items to return, in contrast to split() this will return all remaining characters in the last item (see example) @return array An array of the splitted parts, excluding the matched pattern
[ "Split", "a", "string", "by", "a", "separator", "using", "regular", "expression", "matching", "(", "PREG", "style", ")" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Eel/Classes/Helper/StringHelper.php#L303-L306
neos/flow-development-collection
Neos.Eel/Classes/Helper/StringHelper.php
StringHelper.split
public function split($string, $separator = null, $limit = null) { $string = (string)$string; if ($separator === null) { return [$string]; } if ($separator === '') { $result = str_split($string); if ($limit !== null) { $result = array_slice($result, 0, $limit); } return $result; } if ($limit === null) { $result = explode($separator, $string); } else { $result = explode($separator, $string, $limit); } return $result; }
php
public function split($string, $separator = null, $limit = null) { $string = (string)$string; if ($separator === null) { return [$string]; } if ($separator === '') { $result = str_split($string); if ($limit !== null) { $result = array_slice($result, 0, $limit); } return $result; } if ($limit === null) { $result = explode($separator, $string); } else { $result = explode($separator, $string, $limit); } return $result; }
[ "public", "function", "split", "(", "$", "string", ",", "$", "separator", "=", "null", ",", "$", "limit", "=", "null", ")", "{", "$", "string", "=", "(", "string", ")", "$", "string", ";", "if", "(", "$", "separator", "===", "null", ")", "{", "re...
Split a string by a separator Example:: String.split("My hovercraft is full of eels", " ") == ['My', 'hovercraft', 'is', 'full', 'of', 'eels'] String.split("Foo", "", 2) == ['F', 'o'] Node: This implementation follows JavaScript semantics without support of regular expressions. @param string $string The string to split @param string $separator The separator where the string should be splitted @param integer $limit The maximum amount of items to split (exceeding items will be discarded) @return array An array of the splitted parts, excluding the separators
[ "Split", "a", "string", "by", "a", "separator" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Eel/Classes/Helper/StringHelper.php#L342-L362
neos/flow-development-collection
Neos.Eel/Classes/Helper/StringHelper.php
StringHelper.startsWith
public function startsWith($string, $search, $position = null) { $position = $position !== null ? $position : 0; return mb_strpos((string)$string, $search, null, 'UTF-8') === $position; }
php
public function startsWith($string, $search, $position = null) { $position = $position !== null ? $position : 0; return mb_strpos((string)$string, $search, null, 'UTF-8') === $position; }
[ "public", "function", "startsWith", "(", "$", "string", ",", "$", "search", ",", "$", "position", "=", "null", ")", "{", "$", "position", "=", "$", "position", "!==", "null", "?", "$", "position", ":", "0", ";", "return", "mb_strpos", "(", "(", "stri...
Test if a string starts with the given search string Examples:: String.startsWith('Hello world!', 'Hello') == true String.startsWith('My hovercraft is full of...', 'Hello') == false String.startsWith('My hovercraft is full of...', 'hovercraft', 3) == true @param string $string The input string @param string $search The string to search for @param integer $position The position to test (defaults to the beginning of the string) @return boolean
[ "Test", "if", "a", "string", "starts", "with", "the", "given", "search", "string" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Eel/Classes/Helper/StringHelper.php#L378-L382
neos/flow-development-collection
Neos.Eel/Classes/Helper/StringHelper.php
StringHelper.trim
public function trim($string, $charlist = null) { $string = (string)$string; if ($charlist === null) { return trim($string); } else { return trim($string, $charlist); } }
php
public function trim($string, $charlist = null) { $string = (string)$string; if ($charlist === null) { return trim($string); } else { return trim($string, $charlist); } }
[ "public", "function", "trim", "(", "$", "string", ",", "$", "charlist", "=", "null", ")", "{", "$", "string", "=", "(", "string", ")", "$", "string", ";", "if", "(", "$", "charlist", "===", "null", ")", "{", "return", "trim", "(", "$", "string", ...
Trim whitespace at the beginning and end of a string @param string $string The string to trim @param string $charlist List of characters that should be trimmed, defaults to whitespace @return string The trimmed string
[ "Trim", "whitespace", "at", "the", "beginning", "and", "end", "of", "a", "string" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Eel/Classes/Helper/StringHelper.php#L494-L503
neos/flow-development-collection
Neos.Eel/Classes/Helper/StringHelper.php
StringHelper.htmlSpecialChars
public function htmlSpecialChars($string, $preserveEntities = false) { return htmlspecialchars((string)$string, null, null, !$preserveEntities); }
php
public function htmlSpecialChars($string, $preserveEntities = false) { return htmlspecialchars((string)$string, null, null, !$preserveEntities); }
[ "public", "function", "htmlSpecialChars", "(", "$", "string", ",", "$", "preserveEntities", "=", "false", ")", "{", "return", "htmlspecialchars", "(", "(", "string", ")", "$", "string", ",", "null", ",", "null", ",", "!", "$", "preserveEntities", ")", ";",...
Convert special characters to HTML entities @param string $string The string to convert @param boolean $preserveEntities ``true`` if entities should not be double encoded @return string The converted string
[ "Convert", "special", "characters", "to", "HTML", "entities" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Eel/Classes/Helper/StringHelper.php#L580-L583
neos/flow-development-collection
Neos.Eel/Classes/Helper/StringHelper.php
StringHelper.crop
public function crop($string, $maximumCharacters, $suffix = '') { $string = (string)$string; if (UnicodeFunctions::strlen($string) > $maximumCharacters) { $string = UnicodeFunctions::substr($string, 0, $maximumCharacters); $string .= $suffix; } return $string; }
php
public function crop($string, $maximumCharacters, $suffix = '') { $string = (string)$string; if (UnicodeFunctions::strlen($string) > $maximumCharacters) { $string = UnicodeFunctions::substr($string, 0, $maximumCharacters); $string .= $suffix; } return $string; }
[ "public", "function", "crop", "(", "$", "string", ",", "$", "maximumCharacters", ",", "$", "suffix", "=", "''", ")", "{", "$", "string", "=", "(", "string", ")", "$", "string", ";", "if", "(", "UnicodeFunctions", "::", "strlen", "(", "$", "string", "...
Crop a string to ``maximumCharacters`` length, optionally appending ``suffix`` if cropping was necessary. @param string $string The input string @param integer $maximumCharacters Number of characters where cropping should happen @param string $suffix Suffix to be appended if cropping was necessary @return string The cropped string
[ "Crop", "a", "string", "to", "maximumCharacters", "length", "optionally", "appending", "suffix", "if", "cropping", "was", "necessary", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Eel/Classes/Helper/StringHelper.php#L593-L603
neos/flow-development-collection
Neos.Eel/Classes/Helper/StringHelper.php
StringHelper.cropAtWord
public function cropAtWord($string, $maximumCharacters, $suffix = '') { $string = (string)$string; if (UnicodeFunctions::strlen($string) > $maximumCharacters) { $iterator = new TextIterator($string, TextIterator::WORD); $string = UnicodeFunctions::substr($string, 0, $iterator->preceding($maximumCharacters)); $string .= $suffix; } return $string; }
php
public function cropAtWord($string, $maximumCharacters, $suffix = '') { $string = (string)$string; if (UnicodeFunctions::strlen($string) > $maximumCharacters) { $iterator = new TextIterator($string, TextIterator::WORD); $string = UnicodeFunctions::substr($string, 0, $iterator->preceding($maximumCharacters)); $string .= $suffix; } return $string; }
[ "public", "function", "cropAtWord", "(", "$", "string", ",", "$", "maximumCharacters", ",", "$", "suffix", "=", "''", ")", "{", "$", "string", "=", "(", "string", ")", "$", "string", ";", "if", "(", "UnicodeFunctions", "::", "strlen", "(", "$", "string...
Crop a string to ``maximumCharacters`` length, taking words into account, optionally appending ``suffix`` if cropping was necessary. @param string $string The input string @param integer $maximumCharacters Number of characters where cropping should happen @param string $suffix Suffix to be appended if cropping was necessary @return string The cropped string
[ "Crop", "a", "string", "to", "maximumCharacters", "length", "taking", "words", "into", "account", "optionally", "appending", "suffix", "if", "cropping", "was", "necessary", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Eel/Classes/Helper/StringHelper.php#L614-L625
neos/flow-development-collection
Neos.Eel/Classes/Helper/StringHelper.php
StringHelper.cropAtSentence
public function cropAtSentence($string, $maximumCharacters, $suffix = '') { $string = (string)$string; if (UnicodeFunctions::strlen($string) > $maximumCharacters) { $iterator = new TextIterator($string, TextIterator::SENTENCE); $string = UnicodeFunctions::substr($string, 0, $iterator->preceding($maximumCharacters)); $string .= $suffix; } return $string; }
php
public function cropAtSentence($string, $maximumCharacters, $suffix = '') { $string = (string)$string; if (UnicodeFunctions::strlen($string) > $maximumCharacters) { $iterator = new TextIterator($string, TextIterator::SENTENCE); $string = UnicodeFunctions::substr($string, 0, $iterator->preceding($maximumCharacters)); $string .= $suffix; } return $string; }
[ "public", "function", "cropAtSentence", "(", "$", "string", ",", "$", "maximumCharacters", ",", "$", "suffix", "=", "''", ")", "{", "$", "string", "=", "(", "string", ")", "$", "string", ";", "if", "(", "UnicodeFunctions", "::", "strlen", "(", "$", "st...
Crop a string to ``maximumCharacters`` length, taking sentences into account, optionally appending ``suffix`` if cropping was necessary. @param string $string The input string @param integer $maximumCharacters Number of characters where cropping should happen @param string $suffix Suffix to be appended if cropping was necessary @return string The cropped string
[ "Crop", "a", "string", "to", "maximumCharacters", "length", "taking", "sentences", "into", "account", "optionally", "appending", "suffix", "if", "cropping", "was", "necessary", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Eel/Classes/Helper/StringHelper.php#L636-L647
neos/flow-development-collection
Neos.Eel/Classes/Helper/StringHelper.php
StringHelper.wordCount
public function wordCount($unicodeString) { $unicodeString = (string)$unicodeString; $unicodeString = preg_replace('/[[:punct:][:digit:]]/', '', $unicodeString); return count(preg_split('/[[:space:]]+/', $unicodeString, 0, PREG_SPLIT_NO_EMPTY)); }
php
public function wordCount($unicodeString) { $unicodeString = (string)$unicodeString; $unicodeString = preg_replace('/[[:punct:][:digit:]]/', '', $unicodeString); return count(preg_split('/[[:space:]]+/', $unicodeString, 0, PREG_SPLIT_NO_EMPTY)); }
[ "public", "function", "wordCount", "(", "$", "unicodeString", ")", "{", "$", "unicodeString", "=", "(", "string", ")", "$", "unicodeString", ";", "$", "unicodeString", "=", "preg_replace", "(", "'/[[:punct:][:digit:]]/'", ",", "''", ",", "$", "unicodeString", ...
Return the count of words for a given string. Remove marks & digits and flatten all kind of whitespaces (tabs, new lines and multiple spaces) For example this helper can be utilized to calculate the reading time of an article. @param string $unicodeString The input string @return integer Number of words
[ "Return", "the", "count", "of", "words", "for", "a", "given", "string", ".", "Remove", "marks", "&", "digits", "and", "flatten", "all", "kind", "of", "whitespaces", "(", "tabs", "new", "lines", "and", "multiple", "spaces", ")", "For", "example", "this", ...
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Eel/Classes/Helper/StringHelper.php#L698-L705
neos/flow-development-collection
Neos.FluidAdaptor/Classes/View/AbstractTemplateView.php
AbstractTemplateView.renderSection
public function renderSection($sectionName, array $variables = [], $ignoreUnknown = false) { // FIXME: We should probably give variables explicitly to this method. if ($variables === []) { $variables = $this->getRenderingContext()->getVariableProvider()->getAll(); } return parent::renderSection($sectionName, $variables, $ignoreUnknown); }
php
public function renderSection($sectionName, array $variables = [], $ignoreUnknown = false) { // FIXME: We should probably give variables explicitly to this method. if ($variables === []) { $variables = $this->getRenderingContext()->getVariableProvider()->getAll(); } return parent::renderSection($sectionName, $variables, $ignoreUnknown); }
[ "public", "function", "renderSection", "(", "$", "sectionName", ",", "array", "$", "variables", "=", "[", "]", ",", "$", "ignoreUnknown", "=", "false", ")", "{", "// FIXME: We should probably give variables explicitly to this method.", "if", "(", "$", "variables", "...
Renders a given section. @param string $sectionName Name of section to render @param array $variables The variables to use @param boolean $ignoreUnknown Ignore an unknown section and just return an empty string @return string rendered template for the section @throws \Neos\FluidAdaptor\View\Exception\InvalidSectionException
[ "Renders", "a", "given", "section", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.FluidAdaptor/Classes/View/AbstractTemplateView.php#L197-L205
neos/flow-development-collection
Neos.FluidAdaptor/Classes/View/AbstractTemplateView.php
AbstractTemplateView.validateOptions
protected function validateOptions(array $options) { // check for options given but not supported if (($unsupportedOptions = array_diff_key($options, $this->supportedOptions)) !== []) { throw new Exception(sprintf('The view options "%s" you\'re trying to set don\'t exist in class "%s".', implode(',', array_keys($unsupportedOptions)), get_class($this)), 1359625876); } // check for required options being set array_walk( $this->supportedOptions, function ($supportedOptionData, $supportedOptionName, $options) { if (isset($supportedOptionData[3]) && !array_key_exists($supportedOptionName, $options)) { throw new Exception('Required view option not set: ' . $supportedOptionName, 1359625876); } }, $options ); }
php
protected function validateOptions(array $options) { // check for options given but not supported if (($unsupportedOptions = array_diff_key($options, $this->supportedOptions)) !== []) { throw new Exception(sprintf('The view options "%s" you\'re trying to set don\'t exist in class "%s".', implode(',', array_keys($unsupportedOptions)), get_class($this)), 1359625876); } // check for required options being set array_walk( $this->supportedOptions, function ($supportedOptionData, $supportedOptionName, $options) { if (isset($supportedOptionData[3]) && !array_key_exists($supportedOptionName, $options)) { throw new Exception('Required view option not set: ' . $supportedOptionName, 1359625876); } }, $options ); }
[ "protected", "function", "validateOptions", "(", "array", "$", "options", ")", "{", "// check for options given but not supported", "if", "(", "(", "$", "unsupportedOptions", "=", "array_diff_key", "(", "$", "options", ",", "$", "this", "->", "supportedOptions", ")"...
Validate options given to this view. @param array $options @return void @throws Exception
[ "Validate", "options", "given", "to", "this", "view", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.FluidAdaptor/Classes/View/AbstractTemplateView.php#L214-L231
neos/flow-development-collection
Neos.FluidAdaptor/Classes/View/AbstractTemplateView.php
AbstractTemplateView.setOptions
protected function setOptions(array $options) { $this->options = array_merge( array_map( function ($value) { return $value[0]; }, $this->supportedOptions ), $options ); }
php
protected function setOptions(array $options) { $this->options = array_merge( array_map( function ($value) { return $value[0]; }, $this->supportedOptions ), $options ); }
[ "protected", "function", "setOptions", "(", "array", "$", "options", ")", "{", "$", "this", "->", "options", "=", "array_merge", "(", "array_map", "(", "function", "(", "$", "value", ")", "{", "return", "$", "value", "[", "0", "]", ";", "}", ",", "$"...
Merges the given options with the default values and sets the resulting options in this object. @param array $options @return void
[ "Merges", "the", "given", "options", "with", "the", "default", "values", "and", "sets", "the", "resulting", "options", "in", "this", "object", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.FluidAdaptor/Classes/View/AbstractTemplateView.php#L240-L251
neos/flow-development-collection
Neos.FluidAdaptor/Classes/View/AbstractTemplateView.php
AbstractTemplateView.getOption
public function getOption($optionName) { if (!array_key_exists($optionName, $this->supportedOptions)) { throw new \Neos\Flow\Mvc\Exception(sprintf('The view option "%s" you\'re trying to get doesn\'t exist in class "%s".', $optionName, get_class($this)), 1359625876); } return $this->options[$optionName]; }
php
public function getOption($optionName) { if (!array_key_exists($optionName, $this->supportedOptions)) { throw new \Neos\Flow\Mvc\Exception(sprintf('The view option "%s" you\'re trying to get doesn\'t exist in class "%s".', $optionName, get_class($this)), 1359625876); } return $this->options[$optionName]; }
[ "public", "function", "getOption", "(", "$", "optionName", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "optionName", ",", "$", "this", "->", "supportedOptions", ")", ")", "{", "throw", "new", "\\", "Neos", "\\", "Flow", "\\", "Mvc", "\\", "...
Get a specific option of this View @param string $optionName @return mixed @throws \Neos\Flow\Mvc\Exception
[ "Get", "a", "specific", "option", "of", "this", "View" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.FluidAdaptor/Classes/View/AbstractTemplateView.php#L260-L267
neos/flow-development-collection
Neos.FluidAdaptor/Classes/View/AbstractTemplateView.php
AbstractTemplateView.setOption
public function setOption($optionName, $value) { if (!array_key_exists($optionName, $this->supportedOptions)) { throw new \Neos\Flow\Mvc\Exception(sprintf('The view option "%s" you\'re trying to set doesn\'t exist in class "%s".', $optionName, get_class($this)), 1359625876); } $this->options[$optionName] = $value; if ($this->baseRenderingContext instanceof RenderingContext) { $this->baseRenderingContext->setOption($optionName, $value); } }
php
public function setOption($optionName, $value) { if (!array_key_exists($optionName, $this->supportedOptions)) { throw new \Neos\Flow\Mvc\Exception(sprintf('The view option "%s" you\'re trying to set doesn\'t exist in class "%s".', $optionName, get_class($this)), 1359625876); } $this->options[$optionName] = $value; if ($this->baseRenderingContext instanceof RenderingContext) { $this->baseRenderingContext->setOption($optionName, $value); } }
[ "public", "function", "setOption", "(", "$", "optionName", ",", "$", "value", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "optionName", ",", "$", "this", "->", "supportedOptions", ")", ")", "{", "throw", "new", "\\", "Neos", "\\", "Flow", "...
Set a specific option of this View @param string $optionName @param mixed $value @return void @throws \Neos\Flow\Mvc\Exception
[ "Set", "a", "specific", "option", "of", "this", "View" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.FluidAdaptor/Classes/View/AbstractTemplateView.php#L277-L287
neos/flow-development-collection
Neos.Flow/Classes/Security/Authentication/Token/AbstractToken.php
AbstractToken.setRequestPatterns
public function setRequestPatterns(array $requestPatterns) { foreach ($requestPatterns as $requestPattern) { if (!$requestPattern instanceof RequestPatternInterface) { throw new \InvalidArgumentException(sprintf('Invalid request pattern passed to token of type "%s"', get_class($this)), 1327398366); } } $this->requestPatterns = $requestPatterns; }
php
public function setRequestPatterns(array $requestPatterns) { foreach ($requestPatterns as $requestPattern) { if (!$requestPattern instanceof RequestPatternInterface) { throw new \InvalidArgumentException(sprintf('Invalid request pattern passed to token of type "%s"', get_class($this)), 1327398366); } } $this->requestPatterns = $requestPatterns; }
[ "public", "function", "setRequestPatterns", "(", "array", "$", "requestPatterns", ")", "{", "foreach", "(", "$", "requestPatterns", "as", "$", "requestPattern", ")", "{", "if", "(", "!", "$", "requestPattern", "instanceof", "RequestPatternInterface", ")", "{", "...
Sets request patterns @param array $requestPatterns Array of RequestPatternInterface to be set @return void @throws \InvalidArgumentException
[ "Sets", "request", "patterns" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Authentication/Token/AbstractToken.php#L129-L137
neos/flow-development-collection
Neos.Flow/Classes/Security/Authentication/Token/AbstractToken.php
AbstractToken.setAuthenticationStatus
public function setAuthenticationStatus($authenticationStatus) { if (!in_array($authenticationStatus, [self::NO_CREDENTIALS_GIVEN, self::WRONG_CREDENTIALS, self::AUTHENTICATION_SUCCESSFUL, self::AUTHENTICATION_NEEDED])) { throw new InvalidAuthenticationStatusException('Invalid authentication status.', 1237224453); } $this->authenticationStatus = $authenticationStatus; }
php
public function setAuthenticationStatus($authenticationStatus) { if (!in_array($authenticationStatus, [self::NO_CREDENTIALS_GIVEN, self::WRONG_CREDENTIALS, self::AUTHENTICATION_SUCCESSFUL, self::AUTHENTICATION_NEEDED])) { throw new InvalidAuthenticationStatusException('Invalid authentication status.', 1237224453); } $this->authenticationStatus = $authenticationStatus; }
[ "public", "function", "setAuthenticationStatus", "(", "$", "authenticationStatus", ")", "{", "if", "(", "!", "in_array", "(", "$", "authenticationStatus", ",", "[", "self", "::", "NO_CREDENTIALS_GIVEN", ",", "self", "::", "WRONG_CREDENTIALS", ",", "self", "::", ...
Sets the authentication status. Usually called by the responsible \Neos\Flow\Security\Authentication\AuthenticationManagerInterface @param integer $authenticationStatus One of NO_CREDENTIALS_GIVEN, WRONG_CREDENTIALS, AUTHENTICATION_SUCCESSFUL, AUTHENTICATION_NEEDED @return void @throws InvalidAuthenticationStatusException
[ "Sets", "the", "authentication", "status", ".", "Usually", "called", "by", "the", "responsible", "\\", "Neos", "\\", "Flow", "\\", "Security", "\\", "Authentication", "\\", "AuthenticationManagerInterface" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Authentication/Token/AbstractToken.php#L188-L194
neos/flow-development-collection
Neos.Flow/Classes/Cli/CommandRequestHandler.php
CommandRequestHandler.handleRequest
public function handleRequest() { $runLevel = $this->bootstrap->isCompiletimeCommand(isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1] : '') ? Bootstrap::RUNLEVEL_COMPILETIME : Bootstrap::RUNLEVEL_RUNTIME; $this->boot($runLevel); $commandLine = isset($_SERVER['argv']) ? $_SERVER['argv'] : []; $this->request = $this->objectManager->get(RequestBuilder::class)->build(array_slice($commandLine, 1)); $this->response = new Response(); $this->exitIfCompiletimeCommandWasNotCalledCorrectly($runLevel); if ($runLevel === Bootstrap::RUNLEVEL_RUNTIME) { /** @var Context $securityContext */ $securityContext = $this->objectManager->get(Context::class); $securityContext->withoutAuthorizationChecks(function () { $this->dispatcher->dispatch($this->request, $this->response); }); } else { $this->dispatcher->dispatch($this->request, $this->response); } $this->response->send(); $this->shutdown($runLevel); }
php
public function handleRequest() { $runLevel = $this->bootstrap->isCompiletimeCommand(isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1] : '') ? Bootstrap::RUNLEVEL_COMPILETIME : Bootstrap::RUNLEVEL_RUNTIME; $this->boot($runLevel); $commandLine = isset($_SERVER['argv']) ? $_SERVER['argv'] : []; $this->request = $this->objectManager->get(RequestBuilder::class)->build(array_slice($commandLine, 1)); $this->response = new Response(); $this->exitIfCompiletimeCommandWasNotCalledCorrectly($runLevel); if ($runLevel === Bootstrap::RUNLEVEL_RUNTIME) { /** @var Context $securityContext */ $securityContext = $this->objectManager->get(Context::class); $securityContext->withoutAuthorizationChecks(function () { $this->dispatcher->dispatch($this->request, $this->response); }); } else { $this->dispatcher->dispatch($this->request, $this->response); } $this->response->send(); $this->shutdown($runLevel); }
[ "public", "function", "handleRequest", "(", ")", "{", "$", "runLevel", "=", "$", "this", "->", "bootstrap", "->", "isCompiletimeCommand", "(", "isset", "(", "$", "_SERVER", "[", "'argv'", "]", "[", "1", "]", ")", "?", "$", "_SERVER", "[", "'argv'", "]"...
Handles a command line request. While booting, the Object Manager is not yet available for retrieving the CommandExceptionHandler. For this purpose, possible occurring exceptions at this stage are caught manually and treated the same way the CommandExceptionHandler treats exceptions on itself anyways. @return void
[ "Handles", "a", "command", "line", "request", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Cli/CommandRequestHandler.php#L93-L117
neos/flow-development-collection
Neos.Flow/Classes/Cli/CommandRequestHandler.php
CommandRequestHandler.exitIfCompiletimeCommandWasNotCalledCorrectly
public function exitIfCompiletimeCommandWasNotCalledCorrectly(string $runlevel) { if ($runlevel === Bootstrap::RUNLEVEL_COMPILETIME) { return; } $command = $this->request->getCommand(); if ($this->bootstrap->isCompiletimeCommand($command->getCommandIdentifier())) { $this->response->appendContent(sprintf( "<b>Unrecognized Command</b>\n\n" . "Sorry, but the command \"%s\" must be specified by its full command\n" . "identifier because it is a compile time command which cannot be resolved\n" . "from an abbreviated command identifier.\n\n", $command->getCommandIdentifier()) ); $this->response->send(); $this->shutdown($runlevel); exit(1); } }
php
public function exitIfCompiletimeCommandWasNotCalledCorrectly(string $runlevel) { if ($runlevel === Bootstrap::RUNLEVEL_COMPILETIME) { return; } $command = $this->request->getCommand(); if ($this->bootstrap->isCompiletimeCommand($command->getCommandIdentifier())) { $this->response->appendContent(sprintf( "<b>Unrecognized Command</b>\n\n" . "Sorry, but the command \"%s\" must be specified by its full command\n" . "identifier because it is a compile time command which cannot be resolved\n" . "from an abbreviated command identifier.\n\n", $command->getCommandIdentifier()) ); $this->response->send(); $this->shutdown($runlevel); exit(1); } }
[ "public", "function", "exitIfCompiletimeCommandWasNotCalledCorrectly", "(", "string", "$", "runlevel", ")", "{", "if", "(", "$", "runlevel", "===", "Bootstrap", "::", "RUNLEVEL_COMPILETIME", ")", "{", "return", ";", "}", "$", "command", "=", "$", "this", "->", ...
Checks if compile time command was not recognized as such, then runlevel was booted but it turned out that in fact the command is a compile time command. This happens if the user doesn't specify the full command identifier. @param string $runlevel one of the Bootstrap::RUNLEVEL_* constants @return void
[ "Checks", "if", "compile", "time", "command", "was", "not", "recognized", "as", "such", "then", "runlevel", "was", "booted", "but", "it", "turned", "out", "that", "in", "fact", "the", "command", "is", "a", "compile", "time", "command", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Cli/CommandRequestHandler.php#L128-L146
neos/flow-development-collection
Neos.Flow/Classes/Cli/CommandRequestHandler.php
CommandRequestHandler.boot
protected function boot(string $runlevel) { $sequence = ($runlevel === Bootstrap::RUNLEVEL_COMPILETIME) ? $this->bootstrap->buildCompiletimeSequence() : $this->bootstrap->buildRuntimeSequence(); $sequence->invoke($this->bootstrap); $this->objectManager = $this->bootstrap->getObjectManager(); $this->dispatcher = $this->objectManager->get(Dispatcher::class); }
php
protected function boot(string $runlevel) { $sequence = ($runlevel === Bootstrap::RUNLEVEL_COMPILETIME) ? $this->bootstrap->buildCompiletimeSequence() : $this->bootstrap->buildRuntimeSequence(); $sequence->invoke($this->bootstrap); $this->objectManager = $this->bootstrap->getObjectManager(); $this->dispatcher = $this->objectManager->get(Dispatcher::class); }
[ "protected", "function", "boot", "(", "string", "$", "runlevel", ")", "{", "$", "sequence", "=", "(", "$", "runlevel", "===", "Bootstrap", "::", "RUNLEVEL_COMPILETIME", ")", "?", "$", "this", "->", "bootstrap", "->", "buildCompiletimeSequence", "(", ")", ":"...
Initializes the matching boot sequence depending on the type of the command (RUNLEVEL_RUNTIME or RUNLEVEL_COMPILETIME) and manually injects the necessary dependencies of this request handler. @param string $runlevel one of the Bootstrap::RUNLEVEL_* constants @return void
[ "Initializes", "the", "matching", "boot", "sequence", "depending", "on", "the", "type", "of", "the", "command", "(", "RUNLEVEL_RUNTIME", "or", "RUNLEVEL_COMPILETIME", ")", "and", "manually", "injects", "the", "necessary", "dependencies", "of", "this", "request", "...
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Cli/CommandRequestHandler.php#L156-L163
neos/flow-development-collection
Neos.Flow/Classes/Cli/CommandRequestHandler.php
CommandRequestHandler.shutdown
protected function shutdown(string $runlevel) { $this->bootstrap->shutdown($runlevel); if ($runlevel === Bootstrap::RUNLEVEL_COMPILETIME) { $this->objectManager->get(LockManager::class)->unlockSite(); } exit($this->response->getExitCode()); }
php
protected function shutdown(string $runlevel) { $this->bootstrap->shutdown($runlevel); if ($runlevel === Bootstrap::RUNLEVEL_COMPILETIME) { $this->objectManager->get(LockManager::class)->unlockSite(); } exit($this->response->getExitCode()); }
[ "protected", "function", "shutdown", "(", "string", "$", "runlevel", ")", "{", "$", "this", "->", "bootstrap", "->", "shutdown", "(", "$", "runlevel", ")", ";", "if", "(", "$", "runlevel", "===", "Bootstrap", "::", "RUNLEVEL_COMPILETIME", ")", "{", "$", ...
Starts the shutdown sequence @param string $runlevel one of the Bootstrap::RUNLEVEL_* constants @return void
[ "Starts", "the", "shutdown", "sequence" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Cli/CommandRequestHandler.php#L171-L178
neos/flow-development-collection
Neos.Flow/Classes/Reflection/DocCommentParser.php
DocCommentParser.parseDocComment
public function parseDocComment($docComment) { $this->description = ''; $this->tags = []; $lines = explode(chr(10), $docComment); foreach ($lines as $line) { $line = trim($line); if ($line === '*/') { break; } if ($line !== '' && strpos($line, '* @') !== false) { $this->parseTag(substr($line, strpos($line, '@'))); } elseif (count($this->tags) === 0) { $this->description .= preg_replace('/\s*\\/?[\\\\*]*\s?(.*)$/', '$1', $line) . chr(10); } } $this->description = trim($this->description); }
php
public function parseDocComment($docComment) { $this->description = ''; $this->tags = []; $lines = explode(chr(10), $docComment); foreach ($lines as $line) { $line = trim($line); if ($line === '*/') { break; } if ($line !== '' && strpos($line, '* @') !== false) { $this->parseTag(substr($line, strpos($line, '@'))); } elseif (count($this->tags) === 0) { $this->description .= preg_replace('/\s*\\/?[\\\\*]*\s?(.*)$/', '$1', $line) . chr(10); } } $this->description = trim($this->description); }
[ "public", "function", "parseDocComment", "(", "$", "docComment", ")", "{", "$", "this", "->", "description", "=", "''", ";", "$", "this", "->", "tags", "=", "[", "]", ";", "$", "lines", "=", "explode", "(", "chr", "(", "10", ")", ",", "$", "docComm...
Parses the given doc comment and saves the result (description and tags) in the parser's object. They can be retrieved by the getTags() getTagValues() and getDescription() methods. @param string $docComment A doc comment as returned by the reflection getDocComment() method @return void
[ "Parses", "the", "given", "doc", "comment", "and", "saves", "the", "result", "(", "description", "and", "tags", ")", "in", "the", "parser", "s", "object", ".", "They", "can", "be", "retrieved", "by", "the", "getTags", "()", "getTagValues", "()", "and", "...
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Reflection/DocCommentParser.php#L43-L61
neos/flow-development-collection
Neos.Flow/Classes/Reflection/DocCommentParser.php
DocCommentParser.getTagValues
public function getTagValues($tagName) { if (!$this->isTaggedWith($tagName)) { throw new Exception('Tag "' . $tagName . '" does not exist.', 1169128255); } return $this->tags[$tagName]; }
php
public function getTagValues($tagName) { if (!$this->isTaggedWith($tagName)) { throw new Exception('Tag "' . $tagName . '" does not exist.', 1169128255); } return $this->tags[$tagName]; }
[ "public", "function", "getTagValues", "(", "$", "tagName", ")", "{", "if", "(", "!", "$", "this", "->", "isTaggedWith", "(", "$", "tagName", ")", ")", "{", "throw", "new", "Exception", "(", "'Tag \"'", ".", "$", "tagName", ".", "'\" does not exist.'", ",...
Returns the values of the specified tag. The doc comment must be parsed with parseDocComment() before tags are available. @param string $tagName The tag name to retrieve the values for @return array The tag's values @throws Exception
[ "Returns", "the", "values", "of", "the", "specified", "tag", ".", "The", "doc", "comment", "must", "be", "parsed", "with", "parseDocComment", "()", "before", "tags", "are", "available", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Reflection/DocCommentParser.php#L82-L88
neos/flow-development-collection
Neos.Flow/Classes/Reflection/DocCommentParser.php
DocCommentParser.parseTag
protected function parseTag($line) { $tagAndValue = []; if (preg_match('/@[A-Za-z0-9\\\\]+\\\\([A-Za-z0-9]+)(?:\\((.*)\\))?$/', $line, $tagAndValue) === 0) { $tagAndValue = preg_split('/\s/', $line, 2); } else { array_shift($tagAndValue); } $tag = strtolower(trim($tagAndValue[0], '@')); if (count($tagAndValue) > 1) { $this->tags[$tag][] = trim($tagAndValue[1], ' "'); } else { $this->tags[$tag] = []; } }
php
protected function parseTag($line) { $tagAndValue = []; if (preg_match('/@[A-Za-z0-9\\\\]+\\\\([A-Za-z0-9]+)(?:\\((.*)\\))?$/', $line, $tagAndValue) === 0) { $tagAndValue = preg_split('/\s/', $line, 2); } else { array_shift($tagAndValue); } $tag = strtolower(trim($tagAndValue[0], '@')); if (count($tagAndValue) > 1) { $this->tags[$tag][] = trim($tagAndValue[1], ' "'); } else { $this->tags[$tag] = []; } }
[ "protected", "function", "parseTag", "(", "$", "line", ")", "{", "$", "tagAndValue", "=", "[", "]", ";", "if", "(", "preg_match", "(", "'/@[A-Za-z0-9\\\\\\\\]+\\\\\\\\([A-Za-z0-9]+)(?:\\\\((.*)\\\\))?$/'", ",", "$", "line", ",", "$", "tagAndValue", ")", "===", "...
Parses a line of a doc comment for a tag and its value. The result is stored in the internal tags array. @param string $line A line of a doc comment which starts with an @-sign @return void
[ "Parses", "a", "line", "of", "a", "doc", "comment", "for", "a", "tag", "and", "its", "value", ".", "The", "result", "is", "stored", "in", "the", "internal", "tags", "array", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Reflection/DocCommentParser.php#L118-L132
neos/flow-development-collection
Neos.Flow/Classes/Package/PackageManager.php
PackageManager.initialize
public function initialize(Bootstrap $bootstrap) { $this->bootstrap = $bootstrap; $this->packageStatesConfiguration = $this->getCurrentPackageStates(); $this->registerPackagesFromConfiguration($this->packageStatesConfiguration); /** @var PackageInterface $package */ foreach ($this->packages as $package) { if ($package instanceof FlowPackageInterface) { $this->flowPackages[$package->getPackageKey()] = $package; } if (!$package instanceof BootablePackageInterface) { continue; } $package->boot($bootstrap); } }
php
public function initialize(Bootstrap $bootstrap) { $this->bootstrap = $bootstrap; $this->packageStatesConfiguration = $this->getCurrentPackageStates(); $this->registerPackagesFromConfiguration($this->packageStatesConfiguration); /** @var PackageInterface $package */ foreach ($this->packages as $package) { if ($package instanceof FlowPackageInterface) { $this->flowPackages[$package->getPackageKey()] = $package; } if (!$package instanceof BootablePackageInterface) { continue; } $package->boot($bootstrap); } }
[ "public", "function", "initialize", "(", "Bootstrap", "$", "bootstrap", ")", "{", "$", "this", "->", "bootstrap", "=", "$", "bootstrap", ";", "$", "this", "->", "packageStatesConfiguration", "=", "$", "this", "->", "getCurrentPackageStates", "(", ")", ";", "...
Initializes the package manager @param Bootstrap $bootstrap The current bootstrap @return void
[ "Initializes", "the", "package", "manager" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Package/PackageManager.php#L133-L149
neos/flow-development-collection
Neos.Flow/Classes/Package/PackageManager.php
PackageManager.getPackage
public function getPackage($packageKey) { if (!$this->isPackageAvailable($packageKey)) { throw new Exception\UnknownPackageException('Package "' . $packageKey . '" is not available. Please check if the package exists and that the package key is correct (package keys are case sensitive).', 1166546734); } return $this->packages[$packageKey]; }
php
public function getPackage($packageKey) { if (!$this->isPackageAvailable($packageKey)) { throw new Exception\UnknownPackageException('Package "' . $packageKey . '" is not available. Please check if the package exists and that the package key is correct (package keys are case sensitive).', 1166546734); } return $this->packages[$packageKey]; }
[ "public", "function", "getPackage", "(", "$", "packageKey", ")", "{", "if", "(", "!", "$", "this", "->", "isPackageAvailable", "(", "$", "packageKey", ")", ")", "{", "throw", "new", "Exception", "\\", "UnknownPackageException", "(", "'Package \"'", ".", "$",...
Returns a PackageInterface object for the specified package. @param string $packageKey @return PackageInterface The requested package object @throws Exception\UnknownPackageException if the specified package is not known @api
[ "Returns", "a", "PackageInterface", "object", "for", "the", "specified", "package", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Package/PackageManager.php#L194-L201
neos/flow-development-collection
Neos.Flow/Classes/Package/PackageManager.php
PackageManager.getFrozenPackages
public function getFrozenPackages() { $frozenPackages = []; if ($this->bootstrap->getContext()->isDevelopment()) { /** @var PackageInterface $package */ foreach ($this->packages as $packageKey => $package) { if (isset($this->packageStatesConfiguration['packages'][$package->getComposerName()]['frozen']) && $this->packageStatesConfiguration['packages'][$package->getComposerName()]['frozen'] === true ) { $frozenPackages[$packageKey] = $package; } } } return $frozenPackages; }
php
public function getFrozenPackages() { $frozenPackages = []; if ($this->bootstrap->getContext()->isDevelopment()) { /** @var PackageInterface $package */ foreach ($this->packages as $packageKey => $package) { if (isset($this->packageStatesConfiguration['packages'][$package->getComposerName()]['frozen']) && $this->packageStatesConfiguration['packages'][$package->getComposerName()]['frozen'] === true ) { $frozenPackages[$packageKey] = $package; } } } return $frozenPackages; }
[ "public", "function", "getFrozenPackages", "(", ")", "{", "$", "frozenPackages", "=", "[", "]", ";", "if", "(", "$", "this", "->", "bootstrap", "->", "getContext", "(", ")", "->", "isDevelopment", "(", ")", ")", "{", "/** @var PackageInterface $package */", ...
Returns an array of PackageInterface objects of all frozen packages. A frozen package is not considered by file monitoring and provides some precompiled reflection data in order to improve performance. @return array<PackageInterface>
[ "Returns", "an", "array", "of", "PackageInterface", "objects", "of", "all", "frozen", "packages", ".", "A", "frozen", "package", "is", "not", "considered", "by", "file", "monitoring", "and", "provides", "some", "precompiled", "reflection", "data", "in", "order",...
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Package/PackageManager.php#L222-L237
neos/flow-development-collection
Neos.Flow/Classes/Package/PackageManager.php
PackageManager.getFilteredPackages
public function getFilteredPackages($packageState = 'available', $packagePath = null, $packageType = null) { switch (strtolower($packageState)) { case 'available': $packages = $this->getAvailablePackages(); break; case 'frozen': $packages = $this->getFrozenPackages(); break; default: throw new Exception\InvalidPackageStateException('The package state "' . $packageState . '" is invalid', 1372458274); } if ($packagePath !== null) { $packages = $this->filterPackagesByPath($packages, $packagePath); } if ($packageType !== null) { $packages = $this->filterPackagesByType($packages, $packageType); } return $packages; }
php
public function getFilteredPackages($packageState = 'available', $packagePath = null, $packageType = null) { switch (strtolower($packageState)) { case 'available': $packages = $this->getAvailablePackages(); break; case 'frozen': $packages = $this->getFrozenPackages(); break; default: throw new Exception\InvalidPackageStateException('The package state "' . $packageState . '" is invalid', 1372458274); } if ($packagePath !== null) { $packages = $this->filterPackagesByPath($packages, $packagePath); } if ($packageType !== null) { $packages = $this->filterPackagesByType($packages, $packageType); } return $packages; }
[ "public", "function", "getFilteredPackages", "(", "$", "packageState", "=", "'available'", ",", "$", "packagePath", "=", "null", ",", "$", "packageType", "=", "null", ")", "{", "switch", "(", "strtolower", "(", "$", "packageState", ")", ")", "{", "case", "...
Returns an array of PackageInterface objects of all packages that match the given package state, path, and type filters. All three filters must match, if given. @param string $packageState defaults to available @param string $packagePath DEPRECATED since Flow 5.0 @param string $packageType @return array<PackageInterface> @throws Exception\InvalidPackageStateException @api
[ "Returns", "an", "array", "of", "PackageInterface", "objects", "of", "all", "packages", "that", "match", "the", "given", "package", "state", "path", "and", "type", "filters", ".", "All", "three", "filters", "must", "match", "if", "given", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Package/PackageManager.php#L251-L272
neos/flow-development-collection
Neos.Flow/Classes/Package/PackageManager.php
PackageManager.filterPackagesByPath
protected function filterPackagesByPath($packages, $filterPath) { $filteredPackages = []; /** @var $package Package */ foreach ($packages as $package) { $packagePath = substr($package->getPackagePath(), strlen($this->packagesBasePath)); $packageGroup = substr($packagePath, 0, strpos($packagePath, '/')); if ($packageGroup === $filterPath) { $filteredPackages[$package->getPackageKey()] = $package; } } return $filteredPackages; }
php
protected function filterPackagesByPath($packages, $filterPath) { $filteredPackages = []; /** @var $package Package */ foreach ($packages as $package) { $packagePath = substr($package->getPackagePath(), strlen($this->packagesBasePath)); $packageGroup = substr($packagePath, 0, strpos($packagePath, '/')); if ($packageGroup === $filterPath) { $filteredPackages[$package->getPackageKey()] = $package; } } return $filteredPackages; }
[ "protected", "function", "filterPackagesByPath", "(", "$", "packages", ",", "$", "filterPath", ")", "{", "$", "filteredPackages", "=", "[", "]", ";", "/** @var $package Package */", "foreach", "(", "$", "packages", "as", "$", "package", ")", "{", "$", "package...
Returns an array of PackageInterface objects in the given array of packages that are in the specified Package Path @param array $packages Array of PackageInterface to be filtered @param string $filterPath Filter out anything that's not in this path @return array<PackageInterface>
[ "Returns", "an", "array", "of", "PackageInterface", "objects", "in", "the", "given", "array", "of", "packages", "that", "are", "in", "the", "specified", "Package", "Path" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Package/PackageManager.php#L282-L295
neos/flow-development-collection
Neos.Flow/Classes/Package/PackageManager.php
PackageManager.filterPackagesByType
protected function filterPackagesByType($packages, $packageType) { $filteredPackages = []; /** @var $package Package */ foreach ($packages as $package) { if ($package->getComposerManifest('type') === $packageType) { $filteredPackages[$package->getPackageKey()] = $package; } } return $filteredPackages; }
php
protected function filterPackagesByType($packages, $packageType) { $filteredPackages = []; /** @var $package Package */ foreach ($packages as $package) { if ($package->getComposerManifest('type') === $packageType) { $filteredPackages[$package->getPackageKey()] = $package; } } return $filteredPackages; }
[ "protected", "function", "filterPackagesByType", "(", "$", "packages", ",", "$", "packageType", ")", "{", "$", "filteredPackages", "=", "[", "]", ";", "/** @var $package Package */", "foreach", "(", "$", "packages", "as", "$", "package", ")", "{", "if", "(", ...
Returns an array of PackageInterface objects in the given array of packages that are of the specified package type. @param array $packages Array of PackageInterface objects to be filtered @param string $packageType Filter out anything that's not of this packageType @return array<PackageInterface>
[ "Returns", "an", "array", "of", "PackageInterface", "objects", "in", "the", "given", "array", "of", "packages", "that", "are", "of", "the", "specified", "package", "type", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Package/PackageManager.php#L305-L316
neos/flow-development-collection
Neos.Flow/Classes/Package/PackageManager.php
PackageManager.createPackage
public function createPackage($packageKey, array $manifest = [], $packagesPath = null) { if (!$this->isPackageKeyValid($packageKey)) { throw new Exception\InvalidPackageKeyException('The package key "' . $packageKey . '" is invalid', 1220722210); } if ($this->isPackageAvailable($packageKey)) { throw new Exception\PackageKeyAlreadyExistsException('The package key "' . $packageKey . '" already exists', 1220722873); } if (!isset($manifest['type'])) { $manifest['type'] = PackageInterface::DEFAULT_COMPOSER_TYPE; } $runComposerRequireForTheCreatedPackage = false; if ($packagesPath === null) { $composerManifestRepositories = ComposerUtility::getComposerManifest(FLOW_PATH_ROOT, 'repositories'); if (is_array($composerManifestRepositories)) { foreach ($composerManifestRepositories as $repository) { if (is_array($repository) && isset($repository['type']) && $repository['type'] === 'path' && isset($repository['url']) && substr($repository['url'], 0, 2) === './' && substr($repository['url'], -2) === '/*' ) { $packagesPath = Files::getUnixStylePath(Files::concatenatePaths([FLOW_PATH_ROOT, substr($repository['url'], 0, -2)])); $runComposerRequireForTheCreatedPackage = true; break; } } } } if ($packagesPath === null) { $packagesPath = 'Application'; if (is_array($this->settings['packagesPathByType']) && isset($this->settings['packagesPathByType'][$manifest['type']])) { $packagesPath = $this->settings['packagesPathByType'][$manifest['type']]; } $packagesPath = Files::getUnixStylePath(Files::concatenatePaths([$this->packagesBasePath, $packagesPath])); } $packagePath = Files::concatenatePaths([$packagesPath, $packageKey]) . '/'; Files::createDirectoryRecursively($packagePath); foreach ( [ FlowPackageInterface::DIRECTORY_CLASSES, FlowPackageInterface::DIRECTORY_CONFIGURATION, FlowPackageInterface::DIRECTORY_RESOURCES, FlowPackageInterface::DIRECTORY_TESTS_UNIT, FlowPackageInterface::DIRECTORY_TESTS_FUNCTIONAL, ] as $path) { Files::createDirectoryRecursively(Files::concatenatePaths([$packagePath, $path])); } $manifest = ComposerUtility::writeComposerManifest($packagePath, $packageKey, $manifest); if ($runComposerRequireForTheCreatedPackage) { exec('composer require ' . $manifest['name'] . ' @dev'); } $refreshedPackageStatesConfiguration = $this->rescanPackages(); $this->packageStatesConfiguration = $refreshedPackageStatesConfiguration; $this->registerPackageFromStateConfiguration($manifest['name'], $this->packageStatesConfiguration['packages'][$manifest['name']]); $package = $this->packages[$packageKey]; if ($package instanceof FlowPackageInterface) { $this->flowPackages[$packageKey] = $package; } return $package; }
php
public function createPackage($packageKey, array $manifest = [], $packagesPath = null) { if (!$this->isPackageKeyValid($packageKey)) { throw new Exception\InvalidPackageKeyException('The package key "' . $packageKey . '" is invalid', 1220722210); } if ($this->isPackageAvailable($packageKey)) { throw new Exception\PackageKeyAlreadyExistsException('The package key "' . $packageKey . '" already exists', 1220722873); } if (!isset($manifest['type'])) { $manifest['type'] = PackageInterface::DEFAULT_COMPOSER_TYPE; } $runComposerRequireForTheCreatedPackage = false; if ($packagesPath === null) { $composerManifestRepositories = ComposerUtility::getComposerManifest(FLOW_PATH_ROOT, 'repositories'); if (is_array($composerManifestRepositories)) { foreach ($composerManifestRepositories as $repository) { if (is_array($repository) && isset($repository['type']) && $repository['type'] === 'path' && isset($repository['url']) && substr($repository['url'], 0, 2) === './' && substr($repository['url'], -2) === '/*' ) { $packagesPath = Files::getUnixStylePath(Files::concatenatePaths([FLOW_PATH_ROOT, substr($repository['url'], 0, -2)])); $runComposerRequireForTheCreatedPackage = true; break; } } } } if ($packagesPath === null) { $packagesPath = 'Application'; if (is_array($this->settings['packagesPathByType']) && isset($this->settings['packagesPathByType'][$manifest['type']])) { $packagesPath = $this->settings['packagesPathByType'][$manifest['type']]; } $packagesPath = Files::getUnixStylePath(Files::concatenatePaths([$this->packagesBasePath, $packagesPath])); } $packagePath = Files::concatenatePaths([$packagesPath, $packageKey]) . '/'; Files::createDirectoryRecursively($packagePath); foreach ( [ FlowPackageInterface::DIRECTORY_CLASSES, FlowPackageInterface::DIRECTORY_CONFIGURATION, FlowPackageInterface::DIRECTORY_RESOURCES, FlowPackageInterface::DIRECTORY_TESTS_UNIT, FlowPackageInterface::DIRECTORY_TESTS_FUNCTIONAL, ] as $path) { Files::createDirectoryRecursively(Files::concatenatePaths([$packagePath, $path])); } $manifest = ComposerUtility::writeComposerManifest($packagePath, $packageKey, $manifest); if ($runComposerRequireForTheCreatedPackage) { exec('composer require ' . $manifest['name'] . ' @dev'); } $refreshedPackageStatesConfiguration = $this->rescanPackages(); $this->packageStatesConfiguration = $refreshedPackageStatesConfiguration; $this->registerPackageFromStateConfiguration($manifest['name'], $this->packageStatesConfiguration['packages'][$manifest['name']]); $package = $this->packages[$packageKey]; if ($package instanceof FlowPackageInterface) { $this->flowPackages[$packageKey] = $package; } return $package; }
[ "public", "function", "createPackage", "(", "$", "packageKey", ",", "array", "$", "manifest", "=", "[", "]", ",", "$", "packagesPath", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->", "isPackageKeyValid", "(", "$", "packageKey", ")", ")", "{",...
Create a package, given the package key @param string $packageKey The package key of the new package @param array $manifest A composer manifest as associative array. @param string $packagesPath If specified, the package will be created in this path, otherwise the default "Application" directory is used @return PackageInterface The newly created package @throws Exception\PackageKeyAlreadyExistsException @throws Exception\InvalidPackageKeyException @throws Exception\PackageKeyAlreadyExistsException @api
[ "Create", "a", "package", "given", "the", "package", "key" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Package/PackageManager.php#L331-L398
neos/flow-development-collection
Neos.Flow/Classes/Package/PackageManager.php
PackageManager.movePackage
protected function movePackage($fromAbsolutePath, $toAbsolutePath) { Files::createDirectoryRecursively($toAbsolutePath); Files::copyDirectoryRecursively($fromAbsolutePath, $toAbsolutePath, false, true); Files::removeDirectoryRecursively($fromAbsolutePath); }
php
protected function movePackage($fromAbsolutePath, $toAbsolutePath) { Files::createDirectoryRecursively($toAbsolutePath); Files::copyDirectoryRecursively($fromAbsolutePath, $toAbsolutePath, false, true); Files::removeDirectoryRecursively($fromAbsolutePath); }
[ "protected", "function", "movePackage", "(", "$", "fromAbsolutePath", ",", "$", "toAbsolutePath", ")", "{", "Files", "::", "createDirectoryRecursively", "(", "$", "toAbsolutePath", ")", ";", "Files", "::", "copyDirectoryRecursively", "(", "$", "fromAbsolutePath", ",...
Moves a package from one path to another. @param string $fromAbsolutePath @param string $toAbsolutePath @return void
[ "Moves", "a", "package", "from", "one", "path", "to", "another", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Package/PackageManager.php#L407-L412
neos/flow-development-collection
Neos.Flow/Classes/Package/PackageManager.php
PackageManager.freezePackage
public function freezePackage($packageKey) { if (!$this->bootstrap->getContext()->isDevelopment()) { throw new \LogicException('Package freezing is only supported in Development context.', 1338810870); } if (!$this->isPackageAvailable($packageKey)) { throw new Exception\UnknownPackageException('Package "' . $packageKey . '" is not available.', 1331715956); } if ($this->isPackageFrozen($packageKey)) { return; } $package = $this->packages[$packageKey]; $this->bootstrap->getObjectManager()->get(ReflectionService::class)->freezePackageReflection($packageKey); $this->packageStatesConfiguration['packages'][$package->getComposerName()]['frozen'] = true; $this->savePackageStates($this->packageStatesConfiguration); }
php
public function freezePackage($packageKey) { if (!$this->bootstrap->getContext()->isDevelopment()) { throw new \LogicException('Package freezing is only supported in Development context.', 1338810870); } if (!$this->isPackageAvailable($packageKey)) { throw new Exception\UnknownPackageException('Package "' . $packageKey . '" is not available.', 1331715956); } if ($this->isPackageFrozen($packageKey)) { return; } $package = $this->packages[$packageKey]; $this->bootstrap->getObjectManager()->get(ReflectionService::class)->freezePackageReflection($packageKey); $this->packageStatesConfiguration['packages'][$package->getComposerName()]['frozen'] = true; $this->savePackageStates($this->packageStatesConfiguration); }
[ "public", "function", "freezePackage", "(", "$", "packageKey", ")", "{", "if", "(", "!", "$", "this", "->", "bootstrap", "->", "getContext", "(", ")", "->", "isDevelopment", "(", ")", ")", "{", "throw", "new", "\\", "LogicException", "(", "'Package freezin...
Freezes a package @param string $packageKey The package to freeze @return void @throws \LogicException @throws Exception\UnknownPackageException
[ "Freezes", "a", "package" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Package/PackageManager.php#L422-L440
neos/flow-development-collection
Neos.Flow/Classes/Package/PackageManager.php
PackageManager.isPackageFrozen
public function isPackageFrozen($packageKey) { if (!isset($this->packages[$packageKey])) { return false; } $composerName = $this->packages[$packageKey]->getComposerName(); return ( $this->bootstrap->getContext()->isDevelopment() && isset($this->packageStatesConfiguration['packages'][$composerName]['frozen']) && $this->packageStatesConfiguration['packages'][$composerName]['frozen'] === true ); }
php
public function isPackageFrozen($packageKey) { if (!isset($this->packages[$packageKey])) { return false; } $composerName = $this->packages[$packageKey]->getComposerName(); return ( $this->bootstrap->getContext()->isDevelopment() && isset($this->packageStatesConfiguration['packages'][$composerName]['frozen']) && $this->packageStatesConfiguration['packages'][$composerName]['frozen'] === true ); }
[ "public", "function", "isPackageFrozen", "(", "$", "packageKey", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "packages", "[", "$", "packageKey", "]", ")", ")", "{", "return", "false", ";", "}", "$", "composerName", "=", "$", "this", "-...
Tells if a package is frozen @param string $packageKey The package to check @return boolean
[ "Tells", "if", "a", "package", "is", "frozen" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Package/PackageManager.php#L448-L460
neos/flow-development-collection
Neos.Flow/Classes/Package/PackageManager.php
PackageManager.unfreezePackage
public function unfreezePackage($packageKey) { if (!$this->isPackageFrozen($packageKey)) { return; } if (!isset($this->packages[$packageKey])) { return; } $composerName = $this->packages[$packageKey]->getComposerName(); $this->bootstrap->getObjectManager()->get(ReflectionService::class)->unfreezePackageReflection($packageKey); unset($this->packageStatesConfiguration['packages'][$composerName]['frozen']); $this->savePackageStates($this->packageStatesConfiguration); }
php
public function unfreezePackage($packageKey) { if (!$this->isPackageFrozen($packageKey)) { return; } if (!isset($this->packages[$packageKey])) { return; } $composerName = $this->packages[$packageKey]->getComposerName(); $this->bootstrap->getObjectManager()->get(ReflectionService::class)->unfreezePackageReflection($packageKey); unset($this->packageStatesConfiguration['packages'][$composerName]['frozen']); $this->savePackageStates($this->packageStatesConfiguration); }
[ "public", "function", "unfreezePackage", "(", "$", "packageKey", ")", "{", "if", "(", "!", "$", "this", "->", "isPackageFrozen", "(", "$", "packageKey", ")", ")", "{", "return", ";", "}", "if", "(", "!", "isset", "(", "$", "this", "->", "packages", "...
Unfreezes a package @param string $packageKey The package to unfreeze @return void
[ "Unfreezes", "a", "package" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Package/PackageManager.php#L468-L482
neos/flow-development-collection
Neos.Flow/Classes/Package/PackageManager.php
PackageManager.refreezePackage
public function refreezePackage($packageKey) { if (!$this->isPackageFrozen($packageKey)) { return; } $this->bootstrap->getObjectManager()->get(ReflectionService::class)->unfreezePackageReflection($packageKey); }
php
public function refreezePackage($packageKey) { if (!$this->isPackageFrozen($packageKey)) { return; } $this->bootstrap->getObjectManager()->get(ReflectionService::class)->unfreezePackageReflection($packageKey); }
[ "public", "function", "refreezePackage", "(", "$", "packageKey", ")", "{", "if", "(", "!", "$", "this", "->", "isPackageFrozen", "(", "$", "packageKey", ")", ")", "{", "return", ";", "}", "$", "this", "->", "bootstrap", "->", "getObjectManager", "(", ")"...
Refreezes a package @param string $packageKey The package to refreeze @return void
[ "Refreezes", "a", "package" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Package/PackageManager.php#L490-L497
neos/flow-development-collection
Neos.Flow/Classes/Package/PackageManager.php
PackageManager.getCurrentPackageStates
protected function getCurrentPackageStates() { $savePackageStates = false; $loadedPackageStates = $this->loadPackageStates(); if ( empty($loadedPackageStates) || !isset($loadedPackageStates['version']) || $loadedPackageStates['version'] < self::PACKAGESTATE_FORMAT_VERSION ) { $loadedPackageStates = $this->scanAvailablePackages(); $savePackageStates = true; } if ($savePackageStates) { $loadedPackageStates = $this->sortAndSavePackageStates($loadedPackageStates); } return $loadedPackageStates; }
php
protected function getCurrentPackageStates() { $savePackageStates = false; $loadedPackageStates = $this->loadPackageStates(); if ( empty($loadedPackageStates) || !isset($loadedPackageStates['version']) || $loadedPackageStates['version'] < self::PACKAGESTATE_FORMAT_VERSION ) { $loadedPackageStates = $this->scanAvailablePackages(); $savePackageStates = true; } if ($savePackageStates) { $loadedPackageStates = $this->sortAndSavePackageStates($loadedPackageStates); } return $loadedPackageStates; }
[ "protected", "function", "getCurrentPackageStates", "(", ")", "{", "$", "savePackageStates", "=", "false", ";", "$", "loadedPackageStates", "=", "$", "this", "->", "loadPackageStates", "(", ")", ";", "if", "(", "empty", "(", "$", "loadedPackageStates", ")", "|...
Loads the states of available packages from the PackageStates.php file and initialises a package scan if the file was not found or the configuration format was not current. @return array
[ "Loads", "the", "states", "of", "available", "packages", "from", "the", "PackageStates", ".", "php", "file", "and", "initialises", "a", "package", "scan", "if", "the", "file", "was", "not", "found", "or", "the", "configuration", "format", "was", "not", "curr...
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Package/PackageManager.php#L519-L537
neos/flow-development-collection
Neos.Flow/Classes/Package/PackageManager.php
PackageManager.scanAvailablePackages
protected function scanAvailablePackages() { $newPackageStatesConfiguration = ['packages' => []]; foreach ($this->findComposerPackagesInPath($this->packagesBasePath) as $packagePath) { $composerManifest = ComposerUtility::getComposerManifest($packagePath); if (!isset($composerManifest['name'])) { throw new InvalidConfigurationException(sprintf('A package composer.json was found at "%s" that contained no "name".', $packagePath), 1445933572); } if (strpos($packagePath, Files::concatenatePaths([$this->packagesBasePath, 'Inactive'])) === 0) { // Skip packages in legacy "Inactive" folder. continue; } $packageKey = $this->getPackageKeyFromManifest($composerManifest, $packagePath); $this->composerNameToPackageKeyMap[strtolower($composerManifest['name'])] = $packageKey; $packageConfiguration = $this->preparePackageStateConfiguration($packageKey, $packagePath, $composerManifest); if (isset($newPackageStatesConfiguration['packages'][$composerManifest['name']])) { throw new PackageException( sprintf('The package with the name "%s" was found more than once, please make sure it exists only once. Paths "%s" and "%s".', $composerManifest['name'], $packageConfiguration['packagePath'], $newPackageStatesConfiguration['packages'][$composerManifest['name']]['packagePath']), 1493030262 ); } $newPackageStatesConfiguration['packages'][$composerManifest['name']] = $packageConfiguration; } return $newPackageStatesConfiguration; }
php
protected function scanAvailablePackages() { $newPackageStatesConfiguration = ['packages' => []]; foreach ($this->findComposerPackagesInPath($this->packagesBasePath) as $packagePath) { $composerManifest = ComposerUtility::getComposerManifest($packagePath); if (!isset($composerManifest['name'])) { throw new InvalidConfigurationException(sprintf('A package composer.json was found at "%s" that contained no "name".', $packagePath), 1445933572); } if (strpos($packagePath, Files::concatenatePaths([$this->packagesBasePath, 'Inactive'])) === 0) { // Skip packages in legacy "Inactive" folder. continue; } $packageKey = $this->getPackageKeyFromManifest($composerManifest, $packagePath); $this->composerNameToPackageKeyMap[strtolower($composerManifest['name'])] = $packageKey; $packageConfiguration = $this->preparePackageStateConfiguration($packageKey, $packagePath, $composerManifest); if (isset($newPackageStatesConfiguration['packages'][$composerManifest['name']])) { throw new PackageException( sprintf('The package with the name "%s" was found more than once, please make sure it exists only once. Paths "%s" and "%s".', $composerManifest['name'], $packageConfiguration['packagePath'], $newPackageStatesConfiguration['packages'][$composerManifest['name']]['packagePath']), 1493030262 ); } $newPackageStatesConfiguration['packages'][$composerManifest['name']] = $packageConfiguration; } return $newPackageStatesConfiguration; }
[ "protected", "function", "scanAvailablePackages", "(", ")", "{", "$", "newPackageStatesConfiguration", "=", "[", "'packages'", "=>", "[", "]", "]", ";", "foreach", "(", "$", "this", "->", "findComposerPackagesInPath", "(", "$", "this", "->", "packagesBasePath", ...
Scans all directories in the packages directories for available packages. For each package a Package object is created and stored in $this->packages. @return array @throws Exception @throws InvalidConfigurationException
[ "Scans", "all", "directories", "in", "the", "packages", "directories", "for", "available", "packages", ".", "For", "each", "package", "a", "Package", "object", "is", "created", "and", "stored", "in", "$this", "-", ">", "packages", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Package/PackageManager.php#L557-L589
neos/flow-development-collection
Neos.Flow/Classes/Package/PackageManager.php
PackageManager.findComposerPackagesInPath
protected function findComposerPackagesInPath($startingDirectory) { $directories = [$startingDirectory]; while ($directories !== []) { $currentDirectory = array_pop($directories); if ($handle = opendir($currentDirectory)) { while (false !== ($filename = readdir($handle))) { if ($filename[0] === '.') { continue; } $pathAndFilename = $currentDirectory . $filename; if (is_dir($pathAndFilename)) { $potentialPackageDirectory = $pathAndFilename . '/'; if (is_file($potentialPackageDirectory . 'composer.json')) { $composerManifest = ComposerUtility::getComposerManifest($potentialPackageDirectory); // TODO: Maybe get rid of magic string "neos-package-collection" by fetching collection package types from outside. if (isset($composerManifest['type']) && $composerManifest['type'] === 'neos-package-collection') { $directories[] = $potentialPackageDirectory; continue; } yield $potentialPackageDirectory; } else { $directories[] = $potentialPackageDirectory; } } } closedir($handle); } } }
php
protected function findComposerPackagesInPath($startingDirectory) { $directories = [$startingDirectory]; while ($directories !== []) { $currentDirectory = array_pop($directories); if ($handle = opendir($currentDirectory)) { while (false !== ($filename = readdir($handle))) { if ($filename[0] === '.') { continue; } $pathAndFilename = $currentDirectory . $filename; if (is_dir($pathAndFilename)) { $potentialPackageDirectory = $pathAndFilename . '/'; if (is_file($potentialPackageDirectory . 'composer.json')) { $composerManifest = ComposerUtility::getComposerManifest($potentialPackageDirectory); // TODO: Maybe get rid of magic string "neos-package-collection" by fetching collection package types from outside. if (isset($composerManifest['type']) && $composerManifest['type'] === 'neos-package-collection') { $directories[] = $potentialPackageDirectory; continue; } yield $potentialPackageDirectory; } else { $directories[] = $potentialPackageDirectory; } } } closedir($handle); } } }
[ "protected", "function", "findComposerPackagesInPath", "(", "$", "startingDirectory", ")", "{", "$", "directories", "=", "[", "$", "startingDirectory", "]", ";", "while", "(", "$", "directories", "!==", "[", "]", ")", "{", "$", "currentDirectory", "=", "array_...
Recursively traverses directories from the given starting points and returns all folder paths that contain a composer.json and which does NOT have the key "extra.neos.is-merged-repository" set, as that indicates a composer package that joins several "real" packages together. In case a "is-merged-repository" is found the traversal continues inside. @param string $startingDirectory @return \Generator
[ "Recursively", "traverses", "directories", "from", "the", "given", "starting", "points", "and", "returns", "all", "folder", "paths", "that", "contain", "a", "composer", ".", "json", "and", "which", "does", "NOT", "have", "the", "key", "extra", ".", "neos", "...
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Package/PackageManager.php#L599-L628
neos/flow-development-collection
Neos.Flow/Classes/Package/PackageManager.php
PackageManager.registerPackagesFromConfiguration
protected function registerPackagesFromConfiguration($packageStatesConfiguration) { foreach ($packageStatesConfiguration['packages'] as $composerName => $packageStateConfiguration) { $this->registerPackageFromStateConfiguration($composerName, $packageStateConfiguration); } }
php
protected function registerPackagesFromConfiguration($packageStatesConfiguration) { foreach ($packageStatesConfiguration['packages'] as $composerName => $packageStateConfiguration) { $this->registerPackageFromStateConfiguration($composerName, $packageStateConfiguration); } }
[ "protected", "function", "registerPackagesFromConfiguration", "(", "$", "packageStatesConfiguration", ")", "{", "foreach", "(", "$", "packageStatesConfiguration", "[", "'packages'", "]", "as", "$", "composerName", "=>", "$", "packageStateConfiguration", ")", "{", "$", ...
Requires and registers all packages which were defined in packageStatesConfiguration @param array $packageStatesConfiguration @throws Exception\CorruptPackageException
[ "Requires", "and", "registers", "all", "packages", "which", "were", "defined", "in", "packageStatesConfiguration" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Package/PackageManager.php#L656-L661
neos/flow-development-collection
Neos.Flow/Classes/Package/PackageManager.php
PackageManager.registerPackageFromStateConfiguration
protected function registerPackageFromStateConfiguration($composerName, $packageStateConfiguration) { $packagePath = isset($packageStateConfiguration['packagePath']) ? $packageStateConfiguration['packagePath'] : null; $packageClassInformation = isset($packageStateConfiguration['packageClassInformation']) ? $packageStateConfiguration['packageClassInformation'] : null; $package = $this->packageFactory->create($this->packagesBasePath, $packagePath, $packageStateConfiguration['packageKey'], $composerName, $packageStateConfiguration['autoloadConfiguration'], $packageClassInformation); $this->packageKeys[strtolower($package->getPackageKey())] = $package->getPackageKey(); $this->packages[$package->getPackageKey()] = $package; }
php
protected function registerPackageFromStateConfiguration($composerName, $packageStateConfiguration) { $packagePath = isset($packageStateConfiguration['packagePath']) ? $packageStateConfiguration['packagePath'] : null; $packageClassInformation = isset($packageStateConfiguration['packageClassInformation']) ? $packageStateConfiguration['packageClassInformation'] : null; $package = $this->packageFactory->create($this->packagesBasePath, $packagePath, $packageStateConfiguration['packageKey'], $composerName, $packageStateConfiguration['autoloadConfiguration'], $packageClassInformation); $this->packageKeys[strtolower($package->getPackageKey())] = $package->getPackageKey(); $this->packages[$package->getPackageKey()] = $package; }
[ "protected", "function", "registerPackageFromStateConfiguration", "(", "$", "composerName", ",", "$", "packageStateConfiguration", ")", "{", "$", "packagePath", "=", "isset", "(", "$", "packageStateConfiguration", "[", "'packagePath'", "]", ")", "?", "$", "packageStat...
Registers a package under the given composer name with the configuration. This uses the PackageFactory to create the Package instance and sets it to all relevant data arrays. @param string $composerName @param array $packageStateConfiguration @return void
[ "Registers", "a", "package", "under", "the", "given", "composer", "name", "with", "the", "configuration", ".", "This", "uses", "the", "PackageFactory", "to", "create", "the", "Package", "instance", "and", "sets", "it", "to", "all", "relevant", "data", "arrays"...
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Package/PackageManager.php#L672-L679
neos/flow-development-collection
Neos.Flow/Classes/Package/PackageManager.php
PackageManager.sortAndSavePackageStates
protected function sortAndSavePackageStates(array $packageStates) { $orderedPackageStates = $this->sortAvailablePackagesByDependencies($packageStates); $this->savePackageStates($orderedPackageStates); return $orderedPackageStates; }
php
protected function sortAndSavePackageStates(array $packageStates) { $orderedPackageStates = $this->sortAvailablePackagesByDependencies($packageStates); $this->savePackageStates($orderedPackageStates); return $orderedPackageStates; }
[ "protected", "function", "sortAndSavePackageStates", "(", "array", "$", "packageStates", ")", "{", "$", "orderedPackageStates", "=", "$", "this", "->", "sortAvailablePackagesByDependencies", "(", "$", "packageStates", ")", ";", "$", "this", "->", "savePackageStates", ...
Takes the given packageStatesConfiguration, sorts it by dependencies, saves it and returns the ordered list @param array $packageStates @return array
[ "Takes", "the", "given", "packageStatesConfiguration", "sorts", "it", "by", "dependencies", "saves", "it", "and", "returns", "the", "ordered", "list" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Package/PackageManager.php#L688-L694
neos/flow-development-collection
Neos.Flow/Classes/Package/PackageManager.php
PackageManager.savePackageStates
protected function savePackageStates(array $orderedPackageStates) { $orderedPackageStates['version'] = static::PACKAGESTATE_FORMAT_VERSION; $fileDescription = "# PackageStates.php\n\n"; $fileDescription .= "# This file is maintained by Flow's package management. You shouldn't edit it manually\n"; $fileDescription .= "# manually, you should rather use the command line commands for maintaining packages.\n"; $fileDescription .= "# You'll find detailed information about the neos.flow:package:* commands in their\n"; $fileDescription .= "# respective help screens.\n\n"; $fileDescription .= "# This file will be regenerated automatically if it doesn't exist. Deleting this file\n"; $fileDescription .= "# should, however, never become necessary if you use the package commands.\n"; $packageStatesCode = "<?php\n" . $fileDescription . "\nreturn " . var_export($orderedPackageStates, true) . ';'; Files::createDirectoryRecursively(dirname($this->packageInformationCacheFilePath)); $result = @file_put_contents($this->packageInformationCacheFilePath, $packageStatesCode); if ($result === false) { throw new Exception\PackageStatesFileNotWritableException(sprintf('Flow could not update the list of installed packages because the file %s is not writable. Please, check the file system permissions and make sure that the web server can write to it.', $this->packageInformationCacheFilePath), 1382449759); } // Clean legacy file TODO: Remove at some point $legacyPackageStatesPath = FLOW_PATH_CONFIGURATION . 'PackageStates.php'; if (is_file($legacyPackageStatesPath)) { @unlink($legacyPackageStatesPath); } OpcodeCacheHelper::clearAllActive($this->packageInformationCacheFilePath); $this->emitPackageStatesUpdated(); }
php
protected function savePackageStates(array $orderedPackageStates) { $orderedPackageStates['version'] = static::PACKAGESTATE_FORMAT_VERSION; $fileDescription = "# PackageStates.php\n\n"; $fileDescription .= "# This file is maintained by Flow's package management. You shouldn't edit it manually\n"; $fileDescription .= "# manually, you should rather use the command line commands for maintaining packages.\n"; $fileDescription .= "# You'll find detailed information about the neos.flow:package:* commands in their\n"; $fileDescription .= "# respective help screens.\n\n"; $fileDescription .= "# This file will be regenerated automatically if it doesn't exist. Deleting this file\n"; $fileDescription .= "# should, however, never become necessary if you use the package commands.\n"; $packageStatesCode = "<?php\n" . $fileDescription . "\nreturn " . var_export($orderedPackageStates, true) . ';'; Files::createDirectoryRecursively(dirname($this->packageInformationCacheFilePath)); $result = @file_put_contents($this->packageInformationCacheFilePath, $packageStatesCode); if ($result === false) { throw new Exception\PackageStatesFileNotWritableException(sprintf('Flow could not update the list of installed packages because the file %s is not writable. Please, check the file system permissions and make sure that the web server can write to it.', $this->packageInformationCacheFilePath), 1382449759); } // Clean legacy file TODO: Remove at some point $legacyPackageStatesPath = FLOW_PATH_CONFIGURATION . 'PackageStates.php'; if (is_file($legacyPackageStatesPath)) { @unlink($legacyPackageStatesPath); } OpcodeCacheHelper::clearAllActive($this->packageInformationCacheFilePath); $this->emitPackageStatesUpdated(); }
[ "protected", "function", "savePackageStates", "(", "array", "$", "orderedPackageStates", ")", "{", "$", "orderedPackageStates", "[", "'version'", "]", "=", "static", "::", "PACKAGESTATE_FORMAT_VERSION", ";", "$", "fileDescription", "=", "\"# PackageStates.php\\n\\n\"", ...
Save the given (ordered) array of package states data @param array $orderedPackageStates @throws Exception\PackageStatesFileNotWritableException
[ "Save", "the", "given", "(", "ordered", ")", "array", "of", "package", "states", "data" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Package/PackageManager.php#L702-L729
neos/flow-development-collection
Neos.Flow/Classes/Package/PackageManager.php
PackageManager.sortAvailablePackagesByDependencies
protected function sortAvailablePackagesByDependencies(array $packageStates) { $packageOrderResolver = new PackageOrderResolver($packageStates['packages'], $this->collectPackageManifestData($packageStates)); $packageStates['packages'] = $packageOrderResolver->sort(); return $packageStates; }
php
protected function sortAvailablePackagesByDependencies(array $packageStates) { $packageOrderResolver = new PackageOrderResolver($packageStates['packages'], $this->collectPackageManifestData($packageStates)); $packageStates['packages'] = $packageOrderResolver->sort(); return $packageStates; }
[ "protected", "function", "sortAvailablePackagesByDependencies", "(", "array", "$", "packageStates", ")", "{", "$", "packageOrderResolver", "=", "new", "PackageOrderResolver", "(", "$", "packageStates", "[", "'packages'", "]", ",", "$", "this", "->", "collectPackageMan...
Orders all packages by comparing their dependencies. By this, the packages and package configurations arrays holds all packages in the correct initialization order. @param array $packageStates The unordered package states @return array ordered package states.
[ "Orders", "all", "packages", "by", "comparing", "their", "dependencies", ".", "By", "this", "the", "packages", "and", "package", "configurations", "arrays", "holds", "all", "packages", "in", "the", "correct", "initialization", "order", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Package/PackageManager.php#L739-L745
neos/flow-development-collection
Neos.Flow/Classes/Package/PackageManager.php
PackageManager.collectPackageManifestData
protected function collectPackageManifestData(array $packageStates) { return array_map(function ($packageState) { return ComposerUtility::getComposerManifest(Files::getNormalizedPath(Files::concatenatePaths([$this->packagesBasePath, $packageState['packagePath']]))); }, $packageStates['packages']); }
php
protected function collectPackageManifestData(array $packageStates) { return array_map(function ($packageState) { return ComposerUtility::getComposerManifest(Files::getNormalizedPath(Files::concatenatePaths([$this->packagesBasePath, $packageState['packagePath']]))); }, $packageStates['packages']); }
[ "protected", "function", "collectPackageManifestData", "(", "array", "$", "packageStates", ")", "{", "return", "array_map", "(", "function", "(", "$", "packageState", ")", "{", "return", "ComposerUtility", "::", "getComposerManifest", "(", "Files", "::", "getNormali...
Collects the manifest data for all packages in the given package states array @param array $packageStates @return array
[ "Collects", "the", "manifest", "data", "for", "all", "packages", "in", "the", "given", "package", "states", "array" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Package/PackageManager.php#L753-L758
neos/flow-development-collection
Neos.Flow/Classes/Package/PackageManager.php
PackageManager.getCaseSensitivePackageKey
public function getCaseSensitivePackageKey($unknownCasedPackageKey) { $lowerCasedPackageKey = strtolower($unknownCasedPackageKey); return (isset($this->packageKeys[$lowerCasedPackageKey])) ? $this->packageKeys[$lowerCasedPackageKey] : false; }
php
public function getCaseSensitivePackageKey($unknownCasedPackageKey) { $lowerCasedPackageKey = strtolower($unknownCasedPackageKey); return (isset($this->packageKeys[$lowerCasedPackageKey])) ? $this->packageKeys[$lowerCasedPackageKey] : false; }
[ "public", "function", "getCaseSensitivePackageKey", "(", "$", "unknownCasedPackageKey", ")", "{", "$", "lowerCasedPackageKey", "=", "strtolower", "(", "$", "unknownCasedPackageKey", ")", ";", "return", "(", "isset", "(", "$", "this", "->", "packageKeys", "[", "$",...
Returns the correctly cased version of the given package key or false if no such package is available. @param string $unknownCasedPackageKey The package key to convert @return mixed The upper camel cased package key or false if no such package exists @api
[ "Returns", "the", "correctly", "cased", "version", "of", "the", "given", "package", "key", "or", "false", "if", "no", "such", "package", "is", "available", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Package/PackageManager.php#L768-L773
neos/flow-development-collection
Neos.Flow/Classes/Package/PackageManager.php
PackageManager.getPackageKeyFromComposerName
public function getPackageKeyFromComposerName($composerName) { if ($this->composerNameToPackageKeyMap === []) { foreach ($this->packageStatesConfiguration['packages'] as $packageStateConfiguration) { $this->composerNameToPackageKeyMap[$packageStateConfiguration['composerName']] = $packageStateConfiguration['packageKey']; } } $lowercasedComposerName = strtolower($composerName); if (!isset($this->composerNameToPackageKeyMap[$lowercasedComposerName])) { throw new Exception\InvalidPackageStateException('Could not find package with composer name "' . $lowercasedComposerName . '" in PackageStates configuration.', 1352320649); } return $this->composerNameToPackageKeyMap[$lowercasedComposerName]; }
php
public function getPackageKeyFromComposerName($composerName) { if ($this->composerNameToPackageKeyMap === []) { foreach ($this->packageStatesConfiguration['packages'] as $packageStateConfiguration) { $this->composerNameToPackageKeyMap[$packageStateConfiguration['composerName']] = $packageStateConfiguration['packageKey']; } } $lowercasedComposerName = strtolower($composerName); if (!isset($this->composerNameToPackageKeyMap[$lowercasedComposerName])) { throw new Exception\InvalidPackageStateException('Could not find package with composer name "' . $lowercasedComposerName . '" in PackageStates configuration.', 1352320649); } return $this->composerNameToPackageKeyMap[$lowercasedComposerName]; }
[ "public", "function", "getPackageKeyFromComposerName", "(", "$", "composerName", ")", "{", "if", "(", "$", "this", "->", "composerNameToPackageKeyMap", "===", "[", "]", ")", "{", "foreach", "(", "$", "this", "->", "packageStatesConfiguration", "[", "'packages'", ...
Resolves a Flow package key from a composer package name. @param string $composerName @return string @throws Exception\InvalidPackageStateException
[ "Resolves", "a", "Flow", "package", "key", "from", "a", "composer", "package", "name", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Package/PackageManager.php#L782-L796
neos/flow-development-collection
Neos.Flow/Classes/Package/PackageManager.php
PackageManager.getPackageKeyFromManifest
protected function getPackageKeyFromManifest(array $manifest, $packagePath) { if (isset($manifest['extra']['neos']['package-key']) && $this->isPackageKeyValid($manifest['extra']['neos']['package-key'])) { return $manifest['extra']['neos']['package-key']; } $composerName = $manifest['name']; $autoloadNamespace = null; $type = null; if (isset($manifest['autoload']['psr-0']) && is_array($manifest['autoload']['psr-0'])) { $namespaces = array_keys($manifest['autoload']['psr-0']); $autoloadNamespace = reset($namespaces); } if (isset($manifest['type'])) { $type = $manifest['type']; } return $this->derivePackageKey($composerName, $type, $packagePath, $autoloadNamespace); }
php
protected function getPackageKeyFromManifest(array $manifest, $packagePath) { if (isset($manifest['extra']['neos']['package-key']) && $this->isPackageKeyValid($manifest['extra']['neos']['package-key'])) { return $manifest['extra']['neos']['package-key']; } $composerName = $manifest['name']; $autoloadNamespace = null; $type = null; if (isset($manifest['autoload']['psr-0']) && is_array($manifest['autoload']['psr-0'])) { $namespaces = array_keys($manifest['autoload']['psr-0']); $autoloadNamespace = reset($namespaces); } if (isset($manifest['type'])) { $type = $manifest['type']; } return $this->derivePackageKey($composerName, $type, $packagePath, $autoloadNamespace); }
[ "protected", "function", "getPackageKeyFromManifest", "(", "array", "$", "manifest", ",", "$", "packagePath", ")", "{", "if", "(", "isset", "(", "$", "manifest", "[", "'extra'", "]", "[", "'neos'", "]", "[", "'package-key'", "]", ")", "&&", "$", "this", ...
Resolves package key from Composer manifest If it is a Flow package the name of the containing directory will be used. Else if the composer name of the package matches the first part of the lowercased namespace of the package, the mixed case version of the composer name / namespace will be used, with backslashes replaced by dots. Else the composer name will be used with the slash replaced by a dot @param array $manifest @param string $packagePath @return string
[ "Resolves", "package", "key", "from", "Composer", "manifest" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Package/PackageManager.php#L824-L843
neos/flow-development-collection
Neos.Flow/Classes/Package/PackageManager.php
PackageManager.derivePackageKey
protected function derivePackageKey($composerName, $packageType = null, $packagePath = null, $autoloadNamespace = null) { $packageKey = ''; if ($packageType !== null && ComposerUtility::isFlowPackageType($packageType)) { $lastSegmentOfPackagePath = substr(trim($packagePath, '/'), strrpos(trim($packagePath, '/'), '/') + 1); if (strpos($lastSegmentOfPackagePath, '.') !== false) { $packageKey = $lastSegmentOfPackagePath; } } if ($autoloadNamespace !== null && ($packageKey === null || $this->isPackageKeyValid($packageKey) === false)) { $packageKey = str_replace('\\', '.', $autoloadNamespace); } if (($packageKey === null || $this->isPackageKeyValid($packageKey) === false)) { $packageKey = str_replace('/', '.', $composerName); } $packageKey = trim($packageKey, '.'); $packageKey = preg_replace('/[^A-Za-z0-9.]/', '', $packageKey); return $packageKey; }
php
protected function derivePackageKey($composerName, $packageType = null, $packagePath = null, $autoloadNamespace = null) { $packageKey = ''; if ($packageType !== null && ComposerUtility::isFlowPackageType($packageType)) { $lastSegmentOfPackagePath = substr(trim($packagePath, '/'), strrpos(trim($packagePath, '/'), '/') + 1); if (strpos($lastSegmentOfPackagePath, '.') !== false) { $packageKey = $lastSegmentOfPackagePath; } } if ($autoloadNamespace !== null && ($packageKey === null || $this->isPackageKeyValid($packageKey) === false)) { $packageKey = str_replace('\\', '.', $autoloadNamespace); } if (($packageKey === null || $this->isPackageKeyValid($packageKey) === false)) { $packageKey = str_replace('/', '.', $composerName); } $packageKey = trim($packageKey, '.'); $packageKey = preg_replace('/[^A-Za-z0-9.]/', '', $packageKey); return $packageKey; }
[ "protected", "function", "derivePackageKey", "(", "$", "composerName", ",", "$", "packageType", "=", "null", ",", "$", "packagePath", "=", "null", ",", "$", "autoloadNamespace", "=", "null", ")", "{", "$", "packageKey", "=", "''", ";", "if", "(", "$", "p...
Derive a flow package key from the given information. The order of importance is: - package install path - first found autoload namespace - composer name @param string $composerName @param string $packageType @param string $packagePath @param string $autoloadNamespace @return string
[ "Derive", "a", "flow", "package", "key", "from", "the", "given", "information", ".", "The", "order", "of", "importance", "is", ":" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Package/PackageManager.php#L859-L882
neos/flow-development-collection
Neos.Flow/Classes/Package/PackageManager.php
PackageManager.emitPackageStatesUpdated
protected function emitPackageStatesUpdated() { if ($this->bootstrap === null) { return; } if ($this->dispatcher === null) { $this->dispatcher = $this->bootstrap->getEarlyInstance(Dispatcher::class); } $this->dispatcher->dispatch(PackageManager::class, 'packageStatesUpdated'); }
php
protected function emitPackageStatesUpdated() { if ($this->bootstrap === null) { return; } if ($this->dispatcher === null) { $this->dispatcher = $this->bootstrap->getEarlyInstance(Dispatcher::class); } $this->dispatcher->dispatch(PackageManager::class, 'packageStatesUpdated'); }
[ "protected", "function", "emitPackageStatesUpdated", "(", ")", "{", "if", "(", "$", "this", "->", "bootstrap", "===", "null", ")", "{", "return", ";", "}", "if", "(", "$", "this", "->", "dispatcher", "===", "null", ")", "{", "$", "this", "->", "dispatc...
Emits a signal when package states have been changed (e.g. when a package was created) The advice is not proxyable, so the signal is dispatched manually here. @return void @Flow\Signal
[ "Emits", "a", "signal", "when", "package", "states", "have", "been", "changed", "(", "e", ".", "g", ".", "when", "a", "package", "was", "created", ")" ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Package/PackageManager.php#L892-L903
neos/flow-development-collection
Neos.Flow/Classes/Cli/RequestBuilder.php
RequestBuilder.build
public function build($commandLine): Request { $request = new Request(); $request->setControllerObjectName(HelpCommandController::class); if (is_array($commandLine) === true) { $rawCommandLineArguments = $commandLine; } else { preg_match_all(self::ARGUMENT_MATCHING_EXPRESSION, $commandLine, $commandLineMatchings, PREG_SET_ORDER); $rawCommandLineArguments = []; foreach ($commandLineMatchings as $match) { if (isset($match['NoQuotes'])) { $rawCommandLineArguments[] = str_replace(['\ ', '\"', "\\'", '\\\\'], [ ' ', '"', "'", '\\' ], $match['NoQuotes']); } elseif (isset($match['DoubleQuotes'])) { $rawCommandLineArguments[] = str_replace('\\"', '"', $match['DoubleQuotes']); } elseif (isset($match['SingleQuotes'])) { $rawCommandLineArguments[] = str_replace('\\\'', '\'', $match['SingleQuotes']); } else { throw new InvalidArgumentNameException(sprintf('Could not parse the command line "%s" - specifically the part "%s".', $commandLine, $match[0])); } } } if (count($rawCommandLineArguments) === 0) { $request->setControllerCommandName('helpStub'); return $request; } $commandIdentifier = trim(array_shift($rawCommandLineArguments)); try { $command = $this->commandManager->getCommandByIdentifier($commandIdentifier); } catch (CommandException $exception) { $request->setArgument('exception', $exception); $request->setControllerCommandName('error'); return $request; } $controllerObjectName = $this->objectManager->getObjectNameByClassName($command->getControllerClassName()); $controllerCommandName = $command->getControllerCommandName(); $request->setControllerObjectName($controllerObjectName); $request->setControllerCommandName($controllerCommandName); list($commandLineArguments, $exceedingCommandLineArguments) = $this->parseRawCommandLineArguments($rawCommandLineArguments, $controllerObjectName, $controllerCommandName); $request->setArguments($commandLineArguments); $request->setExceedingArguments($exceedingCommandLineArguments); return $request; }
php
public function build($commandLine): Request { $request = new Request(); $request->setControllerObjectName(HelpCommandController::class); if (is_array($commandLine) === true) { $rawCommandLineArguments = $commandLine; } else { preg_match_all(self::ARGUMENT_MATCHING_EXPRESSION, $commandLine, $commandLineMatchings, PREG_SET_ORDER); $rawCommandLineArguments = []; foreach ($commandLineMatchings as $match) { if (isset($match['NoQuotes'])) { $rawCommandLineArguments[] = str_replace(['\ ', '\"', "\\'", '\\\\'], [ ' ', '"', "'", '\\' ], $match['NoQuotes']); } elseif (isset($match['DoubleQuotes'])) { $rawCommandLineArguments[] = str_replace('\\"', '"', $match['DoubleQuotes']); } elseif (isset($match['SingleQuotes'])) { $rawCommandLineArguments[] = str_replace('\\\'', '\'', $match['SingleQuotes']); } else { throw new InvalidArgumentNameException(sprintf('Could not parse the command line "%s" - specifically the part "%s".', $commandLine, $match[0])); } } } if (count($rawCommandLineArguments) === 0) { $request->setControllerCommandName('helpStub'); return $request; } $commandIdentifier = trim(array_shift($rawCommandLineArguments)); try { $command = $this->commandManager->getCommandByIdentifier($commandIdentifier); } catch (CommandException $exception) { $request->setArgument('exception', $exception); $request->setControllerCommandName('error'); return $request; } $controllerObjectName = $this->objectManager->getObjectNameByClassName($command->getControllerClassName()); $controllerCommandName = $command->getControllerCommandName(); $request->setControllerObjectName($controllerObjectName); $request->setControllerCommandName($controllerCommandName); list($commandLineArguments, $exceedingCommandLineArguments) = $this->parseRawCommandLineArguments($rawCommandLineArguments, $controllerObjectName, $controllerCommandName); $request->setArguments($commandLineArguments); $request->setExceedingArguments($exceedingCommandLineArguments); return $request; }
[ "public", "function", "build", "(", "$", "commandLine", ")", ":", "Request", "{", "$", "request", "=", "new", "Request", "(", ")", ";", "$", "request", "->", "setControllerObjectName", "(", "HelpCommandController", "::", "class", ")", ";", "if", "(", "is_a...
Builds a CLI request object from a command line. The given command line may be a string (e.g. "mypackage:foo do-that-thing --force") or an array consisting of the individual parts. The array must not include the script name (like in $argv) but start with command right away. @param mixed $commandLine The command line, either as a string or as an array @return Request The CLI request as an object @throws InvalidArgumentMixingException @throws InvalidArgumentNameException
[ "Builds", "a", "CLI", "request", "object", "from", "a", "command", "line", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Cli/RequestBuilder.php#L116-L167
neos/flow-development-collection
Neos.Flow/Classes/Cli/RequestBuilder.php
RequestBuilder.parseRawCommandLineArguments
protected function parseRawCommandLineArguments(array $rawCommandLineArguments, string $controllerObjectName, string $controllerCommandName): array { $commandLineArguments = []; $exceedingArguments = []; $commandMethodName = $controllerCommandName . 'Command'; $commandMethodParameters = $this->commandManager->getCommandMethodParameters($controllerObjectName, $commandMethodName); $requiredArguments = []; $optionalArguments = []; foreach ($commandMethodParameters as $parameterName => $parameterInfo) { if ($parameterInfo['optional'] === false) { $requiredArguments[strtolower($parameterName)] = [ 'parameterName' => $parameterName, 'type' => $parameterInfo['type'] ]; } else { $optionalArguments[strtolower($parameterName)] = [ 'parameterName' => $parameterName, 'type' => $parameterInfo['type'] ]; } } $decidedToUseNamedArguments = false; $decidedToUseUnnamedArguments = false; while (count($rawCommandLineArguments) > 0) { $rawArgument = array_shift($rawCommandLineArguments); if ($rawArgument !== '' && $rawArgument[0] === '-') { if ($rawArgument[1] === '-') { $rawArgument = substr($rawArgument, 2); } else { $rawArgument = substr($rawArgument, 1); } $argumentName = $this->extractArgumentNameFromCommandLinePart($rawArgument); if (isset($optionalArguments[$argumentName])) { $argumentValue = $this->getValueOfCurrentCommandLineOption($rawArgument, $rawCommandLineArguments, $optionalArguments[$argumentName]['type']); $commandLineArguments[$optionalArguments[$argumentName]['parameterName']] = $argumentValue; } elseif (isset($requiredArguments[$argumentName])) { if ($decidedToUseUnnamedArguments) { throw new InvalidArgumentMixingException(sprintf('Unexpected named argument "%s". If you use unnamed arguments, all required arguments must be passed without a name.', $argumentName), 1309971821); } $decidedToUseNamedArguments = true; $argumentValue = $this->getValueOfCurrentCommandLineOption($rawArgument, $rawCommandLineArguments, $requiredArguments[$argumentName]['type']); $commandLineArguments[$requiredArguments[$argumentName]['parameterName']] = $argumentValue; unset($requiredArguments[$argumentName]); } } else { if (count($requiredArguments) > 0) { if ($decidedToUseNamedArguments) { throw new InvalidArgumentMixingException(sprintf('Unexpected unnamed argument "%s". If you use named arguments, all required arguments must be passed named.', $rawArgument), 1309971820); } $argument = array_shift($requiredArguments); $commandLineArguments[$argument['parameterName']] = $rawArgument; $decidedToUseUnnamedArguments = true; } else { $exceedingArguments[] = $rawArgument; } } } return [$commandLineArguments, $exceedingArguments]; }
php
protected function parseRawCommandLineArguments(array $rawCommandLineArguments, string $controllerObjectName, string $controllerCommandName): array { $commandLineArguments = []; $exceedingArguments = []; $commandMethodName = $controllerCommandName . 'Command'; $commandMethodParameters = $this->commandManager->getCommandMethodParameters($controllerObjectName, $commandMethodName); $requiredArguments = []; $optionalArguments = []; foreach ($commandMethodParameters as $parameterName => $parameterInfo) { if ($parameterInfo['optional'] === false) { $requiredArguments[strtolower($parameterName)] = [ 'parameterName' => $parameterName, 'type' => $parameterInfo['type'] ]; } else { $optionalArguments[strtolower($parameterName)] = [ 'parameterName' => $parameterName, 'type' => $parameterInfo['type'] ]; } } $decidedToUseNamedArguments = false; $decidedToUseUnnamedArguments = false; while (count($rawCommandLineArguments) > 0) { $rawArgument = array_shift($rawCommandLineArguments); if ($rawArgument !== '' && $rawArgument[0] === '-') { if ($rawArgument[1] === '-') { $rawArgument = substr($rawArgument, 2); } else { $rawArgument = substr($rawArgument, 1); } $argumentName = $this->extractArgumentNameFromCommandLinePart($rawArgument); if (isset($optionalArguments[$argumentName])) { $argumentValue = $this->getValueOfCurrentCommandLineOption($rawArgument, $rawCommandLineArguments, $optionalArguments[$argumentName]['type']); $commandLineArguments[$optionalArguments[$argumentName]['parameterName']] = $argumentValue; } elseif (isset($requiredArguments[$argumentName])) { if ($decidedToUseUnnamedArguments) { throw new InvalidArgumentMixingException(sprintf('Unexpected named argument "%s". If you use unnamed arguments, all required arguments must be passed without a name.', $argumentName), 1309971821); } $decidedToUseNamedArguments = true; $argumentValue = $this->getValueOfCurrentCommandLineOption($rawArgument, $rawCommandLineArguments, $requiredArguments[$argumentName]['type']); $commandLineArguments[$requiredArguments[$argumentName]['parameterName']] = $argumentValue; unset($requiredArguments[$argumentName]); } } else { if (count($requiredArguments) > 0) { if ($decidedToUseNamedArguments) { throw new InvalidArgumentMixingException(sprintf('Unexpected unnamed argument "%s". If you use named arguments, all required arguments must be passed named.', $rawArgument), 1309971820); } $argument = array_shift($requiredArguments); $commandLineArguments[$argument['parameterName']] = $rawArgument; $decidedToUseUnnamedArguments = true; } else { $exceedingArguments[] = $rawArgument; } } } return [$commandLineArguments, $exceedingArguments]; }
[ "protected", "function", "parseRawCommandLineArguments", "(", "array", "$", "rawCommandLineArguments", ",", "string", "$", "controllerObjectName", ",", "string", "$", "controllerCommandName", ")", ":", "array", "{", "$", "commandLineArguments", "=", "[", "]", ";", "...
Takes an array of unparsed command line arguments and options and converts it separated by named arguments, options and unnamed arguments. @param array $rawCommandLineArguments The unparsed command parts (such as "--foo") as an array @param string $controllerObjectName Object name of the designated command controller @param string $controllerCommandName Command name of the recognized command (ie. method name without "Command" suffix) @return array All and exceeding command line arguments @throws InvalidArgumentMixingException
[ "Takes", "an", "array", "of", "unparsed", "command", "line", "arguments", "and", "options", "and", "converts", "it", "separated", "by", "named", "arguments", "options", "and", "unnamed", "arguments", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Cli/RequestBuilder.php#L179-L242
neos/flow-development-collection
Neos.Flow/Classes/Cli/RequestBuilder.php
RequestBuilder.extractArgumentNameFromCommandLinePart
protected function extractArgumentNameFromCommandLinePart(string $commandLinePart): string { $nameAndValue = explode('=', $commandLinePart, 2); return strtolower(str_replace('-', '', $nameAndValue[0])); }
php
protected function extractArgumentNameFromCommandLinePart(string $commandLinePart): string { $nameAndValue = explode('=', $commandLinePart, 2); return strtolower(str_replace('-', '', $nameAndValue[0])); }
[ "protected", "function", "extractArgumentNameFromCommandLinePart", "(", "string", "$", "commandLinePart", ")", ":", "string", "{", "$", "nameAndValue", "=", "explode", "(", "'='", ",", "$", "commandLinePart", ",", "2", ")", ";", "return", "strtolower", "(", "str...
Extracts the option or argument name from the name / value pair of a command line. @param string $commandLinePart Part of the command line, e.g. "my-important-option=SomeInterestingValue" @return string The lowercased argument name, e.g. "myimportantoption"
[ "Extracts", "the", "option", "or", "argument", "name", "from", "the", "name", "/", "value", "pair", "of", "a", "command", "line", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Cli/RequestBuilder.php#L250-L255
neos/flow-development-collection
Neos.Flow/Classes/Cli/RequestBuilder.php
RequestBuilder.getValueOfCurrentCommandLineOption
protected function getValueOfCurrentCommandLineOption(string $currentArgument, array &$rawCommandLineArguments, string $expectedArgumentType) { if ((!isset($rawCommandLineArguments[0]) && (strpos($currentArgument, '=') === false)) || (isset($rawCommandLineArguments[0]) && $rawCommandLineArguments[0][0] === '-' && (strpos($currentArgument, '=') === false))) { return true; } if (strpos($currentArgument, '=') === false) { $possibleValue = trim(array_shift($rawCommandLineArguments)); if (strpos($possibleValue, '=') === false) { if ($expectedArgumentType !== 'boolean') { return $possibleValue; } if (array_search($possibleValue, ['on', '1', 'y', 'yes', 'true', 'TRUE']) !== false) { return true; } if (array_search($possibleValue, ['off', '0', 'n', 'no', 'false', 'FALSE']) !== false) { return false; } array_unshift($rawCommandLineArguments, $possibleValue); return true; } $currentArgument .= $possibleValue; } $splitArgument = explode('=', $currentArgument, 2); while ((!isset($splitArgument[1]) || trim($splitArgument[1]) === '') && count($rawCommandLineArguments) > 0) { $currentArgument .= array_shift($rawCommandLineArguments); $splitArgument = explode('=', $currentArgument); } return $splitArgument[1] ?? ''; }
php
protected function getValueOfCurrentCommandLineOption(string $currentArgument, array &$rawCommandLineArguments, string $expectedArgumentType) { if ((!isset($rawCommandLineArguments[0]) && (strpos($currentArgument, '=') === false)) || (isset($rawCommandLineArguments[0]) && $rawCommandLineArguments[0][0] === '-' && (strpos($currentArgument, '=') === false))) { return true; } if (strpos($currentArgument, '=') === false) { $possibleValue = trim(array_shift($rawCommandLineArguments)); if (strpos($possibleValue, '=') === false) { if ($expectedArgumentType !== 'boolean') { return $possibleValue; } if (array_search($possibleValue, ['on', '1', 'y', 'yes', 'true', 'TRUE']) !== false) { return true; } if (array_search($possibleValue, ['off', '0', 'n', 'no', 'false', 'FALSE']) !== false) { return false; } array_unshift($rawCommandLineArguments, $possibleValue); return true; } $currentArgument .= $possibleValue; } $splitArgument = explode('=', $currentArgument, 2); while ((!isset($splitArgument[1]) || trim($splitArgument[1]) === '') && count($rawCommandLineArguments) > 0) { $currentArgument .= array_shift($rawCommandLineArguments); $splitArgument = explode('=', $currentArgument); } return $splitArgument[1] ?? ''; }
[ "protected", "function", "getValueOfCurrentCommandLineOption", "(", "string", "$", "currentArgument", ",", "array", "&", "$", "rawCommandLineArguments", ",", "string", "$", "expectedArgumentType", ")", "{", "if", "(", "(", "!", "isset", "(", "$", "rawCommandLineArgu...
Returns the value of the first argument of the given input array. Shifts the parsed argument off the array. @param string $currentArgument The current argument @param array &$rawCommandLineArguments Array of the remaining command line arguments @param string $expectedArgumentType The expected type of the current argument, because booleans get special attention @return mixed The value of the first argument
[ "Returns", "the", "value", "of", "the", "first", "argument", "of", "the", "given", "input", "array", ".", "Shifts", "the", "parsed", "argument", "off", "the", "array", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Cli/RequestBuilder.php#L265-L297
neos/flow-development-collection
Neos.FluidAdaptor/Classes/Core/ViewHelper/TemplateVariableContainer.php
TemplateVariableContainer.getByPath
public function getByPath($path, array $accessors = []) { $propertyPathSegments = explode('.', $path); $subject = $this->variables; foreach ($propertyPathSegments as $propertyName) { if ($subject === null) { break; } try { $subject = ObjectAccess::getProperty($subject, $propertyName); } catch (PropertyNotAccessibleException $exception) { $subject = null; } if ($subject instanceof TemplateObjectAccessInterface) { $subject = $subject->objectAccess(); } } if ($subject === null) { $subject = $this->getBooleanValue($path); } return $subject; }
php
public function getByPath($path, array $accessors = []) { $propertyPathSegments = explode('.', $path); $subject = $this->variables; foreach ($propertyPathSegments as $propertyName) { if ($subject === null) { break; } try { $subject = ObjectAccess::getProperty($subject, $propertyName); } catch (PropertyNotAccessibleException $exception) { $subject = null; } if ($subject instanceof TemplateObjectAccessInterface) { $subject = $subject->objectAccess(); } } if ($subject === null) { $subject = $this->getBooleanValue($path); } return $subject; }
[ "public", "function", "getByPath", "(", "$", "path", ",", "array", "$", "accessors", "=", "[", "]", ")", "{", "$", "propertyPathSegments", "=", "explode", "(", "'.'", ",", "$", "path", ")", ";", "$", "subject", "=", "$", "this", "->", "variables", ";...
Get a variable by dotted path expression, retrieving the variable from nested arrays/objects one segment at a time. If the second argument is provided, it must be an array of accessor names which can be used to extract each value in the dotted path. @param string $path @param array $accessors @return mixed
[ "Get", "a", "variable", "by", "dotted", "path", "expression", "retrieving", "the", "variable", "from", "nested", "arrays", "/", "objects", "one", "segment", "at", "a", "time", ".", "If", "the", "second", "argument", "is", "provided", "it", "must", "be", "a...
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.FluidAdaptor/Classes/Core/ViewHelper/TemplateVariableContainer.php#L51-L77
neos/flow-development-collection
Neos.FluidAdaptor/Classes/Core/ViewHelper/TemplateVariableContainer.php
TemplateVariableContainer.getBooleanValue
protected function getBooleanValue($path) { $normalizedPath = strtolower($path); if (in_array($normalizedPath, ['true', 'on', 'yes'])) { return true; } if (in_array($normalizedPath, ['false', 'off', 'no'])) { return false; } return null; }
php
protected function getBooleanValue($path) { $normalizedPath = strtolower($path); if (in_array($normalizedPath, ['true', 'on', 'yes'])) { return true; } if (in_array($normalizedPath, ['false', 'off', 'no'])) { return false; } return null; }
[ "protected", "function", "getBooleanValue", "(", "$", "path", ")", "{", "$", "normalizedPath", "=", "strtolower", "(", "$", "path", ")", ";", "if", "(", "in_array", "(", "$", "normalizedPath", ",", "[", "'true'", ",", "'on'", ",", "'yes'", "]", ")", ")...
Tries to interpret the given path as boolean value, either returns the boolean value or null. @param $path @return boolean|null
[ "Tries", "to", "interpret", "the", "given", "path", "as", "boolean", "value", "either", "returns", "the", "boolean", "value", "or", "null", "." ]
train
https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.FluidAdaptor/Classes/Core/ViewHelper/TemplateVariableContainer.php#L85-L98