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.FluidAdaptor/Classes/ViewHelpers/Form/SelectViewHelper.php | SelectViewHelper.getOptionValueScalar | protected function getOptionValueScalar($valueElement)
{
if (is_object($valueElement)) {
if ($this->hasArgument('optionValueField')) {
return ObjectAccess::getPropertyPath($valueElement, $this->arguments['optionValueField']);
} elseif ($this->persistenceManager->getIdentifierByObject($valueElement) !== null) {
return $this->persistenceManager->getIdentifierByObject($valueElement);
} else {
return (string)$valueElement;
}
} else {
return $valueElement;
}
} | php | protected function getOptionValueScalar($valueElement)
{
if (is_object($valueElement)) {
if ($this->hasArgument('optionValueField')) {
return ObjectAccess::getPropertyPath($valueElement, $this->arguments['optionValueField']);
} elseif ($this->persistenceManager->getIdentifierByObject($valueElement) !== null) {
return $this->persistenceManager->getIdentifierByObject($valueElement);
} else {
return (string)$valueElement;
}
} else {
return $valueElement;
}
} | [
"protected",
"function",
"getOptionValueScalar",
"(",
"$",
"valueElement",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"valueElement",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasArgument",
"(",
"'optionValueField'",
")",
")",
"{",
"return",
"ObjectAcce... | Get the option value for an object
@param mixed $valueElement
@return string | [
"Get",
"the",
"option",
"value",
"for",
"an",
"object"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.FluidAdaptor/Classes/ViewHelpers/Form/SelectViewHelper.php#L330-L343 |
neos/flow-development-collection | Neos.FluidAdaptor/Classes/ViewHelpers/Form/SelectViewHelper.php | SelectViewHelper.renderOptionTag | protected function renderOptionTag($value, $label)
{
$output = '<option value="' . htmlspecialchars($value) . '"';
if ($this->isSelected($value)) {
$output .= ' selected="selected"';
}
$output .= '>' . htmlspecialchars($label) . '</option>';
return $output;
} | php | protected function renderOptionTag($value, $label)
{
$output = '<option value="' . htmlspecialchars($value) . '"';
if ($this->isSelected($value)) {
$output .= ' selected="selected"';
}
$output .= '>' . htmlspecialchars($label) . '</option>';
return $output;
} | [
"protected",
"function",
"renderOptionTag",
"(",
"$",
"value",
",",
"$",
"label",
")",
"{",
"$",
"output",
"=",
"'<option value=\"'",
".",
"htmlspecialchars",
"(",
"$",
"value",
")",
".",
"'\"'",
";",
"if",
"(",
"$",
"this",
"->",
"isSelected",
"(",
"$",... | Render one option tag
@param string $value value attribute of the option tag (will be escaped)
@param string $label content of the option tag (will be escaped)
@return string the rendered option tag | [
"Render",
"one",
"option",
"tag"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.FluidAdaptor/Classes/ViewHelpers/Form/SelectViewHelper.php#L352-L362 |
neos/flow-development-collection | Neos.Flow/Classes/Log/Utility/LogEnvironment.php | LogEnvironment.fromMethodName | public static function fromMethodName(string $methodName): array
{
if (strpos($methodName, '::') > 0) {
list($className, $functionName) = explode('::', $methodName);
} elseif (substr($methodName, -9, 9) === '{closure}') {
$className = substr($methodName, 0, -9);
$functionName = '{closure}';
}
return [
'FLOW_LOG_ENVIRONMENT' => [
'packageKey' => self::getPackageKeyFromClassName($className),
'className' => $className,
'methodName' => $functionName
]
];
} | php | public static function fromMethodName(string $methodName): array
{
if (strpos($methodName, '::') > 0) {
list($className, $functionName) = explode('::', $methodName);
} elseif (substr($methodName, -9, 9) === '{closure}') {
$className = substr($methodName, 0, -9);
$functionName = '{closure}';
}
return [
'FLOW_LOG_ENVIRONMENT' => [
'packageKey' => self::getPackageKeyFromClassName($className),
'className' => $className,
'methodName' => $functionName
]
];
} | [
"public",
"static",
"function",
"fromMethodName",
"(",
"string",
"$",
"methodName",
")",
":",
"array",
"{",
"if",
"(",
"strpos",
"(",
"$",
"methodName",
",",
"'::'",
")",
">",
"0",
")",
"{",
"list",
"(",
"$",
"className",
",",
"$",
"functionName",
")",... | Returns an array containing the log environment variables
under the key FLOW_LOG_ENVIRONMENT to be set as part of the additional data
in an log method call.
@param string $methodName
@return array | [
"Returns",
"an",
"array",
"containing",
"the",
"log",
"environment",
"variables",
"under",
"the",
"key",
"FLOW_LOG_ENVIRONMENT",
"to",
"be",
"set",
"as",
"part",
"of",
"the",
"additional",
"data",
"in",
"an",
"log",
"method",
"call",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Log/Utility/LogEnvironment.php#L39-L55 |
neos/flow-development-collection | Neos.Cache/Classes/Backend/FileBackend.php | FileBackend.freeze | public function freeze()
{
if ($this->frozen === true) {
throw new \RuntimeException(sprintf('The cache "%s" is already frozen.', $this->cacheIdentifier), 1323353176);
}
$cacheEntryFileExtensionLength = strlen($this->cacheEntryFileExtension);
for ($directoryIterator = new \DirectoryIterator($this->cacheDirectory); $directoryIterator->valid(); $directoryIterator->next()) {
if ($directoryIterator->isDot()) {
continue;
}
if ($cacheEntryFileExtensionLength > 0) {
$entryIdentifier = substr($directoryIterator->getFilename(), 0, -$cacheEntryFileExtensionLength);
} else {
$entryIdentifier = $directoryIterator->getFilename();
}
$this->cacheEntryIdentifiers[$entryIdentifier] = true;
$cacheEntryPathAndFilename = $this->cacheDirectory . $entryIdentifier . $this->cacheEntryFileExtension;
$this->writeCacheFile($cacheEntryPathAndFilename, $this->internalGet($entryIdentifier, false));
}
$cachePathAndFileName = $this->cacheDirectory . 'FrozenCache.data';
if ($this->useIgBinary === true) {
$data = igbinary_serialize($this->cacheEntryIdentifiers);
} else {
$data = serialize($this->cacheEntryIdentifiers);
}
if ($this->writeCacheFile($cachePathAndFileName, $data) !== false) {
$this->frozen = true;
}
} | php | public function freeze()
{
if ($this->frozen === true) {
throw new \RuntimeException(sprintf('The cache "%s" is already frozen.', $this->cacheIdentifier), 1323353176);
}
$cacheEntryFileExtensionLength = strlen($this->cacheEntryFileExtension);
for ($directoryIterator = new \DirectoryIterator($this->cacheDirectory); $directoryIterator->valid(); $directoryIterator->next()) {
if ($directoryIterator->isDot()) {
continue;
}
if ($cacheEntryFileExtensionLength > 0) {
$entryIdentifier = substr($directoryIterator->getFilename(), 0, -$cacheEntryFileExtensionLength);
} else {
$entryIdentifier = $directoryIterator->getFilename();
}
$this->cacheEntryIdentifiers[$entryIdentifier] = true;
$cacheEntryPathAndFilename = $this->cacheDirectory . $entryIdentifier . $this->cacheEntryFileExtension;
$this->writeCacheFile($cacheEntryPathAndFilename, $this->internalGet($entryIdentifier, false));
}
$cachePathAndFileName = $this->cacheDirectory . 'FrozenCache.data';
if ($this->useIgBinary === true) {
$data = igbinary_serialize($this->cacheEntryIdentifiers);
} else {
$data = serialize($this->cacheEntryIdentifiers);
}
if ($this->writeCacheFile($cachePathAndFileName, $data) !== false) {
$this->frozen = true;
}
} | [
"public",
"function",
"freeze",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"frozen",
"===",
"true",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"'The cache \"%s\" is already frozen.'",
",",
"$",
"this",
"->",
"cacheIdentifier",
... | Freezes this cache backend.
All data in a frozen backend remains unchanged and methods which try to add
or modify data result in an exception thrown. Possible expiry times of
individual cache entries are ignored.
On the positive side, a frozen cache backend is much faster on read access.
A frozen backend can only be thawed by calling the flush() method.
@return void
@throws \RuntimeException | [
"Freezes",
"this",
"cache",
"backend",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Cache/Classes/Backend/FileBackend.php#L63-L95 |
neos/flow-development-collection | Neos.Cache/Classes/Backend/FileBackend.php | FileBackend.setCache | public function setCache(FrontendInterface $cache)
{
parent::setCache($cache);
if (is_file($this->cacheDirectory . 'FrozenCache.data')) {
$this->frozen = true;
$cachePathAndFileName = $this->cacheDirectory . 'FrozenCache.data';
$data = $this->readCacheFile($cachePathAndFileName);
if ($this->useIgBinary === true) {
$this->cacheEntryIdentifiers = igbinary_unserialize($data);
} else {
$this->cacheEntryIdentifiers = unserialize($data);
}
}
} | php | public function setCache(FrontendInterface $cache)
{
parent::setCache($cache);
if (is_file($this->cacheDirectory . 'FrozenCache.data')) {
$this->frozen = true;
$cachePathAndFileName = $this->cacheDirectory . 'FrozenCache.data';
$data = $this->readCacheFile($cachePathAndFileName);
if ($this->useIgBinary === true) {
$this->cacheEntryIdentifiers = igbinary_unserialize($data);
} else {
$this->cacheEntryIdentifiers = unserialize($data);
}
}
} | [
"public",
"function",
"setCache",
"(",
"FrontendInterface",
"$",
"cache",
")",
"{",
"parent",
"::",
"setCache",
"(",
"$",
"cache",
")",
";",
"if",
"(",
"is_file",
"(",
"$",
"this",
"->",
"cacheDirectory",
".",
"'FrozenCache.data'",
")",
")",
"{",
"$",
"t... | Sets a reference to the cache frontend which uses this backend and
initializes the default cache directory.
This method also detects if this backend is frozen and sets the internal
flag accordingly.
@param FrontendInterface $cache The cache frontend
@return void
@throws Exception | [
"Sets",
"a",
"reference",
"to",
"the",
"cache",
"frontend",
"which",
"uses",
"this",
"backend",
"and",
"initializes",
"the",
"default",
"cache",
"directory",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Cache/Classes/Backend/FileBackend.php#L118-L132 |
neos/flow-development-collection | Neos.Cache/Classes/Backend/FileBackend.php | FileBackend.set | public function set(string $entryIdentifier, string $data, array $tags = [], int $lifetime = null)
{
if ($entryIdentifier !== basename($entryIdentifier)) {
throw new \InvalidArgumentException('The specified entry identifier must not contain a path segment.', 1282073032);
}
if ($entryIdentifier === '') {
throw new \InvalidArgumentException('The specified entry identifier must not be empty.', 1298114280);
}
if ($this->frozen === true) {
throw new \RuntimeException(sprintf('Cannot add or modify cache entry because the backend of cache "%s" is frozen.', $this->cacheIdentifier), 1323344192);
}
$cacheEntryPathAndFilename = $this->cacheDirectory . $entryIdentifier . $this->cacheEntryFileExtension;
$lifetime = $lifetime === null ? $this->defaultLifetime : $lifetime;
$expiryTime = ($lifetime === 0) ? 0 : (time() + $lifetime);
$metaData = implode(' ', $tags) . str_pad($expiryTime, self::EXPIRYTIME_LENGTH) . str_pad(strlen($data), self::DATASIZE_DIGITS);
$result = $this->writeCacheFile($cacheEntryPathAndFilename, $data . $metaData);
if ($result !== false) {
if ($this->cacheEntryFileExtension === '.php') {
OpcodeCacheHelper::clearAllActive($cacheEntryPathAndFilename);
}
return;
}
$this->throwExceptionIfPathExceedsMaximumLength($cacheEntryPathAndFilename);
throw new Exception('The cache file "' . $cacheEntryPathAndFilename . '" could not be written.', 1222361632);
} | php | public function set(string $entryIdentifier, string $data, array $tags = [], int $lifetime = null)
{
if ($entryIdentifier !== basename($entryIdentifier)) {
throw new \InvalidArgumentException('The specified entry identifier must not contain a path segment.', 1282073032);
}
if ($entryIdentifier === '') {
throw new \InvalidArgumentException('The specified entry identifier must not be empty.', 1298114280);
}
if ($this->frozen === true) {
throw new \RuntimeException(sprintf('Cannot add or modify cache entry because the backend of cache "%s" is frozen.', $this->cacheIdentifier), 1323344192);
}
$cacheEntryPathAndFilename = $this->cacheDirectory . $entryIdentifier . $this->cacheEntryFileExtension;
$lifetime = $lifetime === null ? $this->defaultLifetime : $lifetime;
$expiryTime = ($lifetime === 0) ? 0 : (time() + $lifetime);
$metaData = implode(' ', $tags) . str_pad($expiryTime, self::EXPIRYTIME_LENGTH) . str_pad(strlen($data), self::DATASIZE_DIGITS);
$result = $this->writeCacheFile($cacheEntryPathAndFilename, $data . $metaData);
if ($result !== false) {
if ($this->cacheEntryFileExtension === '.php') {
OpcodeCacheHelper::clearAllActive($cacheEntryPathAndFilename);
}
return;
}
$this->throwExceptionIfPathExceedsMaximumLength($cacheEntryPathAndFilename);
throw new Exception('The cache file "' . $cacheEntryPathAndFilename . '" could not be written.', 1222361632);
} | [
"public",
"function",
"set",
"(",
"string",
"$",
"entryIdentifier",
",",
"string",
"$",
"data",
",",
"array",
"$",
"tags",
"=",
"[",
"]",
",",
"int",
"$",
"lifetime",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"entryIdentifier",
"!==",
"basename",
"(",
"... | Saves data in a cache file.
@param string $entryIdentifier An identifier for this specific cache entry
@param string $data The data to be stored
@param array $tags Tags to associate with this cache entry
@param integer $lifetime Lifetime of this cache entry in seconds. If NULL is specified, the default lifetime is used. "0" means unlimited lifetime.
@return void
@throws \RuntimeException
@throws Exception if the directory does not exist or is not writable or exceeds the maximum allowed path length, or if no cache frontend has been set.
@throws \InvalidArgumentException
@api | [
"Saves",
"data",
"in",
"a",
"cache",
"file",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Cache/Classes/Backend/FileBackend.php#L147-L174 |
neos/flow-development-collection | Neos.Cache/Classes/Backend/FileBackend.php | FileBackend.has | public function has(string $entryIdentifier): bool
{
if ($this->frozen === true) {
return isset($this->cacheEntryIdentifiers[$entryIdentifier]);
}
if ($entryIdentifier !== basename($entryIdentifier)) {
throw new \InvalidArgumentException('The specified entry identifier must not contain a path segment.', 1282073034);
}
return !$this->isCacheFileExpired($this->cacheDirectory . $entryIdentifier . $this->cacheEntryFileExtension);
} | php | public function has(string $entryIdentifier): bool
{
if ($this->frozen === true) {
return isset($this->cacheEntryIdentifiers[$entryIdentifier]);
}
if ($entryIdentifier !== basename($entryIdentifier)) {
throw new \InvalidArgumentException('The specified entry identifier must not contain a path segment.', 1282073034);
}
return !$this->isCacheFileExpired($this->cacheDirectory . $entryIdentifier . $this->cacheEntryFileExtension);
} | [
"public",
"function",
"has",
"(",
"string",
"$",
"entryIdentifier",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"this",
"->",
"frozen",
"===",
"true",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"cacheEntryIdentifiers",
"[",
"$",
"entryIdentifier",
"... | Checks if a cache entry with the specified identifier exists.
@param string $entryIdentifier
@return boolean true if such an entry exists, false if not
@throws \InvalidArgumentException
@api | [
"Checks",
"if",
"a",
"cache",
"entry",
"with",
"the",
"specified",
"identifier",
"exists",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Cache/Classes/Backend/FileBackend.php#L197-L206 |
neos/flow-development-collection | Neos.Cache/Classes/Backend/FileBackend.php | FileBackend.remove | public function remove(string $entryIdentifier): bool
{
if ($this->frozen === true) {
throw new \RuntimeException(sprintf('Cannot remove cache entry because the backend of cache "%s" is frozen.', $this->cacheIdentifier), 1323344193);
}
return parent::remove($entryIdentifier);
} | php | public function remove(string $entryIdentifier): bool
{
if ($this->frozen === true) {
throw new \RuntimeException(sprintf('Cannot remove cache entry because the backend of cache "%s" is frozen.', $this->cacheIdentifier), 1323344193);
}
return parent::remove($entryIdentifier);
} | [
"public",
"function",
"remove",
"(",
"string",
"$",
"entryIdentifier",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"this",
"->",
"frozen",
"===",
"true",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"'Cannot remove cache entry because th... | Removes all cache entries matching the specified identifier.
Usually this only affects one entry.
@param string $entryIdentifier Specifies the cache entry to remove
@return boolean true if (at least) an entry could be removed or false if no entry was found
@throws \RuntimeException
@throws \InvalidArgumentException
@api | [
"Removes",
"all",
"cache",
"entries",
"matching",
"the",
"specified",
"identifier",
".",
"Usually",
"this",
"only",
"affects",
"one",
"entry",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Cache/Classes/Backend/FileBackend.php#L218-L225 |
neos/flow-development-collection | Neos.Cache/Classes/Backend/FileBackend.php | FileBackend.findIdentifiersByTag | public function findIdentifiersByTag(string $searchedTag): array
{
$entryIdentifiers = [];
$now = $_SERVER['REQUEST_TIME'];
$cacheEntryFileExtensionLength = strlen($this->cacheEntryFileExtension);
for ($directoryIterator = new \DirectoryIterator($this->cacheDirectory); $directoryIterator->valid(); $directoryIterator->next()) {
if ($directoryIterator->isDot()) {
continue;
}
$cacheEntryPathAndFilename = $directoryIterator->getPathname();
$fileSize = filesize($cacheEntryPathAndFilename);
$index = (integer)$this->readCacheFile($cacheEntryPathAndFilename, $fileSize - self::DATASIZE_DIGITS, self::DATASIZE_DIGITS);
$metaData = $this->readCacheFile($cacheEntryPathAndFilename, $index, $fileSize - $index - self::DATASIZE_DIGITS);
$expiryTime = (integer)substr($metaData, -self::EXPIRYTIME_LENGTH, self::EXPIRYTIME_LENGTH);
if ($expiryTime !== 0 && $expiryTime < $now) {
continue;
}
if (!in_array($searchedTag, explode(' ', substr($metaData, 0, -self::EXPIRYTIME_LENGTH)))) {
continue;
}
if ($cacheEntryFileExtensionLength > 0) {
$entryIdentifiers[] = substr($directoryIterator->getFilename(), 0, -$cacheEntryFileExtensionLength);
} else {
$entryIdentifiers[] = $directoryIterator->getFilename();
}
}
return $entryIdentifiers;
} | php | public function findIdentifiersByTag(string $searchedTag): array
{
$entryIdentifiers = [];
$now = $_SERVER['REQUEST_TIME'];
$cacheEntryFileExtensionLength = strlen($this->cacheEntryFileExtension);
for ($directoryIterator = new \DirectoryIterator($this->cacheDirectory); $directoryIterator->valid(); $directoryIterator->next()) {
if ($directoryIterator->isDot()) {
continue;
}
$cacheEntryPathAndFilename = $directoryIterator->getPathname();
$fileSize = filesize($cacheEntryPathAndFilename);
$index = (integer)$this->readCacheFile($cacheEntryPathAndFilename, $fileSize - self::DATASIZE_DIGITS, self::DATASIZE_DIGITS);
$metaData = $this->readCacheFile($cacheEntryPathAndFilename, $index, $fileSize - $index - self::DATASIZE_DIGITS);
$expiryTime = (integer)substr($metaData, -self::EXPIRYTIME_LENGTH, self::EXPIRYTIME_LENGTH);
if ($expiryTime !== 0 && $expiryTime < $now) {
continue;
}
if (!in_array($searchedTag, explode(' ', substr($metaData, 0, -self::EXPIRYTIME_LENGTH)))) {
continue;
}
if ($cacheEntryFileExtensionLength > 0) {
$entryIdentifiers[] = substr($directoryIterator->getFilename(), 0, -$cacheEntryFileExtensionLength);
} else {
$entryIdentifiers[] = $directoryIterator->getFilename();
}
}
return $entryIdentifiers;
} | [
"public",
"function",
"findIdentifiersByTag",
"(",
"string",
"$",
"searchedTag",
")",
":",
"array",
"{",
"$",
"entryIdentifiers",
"=",
"[",
"]",
";",
"$",
"now",
"=",
"$",
"_SERVER",
"[",
"'REQUEST_TIME'",
"]",
";",
"$",
"cacheEntryFileExtensionLength",
"=",
... | Finds and returns all cache entry identifiers which are tagged by the
specified tag.
@param string $searchedTag The tag to search for
@return array An array with identifiers of all matching entries. An empty array if no entries matched
@api | [
"Finds",
"and",
"returns",
"all",
"cache",
"entry",
"identifiers",
"which",
"are",
"tagged",
"by",
"the",
"specified",
"tag",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Cache/Classes/Backend/FileBackend.php#L235-L264 |
neos/flow-development-collection | Neos.Cache/Classes/Backend/FileBackend.php | FileBackend.flush | public function flush()
{
Files::emptyDirectoryRecursively($this->cacheDirectory);
if ($this->frozen === true) {
@unlink($this->cacheDirectory . 'FrozenCache.data');
$this->frozen = false;
}
} | php | public function flush()
{
Files::emptyDirectoryRecursively($this->cacheDirectory);
if ($this->frozen === true) {
@unlink($this->cacheDirectory . 'FrozenCache.data');
$this->frozen = false;
}
} | [
"public",
"function",
"flush",
"(",
")",
"{",
"Files",
"::",
"emptyDirectoryRecursively",
"(",
"$",
"this",
"->",
"cacheDirectory",
")",
";",
"if",
"(",
"$",
"this",
"->",
"frozen",
"===",
"true",
")",
"{",
"@",
"unlink",
"(",
"$",
"this",
"->",
"cache... | Removes all cache entries of this cache and sets the frozen flag to false.
@return void
@api
@throws \Neos\Utility\Exception\FilesException | [
"Removes",
"all",
"cache",
"entries",
"of",
"this",
"cache",
"and",
"sets",
"the",
"frozen",
"flag",
"to",
"false",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Cache/Classes/Backend/FileBackend.php#L273-L280 |
neos/flow-development-collection | Neos.Cache/Classes/Backend/FileBackend.php | FileBackend.flushByTag | public function flushByTag(string $tag): int
{
$identifiers = $this->findIdentifiersByTag($tag);
if (count($identifiers) === 0) {
return 0;
}
foreach ($identifiers as $entryIdentifier) {
$this->remove($entryIdentifier);
}
return count($identifiers);
} | php | public function flushByTag(string $tag): int
{
$identifiers = $this->findIdentifiersByTag($tag);
if (count($identifiers) === 0) {
return 0;
}
foreach ($identifiers as $entryIdentifier) {
$this->remove($entryIdentifier);
}
return count($identifiers);
} | [
"public",
"function",
"flushByTag",
"(",
"string",
"$",
"tag",
")",
":",
"int",
"{",
"$",
"identifiers",
"=",
"$",
"this",
"->",
"findIdentifiersByTag",
"(",
"$",
"tag",
")",
";",
"if",
"(",
"count",
"(",
"$",
"identifiers",
")",
"===",
"0",
")",
"{"... | Removes all cache entries of this cache which are tagged by the specified tag.
@param string $tag The tag the entries must have
@return integer The number of entries which have been affected by this flush
@api | [
"Removes",
"all",
"cache",
"entries",
"of",
"this",
"cache",
"which",
"are",
"tagged",
"by",
"the",
"specified",
"tag",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Cache/Classes/Backend/FileBackend.php#L289-L300 |
neos/flow-development-collection | Neos.Cache/Classes/Backend/FileBackend.php | FileBackend.isCacheFileExpired | protected function isCacheFileExpired(string $cacheEntryPathAndFilename, bool $acquireLock = true): bool
{
if (is_file($cacheEntryPathAndFilename) === false) {
return true;
}
$expiryTimeOffset = filesize($cacheEntryPathAndFilename) - self::DATASIZE_DIGITS - self::EXPIRYTIME_LENGTH;
if ($acquireLock) {
$expiryTime = (integer)$this->readCacheFile($cacheEntryPathAndFilename, $expiryTimeOffset, self::EXPIRYTIME_LENGTH);
} else {
$expiryTime = (integer)file_get_contents($cacheEntryPathAndFilename, null, null, $expiryTimeOffset, self::EXPIRYTIME_LENGTH);
}
return ($expiryTime !== 0 && $expiryTime < time());
} | php | protected function isCacheFileExpired(string $cacheEntryPathAndFilename, bool $acquireLock = true): bool
{
if (is_file($cacheEntryPathAndFilename) === false) {
return true;
}
$expiryTimeOffset = filesize($cacheEntryPathAndFilename) - self::DATASIZE_DIGITS - self::EXPIRYTIME_LENGTH;
if ($acquireLock) {
$expiryTime = (integer)$this->readCacheFile($cacheEntryPathAndFilename, $expiryTimeOffset, self::EXPIRYTIME_LENGTH);
} else {
$expiryTime = (integer)file_get_contents($cacheEntryPathAndFilename, null, null, $expiryTimeOffset, self::EXPIRYTIME_LENGTH);
}
return ($expiryTime !== 0 && $expiryTime < time());
} | [
"protected",
"function",
"isCacheFileExpired",
"(",
"string",
"$",
"cacheEntryPathAndFilename",
",",
"bool",
"$",
"acquireLock",
"=",
"true",
")",
":",
"bool",
"{",
"if",
"(",
"is_file",
"(",
"$",
"cacheEntryPathAndFilename",
")",
"===",
"false",
")",
"{",
"re... | Checks if the given cache entry files are still valid or if their
lifetime has exceeded.
@param string $cacheEntryPathAndFilename
@param boolean $acquireLock
@return boolean
@api | [
"Checks",
"if",
"the",
"given",
"cache",
"entry",
"files",
"are",
"still",
"valid",
"or",
"if",
"their",
"lifetime",
"has",
"exceeded",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Cache/Classes/Backend/FileBackend.php#L311-L325 |
neos/flow-development-collection | Neos.Cache/Classes/Backend/FileBackend.php | FileBackend.collectGarbage | public function collectGarbage()
{
if ($this->frozen === true) {
return;
}
for ($directoryIterator = new \DirectoryIterator($this->cacheDirectory); $directoryIterator->valid(); $directoryIterator->next()) {
if ($directoryIterator->isDot()) {
continue;
}
if ($this->isCacheFileExpired($directoryIterator->getPathname())) {
$this->remove($directoryIterator->getBasename($this->cacheEntryFileExtension));
}
}
} | php | public function collectGarbage()
{
if ($this->frozen === true) {
return;
}
for ($directoryIterator = new \DirectoryIterator($this->cacheDirectory); $directoryIterator->valid(); $directoryIterator->next()) {
if ($directoryIterator->isDot()) {
continue;
}
if ($this->isCacheFileExpired($directoryIterator->getPathname())) {
$this->remove($directoryIterator->getBasename($this->cacheEntryFileExtension));
}
}
} | [
"public",
"function",
"collectGarbage",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"frozen",
"===",
"true",
")",
"{",
"return",
";",
"}",
"for",
"(",
"$",
"directoryIterator",
"=",
"new",
"\\",
"DirectoryIterator",
"(",
"$",
"this",
"->",
"cacheDirecto... | Does garbage collection
@return void
@api | [
"Does",
"garbage",
"collection"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Cache/Classes/Backend/FileBackend.php#L333-L348 |
neos/flow-development-collection | Neos.Cache/Classes/Backend/FileBackend.php | FileBackend.findCacheFilesByIdentifier | protected function findCacheFilesByIdentifier(string $entryIdentifier)
{
$pattern = $this->cacheDirectory . $entryIdentifier;
$filesFound = glob($pattern);
if ($filesFound === false || count($filesFound) === 0) {
return false;
}
return $filesFound;
} | php | protected function findCacheFilesByIdentifier(string $entryIdentifier)
{
$pattern = $this->cacheDirectory . $entryIdentifier;
$filesFound = glob($pattern);
if ($filesFound === false || count($filesFound) === 0) {
return false;
}
return $filesFound;
} | [
"protected",
"function",
"findCacheFilesByIdentifier",
"(",
"string",
"$",
"entryIdentifier",
")",
"{",
"$",
"pattern",
"=",
"$",
"this",
"->",
"cacheDirectory",
".",
"$",
"entryIdentifier",
";",
"$",
"filesFound",
"=",
"glob",
"(",
"$",
"pattern",
")",
";",
... | Tries to find the cache entry for the specified identifier.
Usually only one cache entry should be found - if more than one exist, this
is due to some error or crash.
@param string $entryIdentifier The cache entry identifier
@return mixed The filenames (including path) as an array if one or more entries could be found, otherwise false | [
"Tries",
"to",
"find",
"the",
"cache",
"entry",
"for",
"the",
"specified",
"identifier",
".",
"Usually",
"only",
"one",
"cache",
"entry",
"should",
"be",
"found",
"-",
"if",
"more",
"than",
"one",
"exist",
"this",
"is",
"due",
"to",
"some",
"error",
"or"... | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Cache/Classes/Backend/FileBackend.php#L358-L366 |
neos/flow-development-collection | Neos.Cache/Classes/Backend/FileBackend.php | FileBackend.requireOnce | public function requireOnce(string $entryIdentifier)
{
if ($this->frozen === true) {
if (isset($this->cacheEntryIdentifiers[$entryIdentifier])) {
return require_once($this->cacheDirectory . $entryIdentifier . $this->cacheEntryFileExtension);
}
return false;
}
$pathAndFilename = $this->cacheDirectory . $entryIdentifier . $this->cacheEntryFileExtension;
if ($entryIdentifier !== basename($entryIdentifier)) {
throw new \InvalidArgumentException('The specified entry identifier (' . $entryIdentifier . ') must not contain a path segment.', 1282073036);
}
return ($this->isCacheFileExpired($pathAndFilename)) ? false : require_once($pathAndFilename);
} | php | public function requireOnce(string $entryIdentifier)
{
if ($this->frozen === true) {
if (isset($this->cacheEntryIdentifiers[$entryIdentifier])) {
return require_once($this->cacheDirectory . $entryIdentifier . $this->cacheEntryFileExtension);
}
return false;
}
$pathAndFilename = $this->cacheDirectory . $entryIdentifier . $this->cacheEntryFileExtension;
if ($entryIdentifier !== basename($entryIdentifier)) {
throw new \InvalidArgumentException('The specified entry identifier (' . $entryIdentifier . ') must not contain a path segment.', 1282073036);
}
return ($this->isCacheFileExpired($pathAndFilename)) ? false : require_once($pathAndFilename);
} | [
"public",
"function",
"requireOnce",
"(",
"string",
"$",
"entryIdentifier",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"frozen",
"===",
"true",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"cacheEntryIdentifiers",
"[",
"$",
"entryIdentifier",
"]",
... | Loads PHP code from the cache and require_onces it right away.
@param string $entryIdentifier An identifier which describes the cache entry to load
@throws \InvalidArgumentException
@return mixed Potential return value from the include operation
@api | [
"Loads",
"PHP",
"code",
"from",
"the",
"cache",
"and",
"require_onces",
"it",
"right",
"away",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Cache/Classes/Backend/FileBackend.php#L376-L390 |
neos/flow-development-collection | Neos.Cache/Classes/Backend/FileBackend.php | FileBackend.internalGet | protected function internalGet(string $entryIdentifier, bool $acquireLock = true)
{
if ($entryIdentifier !== basename($entryIdentifier)) {
throw new \InvalidArgumentException('The specified entry identifier must not contain a path segment.', 1282073033);
}
$pathAndFilename = $this->cacheDirectory . $entryIdentifier . $this->cacheEntryFileExtension;
if ($this->frozen === true) {
$result = false;
if (isset($this->cacheEntryIdentifiers[$entryIdentifier])) {
if ($acquireLock) {
$result = $this->readCacheFile($pathAndFilename);
} else {
$result = file_get_contents($pathAndFilename);
}
}
return $result;
}
if ($this->isCacheFileExpired($pathAndFilename, $acquireLock)) {
return false;
}
$cacheData = null;
if ($acquireLock) {
$cacheData = $this->readCacheFile($pathAndFilename);
} else {
$cacheData = file_get_contents($pathAndFilename);
}
$dataSize = (integer)substr($cacheData, -(self::DATASIZE_DIGITS));
return substr($cacheData, 0, $dataSize);
} | php | protected function internalGet(string $entryIdentifier, bool $acquireLock = true)
{
if ($entryIdentifier !== basename($entryIdentifier)) {
throw new \InvalidArgumentException('The specified entry identifier must not contain a path segment.', 1282073033);
}
$pathAndFilename = $this->cacheDirectory . $entryIdentifier . $this->cacheEntryFileExtension;
if ($this->frozen === true) {
$result = false;
if (isset($this->cacheEntryIdentifiers[$entryIdentifier])) {
if ($acquireLock) {
$result = $this->readCacheFile($pathAndFilename);
} else {
$result = file_get_contents($pathAndFilename);
}
}
return $result;
}
if ($this->isCacheFileExpired($pathAndFilename, $acquireLock)) {
return false;
}
$cacheData = null;
if ($acquireLock) {
$cacheData = $this->readCacheFile($pathAndFilename);
} else {
$cacheData = file_get_contents($pathAndFilename);
}
$dataSize = (integer)substr($cacheData, -(self::DATASIZE_DIGITS));
return substr($cacheData, 0, $dataSize);
} | [
"protected",
"function",
"internalGet",
"(",
"string",
"$",
"entryIdentifier",
",",
"bool",
"$",
"acquireLock",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"entryIdentifier",
"!==",
"basename",
"(",
"$",
"entryIdentifier",
")",
")",
"{",
"throw",
"new",
"\\",
"... | Internal get method, allows to nest locks by using the $acquireLock flag
@param string $entryIdentifier
@param boolean $acquireLock
@return bool|string
@throws \InvalidArgumentException | [
"Internal",
"get",
"method",
"allows",
"to",
"nest",
"locks",
"by",
"using",
"the",
"$acquireLock",
"flag"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Cache/Classes/Backend/FileBackend.php#L400-L434 |
neos/flow-development-collection | Neos.Flow/Classes/Reflection/PropertyReflection.php | PropertyReflection.getValue | public function getValue($object = null)
{
if (!is_object($object)) {
throw new Exception('$object is of type ' . gettype($object) . ', instance of class ' . $this->class . ' expected.', 1210859212);
}
if ($this->isPublic()) {
return parent::getValue($object);
}
parent::setAccessible(true);
return parent::getValue($object);
} | php | public function getValue($object = null)
{
if (!is_object($object)) {
throw new Exception('$object is of type ' . gettype($object) . ', instance of class ' . $this->class . ' expected.', 1210859212);
}
if ($this->isPublic()) {
return parent::getValue($object);
}
parent::setAccessible(true);
return parent::getValue($object);
} | [
"public",
"function",
"getValue",
"(",
"$",
"object",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_object",
"(",
"$",
"object",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'$object is of type '",
".",
"gettype",
"(",
"$",
"object",
")",
".",
"', in... | Returns the value of the reflected property - even if it is protected.
@param object $object Instance of the declaring class to read the value from
@return mixed Value of the property
@throws Exception | [
"Returns",
"the",
"value",
"of",
"the",
"reflected",
"property",
"-",
"even",
"if",
"it",
"is",
"protected",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Reflection/PropertyReflection.php#L96-L107 |
neos/flow-development-collection | Neos.Flow/Classes/Reflection/PropertyReflection.php | PropertyReflection.setValue | public function setValue($object = null, $value = null)
{
if (!is_object($object)) {
throw new Exception('$object is of type ' . gettype($object) . ', instance of class ' . $this->class . ' expected.', 1210859212);
}
if ($this->isPublic()) {
parent::setValue($object, $value);
} else {
parent::setAccessible(true);
parent::setValue($object, $value);
}
} | php | public function setValue($object = null, $value = null)
{
if (!is_object($object)) {
throw new Exception('$object is of type ' . gettype($object) . ', instance of class ' . $this->class . ' expected.', 1210859212);
}
if ($this->isPublic()) {
parent::setValue($object, $value);
} else {
parent::setAccessible(true);
parent::setValue($object, $value);
}
} | [
"public",
"function",
"setValue",
"(",
"$",
"object",
"=",
"null",
",",
"$",
"value",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_object",
"(",
"$",
"object",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'$object is of type '",
".",
"gettype",
"(",... | Returns the value of the reflected property - even if it is protected.
@param object $object Instance of the declaring class to set the value on
@param mixed $value The value to set on the property
@return void
@throws Exception | [
"Returns",
"the",
"value",
"of",
"the",
"reflected",
"property",
"-",
"even",
"if",
"it",
"is",
"protected",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Reflection/PropertyReflection.php#L117-L129 |
neos/flow-development-collection | Neos.Flow/Classes/Log/PsrLoggerFactory.php | PsrLoggerFactory.get | public function get(string $identifier): \Psr\Log\LoggerInterface
{
if (isset($this->instances[$identifier])) {
return $this->instances[$identifier];
}
if (!isset($this->configuration[$identifier])) {
throw new \InvalidArgumentException(sprintf('The given log identifier "%s" was not configured for the "%s" factory.', htmlspecialchars($identifier), self::class), 1515355505545);
}
if (!class_exists(Logger::class)) {
throw new \Exception('To use the default logging you have to have the "neos/flow-log" package installed. It seems you miss it, so install it via "composer require neos/flow-log".', 1515437383589);
}
$backends = $this->instantiateBackends($this->configuration[$identifier]);
$logger = new Logger($backends);
$this->instances[$identifier] = $logger;
return $logger;
} | php | public function get(string $identifier): \Psr\Log\LoggerInterface
{
if (isset($this->instances[$identifier])) {
return $this->instances[$identifier];
}
if (!isset($this->configuration[$identifier])) {
throw new \InvalidArgumentException(sprintf('The given log identifier "%s" was not configured for the "%s" factory.', htmlspecialchars($identifier), self::class), 1515355505545);
}
if (!class_exists(Logger::class)) {
throw new \Exception('To use the default logging you have to have the "neos/flow-log" package installed. It seems you miss it, so install it via "composer require neos/flow-log".', 1515437383589);
}
$backends = $this->instantiateBackends($this->configuration[$identifier]);
$logger = new Logger($backends);
$this->instances[$identifier] = $logger;
return $logger;
} | [
"public",
"function",
"get",
"(",
"string",
"$",
"identifier",
")",
":",
"\\",
"Psr",
"\\",
"Log",
"\\",
"LoggerInterface",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"instances",
"[",
"$",
"identifier",
"]",
")",
")",
"{",
"return",
"$",
"this... | Get the logger configured with given identifier.
This implementation treats the logger as singleton.
@param string $identifier
@return \Psr\Log\LoggerInterface
@throws \Exception | [
"Get",
"the",
"logger",
"configured",
"with",
"given",
"identifier",
".",
"This",
"implementation",
"treats",
"the",
"logger",
"as",
"singleton",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Log/PsrLoggerFactory.php#L46-L65 |
neos/flow-development-collection | Neos.Flow/Classes/Log/PsrLoggerFactory.php | PsrLoggerFactory.instantiateBackends | protected function instantiateBackends(array $configuration)
{
$backends = [];
foreach ($configuration as $backendConfiguration) {
$class = $backendConfiguration['class'] ?? '';
$options = $backendConfiguration['options'] ?? [];
$backends[] = $this->instantiateBackend($class, $options);
}
return $backends;
} | php | protected function instantiateBackends(array $configuration)
{
$backends = [];
foreach ($configuration as $backendConfiguration) {
$class = $backendConfiguration['class'] ?? '';
$options = $backendConfiguration['options'] ?? [];
$backends[] = $this->instantiateBackend($class, $options);
}
return $backends;
} | [
"protected",
"function",
"instantiateBackends",
"(",
"array",
"$",
"configuration",
")",
"{",
"$",
"backends",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"configuration",
"as",
"$",
"backendConfiguration",
")",
"{",
"$",
"class",
"=",
"$",
"backendConfiguration"... | Instantiate all configured backends
@param array $configuration
@return BackendInterface[]
@throws \Exception | [
"Instantiate",
"all",
"configured",
"backends"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Log/PsrLoggerFactory.php#L86-L96 |
neos/flow-development-collection | Neos.Flow/Classes/Log/PsrLoggerFactory.php | PsrLoggerFactory.instantiateBackend | protected function instantiateBackend(string $class, array $options = [])
{
$backend = new $class($options);
if (!($backend instanceof BackendInterface)) {
throw new \Exception(sprintf('The log backend class "%s" does not implement the BackendInterface', htmlspecialchars($class)), 1515355501615);
}
return $backend;
} | php | protected function instantiateBackend(string $class, array $options = [])
{
$backend = new $class($options);
if (!($backend instanceof BackendInterface)) {
throw new \Exception(sprintf('The log backend class "%s" does not implement the BackendInterface', htmlspecialchars($class)), 1515355501615);
}
return $backend;
} | [
"protected",
"function",
"instantiateBackend",
"(",
"string",
"$",
"class",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"backend",
"=",
"new",
"$",
"class",
"(",
"$",
"options",
")",
";",
"if",
"(",
"!",
"(",
"$",
"backend",
"instance... | Instantiate a backend based on configuration.
@param string $class
@param array $options
@return BackendInterface
@throws \Exception | [
"Instantiate",
"a",
"backend",
"based",
"on",
"configuration",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Log/PsrLoggerFactory.php#L106-L114 |
neos/flow-development-collection | Neos.Flow/Classes/Reflection/ClassSchema.php | ClassSchema.addProperty | public function addProperty($name, $type, $lazy = false, $transient = false)
{
try {
$type = TypeHandling::parseType($type);
} catch (InvalidTypeException $exception) {
throw new \InvalidArgumentException(sprintf($exception->getMessage(), 'class "' . $name . '"'), 1315564474);
}
$this->properties[$name] = [
'type' => $type['type'],
'elementType' => $type['elementType'],
'lazy' => $lazy,
'transient' => $transient
];
} | php | public function addProperty($name, $type, $lazy = false, $transient = false)
{
try {
$type = TypeHandling::parseType($type);
} catch (InvalidTypeException $exception) {
throw new \InvalidArgumentException(sprintf($exception->getMessage(), 'class "' . $name . '"'), 1315564474);
}
$this->properties[$name] = [
'type' => $type['type'],
'elementType' => $type['elementType'],
'lazy' => $lazy,
'transient' => $transient
];
} | [
"public",
"function",
"addProperty",
"(",
"$",
"name",
",",
"$",
"type",
",",
"$",
"lazy",
"=",
"false",
",",
"$",
"transient",
"=",
"false",
")",
"{",
"try",
"{",
"$",
"type",
"=",
"TypeHandling",
"::",
"parseType",
"(",
"$",
"type",
")",
";",
"}"... | Adds (defines) a specific property and its type.
@param string $name Name of the property
@param string $type Type of the property
@param boolean $lazy Whether the property should be lazy-loaded when reconstituting
@param boolean $transient Whether the property should not be considered for persistence
@return void
@throws \InvalidArgumentException | [
"Adds",
"(",
"defines",
")",
"a",
"specific",
"property",
"and",
"its",
"type",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Reflection/ClassSchema.php#L119-L132 |
neos/flow-development-collection | Neos.Flow/Classes/Reflection/ClassSchema.php | ClassSchema.isMultiValuedProperty | public function isMultiValuedProperty($propertyName)
{
return ($this->properties[$propertyName]['type'] === 'array' || $this->properties[$propertyName]['type'] === 'SplObjectStorage' || $this->properties[$propertyName]['type'] === 'Doctrine\Common\Collections\Collection' || $this->properties[$propertyName]['type'] === 'Doctrine\Common\Collections\ArrayCollection');
} | php | public function isMultiValuedProperty($propertyName)
{
return ($this->properties[$propertyName]['type'] === 'array' || $this->properties[$propertyName]['type'] === 'SplObjectStorage' || $this->properties[$propertyName]['type'] === 'Doctrine\Common\Collections\Collection' || $this->properties[$propertyName]['type'] === 'Doctrine\Common\Collections\ArrayCollection');
} | [
"public",
"function",
"isMultiValuedProperty",
"(",
"$",
"propertyName",
")",
"{",
"return",
"(",
"$",
"this",
"->",
"properties",
"[",
"$",
"propertyName",
"]",
"[",
"'type'",
"]",
"===",
"'array'",
"||",
"$",
"this",
"->",
"properties",
"[",
"$",
"proper... | Checks if the given property defined in this schema is multi-valued (i.e.
array or SplObjectStorage).
@param string $propertyName
@return boolean | [
"Checks",
"if",
"the",
"given",
"property",
"defined",
"in",
"this",
"schema",
"is",
"multi",
"-",
"valued",
"(",
"i",
".",
"e",
".",
"array",
"or",
"SplObjectStorage",
")",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Reflection/ClassSchema.php#L163-L166 |
neos/flow-development-collection | Neos.Flow/Classes/Reflection/ClassSchema.php | ClassSchema.setModelType | public function setModelType($modelType)
{
if ($modelType !== self::MODELTYPE_ENTITY && $modelType !== self::MODELTYPE_VALUEOBJECT) {
throw new \InvalidArgumentException('"' . $modelType . '" is an invalid model type.', 1212519195);
}
$this->modelType = $modelType;
if ($modelType === self::MODELTYPE_VALUEOBJECT) {
$this->identityProperties = [];
$this->repositoryClassName = null;
}
} | php | public function setModelType($modelType)
{
if ($modelType !== self::MODELTYPE_ENTITY && $modelType !== self::MODELTYPE_VALUEOBJECT) {
throw new \InvalidArgumentException('"' . $modelType . '" is an invalid model type.', 1212519195);
}
$this->modelType = $modelType;
if ($modelType === self::MODELTYPE_VALUEOBJECT) {
$this->identityProperties = [];
$this->repositoryClassName = null;
}
} | [
"public",
"function",
"setModelType",
"(",
"$",
"modelType",
")",
"{",
"if",
"(",
"$",
"modelType",
"!==",
"self",
"::",
"MODELTYPE_ENTITY",
"&&",
"$",
"modelType",
"!==",
"self",
"::",
"MODELTYPE_VALUEOBJECT",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentE... | Sets the model type of the class this schema is referring to.
@param integer $modelType The model type, one of the MODELTYPE_* constants.
@return void
@throws \InvalidArgumentException | [
"Sets",
"the",
"model",
"type",
"of",
"the",
"class",
"this",
"schema",
"is",
"referring",
"to",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Reflection/ClassSchema.php#L175-L185 |
neos/flow-development-collection | Neos.Flow/Classes/Reflection/ClassSchema.php | ClassSchema.setRepositoryClassName | public function setRepositoryClassName($repositoryClassName)
{
if ($this->modelType === self::MODELTYPE_VALUEOBJECT && $repositoryClassName !== null) {
throw new Exception\ClassSchemaConstraintViolationException('Value objects must not be aggregate roots (have a repository)', 1268739172);
}
$this->repositoryClassName = $repositoryClassName;
} | php | public function setRepositoryClassName($repositoryClassName)
{
if ($this->modelType === self::MODELTYPE_VALUEOBJECT && $repositoryClassName !== null) {
throw new Exception\ClassSchemaConstraintViolationException('Value objects must not be aggregate roots (have a repository)', 1268739172);
}
$this->repositoryClassName = $repositoryClassName;
} | [
"public",
"function",
"setRepositoryClassName",
"(",
"$",
"repositoryClassName",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"modelType",
"===",
"self",
"::",
"MODELTYPE_VALUEOBJECT",
"&&",
"$",
"repositoryClassName",
"!==",
"null",
")",
"{",
"throw",
"new",
"Except... | Set the class name of the repository managing an entity.
@param string $repositoryClassName
@return void
@throws Exception\ClassSchemaConstraintViolationException | [
"Set",
"the",
"class",
"name",
"of",
"the",
"repository",
"managing",
"an",
"entity",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Reflection/ClassSchema.php#L204-L210 |
neos/flow-development-collection | Neos.Flow/Classes/Reflection/ClassSchema.php | ClassSchema.markAsIdentityProperty | public function markAsIdentityProperty($propertyName)
{
if ($this->modelType === self::MODELTYPE_VALUEOBJECT) {
throw new Exception\ClassSchemaConstraintViolationException('Value objects must not have identity properties', 1264102084);
}
if (!array_key_exists($propertyName, $this->properties)) {
throw new \InvalidArgumentException('Property "' . $propertyName . '" must be added to the class schema before it can be marked as identity property.', 1233775407);
}
if ($this->properties[$propertyName]['lazy'] === true) {
throw new \InvalidArgumentException('Property "' . $propertyName . '" must not be marked for lazy loading to be marked as identity property.', 1239896904);
}
$this->identityProperties[$propertyName] = $this->properties[$propertyName]['type'];
} | php | public function markAsIdentityProperty($propertyName)
{
if ($this->modelType === self::MODELTYPE_VALUEOBJECT) {
throw new Exception\ClassSchemaConstraintViolationException('Value objects must not have identity properties', 1264102084);
}
if (!array_key_exists($propertyName, $this->properties)) {
throw new \InvalidArgumentException('Property "' . $propertyName . '" must be added to the class schema before it can be marked as identity property.', 1233775407);
}
if ($this->properties[$propertyName]['lazy'] === true) {
throw new \InvalidArgumentException('Property "' . $propertyName . '" must not be marked for lazy loading to be marked as identity property.', 1239896904);
}
$this->identityProperties[$propertyName] = $this->properties[$propertyName]['type'];
} | [
"public",
"function",
"markAsIdentityProperty",
"(",
"$",
"propertyName",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"modelType",
"===",
"self",
"::",
"MODELTYPE_VALUEOBJECT",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"ClassSchemaConstraintViolationException",
"(",
... | Marks the given property as one of properties forming the identity
of an object. The property must already be registered in the class
schema.
@param string $propertyName
@return void
@throws \InvalidArgumentException
@throws Exception\ClassSchemaConstraintViolationException | [
"Marks",
"the",
"given",
"property",
"as",
"one",
"of",
"properties",
"forming",
"the",
"identity",
"of",
"an",
"object",
".",
"The",
"property",
"must",
"already",
"be",
"registered",
"in",
"the",
"class",
"schema",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Reflection/ClassSchema.php#L273-L286 |
neos/flow-development-collection | Neos.Eel/Classes/Helper/SecurityHelper.php | SecurityHelper.isAuthenticated | public function isAuthenticated(): bool
{
if (!$this->securityContext->canBeInitialized()) {
return false;
}
return array_reduce($this->securityContext->getAuthenticationTokens(), function (bool $isAuthenticated, TokenInterface $token) {
return $isAuthenticated || $token->isAuthenticated();
}, false);
} | php | public function isAuthenticated(): bool
{
if (!$this->securityContext->canBeInitialized()) {
return false;
}
return array_reduce($this->securityContext->getAuthenticationTokens(), function (bool $isAuthenticated, TokenInterface $token) {
return $isAuthenticated || $token->isAuthenticated();
}, false);
} | [
"public",
"function",
"isAuthenticated",
"(",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"securityContext",
"->",
"canBeInitialized",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"array_reduce",
"(",
"$",
"this",
"->",
"secur... | Returns true, if any account is currently authenticated
@return boolean true if any account is authenticated | [
"Returns",
"true",
"if",
"any",
"account",
"is",
"currently",
"authenticated"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Eel/Classes/Helper/SecurityHelper.php#L68-L77 |
neos/flow-development-collection | Neos.Eel/Classes/Helper/SecurityHelper.php | SecurityHelper.hasAccess | public function hasAccess(string $privilegeTarget, array $parameters = []): bool
{
if (!$this->securityContext->canBeInitialized()) {
return false;
}
return $this->privilegeManager->isPrivilegeTargetGranted($privilegeTarget, $parameters);
} | php | public function hasAccess(string $privilegeTarget, array $parameters = []): bool
{
if (!$this->securityContext->canBeInitialized()) {
return false;
}
return $this->privilegeManager->isPrivilegeTargetGranted($privilegeTarget, $parameters);
} | [
"public",
"function",
"hasAccess",
"(",
"string",
"$",
"privilegeTarget",
",",
"array",
"$",
"parameters",
"=",
"[",
"]",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"securityContext",
"->",
"canBeInitialized",
"(",
")",
")",
"{",
"return",... | Returns true, if access to the given privilege-target is granted
@param string $privilegeTarget The identifier of the privilege target to decide on
@param array $parameters Optional array of privilege parameters (simple key => value array)
@return boolean true if access is granted, false otherwise | [
"Returns",
"true",
"if",
"access",
"to",
"the",
"given",
"privilege",
"-",
"target",
"is",
"granted"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Eel/Classes/Helper/SecurityHelper.php#L86-L92 |
neos/flow-development-collection | Neos.Eel/Classes/Helper/SecurityHelper.php | SecurityHelper.hasRole | public function hasRole($roleIdentifier)
{
if ($roleIdentifier === 'Neos.Flow:Everybody') {
return true;
}
if ($this->securityContext->canBeInitialized()) {
return $this->securityContext->hasRole($roleIdentifier);
}
return false;
} | php | public function hasRole($roleIdentifier)
{
if ($roleIdentifier === 'Neos.Flow:Everybody') {
return true;
}
if ($this->securityContext->canBeInitialized()) {
return $this->securityContext->hasRole($roleIdentifier);
}
return false;
} | [
"public",
"function",
"hasRole",
"(",
"$",
"roleIdentifier",
")",
"{",
"if",
"(",
"$",
"roleIdentifier",
"===",
"'Neos.Flow:Everybody'",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"securityContext",
"->",
"canBeInitialized",
"(",
")"... | Returns true, if at least one of the currently authenticated accounts holds
a role with the given identifier, also recursively.
@param string $roleIdentifier The string representation of the role to search for
@return boolean true, if a role with the given string representation was found | [
"Returns",
"true",
"if",
"at",
"least",
"one",
"of",
"the",
"currently",
"authenticated",
"accounts",
"holds",
"a",
"role",
"with",
"the",
"given",
"identifier",
"also",
"recursively",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Eel/Classes/Helper/SecurityHelper.php#L101-L112 |
neos/flow-development-collection | Neos.Flow/Classes/Security/Authentication/AuthenticationProviderManager.php | AuthenticationProviderManager.injectSettings | public function injectSettings(array $settings): void
{
if (isset($settings['security']['authentication']['authenticationStrategy'])) {
$authenticationStrategyName = $settings['security']['authentication']['authenticationStrategy'];
switch ($authenticationStrategyName) {
case 'allTokens':
$this->authenticationStrategy = Context::AUTHENTICATE_ALL_TOKENS;
break;
case 'oneToken':
$this->authenticationStrategy = Context::AUTHENTICATE_ONE_TOKEN;
break;
case 'atLeastOneToken':
$this->authenticationStrategy = Context::AUTHENTICATE_AT_LEAST_ONE_TOKEN;
break;
case 'anyToken':
$this->authenticationStrategy = Context::AUTHENTICATE_ANY_TOKEN;
break;
default:
throw new Exception('Invalid setting "' . $authenticationStrategyName . '" for security.authentication.authenticationStrategy', 1291043022);
}
}
} | php | public function injectSettings(array $settings): void
{
if (isset($settings['security']['authentication']['authenticationStrategy'])) {
$authenticationStrategyName = $settings['security']['authentication']['authenticationStrategy'];
switch ($authenticationStrategyName) {
case 'allTokens':
$this->authenticationStrategy = Context::AUTHENTICATE_ALL_TOKENS;
break;
case 'oneToken':
$this->authenticationStrategy = Context::AUTHENTICATE_ONE_TOKEN;
break;
case 'atLeastOneToken':
$this->authenticationStrategy = Context::AUTHENTICATE_AT_LEAST_ONE_TOKEN;
break;
case 'anyToken':
$this->authenticationStrategy = Context::AUTHENTICATE_ANY_TOKEN;
break;
default:
throw new Exception('Invalid setting "' . $authenticationStrategyName . '" for security.authentication.authenticationStrategy', 1291043022);
}
}
} | [
"public",
"function",
"injectSettings",
"(",
"array",
"$",
"settings",
")",
":",
"void",
"{",
"if",
"(",
"isset",
"(",
"$",
"settings",
"[",
"'security'",
"]",
"[",
"'authentication'",
"]",
"[",
"'authenticationStrategy'",
"]",
")",
")",
"{",
"$",
"authent... | Inject the settings and does a fresh build of tokens based on the injected settings
@param array $settings The settings
@return void
@throws Exception | [
"Inject",
"the",
"settings",
"and",
"does",
"a",
"fresh",
"build",
"of",
"tokens",
"based",
"on",
"the",
"injected",
"settings"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Authentication/AuthenticationProviderManager.php#L87-L108 |
neos/flow-development-collection | Neos.Flow/Classes/Security/Authentication/AuthenticationProviderManager.php | AuthenticationProviderManager.authenticate | public function authenticate()
{
$this->isAuthenticated = false;
$anyTokenAuthenticated = false;
if ($this->securityContext === null) {
throw new Exception('Cannot authenticate because no security context has been set.', 1232978667);
}
$tokens = $this->securityContext->getAuthenticationTokens();
if (count($tokens) === 0) {
throw new NoTokensAuthenticatedException('The security context contained no tokens which could be authenticated.', 1258721059);
}
$session = $this->sessionManager->getCurrentSession();
/** @var $token TokenInterface */
foreach ($tokens as $token) {
/** @var $provider AuthenticationProviderInterface */
foreach ($this->tokenAndProviderFactory->getProviders() as $provider) {
if ($provider->canAuthenticate($token) && $token->getAuthenticationStatus() === TokenInterface::AUTHENTICATION_NEEDED) {
$provider->authenticate($token);
if ($token->isAuthenticated()) {
$this->emitAuthenticatedToken($token);
}
break;
}
}
if ($token->isAuthenticated()) {
if (!$token instanceof SessionlessTokenInterface) {
if (!$session->isStarted()) {
$session->start();
}
$account = $token->getAccount();
if ($account !== null) {
$this->securityContext->withoutAuthorizationChecks(function () use ($account, $session) {
$session->addTag($this->securityContext->getSessionTagForAccount($account));
});
}
}
if ($this->authenticationStrategy === Context::AUTHENTICATE_ONE_TOKEN) {
$this->isAuthenticated = true;
$this->emitSuccessfullyAuthenticated();
return;
}
$anyTokenAuthenticated = true;
} else {
if ($this->authenticationStrategy === Context::AUTHENTICATE_ALL_TOKENS) {
throw new AuthenticationRequiredException('Could not authenticate all tokens, but authenticationStrategy was set to "all".', 1222203912);
}
}
}
if (!$anyTokenAuthenticated && $this->authenticationStrategy !== Context::AUTHENTICATE_ANY_TOKEN) {
throw new NoTokensAuthenticatedException('Could not authenticate any token. Might be missing or wrong credentials or no authentication provider matched.', 1222204027);
}
$this->isAuthenticated = $anyTokenAuthenticated;
$this->emitSuccessfullyAuthenticated();
} | php | public function authenticate()
{
$this->isAuthenticated = false;
$anyTokenAuthenticated = false;
if ($this->securityContext === null) {
throw new Exception('Cannot authenticate because no security context has been set.', 1232978667);
}
$tokens = $this->securityContext->getAuthenticationTokens();
if (count($tokens) === 0) {
throw new NoTokensAuthenticatedException('The security context contained no tokens which could be authenticated.', 1258721059);
}
$session = $this->sessionManager->getCurrentSession();
/** @var $token TokenInterface */
foreach ($tokens as $token) {
/** @var $provider AuthenticationProviderInterface */
foreach ($this->tokenAndProviderFactory->getProviders() as $provider) {
if ($provider->canAuthenticate($token) && $token->getAuthenticationStatus() === TokenInterface::AUTHENTICATION_NEEDED) {
$provider->authenticate($token);
if ($token->isAuthenticated()) {
$this->emitAuthenticatedToken($token);
}
break;
}
}
if ($token->isAuthenticated()) {
if (!$token instanceof SessionlessTokenInterface) {
if (!$session->isStarted()) {
$session->start();
}
$account = $token->getAccount();
if ($account !== null) {
$this->securityContext->withoutAuthorizationChecks(function () use ($account, $session) {
$session->addTag($this->securityContext->getSessionTagForAccount($account));
});
}
}
if ($this->authenticationStrategy === Context::AUTHENTICATE_ONE_TOKEN) {
$this->isAuthenticated = true;
$this->emitSuccessfullyAuthenticated();
return;
}
$anyTokenAuthenticated = true;
} else {
if ($this->authenticationStrategy === Context::AUTHENTICATE_ALL_TOKENS) {
throw new AuthenticationRequiredException('Could not authenticate all tokens, but authenticationStrategy was set to "all".', 1222203912);
}
}
}
if (!$anyTokenAuthenticated && $this->authenticationStrategy !== Context::AUTHENTICATE_ANY_TOKEN) {
throw new NoTokensAuthenticatedException('Could not authenticate any token. Might be missing or wrong credentials or no authentication provider matched.', 1222204027);
}
$this->isAuthenticated = $anyTokenAuthenticated;
$this->emitSuccessfullyAuthenticated();
} | [
"public",
"function",
"authenticate",
"(",
")",
"{",
"$",
"this",
"->",
"isAuthenticated",
"=",
"false",
";",
"$",
"anyTokenAuthenticated",
"=",
"false",
";",
"if",
"(",
"$",
"this",
"->",
"securityContext",
"===",
"null",
")",
"{",
"throw",
"new",
"Except... | Tries to authenticate the tokens in the security context (in the given order)
with the available authentication providers, if needed.
If the authentication strategy is set to "allTokens", all tokens have to be authenticated.
If the strategy is set to "oneToken", only one token needs to be authenticated, but the
authentication will stop after the first authenticated token. The strategy
"atLeastOne" will try to authenticate at least one and as many tokens as possible.
@return void
@throws Exception
@throws AuthenticationRequiredException
@throws NoTokensAuthenticatedException | [
"Tries",
"to",
"authenticate",
"the",
"tokens",
"in",
"the",
"security",
"context",
"(",
"in",
"the",
"given",
"order",
")",
"with",
"the",
"available",
"authentication",
"providers",
"if",
"needed",
".",
"If",
"the",
"authentication",
"strategy",
"is",
"set",... | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Authentication/AuthenticationProviderManager.php#L170-L229 |
neos/flow-development-collection | Neos.Flow/Classes/Security/Authentication/AuthenticationProviderManager.php | AuthenticationProviderManager.isAuthenticated | public function isAuthenticated()
{
if ($this->isAuthenticated === null) {
try {
$this->authenticate();
} catch (AuthenticationRequiredException $exception) {
}
}
return $this->isAuthenticated;
} | php | public function isAuthenticated()
{
if ($this->isAuthenticated === null) {
try {
$this->authenticate();
} catch (AuthenticationRequiredException $exception) {
}
}
return $this->isAuthenticated;
} | [
"public",
"function",
"isAuthenticated",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isAuthenticated",
"===",
"null",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"authenticate",
"(",
")",
";",
"}",
"catch",
"(",
"AuthenticationRequiredException",
"$",
"exce... | Checks if one or all tokens are authenticated (depending on the authentication strategy).
Will call authenticate() if not done before.
@return boolean
@throws Exception | [
"Checks",
"if",
"one",
"or",
"all",
"tokens",
"are",
"authenticated",
"(",
"depending",
"on",
"the",
"authentication",
"strategy",
")",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Authentication/AuthenticationProviderManager.php#L239-L248 |
neos/flow-development-collection | Neos.Flow/Classes/Security/Authentication/AuthenticationProviderManager.php | AuthenticationProviderManager.logout | public function logout()
{
if ($this->isAuthenticated() !== true) {
return;
}
$this->isAuthenticated = null;
$session = $this->sessionManager->getCurrentSession();
/** @var $token TokenInterface */
foreach ($this->securityContext->getAuthenticationTokens() as $token) {
$token->setAuthenticationStatus(TokenInterface::NO_CREDENTIALS_GIVEN);
}
$this->emitLoggedOut();
if ($session->isStarted()) {
$session->destroy('Logout through AuthenticationProviderManager');
}
} | php | public function logout()
{
if ($this->isAuthenticated() !== true) {
return;
}
$this->isAuthenticated = null;
$session = $this->sessionManager->getCurrentSession();
/** @var $token TokenInterface */
foreach ($this->securityContext->getAuthenticationTokens() as $token) {
$token->setAuthenticationStatus(TokenInterface::NO_CREDENTIALS_GIVEN);
}
$this->emitLoggedOut();
if ($session->isStarted()) {
$session->destroy('Logout through AuthenticationProviderManager');
}
} | [
"public",
"function",
"logout",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isAuthenticated",
"(",
")",
"!==",
"true",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"isAuthenticated",
"=",
"null",
";",
"$",
"session",
"=",
"$",
"this",
"->",
"... | Logout all active authentication tokens
@return void
@throws Exception
@throws \Neos\Flow\Session\Exception\SessionNotStartedException | [
"Logout",
"all",
"active",
"authentication",
"tokens"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Authentication/AuthenticationProviderManager.php#L257-L273 |
neos/flow-development-collection | Neos.Flow/Classes/ResourceManagement/ResourceTypeConverter.php | ResourceTypeConverter.convertFrom | public function convertFrom($source, $targetType, array $convertedChildProperties = [], PropertyMappingConfigurationInterface $configuration = null)
{
if (empty($source)) {
return null;
}
if ($source instanceof UploadedFileInterface) {
return $this->handleUploadedFile($source, $configuration);
}
if (is_string($source)) {
$source = ['hash' => $source];
}
// $source is ALWAYS an array at this point
if (isset($source['error']) || isset($source['originallySubmittedResource'])) {
return $this->handleFileUploads($source, $configuration);
} elseif (isset($source['hash']) || isset($source['data'])) {
return $this->handleHashAndData($source, $configuration);
}
return null;
} | php | public function convertFrom($source, $targetType, array $convertedChildProperties = [], PropertyMappingConfigurationInterface $configuration = null)
{
if (empty($source)) {
return null;
}
if ($source instanceof UploadedFileInterface) {
return $this->handleUploadedFile($source, $configuration);
}
if (is_string($source)) {
$source = ['hash' => $source];
}
// $source is ALWAYS an array at this point
if (isset($source['error']) || isset($source['originallySubmittedResource'])) {
return $this->handleFileUploads($source, $configuration);
} elseif (isset($source['hash']) || isset($source['data'])) {
return $this->handleHashAndData($source, $configuration);
}
return null;
} | [
"public",
"function",
"convertFrom",
"(",
"$",
"source",
",",
"$",
"targetType",
",",
"array",
"$",
"convertedChildProperties",
"=",
"[",
"]",
",",
"PropertyMappingConfigurationInterface",
"$",
"configuration",
"=",
"null",
")",
"{",
"if",
"(",
"empty",
"(",
"... | Converts the given string or array to a PersistentResource object.
If the input format is an array, this method assumes the resource to be a
fresh file upload and imports the temporary upload file through the
ResourceManager.
Note that $source['error'] will also be present if a file was successfully
uploaded. In that case its value will be \UPLOAD_ERR_OK.
@param array $source The upload info (expected keys: error, name, tmp_name)
@param string $targetType
@param array $convertedChildProperties
@param PropertyMappingConfigurationInterface $configuration
@return PersistentResource|FlowError if the input format is not supported or could not be converted for other reasons
@throws Exception
@throws Exception\InvalidResourceDataException
@throws InvalidPropertyMappingConfigurationException | [
"Converts",
"the",
"given",
"string",
"or",
"array",
"to",
"a",
"PersistentResource",
"object",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ResourceManagement/ResourceTypeConverter.php#L155-L176 |
neos/flow-development-collection | Neos.Flow/Classes/ResourceManagement/ResourceTypeConverter.php | ResourceTypeConverter.getCollectionName | protected function getCollectionName($source, PropertyMappingConfigurationInterface $configuration = null)
{
if ($configuration === null) {
return ResourceManager::DEFAULT_PERSISTENT_COLLECTION_NAME;
}
$collectionName = $configuration->getConfigurationValue(ResourceTypeConverter::class, self::CONFIGURATION_COLLECTION_NAME) ?: ResourceManager::DEFAULT_PERSISTENT_COLLECTION_NAME;
if ($source instanceof FlowUploadedFile && $source->getCollectionName() !== null) {
$collectionName = $source->getCollectionName();
}
if (is_array($source) && isset($source['__collectionName']) && $source['__collectionName'] !== '') {
$collectionName = $source['__collectionName'];
}
if ($this->resourceManager->getCollection($collectionName) === null) {
throw new InvalidPropertyMappingConfigurationException(sprintf('The selected resource collection named "%s" does not exist, a resource could not be imported.', $collectionName), 1416687475);
}
return $collectionName;
} | php | protected function getCollectionName($source, PropertyMappingConfigurationInterface $configuration = null)
{
if ($configuration === null) {
return ResourceManager::DEFAULT_PERSISTENT_COLLECTION_NAME;
}
$collectionName = $configuration->getConfigurationValue(ResourceTypeConverter::class, self::CONFIGURATION_COLLECTION_NAME) ?: ResourceManager::DEFAULT_PERSISTENT_COLLECTION_NAME;
if ($source instanceof FlowUploadedFile && $source->getCollectionName() !== null) {
$collectionName = $source->getCollectionName();
}
if (is_array($source) && isset($source['__collectionName']) && $source['__collectionName'] !== '') {
$collectionName = $source['__collectionName'];
}
if ($this->resourceManager->getCollection($collectionName) === null) {
throw new InvalidPropertyMappingConfigurationException(sprintf('The selected resource collection named "%s" does not exist, a resource could not be imported.', $collectionName), 1416687475);
}
return $collectionName;
} | [
"protected",
"function",
"getCollectionName",
"(",
"$",
"source",
",",
"PropertyMappingConfigurationInterface",
"$",
"configuration",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"configuration",
"===",
"null",
")",
"{",
"return",
"ResourceManager",
"::",
"DEFAULT_PERSIST... | Get the collection name this resource will be stored in. Default will be ResourceManager::DEFAULT_PERSISTENT_COLLECTION_NAME
The propertyMappingConfiguration CONFIGURATION_COLLECTION_NAME will directly override the default. Then if CONFIGURATION_ALLOW_COLLECTION_OVERRIDE is true
and __collectionName is in the $source this will finally be the value.
@param array|UploadedFileInterface $source
@param PropertyMappingConfigurationInterface $configuration
@return string
@throws InvalidPropertyMappingConfigurationException | [
"Get",
"the",
"collection",
"name",
"this",
"resource",
"will",
"be",
"stored",
"in",
".",
"Default",
"will",
"be",
"ResourceManager",
"::",
"DEFAULT_PERSISTENT_COLLECTION_NAME",
"The",
"propertyMappingConfiguration",
"CONFIGURATION_COLLECTION_NAME",
"will",
"directly",
"... | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ResourceManagement/ResourceTypeConverter.php#L329-L349 |
neos/flow-development-collection | Neos.Flow/Classes/Security/AccountRepository.php | AccountRepository.findByAccountIdentifierAndAuthenticationProviderName | public function findByAccountIdentifierAndAuthenticationProviderName($accountIdentifier, $authenticationProviderName)
{
$query = $this->createQuery();
return $query->matching(
$query->logicalAnd(
$query->equals('accountIdentifier', $accountIdentifier),
$query->equals('authenticationProviderName', $authenticationProviderName)
)
)->execute()->getFirst();
} | php | public function findByAccountIdentifierAndAuthenticationProviderName($accountIdentifier, $authenticationProviderName)
{
$query = $this->createQuery();
return $query->matching(
$query->logicalAnd(
$query->equals('accountIdentifier', $accountIdentifier),
$query->equals('authenticationProviderName', $authenticationProviderName)
)
)->execute()->getFirst();
} | [
"public",
"function",
"findByAccountIdentifierAndAuthenticationProviderName",
"(",
"$",
"accountIdentifier",
",",
"$",
"authenticationProviderName",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"createQuery",
"(",
")",
";",
"return",
"$",
"query",
"->",
"matching... | Returns the account for a specific authentication provider with the given identifier
@param string $accountIdentifier The account identifier
@param string $authenticationProviderName The authentication provider name
@return Account | [
"Returns",
"the",
"account",
"for",
"a",
"specific",
"authentication",
"provider",
"with",
"the",
"given",
"identifier"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/AccountRepository.php#L67-L76 |
neos/flow-development-collection | Neos.Flow/Classes/Security/AccountRepository.php | AccountRepository.findActiveByAccountIdentifierAndAuthenticationProviderName | public function findActiveByAccountIdentifierAndAuthenticationProviderName($accountIdentifier, $authenticationProviderName)
{
$query = $this->createQuery();
return $query->matching(
$query->logicalAnd(
$query->equals('accountIdentifier', $accountIdentifier),
$query->equals('authenticationProviderName', $authenticationProviderName),
$query->logicalOr(
$query->equals('expirationDate', null),
$query->greaterThan('expirationDate', new \DateTime())
)
)
)->execute()->getFirst();
} | php | public function findActiveByAccountIdentifierAndAuthenticationProviderName($accountIdentifier, $authenticationProviderName)
{
$query = $this->createQuery();
return $query->matching(
$query->logicalAnd(
$query->equals('accountIdentifier', $accountIdentifier),
$query->equals('authenticationProviderName', $authenticationProviderName),
$query->logicalOr(
$query->equals('expirationDate', null),
$query->greaterThan('expirationDate', new \DateTime())
)
)
)->execute()->getFirst();
} | [
"public",
"function",
"findActiveByAccountIdentifierAndAuthenticationProviderName",
"(",
"$",
"accountIdentifier",
",",
"$",
"authenticationProviderName",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"createQuery",
"(",
")",
";",
"return",
"$",
"query",
"->",
"ma... | Returns the account for a specific authentication provider with the given identifier if it's not expired
@param string $accountIdentifier The account identifier
@param string $authenticationProviderName The authentication provider name
@return Account | [
"Returns",
"the",
"account",
"for",
"a",
"specific",
"authentication",
"provider",
"with",
"the",
"given",
"identifier",
"if",
"it",
"s",
"not",
"expired"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/AccountRepository.php#L85-L98 |
neos/flow-development-collection | Neos.Flow/Classes/Mvc/Dispatcher.php | Dispatcher.dispatch | public function dispatch(RequestInterface $request, ResponseInterface $response)
{
if ($request instanceof CliRequest) {
$this->initiateDispatchLoop($request, $response);
return;
}
// NOTE: The dispatcher is used for both Action- and CLI-Requests. For the latter case dispatching might happen during compile-time, that's why we can't inject the following dependencies
/** @var Context $securityContext */
$securityContext = $this->objectManager->get(Context::class);
if ($securityContext->areAuthorizationChecksDisabled()) {
$this->initiateDispatchLoop($request, $response);
return;
}
/** @var FirewallInterface $firewall */
$firewall = $this->objectManager->get(FirewallInterface::class);
/** @var PsrLoggerFactoryInterface $securityLogger */
$securityLogger = $this->objectManager->get(PsrLoggerFactoryInterface::class)->get('securityLogger');
try {
/** @var ActionRequest $request */
$firewall->blockIllegalRequests($request);
$this->initiateDispatchLoop($request, $response);
} catch (AuthenticationRequiredException $exception) {
$entryPointFound = false;
/** @var $token TokenInterface */
foreach ($securityContext->getAuthenticationTokens() as $token) {
$entryPoint = $token->getAuthenticationEntryPoint();
if ($entryPoint === null) {
continue;
}
$entryPointFound = true;
if ($entryPoint instanceof WebRedirect) {
$securityLogger->info('Redirecting to authentication entry point', $entryPoint->getOptions(), LogEnvironment::fromMethodName(__METHOD__));
} else {
$securityLogger->info(sprintf('Starting authentication with entry point of type "%s"', get_class($entryPoint)), LogEnvironment::fromMethodName(__METHOD__));
}
$securityContext->setInterceptedRequest($request->getMainRequest());
/** @var HttpResponse $response */
$entryPoint->startAuthentication($request->getHttpRequest(), $response);
}
if ($entryPointFound === false) {
$securityLogger->notice('No authentication entry point found for active tokens, therefore cannot authenticate or redirect to authentication automatically.');
throw $exception;
}
} catch (AccessDeniedException $exception) {
$securityLogger->warning('Access denied', LogEnvironment::fromMethodName(__METHOD__));
throw $exception;
}
} | php | public function dispatch(RequestInterface $request, ResponseInterface $response)
{
if ($request instanceof CliRequest) {
$this->initiateDispatchLoop($request, $response);
return;
}
// NOTE: The dispatcher is used for both Action- and CLI-Requests. For the latter case dispatching might happen during compile-time, that's why we can't inject the following dependencies
/** @var Context $securityContext */
$securityContext = $this->objectManager->get(Context::class);
if ($securityContext->areAuthorizationChecksDisabled()) {
$this->initiateDispatchLoop($request, $response);
return;
}
/** @var FirewallInterface $firewall */
$firewall = $this->objectManager->get(FirewallInterface::class);
/** @var PsrLoggerFactoryInterface $securityLogger */
$securityLogger = $this->objectManager->get(PsrLoggerFactoryInterface::class)->get('securityLogger');
try {
/** @var ActionRequest $request */
$firewall->blockIllegalRequests($request);
$this->initiateDispatchLoop($request, $response);
} catch (AuthenticationRequiredException $exception) {
$entryPointFound = false;
/** @var $token TokenInterface */
foreach ($securityContext->getAuthenticationTokens() as $token) {
$entryPoint = $token->getAuthenticationEntryPoint();
if ($entryPoint === null) {
continue;
}
$entryPointFound = true;
if ($entryPoint instanceof WebRedirect) {
$securityLogger->info('Redirecting to authentication entry point', $entryPoint->getOptions(), LogEnvironment::fromMethodName(__METHOD__));
} else {
$securityLogger->info(sprintf('Starting authentication with entry point of type "%s"', get_class($entryPoint)), LogEnvironment::fromMethodName(__METHOD__));
}
$securityContext->setInterceptedRequest($request->getMainRequest());
/** @var HttpResponse $response */
$entryPoint->startAuthentication($request->getHttpRequest(), $response);
}
if ($entryPointFound === false) {
$securityLogger->notice('No authentication entry point found for active tokens, therefore cannot authenticate or redirect to authentication automatically.');
throw $exception;
}
} catch (AccessDeniedException $exception) {
$securityLogger->warning('Access denied', LogEnvironment::fromMethodName(__METHOD__));
throw $exception;
}
} | [
"public",
"function",
"dispatch",
"(",
"RequestInterface",
"$",
"request",
",",
"ResponseInterface",
"$",
"response",
")",
"{",
"if",
"(",
"$",
"request",
"instanceof",
"CliRequest",
")",
"{",
"$",
"this",
"->",
"initiateDispatchLoop",
"(",
"$",
"request",
","... | Dispatches a request to a controller
@param RequestInterface $request The request to dispatch
@param ResponseInterface $response The response, to be modified by the controller
@return void
@throws AccessDeniedException
@throws AuthenticationRequiredException
@throws InfiniteLoopException
@throws InvalidControllerException
@throws NoSuchOptionException
@throws MissingConfigurationException
@api | [
"Dispatches",
"a",
"request",
"to",
"a",
"controller"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Mvc/Dispatcher.php#L74-L125 |
neos/flow-development-collection | Neos.Flow/Classes/Mvc/Dispatcher.php | Dispatcher.initiateDispatchLoop | protected function initiateDispatchLoop(RequestInterface $request, ResponseInterface $response)
{
$dispatchLoopCount = 0;
/** @var ActionRequest $request */
while (!$request->isDispatched()) {
if ($dispatchLoopCount++ > 99) {
throw new Exception\InfiniteLoopException(sprintf('Could not ultimately dispatch the request after %d iterations.', $dispatchLoopCount), 1217839467);
}
$controller = $this->resolveController($request);
try {
$this->emitBeforeControllerInvocation($request, $response, $controller);
$controller->processRequest($request, $response);
$this->emitAfterControllerInvocation($request, $response, $controller);
} catch (StopActionException $exception) {
$this->emitAfterControllerInvocation($request, $response, $controller);
if ($exception instanceof ForwardException) {
$request = $exception->getNextRequest();
} elseif (!$request->isMainRequest()) {
$request = $request->getParentRequest();
}
}
}
} | php | protected function initiateDispatchLoop(RequestInterface $request, ResponseInterface $response)
{
$dispatchLoopCount = 0;
/** @var ActionRequest $request */
while (!$request->isDispatched()) {
if ($dispatchLoopCount++ > 99) {
throw new Exception\InfiniteLoopException(sprintf('Could not ultimately dispatch the request after %d iterations.', $dispatchLoopCount), 1217839467);
}
$controller = $this->resolveController($request);
try {
$this->emitBeforeControllerInvocation($request, $response, $controller);
$controller->processRequest($request, $response);
$this->emitAfterControllerInvocation($request, $response, $controller);
} catch (StopActionException $exception) {
$this->emitAfterControllerInvocation($request, $response, $controller);
if ($exception instanceof ForwardException) {
$request = $exception->getNextRequest();
} elseif (!$request->isMainRequest()) {
$request = $request->getParentRequest();
}
}
}
} | [
"protected",
"function",
"initiateDispatchLoop",
"(",
"RequestInterface",
"$",
"request",
",",
"ResponseInterface",
"$",
"response",
")",
"{",
"$",
"dispatchLoopCount",
"=",
"0",
";",
"/** @var ActionRequest $request */",
"while",
"(",
"!",
"$",
"request",
"->",
"is... | Try processing the request until it is successfully marked "dispatched"
@param RequestInterface $request
@param ResponseInterface $response
@throws InvalidControllerException|InfiniteLoopException|NoSuchOptionException
TODO: From next major we might want to create one ActionResponse PER controller invocation and then merge results here | [
"Try",
"processing",
"the",
"request",
"until",
"it",
"is",
"successfully",
"marked",
"dispatched"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Mvc/Dispatcher.php#L136-L158 |
neos/flow-development-collection | Neos.Flow/Classes/Mvc/Dispatcher.php | Dispatcher.resolveController | protected function resolveController(RequestInterface $request)
{
/** @var ActionRequest $request */
$controllerObjectName = $request->getControllerObjectName();
if ($controllerObjectName === '') {
$exceptionMessage = 'No controller could be resolved which would match your request';
if ($request instanceof ActionRequest) {
$exceptionMessage .= sprintf('. Package key: "%s", controller name: "%s"', $request->getControllerPackageKey(), $request->getControllerName());
if ($request->getControllerSubpackageKey() !== null) {
$exceptionMessage .= sprintf(', SubPackage key: "%s"', $request->getControllerSubpackageKey());
}
$exceptionMessage .= sprintf('. (%s %s)', $request->getHttpRequest()->getMethod(), $request->getHttpRequest()->getUri());
}
throw new Controller\Exception\InvalidControllerException($exceptionMessage, 1303209195, null, $request);
}
$controller = $this->objectManager->get($controllerObjectName);
if (!$controller instanceof ControllerInterface) {
throw new Controller\Exception\InvalidControllerException('Invalid controller "' . $request->getControllerObjectName() . '". The controller must be a valid request handling controller, ' . (is_object($controller) ? get_class($controller) : gettype($controller)) . ' given.', 1202921619, null, $request);
}
return $controller;
} | php | protected function resolveController(RequestInterface $request)
{
/** @var ActionRequest $request */
$controllerObjectName = $request->getControllerObjectName();
if ($controllerObjectName === '') {
$exceptionMessage = 'No controller could be resolved which would match your request';
if ($request instanceof ActionRequest) {
$exceptionMessage .= sprintf('. Package key: "%s", controller name: "%s"', $request->getControllerPackageKey(), $request->getControllerName());
if ($request->getControllerSubpackageKey() !== null) {
$exceptionMessage .= sprintf(', SubPackage key: "%s"', $request->getControllerSubpackageKey());
}
$exceptionMessage .= sprintf('. (%s %s)', $request->getHttpRequest()->getMethod(), $request->getHttpRequest()->getUri());
}
throw new Controller\Exception\InvalidControllerException($exceptionMessage, 1303209195, null, $request);
}
$controller = $this->objectManager->get($controllerObjectName);
if (!$controller instanceof ControllerInterface) {
throw new Controller\Exception\InvalidControllerException('Invalid controller "' . $request->getControllerObjectName() . '". The controller must be a valid request handling controller, ' . (is_object($controller) ? get_class($controller) : gettype($controller)) . ' given.', 1202921619, null, $request);
}
return $controller;
} | [
"protected",
"function",
"resolveController",
"(",
"RequestInterface",
"$",
"request",
")",
"{",
"/** @var ActionRequest $request */",
"$",
"controllerObjectName",
"=",
"$",
"request",
"->",
"getControllerObjectName",
"(",
")",
";",
"if",
"(",
"$",
"controllerObjectName... | Finds and instantiates a controller that matches the current request.
If no controller can be found, an instance of NotFoundControllerInterface is returned.
@param RequestInterface $request The request to dispatch
@return ControllerInterface
@throws NoSuchOptionException
@throws Controller\Exception\InvalidControllerException | [
"Finds",
"and",
"instantiates",
"a",
"controller",
"that",
"matches",
"the",
"current",
"request",
".",
"If",
"no",
"controller",
"can",
"be",
"found",
"an",
"instance",
"of",
"NotFoundControllerInterface",
"is",
"returned",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Mvc/Dispatcher.php#L196-L217 |
neos/flow-development-collection | Neos.Cache/Classes/Backend/SimpleFileBackend.php | SimpleFileBackend.setCache | public function setCache(FrontendInterface $cache)
{
parent::setCache($cache);
$this->cacheEntryFileExtension = ($cache instanceof PhpFrontend) ? '.php' : '';
$this->configureCacheDirectory();
} | php | public function setCache(FrontendInterface $cache)
{
parent::setCache($cache);
$this->cacheEntryFileExtension = ($cache instanceof PhpFrontend) ? '.php' : '';
$this->configureCacheDirectory();
} | [
"public",
"function",
"setCache",
"(",
"FrontendInterface",
"$",
"cache",
")",
"{",
"parent",
"::",
"setCache",
"(",
"$",
"cache",
")",
";",
"$",
"this",
"->",
"cacheEntryFileExtension",
"=",
"(",
"$",
"cache",
"instanceof",
"PhpFrontend",
")",
"?",
"'.php'"... | Sets a reference to the cache frontend which uses this backend and
initializes the default cache directory.
@param \Neos\Cache\Frontend\FrontendInterface $cache The cache frontend
@return void
@throws Exception | [
"Sets",
"a",
"reference",
"to",
"the",
"cache",
"frontend",
"which",
"uses",
"this",
"backend",
"and",
"initializes",
"the",
"default",
"cache",
"directory",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Cache/Classes/Backend/SimpleFileBackend.php#L104-L109 |
neos/flow-development-collection | Neos.Cache/Classes/Backend/SimpleFileBackend.php | SimpleFileBackend.set | public function set(string $entryIdentifier, string $data, array $tags = [], int $lifetime = null)
{
if ($entryIdentifier !== basename($entryIdentifier)) {
throw new \InvalidArgumentException('The specified entry identifier must not contain a path segment.', 1334756735);
}
if ($entryIdentifier === '') {
throw new \InvalidArgumentException('The specified entry identifier must not be empty.', 1334756736);
}
$cacheEntryPathAndFilename = $this->cacheDirectory . $entryIdentifier . $this->cacheEntryFileExtension;
$result = $this->writeCacheFile($cacheEntryPathAndFilename, $data);
if ($result !== false) {
if ($this->cacheEntryFileExtension === '.php') {
OpcodeCacheHelper::clearAllActive($cacheEntryPathAndFilename);
}
return;
}
$this->throwExceptionIfPathExceedsMaximumLength($cacheEntryPathAndFilename);
throw new Exception('The cache file "' . $cacheEntryPathAndFilename . '" could not be written.', 1334756737);
} | php | public function set(string $entryIdentifier, string $data, array $tags = [], int $lifetime = null)
{
if ($entryIdentifier !== basename($entryIdentifier)) {
throw new \InvalidArgumentException('The specified entry identifier must not contain a path segment.', 1334756735);
}
if ($entryIdentifier === '') {
throw new \InvalidArgumentException('The specified entry identifier must not be empty.', 1334756736);
}
$cacheEntryPathAndFilename = $this->cacheDirectory . $entryIdentifier . $this->cacheEntryFileExtension;
$result = $this->writeCacheFile($cacheEntryPathAndFilename, $data);
if ($result !== false) {
if ($this->cacheEntryFileExtension === '.php') {
OpcodeCacheHelper::clearAllActive($cacheEntryPathAndFilename);
}
return;
}
$this->throwExceptionIfPathExceedsMaximumLength($cacheEntryPathAndFilename);
throw new Exception('The cache file "' . $cacheEntryPathAndFilename . '" could not be written.', 1334756737);
} | [
"public",
"function",
"set",
"(",
"string",
"$",
"entryIdentifier",
",",
"string",
"$",
"data",
",",
"array",
"$",
"tags",
"=",
"[",
"]",
",",
"int",
"$",
"lifetime",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"entryIdentifier",
"!==",
"basename",
"(",
"... | Saves data in a cache file.
@param string $entryIdentifier An identifier for this specific cache entry
@param string $data The data to be stored
@param array $tags Ignored in this type of cache backend
@param integer $lifetime Ignored in this type of cache backend
@return void
@throws Exception if the directory does not exist or is not writable or exceeds the maximum allowed path length, or if no cache frontend has been set.
@throws \InvalidArgumentException
@api | [
"Saves",
"data",
"in",
"a",
"cache",
"file",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Cache/Classes/Backend/SimpleFileBackend.php#L146-L167 |
neos/flow-development-collection | Neos.Cache/Classes/Backend/SimpleFileBackend.php | SimpleFileBackend.get | public function get(string $entryIdentifier)
{
if ($entryIdentifier !== basename($entryIdentifier)) {
throw new \InvalidArgumentException('The specified entry identifier must not contain a path segment.', 1334756877);
}
$pathAndFilename = $this->cacheDirectory . $entryIdentifier . $this->cacheEntryFileExtension;
if (!file_exists($pathAndFilename)) {
return false;
}
return $this->readCacheFile($pathAndFilename);
} | php | public function get(string $entryIdentifier)
{
if ($entryIdentifier !== basename($entryIdentifier)) {
throw new \InvalidArgumentException('The specified entry identifier must not contain a path segment.', 1334756877);
}
$pathAndFilename = $this->cacheDirectory . $entryIdentifier . $this->cacheEntryFileExtension;
if (!file_exists($pathAndFilename)) {
return false;
}
return $this->readCacheFile($pathAndFilename);
} | [
"public",
"function",
"get",
"(",
"string",
"$",
"entryIdentifier",
")",
"{",
"if",
"(",
"$",
"entryIdentifier",
"!==",
"basename",
"(",
"$",
"entryIdentifier",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'The specified entry identifier ... | Loads data from a cache file.
@param string $entryIdentifier An identifier which describes the cache entry to load
@return mixed The cache entry's content as a string or false if the cache entry could not be loaded
@throws \InvalidArgumentException
@api | [
"Loads",
"data",
"from",
"a",
"cache",
"file",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Cache/Classes/Backend/SimpleFileBackend.php#L177-L190 |
neos/flow-development-collection | Neos.Cache/Classes/Backend/SimpleFileBackend.php | SimpleFileBackend.has | public function has(string $entryIdentifier): bool
{
if ($entryIdentifier !== basename($entryIdentifier)) {
throw new \InvalidArgumentException('The specified entry identifier must not contain a path segment.', 1334756878);
}
return file_exists($this->cacheDirectory . $entryIdentifier . $this->cacheEntryFileExtension);
} | php | public function has(string $entryIdentifier): bool
{
if ($entryIdentifier !== basename($entryIdentifier)) {
throw new \InvalidArgumentException('The specified entry identifier must not contain a path segment.', 1334756878);
}
return file_exists($this->cacheDirectory . $entryIdentifier . $this->cacheEntryFileExtension);
} | [
"public",
"function",
"has",
"(",
"string",
"$",
"entryIdentifier",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"entryIdentifier",
"!==",
"basename",
"(",
"$",
"entryIdentifier",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'The specified ... | Checks if a cache entry with the specified identifier exists.
@param string $entryIdentifier
@return boolean true if such an entry exists, false if not
@throws \InvalidArgumentException
@api | [
"Checks",
"if",
"a",
"cache",
"entry",
"with",
"the",
"specified",
"identifier",
"exists",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Cache/Classes/Backend/SimpleFileBackend.php#L200-L206 |
neos/flow-development-collection | Neos.Cache/Classes/Backend/SimpleFileBackend.php | SimpleFileBackend.tryRemoveWithLock | private function tryRemoveWithLock(string $fileName): bool
{
if (strncasecmp(PHP_OS, 'WIN', 3) == 0) {
// On Windows, unlinking a locked/opened file will not work, so we just attempt the delete straight away.
// In the worst case, the unlink will just fail due to concurrent access and the caller needs to deal with that.
return unlink($fileName);
}
$file = fopen($fileName, 'rb');
if ($file === false) {
return false;
}
$result = false;
if (flock($file, LOCK_EX) !== false) {
$result = unlink($fileName);
flock($file, LOCK_UN);
}
fclose($file);
return $result;
} | php | private function tryRemoveWithLock(string $fileName): bool
{
if (strncasecmp(PHP_OS, 'WIN', 3) == 0) {
// On Windows, unlinking a locked/opened file will not work, so we just attempt the delete straight away.
// In the worst case, the unlink will just fail due to concurrent access and the caller needs to deal with that.
return unlink($fileName);
}
$file = fopen($fileName, 'rb');
if ($file === false) {
return false;
}
$result = false;
if (flock($file, LOCK_EX) !== false) {
$result = unlink($fileName);
flock($file, LOCK_UN);
}
fclose($file);
return $result;
} | [
"private",
"function",
"tryRemoveWithLock",
"(",
"string",
"$",
"fileName",
")",
":",
"bool",
"{",
"if",
"(",
"strncasecmp",
"(",
"PHP_OS",
",",
"'WIN'",
",",
"3",
")",
"==",
"0",
")",
"{",
"// On Windows, unlinking a locked/opened file will not work, so we just att... | Try to remove a file and make sure it is not locked.
@param string $fileName The full filename of the file to remove.
@return bool True if the file was removed successfully or false otherwise | [
"Try",
"to",
"remove",
"a",
"file",
"and",
"make",
"sure",
"it",
"is",
"not",
"locked",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Cache/Classes/Backend/SimpleFileBackend.php#L214-L234 |
neos/flow-development-collection | Neos.Cache/Classes/Backend/SimpleFileBackend.php | SimpleFileBackend.remove | public function remove(string $entryIdentifier): bool
{
if ($entryIdentifier !== basename($entryIdentifier)) {
throw new \InvalidArgumentException('The specified entry identifier must not contain a path segment.', 1334756960);
}
if ($entryIdentifier === '') {
throw new \InvalidArgumentException('The specified entry identifier must not be empty.', 1334756961);
}
$cacheEntryPathAndFilename = $this->cacheDirectory . $entryIdentifier . $this->cacheEntryFileExtension;
for ($i = 0; $i < 3; $i++) {
try {
$result = $this->tryRemoveWithLock($cacheEntryPathAndFilename);
if ($result === true) {
clearstatcache(true, $cacheEntryPathAndFilename);
return $result;
}
} catch (\Exception $e) {
}
usleep(rand(10, 500));
}
return false;
} | php | public function remove(string $entryIdentifier): bool
{
if ($entryIdentifier !== basename($entryIdentifier)) {
throw new \InvalidArgumentException('The specified entry identifier must not contain a path segment.', 1334756960);
}
if ($entryIdentifier === '') {
throw new \InvalidArgumentException('The specified entry identifier must not be empty.', 1334756961);
}
$cacheEntryPathAndFilename = $this->cacheDirectory . $entryIdentifier . $this->cacheEntryFileExtension;
for ($i = 0; $i < 3; $i++) {
try {
$result = $this->tryRemoveWithLock($cacheEntryPathAndFilename);
if ($result === true) {
clearstatcache(true, $cacheEntryPathAndFilename);
return $result;
}
} catch (\Exception $e) {
}
usleep(rand(10, 500));
}
return false;
} | [
"public",
"function",
"remove",
"(",
"string",
"$",
"entryIdentifier",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"entryIdentifier",
"!==",
"basename",
"(",
"$",
"entryIdentifier",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'The specifi... | Removes all cache entries matching the specified identifier.
Usually this only affects one entry.
@param string $entryIdentifier Specifies the cache entry to remove
@return boolean true if (at least) an entry could be removed or false if no entry was found
@throws \InvalidArgumentException
@api | [
"Removes",
"all",
"cache",
"entries",
"matching",
"the",
"specified",
"identifier",
".",
"Usually",
"this",
"only",
"affects",
"one",
"entry",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Cache/Classes/Backend/SimpleFileBackend.php#L245-L268 |
neos/flow-development-collection | Neos.Cache/Classes/Backend/SimpleFileBackend.php | SimpleFileBackend.findCacheFilesByIdentifier | protected function findCacheFilesByIdentifier(string $entryIdentifier)
{
$pathAndFilename = $this->cacheDirectory . $entryIdentifier . $this->cacheEntryFileExtension;
return (file_exists($pathAndFilename) ? [$pathAndFilename] : false);
} | php | protected function findCacheFilesByIdentifier(string $entryIdentifier)
{
$pathAndFilename = $this->cacheDirectory . $entryIdentifier . $this->cacheEntryFileExtension;
return (file_exists($pathAndFilename) ? [$pathAndFilename] : false);
} | [
"protected",
"function",
"findCacheFilesByIdentifier",
"(",
"string",
"$",
"entryIdentifier",
")",
"{",
"$",
"pathAndFilename",
"=",
"$",
"this",
"->",
"cacheDirectory",
".",
"$",
"entryIdentifier",
".",
"$",
"this",
"->",
"cacheEntryFileExtension",
";",
"return",
... | Tries to find the cache entry for the specified identifier.
@param string $entryIdentifier The cache entry identifier
@return mixed The filenames (including path) as an array if one or more entries could be found, otherwise false | [
"Tries",
"to",
"find",
"the",
"cache",
"entry",
"for",
"the",
"specified",
"identifier",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Cache/Classes/Backend/SimpleFileBackend.php#L311-L315 |
neos/flow-development-collection | Neos.Cache/Classes/Backend/SimpleFileBackend.php | SimpleFileBackend.requireOnce | public function requireOnce(string $entryIdentifier)
{
$pathAndFilename = $this->cacheDirectory . $entryIdentifier . $this->cacheEntryFileExtension;
if ($entryIdentifier !== basename($entryIdentifier)) {
throw new \InvalidArgumentException('The specified entry identifier (' . $entryIdentifier . ') must not contain a path segment.', 1282073036);
}
if (is_file($pathAndFilename)) {
return include_once($pathAndFilename);
}
return false;
} | php | public function requireOnce(string $entryIdentifier)
{
$pathAndFilename = $this->cacheDirectory . $entryIdentifier . $this->cacheEntryFileExtension;
if ($entryIdentifier !== basename($entryIdentifier)) {
throw new \InvalidArgumentException('The specified entry identifier (' . $entryIdentifier . ') must not contain a path segment.', 1282073036);
}
if (is_file($pathAndFilename)) {
return include_once($pathAndFilename);
}
return false;
} | [
"public",
"function",
"requireOnce",
"(",
"string",
"$",
"entryIdentifier",
")",
"{",
"$",
"pathAndFilename",
"=",
"$",
"this",
"->",
"cacheDirectory",
".",
"$",
"entryIdentifier",
".",
"$",
"this",
"->",
"cacheEntryFileExtension",
";",
"if",
"(",
"$",
"entryI... | Loads PHP code from the cache and include_onces it right away.
@param string $entryIdentifier An identifier which describes the cache entry to load
@return mixed Potential return value from the include operation
@throws \InvalidArgumentException
@api | [
"Loads",
"PHP",
"code",
"from",
"the",
"cache",
"and",
"include_onces",
"it",
"right",
"away",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Cache/Classes/Backend/SimpleFileBackend.php#L325-L336 |
neos/flow-development-collection | Neos.Cache/Classes/Backend/SimpleFileBackend.php | SimpleFileBackend.current | public function current()
{
if ($this->cacheFilesIterator === null) {
$this->rewind();
}
$pathAndFilename = $this->cacheFilesIterator->getPathname();
return $this->readCacheFile($pathAndFilename);
} | php | public function current()
{
if ($this->cacheFilesIterator === null) {
$this->rewind();
}
$pathAndFilename = $this->cacheFilesIterator->getPathname();
return $this->readCacheFile($pathAndFilename);
} | [
"public",
"function",
"current",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"cacheFilesIterator",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"rewind",
"(",
")",
";",
"}",
"$",
"pathAndFilename",
"=",
"$",
"this",
"->",
"cacheFilesIterator",
"->",
"g... | Returns the data of the current cache entry pointed to by the cache entry
iterator.
@return mixed
@api | [
"Returns",
"the",
"data",
"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/SimpleFileBackend.php#L345-L353 |
neos/flow-development-collection | Neos.Cache/Classes/Backend/SimpleFileBackend.php | SimpleFileBackend.next | public function next()
{
if ($this->cacheFilesIterator === null) {
$this->rewind();
}
$this->cacheFilesIterator->next();
while ($this->cacheFilesIterator->isDot() && $this->cacheFilesIterator->valid()) {
$this->cacheFilesIterator->next();
}
} | php | public function next()
{
if ($this->cacheFilesIterator === null) {
$this->rewind();
}
$this->cacheFilesIterator->next();
while ($this->cacheFilesIterator->isDot() && $this->cacheFilesIterator->valid()) {
$this->cacheFilesIterator->next();
}
} | [
"public",
"function",
"next",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"cacheFilesIterator",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"rewind",
"(",
")",
";",
"}",
"$",
"this",
"->",
"cacheFilesIterator",
"->",
"next",
"(",
")",
";",
"while",
... | Move forward to the next cache entry
@return void
@api | [
"Move",
"forward",
"to",
"the",
"next",
"cache",
"entry"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Cache/Classes/Backend/SimpleFileBackend.php#L361-L370 |
neos/flow-development-collection | Neos.Cache/Classes/Backend/SimpleFileBackend.php | SimpleFileBackend.key | public function key(): string
{
if ($this->cacheFilesIterator === null) {
$this->rewind();
}
return $this->cacheFilesIterator->getBasename($this->cacheEntryFileExtension);
} | php | public function key(): string
{
if ($this->cacheFilesIterator === null) {
$this->rewind();
}
return $this->cacheFilesIterator->getBasename($this->cacheEntryFileExtension);
} | [
"public",
"function",
"key",
"(",
")",
":",
"string",
"{",
"if",
"(",
"$",
"this",
"->",
"cacheFilesIterator",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"rewind",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"cacheFilesIterator",
"->",
"getBasena... | 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/SimpleFileBackend.php#L379-L385 |
neos/flow-development-collection | Neos.Cache/Classes/Backend/SimpleFileBackend.php | SimpleFileBackend.valid | public function valid(): bool
{
if ($this->cacheFilesIterator === null) {
$this->rewind();
}
return $this->cacheFilesIterator->valid();
} | php | public function valid(): bool
{
if ($this->cacheFilesIterator === null) {
$this->rewind();
}
return $this->cacheFilesIterator->valid();
} | [
"public",
"function",
"valid",
"(",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"this",
"->",
"cacheFilesIterator",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"rewind",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"cacheFilesIterator",
"->",
"valid",
... | Checks if the current position of the cache entry iterator is valid
@return boolean true if the current position is valid, otherwise false
@api | [
"Checks",
"if",
"the",
"current",
"position",
"of",
"the",
"cache",
"entry",
"iterator",
"is",
"valid"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Cache/Classes/Backend/SimpleFileBackend.php#L393-L399 |
neos/flow-development-collection | Neos.Cache/Classes/Backend/SimpleFileBackend.php | SimpleFileBackend.rewind | public function rewind()
{
if ($this->cacheFilesIterator === null) {
$this->cacheFilesIterator = new \DirectoryIterator($this->cacheDirectory);
}
$this->cacheFilesIterator->rewind();
while (substr($this->cacheFilesIterator->getFilename(), 0, 1) === '.' && $this->cacheFilesIterator->valid()) {
$this->cacheFilesIterator->next();
}
} | php | public function rewind()
{
if ($this->cacheFilesIterator === null) {
$this->cacheFilesIterator = new \DirectoryIterator($this->cacheDirectory);
}
$this->cacheFilesIterator->rewind();
while (substr($this->cacheFilesIterator->getFilename(), 0, 1) === '.' && $this->cacheFilesIterator->valid()) {
$this->cacheFilesIterator->next();
}
} | [
"public",
"function",
"rewind",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"cacheFilesIterator",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"cacheFilesIterator",
"=",
"new",
"\\",
"DirectoryIterator",
"(",
"$",
"this",
"->",
"cacheDirectory",
")",
";",
... | 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/SimpleFileBackend.php#L407-L416 |
neos/flow-development-collection | Neos.Cache/Classes/Backend/SimpleFileBackend.php | SimpleFileBackend.readCacheFile | protected function readCacheFile(string $cacheEntryPathAndFilename, int $offset = null, int $maxlen = null)
{
for ($i = 0; $i < 3; $i++) {
$data = false;
try {
$file = fopen($cacheEntryPathAndFilename, 'rb');
if ($file === false) {
continue;
}
if (flock($file, LOCK_SH) !== false) {
if ($offset !== null) {
fseek($file, $offset);
}
$data = fread($file, $maxlen !== null ? $maxlen : filesize($cacheEntryPathAndFilename) - (int)$offset);
flock($file, LOCK_UN);
}
fclose($file);
} catch (\Exception $e) {
}
if ($data !== false) {
return $data;
}
usleep(rand(10, 500));
}
return false;
} | php | protected function readCacheFile(string $cacheEntryPathAndFilename, int $offset = null, int $maxlen = null)
{
for ($i = 0; $i < 3; $i++) {
$data = false;
try {
$file = fopen($cacheEntryPathAndFilename, 'rb');
if ($file === false) {
continue;
}
if (flock($file, LOCK_SH) !== false) {
if ($offset !== null) {
fseek($file, $offset);
}
$data = fread($file, $maxlen !== null ? $maxlen : filesize($cacheEntryPathAndFilename) - (int)$offset);
flock($file, LOCK_UN);
}
fclose($file);
} catch (\Exception $e) {
}
if ($data !== false) {
return $data;
}
usleep(rand(10, 500));
}
return false;
} | [
"protected",
"function",
"readCacheFile",
"(",
"string",
"$",
"cacheEntryPathAndFilename",
",",
"int",
"$",
"offset",
"=",
"null",
",",
"int",
"$",
"maxlen",
"=",
"null",
")",
"{",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"3",
";",
"$",
... | Reads the cache data from the given cache file, using locking.
@param string $cacheEntryPathAndFilename
@param int|null $offset
@param int|null $maxlen
@return boolean|string The contents of the cache file or false on error | [
"Reads",
"the",
"cache",
"data",
"from",
"the",
"given",
"cache",
"file",
"using",
"locking",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Cache/Classes/Backend/SimpleFileBackend.php#L491-L518 |
neos/flow-development-collection | Neos.Cache/Classes/Backend/SimpleFileBackend.php | SimpleFileBackend.writeCacheFile | protected function writeCacheFile(string $cacheEntryPathAndFilename, string $data)
{
for ($i = 0; $i < 3; $i++) {
// This can be replaced by a simple file_put_contents($cacheEntryPathAndFilename, $data, LOCK_EX) once vfs
// is fixed for file_put_contents with LOCK_EX, see https://github.com/mikey179/vfsStream/wiki/Known-Issues
$result = false;
try {
$file = fopen($cacheEntryPathAndFilename, 'wb');
if ($file === false) {
continue;
}
if (flock($file, LOCK_EX) !== false) {
$result = fwrite($file, $data);
flock($file, LOCK_UN);
}
fclose($file);
} catch (\Exception $e) {
}
if ($result !== false) {
clearstatcache(true, $cacheEntryPathAndFilename);
return $result;
}
usleep(rand(10, 500));
}
return false;
} | php | protected function writeCacheFile(string $cacheEntryPathAndFilename, string $data)
{
for ($i = 0; $i < 3; $i++) {
// This can be replaced by a simple file_put_contents($cacheEntryPathAndFilename, $data, LOCK_EX) once vfs
// is fixed for file_put_contents with LOCK_EX, see https://github.com/mikey179/vfsStream/wiki/Known-Issues
$result = false;
try {
$file = fopen($cacheEntryPathAndFilename, 'wb');
if ($file === false) {
continue;
}
if (flock($file, LOCK_EX) !== false) {
$result = fwrite($file, $data);
flock($file, LOCK_UN);
}
fclose($file);
} catch (\Exception $e) {
}
if ($result !== false) {
clearstatcache(true, $cacheEntryPathAndFilename);
return $result;
}
usleep(rand(10, 500));
}
return false;
} | [
"protected",
"function",
"writeCacheFile",
"(",
"string",
"$",
"cacheEntryPathAndFilename",
",",
"string",
"$",
"data",
")",
"{",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"3",
";",
"$",
"i",
"++",
")",
"{",
"// This can be replaced by a simple f... | Writes the cache data into the given cache file, using locking.
@param string $cacheEntryPathAndFilename
@param string $data
@return boolean|integer Return value of file_put_contents | [
"Writes",
"the",
"cache",
"data",
"into",
"the",
"given",
"cache",
"file",
"using",
"locking",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Cache/Classes/Backend/SimpleFileBackend.php#L527-L553 |
neos/flow-development-collection | Neos.Cache/Classes/Backend/SimpleFileBackend.php | SimpleFileBackend.setup | public function setup(): Result
{
$result = new Result();
try {
$this->configureCacheDirectory();
} catch (Exception $exception) {
$result->addError(new Error('Failed to configure cache directory: %s', $exception->getCode(), [$exception->getMessage()], 'Cache Directory'));
}
return $result;
} | php | public function setup(): Result
{
$result = new Result();
try {
$this->configureCacheDirectory();
} catch (Exception $exception) {
$result->addError(new Error('Failed to configure cache directory: %s', $exception->getCode(), [$exception->getMessage()], 'Cache Directory'));
}
return $result;
} | [
"public",
"function",
"setup",
"(",
")",
":",
"Result",
"{",
"$",
"result",
"=",
"new",
"Result",
"(",
")",
";",
"try",
"{",
"$",
"this",
"->",
"configureCacheDirectory",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"exception",
")",
"{",
"$",... | Sets up this backend by creating the required cache directory if it doesn't exist yet
@return Result
@api | [
"Sets",
"up",
"this",
"backend",
"by",
"creating",
"the",
"required",
"cache",
"directory",
"if",
"it",
"doesn",
"t",
"exist",
"yet"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Cache/Classes/Backend/SimpleFileBackend.php#L561-L570 |
neos/flow-development-collection | Neos.Cache/Classes/Backend/SimpleFileBackend.php | SimpleFileBackend.getStatus | public function getStatus(): Result
{
$result = new Result();
try {
$this->verifyCacheDirectory();
} catch (Exception $exception) {
$result->addError(new Error($exception->getMessage(), $exception->getCode(), [], 'Cache Directory'));
return $result;
}
$result->addNotice(new Notice($this->baseDirectory ?? '-', null, [], 'Base Directory'));
$result->addNotice(new Notice($this->getCacheDirectory(), null, [], 'Cache Directory'));
return $result;
} | php | public function getStatus(): Result
{
$result = new Result();
try {
$this->verifyCacheDirectory();
} catch (Exception $exception) {
$result->addError(new Error($exception->getMessage(), $exception->getCode(), [], 'Cache Directory'));
return $result;
}
$result->addNotice(new Notice($this->baseDirectory ?? '-', null, [], 'Base Directory'));
$result->addNotice(new Notice($this->getCacheDirectory(), null, [], 'Cache Directory'));
return $result;
} | [
"public",
"function",
"getStatus",
"(",
")",
":",
"Result",
"{",
"$",
"result",
"=",
"new",
"Result",
"(",
")",
";",
"try",
"{",
"$",
"this",
"->",
"verifyCacheDirectory",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"exception",
")",
"{",
"$"... | Validates that the configured cache directory exists and is writeable and returns some details about its configuration if that's the case
@return Result
@api | [
"Validates",
"that",
"the",
"configured",
"cache",
"directory",
"exists",
"and",
"is",
"writeable",
"and",
"returns",
"some",
"details",
"about",
"its",
"configuration",
"if",
"that",
"s",
"the",
"case"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Cache/Classes/Backend/SimpleFileBackend.php#L578-L590 |
neos/flow-development-collection | Neos.Flow/Classes/Security/Policy/Role.php | Role.setParentRoles | public function setParentRoles(array $parentRoles)
{
$this->parentRoles = [];
foreach ($parentRoles as $parentRole) {
$this->addParentRole($parentRole);
}
} | php | public function setParentRoles(array $parentRoles)
{
$this->parentRoles = [];
foreach ($parentRoles as $parentRole) {
$this->addParentRole($parentRole);
}
} | [
"public",
"function",
"setParentRoles",
"(",
"array",
"$",
"parentRoles",
")",
"{",
"$",
"this",
"->",
"parentRoles",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"parentRoles",
"as",
"$",
"parentRole",
")",
"{",
"$",
"this",
"->",
"addParentRole",
"(",
"$",... | Assign parent roles to this role.
@param Role[] $parentRoles indexed by role identifier
@return void | [
"Assign",
"parent",
"roles",
"to",
"this",
"role",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Policy/Role.php#L137-L143 |
neos/flow-development-collection | Neos.Flow/Classes/Security/Policy/Role.php | Role.getAllParentRoles | public function getAllParentRoles()
{
$reducer = function (array $result, Role $role) {
$result[$role->getIdentifier()] = $role;
return array_merge($result, $role->getAllParentRoles());
};
return array_reduce($this->parentRoles, $reducer, []);
} | php | public function getAllParentRoles()
{
$reducer = function (array $result, Role $role) {
$result[$role->getIdentifier()] = $role;
return array_merge($result, $role->getAllParentRoles());
};
return array_reduce($this->parentRoles, $reducer, []);
} | [
"public",
"function",
"getAllParentRoles",
"(",
")",
"{",
"$",
"reducer",
"=",
"function",
"(",
"array",
"$",
"result",
",",
"Role",
"$",
"role",
")",
"{",
"$",
"result",
"[",
"$",
"role",
"->",
"getIdentifier",
"(",
")",
"]",
"=",
"$",
"role",
";",
... | Returns all (directly and indirectly reachable) parent roles for the given role.
@return Role[] Array of parent roles, indexed by role identifier | [
"Returns",
"all",
"(",
"directly",
"and",
"indirectly",
"reachable",
")",
"parent",
"roles",
"for",
"the",
"given",
"role",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Policy/Role.php#L160-L168 |
neos/flow-development-collection | Neos.Flow/Classes/Security/Policy/Role.php | Role.addParentRole | public function addParentRole(Role $parentRole)
{
if (!$this->hasParentRole($parentRole)) {
$parentRoleIdentifier = $parentRole->getIdentifier();
$this->parentRoles[$parentRoleIdentifier] = $parentRole;
}
} | php | public function addParentRole(Role $parentRole)
{
if (!$this->hasParentRole($parentRole)) {
$parentRoleIdentifier = $parentRole->getIdentifier();
$this->parentRoles[$parentRoleIdentifier] = $parentRole;
}
} | [
"public",
"function",
"addParentRole",
"(",
"Role",
"$",
"parentRole",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasParentRole",
"(",
"$",
"parentRole",
")",
")",
"{",
"$",
"parentRoleIdentifier",
"=",
"$",
"parentRole",
"->",
"getIdentifier",
"(",
")"... | Add a (direct) parent role to this role.
@param Role $parentRole
@return void | [
"Add",
"a",
"(",
"direct",
")",
"parent",
"role",
"to",
"this",
"role",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Policy/Role.php#L176-L182 |
neos/flow-development-collection | Neos.Flow/Classes/Security/Policy/Role.php | Role.setPrivileges | public function setPrivileges(array $privileges)
{
foreach ($privileges as $privilege) {
$this->privileges[$privilege->getCacheEntryIdentifier()] = $privilege;
}
} | php | public function setPrivileges(array $privileges)
{
foreach ($privileges as $privilege) {
$this->privileges[$privilege->getCacheEntryIdentifier()] = $privilege;
}
} | [
"public",
"function",
"setPrivileges",
"(",
"array",
"$",
"privileges",
")",
"{",
"foreach",
"(",
"$",
"privileges",
"as",
"$",
"privilege",
")",
"{",
"$",
"this",
"->",
"privileges",
"[",
"$",
"privilege",
"->",
"getCacheEntryIdentifier",
"(",
")",
"]",
"... | Assign privileges to this role.
@param PrivilegeInterface[] $privileges
@return void | [
"Assign",
"privileges",
"to",
"this",
"role",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Policy/Role.php#L201-L206 |
neos/flow-development-collection | Neos.Flow/Classes/Http/Helper/ResponseInformationHelper.php | ResponseInformationHelper.createFromRaw | public static function createFromRaw(string $rawResponse, string $responseClassName = Response::class): ResponseInterface
{
$response = new $responseClassName();
if (!$response instanceof ResponseInterface) {
throw new \InvalidArgumentException(sprintf('The given response class name "%s" does not implement the "%s" and cannot be created with this method.', $responseClassName, ResponseInterface::class));
}
// see https://tools.ietf.org/html/rfc7230#section-3.5
$lines = explode(chr(10), $rawResponse);
$statusLine = array_shift($lines);
if (substr($statusLine, 0, 5) !== 'HTTP/') {
throw new \InvalidArgumentException('The given raw HTTP message is not a valid response.', 1335175601);
}
list($httpAndVersion, $statusCode, $reasonPhrase) = explode(' ', $statusLine, 3);
$version = explode('/', $httpAndVersion)[1];
if (strlen($statusCode) !== 3) {
// See https://tools.ietf.org/html/rfc7230#section-3.1.2
throw new \InvalidArgumentException('The given raw HTTP message contains an invalid status code.', 1502981352);
}
$response = $response->withStatus((integer)$statusCode, trim($reasonPhrase));
$response = $response->withProtocolVersion($version);
$parsingHeader = true;
$contentLines = [];
$headers = new Headers();
foreach ($lines as $line) {
if ($parsingHeader) {
if (trim($line) === '') {
$parsingHeader = false;
continue;
}
$headerSeparatorIndex = strpos($line, ':');
if ($headerSeparatorIndex === false) {
throw new \InvalidArgumentException('The given raw HTTP message contains an invalid header.', 1502984804);
}
$fieldName = trim(substr($line, 0, $headerSeparatorIndex));
$fieldValue = trim(substr($line, strlen($fieldName) + 1));
if (strtoupper(substr($fieldName, 0, 10)) === 'SET-COOKIE') {
$cookie = Cookie::createFromRawSetCookieHeader($fieldValue);
if ($cookie !== null) {
$headers->setCookie($cookie);
}
} else {
$headers->set($fieldName, $fieldValue, false);
}
} else {
$contentLines[] = $line;
}
}
if ($parsingHeader === true) {
throw new \InvalidArgumentException('The given raw HTTP message contains no separating empty line between header and body.', 1502984823);
}
$content = implode(chr(10), $contentLines);
$response->setHeaders($headers);
$response = $response->withBody(ArgumentsHelper::createContentStreamFromString($content));
return $response;
} | php | public static function createFromRaw(string $rawResponse, string $responseClassName = Response::class): ResponseInterface
{
$response = new $responseClassName();
if (!$response instanceof ResponseInterface) {
throw new \InvalidArgumentException(sprintf('The given response class name "%s" does not implement the "%s" and cannot be created with this method.', $responseClassName, ResponseInterface::class));
}
// see https://tools.ietf.org/html/rfc7230#section-3.5
$lines = explode(chr(10), $rawResponse);
$statusLine = array_shift($lines);
if (substr($statusLine, 0, 5) !== 'HTTP/') {
throw new \InvalidArgumentException('The given raw HTTP message is not a valid response.', 1335175601);
}
list($httpAndVersion, $statusCode, $reasonPhrase) = explode(' ', $statusLine, 3);
$version = explode('/', $httpAndVersion)[1];
if (strlen($statusCode) !== 3) {
// See https://tools.ietf.org/html/rfc7230#section-3.1.2
throw new \InvalidArgumentException('The given raw HTTP message contains an invalid status code.', 1502981352);
}
$response = $response->withStatus((integer)$statusCode, trim($reasonPhrase));
$response = $response->withProtocolVersion($version);
$parsingHeader = true;
$contentLines = [];
$headers = new Headers();
foreach ($lines as $line) {
if ($parsingHeader) {
if (trim($line) === '') {
$parsingHeader = false;
continue;
}
$headerSeparatorIndex = strpos($line, ':');
if ($headerSeparatorIndex === false) {
throw new \InvalidArgumentException('The given raw HTTP message contains an invalid header.', 1502984804);
}
$fieldName = trim(substr($line, 0, $headerSeparatorIndex));
$fieldValue = trim(substr($line, strlen($fieldName) + 1));
if (strtoupper(substr($fieldName, 0, 10)) === 'SET-COOKIE') {
$cookie = Cookie::createFromRawSetCookieHeader($fieldValue);
if ($cookie !== null) {
$headers->setCookie($cookie);
}
} else {
$headers->set($fieldName, $fieldValue, false);
}
} else {
$contentLines[] = $line;
}
}
if ($parsingHeader === true) {
throw new \InvalidArgumentException('The given raw HTTP message contains no separating empty line between header and body.', 1502984823);
}
$content = implode(chr(10), $contentLines);
$response->setHeaders($headers);
$response = $response->withBody(ArgumentsHelper::createContentStreamFromString($content));
return $response;
} | [
"public",
"static",
"function",
"createFromRaw",
"(",
"string",
"$",
"rawResponse",
",",
"string",
"$",
"responseClassName",
"=",
"Response",
"::",
"class",
")",
":",
"ResponseInterface",
"{",
"$",
"response",
"=",
"new",
"$",
"responseClassName",
"(",
")",
";... | Creates a response from the given raw, that is plain text, HTTP response.
@param string $rawResponse
@throws \InvalidArgumentException
@return ResponseInterface | [
"Creates",
"a",
"response",
"from",
"the",
"given",
"raw",
"that",
"is",
"plain",
"text",
"HTTP",
"response",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Http/Helper/ResponseInformationHelper.php#L33-L93 |
neos/flow-development-collection | Neos.Flow/Classes/Http/Helper/ResponseInformationHelper.php | ResponseInformationHelper.generateStatusLine | public static function generateStatusLine(ResponseInterface $response): string
{
return sprintf("HTTP/%s %s %s\r\n", $response->getProtocolVersion(), $response->getStatusCode(), $response->getReasonPhrase());
} | php | public static function generateStatusLine(ResponseInterface $response): string
{
return sprintf("HTTP/%s %s %s\r\n", $response->getProtocolVersion(), $response->getStatusCode(), $response->getReasonPhrase());
} | [
"public",
"static",
"function",
"generateStatusLine",
"(",
"ResponseInterface",
"$",
"response",
")",
":",
"string",
"{",
"return",
"sprintf",
"(",
"\"HTTP/%s %s %s\\r\\n\"",
",",
"$",
"response",
"->",
"getProtocolVersion",
"(",
")",
",",
"$",
"response",
"->",
... | Return the Request-Line of this Request Message, consisting of the method, the URI and the HTTP version
Would be, for example, "GET /foo?bar=baz HTTP/1.1"
Note that the URI part is, at the moment, only possible in the form "abs_path" since the
actual requestUri of the Request cannot be determined during the creation of the Request.
@param ResponseInterface $response
@return string
@see http://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html#sec6.1 | [
"Return",
"the",
"Request",
"-",
"Line",
"of",
"this",
"Request",
"Message",
"consisting",
"of",
"the",
"method",
"the",
"URI",
"and",
"the",
"HTTP",
"version",
"Would",
"be",
"for",
"example",
"GET",
"/",
"foo?bar",
"=",
"baz",
"HTTP",
"/",
"1",
".",
... | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Http/Helper/ResponseInformationHelper.php#L164-L167 |
neos/flow-development-collection | Neos.Flow/Classes/Http/Helper/ResponseInformationHelper.php | ResponseInformationHelper.prepareHeaders | public static function prepareHeaders(ResponseInterface $response): array
{
$preparedHeaders = [];
$statusHeader = rtrim(self::generateStatusLine($response), "\r\n");
$preparedHeaders[] = $statusHeader;
$headers = $response->getHeaders();
if ($headers instanceof Headers) {
$preparedHeaders = array_merge($preparedHeaders, $headers->getPreparedValues());
} else {
foreach (array_keys($headers) as $name) {
$preparedHeaders[] = $response->getHeaderLine($name);
}
}
return $preparedHeaders;
} | php | public static function prepareHeaders(ResponseInterface $response): array
{
$preparedHeaders = [];
$statusHeader = rtrim(self::generateStatusLine($response), "\r\n");
$preparedHeaders[] = $statusHeader;
$headers = $response->getHeaders();
if ($headers instanceof Headers) {
$preparedHeaders = array_merge($preparedHeaders, $headers->getPreparedValues());
} else {
foreach (array_keys($headers) as $name) {
$preparedHeaders[] = $response->getHeaderLine($name);
}
}
return $preparedHeaders;
} | [
"public",
"static",
"function",
"prepareHeaders",
"(",
"ResponseInterface",
"$",
"response",
")",
":",
"array",
"{",
"$",
"preparedHeaders",
"=",
"[",
"]",
";",
"$",
"statusHeader",
"=",
"rtrim",
"(",
"self",
"::",
"generateStatusLine",
"(",
"$",
"response",
... | Prepare array of header lines for this response
@param ResponseInterface $response
@return array | [
"Prepare",
"array",
"of",
"header",
"lines",
"for",
"this",
"response"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Http/Helper/ResponseInformationHelper.php#L175-L191 |
neos/flow-development-collection | Neos.Flow/Classes/Http/Helper/ResponseInformationHelper.php | ResponseInformationHelper.makeStandardsCompliant | public static function makeStandardsCompliant(ResponseInterface $response, RequestInterface $request): ResponseInterface
{
$statusCode = $response->getStatusCode();
if ($request->hasHeader('If-Modified-Since') && $response->hasHeader('Last-Modified') && $statusCode === 200) {
$ifModifiedSince = $request->getHeader('If-Modified-Since');
$ifModifiedSinceDate = is_array($ifModifiedSince) ? reset($ifModifiedSince) : $ifModifiedSince;
$lastModified = $response->getHeader('Last-Modified');
$lastModifiedDate = is_array($lastModified) ? reset($lastModified) : $lastModified;
if ($lastModifiedDate <= $ifModifiedSinceDate) {
$response = $response->withStatus(304);
}
} elseif ($request->hasHeader('If-Unmodified-Since') && $response->hasHeader('Last-Modified')
&& (($statusCode >= 200 && $$statusCode <= 299) || $statusCode === 412)) {
$unmodifiedSince = $request->getHeader('If-Unmodified-Since');
$unmodifiedSinceDate = is_array($unmodifiedSince) ? reset($unmodifiedSince) : $unmodifiedSince;
$lastModified = $response->getHeader('Last-Modified');
$lastModifiedDate = is_array($lastModified) ? reset($lastModified) : $lastModified;
if ($lastModifiedDate > $unmodifiedSinceDate) {
$response = $response->withStatus(412);
}
}
if (in_array($response->getStatusCode(), [100, 101, 204, 304])) {
$response = $response->withBody(ArgumentsHelper::createContentStreamFromString(''));
}
$cacheControlHeaderLine = $response->getHeaderLine('Cache-Control');
if (!empty($cacheControlHeaderLine) && strpos('no-cache', $cacheControlHeaderLine) !== false || $response->hasHeader('Expires')) {
$cacheControlHeaderValue = trim(substr($cacheControlHeaderLine, 14));
$cacheControlHeaderValue = str_replace('max-age', '', $cacheControlHeaderValue);
$cacheControlHeaderValue = trim($cacheControlHeaderValue, ' ,');
$response = $response->withHeader('Cache-Control', $cacheControlHeaderValue);
}
if (!$response->hasHeader('Content-Length')) {
$response = $response->withHeader('Content-Length', $response->getBody()->getSize());
}
if ($request->getMethod() === 'HEAD') {
$response = $response->withBody(ArgumentsHelper::createContentStreamFromString(''));
}
if ($response->hasHeader('Transfer-Encoding')) {
$response = $response->withoutHeader('Content-Length');
}
return $response;
} | php | public static function makeStandardsCompliant(ResponseInterface $response, RequestInterface $request): ResponseInterface
{
$statusCode = $response->getStatusCode();
if ($request->hasHeader('If-Modified-Since') && $response->hasHeader('Last-Modified') && $statusCode === 200) {
$ifModifiedSince = $request->getHeader('If-Modified-Since');
$ifModifiedSinceDate = is_array($ifModifiedSince) ? reset($ifModifiedSince) : $ifModifiedSince;
$lastModified = $response->getHeader('Last-Modified');
$lastModifiedDate = is_array($lastModified) ? reset($lastModified) : $lastModified;
if ($lastModifiedDate <= $ifModifiedSinceDate) {
$response = $response->withStatus(304);
}
} elseif ($request->hasHeader('If-Unmodified-Since') && $response->hasHeader('Last-Modified')
&& (($statusCode >= 200 && $$statusCode <= 299) || $statusCode === 412)) {
$unmodifiedSince = $request->getHeader('If-Unmodified-Since');
$unmodifiedSinceDate = is_array($unmodifiedSince) ? reset($unmodifiedSince) : $unmodifiedSince;
$lastModified = $response->getHeader('Last-Modified');
$lastModifiedDate = is_array($lastModified) ? reset($lastModified) : $lastModified;
if ($lastModifiedDate > $unmodifiedSinceDate) {
$response = $response->withStatus(412);
}
}
if (in_array($response->getStatusCode(), [100, 101, 204, 304])) {
$response = $response->withBody(ArgumentsHelper::createContentStreamFromString(''));
}
$cacheControlHeaderLine = $response->getHeaderLine('Cache-Control');
if (!empty($cacheControlHeaderLine) && strpos('no-cache', $cacheControlHeaderLine) !== false || $response->hasHeader('Expires')) {
$cacheControlHeaderValue = trim(substr($cacheControlHeaderLine, 14));
$cacheControlHeaderValue = str_replace('max-age', '', $cacheControlHeaderValue);
$cacheControlHeaderValue = trim($cacheControlHeaderValue, ' ,');
$response = $response->withHeader('Cache-Control', $cacheControlHeaderValue);
}
if (!$response->hasHeader('Content-Length')) {
$response = $response->withHeader('Content-Length', $response->getBody()->getSize());
}
if ($request->getMethod() === 'HEAD') {
$response = $response->withBody(ArgumentsHelper::createContentStreamFromString(''));
}
if ($response->hasHeader('Transfer-Encoding')) {
$response = $response->withoutHeader('Content-Length');
}
return $response;
} | [
"public",
"static",
"function",
"makeStandardsCompliant",
"(",
"ResponseInterface",
"$",
"response",
",",
"RequestInterface",
"$",
"request",
")",
":",
"ResponseInterface",
"{",
"$",
"statusCode",
"=",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
";",
"if",
... | Analyzes this response, considering the given request and makes additions
or removes certain headers in order to make the response compliant to
RFC 2616 and related standards.
It is recommended to call this method before the response is sent and Flow
does so by default in its built-in HTTP request handler.
@param ResponseInterface $response
@param RequestInterface $request The corresponding request
@return ResponseInterface
@api | [
"Analyzes",
"this",
"response",
"considering",
"the",
"given",
"request",
"and",
"makes",
"additions",
"or",
"removes",
"certain",
"headers",
"in",
"order",
"to",
"make",
"the",
"response",
"compliant",
"to",
"RFC",
"2616",
"and",
"related",
"standards",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Http/Helper/ResponseInformationHelper.php#L206-L254 |
neos/flow-development-collection | Neos.FluidAdaptor/Classes/Service/AbstractGenerator.php | AbstractGenerator.getClassNamesInNamespace | protected function getClassNamesInNamespace($namespace)
{
$affectedViewHelperClassNames = [];
$allViewHelperClassNames = $this->reflectionService->getAllSubClassNamesForClass(AbstractViewHelper::class);
foreach ($allViewHelperClassNames as $viewHelperClassName) {
if ($this->reflectionService->isClassAbstract($viewHelperClassName)) {
continue;
}
if (strncmp($namespace, $viewHelperClassName, strlen($namespace)) === 0) {
$affectedViewHelperClassNames[] = $viewHelperClassName;
}
}
sort($affectedViewHelperClassNames);
return $affectedViewHelperClassNames;
} | php | protected function getClassNamesInNamespace($namespace)
{
$affectedViewHelperClassNames = [];
$allViewHelperClassNames = $this->reflectionService->getAllSubClassNamesForClass(AbstractViewHelper::class);
foreach ($allViewHelperClassNames as $viewHelperClassName) {
if ($this->reflectionService->isClassAbstract($viewHelperClassName)) {
continue;
}
if (strncmp($namespace, $viewHelperClassName, strlen($namespace)) === 0) {
$affectedViewHelperClassNames[] = $viewHelperClassName;
}
}
sort($affectedViewHelperClassNames);
return $affectedViewHelperClassNames;
} | [
"protected",
"function",
"getClassNamesInNamespace",
"(",
"$",
"namespace",
")",
"{",
"$",
"affectedViewHelperClassNames",
"=",
"[",
"]",
";",
"$",
"allViewHelperClassNames",
"=",
"$",
"this",
"->",
"reflectionService",
"->",
"getAllSubClassNamesForClass",
"(",
"Abstr... | Get all class names inside this namespace and return them as array.
@param string $namespace
@return array Array of all class names inside a given namespace. | [
"Get",
"all",
"class",
"names",
"inside",
"this",
"namespace",
"and",
"return",
"them",
"as",
"array",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.FluidAdaptor/Classes/Service/AbstractGenerator.php#L59-L74 |
neos/flow-development-collection | Neos.FluidAdaptor/Classes/Service/AbstractGenerator.php | AbstractGenerator.getTagNameForClass | protected function getTagNameForClass($className, $namespace)
{
$strippedClassName = substr($className, strlen($namespace));
$classNameParts = explode('\\', $strippedClassName);
if (count($classNameParts) == 1) {
$tagName = lcfirst(substr($classNameParts[0], 0, -10)); // strip the "ViewHelper" ending
} else {
$tagName = lcfirst($classNameParts[0]) . '.' . lcfirst(substr($classNameParts[1], 0, -10));
}
return $tagName;
} | php | protected function getTagNameForClass($className, $namespace)
{
$strippedClassName = substr($className, strlen($namespace));
$classNameParts = explode('\\', $strippedClassName);
if (count($classNameParts) == 1) {
$tagName = lcfirst(substr($classNameParts[0], 0, -10)); // strip the "ViewHelper" ending
} else {
$tagName = lcfirst($classNameParts[0]) . '.' . lcfirst(substr($classNameParts[1], 0, -10));
}
return $tagName;
} | [
"protected",
"function",
"getTagNameForClass",
"(",
"$",
"className",
",",
"$",
"namespace",
")",
"{",
"$",
"strippedClassName",
"=",
"substr",
"(",
"$",
"className",
",",
"strlen",
"(",
"$",
"namespace",
")",
")",
";",
"$",
"classNameParts",
"=",
"explode",... | Get a tag name for a given ViewHelper class.
Example: For the View Helper Neos\FluidAdaptor\ViewHelpers\Form\SelectViewHelper, and the
namespace prefix Neos\FluidAdaptor\ViewHelpers\, this method returns "form.select".
@param string $className Class name
@param string $namespace Base namespace to use
@return string Tag name | [
"Get",
"a",
"tag",
"name",
"for",
"a",
"given",
"ViewHelper",
"class",
".",
"Example",
":",
"For",
"the",
"View",
"Helper",
"Neos",
"\\",
"FluidAdaptor",
"\\",
"ViewHelpers",
"\\",
"Form",
"\\",
"SelectViewHelper",
"and",
"the",
"namespace",
"prefix",
"Neos"... | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.FluidAdaptor/Classes/Service/AbstractGenerator.php#L85-L96 |
neos/flow-development-collection | Neos.Flow/Classes/Validation/Validator/CountValidator.php | CountValidator.isValid | protected function isValid($value)
{
if (!is_array($value) && !($value instanceof \Countable)) {
$this->addError('The given subject was not countable.', 1253718666);
return;
}
$minimum = intval($this->options['minimum']);
$maximum = intval($this->options['maximum']);
if (count($value) < $minimum || count($value) > $maximum) {
$this->addError('The count must be between %1$d and %2$d.', 1253718831, [$minimum, $maximum]);
}
} | php | protected function isValid($value)
{
if (!is_array($value) && !($value instanceof \Countable)) {
$this->addError('The given subject was not countable.', 1253718666);
return;
}
$minimum = intval($this->options['minimum']);
$maximum = intval($this->options['maximum']);
if (count($value) < $minimum || count($value) > $maximum) {
$this->addError('The count must be between %1$d and %2$d.', 1253718831, [$minimum, $maximum]);
}
} | [
"protected",
"function",
"isValid",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"value",
")",
"&&",
"!",
"(",
"$",
"value",
"instanceof",
"\\",
"Countable",
")",
")",
"{",
"$",
"this",
"->",
"addError",
"(",
"'The given subject w... | The given value is valid if it is an array or \Countable that contains the specified amount of elements.
@param mixed $value The value that should be validated
@return void
@api | [
"The",
"given",
"value",
"is",
"valid",
"if",
"it",
"is",
"an",
"array",
"or",
"\\",
"Countable",
"that",
"contains",
"the",
"specified",
"amount",
"of",
"elements",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Validation/Validator/CountValidator.php#L37-L49 |
neos/flow-development-collection | Neos.Flow/Classes/I18n/Xliff/Model/FileAdapter.php | FileAdapter.getTargetBySource | public function getTargetBySource($source, $pluralFormIndex = 0)
{
if (empty($this->fileData['translationUnits'])) {
$this->i18nLogger->debug(sprintf('No trans-unit elements were found in "%s". This is allowed per specification, but no translation can be applied then.', $this->fileData['fileIdentifier']));
return false;
}
foreach ($this->fileData['translationUnits'] as $translationUnit) {
// $source is always singular (or only) form, so compare with index 0
if (!isset($translationUnit[0]) || $translationUnit[0]['source'] !== $source) {
continue;
}
if (count($translationUnit) <= $pluralFormIndex) {
$this->i18nLogger->debug('The plural form index "' . $pluralFormIndex . '" for the source translation "' . $source . '" in ' . $this->fileData['fileIdentifier'] . ' is not available.');
return false;
}
return $translationUnit[$pluralFormIndex]['target'] ?: false;
}
return false;
} | php | public function getTargetBySource($source, $pluralFormIndex = 0)
{
if (empty($this->fileData['translationUnits'])) {
$this->i18nLogger->debug(sprintf('No trans-unit elements were found in "%s". This is allowed per specification, but no translation can be applied then.', $this->fileData['fileIdentifier']));
return false;
}
foreach ($this->fileData['translationUnits'] as $translationUnit) {
// $source is always singular (or only) form, so compare with index 0
if (!isset($translationUnit[0]) || $translationUnit[0]['source'] !== $source) {
continue;
}
if (count($translationUnit) <= $pluralFormIndex) {
$this->i18nLogger->debug('The plural form index "' . $pluralFormIndex . '" for the source translation "' . $source . '" in ' . $this->fileData['fileIdentifier'] . ' is not available.');
return false;
}
return $translationUnit[$pluralFormIndex]['target'] ?: false;
}
return false;
} | [
"public",
"function",
"getTargetBySource",
"(",
"$",
"source",
",",
"$",
"pluralFormIndex",
"=",
"0",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"fileData",
"[",
"'translationUnits'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"i18nLogger",
"->",
... | Returns translated label ("target" tag in XLIFF) from source-target
pair where "source" tag equals to $source parameter.
@param string $source Label in original language ("source" tag in XLIFF)
@param integer $pluralFormIndex Index of plural form to use (starts with 0)
@return mixed Translated label or false on failure | [
"Returns",
"translated",
"label",
"(",
"target",
"tag",
"in",
"XLIFF",
")",
"from",
"source",
"-",
"target",
"pair",
"where",
"source",
"tag",
"equals",
"to",
"$source",
"parameter",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/I18n/Xliff/Model/FileAdapter.php#L75-L98 |
neos/flow-development-collection | Neos.Flow/Classes/I18n/Xliff/Model/FileAdapter.php | FileAdapter.getTargetByTransUnitId | public function getTargetByTransUnitId($transUnitId, $pluralFormIndex = 0)
{
if (!isset($this->fileData['translationUnits'][$transUnitId])) {
$this->i18nLogger->debug('No trans-unit element with the id "' . $transUnitId . '" was found in ' . $this->fileData['fileIdentifier'] . '. Either this translation has been removed or the id in the code or template referring to the translation is wrong.');
return false;
}
if (!isset($this->fileData['translationUnits'][$transUnitId][$pluralFormIndex])) {
$this->i18nLogger->debug('The plural form index "' . $pluralFormIndex . '" for the trans-unit element with the id "' . $transUnitId . '" in ' . $this->fileData['fileIdentifier'] . ' is not available.');
return false;
}
if ($this->fileData['translationUnits'][$transUnitId][$pluralFormIndex]['target']) {
return $this->fileData['translationUnits'][$transUnitId][$pluralFormIndex]['target'];
} elseif ($this->requestedLocale->getLanguage() === $this->fileData['sourceLocale']->getLanguage()) {
return $this->fileData['translationUnits'][$transUnitId][$pluralFormIndex]['source'] ?: false;
} else {
$this->i18nLogger->debug('The target translation was empty and the source translation language (' . $this->fileData['sourceLocale']->getLanguage() . ') does not match the current locale (' . $this->requestedLocale->getLanguage() . ') for the trans-unit element with the id "' . $transUnitId . '" in ' . $this->fileData['fileIdentifier']);
return false;
}
} | php | public function getTargetByTransUnitId($transUnitId, $pluralFormIndex = 0)
{
if (!isset($this->fileData['translationUnits'][$transUnitId])) {
$this->i18nLogger->debug('No trans-unit element with the id "' . $transUnitId . '" was found in ' . $this->fileData['fileIdentifier'] . '. Either this translation has been removed or the id in the code or template referring to the translation is wrong.');
return false;
}
if (!isset($this->fileData['translationUnits'][$transUnitId][$pluralFormIndex])) {
$this->i18nLogger->debug('The plural form index "' . $pluralFormIndex . '" for the trans-unit element with the id "' . $transUnitId . '" in ' . $this->fileData['fileIdentifier'] . ' is not available.');
return false;
}
if ($this->fileData['translationUnits'][$transUnitId][$pluralFormIndex]['target']) {
return $this->fileData['translationUnits'][$transUnitId][$pluralFormIndex]['target'];
} elseif ($this->requestedLocale->getLanguage() === $this->fileData['sourceLocale']->getLanguage()) {
return $this->fileData['translationUnits'][$transUnitId][$pluralFormIndex]['source'] ?: false;
} else {
$this->i18nLogger->debug('The target translation was empty and the source translation language (' . $this->fileData['sourceLocale']->getLanguage() . ') does not match the current locale (' . $this->requestedLocale->getLanguage() . ') for the trans-unit element with the id "' . $transUnitId . '" in ' . $this->fileData['fileIdentifier']);
return false;
}
} | [
"public",
"function",
"getTargetByTransUnitId",
"(",
"$",
"transUnitId",
",",
"$",
"pluralFormIndex",
"=",
"0",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"fileData",
"[",
"'translationUnits'",
"]",
"[",
"$",
"transUnitId",
"]",
")",
")",
... | Returns translated label ("target" tag in XLIFF) for the id given.
Id is compared with "id" attribute of "trans-unit" tag (see XLIFF
specification for details).
@param string $transUnitId The "id" attribute of "trans-unit" tag in XLIFF
@param integer $pluralFormIndex Index of plural form to use (starts with 0)
@return mixed Translated label or false on failure | [
"Returns",
"translated",
"label",
"(",
"target",
"tag",
"in",
"XLIFF",
")",
"for",
"the",
"id",
"given",
".",
"Id",
"is",
"compared",
"with",
"id",
"attribute",
"of",
"trans",
"-",
"unit",
"tag",
"(",
"see",
"XLIFF",
"specification",
"for",
"details",
")... | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/I18n/Xliff/Model/FileAdapter.php#L109-L129 |
neos/flow-development-collection | Neos.Flow/Classes/Persistence/Doctrine/Mapping/ClassMetadata.php | ClassMetadata.wakeupReflection | public function wakeupReflection($reflService)
{
parent::wakeupReflection($reflService);
$this->reflClass = new ClassReflection($this->name);
} | php | public function wakeupReflection($reflService)
{
parent::wakeupReflection($reflService);
$this->reflClass = new ClassReflection($this->name);
} | [
"public",
"function",
"wakeupReflection",
"(",
"$",
"reflService",
")",
"{",
"parent",
"::",
"wakeupReflection",
"(",
"$",
"reflService",
")",
";",
"$",
"this",
"->",
"reflClass",
"=",
"new",
"ClassReflection",
"(",
"$",
"this",
"->",
"name",
")",
";",
"}"... | Restores some state that can not be serialized/unserialized.
@param DoctrineReflectionService $reflService
@return void | [
"Restores",
"some",
"state",
"that",
"can",
"not",
"be",
"serialized",
"/",
"unserialized",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Persistence/Doctrine/Mapping/ClassMetadata.php#L53-L57 |
neos/flow-development-collection | Neos.Flow/Classes/Persistence/Doctrine/Mapping/ClassMetadata.php | ClassMetadata._initializeReflection | protected function _initializeReflection()
{
$this->reflClass = new ClassReflection($this->name);
$this->namespace = $this->reflClass->getNamespaceName();
$this->name = $this->rootEntityName = $this->reflClass->getName();
$this->table['name'] = $this->reflClass->getShortName();
} | php | protected function _initializeReflection()
{
$this->reflClass = new ClassReflection($this->name);
$this->namespace = $this->reflClass->getNamespaceName();
$this->name = $this->rootEntityName = $this->reflClass->getName();
$this->table['name'] = $this->reflClass->getShortName();
} | [
"protected",
"function",
"_initializeReflection",
"(",
")",
"{",
"$",
"this",
"->",
"reflClass",
"=",
"new",
"ClassReflection",
"(",
"$",
"this",
"->",
"name",
")",
";",
"$",
"this",
"->",
"namespace",
"=",
"$",
"this",
"->",
"reflClass",
"->",
"getNamespa... | Initializes $this->reflClass and a number of related variables.
@return void | [
"Initializes",
"$this",
"-",
">",
"reflClass",
"and",
"a",
"number",
"of",
"related",
"variables",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Persistence/Doctrine/Mapping/ClassMetadata.php#L64-L70 |
neos/flow-development-collection | Neos.Flow/Classes/Utility/PhpAnalyzer.php | PhpAnalyzer.extractFullyQualifiedClassName | public function extractFullyQualifiedClassName()
{
$fullyQualifiedClassName = $this->extractClassName();
if ($fullyQualifiedClassName === null) {
return null;
}
$namespace = $this->extractNamespace();
if ($namespace !== null) {
$fullyQualifiedClassName = $namespace . '\\' . $fullyQualifiedClassName;
}
return $fullyQualifiedClassName;
} | php | public function extractFullyQualifiedClassName()
{
$fullyQualifiedClassName = $this->extractClassName();
if ($fullyQualifiedClassName === null) {
return null;
}
$namespace = $this->extractNamespace();
if ($namespace !== null) {
$fullyQualifiedClassName = $namespace . '\\' . $fullyQualifiedClassName;
}
return $fullyQualifiedClassName;
} | [
"public",
"function",
"extractFullyQualifiedClassName",
"(",
")",
"{",
"$",
"fullyQualifiedClassName",
"=",
"$",
"this",
"->",
"extractClassName",
"(",
")",
";",
"if",
"(",
"$",
"fullyQualifiedClassName",
"===",
"null",
")",
"{",
"return",
"null",
";",
"}",
"$... | Extracts the Fully Qualified Class name from the given PHP code
@return string FQN in the format "Some\Fully\Qualified\ClassName" or NULL if no class was detected | [
"Extracts",
"the",
"Fully",
"Qualified",
"Class",
"name",
"from",
"the",
"given",
"PHP",
"code"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Utility/PhpAnalyzer.php#L48-L59 |
neos/flow-development-collection | Neos.Flow/Classes/Utility/PhpAnalyzer.php | PhpAnalyzer.extractNamespace | public function extractNamespace()
{
$namespaceParts = [];
$tokens = token_get_all($this->phpCode);
$numberOfTokens = count($tokens);
for ($i = 0; $i < $numberOfTokens; $i++) {
$token = $tokens[$i];
if (is_string($token) || $token[0] !== T_NAMESPACE) {
continue;
}
for (++$i; $i < $numberOfTokens; $i++) {
$token = $tokens[$i];
if (is_string($token)) {
break;
}
list($type, $value) = $token;
if ($type === T_STRING) {
$namespaceParts[] = $value;
continue;
}
if ($type !== T_NS_SEPARATOR && $type !== T_WHITESPACE) {
break;
}
}
break;
}
if ($namespaceParts === []) {
return null;
}
return implode('\\', $namespaceParts);
} | php | public function extractNamespace()
{
$namespaceParts = [];
$tokens = token_get_all($this->phpCode);
$numberOfTokens = count($tokens);
for ($i = 0; $i < $numberOfTokens; $i++) {
$token = $tokens[$i];
if (is_string($token) || $token[0] !== T_NAMESPACE) {
continue;
}
for (++$i; $i < $numberOfTokens; $i++) {
$token = $tokens[$i];
if (is_string($token)) {
break;
}
list($type, $value) = $token;
if ($type === T_STRING) {
$namespaceParts[] = $value;
continue;
}
if ($type !== T_NS_SEPARATOR && $type !== T_WHITESPACE) {
break;
}
}
break;
}
if ($namespaceParts === []) {
return null;
}
return implode('\\', $namespaceParts);
} | [
"public",
"function",
"extractNamespace",
"(",
")",
"{",
"$",
"namespaceParts",
"=",
"[",
"]",
";",
"$",
"tokens",
"=",
"token_get_all",
"(",
"$",
"this",
"->",
"phpCode",
")",
";",
"$",
"numberOfTokens",
"=",
"count",
"(",
"$",
"tokens",
")",
";",
"fo... | Extracts the PHP namespace from the given PHP code
@return string the PHP namespace in the form "Some\Namespace" (w/o leading backslash) - or NULL if no namespace modifier was found | [
"Extracts",
"the",
"PHP",
"namespace",
"from",
"the",
"given",
"PHP",
"code"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Utility/PhpAnalyzer.php#L66-L96 |
neos/flow-development-collection | Neos.Flow/Classes/Utility/PhpAnalyzer.php | PhpAnalyzer.extractClassName | public function extractClassName()
{
$tokens = token_get_all($this->phpCode);
$numberOfTokens = count($tokens);
for ($i = 0; $i < $numberOfTokens; $i++) {
$token = $tokens[$i];
if (is_string($token) || $token[0] !== T_CLASS) {
continue;
}
for (++$i; $i < $numberOfTokens; $i++) {
$token = $tokens[$i];
if (is_string($token)) {
break;
}
list($type, $value) = $token;
if ($type === T_STRING) {
return $value;
}
if ($type !== T_WHITESPACE) {
break;
}
}
}
return null;
} | php | public function extractClassName()
{
$tokens = token_get_all($this->phpCode);
$numberOfTokens = count($tokens);
for ($i = 0; $i < $numberOfTokens; $i++) {
$token = $tokens[$i];
if (is_string($token) || $token[0] !== T_CLASS) {
continue;
}
for (++$i; $i < $numberOfTokens; $i++) {
$token = $tokens[$i];
if (is_string($token)) {
break;
}
list($type, $value) = $token;
if ($type === T_STRING) {
return $value;
}
if ($type !== T_WHITESPACE) {
break;
}
}
}
return null;
} | [
"public",
"function",
"extractClassName",
"(",
")",
"{",
"$",
"tokens",
"=",
"token_get_all",
"(",
"$",
"this",
"->",
"phpCode",
")",
";",
"$",
"numberOfTokens",
"=",
"count",
"(",
"$",
"tokens",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
... | Extracts the className of the given PHP code
Note: This only returns the class name without namespace, @see extractFullyQualifiedClassName()
@return string | [
"Extracts",
"the",
"className",
"of",
"the",
"given",
"PHP",
"code",
"Note",
":",
"This",
"only",
"returns",
"the",
"class",
"name",
"without",
"namespace",
"@see",
"extractFullyQualifiedClassName",
"()"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Utility/PhpAnalyzer.php#L104-L128 |
neos/flow-development-collection | Neos.Flow/Classes/Mvc/Routing/Router.php | Router.route | public function route(RouteContext $routeContext): array
{
$this->lastMatchedRoute = null;
$cachedRouteResult = $this->routerCachingService->getCachedMatchResults($routeContext);
if ($cachedRouteResult !== false) {
return $cachedRouteResult;
}
$this->createRoutesFromConfiguration();
$httpRequest = $routeContext->getHttpRequest();
/** @var $route Route */
foreach ($this->routes as $route) {
if ($route->matches($routeContext) === true) {
$this->lastMatchedRoute = $route;
$matchResults = $route->getMatchResults();
$this->routerCachingService->storeMatchResults($routeContext, $matchResults, $route->getMatchedTags());
$this->logger->debug(sprintf('Router route(): Route "%s" matched the request "%s (%s)".', $route->getName(), $httpRequest->getUri(), $httpRequest->getMethod()));
return $matchResults;
}
}
$this->logger->debug(sprintf('Router route(): No route matched the route path "%s".', $httpRequest->getRelativePath()));
throw new NoMatchingRouteException('Could not match a route for the HTTP request.', 1510846308);
} | php | public function route(RouteContext $routeContext): array
{
$this->lastMatchedRoute = null;
$cachedRouteResult = $this->routerCachingService->getCachedMatchResults($routeContext);
if ($cachedRouteResult !== false) {
return $cachedRouteResult;
}
$this->createRoutesFromConfiguration();
$httpRequest = $routeContext->getHttpRequest();
/** @var $route Route */
foreach ($this->routes as $route) {
if ($route->matches($routeContext) === true) {
$this->lastMatchedRoute = $route;
$matchResults = $route->getMatchResults();
$this->routerCachingService->storeMatchResults($routeContext, $matchResults, $route->getMatchedTags());
$this->logger->debug(sprintf('Router route(): Route "%s" matched the request "%s (%s)".', $route->getName(), $httpRequest->getUri(), $httpRequest->getMethod()));
return $matchResults;
}
}
$this->logger->debug(sprintf('Router route(): No route matched the route path "%s".', $httpRequest->getRelativePath()));
throw new NoMatchingRouteException('Could not match a route for the HTTP request.', 1510846308);
} | [
"public",
"function",
"route",
"(",
"RouteContext",
"$",
"routeContext",
")",
":",
"array",
"{",
"$",
"this",
"->",
"lastMatchedRoute",
"=",
"null",
";",
"$",
"cachedRouteResult",
"=",
"$",
"this",
"->",
"routerCachingService",
"->",
"getCachedMatchResults",
"("... | Iterates through all configured routes and calls matches() on them.
Returns the matchResults of the matching route or NULL if no matching
route could be found.
@param RouteContext $routeContext The Route Context containing the current HTTP Request and, optional, Routing RouteParameters
@return array The results of the matching route or NULL if no route matched
@throws InvalidRouteSetupException
@throws NoMatchingRouteException if no route matched the given $routeContext
@throws InvalidRoutePartValueException | [
"Iterates",
"through",
"all",
"configured",
"routes",
"and",
"calls",
"matches",
"()",
"on",
"them",
".",
"Returns",
"the",
"matchResults",
"of",
"the",
"matching",
"route",
"or",
"NULL",
"if",
"no",
"matching",
"route",
"could",
"be",
"found",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Mvc/Routing/Router.php#L115-L137 |
neos/flow-development-collection | Neos.Flow/Classes/Mvc/Routing/Router.php | Router.resolve | public function resolve(ResolveContext $resolveContext): UriInterface
{
$this->lastResolvedRoute = null;
$cachedResolvedUriConstraints = $this->routerCachingService->getCachedResolvedUriConstraints($resolveContext);
if ($cachedResolvedUriConstraints !== false) {
return $cachedResolvedUriConstraints->applyTo($resolveContext->getBaseUri(), $resolveContext->isForceAbsoluteUri());
}
$this->createRoutesFromConfiguration();
/** @var $route Route */
foreach ($this->routes as $route) {
if ($route->resolves($resolveContext->getRouteValues()) === true) {
$uriConstraints = $route->getResolvedUriConstraints()->withPathPrefix($resolveContext->getUriPathPrefix());
$resolvedUri = $uriConstraints->applyTo($resolveContext->getBaseUri(), $resolveContext->isForceAbsoluteUri());
$this->routerCachingService->storeResolvedUriConstraints($resolveContext, $uriConstraints, $route->getResolvedTags());
$this->lastResolvedRoute = $route;
return $resolvedUri;
}
}
$this->logger->warning('Router resolve(): Could not resolve a route for building an URI for the given resolve context.', LogEnvironment::fromMethodName(__METHOD__) + ['routeValues' => $resolveContext->getRouteValues()]);
throw new NoMatchingRouteException('Could not resolve a route and its corresponding URI for the given parameters. This may be due to referring to a not existing package / controller / action while building a link or URI. Refer to log and check the backtrace for more details.', 1301610453);
} | php | public function resolve(ResolveContext $resolveContext): UriInterface
{
$this->lastResolvedRoute = null;
$cachedResolvedUriConstraints = $this->routerCachingService->getCachedResolvedUriConstraints($resolveContext);
if ($cachedResolvedUriConstraints !== false) {
return $cachedResolvedUriConstraints->applyTo($resolveContext->getBaseUri(), $resolveContext->isForceAbsoluteUri());
}
$this->createRoutesFromConfiguration();
/** @var $route Route */
foreach ($this->routes as $route) {
if ($route->resolves($resolveContext->getRouteValues()) === true) {
$uriConstraints = $route->getResolvedUriConstraints()->withPathPrefix($resolveContext->getUriPathPrefix());
$resolvedUri = $uriConstraints->applyTo($resolveContext->getBaseUri(), $resolveContext->isForceAbsoluteUri());
$this->routerCachingService->storeResolvedUriConstraints($resolveContext, $uriConstraints, $route->getResolvedTags());
$this->lastResolvedRoute = $route;
return $resolvedUri;
}
}
$this->logger->warning('Router resolve(): Could not resolve a route for building an URI for the given resolve context.', LogEnvironment::fromMethodName(__METHOD__) + ['routeValues' => $resolveContext->getRouteValues()]);
throw new NoMatchingRouteException('Could not resolve a route and its corresponding URI for the given parameters. This may be due to referring to a not existing package / controller / action while building a link or URI. Refer to log and check the backtrace for more details.', 1301610453);
} | [
"public",
"function",
"resolve",
"(",
"ResolveContext",
"$",
"resolveContext",
")",
":",
"UriInterface",
"{",
"$",
"this",
"->",
"lastResolvedRoute",
"=",
"null",
";",
"$",
"cachedResolvedUriConstraints",
"=",
"$",
"this",
"->",
"routerCachingService",
"->",
"getC... | Builds the corresponding uri (excluding protocol and host) by iterating
through all configured routes and calling their respective resolves()
method. If no matching route is found, an empty string is returned.
Note: calls of this message are cached by RouterCachingAspect
@param ResolveContext $resolveContext The Resolve Context containing the route values, the request URI and some flags to be resolved
@return UriInterface The resolved URI
@throws NoMatchingRouteException if no route could resolve the given $resolveContext | [
"Builds",
"the",
"corresponding",
"uri",
"(",
"excluding",
"protocol",
"and",
"host",
")",
"by",
"iterating",
"through",
"all",
"configured",
"routes",
"and",
"calling",
"their",
"respective",
"resolves",
"()",
"method",
".",
"If",
"no",
"matching",
"route",
"... | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Mvc/Routing/Router.php#L183-L205 |
neos/flow-development-collection | Neos.Flow/Classes/Mvc/Routing/Router.php | Router.createRoutesFromConfiguration | protected function createRoutesFromConfiguration()
{
if ($this->routesCreated === true) {
return;
}
$this->initializeRoutesConfiguration();
$this->routes = [];
$routesWithHttpMethodConstraints = [];
foreach ($this->routesConfiguration as $routeConfiguration) {
$route = new Route();
if (isset($routeConfiguration['name'])) {
$route->setName($routeConfiguration['name']);
}
$uriPattern = $routeConfiguration['uriPattern'];
$route->setUriPattern($uriPattern);
if (isset($routeConfiguration['defaults'])) {
$route->setDefaults($routeConfiguration['defaults']);
}
if (isset($routeConfiguration['routeParts'])) {
$route->setRoutePartsConfiguration($routeConfiguration['routeParts']);
}
if (isset($routeConfiguration['toLowerCase'])) {
$route->setLowerCase($routeConfiguration['toLowerCase']);
}
if (isset($routeConfiguration['appendExceedingArguments'])) {
$route->setAppendExceedingArguments($routeConfiguration['appendExceedingArguments']);
}
if (isset($routeConfiguration['httpMethods'])) {
if (isset($routesWithHttpMethodConstraints[$uriPattern]) && $routesWithHttpMethodConstraints[$uriPattern] === false) {
throw new InvalidRouteSetupException(sprintf('There are multiple routes with the uriPattern "%s" and "httpMethods" option set. Please specify accepted HTTP methods for all of these, or adjust the uriPattern', $uriPattern), 1365678427);
}
$routesWithHttpMethodConstraints[$uriPattern] = true;
$route->setHttpMethods($routeConfiguration['httpMethods']);
} else {
if (isset($routesWithHttpMethodConstraints[$uriPattern]) && $routesWithHttpMethodConstraints[$uriPattern] === true) {
throw new InvalidRouteSetupException(sprintf('There are multiple routes with the uriPattern "%s" and "httpMethods" option set. Please specify accepted HTTP methods for all of these, or adjust the uriPattern', $uriPattern), 1365678432);
}
$routesWithHttpMethodConstraints[$uriPattern] = false;
}
$this->routes[] = $route;
}
$this->routesCreated = true;
} | php | protected function createRoutesFromConfiguration()
{
if ($this->routesCreated === true) {
return;
}
$this->initializeRoutesConfiguration();
$this->routes = [];
$routesWithHttpMethodConstraints = [];
foreach ($this->routesConfiguration as $routeConfiguration) {
$route = new Route();
if (isset($routeConfiguration['name'])) {
$route->setName($routeConfiguration['name']);
}
$uriPattern = $routeConfiguration['uriPattern'];
$route->setUriPattern($uriPattern);
if (isset($routeConfiguration['defaults'])) {
$route->setDefaults($routeConfiguration['defaults']);
}
if (isset($routeConfiguration['routeParts'])) {
$route->setRoutePartsConfiguration($routeConfiguration['routeParts']);
}
if (isset($routeConfiguration['toLowerCase'])) {
$route->setLowerCase($routeConfiguration['toLowerCase']);
}
if (isset($routeConfiguration['appendExceedingArguments'])) {
$route->setAppendExceedingArguments($routeConfiguration['appendExceedingArguments']);
}
if (isset($routeConfiguration['httpMethods'])) {
if (isset($routesWithHttpMethodConstraints[$uriPattern]) && $routesWithHttpMethodConstraints[$uriPattern] === false) {
throw new InvalidRouteSetupException(sprintf('There are multiple routes with the uriPattern "%s" and "httpMethods" option set. Please specify accepted HTTP methods for all of these, or adjust the uriPattern', $uriPattern), 1365678427);
}
$routesWithHttpMethodConstraints[$uriPattern] = true;
$route->setHttpMethods($routeConfiguration['httpMethods']);
} else {
if (isset($routesWithHttpMethodConstraints[$uriPattern]) && $routesWithHttpMethodConstraints[$uriPattern] === true) {
throw new InvalidRouteSetupException(sprintf('There are multiple routes with the uriPattern "%s" and "httpMethods" option set. Please specify accepted HTTP methods for all of these, or adjust the uriPattern', $uriPattern), 1365678432);
}
$routesWithHttpMethodConstraints[$uriPattern] = false;
}
$this->routes[] = $route;
}
$this->routesCreated = true;
} | [
"protected",
"function",
"createRoutesFromConfiguration",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"routesCreated",
"===",
"true",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"initializeRoutesConfiguration",
"(",
")",
";",
"$",
"this",
"->",
"routes... | Creates \Neos\Flow\Mvc\Routing\Route objects from the injected routes
configuration.
@return void
@throws InvalidRouteSetupException | [
"Creates",
"\\",
"Neos",
"\\",
"Flow",
"\\",
"Mvc",
"\\",
"Routing",
"\\",
"Route",
"objects",
"from",
"the",
"injected",
"routes",
"configuration",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Mvc/Routing/Router.php#L225-L267 |
neos/flow-development-collection | Neos.Flow/Classes/Mvc/Routing/Router.php | Router.initializeRoutesConfiguration | protected function initializeRoutesConfiguration()
{
if ($this->routesConfiguration === null) {
$this->routesConfiguration = $this->configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_ROUTES);
}
} | php | protected function initializeRoutesConfiguration()
{
if ($this->routesConfiguration === null) {
$this->routesConfiguration = $this->configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_ROUTES);
}
} | [
"protected",
"function",
"initializeRoutesConfiguration",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"routesConfiguration",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"routesConfiguration",
"=",
"$",
"this",
"->",
"configurationManager",
"->",
"getConfiguration... | Checks if a routes configuration was set and otherwise loads the configuration from the configuration manager.
@return void | [
"Checks",
"if",
"a",
"routes",
"configuration",
"was",
"set",
"and",
"otherwise",
"loads",
"the",
"configuration",
"from",
"the",
"configuration",
"manager",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Mvc/Routing/Router.php#L274-L279 |
neos/flow-development-collection | Neos.Flow/Classes/Configuration/ConfigurationSchemaValidator.php | ConfigurationSchemaValidator.validate | public function validate(string $configurationType = null, string $path = null, array &$loadedSchemaFiles = []): Result
{
if ($configurationType === null) {
$configurationTypes = $this->configurationManager->getAvailableConfigurationTypes();
} else {
$configurationTypes = [$configurationType];
}
$result = new Result();
foreach ($configurationTypes as $configurationType) {
$resultForEachType = $this->validateSingleType($configurationType, $path, $loadedSchemaFiles);
$result->forProperty($configurationType)->merge($resultForEachType);
}
return $result;
} | php | public function validate(string $configurationType = null, string $path = null, array &$loadedSchemaFiles = []): Result
{
if ($configurationType === null) {
$configurationTypes = $this->configurationManager->getAvailableConfigurationTypes();
} else {
$configurationTypes = [$configurationType];
}
$result = new Result();
foreach ($configurationTypes as $configurationType) {
$resultForEachType = $this->validateSingleType($configurationType, $path, $loadedSchemaFiles);
$result->forProperty($configurationType)->merge($resultForEachType);
}
return $result;
} | [
"public",
"function",
"validate",
"(",
"string",
"$",
"configurationType",
"=",
"null",
",",
"string",
"$",
"path",
"=",
"null",
",",
"array",
"&",
"$",
"loadedSchemaFiles",
"=",
"[",
"]",
")",
":",
"Result",
"{",
"if",
"(",
"$",
"configurationType",
"==... | Validate the given $configurationType and $path
@param string $configurationType (optional) the configuration type to validate. if NULL, validates all configuration.
@param string $path (optional) configuration path to validate
@param array $loadedSchemaFiles (optional). if given, will be filled with a list of loaded schema files
@return \Neos\Error\Messages\Result the result of the validation
@throws Exception\SchemaValidationException | [
"Validate",
"the",
"given",
"$configurationType",
"and",
"$path"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Configuration/ConfigurationSchemaValidator.php#L66-L80 |
neos/flow-development-collection | Neos.Flow/Classes/Configuration/ConfigurationSchemaValidator.php | ConfigurationSchemaValidator.validateSingleType | protected function validateSingleType(string $configurationType, string $path = null, array&$loadedSchemaFiles = []): Result
{
$availableConfigurationTypes = $this->configurationManager->getAvailableConfigurationTypes();
if (in_array($configurationType, $availableConfigurationTypes) === false) {
throw new Exception\SchemaValidationException('The configuration type "' . $configurationType . '" was not found. Only the following configuration types are supported: "' . implode('", "', $availableConfigurationTypes) . '"', 1364984886);
}
$configuration = $this->configurationManager->getConfiguration($configurationType);
// find schema files for the given type and path
$schemaFileInfos = [];
foreach ($this->packageManager->getFlowPackages() as $package) {
$packageKey = $package->getPackageKey();
$packageSchemaPath = Files::concatenatePaths([$package->getResourcesPath(), 'Private/Schema']);
if (is_dir($packageSchemaPath)) {
foreach (Files::getRecursiveDirectoryGenerator($packageSchemaPath, '.schema.yaml') as $schemaFile) {
$schemaName = substr($schemaFile, strlen($packageSchemaPath) + 1, -strlen('.schema.yaml'));
$schemaNameParts = explode('.', str_replace('/', '.', $schemaName), 2);
$schemaType = $schemaNameParts[0];
$schemaPath = isset($schemaNameParts[1]) ? $schemaNameParts[1] : null;
if ($schemaType === $configurationType && ($path === null || strpos($schemaPath, $path) === 0)) {
$schemaFileInfos[] = [
'file' => $schemaFile,
'name' => $schemaName,
'path' => $schemaPath,
'packageKey' => $packageKey
];
}
}
}
}
if (count($schemaFileInfos) === 0) {
throw new Exception\SchemaValidationException('No schema files found for configuration type "' . $configurationType . '"' . ($path !== null ? ' and path "' . $path . '".': '.'), 1364985056);
}
$result = new Result();
foreach ($schemaFileInfos as $schemaFileInfo) {
$loadedSchemaFiles[] = $schemaFileInfo['file'];
if ($schemaFileInfo['path'] !== null) {
$data = Arrays::getValueByPath($configuration, $schemaFileInfo['path']);
} else {
$data = $configuration;
}
if (empty($data)) {
$result->addNotice(new Notice('No configuration found, skipping schema "%s".', 1364985445, [substr($schemaFileInfo['file'], strlen(FLOW_PATH_ROOT))]));
} else {
$parsedSchema = Yaml::parseFile($schemaFileInfo['file']);
$validationResultForSingleSchema = $this->schemaValidator->validate($data, $parsedSchema);
if ($schemaFileInfo['path'] !== null) {
$result->forProperty($schemaFileInfo['path'])->merge($validationResultForSingleSchema);
} else {
$result->merge($validationResultForSingleSchema);
}
}
}
return $result;
} | php | protected function validateSingleType(string $configurationType, string $path = null, array&$loadedSchemaFiles = []): Result
{
$availableConfigurationTypes = $this->configurationManager->getAvailableConfigurationTypes();
if (in_array($configurationType, $availableConfigurationTypes) === false) {
throw new Exception\SchemaValidationException('The configuration type "' . $configurationType . '" was not found. Only the following configuration types are supported: "' . implode('", "', $availableConfigurationTypes) . '"', 1364984886);
}
$configuration = $this->configurationManager->getConfiguration($configurationType);
// find schema files for the given type and path
$schemaFileInfos = [];
foreach ($this->packageManager->getFlowPackages() as $package) {
$packageKey = $package->getPackageKey();
$packageSchemaPath = Files::concatenatePaths([$package->getResourcesPath(), 'Private/Schema']);
if (is_dir($packageSchemaPath)) {
foreach (Files::getRecursiveDirectoryGenerator($packageSchemaPath, '.schema.yaml') as $schemaFile) {
$schemaName = substr($schemaFile, strlen($packageSchemaPath) + 1, -strlen('.schema.yaml'));
$schemaNameParts = explode('.', str_replace('/', '.', $schemaName), 2);
$schemaType = $schemaNameParts[0];
$schemaPath = isset($schemaNameParts[1]) ? $schemaNameParts[1] : null;
if ($schemaType === $configurationType && ($path === null || strpos($schemaPath, $path) === 0)) {
$schemaFileInfos[] = [
'file' => $schemaFile,
'name' => $schemaName,
'path' => $schemaPath,
'packageKey' => $packageKey
];
}
}
}
}
if (count($schemaFileInfos) === 0) {
throw new Exception\SchemaValidationException('No schema files found for configuration type "' . $configurationType . '"' . ($path !== null ? ' and path "' . $path . '".': '.'), 1364985056);
}
$result = new Result();
foreach ($schemaFileInfos as $schemaFileInfo) {
$loadedSchemaFiles[] = $schemaFileInfo['file'];
if ($schemaFileInfo['path'] !== null) {
$data = Arrays::getValueByPath($configuration, $schemaFileInfo['path']);
} else {
$data = $configuration;
}
if (empty($data)) {
$result->addNotice(new Notice('No configuration found, skipping schema "%s".', 1364985445, [substr($schemaFileInfo['file'], strlen(FLOW_PATH_ROOT))]));
} else {
$parsedSchema = Yaml::parseFile($schemaFileInfo['file']);
$validationResultForSingleSchema = $this->schemaValidator->validate($data, $parsedSchema);
if ($schemaFileInfo['path'] !== null) {
$result->forProperty($schemaFileInfo['path'])->merge($validationResultForSingleSchema);
} else {
$result->merge($validationResultForSingleSchema);
}
}
}
return $result;
} | [
"protected",
"function",
"validateSingleType",
"(",
"string",
"$",
"configurationType",
",",
"string",
"$",
"path",
"=",
"null",
",",
"array",
"&",
"$",
"loadedSchemaFiles",
"=",
"[",
"]",
")",
":",
"Result",
"{",
"$",
"availableConfigurationTypes",
"=",
"$",
... | Validate a single configuration type
@param string $configurationType the configuration typr to validate
@param string $path configuration path to validate, or NULL.
@param array $loadedSchemaFiles will be filled with a list of loaded schema files
@return \Neos\Error\Messages\Result
@throws Exception\SchemaValidationException | [
"Validate",
"a",
"single",
"configuration",
"type"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Configuration/ConfigurationSchemaValidator.php#L91-L154 |
neos/flow-development-collection | Neos.Flow/Classes/Security/Authorization/Interceptor/PolicyEnforcement.php | PolicyEnforcement.invoke | public function invoke()
{
$reason = '';
$privilegeSubject = new MethodPrivilegeSubject($this->joinPoint);
try {
$this->authenticationManager->authenticate();
} catch (EntityNotFoundException $exception) {
throw new AuthenticationRequiredException('Could not authenticate. Looks like a broken session.', 1358971444, $exception);
} catch (NoTokensAuthenticatedException $noTokensAuthenticatedException) {
// We still need to check if the privilege is available to "Neos.Flow:Everybody".
if ($this->privilegeManager->isGranted(MethodPrivilegeInterface::class, $privilegeSubject, $reason) === false) {
throw new NoTokensAuthenticatedException($noTokensAuthenticatedException->getMessage() . chr(10) . $reason, $noTokensAuthenticatedException->getCode());
}
}
if ($this->privilegeManager->isGranted(MethodPrivilegeInterface::class, $privilegeSubject, $reason) === false) {
throw new AccessDeniedException($this->renderDecisionReasonMessage($reason), 1222268609);
}
return true;
} | php | public function invoke()
{
$reason = '';
$privilegeSubject = new MethodPrivilegeSubject($this->joinPoint);
try {
$this->authenticationManager->authenticate();
} catch (EntityNotFoundException $exception) {
throw new AuthenticationRequiredException('Could not authenticate. Looks like a broken session.', 1358971444, $exception);
} catch (NoTokensAuthenticatedException $noTokensAuthenticatedException) {
// We still need to check if the privilege is available to "Neos.Flow:Everybody".
if ($this->privilegeManager->isGranted(MethodPrivilegeInterface::class, $privilegeSubject, $reason) === false) {
throw new NoTokensAuthenticatedException($noTokensAuthenticatedException->getMessage() . chr(10) . $reason, $noTokensAuthenticatedException->getCode());
}
}
if ($this->privilegeManager->isGranted(MethodPrivilegeInterface::class, $privilegeSubject, $reason) === false) {
throw new AccessDeniedException($this->renderDecisionReasonMessage($reason), 1222268609);
}
return true;
} | [
"public",
"function",
"invoke",
"(",
")",
"{",
"$",
"reason",
"=",
"''",
";",
"$",
"privilegeSubject",
"=",
"new",
"MethodPrivilegeSubject",
"(",
"$",
"this",
"->",
"joinPoint",
")",
";",
"try",
"{",
"$",
"this",
"->",
"authenticationManager",
"->",
"authe... | Invokes the security interception
@return boolean true if the security checks was passed
@throws AccessDeniedException
@throws AuthenticationRequiredException if an entity could not be found (assuming it is bound to the current session), causing a redirect to the authentication entrypoint
@throws NoTokensAuthenticatedException if no tokens could be found and the accessDecisionManager denied access to the privilege target, causing a redirect to the authentication entrypoint | [
"Invokes",
"the",
"security",
"interception"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Authorization/Interceptor/PolicyEnforcement.php#L91-L113 |
neos/flow-development-collection | Neos.Flow/Classes/Security/Authorization/Interceptor/PolicyEnforcement.php | PolicyEnforcement.renderDecisionReasonMessage | protected function renderDecisionReasonMessage($privilegeReasonMessage)
{
if (count($this->securityContext->getRoles()) === 0) {
$rolesMessage = 'No authenticated roles';
} else {
$rolesMessage = 'Authenticated roles: ' . implode(', ', array_keys($this->securityContext->getRoles()));
}
return sprintf('Access denied for method' . chr(10) . 'Method: %s::%s()' . chr(10) . chr(10) . '%s' . chr(10) . chr(10) . '%s', $this->joinPoint->getClassName(), $this->joinPoint->getMethodName(), $privilegeReasonMessage, $rolesMessage);
} | php | protected function renderDecisionReasonMessage($privilegeReasonMessage)
{
if (count($this->securityContext->getRoles()) === 0) {
$rolesMessage = 'No authenticated roles';
} else {
$rolesMessage = 'Authenticated roles: ' . implode(', ', array_keys($this->securityContext->getRoles()));
}
return sprintf('Access denied for method' . chr(10) . 'Method: %s::%s()' . chr(10) . chr(10) . '%s' . chr(10) . chr(10) . '%s', $this->joinPoint->getClassName(), $this->joinPoint->getMethodName(), $privilegeReasonMessage, $rolesMessage);
} | [
"protected",
"function",
"renderDecisionReasonMessage",
"(",
"$",
"privilegeReasonMessage",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"securityContext",
"->",
"getRoles",
"(",
")",
")",
"===",
"0",
")",
"{",
"$",
"rolesMessage",
"=",
"'No authentic... | Returns a string message, giving insights what happened during privilege evaluation.
@param string $privilegeReasonMessage
@return string | [
"Returns",
"a",
"string",
"message",
"giving",
"insights",
"what",
"happened",
"during",
"privilege",
"evaluation",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Authorization/Interceptor/PolicyEnforcement.php#L121-L130 |
neos/flow-development-collection | Neos.Flow/Classes/Security/Authentication/Token/PasswordToken.php | PasswordToken.updateCredentials | public function updateCredentials(ActionRequest $actionRequest)
{
if ($actionRequest->getHttpRequest()->getMethod() !== 'POST') {
return;
}
$postArguments = $actionRequest->getInternalArguments();
$password = ObjectAccess::getPropertyPath($postArguments, '__authentication.Neos.Flow.Security.Authentication.Token.PasswordToken.password');
if (!empty($password)) {
$this->credentials['password'] = $password;
$this->setAuthenticationStatus(self::AUTHENTICATION_NEEDED);
}
} | php | public function updateCredentials(ActionRequest $actionRequest)
{
if ($actionRequest->getHttpRequest()->getMethod() !== 'POST') {
return;
}
$postArguments = $actionRequest->getInternalArguments();
$password = ObjectAccess::getPropertyPath($postArguments, '__authentication.Neos.Flow.Security.Authentication.Token.PasswordToken.password');
if (!empty($password)) {
$this->credentials['password'] = $password;
$this->setAuthenticationStatus(self::AUTHENTICATION_NEEDED);
}
} | [
"public",
"function",
"updateCredentials",
"(",
"ActionRequest",
"$",
"actionRequest",
")",
"{",
"if",
"(",
"$",
"actionRequest",
"->",
"getHttpRequest",
"(",
")",
"->",
"getMethod",
"(",
")",
"!==",
"'POST'",
")",
"{",
"return",
";",
"}",
"$",
"postArgument... | Updates the password credential from the POST vars, if the POST parameters
are available. Sets the authentication status to AUTHENTICATION_NEEDED, if credentials have been sent.
Note: You need to send the password in this POST parameter:
__authentication[Neos][Flow][Security][Authentication][Token][PasswordToken][password]
@param ActionRequest $actionRequest The current action request
@return void | [
"Updates",
"the",
"password",
"credential",
"from",
"the",
"POST",
"vars",
"if",
"the",
"POST",
"parameters",
"are",
"available",
".",
"Sets",
"the",
"authentication",
"status",
"to",
"AUTHENTICATION_NEEDED",
"if",
"credentials",
"have",
"been",
"sent",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Authentication/Token/PasswordToken.php#L46-L59 |
neos/flow-development-collection | Neos.Flow/Classes/Core/ProxyClassLoader.php | ProxyClassLoader.loadClass | public function loadClass($className)
{
$className = ltrim($className, '\\');
$namespaceParts = explode('\\', $className);
// Workaround for Doctrine's annotation parser which does a class_exists() for annotations like "@param" and so on:
if (isset($this->ignoredClassNames[$className]) || isset($this->ignoredClassNames[end($namespaceParts)])) {
return false;
}
// Loads any known proxied class:
if ($this->classesCache !== null && ($this->availableProxyClasses === null || isset($this->availableProxyClasses[implode('_', $namespaceParts)])) && $this->classesCache->requireOnce(implode('_', $namespaceParts)) !== false) {
return true;
}
return false;
} | php | public function loadClass($className)
{
$className = ltrim($className, '\\');
$namespaceParts = explode('\\', $className);
// Workaround for Doctrine's annotation parser which does a class_exists() for annotations like "@param" and so on:
if (isset($this->ignoredClassNames[$className]) || isset($this->ignoredClassNames[end($namespaceParts)])) {
return false;
}
// Loads any known proxied class:
if ($this->classesCache !== null && ($this->availableProxyClasses === null || isset($this->availableProxyClasses[implode('_', $namespaceParts)])) && $this->classesCache->requireOnce(implode('_', $namespaceParts)) !== false) {
return true;
}
return false;
} | [
"public",
"function",
"loadClass",
"(",
"$",
"className",
")",
"{",
"$",
"className",
"=",
"ltrim",
"(",
"$",
"className",
",",
"'\\\\'",
")",
";",
"$",
"namespaceParts",
"=",
"explode",
"(",
"'\\\\'",
",",
"$",
"className",
")",
";",
"// Workaround for Do... | Loads php files containing classes or interfaces found in the classes directory of
a package and specifically registered classes.
@param string $className Name of the class/interface to load
@return boolean | [
"Loads",
"php",
"files",
"containing",
"classes",
"or",
"interfaces",
"found",
"in",
"the",
"classes",
"directory",
"of",
"a",
"package",
"and",
"specifically",
"registered",
"classes",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Core/ProxyClassLoader.php#L84-L100 |
neos/flow-development-collection | Neos.Flow/Classes/Core/ProxyClassLoader.php | ProxyClassLoader.initializeAvailableProxyClasses | public function initializeAvailableProxyClasses(ApplicationContext $context = null)
{
if ($context === null) {
return;
}
$proxyClasses = @include(FLOW_PATH_TEMPORARY_BASE . '/' . (string)$context . '/AvailableProxyClasses.php');
if ($proxyClasses !== false) {
$this->availableProxyClasses = $proxyClasses;
}
} | php | public function initializeAvailableProxyClasses(ApplicationContext $context = null)
{
if ($context === null) {
return;
}
$proxyClasses = @include(FLOW_PATH_TEMPORARY_BASE . '/' . (string)$context . '/AvailableProxyClasses.php');
if ($proxyClasses !== false) {
$this->availableProxyClasses = $proxyClasses;
}
} | [
"public",
"function",
"initializeAvailableProxyClasses",
"(",
"ApplicationContext",
"$",
"context",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"context",
"===",
"null",
")",
"{",
"return",
";",
"}",
"$",
"proxyClasses",
"=",
"@",
"include",
"(",
"FLOW_PATH_TEMPORA... | Initialize available proxy classes from the cached list.
@param ApplicationContext $context
@return void | [
"Initialize",
"available",
"proxy",
"classes",
"from",
"the",
"cached",
"list",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Core/ProxyClassLoader.php#L108-L118 |
neos/flow-development-collection | Neos.FluidAdaptor/Classes/Core/ViewHelper/AbstractViewHelper.php | AbstractViewHelper.callRenderMethod | protected function callRenderMethod()
{
$renderMethodParameters = [];
foreach ($this->argumentDefinitions as $argumentName => $argumentDefinition) {
if ($argumentDefinition instanceof ArgumentDefinition && $argumentDefinition->isMethodParameter()) {
$renderMethodParameters[$argumentName] = $this->arguments[$argumentName];
}
}
try {
return call_user_func_array([$this, 'render'], $renderMethodParameters);
} catch (Exception $exception) {
if (!$this->objectManager->getContext()->isProduction()) {
throw $exception;
}
$this->logger->error('A Fluid ViewHelper Exception was captured: ' . $exception->getMessage() . ' (' . $exception->getCode() . ')',
['exception' => $exception]
);
return '';
}
} | php | protected function callRenderMethod()
{
$renderMethodParameters = [];
foreach ($this->argumentDefinitions as $argumentName => $argumentDefinition) {
if ($argumentDefinition instanceof ArgumentDefinition && $argumentDefinition->isMethodParameter()) {
$renderMethodParameters[$argumentName] = $this->arguments[$argumentName];
}
}
try {
return call_user_func_array([$this, 'render'], $renderMethodParameters);
} catch (Exception $exception) {
if (!$this->objectManager->getContext()->isProduction()) {
throw $exception;
}
$this->logger->error('A Fluid ViewHelper Exception was captured: ' . $exception->getMessage() . ' (' . $exception->getCode() . ')',
['exception' => $exception]
);
return '';
}
} | [
"protected",
"function",
"callRenderMethod",
"(",
")",
"{",
"$",
"renderMethodParameters",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"argumentDefinitions",
"as",
"$",
"argumentName",
"=>",
"$",
"argumentDefinition",
")",
"{",
"if",
"(",
"$",
"ar... | Call the render() method and handle errors.
@return string the rendered ViewHelper
@throws Exception | [
"Call",
"the",
"render",
"()",
"method",
"and",
"handle",
"errors",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.FluidAdaptor/Classes/Core/ViewHelper/AbstractViewHelper.php#L112-L134 |
neos/flow-development-collection | Neos.FluidAdaptor/Classes/Core/ViewHelper/AbstractViewHelper.php | AbstractViewHelper.registerArgument | protected function registerArgument($name, $type, $description, $required = false, $defaultValue = null)
{
if (array_key_exists($name, $this->argumentDefinitions)) {
throw new Exception('Argument "' . $name . '" has already been defined, thus it should not be defined again.', 1253036401);
}
return parent::registerArgument($name, $type, $description, $required, $defaultValue);
} | php | protected function registerArgument($name, $type, $description, $required = false, $defaultValue = null)
{
if (array_key_exists($name, $this->argumentDefinitions)) {
throw new Exception('Argument "' . $name . '" has already been defined, thus it should not be defined again.', 1253036401);
}
return parent::registerArgument($name, $type, $description, $required, $defaultValue);
} | [
"protected",
"function",
"registerArgument",
"(",
"$",
"name",
",",
"$",
"type",
",",
"$",
"description",
",",
"$",
"required",
"=",
"false",
",",
"$",
"defaultValue",
"=",
"null",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"t... | Register a new argument. Call this method from your ViewHelper subclass
inside the initializeArguments() method.
@param string $name Name of the argument
@param string $type Type of the argument
@param string $description Description of the argument
@param boolean $required If true, argument is required. Defaults to false.
@param mixed $defaultValue Default value of argument
@return FluidAbstractViewHelper $this, to allow chaining.
@throws Exception
@api | [
"Register",
"a",
"new",
"argument",
".",
"Call",
"this",
"method",
"from",
"your",
"ViewHelper",
"subclass",
"inside",
"the",
"initializeArguments",
"()",
"method",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.FluidAdaptor/Classes/Core/ViewHelper/AbstractViewHelper.php#L162-L168 |
neos/flow-development-collection | Neos.FluidAdaptor/Classes/Core/ViewHelper/AbstractViewHelper.php | AbstractViewHelper.registerRenderMethodArguments | protected function registerRenderMethodArguments()
{
foreach (static::getRenderMethodArgumentDefinitions($this->objectManager) as $argumentName => $definition) {
$this->argumentDefinitions[$argumentName] = new ArgumentDefinition($definition[0], $definition[1], $definition[2], $definition[3], $definition[4], $definition[5]);
}
} | php | protected function registerRenderMethodArguments()
{
foreach (static::getRenderMethodArgumentDefinitions($this->objectManager) as $argumentName => $definition) {
$this->argumentDefinitions[$argumentName] = new ArgumentDefinition($definition[0], $definition[1], $definition[2], $definition[3], $definition[4], $definition[5]);
}
} | [
"protected",
"function",
"registerRenderMethodArguments",
"(",
")",
"{",
"foreach",
"(",
"static",
"::",
"getRenderMethodArgumentDefinitions",
"(",
"$",
"this",
"->",
"objectManager",
")",
"as",
"$",
"argumentName",
"=>",
"$",
"definition",
")",
"{",
"$",
"this",
... | Registers render method arguments
@return void
@deprecated Render method should no longer expect arguments, instead all arguments should be registered in "initializeArguments" | [
"Registers",
"render",
"method",
"arguments"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.FluidAdaptor/Classes/Core/ViewHelper/AbstractViewHelper.php#L199-L204 |
neos/flow-development-collection | Neos.Flow/Classes/Cache/CacheFactory.php | CacheFactory.instantiateCache | protected function instantiateCache(string $cacheIdentifier, string $cacheObjectName, BackendInterface $backend): FrontendInterface
{
$cache = parent::instantiateCache($cacheIdentifier, $cacheObjectName, $backend);
if (is_callable([$cache, 'initializeObject'])) {
$cache->initializeObject(ObjectManagerInterface::INITIALIZATIONCAUSE_CREATED);
}
return $cache;
} | php | protected function instantiateCache(string $cacheIdentifier, string $cacheObjectName, BackendInterface $backend): FrontendInterface
{
$cache = parent::instantiateCache($cacheIdentifier, $cacheObjectName, $backend);
if (is_callable([$cache, 'initializeObject'])) {
$cache->initializeObject(ObjectManagerInterface::INITIALIZATIONCAUSE_CREATED);
}
return $cache;
} | [
"protected",
"function",
"instantiateCache",
"(",
"string",
"$",
"cacheIdentifier",
",",
"string",
"$",
"cacheObjectName",
",",
"BackendInterface",
"$",
"backend",
")",
":",
"FrontendInterface",
"{",
"$",
"cache",
"=",
"parent",
"::",
"instantiateCache",
"(",
"$",... | {@inheritdoc} | [
"{"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Cache/CacheFactory.php#L120-L129 |
neos/flow-development-collection | Neos.Utility.Unicode/Classes/Functions.php | Functions.strtotitle | public static function strtotitle(string $string): string
{
$result = '';
$splitIntoLowerCaseWords = preg_split("/([\n\r\t ])/", self::strtolower($string), -1, PREG_SPLIT_DELIM_CAPTURE);
foreach ($splitIntoLowerCaseWords as $delimiterOrValue) {
$result .= self::strtoupper(self::substr($delimiterOrValue, 0, 1)) . self::substr($delimiterOrValue, 1);
}
return $result;
} | php | public static function strtotitle(string $string): string
{
$result = '';
$splitIntoLowerCaseWords = preg_split("/([\n\r\t ])/", self::strtolower($string), -1, PREG_SPLIT_DELIM_CAPTURE);
foreach ($splitIntoLowerCaseWords as $delimiterOrValue) {
$result .= self::strtoupper(self::substr($delimiterOrValue, 0, 1)) . self::substr($delimiterOrValue, 1);
}
return $result;
} | [
"public",
"static",
"function",
"strtotitle",
"(",
"string",
"$",
"string",
")",
":",
"string",
"{",
"$",
"result",
"=",
"''",
";",
"$",
"splitIntoLowerCaseWords",
"=",
"preg_split",
"(",
"\"/([\\n\\r\\t ])/\"",
",",
"self",
"::",
"strtolower",
"(",
"$",
"st... | Converts the first character of each word to uppercase and all remaining characters
to lowercase.
@param string $string The string to convert
@return string The converted string
@api | [
"Converts",
"the",
"first",
"character",
"of",
"each",
"word",
"to",
"uppercase",
"and",
"all",
"remaining",
"characters",
"to",
"lowercase",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Utility.Unicode/Classes/Functions.php#L31-L39 |
neos/flow-development-collection | Neos.Utility.Unicode/Classes/Functions.php | Functions.substr | public static function substr(string $string, int $start, int $length = null)
{
if ($length === 0) {
return '';
}
// Cannot omit $length, when specifying charset
if ($length === null) {
// save internal encoding
$enc = mb_internal_encoding();
mb_internal_encoding('UTF-8');
$str = mb_substr($string, $start);
// restore internal encoding
mb_internal_encoding($enc);
return $str;
}
return mb_substr($string, $start, $length, 'UTF-8');
} | php | public static function substr(string $string, int $start, int $length = null)
{
if ($length === 0) {
return '';
}
// Cannot omit $length, when specifying charset
if ($length === null) {
// save internal encoding
$enc = mb_internal_encoding();
mb_internal_encoding('UTF-8');
$str = mb_substr($string, $start);
// restore internal encoding
mb_internal_encoding($enc);
return $str;
}
return mb_substr($string, $start, $length, 'UTF-8');
} | [
"public",
"static",
"function",
"substr",
"(",
"string",
"$",
"string",
",",
"int",
"$",
"start",
",",
"int",
"$",
"length",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"length",
"===",
"0",
")",
"{",
"return",
"''",
";",
"}",
"// Cannot omit $length, when ... | Unicode variant of substr()
@param string $string The string to crop
@param integer $start Position of the left boundary
@param integer $length (optional) Length of the returned string
@return string The processed string
@api | [
"Unicode",
"variant",
"of",
"substr",
"()"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Utility.Unicode/Classes/Functions.php#L50-L69 |
neos/flow-development-collection | Neos.Utility.Unicode/Classes/Functions.php | Functions.strtoupper | public static function strtoupper(string $string): string
{
return str_replace('ß', 'SS', mb_strtoupper($string, 'UTF-8'));
} | php | public static function strtoupper(string $string): string
{
return str_replace('ß', 'SS', mb_strtoupper($string, 'UTF-8'));
} | [
"public",
"static",
"function",
"strtoupper",
"(",
"string",
"$",
"string",
")",
":",
"string",
"{",
"return",
"str_replace",
"(",
"'ß',",
" ",
"SS',",
" ",
"b_strtoupper(",
"$",
"s",
"tring,",
" ",
"UTF-8')",
")",
";",
"",
"}"
] | Unicode variant of strtoupper()
@param string $string The string to uppercase
@return string The processed string
@api | [
"Unicode",
"variant",
"of",
"strtoupper",
"()"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Utility.Unicode/Classes/Functions.php#L78-L81 |
neos/flow-development-collection | Neos.Utility.Unicode/Classes/Functions.php | Functions.ucfirst | public static function ucfirst(string $string): string
{
return self::strtoupper(self::substr($string, 0, 1)) . self::substr($string, 1);
} | php | public static function ucfirst(string $string): string
{
return self::strtoupper(self::substr($string, 0, 1)) . self::substr($string, 1);
} | [
"public",
"static",
"function",
"ucfirst",
"(",
"string",
"$",
"string",
")",
":",
"string",
"{",
"return",
"self",
"::",
"strtoupper",
"(",
"self",
"::",
"substr",
"(",
"$",
"string",
",",
"0",
",",
"1",
")",
")",
".",
"self",
"::",
"substr",
"(",
... | Unicode variant of ucfirst() - assumes that the string is a Unicode string, not binary
@param string $string The string whose first letter should be uppercased
@return string The same string, first character uppercased
@api | [
"Unicode",
"variant",
"of",
"ucfirst",
"()",
"-",
"assumes",
"that",
"the",
"string",
"is",
"a",
"Unicode",
"string",
"not",
"binary"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Utility.Unicode/Classes/Functions.php#L114-L117 |
neos/flow-development-collection | Neos.Utility.Unicode/Classes/Functions.php | Functions.lcfirst | public static function lcfirst(string $string): string
{
return self::strtolower(self::substr($string, 0, 1)) . self::substr($string, 1);
} | php | public static function lcfirst(string $string): string
{
return self::strtolower(self::substr($string, 0, 1)) . self::substr($string, 1);
} | [
"public",
"static",
"function",
"lcfirst",
"(",
"string",
"$",
"string",
")",
":",
"string",
"{",
"return",
"self",
"::",
"strtolower",
"(",
"self",
"::",
"substr",
"(",
"$",
"string",
",",
"0",
",",
"1",
")",
")",
".",
"self",
"::",
"substr",
"(",
... | Unicode variant of lcfirst() - assumes that the string is a Unicode string, not binary
@param string $string The string whose first letter should be lowercased
@return string The same string, first character lowercased
@api | [
"Unicode",
"variant",
"of",
"lcfirst",
"()",
"-",
"assumes",
"that",
"the",
"string",
"is",
"a",
"Unicode",
"string",
"not",
"binary"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Utility.Unicode/Classes/Functions.php#L126-L129 |
neos/flow-development-collection | Neos.Utility.Unicode/Classes/Functions.php | Functions.strpos | public static function strpos(string $haystack, string $needle, int $offset = 0)
{
return mb_strpos($haystack, $needle, $offset, 'UTF-8');
} | php | public static function strpos(string $haystack, string $needle, int $offset = 0)
{
return mb_strpos($haystack, $needle, $offset, 'UTF-8');
} | [
"public",
"static",
"function",
"strpos",
"(",
"string",
"$",
"haystack",
",",
"string",
"$",
"needle",
",",
"int",
"$",
"offset",
"=",
"0",
")",
"{",
"return",
"mb_strpos",
"(",
"$",
"haystack",
",",
"$",
"needle",
",",
"$",
"offset",
",",
"'UTF-8'",
... | Unicode variant of strpos() - assumes that the string is a Unicode string, not binary
@param string $haystack UTF-8 string to search in
@param string $needle UTF-8 string to search for
@param integer $offset Positition to start the search
@return integer The character position
@api | [
"Unicode",
"variant",
"of",
"strpos",
"()",
"-",
"assumes",
"that",
"the",
"string",
"is",
"a",
"Unicode",
"string",
"not",
"binary"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Utility.Unicode/Classes/Functions.php#L140-L143 |
neos/flow-development-collection | Neos.Utility.Unicode/Classes/Functions.php | Functions.pathinfo | public static function pathinfo(string $path, int $options = null)
{
$currentLocale = setlocale(LC_CTYPE, 0);
// Before we have a setting for setlocale, his should suffice for pathinfo
// to work correctly on Unicode strings
setlocale(LC_CTYPE, 'en_US.UTF-8');
$pathinfo = $options == null ? pathinfo($path) : pathinfo($path, $options);
setlocale(LC_CTYPE, $currentLocale);
return $pathinfo;
} | php | public static function pathinfo(string $path, int $options = null)
{
$currentLocale = setlocale(LC_CTYPE, 0);
// Before we have a setting for setlocale, his should suffice for pathinfo
// to work correctly on Unicode strings
setlocale(LC_CTYPE, 'en_US.UTF-8');
$pathinfo = $options == null ? pathinfo($path) : pathinfo($path, $options);
setlocale(LC_CTYPE, $currentLocale);
return $pathinfo;
} | [
"public",
"static",
"function",
"pathinfo",
"(",
"string",
"$",
"path",
",",
"int",
"$",
"options",
"=",
"null",
")",
"{",
"$",
"currentLocale",
"=",
"setlocale",
"(",
"LC_CTYPE",
",",
"0",
")",
";",
"// Before we have a setting for setlocale, his should suffice f... | Unicode variant of pathinfo()
pathinfo() function is not unicode-friendly
if setlocale is not set. It's sufficient to set it
to any UTF-8 locale to correctly handle unicode strings.
This wrapper function temporarily sets locale to 'en_US.UTF-8'
and then restores original locale.
It's not necessary to use this function in cases,
where only file extension is determined, as it's
hard to imagine a unicode file extension.
@see http://www.php.net/manual/en/function.pathinfo.php
@param string $path
@param integer $options Optional, one of PATHINFO_DIRNAME, PATHINFO_BASENAME, PATHINFO_EXTENSION or PATHINFO_FILENAME.
@return string|array
@api | [
"Unicode",
"variant",
"of",
"pathinfo",
"()",
"pathinfo",
"()",
"function",
"is",
"not",
"unicode",
"-",
"friendly",
"if",
"setlocale",
"is",
"not",
"set",
".",
"It",
"s",
"sufficient",
"to",
"set",
"it",
"to",
"any",
"UTF",
"-",
"8",
"locale",
"to",
"... | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Utility.Unicode/Classes/Functions.php#L162-L171 |
neos/flow-development-collection | Neos.Utility.Unicode/Classes/Functions.php | Functions.parse_url | public static function parse_url(string $url, int $component = -1)
{
// the host and port must be used as is, to allow IPv6 syntax, e.g.: [3b00:f59:1008::212:183:20]:8080
// thus we parse here, before url-encoding
$componentsFromUrl = parse_url($url);
if ($componentsFromUrl === false) {
return false;
}
$encodedUrl = preg_replace_callback('%[^:@/?#&=\.]+%usD', function ($matches) {
return urlencode($matches[0]);
}, $url);
$components = parse_url($encodedUrl);
if ($components === false) {
return false;
}
foreach ($components as &$currentComponent) {
$currentComponent = urldecode($currentComponent);
}
// the host and port must be used as is, to allow IPv6 syntax, e.g.: [3b00:f59:1008::212:183:20]:8080
if (array_key_exists('host', $componentsFromUrl)) {
$components['host'] = $componentsFromUrl['host'];
}
if (array_key_exists('port', $componentsFromUrl)) {
$components['port'] = (integer)$componentsFromUrl['port'];
} else {
unset($components['port']);
}
switch ($component) {
case -1:
return $components;
case PHP_URL_SCHEME:
return $components['scheme'];
case PHP_URL_HOST:
return $components['host'];
case PHP_URL_PORT:
return $components['port'];
case PHP_URL_USER:
return $components['user'];
case PHP_URL_PASS:
return $components['pass'];
case PHP_URL_PATH:
return $components['path'];
case PHP_URL_QUERY:
return $components['query'];
case PHP_URL_FRAGMENT:
return $components['fragment'];
default:
throw new \InvalidArgumentException('Invalid component requested for URL parsing.', 1406280743);
}
} | php | public static function parse_url(string $url, int $component = -1)
{
// the host and port must be used as is, to allow IPv6 syntax, e.g.: [3b00:f59:1008::212:183:20]:8080
// thus we parse here, before url-encoding
$componentsFromUrl = parse_url($url);
if ($componentsFromUrl === false) {
return false;
}
$encodedUrl = preg_replace_callback('%[^:@/?#&=\.]+%usD', function ($matches) {
return urlencode($matches[0]);
}, $url);
$components = parse_url($encodedUrl);
if ($components === false) {
return false;
}
foreach ($components as &$currentComponent) {
$currentComponent = urldecode($currentComponent);
}
// the host and port must be used as is, to allow IPv6 syntax, e.g.: [3b00:f59:1008::212:183:20]:8080
if (array_key_exists('host', $componentsFromUrl)) {
$components['host'] = $componentsFromUrl['host'];
}
if (array_key_exists('port', $componentsFromUrl)) {
$components['port'] = (integer)$componentsFromUrl['port'];
} else {
unset($components['port']);
}
switch ($component) {
case -1:
return $components;
case PHP_URL_SCHEME:
return $components['scheme'];
case PHP_URL_HOST:
return $components['host'];
case PHP_URL_PORT:
return $components['port'];
case PHP_URL_USER:
return $components['user'];
case PHP_URL_PASS:
return $components['pass'];
case PHP_URL_PATH:
return $components['path'];
case PHP_URL_QUERY:
return $components['query'];
case PHP_URL_FRAGMENT:
return $components['fragment'];
default:
throw new \InvalidArgumentException('Invalid component requested for URL parsing.', 1406280743);
}
} | [
"public",
"static",
"function",
"parse_url",
"(",
"string",
"$",
"url",
",",
"int",
"$",
"component",
"=",
"-",
"1",
")",
"{",
"// the host and port must be used as is, to allow IPv6 syntax, e.g.: [3b00:f59:1008::212:183:20]:8080",
"// thus we parse here, before url-encoding",
... | Parse a URL and return its components, UTF-8 safe
@param string $url The URL to parse. Invalid characters are replaced by _.
@param integer $component Specify one of PHP_URL_SCHEME, PHP_URL_HOST, PHP_URL_PORT, PHP_URL_USER, PHP_URL_PASS, PHP_URL_PATH, PHP_URL_QUERY or PHP_URL_FRAGMENT to retrieve just a specific URL component as a string (except when PHP_URL_PORT is given, in which case the return value will be an integer).
@return mixed | [
"Parse",
"a",
"URL",
"and",
"return",
"its",
"components",
"UTF",
"-",
"8",
"safe"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Utility.Unicode/Classes/Functions.php#L180-L234 |
neos/flow-development-collection | Neos.Flow/Classes/Security/Policy/PolicyService.php | PolicyService.initialize | protected function initialize()
{
if ($this->initialized) {
return;
}
$this->policyConfiguration = $this->configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_POLICY);
$this->emitConfigurationLoaded($this->policyConfiguration);
$this->initializePrivilegeTargets();
$privilegeTargetsForEverybody = $this->privilegeTargets;
$this->roles = [];
$everybodyRole = new Role('Neos.Flow:Everybody');
$everybodyRole->setAbstract(true);
if (isset($this->policyConfiguration['roles'])) {
foreach ($this->policyConfiguration['roles'] as $roleIdentifier => $roleConfiguration) {
if ($roleIdentifier === 'Neos.Flow:Everybody') {
$role = $everybodyRole;
} else {
$role = new Role($roleIdentifier);
if (isset($roleConfiguration['abstract'])) {
$role->setAbstract((boolean)$roleConfiguration['abstract']);
}
}
if (isset($roleConfiguration['privileges'])) {
foreach ($roleConfiguration['privileges'] as $privilegeConfiguration) {
$privilegeTargetIdentifier = $privilegeConfiguration['privilegeTarget'];
if (!isset($this->privilegeTargets[$privilegeTargetIdentifier])) {
throw new SecurityException(sprintf('privilege target "%s", referenced in role configuration "%s" is not defined!', $privilegeTargetIdentifier, $roleIdentifier), 1395869320);
}
$privilegeTarget = $this->privilegeTargets[$privilegeTargetIdentifier];
if (!isset($privilegeConfiguration['permission'])) {
throw new SecurityException(sprintf('No permission set for privilegeTarget "%s" in Role "%s"', $privilegeTargetIdentifier, $roleIdentifier), 1395869331);
}
$privilegeParameters = isset($privilegeConfiguration['parameters']) ? $privilegeConfiguration['parameters'] : [];
try {
$privilege = $privilegeTarget->createPrivilege($privilegeConfiguration['permission'], $privilegeParameters);
} catch (\Exception $exception) {
throw new SecurityException(sprintf('Error for privilegeTarget "%s" in Role "%s": %s', $privilegeTargetIdentifier, $roleIdentifier, $exception->getMessage()), 1401886654, $exception);
}
$role->addPrivilege($privilege);
if ($roleIdentifier === 'Neos.Flow:Everybody') {
unset($privilegeTargetsForEverybody[$privilegeTargetIdentifier]);
}
}
}
$this->roles[$roleIdentifier] = $role;
}
}
// create ABSTAIN privilege for all uncovered privilegeTargets
/** @var PrivilegeTarget $privilegeTarget */
foreach ($privilegeTargetsForEverybody as $privilegeTarget) {
if ($privilegeTarget->hasParameters()) {
continue;
}
$everybodyRole->addPrivilege($privilegeTarget->createPrivilege(PrivilegeInterface::ABSTAIN));
}
$this->roles['Neos.Flow:Everybody'] = $everybodyRole;
// Set parent roles
/** @var Role $role */
foreach ($this->roles as $role) {
if (isset($this->policyConfiguration['roles'][$role->getIdentifier()]['parentRoles'])) {
foreach ($this->policyConfiguration['roles'][$role->getIdentifier()]['parentRoles'] as $parentRoleIdentifier) {
$role->addParentRole($this->roles[$parentRoleIdentifier]);
}
}
}
$this->emitRolesInitialized($this->roles);
$this->initialized = true;
} | php | protected function initialize()
{
if ($this->initialized) {
return;
}
$this->policyConfiguration = $this->configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_POLICY);
$this->emitConfigurationLoaded($this->policyConfiguration);
$this->initializePrivilegeTargets();
$privilegeTargetsForEverybody = $this->privilegeTargets;
$this->roles = [];
$everybodyRole = new Role('Neos.Flow:Everybody');
$everybodyRole->setAbstract(true);
if (isset($this->policyConfiguration['roles'])) {
foreach ($this->policyConfiguration['roles'] as $roleIdentifier => $roleConfiguration) {
if ($roleIdentifier === 'Neos.Flow:Everybody') {
$role = $everybodyRole;
} else {
$role = new Role($roleIdentifier);
if (isset($roleConfiguration['abstract'])) {
$role->setAbstract((boolean)$roleConfiguration['abstract']);
}
}
if (isset($roleConfiguration['privileges'])) {
foreach ($roleConfiguration['privileges'] as $privilegeConfiguration) {
$privilegeTargetIdentifier = $privilegeConfiguration['privilegeTarget'];
if (!isset($this->privilegeTargets[$privilegeTargetIdentifier])) {
throw new SecurityException(sprintf('privilege target "%s", referenced in role configuration "%s" is not defined!', $privilegeTargetIdentifier, $roleIdentifier), 1395869320);
}
$privilegeTarget = $this->privilegeTargets[$privilegeTargetIdentifier];
if (!isset($privilegeConfiguration['permission'])) {
throw new SecurityException(sprintf('No permission set for privilegeTarget "%s" in Role "%s"', $privilegeTargetIdentifier, $roleIdentifier), 1395869331);
}
$privilegeParameters = isset($privilegeConfiguration['parameters']) ? $privilegeConfiguration['parameters'] : [];
try {
$privilege = $privilegeTarget->createPrivilege($privilegeConfiguration['permission'], $privilegeParameters);
} catch (\Exception $exception) {
throw new SecurityException(sprintf('Error for privilegeTarget "%s" in Role "%s": %s', $privilegeTargetIdentifier, $roleIdentifier, $exception->getMessage()), 1401886654, $exception);
}
$role->addPrivilege($privilege);
if ($roleIdentifier === 'Neos.Flow:Everybody') {
unset($privilegeTargetsForEverybody[$privilegeTargetIdentifier]);
}
}
}
$this->roles[$roleIdentifier] = $role;
}
}
// create ABSTAIN privilege for all uncovered privilegeTargets
/** @var PrivilegeTarget $privilegeTarget */
foreach ($privilegeTargetsForEverybody as $privilegeTarget) {
if ($privilegeTarget->hasParameters()) {
continue;
}
$everybodyRole->addPrivilege($privilegeTarget->createPrivilege(PrivilegeInterface::ABSTAIN));
}
$this->roles['Neos.Flow:Everybody'] = $everybodyRole;
// Set parent roles
/** @var Role $role */
foreach ($this->roles as $role) {
if (isset($this->policyConfiguration['roles'][$role->getIdentifier()]['parentRoles'])) {
foreach ($this->policyConfiguration['roles'][$role->getIdentifier()]['parentRoles'] as $parentRoleIdentifier) {
$role->addParentRole($this->roles[$parentRoleIdentifier]);
}
}
}
$this->emitRolesInitialized($this->roles);
$this->initialized = true;
} | [
"protected",
"function",
"initialize",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"initialized",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"policyConfiguration",
"=",
"$",
"this",
"->",
"configurationManager",
"->",
"getConfiguration",
"(",
"Configu... | Parses the global policy configuration and initializes roles and privileges accordingly
@return void
@throws SecurityException | [
"Parses",
"the",
"global",
"policy",
"configuration",
"and",
"initializes",
"roles",
"and",
"privileges",
"accordingly"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Policy/PolicyService.php#L92-L170 |
neos/flow-development-collection | Neos.Flow/Classes/Security/Policy/PolicyService.php | PolicyService.initializePrivilegeTargets | protected function initializePrivilegeTargets()
{
if (!isset($this->policyConfiguration['privilegeTargets'])) {
return;
}
foreach ($this->policyConfiguration['privilegeTargets'] as $privilegeClassName => $privilegeTargetsConfiguration) {
foreach ($privilegeTargetsConfiguration as $privilegeTargetIdentifier => $privilegeTargetConfiguration) {
if (!isset($privilegeTargetConfiguration['matcher'])) {
throw new SecurityException(sprintf('No "matcher" configured for privilegeTarget "%s"', $privilegeTargetIdentifier), 1401795388);
}
$parameterDefinitions = [];
$privilegeParameterConfiguration = isset($privilegeTargetConfiguration['parameters']) ? $privilegeTargetConfiguration['parameters'] : [];
foreach ($privilegeParameterConfiguration as $parameterName => $parameterValue) {
if (!isset($privilegeTargetConfiguration['parameters'][$parameterName])) {
throw new SecurityException(sprintf('No parameter definition found for parameter "%s" in privilegeTarget "%s"', $parameterName, $privilegeTargetIdentifier), 1395869330);
}
if (!isset($privilegeTargetConfiguration['parameters'][$parameterName]['className'])) {
throw new SecurityException(sprintf('No "className" defined for parameter "%s" in privilegeTarget "%s"', $parameterName, $privilegeTargetIdentifier), 1396021782);
}
$parameterDefinitions[$parameterName] = new PrivilegeParameterDefinition($parameterName, $privilegeTargetConfiguration['parameters'][$parameterName]['className']);
}
$privilegeTarget = new PrivilegeTarget($privilegeTargetIdentifier, $privilegeClassName, $privilegeTargetConfiguration['matcher'], $parameterDefinitions);
$privilegeTarget->injectObjectManager($this->objectManager);
$this->privilegeTargets[$privilegeTargetIdentifier] = $privilegeTarget;
}
}
} | php | protected function initializePrivilegeTargets()
{
if (!isset($this->policyConfiguration['privilegeTargets'])) {
return;
}
foreach ($this->policyConfiguration['privilegeTargets'] as $privilegeClassName => $privilegeTargetsConfiguration) {
foreach ($privilegeTargetsConfiguration as $privilegeTargetIdentifier => $privilegeTargetConfiguration) {
if (!isset($privilegeTargetConfiguration['matcher'])) {
throw new SecurityException(sprintf('No "matcher" configured for privilegeTarget "%s"', $privilegeTargetIdentifier), 1401795388);
}
$parameterDefinitions = [];
$privilegeParameterConfiguration = isset($privilegeTargetConfiguration['parameters']) ? $privilegeTargetConfiguration['parameters'] : [];
foreach ($privilegeParameterConfiguration as $parameterName => $parameterValue) {
if (!isset($privilegeTargetConfiguration['parameters'][$parameterName])) {
throw new SecurityException(sprintf('No parameter definition found for parameter "%s" in privilegeTarget "%s"', $parameterName, $privilegeTargetIdentifier), 1395869330);
}
if (!isset($privilegeTargetConfiguration['parameters'][$parameterName]['className'])) {
throw new SecurityException(sprintf('No "className" defined for parameter "%s" in privilegeTarget "%s"', $parameterName, $privilegeTargetIdentifier), 1396021782);
}
$parameterDefinitions[$parameterName] = new PrivilegeParameterDefinition($parameterName, $privilegeTargetConfiguration['parameters'][$parameterName]['className']);
}
$privilegeTarget = new PrivilegeTarget($privilegeTargetIdentifier, $privilegeClassName, $privilegeTargetConfiguration['matcher'], $parameterDefinitions);
$privilegeTarget->injectObjectManager($this->objectManager);
$this->privilegeTargets[$privilegeTargetIdentifier] = $privilegeTarget;
}
}
} | [
"protected",
"function",
"initializePrivilegeTargets",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"policyConfiguration",
"[",
"'privilegeTargets'",
"]",
")",
")",
"{",
"return",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"policyConfigu... | Initialized all configured privilege targets from the policy definitions
@return void
@throws SecurityException | [
"Initialized",
"all",
"configured",
"privilege",
"targets",
"from",
"the",
"policy",
"definitions"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Policy/PolicyService.php#L178-L204 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.