repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6 values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1 value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
neos/flow-development-collection | Neos.Cache/Classes/Backend/MemcachedBackend.php | MemcachedBackend.removeIdentifierFromAllTags | protected function removeIdentifierFromAllTags(string $entryIdentifier)
{
// Get tags for this identifier
$tags = $this->findTagsByIdentifier($entryIdentifier);
// Deassociate tags with this identifier
foreach ($tags as $tag) {
$identifiers = $this->findIdentifiersByTag($tag);
// Formally array_search() below should never return false due to
// the behavior of findTagsByIdentifier(). But if reverse index is
// corrupted, we still can get 'false' from array_search(). This is
// not a problem because we are removing this identifier from
// anywhere.
if (($key = array_search($entryIdentifier, $identifiers)) !== false) {
unset($identifiers[$key]);
if (count($identifiers)) {
$this->memcache->set($this->identifierPrefix . 'tag_' . $tag, $identifiers);
} else {
$this->memcache->delete($this->identifierPrefix . 'tag_' . $tag);
}
}
}
// Clear reverse tag index for this identifier
$this->memcache->delete($this->identifierPrefix . 'ident_' . $entryIdentifier);
} | php | protected function removeIdentifierFromAllTags(string $entryIdentifier)
{
// Get tags for this identifier
$tags = $this->findTagsByIdentifier($entryIdentifier);
// Deassociate tags with this identifier
foreach ($tags as $tag) {
$identifiers = $this->findIdentifiersByTag($tag);
// Formally array_search() below should never return false due to
// the behavior of findTagsByIdentifier(). But if reverse index is
// corrupted, we still can get 'false' from array_search(). This is
// not a problem because we are removing this identifier from
// anywhere.
if (($key = array_search($entryIdentifier, $identifiers)) !== false) {
unset($identifiers[$key]);
if (count($identifiers)) {
$this->memcache->set($this->identifierPrefix . 'tag_' . $tag, $identifiers);
} else {
$this->memcache->delete($this->identifierPrefix . 'tag_' . $tag);
}
}
}
// Clear reverse tag index for this identifier
$this->memcache->delete($this->identifierPrefix . 'ident_' . $entryIdentifier);
} | [
"protected",
"function",
"removeIdentifierFromAllTags",
"(",
"string",
"$",
"entryIdentifier",
")",
"{",
"// Get tags for this identifier",
"$",
"tags",
"=",
"$",
"this",
"->",
"findTagsByIdentifier",
"(",
"$",
"entryIdentifier",
")",
";",
"// Deassociate tags with this i... | Removes association of the identifier with the given tags
@param string $entryIdentifier
@return void | [
"Removes",
"association",
"of",
"the",
"identifier",
"with",
"the",
"given",
"tags"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Cache/Classes/Backend/MemcachedBackend.php#L393-L416 |
neos/flow-development-collection | Neos.Flow/Classes/Reflection/ReflectionServiceFactory.php | ReflectionServiceFactory.create | public function create()
{
if ($this->reflectionService !== null) {
return $this->reflectionService;
}
$cacheManager = $this->bootstrap->getEarlyInstance(CacheManager::class);
$configurationManager = $this->bootstrap->getEarlyInstance(ConfigurationManager::class);
$settings = $configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, 'Neos.Flow');
$reflectionService = new ReflectionService();
$reflectionService->injectLogger($this->bootstrap->getEarlyInstance(PsrLoggerFactoryInterface::class)->get('systemLogger'));
$reflectionService->injectSettings($settings);
$reflectionService->injectPackageManager($this->bootstrap->getEarlyInstance(PackageManager::class));
$reflectionService->setStatusCache($cacheManager->getCache('Flow_Reflection_Status'));
$reflectionService->setReflectionDataCompiletimeCache($cacheManager->getCache('Flow_Reflection_CompiletimeData'));
$reflectionService->setReflectionDataRuntimeCache($cacheManager->getCache('Flow_Reflection_RuntimeData'));
$reflectionService->setClassSchemataRuntimeCache($cacheManager->getCache('Flow_Reflection_RuntimeClassSchemata'));
$reflectionService->injectEnvironment($this->bootstrap->getEarlyInstance(Environment::class));
$this->reflectionService = $reflectionService;
return $reflectionService;
} | php | public function create()
{
if ($this->reflectionService !== null) {
return $this->reflectionService;
}
$cacheManager = $this->bootstrap->getEarlyInstance(CacheManager::class);
$configurationManager = $this->bootstrap->getEarlyInstance(ConfigurationManager::class);
$settings = $configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, 'Neos.Flow');
$reflectionService = new ReflectionService();
$reflectionService->injectLogger($this->bootstrap->getEarlyInstance(PsrLoggerFactoryInterface::class)->get('systemLogger'));
$reflectionService->injectSettings($settings);
$reflectionService->injectPackageManager($this->bootstrap->getEarlyInstance(PackageManager::class));
$reflectionService->setStatusCache($cacheManager->getCache('Flow_Reflection_Status'));
$reflectionService->setReflectionDataCompiletimeCache($cacheManager->getCache('Flow_Reflection_CompiletimeData'));
$reflectionService->setReflectionDataRuntimeCache($cacheManager->getCache('Flow_Reflection_RuntimeData'));
$reflectionService->setClassSchemataRuntimeCache($cacheManager->getCache('Flow_Reflection_RuntimeClassSchemata'));
$reflectionService->injectEnvironment($this->bootstrap->getEarlyInstance(Environment::class));
$this->reflectionService = $reflectionService;
return $reflectionService;
} | [
"public",
"function",
"create",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"reflectionService",
"!==",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"reflectionService",
";",
"}",
"$",
"cacheManager",
"=",
"$",
"this",
"->",
"bootstrap",
"->",
"getEar... | Get reflection service instance | [
"Get",
"reflection",
"service",
"instance"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Reflection/ReflectionServiceFactory.php#L54-L76 |
neos/flow-development-collection | Neos.Utility.Arrays/Classes/Arrays.php | Arrays.integerExplode | public static function integerExplode(string $delimiter, string $string): array
{
$chunksArr = explode($delimiter, $string);
foreach ($chunksArr as $key => $value) {
$chunks[$key] = (int)$value;
}
reset($chunks);
return $chunks;
} | php | public static function integerExplode(string $delimiter, string $string): array
{
$chunksArr = explode($delimiter, $string);
foreach ($chunksArr as $key => $value) {
$chunks[$key] = (int)$value;
}
reset($chunks);
return $chunks;
} | [
"public",
"static",
"function",
"integerExplode",
"(",
"string",
"$",
"delimiter",
",",
"string",
"$",
"string",
")",
":",
"array",
"{",
"$",
"chunksArr",
"=",
"explode",
"(",
"$",
"delimiter",
",",
"$",
"string",
")",
";",
"foreach",
"(",
"$",
"chunksAr... | Explodes a $string delimited by $delimiter and passes each item in the array through intval().
Corresponds to explode(), but with conversion to integers for all values.
@param string $delimiter Delimiter string to explode with
@param string $string The string to explode
@return array Exploded values, all converted to integers | [
"Explodes",
"a",
"$string",
"delimited",
"by",
"$delimiter",
"and",
"passes",
"each",
"item",
"in",
"the",
"array",
"through",
"intval",
"()",
".",
"Corresponds",
"to",
"explode",
"()",
"but",
"with",
"conversion",
"to",
"integers",
"for",
"all",
"values",
"... | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Utility.Arrays/Classes/Arrays.php#L28-L36 |
neos/flow-development-collection | Neos.Utility.Arrays/Classes/Arrays.php | Arrays.trimExplode | public static function trimExplode(string $delimiter, string $string, bool $onlyNonEmptyValues = true): array
{
$chunksArr = explode($delimiter, $string);
$newChunksArr = [];
foreach ($chunksArr as $value) {
if ($onlyNonEmptyValues === false || strcmp('', trim($value))) {
$newChunksArr[] = trim($value);
}
}
reset($newChunksArr);
return $newChunksArr;
} | php | public static function trimExplode(string $delimiter, string $string, bool $onlyNonEmptyValues = true): array
{
$chunksArr = explode($delimiter, $string);
$newChunksArr = [];
foreach ($chunksArr as $value) {
if ($onlyNonEmptyValues === false || strcmp('', trim($value))) {
$newChunksArr[] = trim($value);
}
}
reset($newChunksArr);
return $newChunksArr;
} | [
"public",
"static",
"function",
"trimExplode",
"(",
"string",
"$",
"delimiter",
",",
"string",
"$",
"string",
",",
"bool",
"$",
"onlyNonEmptyValues",
"=",
"true",
")",
":",
"array",
"{",
"$",
"chunksArr",
"=",
"explode",
"(",
"$",
"delimiter",
",",
"$",
... | Explodes a string and trims all values for whitespace in the ends.
If $onlyNonEmptyValues is set, then all blank ('') values are removed.
@param string $delimiter Delimiter string to explode with
@param string $string The string to explode
@param boolean $onlyNonEmptyValues If disabled, even empty values (='') will be set in output
@return array Exploded values | [
"Explodes",
"a",
"string",
"and",
"trims",
"all",
"values",
"for",
"whitespace",
"in",
"the",
"ends",
".",
"If",
"$onlyNonEmptyValues",
"is",
"set",
"then",
"all",
"blank",
"(",
")",
"values",
"are",
"removed",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Utility.Arrays/Classes/Arrays.php#L47-L58 |
neos/flow-development-collection | Neos.Utility.Arrays/Classes/Arrays.php | Arrays.arrayMergeRecursiveOverrule | public static function arrayMergeRecursiveOverrule(array $firstArray, array $secondArray, bool $dontAddNewKeys = false, bool $emptyValuesOverride = true): array
{
$data = [&$firstArray, $secondArray];
$entryCount = 1;
for ($i = 0; $i < $entryCount; $i++) {
$firstArrayInner = &$data[$i * 2];
$secondArrayInner = $data[$i * 2 + 1];
foreach ($secondArrayInner as $key => $value) {
if (isset($firstArrayInner[$key]) && is_array($firstArrayInner[$key])) {
if ((!$emptyValuesOverride || $value !== []) && is_array($value)) {
$data[] = &$firstArrayInner[$key];
$data[] = $value;
$entryCount++;
} else {
$firstArrayInner[$key] = $value;
}
} else {
if ($dontAddNewKeys) {
if (array_key_exists($key, $firstArrayInner) && ($emptyValuesOverride || !empty($value))) {
$firstArrayInner[$key] = $value;
}
} else {
if ($emptyValuesOverride || !empty($value)) {
$firstArrayInner[$key] = $value;
} elseif (!isset($firstArrayInner[$key]) && $value === []) {
$firstArrayInner[$key] = $value;
}
}
}
}
}
reset($firstArray);
return $firstArray;
} | php | public static function arrayMergeRecursiveOverrule(array $firstArray, array $secondArray, bool $dontAddNewKeys = false, bool $emptyValuesOverride = true): array
{
$data = [&$firstArray, $secondArray];
$entryCount = 1;
for ($i = 0; $i < $entryCount; $i++) {
$firstArrayInner = &$data[$i * 2];
$secondArrayInner = $data[$i * 2 + 1];
foreach ($secondArrayInner as $key => $value) {
if (isset($firstArrayInner[$key]) && is_array($firstArrayInner[$key])) {
if ((!$emptyValuesOverride || $value !== []) && is_array($value)) {
$data[] = &$firstArrayInner[$key];
$data[] = $value;
$entryCount++;
} else {
$firstArrayInner[$key] = $value;
}
} else {
if ($dontAddNewKeys) {
if (array_key_exists($key, $firstArrayInner) && ($emptyValuesOverride || !empty($value))) {
$firstArrayInner[$key] = $value;
}
} else {
if ($emptyValuesOverride || !empty($value)) {
$firstArrayInner[$key] = $value;
} elseif (!isset($firstArrayInner[$key]) && $value === []) {
$firstArrayInner[$key] = $value;
}
}
}
}
}
reset($firstArray);
return $firstArray;
} | [
"public",
"static",
"function",
"arrayMergeRecursiveOverrule",
"(",
"array",
"$",
"firstArray",
",",
"array",
"$",
"secondArray",
",",
"bool",
"$",
"dontAddNewKeys",
"=",
"false",
",",
"bool",
"$",
"emptyValuesOverride",
"=",
"true",
")",
":",
"array",
"{",
"$... | Merges two arrays recursively and "binary safe" (integer keys are overridden as well), overruling similar values
in the first array ($firstArray) with the values of the second array ($secondArray) in case of identical keys,
ie. keeping the values of the second.
@param array $firstArray First array
@param array $secondArray Second array, overruling the first array
@param boolean $dontAddNewKeys If set, keys that are NOT found in $firstArray (first array) will not be set. Thus only existing value can/will be overruled from second array.
@param boolean $emptyValuesOverride If set (which is the default), values from $secondArray will overrule if they are empty (according to PHP's empty() function)
@return array Resulting array where $secondArray values has overruled $firstArray values | [
"Merges",
"two",
"arrays",
"recursively",
"and",
"binary",
"safe",
"(",
"integer",
"keys",
"are",
"overridden",
"as",
"well",
")",
"overruling",
"similar",
"values",
"in",
"the",
"first",
"array",
"(",
"$firstArray",
")",
"with",
"the",
"values",
"of",
"the"... | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Utility.Arrays/Classes/Arrays.php#L71-L104 |
neos/flow-development-collection | Neos.Utility.Arrays/Classes/Arrays.php | Arrays.arrayMergeRecursiveOverruleWithCallback | public static function arrayMergeRecursiveOverruleWithCallback(array $firstArray, array $secondArray, \Closure $toArray): array
{
$data = [&$firstArray, $secondArray];
$entryCount = 1;
for ($i = 0; $i < $entryCount; $i++) {
$firstArrayInner = &$data[$i * 2];
$secondArrayInner = $data[$i * 2 + 1];
foreach ($secondArrayInner as $key => $value) {
if (!isset($firstArrayInner[$key]) || (!is_array($firstArrayInner[$key]) && !is_array($value))) {
$firstArrayInner[$key] = $value;
} else {
if (!is_array($value)) {
$value = $toArray($value);
}
if (!is_array($firstArrayInner[$key])) {
$firstArrayInner[$key] = $toArray($firstArrayInner[$key]);
}
if (is_array($firstArrayInner[$key]) && is_array($value)) {
$data[] = &$firstArrayInner[$key];
$data[] = $value;
$entryCount++;
} else {
$firstArrayInner[$key] = $value;
}
}
}
}
reset($firstArray);
return $firstArray;
} | php | public static function arrayMergeRecursiveOverruleWithCallback(array $firstArray, array $secondArray, \Closure $toArray): array
{
$data = [&$firstArray, $secondArray];
$entryCount = 1;
for ($i = 0; $i < $entryCount; $i++) {
$firstArrayInner = &$data[$i * 2];
$secondArrayInner = $data[$i * 2 + 1];
foreach ($secondArrayInner as $key => $value) {
if (!isset($firstArrayInner[$key]) || (!is_array($firstArrayInner[$key]) && !is_array($value))) {
$firstArrayInner[$key] = $value;
} else {
if (!is_array($value)) {
$value = $toArray($value);
}
if (!is_array($firstArrayInner[$key])) {
$firstArrayInner[$key] = $toArray($firstArrayInner[$key]);
}
if (is_array($firstArrayInner[$key]) && is_array($value)) {
$data[] = &$firstArrayInner[$key];
$data[] = $value;
$entryCount++;
} else {
$firstArrayInner[$key] = $value;
}
}
}
}
reset($firstArray);
return $firstArray;
} | [
"public",
"static",
"function",
"arrayMergeRecursiveOverruleWithCallback",
"(",
"array",
"$",
"firstArray",
",",
"array",
"$",
"secondArray",
",",
"\\",
"Closure",
"$",
"toArray",
")",
":",
"array",
"{",
"$",
"data",
"=",
"[",
"&",
"$",
"firstArray",
",",
"$... | Merges two arrays recursively and "binary safe" (integer keys are overridden as well), overruling similar values in the first array ($firstArray) with the values of the second array ($secondArray)
In case of identical keys, ie. keeping the values of the second. The given $toArray closure will be used if one of the two array keys contains an array and the other not. It should return an array.
@param array $firstArray First array
@param array $secondArray Second array, overruling the first array
@param callable $toArray The given closure will get a value that is not an array and has to return an array. This is to allow custom merging of simple types with (sub) arrays
@return array Resulting array where $secondArray values has overruled $firstArray values | [
"Merges",
"two",
"arrays",
"recursively",
"and",
"binary",
"safe",
"(",
"integer",
"keys",
"are",
"overridden",
"as",
"well",
")",
"overruling",
"similar",
"values",
"in",
"the",
"first",
"array",
"(",
"$firstArray",
")",
"with",
"the",
"values",
"of",
"the"... | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Utility.Arrays/Classes/Arrays.php#L115-L145 |
neos/flow-development-collection | Neos.Utility.Arrays/Classes/Arrays.php | Arrays.containsMultipleTypes | public static function containsMultipleTypes(array $array): bool
{
if (count($array) > 0) {
reset($array);
$previousType = gettype(current($array));
next($array);
foreach ($array as $value) {
if ($previousType !== gettype($value)) {
return true;
}
}
}
return false;
} | php | public static function containsMultipleTypes(array $array): bool
{
if (count($array) > 0) {
reset($array);
$previousType = gettype(current($array));
next($array);
foreach ($array as $value) {
if ($previousType !== gettype($value)) {
return true;
}
}
}
return false;
} | [
"public",
"static",
"function",
"containsMultipleTypes",
"(",
"array",
"$",
"array",
")",
":",
"bool",
"{",
"if",
"(",
"count",
"(",
"$",
"array",
")",
">",
"0",
")",
"{",
"reset",
"(",
"$",
"array",
")",
";",
"$",
"previousType",
"=",
"gettype",
"("... | Returns true if the given array contains elements of varying types
@param array $array
@return boolean | [
"Returns",
"true",
"if",
"the",
"given",
"array",
"contains",
"elements",
"of",
"varying",
"types"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Utility.Arrays/Classes/Arrays.php#L153-L166 |
neos/flow-development-collection | Neos.Utility.Arrays/Classes/Arrays.php | Arrays.array_reduce | public static function array_reduce(array $array, string $function, $initial = null)
{
$accumulator = $initial;
foreach ($array as $value) {
$accumulator = $function($accumulator, $value);
}
return $accumulator;
} | php | public static function array_reduce(array $array, string $function, $initial = null)
{
$accumulator = $initial;
foreach ($array as $value) {
$accumulator = $function($accumulator, $value);
}
return $accumulator;
} | [
"public",
"static",
"function",
"array_reduce",
"(",
"array",
"$",
"array",
",",
"string",
"$",
"function",
",",
"$",
"initial",
"=",
"null",
")",
"{",
"$",
"accumulator",
"=",
"$",
"initial",
";",
"foreach",
"(",
"$",
"array",
"as",
"$",
"value",
")",... | Replacement for array_reduce that allows any type for $initial (instead
of only integer)
@param array $array the array to reduce
@param string $function the reduce function with the same order of parameters as in the native array_reduce (i.e. accumulator first, then current array element)
@param mixed $initial the initial accumulator value
@return mixed | [
"Replacement",
"for",
"array_reduce",
"that",
"allows",
"any",
"type",
"for",
"$initial",
"(",
"instead",
"of",
"only",
"integer",
")"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Utility.Arrays/Classes/Arrays.php#L177-L184 |
neos/flow-development-collection | Neos.Utility.Arrays/Classes/Arrays.php | Arrays.getValueByPath | public static function getValueByPath(array &$array, $path)
{
if (is_string($path)) {
$path = explode('.', $path);
} elseif (!is_array($path)) {
throw new \InvalidArgumentException('getValueByPath() expects $path to be string or array, "' . gettype($path) . '" given.', 1304950007);
}
$key = array_shift($path);
if (isset($array[$key])) {
if (count($path) > 0) {
return (is_array($array[$key])) ? self::getValueByPath($array[$key], $path) : null;
} else {
return $array[$key];
}
} else {
return null;
}
} | php | public static function getValueByPath(array &$array, $path)
{
if (is_string($path)) {
$path = explode('.', $path);
} elseif (!is_array($path)) {
throw new \InvalidArgumentException('getValueByPath() expects $path to be string or array, "' . gettype($path) . '" given.', 1304950007);
}
$key = array_shift($path);
if (isset($array[$key])) {
if (count($path) > 0) {
return (is_array($array[$key])) ? self::getValueByPath($array[$key], $path) : null;
} else {
return $array[$key];
}
} else {
return null;
}
} | [
"public",
"static",
"function",
"getValueByPath",
"(",
"array",
"&",
"$",
"array",
",",
"$",
"path",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"path",
")",
")",
"{",
"$",
"path",
"=",
"explode",
"(",
"'.'",
",",
"$",
"path",
")",
";",
"}",
"els... | Returns the value of a nested array by following the specifed path.
@param array &$array The array to traverse as a reference
@param array|string $path The path to follow. Either a simple array of keys or a string in the format 'foo.bar.baz'
@return mixed The value found, NULL if the path didn't exist (note there is no way to distinguish between a found NULL value and "path not found")
@throws \InvalidArgumentException | [
"Returns",
"the",
"value",
"of",
"a",
"nested",
"array",
"by",
"following",
"the",
"specifed",
"path",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Utility.Arrays/Classes/Arrays.php#L194-L211 |
neos/flow-development-collection | Neos.Utility.Arrays/Classes/Arrays.php | Arrays.setValueByPath | public static function setValueByPath($subject, $path, $value)
{
if (!is_array($subject) && !($subject instanceof \ArrayAccess)) {
throw new \InvalidArgumentException('setValueByPath() expects $subject to be array or an object implementing \ArrayAccess, "' . (is_object($subject) ? get_class($subject) : gettype($subject)) . '" given.', 1306424308);
}
if (is_string($path)) {
$path = explode('.', $path);
} elseif (!is_array($path)) {
throw new \InvalidArgumentException('setValueByPath() expects $path to be string or array, "' . gettype($path) . '" given.', 1305111499);
}
$key = array_shift($path);
if (count($path) === 0) {
$subject[$key] = $value;
} else {
if (!isset($subject[$key]) || !is_array($subject[$key])) {
$subject[$key] = [];
}
$subject[$key] = self::setValueByPath($subject[$key], $path, $value);
}
return $subject;
} | php | public static function setValueByPath($subject, $path, $value)
{
if (!is_array($subject) && !($subject instanceof \ArrayAccess)) {
throw new \InvalidArgumentException('setValueByPath() expects $subject to be array or an object implementing \ArrayAccess, "' . (is_object($subject) ? get_class($subject) : gettype($subject)) . '" given.', 1306424308);
}
if (is_string($path)) {
$path = explode('.', $path);
} elseif (!is_array($path)) {
throw new \InvalidArgumentException('setValueByPath() expects $path to be string or array, "' . gettype($path) . '" given.', 1305111499);
}
$key = array_shift($path);
if (count($path) === 0) {
$subject[$key] = $value;
} else {
if (!isset($subject[$key]) || !is_array($subject[$key])) {
$subject[$key] = [];
}
$subject[$key] = self::setValueByPath($subject[$key], $path, $value);
}
return $subject;
} | [
"public",
"static",
"function",
"setValueByPath",
"(",
"$",
"subject",
",",
"$",
"path",
",",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"subject",
")",
"&&",
"!",
"(",
"$",
"subject",
"instanceof",
"\\",
"ArrayAccess",
")",
")",
"... | Sets the given value in a nested array or object by following the specified path.
@param array|\ArrayAccess $subject The array or ArrayAccess instance to work on
@param array|string $path The path to follow. Either a simple array of keys or a string in the format 'foo.bar.baz'
@param mixed $value The value to set
@return array|\ArrayAccess The modified array or object
@throws \InvalidArgumentException | [
"Sets",
"the",
"given",
"value",
"in",
"a",
"nested",
"array",
"or",
"object",
"by",
"following",
"the",
"specified",
"path",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Utility.Arrays/Classes/Arrays.php#L222-L242 |
neos/flow-development-collection | Neos.Utility.Arrays/Classes/Arrays.php | Arrays.unsetValueByPath | public static function unsetValueByPath(array $array, $path): array
{
if (is_string($path)) {
$path = explode('.', $path);
} elseif (!is_array($path)) {
throw new \InvalidArgumentException('unsetValueByPath() expects $path to be string or array, "' . gettype($path) . '" given.', 1305111513);
}
$key = array_shift($path);
if (count($path) === 0) {
unset($array[$key]);
} else {
if (!isset($array[$key]) || !is_array($array[$key])) {
return $array;
}
$array[$key] = self::unsetValueByPath($array[$key], $path);
}
return $array;
} | php | public static function unsetValueByPath(array $array, $path): array
{
if (is_string($path)) {
$path = explode('.', $path);
} elseif (!is_array($path)) {
throw new \InvalidArgumentException('unsetValueByPath() expects $path to be string or array, "' . gettype($path) . '" given.', 1305111513);
}
$key = array_shift($path);
if (count($path) === 0) {
unset($array[$key]);
} else {
if (!isset($array[$key]) || !is_array($array[$key])) {
return $array;
}
$array[$key] = self::unsetValueByPath($array[$key], $path);
}
return $array;
} | [
"public",
"static",
"function",
"unsetValueByPath",
"(",
"array",
"$",
"array",
",",
"$",
"path",
")",
":",
"array",
"{",
"if",
"(",
"is_string",
"(",
"$",
"path",
")",
")",
"{",
"$",
"path",
"=",
"explode",
"(",
"'.'",
",",
"$",
"path",
")",
";",
... | Unsets an element/part of a nested array by following the specified path.
@param array $array The array
@param array|string $path The path to follow. Either a simple array of keys or a string in the format 'foo.bar.baz'
@return array The modified array
@throws \InvalidArgumentException | [
"Unsets",
"an",
"element",
"/",
"part",
"of",
"a",
"nested",
"array",
"by",
"following",
"the",
"specified",
"path",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Utility.Arrays/Classes/Arrays.php#L252-L269 |
neos/flow-development-collection | Neos.Utility.Arrays/Classes/Arrays.php | Arrays.sortKeysRecursively | public static function sortKeysRecursively(array &$array, int $sortFlags = null): bool
{
foreach ($array as &$value) {
if (is_array($value)) {
if (self::sortKeysRecursively($value, $sortFlags) === false) {
return false;
}
}
}
return ksort($array, $sortFlags);
} | php | public static function sortKeysRecursively(array &$array, int $sortFlags = null): bool
{
foreach ($array as &$value) {
if (is_array($value)) {
if (self::sortKeysRecursively($value, $sortFlags) === false) {
return false;
}
}
}
return ksort($array, $sortFlags);
} | [
"public",
"static",
"function",
"sortKeysRecursively",
"(",
"array",
"&",
"$",
"array",
",",
"int",
"$",
"sortFlags",
"=",
"null",
")",
":",
"bool",
"{",
"foreach",
"(",
"$",
"array",
"as",
"&",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$"... | Sorts multidimensional arrays by recursively calling ksort on its elements.
@param array $array the array to sort
@param integer $sortFlags may be used to modify the sorting behavior using these values (see http://www.php.net/manual/en/function.sort.php)
@return boolean true on success, false on failure
@see asort() | [
"Sorts",
"multidimensional",
"arrays",
"by",
"recursively",
"calling",
"ksort",
"on",
"its",
"elements",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Utility.Arrays/Classes/Arrays.php#L279-L289 |
neos/flow-development-collection | Neos.Utility.Arrays/Classes/Arrays.php | Arrays.convertObjectToArray | public static function convertObjectToArray($subject): array
{
if (!is_object($subject) && !is_array($subject)) {
throw new \InvalidArgumentException('convertObjectToArray expects either array or object as input, ' . gettype($subject) . ' given.', 1287059709);
}
if (is_object($subject)) {
$subject = (array)$subject;
}
foreach ($subject as $key => $value) {
if (is_array($value) || is_object($value)) {
$subject[$key] = self::convertObjectToArray($value);
}
}
return $subject;
} | php | public static function convertObjectToArray($subject): array
{
if (!is_object($subject) && !is_array($subject)) {
throw new \InvalidArgumentException('convertObjectToArray expects either array or object as input, ' . gettype($subject) . ' given.', 1287059709);
}
if (is_object($subject)) {
$subject = (array)$subject;
}
foreach ($subject as $key => $value) {
if (is_array($value) || is_object($value)) {
$subject[$key] = self::convertObjectToArray($value);
}
}
return $subject;
} | [
"public",
"static",
"function",
"convertObjectToArray",
"(",
"$",
"subject",
")",
":",
"array",
"{",
"if",
"(",
"!",
"is_object",
"(",
"$",
"subject",
")",
"&&",
"!",
"is_array",
"(",
"$",
"subject",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentE... | Recursively convert an object hierarchy into an associative array.
@param mixed $subject An object or array of objects
@return array The subject represented as an array
@throws \InvalidArgumentException | [
"Recursively",
"convert",
"an",
"object",
"hierarchy",
"into",
"an",
"associative",
"array",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Utility.Arrays/Classes/Arrays.php#L298-L312 |
neos/flow-development-collection | Neos.Utility.Arrays/Classes/Arrays.php | Arrays.removeEmptyElementsRecursively | public static function removeEmptyElementsRecursively(array $array): array
{
$result = $array;
foreach ($result as $key => $value) {
if (is_array($value)) {
$result[$key] = self::removeEmptyElementsRecursively($value);
if ($result[$key] === []) {
unset($result[$key]);
}
} elseif ($value === null) {
unset($result[$key]);
}
}
return $result;
} | php | public static function removeEmptyElementsRecursively(array $array): array
{
$result = $array;
foreach ($result as $key => $value) {
if (is_array($value)) {
$result[$key] = self::removeEmptyElementsRecursively($value);
if ($result[$key] === []) {
unset($result[$key]);
}
} elseif ($value === null) {
unset($result[$key]);
}
}
return $result;
} | [
"public",
"static",
"function",
"removeEmptyElementsRecursively",
"(",
"array",
"$",
"array",
")",
":",
"array",
"{",
"$",
"result",
"=",
"$",
"array",
";",
"foreach",
"(",
"$",
"result",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"is_a... | Recursively removes empty array elements.
@param array $array
@return array the modified array | [
"Recursively",
"removes",
"empty",
"array",
"elements",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Utility.Arrays/Classes/Arrays.php#L320-L334 |
neos/flow-development-collection | Neos.Flow/Classes/I18n/TranslationProvider/XliffTranslationProvider.php | XliffTranslationProvider.getTranslationByOriginalLabel | public function getTranslationByOriginalLabel($originalLabel, I18n\Locale $locale, $pluralForm = null, $sourceName = 'Main', $packageKey = 'Neos.Flow')
{
if ($pluralForm !== null) {
$pluralFormsForProvidedLocale = $this->pluralsReader->getPluralForms($locale);
if (!is_array($pluralFormsForProvidedLocale) || !in_array($pluralForm, $pluralFormsForProvidedLocale)) {
throw new Exception\InvalidPluralFormException('There is no plural form "' . $pluralForm . '" in "' . (string)$locale . '" locale.', 1281033386);
}
// We need to convert plural form's string to index, as they are accessed using integers in XLIFF files
$pluralFormIndex = (int)array_search($pluralForm, $pluralFormsForProvidedLocale);
} else {
$pluralFormIndex = 0;
}
$file = $this->fileProvider->getFile($packageKey . ':' . $sourceName, $locale);
return $file->getTargetBySource($originalLabel, $pluralFormIndex);
} | php | public function getTranslationByOriginalLabel($originalLabel, I18n\Locale $locale, $pluralForm = null, $sourceName = 'Main', $packageKey = 'Neos.Flow')
{
if ($pluralForm !== null) {
$pluralFormsForProvidedLocale = $this->pluralsReader->getPluralForms($locale);
if (!is_array($pluralFormsForProvidedLocale) || !in_array($pluralForm, $pluralFormsForProvidedLocale)) {
throw new Exception\InvalidPluralFormException('There is no plural form "' . $pluralForm . '" in "' . (string)$locale . '" locale.', 1281033386);
}
// We need to convert plural form's string to index, as they are accessed using integers in XLIFF files
$pluralFormIndex = (int)array_search($pluralForm, $pluralFormsForProvidedLocale);
} else {
$pluralFormIndex = 0;
}
$file = $this->fileProvider->getFile($packageKey . ':' . $sourceName, $locale);
return $file->getTargetBySource($originalLabel, $pluralFormIndex);
} | [
"public",
"function",
"getTranslationByOriginalLabel",
"(",
"$",
"originalLabel",
",",
"I18n",
"\\",
"Locale",
"$",
"locale",
",",
"$",
"pluralForm",
"=",
"null",
",",
"$",
"sourceName",
"=",
"'Main'",
",",
"$",
"packageKey",
"=",
"'Neos.Flow'",
")",
"{",
"i... | Returns translated label of $originalLabel from a file defined by $sourceName.
Chooses particular form of label if available and defined in $pluralForm.
@param string $originalLabel Label used as a key in order to find translation
@param I18n\Locale $locale Locale to use
@param string $pluralForm One of RULE constants of PluralsReader
@param string $sourceName A relative path to the filename with translations (labels' catalog)
@param string $packageKey Key of the package containing the source file
@return mixed Translated label or false on failure
@throws Exception\InvalidPluralFormException | [
"Returns",
"translated",
"label",
"of",
"$originalLabel",
"from",
"a",
"file",
"defined",
"by",
"$sourceName",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/I18n/TranslationProvider/XliffTranslationProvider.php#L66-L83 |
neos/flow-development-collection | Neos.Flow/Classes/I18n/TranslationProvider/XliffTranslationProvider.php | XliffTranslationProvider.getTranslationById | public function getTranslationById($labelId, I18n\Locale $locale, $pluralForm = null, $sourceName = 'Main', $packageKey = 'Neos.Flow')
{
if ($pluralForm !== null) {
$pluralFormsForProvidedLocale = $this->pluralsReader->getPluralForms($locale);
if (!in_array($pluralForm, $pluralFormsForProvidedLocale)) {
throw new Exception\InvalidPluralFormException('There is no plural form "' . $pluralForm . '" in "' . (string)$locale . '" locale.', 1281033387);
}
// We need to convert plural form's string to index, as they are accessed using integers in XLIFF files
$pluralFormIndex = (int)array_search($pluralForm, $pluralFormsForProvidedLocale);
} else {
$pluralFormIndex = 0;
}
$file = $this->fileProvider->getFile($packageKey . ':' . $sourceName, $locale);
return $file->getTargetByTransUnitId($labelId, $pluralFormIndex);
} | php | public function getTranslationById($labelId, I18n\Locale $locale, $pluralForm = null, $sourceName = 'Main', $packageKey = 'Neos.Flow')
{
if ($pluralForm !== null) {
$pluralFormsForProvidedLocale = $this->pluralsReader->getPluralForms($locale);
if (!in_array($pluralForm, $pluralFormsForProvidedLocale)) {
throw new Exception\InvalidPluralFormException('There is no plural form "' . $pluralForm . '" in "' . (string)$locale . '" locale.', 1281033387);
}
// We need to convert plural form's string to index, as they are accessed using integers in XLIFF files
$pluralFormIndex = (int)array_search($pluralForm, $pluralFormsForProvidedLocale);
} else {
$pluralFormIndex = 0;
}
$file = $this->fileProvider->getFile($packageKey . ':' . $sourceName, $locale);
return $file->getTargetByTransUnitId($labelId, $pluralFormIndex);
} | [
"public",
"function",
"getTranslationById",
"(",
"$",
"labelId",
",",
"I18n",
"\\",
"Locale",
"$",
"locale",
",",
"$",
"pluralForm",
"=",
"null",
",",
"$",
"sourceName",
"=",
"'Main'",
",",
"$",
"packageKey",
"=",
"'Neos.Flow'",
")",
"{",
"if",
"(",
"$",... | Returns label for a key ($labelId) from a file defined by $sourceName.
Chooses particular form of label if available and defined in $pluralForm.
@param string $labelId Key used to find translated label
@param I18n\Locale $locale Locale to use
@param string $pluralForm One of RULE constants of PluralsReader
@param string $sourceName A relative path to the filename with translations (labels' catalog)
@param string $packageKey Key of the package containing the source file
@return mixed Translated label or false on failure
@throws Exception\InvalidPluralFormException | [
"Returns",
"label",
"for",
"a",
"key",
"(",
"$labelId",
")",
"from",
"a",
"file",
"defined",
"by",
"$sourceName",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/I18n/TranslationProvider/XliffTranslationProvider.php#L98-L115 |
neos/flow-development-collection | Neos.Flow/Classes/ObjectManagement/Configuration/Configuration.php | Configuration.setProperties | public function setProperties(array $properties)
{
if ($properties === []) {
$this->properties = [];
} else {
foreach ($properties as $value) {
if ($value instanceof ConfigurationProperty) {
$this->setProperty($value);
} else {
throw new InvalidConfigurationException(sprintf('Only ConfigurationProperty instances are allowed, "%s" given', is_object($value) ? get_class($value) : gettype($value)), 1449217567);
}
}
}
} | php | public function setProperties(array $properties)
{
if ($properties === []) {
$this->properties = [];
} else {
foreach ($properties as $value) {
if ($value instanceof ConfigurationProperty) {
$this->setProperty($value);
} else {
throw new InvalidConfigurationException(sprintf('Only ConfigurationProperty instances are allowed, "%s" given', is_object($value) ? get_class($value) : gettype($value)), 1449217567);
}
}
}
} | [
"public",
"function",
"setProperties",
"(",
"array",
"$",
"properties",
")",
"{",
"if",
"(",
"$",
"properties",
"===",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"properties",
"=",
"[",
"]",
";",
"}",
"else",
"{",
"foreach",
"(",
"$",
"properties",
"as",... | Setter function for injection properties. If an empty array is passed to this
method, all (possibly) defined properties are removed from the configuration.
@param array $properties Array of ConfigurationProperty
@throws InvalidConfigurationException
@return void | [
"Setter",
"function",
"for",
"injection",
"properties",
".",
"If",
"an",
"empty",
"array",
"is",
"passed",
"to",
"this",
"method",
"all",
"(",
"possibly",
")",
"defined",
"properties",
"are",
"removed",
"from",
"the",
"configuration",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ObjectManagement/Configuration/Configuration.php#L333-L346 |
neos/flow-development-collection | Neos.Flow/Classes/ObjectManagement/Configuration/Configuration.php | Configuration.setArguments | public function setArguments(array $arguments)
{
if ($arguments === []) {
$this->arguments = [];
} else {
foreach ($arguments as $argument) {
if ($argument !== null && $argument instanceof ConfigurationArgument) {
$this->setArgument($argument);
} else {
throw new InvalidConfigurationException(sprintf('Only ConfigurationArgument instances are allowed, "%s" given', is_object($argument) ? get_class($argument) : gettype($argument)), 1449217803);
}
}
}
} | php | public function setArguments(array $arguments)
{
if ($arguments === []) {
$this->arguments = [];
} else {
foreach ($arguments as $argument) {
if ($argument !== null && $argument instanceof ConfigurationArgument) {
$this->setArgument($argument);
} else {
throw new InvalidConfigurationException(sprintf('Only ConfigurationArgument instances are allowed, "%s" given', is_object($argument) ? get_class($argument) : gettype($argument)), 1449217803);
}
}
}
} | [
"public",
"function",
"setArguments",
"(",
"array",
"$",
"arguments",
")",
"{",
"if",
"(",
"$",
"arguments",
"===",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"arguments",
"=",
"[",
"]",
";",
"}",
"else",
"{",
"foreach",
"(",
"$",
"arguments",
"as",
"$... | Setter function for injection constructor arguments. If an empty array is passed to this
method, all (possibly) defined constructor arguments are removed from the configuration.
@param array<ConfigurationArgument> $arguments
@throws InvalidConfigurationException
@return void | [
"Setter",
"function",
"for",
"injection",
"constructor",
"arguments",
".",
"If",
"an",
"empty",
"array",
"is",
"passed",
"to",
"this",
"method",
"all",
"(",
"possibly",
")",
"defined",
"constructor",
"arguments",
"are",
"removed",
"from",
"the",
"configuration",... | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ObjectManagement/Configuration/Configuration.php#L377-L390 |
neos/flow-development-collection | Neos.Flow/Classes/ObjectManagement/Configuration/Configuration.php | Configuration.getArguments | public function getArguments()
{
if (count($this->arguments) < 1) {
return [];
}
asort($this->arguments);
$lastArgument = end($this->arguments);
$argumentsCount = $lastArgument->getIndex();
$sortedArguments = [];
for ($index = 1; $index <= $argumentsCount; $index++) {
$sortedArguments[$index] = isset($this->arguments[$index]) ? $this->arguments[$index] : null;
}
return $sortedArguments;
} | php | public function getArguments()
{
if (count($this->arguments) < 1) {
return [];
}
asort($this->arguments);
$lastArgument = end($this->arguments);
$argumentsCount = $lastArgument->getIndex();
$sortedArguments = [];
for ($index = 1; $index <= $argumentsCount; $index++) {
$sortedArguments[$index] = isset($this->arguments[$index]) ? $this->arguments[$index] : null;
}
return $sortedArguments;
} | [
"public",
"function",
"getArguments",
"(",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"arguments",
")",
"<",
"1",
")",
"{",
"return",
"[",
"]",
";",
"}",
"asort",
"(",
"$",
"this",
"->",
"arguments",
")",
";",
"$",
"lastArgument",
"=",
... | Returns a sorted array of constructor arguments indexed by position (starting with "1")
@return array<ConfigurationArgument> A sorted array of ConfigurationArgument objects with the argument position as index | [
"Returns",
"a",
"sorted",
"array",
"of",
"constructor",
"arguments",
"indexed",
"by",
"position",
"(",
"starting",
"with",
"1",
")"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ObjectManagement/Configuration/Configuration.php#L408-L422 |
neos/flow-development-collection | Neos.Flow/Classes/Http/Component/TrustedProxiesComponent.php | TrustedProxiesComponent.getTrustedProxyHeaderValues | protected function getTrustedProxyHeaderValues($type, ServerRequestInterface $request)
{
if (isset($this->settings['headers']) && is_string($this->settings['headers'])) {
$trustedHeaders = $this->settings['headers'];
} else {
$trustedHeaders = $this->settings['headers'][$type] ?? '';
}
if ($trustedHeaders === '' || !$request->getAttribute(Request::ATTRIBUTE_TRUSTED_PROXY)) {
yield null;
return;
}
$trustedHeaders = array_map('trim', explode(',', $trustedHeaders));
foreach ($trustedHeaders as $trustedHeader) {
if (!$request->hasHeader($trustedHeader)) {
continue;
}
if (strtolower($trustedHeader) === 'forwarded') {
$forwardedHeaderValue = $this->getForwardedHeader($type, $request->getHeader($trustedHeader));
if ($forwardedHeaderValue !== null) {
yield $forwardedHeaderValue;
}
} else {
yield array_map('trim', explode(',', $request->getHeader($trustedHeader)));
}
}
yield null;
} | php | protected function getTrustedProxyHeaderValues($type, ServerRequestInterface $request)
{
if (isset($this->settings['headers']) && is_string($this->settings['headers'])) {
$trustedHeaders = $this->settings['headers'];
} else {
$trustedHeaders = $this->settings['headers'][$type] ?? '';
}
if ($trustedHeaders === '' || !$request->getAttribute(Request::ATTRIBUTE_TRUSTED_PROXY)) {
yield null;
return;
}
$trustedHeaders = array_map('trim', explode(',', $trustedHeaders));
foreach ($trustedHeaders as $trustedHeader) {
if (!$request->hasHeader($trustedHeader)) {
continue;
}
if (strtolower($trustedHeader) === 'forwarded') {
$forwardedHeaderValue = $this->getForwardedHeader($type, $request->getHeader($trustedHeader));
if ($forwardedHeaderValue !== null) {
yield $forwardedHeaderValue;
}
} else {
yield array_map('trim', explode(',', $request->getHeader($trustedHeader)));
}
}
yield null;
} | [
"protected",
"function",
"getTrustedProxyHeaderValues",
"(",
"$",
"type",
",",
"ServerRequestInterface",
"$",
"request",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"settings",
"[",
"'headers'",
"]",
")",
"&&",
"is_string",
"(",
"$",
"this",
"->",
... | Get the values of trusted proxy header.
@param string $type One of the HEADER_* constants
@param ServerRequestInterface $request The request to get the trusted proxy header from
@return \Iterator An array of the values for this header type or NULL if this header type should not be trusted | [
"Get",
"the",
"values",
"of",
"trusted",
"proxy",
"header",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Http/Component/TrustedProxiesComponent.php#L125-L153 |
neos/flow-development-collection | Neos.Flow/Classes/Http/Component/TrustedProxiesComponent.php | TrustedProxiesComponent.getFirstTrustedProxyHeaderValue | protected function getFirstTrustedProxyHeaderValue($type, Request $request)
{
$values = $this->getTrustedProxyHeaderValues($type, $request)->current();
return $values !== null ? reset($values) : null;
} | php | protected function getFirstTrustedProxyHeaderValue($type, Request $request)
{
$values = $this->getTrustedProxyHeaderValues($type, $request)->current();
return $values !== null ? reset($values) : null;
} | [
"protected",
"function",
"getFirstTrustedProxyHeaderValue",
"(",
"$",
"type",
",",
"Request",
"$",
"request",
")",
"{",
"$",
"values",
"=",
"$",
"this",
"->",
"getTrustedProxyHeaderValues",
"(",
"$",
"type",
",",
"$",
"request",
")",
"->",
"current",
"(",
")... | Convenience getter for the first value of a given trusted proxy header.
@param string $type One of the HEADER_* constants
@param Request $request The request to get the trusted proxy header from
@return mixed|null The first value of this header type or NULL if this header type should not be trusted | [
"Convenience",
"getter",
"for",
"the",
"first",
"value",
"of",
"a",
"given",
"trusted",
"proxy",
"header",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Http/Component/TrustedProxiesComponent.php#L162-L166 |
neos/flow-development-collection | Neos.Flow/Classes/Http/Component/TrustedProxiesComponent.php | TrustedProxiesComponent.ipIsTrustedProxy | protected function ipIsTrustedProxy($ipAddress)
{
if (filter_var($ipAddress, FILTER_VALIDATE_IP) === false) {
return false;
}
$allowedProxies = $this->settings['proxies'];
if ($allowedProxies === '*') {
return true;
}
if (is_string($allowedProxies)) {
$allowedProxies = array_map('trim', explode(',', $allowedProxies));
}
if (!is_array($allowedProxies)) {
return false;
}
foreach ($allowedProxies as $ipPattern) {
if (IpUtility::cidrMatch($ipAddress, $ipPattern)) {
return true;
}
}
return false;
} | php | protected function ipIsTrustedProxy($ipAddress)
{
if (filter_var($ipAddress, FILTER_VALIDATE_IP) === false) {
return false;
}
$allowedProxies = $this->settings['proxies'];
if ($allowedProxies === '*') {
return true;
}
if (is_string($allowedProxies)) {
$allowedProxies = array_map('trim', explode(',', $allowedProxies));
}
if (!is_array($allowedProxies)) {
return false;
}
foreach ($allowedProxies as $ipPattern) {
if (IpUtility::cidrMatch($ipAddress, $ipPattern)) {
return true;
}
}
return false;
} | [
"protected",
"function",
"ipIsTrustedProxy",
"(",
"$",
"ipAddress",
")",
"{",
"if",
"(",
"filter_var",
"(",
"$",
"ipAddress",
",",
"FILTER_VALIDATE_IP",
")",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}",
"$",
"allowedProxies",
"=",
"$",
"this",
"-... | Check if the given IP address is from a trusted proxy.
@param string $ipAddress
@return bool | [
"Check",
"if",
"the",
"given",
"IP",
"address",
"is",
"from",
"a",
"trusted",
"proxy",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Http/Component/TrustedProxiesComponent.php#L174-L195 |
neos/flow-development-collection | Neos.Flow/Classes/Http/Component/TrustedProxiesComponent.php | TrustedProxiesComponent.isFromTrustedProxy | protected function isFromTrustedProxy(Request $request)
{
$server = $request->getServerParams();
if (!isset($server['REMOTE_ADDR'])) {
return false;
}
return $this->ipIsTrustedProxy($server['REMOTE_ADDR']);
} | php | protected function isFromTrustedProxy(Request $request)
{
$server = $request->getServerParams();
if (!isset($server['REMOTE_ADDR'])) {
return false;
}
return $this->ipIsTrustedProxy($server['REMOTE_ADDR']);
} | [
"protected",
"function",
"isFromTrustedProxy",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"server",
"=",
"$",
"request",
"->",
"getServerParams",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"server",
"[",
"'REMOTE_ADDR'",
"]",
")",
")",
"{",
... | Check if the given request is from a trusted proxy.
@param Request $request
@return bool If the server REMOTE_ADDR is from a trusted proxy | [
"Check",
"if",
"the",
"given",
"request",
"is",
"from",
"a",
"trusted",
"proxy",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Http/Component/TrustedProxiesComponent.php#L203-L210 |
neos/flow-development-collection | Neos.Flow/Classes/Http/Component/TrustedProxiesComponent.php | TrustedProxiesComponent.getTrustedClientIpAddress | protected function getTrustedClientIpAddress(ServerRequestInterface $request)
{
$server = $request->getServerParams();
if (!isset($server['REMOTE_ADDR'])) {
return false;
}
$ipAddress = $server['REMOTE_ADDR'];
$trustedIpHeaders = $this->getTrustedProxyHeaderValues(self::HEADER_CLIENT_IP, $request);
$trustedIpHeader = [];
while ($trustedIpHeaders->valid()) {
$trustedIpHeader = $trustedIpHeaders->current();
if ($trustedIpHeader === null || empty($this->settings['proxies'])) {
return $server['REMOTE_ADDR'];
}
$ipAddress = reset($trustedIpHeader);
if (filter_var($ipAddress, FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE | FILTER_FLAG_NO_PRIV_RANGE) !== false) {
break;
}
$trustedIpHeaders->next();
}
if ($this->settings['proxies'] === '*') {
return $ipAddress;
}
$ipAddress = false;
foreach (array_reverse($trustedIpHeader) as $headerIpAddress) {
$portPosition = strpos($headerIpAddress, ':');
$ipAddress = $portPosition !== false ? substr($headerIpAddress, 0, $portPosition) : $headerIpAddress;
if (!$this->ipIsTrustedProxy($ipAddress)) {
break;
}
}
return $ipAddress;
} | php | protected function getTrustedClientIpAddress(ServerRequestInterface $request)
{
$server = $request->getServerParams();
if (!isset($server['REMOTE_ADDR'])) {
return false;
}
$ipAddress = $server['REMOTE_ADDR'];
$trustedIpHeaders = $this->getTrustedProxyHeaderValues(self::HEADER_CLIENT_IP, $request);
$trustedIpHeader = [];
while ($trustedIpHeaders->valid()) {
$trustedIpHeader = $trustedIpHeaders->current();
if ($trustedIpHeader === null || empty($this->settings['proxies'])) {
return $server['REMOTE_ADDR'];
}
$ipAddress = reset($trustedIpHeader);
if (filter_var($ipAddress, FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE | FILTER_FLAG_NO_PRIV_RANGE) !== false) {
break;
}
$trustedIpHeaders->next();
}
if ($this->settings['proxies'] === '*') {
return $ipAddress;
}
$ipAddress = false;
foreach (array_reverse($trustedIpHeader) as $headerIpAddress) {
$portPosition = strpos($headerIpAddress, ':');
$ipAddress = $portPosition !== false ? substr($headerIpAddress, 0, $portPosition) : $headerIpAddress;
if (!$this->ipIsTrustedProxy($ipAddress)) {
break;
}
}
return $ipAddress;
} | [
"protected",
"function",
"getTrustedClientIpAddress",
"(",
"ServerRequestInterface",
"$",
"request",
")",
"{",
"$",
"server",
"=",
"$",
"request",
"->",
"getServerParams",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"server",
"[",
"'REMOTE_ADDR'",
"]",
... | Get the most trusted client's IP address.
This is the right-most address in the trusted client IP header, that is not a trusted proxy address.
If all proxies are trusted, this is the left-most address in the header.
If no proxies are trusted or no client IP header is trusted, this is the remote address of the machine
directly connected to the server.
@param ServerRequestInterface $request
@return string|bool The most trusted client's IP address or false if no remote address can be found | [
"Get",
"the",
"most",
"trusted",
"client",
"s",
"IP",
"address",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Http/Component/TrustedProxiesComponent.php#L223-L259 |
neos/flow-development-collection | Neos.FluidAdaptor/Classes/Core/Parser/TemplateProcessor/EscapingFlagProcessor.php | EscapingFlagProcessor.preProcessSource | public function preProcessSource($templateSource)
{
$matches = [];
preg_match_all(self::$SCAN_PATTERN_ESCAPINGMODIFIER, $templateSource, $matches, PREG_SET_ORDER);
if ($matches === []) {
return $templateSource;
}
if (count($matches) > 1) {
throw new Exception('There is more than one escaping modifier defined. There can only be one {escapingEnabled=...} per template.', 1407331080);
}
if (strtolower($matches[0]['enabled']) === 'false') {
$this->renderingContext->getTemplateParser()->setEscapingEnabled(false);
}
$templateSource = preg_replace(self::$SCAN_PATTERN_ESCAPINGMODIFIER, '', $templateSource);
return $templateSource;
} | php | public function preProcessSource($templateSource)
{
$matches = [];
preg_match_all(self::$SCAN_PATTERN_ESCAPINGMODIFIER, $templateSource, $matches, PREG_SET_ORDER);
if ($matches === []) {
return $templateSource;
}
if (count($matches) > 1) {
throw new Exception('There is more than one escaping modifier defined. There can only be one {escapingEnabled=...} per template.', 1407331080);
}
if (strtolower($matches[0]['enabled']) === 'false') {
$this->renderingContext->getTemplateParser()->setEscapingEnabled(false);
}
$templateSource = preg_replace(self::$SCAN_PATTERN_ESCAPINGMODIFIER, '', $templateSource);
return $templateSource;
} | [
"public",
"function",
"preProcessSource",
"(",
"$",
"templateSource",
")",
"{",
"$",
"matches",
"=",
"[",
"]",
";",
"preg_match_all",
"(",
"self",
"::",
"$",
"SCAN_PATTERN_ESCAPINGMODIFIER",
",",
"$",
"templateSource",
",",
"$",
"matches",
",",
"PREG_SET_ORDER",... | Pre-process the template source before it is
returned to the TemplateParser or passed to
the next TemplateProcessorInterface instance.
@param string $templateSource
@return string | [
"Pre",
"-",
"process",
"the",
"template",
"source",
"before",
"it",
"is",
"returned",
"to",
"the",
"TemplateParser",
"or",
"passed",
"to",
"the",
"next",
"TemplateProcessorInterface",
"instance",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.FluidAdaptor/Classes/Core/Parser/TemplateProcessor/EscapingFlagProcessor.php#L46-L62 |
neos/flow-development-collection | Neos.Eel/Classes/FlowQuery/Operations/AddOperation.php | AddOperation.evaluate | public function evaluate(FlowQuery $flowQuery, array $arguments)
{
$output = [];
foreach ($flowQuery->getContext() as $element) {
$output[] = $element;
}
if (isset($arguments[0])) {
if (is_array($arguments[0]) || $arguments[0] instanceof \Traversable) {
foreach ($arguments[0] as $element) {
$output[] = $element;
}
} else {
$output[] = $arguments[0];
}
}
$flowQuery->setContext($output);
} | php | public function evaluate(FlowQuery $flowQuery, array $arguments)
{
$output = [];
foreach ($flowQuery->getContext() as $element) {
$output[] = $element;
}
if (isset($arguments[0])) {
if (is_array($arguments[0]) || $arguments[0] instanceof \Traversable) {
foreach ($arguments[0] as $element) {
$output[] = $element;
}
} else {
$output[] = $arguments[0];
}
}
$flowQuery->setContext($output);
} | [
"public",
"function",
"evaluate",
"(",
"FlowQuery",
"$",
"flowQuery",
",",
"array",
"$",
"arguments",
")",
"{",
"$",
"output",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"flowQuery",
"->",
"getContext",
"(",
")",
"as",
"$",
"element",
")",
"{",
"$",
"o... | {@inheritdoc}
@param FlowQuery $flowQuery the FlowQuery object
@param array $arguments the elements to add (as array in index 0)
@return void | [
"{",
"@inheritdoc",
"}"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Eel/Classes/FlowQuery/Operations/AddOperation.php#L37-L53 |
neos/flow-development-collection | Neos.Flow/Classes/SignalSlot/SignalAspect.php | SignalAspect.forwardSignalToDispatcher | public function forwardSignalToDispatcher(JoinPointInterface $joinPoint)
{
$signalName = lcfirst(str_replace('emit', '', $joinPoint->getMethodName()));
$this->dispatcher->dispatch($joinPoint->getClassName(), $signalName, $joinPoint->getMethodArguments());
} | php | public function forwardSignalToDispatcher(JoinPointInterface $joinPoint)
{
$signalName = lcfirst(str_replace('emit', '', $joinPoint->getMethodName()));
$this->dispatcher->dispatch($joinPoint->getClassName(), $signalName, $joinPoint->getMethodArguments());
} | [
"public",
"function",
"forwardSignalToDispatcher",
"(",
"JoinPointInterface",
"$",
"joinPoint",
")",
"{",
"$",
"signalName",
"=",
"lcfirst",
"(",
"str_replace",
"(",
"'emit'",
",",
"''",
",",
"$",
"joinPoint",
"->",
"getMethodName",
"(",
")",
")",
")",
";",
... | Passes the signal over to the Dispatcher
@Flow\AfterReturning("methodAnnotatedWith(Neos\Flow\Annotations\Signal)")
@param JoinPointInterface $joinPoint The current join point
@return void | [
"Passes",
"the",
"signal",
"over",
"to",
"the",
"Dispatcher"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/SignalSlot/SignalAspect.php#L38-L42 |
neos/flow-development-collection | Neos.Flow/Classes/Http/Component/ComponentChain.php | ComponentChain.handle | public function handle(ComponentContext $componentContext)
{
if (!isset($this->options['components'])) {
return;
}
/** @var ComponentInterface $component */
foreach ($this->options['components'] as $component) {
if ($component === null) {
continue;
}
$component->handle($componentContext);
$this->response = $componentContext->getHttpResponse();
if ($componentContext->getParameter(ComponentChain::class, 'cancel') === true) {
$componentContext->setParameter(ComponentChain::class, 'cancel', null);
return;
}
}
} | php | public function handle(ComponentContext $componentContext)
{
if (!isset($this->options['components'])) {
return;
}
/** @var ComponentInterface $component */
foreach ($this->options['components'] as $component) {
if ($component === null) {
continue;
}
$component->handle($componentContext);
$this->response = $componentContext->getHttpResponse();
if ($componentContext->getParameter(ComponentChain::class, 'cancel') === true) {
$componentContext->setParameter(ComponentChain::class, 'cancel', null);
return;
}
}
} | [
"public",
"function",
"handle",
"(",
"ComponentContext",
"$",
"componentContext",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"options",
"[",
"'components'",
"]",
")",
")",
"{",
"return",
";",
"}",
"/** @var ComponentInterface $component */",
"f... | Handle the configured components in the order of the chain
@param ComponentContext $componentContext
@return void | [
"Handle",
"the",
"configured",
"components",
"in",
"the",
"order",
"of",
"the",
"chain"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Http/Component/ComponentChain.php#L51-L68 |
neos/flow-development-collection | Neos.Flow/Classes/Session/Session.php | Session.injectSettings | public function injectSettings(array $settings)
{
$this->sessionCookieName = $settings['session']['name'];
$this->sessionCookieLifetime = (integer)$settings['session']['cookie']['lifetime'];
$this->sessionCookieDomain = $settings['session']['cookie']['domain'];
$this->sessionCookiePath = $settings['session']['cookie']['path'];
$this->sessionCookieSecure = (boolean)$settings['session']['cookie']['secure'];
$this->sessionCookieHttpOnly = (boolean)$settings['session']['cookie']['httponly'];
$this->garbageCollectionProbability = $settings['session']['garbageCollection']['probability'];
$this->garbageCollectionMaximumPerRun = $settings['session']['garbageCollection']['maximumPerRun'];
$this->inactivityTimeout = (integer)$settings['session']['inactivityTimeout'];
} | php | public function injectSettings(array $settings)
{
$this->sessionCookieName = $settings['session']['name'];
$this->sessionCookieLifetime = (integer)$settings['session']['cookie']['lifetime'];
$this->sessionCookieDomain = $settings['session']['cookie']['domain'];
$this->sessionCookiePath = $settings['session']['cookie']['path'];
$this->sessionCookieSecure = (boolean)$settings['session']['cookie']['secure'];
$this->sessionCookieHttpOnly = (boolean)$settings['session']['cookie']['httponly'];
$this->garbageCollectionProbability = $settings['session']['garbageCollection']['probability'];
$this->garbageCollectionMaximumPerRun = $settings['session']['garbageCollection']['maximumPerRun'];
$this->inactivityTimeout = (integer)$settings['session']['inactivityTimeout'];
} | [
"public",
"function",
"injectSettings",
"(",
"array",
"$",
"settings",
")",
"{",
"$",
"this",
"->",
"sessionCookieName",
"=",
"$",
"settings",
"[",
"'session'",
"]",
"[",
"'name'",
"]",
";",
"$",
"this",
"->",
"sessionCookieLifetime",
"=",
"(",
"integer",
... | Injects the Flow settings
@param array $settings Settings of the Flow package
@return void | [
"Injects",
"the",
"Flow",
"settings"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Session/Session.php#L227-L238 |
neos/flow-development-collection | Neos.Flow/Classes/Session/Session.php | Session.start | public function start()
{
if ($this->started === false) {
$this->sessionIdentifier = Algorithms::generateRandomString(32);
$this->storageIdentifier = Algorithms::generateUUID();
$this->sessionCookie = new Cookie($this->sessionCookieName, $this->sessionIdentifier, 0, $this->sessionCookieLifetime, $this->sessionCookieDomain, $this->sessionCookiePath, $this->sessionCookieSecure, $this->sessionCookieHttpOnly);
$this->lastActivityTimestamp = $this->now;
$this->started = true;
$this->writeSessionMetaDataCacheEntry();
}
} | php | public function start()
{
if ($this->started === false) {
$this->sessionIdentifier = Algorithms::generateRandomString(32);
$this->storageIdentifier = Algorithms::generateUUID();
$this->sessionCookie = new Cookie($this->sessionCookieName, $this->sessionIdentifier, 0, $this->sessionCookieLifetime, $this->sessionCookieDomain, $this->sessionCookiePath, $this->sessionCookieSecure, $this->sessionCookieHttpOnly);
$this->lastActivityTimestamp = $this->now;
$this->started = true;
$this->writeSessionMetaDataCacheEntry();
}
} | [
"public",
"function",
"start",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"started",
"===",
"false",
")",
"{",
"$",
"this",
"->",
"sessionIdentifier",
"=",
"Algorithms",
"::",
"generateRandomString",
"(",
"32",
")",
";",
"$",
"this",
"->",
"storageIden... | Starts the session, if it has not been already started
@return void
@api
@deprecated This method is not deprecated, but be aware that from next major a cookie will no longer be auto generated.
@see CookieEnabledInterface | [
"Starts",
"the",
"session",
"if",
"it",
"has",
"not",
"been",
"already",
"started"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Session/Session.php#L304-L315 |
neos/flow-development-collection | Neos.Flow/Classes/Session/Session.php | Session.canBeResumed | public function canBeResumed()
{
if ($this->sessionCookie === null || $this->started === true) {
return false;
}
$sessionMetaData = $this->metaDataCache->get($this->sessionCookie->getValue());
if ($sessionMetaData === false) {
return false;
}
$this->lastActivityTimestamp = $sessionMetaData['lastActivityTimestamp'];
$this->storageIdentifier = $sessionMetaData['storageIdentifier'];
$this->tags = $sessionMetaData['tags'];
return !$this->autoExpire();
} | php | public function canBeResumed()
{
if ($this->sessionCookie === null || $this->started === true) {
return false;
}
$sessionMetaData = $this->metaDataCache->get($this->sessionCookie->getValue());
if ($sessionMetaData === false) {
return false;
}
$this->lastActivityTimestamp = $sessionMetaData['lastActivityTimestamp'];
$this->storageIdentifier = $sessionMetaData['storageIdentifier'];
$this->tags = $sessionMetaData['tags'];
return !$this->autoExpire();
} | [
"public",
"function",
"canBeResumed",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"sessionCookie",
"===",
"null",
"||",
"$",
"this",
"->",
"started",
"===",
"true",
")",
"{",
"return",
"false",
";",
"}",
"$",
"sessionMetaData",
"=",
"$",
"this",
"->",... | Returns true if there is a session that can be resumed.
If a to-be-resumed session was inactive for too long, this function will
trigger the expiration of that session. An expired session cannot be resumed.
NOTE that this method does a bit more than the name implies: Because the
session info data needs to be loaded, this method stores this data already
so it doesn't have to be loaded again once the session is being used.
@return boolean
@api | [
"Returns",
"true",
"if",
"there",
"is",
"a",
"session",
"that",
"can",
"be",
"resumed",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Session/Session.php#L330-L343 |
neos/flow-development-collection | Neos.Flow/Classes/Session/Session.php | Session.resume | public function resume()
{
if ($this->started === false && $this->canBeResumed()) {
$this->started = true;
$sessionObjects = $this->storageCache->get($this->storageIdentifier . md5('Neos_Flow_Object_ObjectManager'));
if (is_array($sessionObjects)) {
foreach ($sessionObjects as $object) {
if ($object instanceof ProxyInterface) {
$objectName = $this->objectManager->getObjectNameByClassName(get_class($object));
if ($this->objectManager->getScope($objectName) === ObjectConfiguration::SCOPE_SESSION) {
$this->objectManager->setInstance($objectName, $object);
$this->objectManager->get(Aspect\LazyLoadingAspect::class)->registerSessionInstance($objectName, $object);
}
}
}
} else {
// Fallback for some malformed session data, if it is no array but something else.
// In this case, we reset all session objects (graceful degradation).
$this->storageCache->set($this->storageIdentifier . md5('Neos_Flow_Object_ObjectManager'), [], [$this->storageIdentifier], 0);
}
$lastActivitySecondsAgo = ($this->now - $this->lastActivityTimestamp);
$this->lastActivityTimestamp = $this->now;
return $lastActivitySecondsAgo;
}
} | php | public function resume()
{
if ($this->started === false && $this->canBeResumed()) {
$this->started = true;
$sessionObjects = $this->storageCache->get($this->storageIdentifier . md5('Neos_Flow_Object_ObjectManager'));
if (is_array($sessionObjects)) {
foreach ($sessionObjects as $object) {
if ($object instanceof ProxyInterface) {
$objectName = $this->objectManager->getObjectNameByClassName(get_class($object));
if ($this->objectManager->getScope($objectName) === ObjectConfiguration::SCOPE_SESSION) {
$this->objectManager->setInstance($objectName, $object);
$this->objectManager->get(Aspect\LazyLoadingAspect::class)->registerSessionInstance($objectName, $object);
}
}
}
} else {
// Fallback for some malformed session data, if it is no array but something else.
// In this case, we reset all session objects (graceful degradation).
$this->storageCache->set($this->storageIdentifier . md5('Neos_Flow_Object_ObjectManager'), [], [$this->storageIdentifier], 0);
}
$lastActivitySecondsAgo = ($this->now - $this->lastActivityTimestamp);
$this->lastActivityTimestamp = $this->now;
return $lastActivitySecondsAgo;
}
} | [
"public",
"function",
"resume",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"started",
"===",
"false",
"&&",
"$",
"this",
"->",
"canBeResumed",
"(",
")",
")",
"{",
"$",
"this",
"->",
"started",
"=",
"true",
";",
"$",
"sessionObjects",
"=",
"$",
"t... | Resumes an existing session, if any.
@return integer If a session was resumed, the inactivity of this session since the last request is returned
@api | [
"Resumes",
"an",
"existing",
"session",
"if",
"any",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Session/Session.php#L351-L377 |
neos/flow-development-collection | Neos.Flow/Classes/Session/Session.php | Session.renewId | public function renewId()
{
if ($this->started !== true) {
throw new Exception\SessionNotStartedException('Tried to renew the session identifier, but the session has not been started yet.', 1351182429);
}
if ($this->remote === true) {
throw new Exception\OperationNotSupportedException(sprintf('Tried to renew the session identifier on a remote session (%s).', $this->sessionIdentifier), 1354034230);
}
$this->removeSessionMetaDataCacheEntry($this->sessionIdentifier);
$this->sessionIdentifier = Algorithms::generateRandomString(32);
$this->writeSessionMetaDataCacheEntry();
$this->sessionCookie->setValue($this->sessionIdentifier);
return $this->sessionIdentifier;
} | php | public function renewId()
{
if ($this->started !== true) {
throw new Exception\SessionNotStartedException('Tried to renew the session identifier, but the session has not been started yet.', 1351182429);
}
if ($this->remote === true) {
throw new Exception\OperationNotSupportedException(sprintf('Tried to renew the session identifier on a remote session (%s).', $this->sessionIdentifier), 1354034230);
}
$this->removeSessionMetaDataCacheEntry($this->sessionIdentifier);
$this->sessionIdentifier = Algorithms::generateRandomString(32);
$this->writeSessionMetaDataCacheEntry();
$this->sessionCookie->setValue($this->sessionIdentifier);
return $this->sessionIdentifier;
} | [
"public",
"function",
"renewId",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"started",
"!==",
"true",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"SessionNotStartedException",
"(",
"'Tried to renew the session identifier, but the session has not been started yet.'",
... | Generates and propagates a new session ID and transfers all existing data
to the new session.
@return string The new session ID
@throws Exception\SessionNotStartedException
@throws Exception\OperationNotSupportedException
@api | [
"Generates",
"and",
"propagates",
"a",
"new",
"session",
"ID",
"and",
"transfers",
"all",
"existing",
"data",
"to",
"the",
"new",
"session",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Session/Session.php#L403-L418 |
neos/flow-development-collection | Neos.Flow/Classes/Session/Session.php | Session.getData | public function getData($key)
{
if ($this->started !== true) {
throw new Exception\SessionNotStartedException('Tried to get session data, but the session has not been started yet.', 1351162255);
}
return $this->storageCache->get($this->storageIdentifier . md5($key));
} | php | public function getData($key)
{
if ($this->started !== true) {
throw new Exception\SessionNotStartedException('Tried to get session data, but the session has not been started yet.', 1351162255);
}
return $this->storageCache->get($this->storageIdentifier . md5($key));
} | [
"public",
"function",
"getData",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"started",
"!==",
"true",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"SessionNotStartedException",
"(",
"'Tried to get session data, but the session has not been started yet.'"... | Returns the data associated with the given key.
@param string $key An identifier for the content stored in the session.
@return mixed The contents associated with the given key
@throws Exception\SessionNotStartedException | [
"Returns",
"the",
"data",
"associated",
"with",
"the",
"given",
"key",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Session/Session.php#L427-L433 |
neos/flow-development-collection | Neos.Flow/Classes/Session/Session.php | Session.hasKey | public function hasKey($key)
{
if ($this->started !== true) {
throw new Exception\SessionNotStartedException('Tried to check a session data entry, but the session has not been started yet.', 1352488661);
}
return $this->storageCache->has($this->storageIdentifier . md5($key));
} | php | public function hasKey($key)
{
if ($this->started !== true) {
throw new Exception\SessionNotStartedException('Tried to check a session data entry, but the session has not been started yet.', 1352488661);
}
return $this->storageCache->has($this->storageIdentifier . md5($key));
} | [
"public",
"function",
"hasKey",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"started",
"!==",
"true",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"SessionNotStartedException",
"(",
"'Tried to check a session data entry, but the session has not been start... | Returns true if a session data entry $key is available.
@param string $key Entry identifier of the session data
@return boolean
@throws Exception\SessionNotStartedException | [
"Returns",
"true",
"if",
"a",
"session",
"data",
"entry",
"$key",
"is",
"available",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Session/Session.php#L442-L448 |
neos/flow-development-collection | Neos.Flow/Classes/Session/Session.php | Session.putData | public function putData($key, $data)
{
if ($this->started !== true) {
throw new Exception\SessionNotStartedException('Tried to create a session data entry, but the session has not been started yet.', 1351162259);
}
if (is_resource($data)) {
throw new Exception\DataNotSerializableException('The given data cannot be stored in a session, because it is of type "' . gettype($data) . '".', 1351162262);
}
$this->storageCache->set($this->storageIdentifier . md5($key), $data, [$this->storageIdentifier], 0);
} | php | public function putData($key, $data)
{
if ($this->started !== true) {
throw new Exception\SessionNotStartedException('Tried to create a session data entry, but the session has not been started yet.', 1351162259);
}
if (is_resource($data)) {
throw new Exception\DataNotSerializableException('The given data cannot be stored in a session, because it is of type "' . gettype($data) . '".', 1351162262);
}
$this->storageCache->set($this->storageIdentifier . md5($key), $data, [$this->storageIdentifier], 0);
} | [
"public",
"function",
"putData",
"(",
"$",
"key",
",",
"$",
"data",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"started",
"!==",
"true",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"SessionNotStartedException",
"(",
"'Tried to create a session data entry, but the ... | Stores the given data under the given key in the session
@param string $key The key under which the data should be stored
@param mixed $data The data to be stored
@return void
@throws Exception\DataNotSerializableException
@throws Exception\SessionNotStartedException
@api | [
"Stores",
"the",
"given",
"data",
"under",
"the",
"given",
"key",
"in",
"the",
"session"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Session/Session.php#L460-L469 |
neos/flow-development-collection | Neos.Flow/Classes/Session/Session.php | Session.addTag | public function addTag($tag)
{
if ($this->started !== true) {
throw new Exception\SessionNotStartedException('Tried to tag a session which has not been started yet.', 1355143533);
}
if (!$this->metaDataCache->isValidTag($tag)) {
throw new \InvalidArgumentException(sprintf('The tag used for tagging session %s contained invalid characters. Make sure it matches this regular expression: "%s"', $this->sessionIdentifier, FrontendInterface::PATTERN_TAG));
}
if (!in_array($tag, $this->tags)) {
$this->tags[] = $tag;
}
} | php | public function addTag($tag)
{
if ($this->started !== true) {
throw new Exception\SessionNotStartedException('Tried to tag a session which has not been started yet.', 1355143533);
}
if (!$this->metaDataCache->isValidTag($tag)) {
throw new \InvalidArgumentException(sprintf('The tag used for tagging session %s contained invalid characters. Make sure it matches this regular expression: "%s"', $this->sessionIdentifier, FrontendInterface::PATTERN_TAG));
}
if (!in_array($tag, $this->tags)) {
$this->tags[] = $tag;
}
} | [
"public",
"function",
"addTag",
"(",
"$",
"tag",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"started",
"!==",
"true",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"SessionNotStartedException",
"(",
"'Tried to tag a session which has not been started yet.'",
",",
"135... | Tags this session with the given tag.
Note that third-party libraries might also tag your session. Therefore it is
recommended to use namespaced tags such as "Acme-Demo-MySpecialTag".
@param string $tag The tag – must match be a valid cache frontend tag
@return void
@throws Exception\SessionNotStartedException
@throws \InvalidArgumentException
@api | [
"Tags",
"this",
"session",
"with",
"the",
"given",
"tag",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Session/Session.php#L502-L513 |
neos/flow-development-collection | Neos.Flow/Classes/Session/Session.php | Session.removeTag | public function removeTag($tag)
{
if ($this->started !== true) {
throw new Exception\SessionNotStartedException('Tried to tag a session which has not been started yet.', 1355150140);
}
$index = array_search($tag, $this->tags);
if ($index !== false) {
unset($this->tags[$index]);
}
} | php | public function removeTag($tag)
{
if ($this->started !== true) {
throw new Exception\SessionNotStartedException('Tried to tag a session which has not been started yet.', 1355150140);
}
$index = array_search($tag, $this->tags);
if ($index !== false) {
unset($this->tags[$index]);
}
} | [
"public",
"function",
"removeTag",
"(",
"$",
"tag",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"started",
"!==",
"true",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"SessionNotStartedException",
"(",
"'Tried to tag a session which has not been started yet.'",
",",
"... | Removes the specified tag from this session.
@param string $tag The tag – must match be a valid cache frontend tag
@return void
@throws Exception\SessionNotStartedException
@api | [
"Removes",
"the",
"specified",
"tag",
"from",
"this",
"session",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Session/Session.php#L523-L532 |
neos/flow-development-collection | Neos.Flow/Classes/Session/Session.php | Session.touch | public function touch()
{
if ($this->started !== true) {
throw new Exception\SessionNotStartedException('Tried to touch a session, but the session has not been started yet.', 1354284318);
}
// Only makes sense for remote sessions because the currently active session
// will be updated on shutdown anyway:
if ($this->remote === true) {
$this->lastActivityTimestamp = $this->now;
$this->writeSessionMetaDataCacheEntry();
}
} | php | public function touch()
{
if ($this->started !== true) {
throw new Exception\SessionNotStartedException('Tried to touch a session, but the session has not been started yet.', 1354284318);
}
// Only makes sense for remote sessions because the currently active session
// will be updated on shutdown anyway:
if ($this->remote === true) {
$this->lastActivityTimestamp = $this->now;
$this->writeSessionMetaDataCacheEntry();
}
} | [
"public",
"function",
"touch",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"started",
"!==",
"true",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"SessionNotStartedException",
"(",
"'Tried to touch a session, but the session has not been started yet.'",
",",
"1354284... | Updates the last activity time to "now".
@return void
@throws Exception\SessionNotStartedException | [
"Updates",
"the",
"last",
"activity",
"time",
"to",
"now",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Session/Session.php#L556-L568 |
neos/flow-development-collection | Neos.Flow/Classes/Session/Session.php | Session.destroy | public function destroy($reason = null)
{
if ($this->started !== true) {
throw new Exception\SessionNotStartedException('Tried to destroy a session which has not been started yet.', 1351162668);
}
if ($this->remote !== true) {
$this->sessionCookie->expire();
}
$this->removeSessionMetaDataCacheEntry($this->sessionIdentifier);
$this->storageCache->flushByTag($this->storageIdentifier);
$this->started = false;
$this->sessionIdentifier = null;
$this->storageIdentifier = null;
$this->tags = [];
$this->request = null;
} | php | public function destroy($reason = null)
{
if ($this->started !== true) {
throw new Exception\SessionNotStartedException('Tried to destroy a session which has not been started yet.', 1351162668);
}
if ($this->remote !== true) {
$this->sessionCookie->expire();
}
$this->removeSessionMetaDataCacheEntry($this->sessionIdentifier);
$this->storageCache->flushByTag($this->storageIdentifier);
$this->started = false;
$this->sessionIdentifier = null;
$this->storageIdentifier = null;
$this->tags = [];
$this->request = null;
} | [
"public",
"function",
"destroy",
"(",
"$",
"reason",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"started",
"!==",
"true",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"SessionNotStartedException",
"(",
"'Tried to destroy a session which has not been star... | Explicitly destroys all session data
@param string $reason A reason for destroying the session – used by the LoggingAspect
@return void
@throws Exception\SessionNotStartedException
@api | [
"Explicitly",
"destroys",
"all",
"session",
"data"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Session/Session.php#L589-L606 |
neos/flow-development-collection | Neos.Flow/Classes/Session/Session.php | Session.collectGarbage | public function collectGarbage()
{
if ($this->inactivityTimeout === 0) {
return 0;
}
if ($this->metaDataCache->has('_garbage-collection-running')) {
return false;
}
$sessionRemovalCount = 0;
$this->metaDataCache->set('_garbage-collection-running', true, [], 120);
foreach ($this->metaDataCache->getIterator() as $sessionIdentifier => $sessionInfo) {
if ($sessionIdentifier === '_garbage-collection-running') {
continue;
}
$lastActivitySecondsAgo = $this->now - $sessionInfo['lastActivityTimestamp'];
if ($lastActivitySecondsAgo > $this->inactivityTimeout) {
if ($sessionInfo['storageIdentifier'] === null) {
$this->logger->warning('SESSION INFO INVALID: ' . $sessionIdentifier, $sessionInfo + LogEnvironment::fromMethodName(__METHOD__));
} else {
$this->storageCache->flushByTag($sessionInfo['storageIdentifier']);
$sessionRemovalCount++;
}
$this->metaDataCache->remove($sessionIdentifier);
}
if ($sessionRemovalCount >= $this->garbageCollectionMaximumPerRun) {
break;
}
}
$this->metaDataCache->remove('_garbage-collection-running');
return $sessionRemovalCount;
} | php | public function collectGarbage()
{
if ($this->inactivityTimeout === 0) {
return 0;
}
if ($this->metaDataCache->has('_garbage-collection-running')) {
return false;
}
$sessionRemovalCount = 0;
$this->metaDataCache->set('_garbage-collection-running', true, [], 120);
foreach ($this->metaDataCache->getIterator() as $sessionIdentifier => $sessionInfo) {
if ($sessionIdentifier === '_garbage-collection-running') {
continue;
}
$lastActivitySecondsAgo = $this->now - $sessionInfo['lastActivityTimestamp'];
if ($lastActivitySecondsAgo > $this->inactivityTimeout) {
if ($sessionInfo['storageIdentifier'] === null) {
$this->logger->warning('SESSION INFO INVALID: ' . $sessionIdentifier, $sessionInfo + LogEnvironment::fromMethodName(__METHOD__));
} else {
$this->storageCache->flushByTag($sessionInfo['storageIdentifier']);
$sessionRemovalCount++;
}
$this->metaDataCache->remove($sessionIdentifier);
}
if ($sessionRemovalCount >= $this->garbageCollectionMaximumPerRun) {
break;
}
}
$this->metaDataCache->remove('_garbage-collection-running');
return $sessionRemovalCount;
} | [
"public",
"function",
"collectGarbage",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"inactivityTimeout",
"===",
"0",
")",
"{",
"return",
"0",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"metaDataCache",
"->",
"has",
"(",
"'_garbage-collection-running'",
")",
... | Iterates over all existing sessions and removes their data if the inactivity
timeout was reached.
@return integer The number of outdated entries removed
@throws \Neos\Cache\Exception
@throws NotSupportedByBackendException
@api | [
"Iterates",
"over",
"all",
"existing",
"sessions",
"and",
"removes",
"their",
"data",
"if",
"the",
"inactivity",
"timeout",
"was",
"reached",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Session/Session.php#L617-L650 |
neos/flow-development-collection | Neos.Flow/Classes/Session/Session.php | Session.shutdownObject | public function shutdownObject()
{
if ($this->started === true && $this->remote === false) {
if ($this->metaDataCache->has($this->sessionIdentifier)) {
// Security context can't be injected and must be retrieved manually
// because it relies on this very session object:
$securityContext = $this->objectManager->get(Context::class);
if ($securityContext->isInitialized()) {
$this->storeAuthenticatedAccountsInfo($securityContext->getAuthenticationTokens());
}
$this->putData('Neos_Flow_Object_ObjectManager', $this->objectManager->getSessionInstances());
$this->writeSessionMetaDataCacheEntry();
}
$this->started = false;
$decimals = (integer)strlen(strrchr($this->garbageCollectionProbability, '.')) - 1;
$factor = ($decimals > -1) ? $decimals * 10 : 1;
if (rand(1, 100 * $factor) <= ($this->garbageCollectionProbability * $factor)) {
$this->collectGarbage();
}
}
} | php | public function shutdownObject()
{
if ($this->started === true && $this->remote === false) {
if ($this->metaDataCache->has($this->sessionIdentifier)) {
// Security context can't be injected and must be retrieved manually
// because it relies on this very session object:
$securityContext = $this->objectManager->get(Context::class);
if ($securityContext->isInitialized()) {
$this->storeAuthenticatedAccountsInfo($securityContext->getAuthenticationTokens());
}
$this->putData('Neos_Flow_Object_ObjectManager', $this->objectManager->getSessionInstances());
$this->writeSessionMetaDataCacheEntry();
}
$this->started = false;
$decimals = (integer)strlen(strrchr($this->garbageCollectionProbability, '.')) - 1;
$factor = ($decimals > -1) ? $decimals * 10 : 1;
if (rand(1, 100 * $factor) <= ($this->garbageCollectionProbability * $factor)) {
$this->collectGarbage();
}
}
} | [
"public",
"function",
"shutdownObject",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"started",
"===",
"true",
"&&",
"$",
"this",
"->",
"remote",
"===",
"false",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"metaDataCache",
"->",
"has",
"(",
"$",
"this",
... | Shuts down this session
This method must not be called manually – it is invoked by Flow's object
management.
@return void
@throws Exception\DataNotSerializableException
@throws Exception\SessionNotStartedException
@throws NotSupportedByBackendException
@throws \Neos\Cache\Exception | [
"Shuts",
"down",
"this",
"session"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Session/Session.php#L664-L686 |
neos/flow-development-collection | Neos.Flow/Classes/Session/Session.php | Session.autoExpire | protected function autoExpire()
{
$lastActivitySecondsAgo = $this->now - $this->lastActivityTimestamp;
$expired = false;
if ($this->inactivityTimeout !== 0 && $lastActivitySecondsAgo > $this->inactivityTimeout) {
$this->started = true;
$this->sessionIdentifier = $this->sessionCookie->getValue();
$this->destroy(sprintf('Session %s was inactive for %s seconds, more than the configured timeout of %s seconds.', $this->sessionIdentifier, $lastActivitySecondsAgo, $this->inactivityTimeout));
$expired = true;
}
return $expired;
} | php | protected function autoExpire()
{
$lastActivitySecondsAgo = $this->now - $this->lastActivityTimestamp;
$expired = false;
if ($this->inactivityTimeout !== 0 && $lastActivitySecondsAgo > $this->inactivityTimeout) {
$this->started = true;
$this->sessionIdentifier = $this->sessionCookie->getValue();
$this->destroy(sprintf('Session %s was inactive for %s seconds, more than the configured timeout of %s seconds.', $this->sessionIdentifier, $lastActivitySecondsAgo, $this->inactivityTimeout));
$expired = true;
}
return $expired;
} | [
"protected",
"function",
"autoExpire",
"(",
")",
"{",
"$",
"lastActivitySecondsAgo",
"=",
"$",
"this",
"->",
"now",
"-",
"$",
"this",
"->",
"lastActivityTimestamp",
";",
"$",
"expired",
"=",
"false",
";",
"if",
"(",
"$",
"this",
"->",
"inactivityTimeout",
... | Automatically expires the session if the user has been inactive for too long.
@return boolean true if the session expired, false if not | [
"Automatically",
"expires",
"the",
"session",
"if",
"the",
"user",
"has",
"been",
"inactive",
"for",
"too",
"long",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Session/Session.php#L693-L704 |
neos/flow-development-collection | Neos.Flow/Classes/Session/Session.php | Session.storeAuthenticatedAccountsInfo | protected function storeAuthenticatedAccountsInfo(array $tokens)
{
$accountProviderAndIdentifierPairs = [];
/** @var TokenInterface $token */
foreach ($tokens as $token) {
$account = $token->getAccount();
if ($token->isAuthenticated() && $account !== null) {
$accountProviderAndIdentifierPairs[$account->getAuthenticationProviderName() . ':' . $account->getAccountIdentifier()] = true;
}
}
if ($accountProviderAndIdentifierPairs !== []) {
$this->putData('Neos_Flow_Security_Accounts', array_keys($accountProviderAndIdentifierPairs));
}
} | php | protected function storeAuthenticatedAccountsInfo(array $tokens)
{
$accountProviderAndIdentifierPairs = [];
/** @var TokenInterface $token */
foreach ($tokens as $token) {
$account = $token->getAccount();
if ($token->isAuthenticated() && $account !== null) {
$accountProviderAndIdentifierPairs[$account->getAuthenticationProviderName() . ':' . $account->getAccountIdentifier()] = true;
}
}
if ($accountProviderAndIdentifierPairs !== []) {
$this->putData('Neos_Flow_Security_Accounts', array_keys($accountProviderAndIdentifierPairs));
}
} | [
"protected",
"function",
"storeAuthenticatedAccountsInfo",
"(",
"array",
"$",
"tokens",
")",
"{",
"$",
"accountProviderAndIdentifierPairs",
"=",
"[",
"]",
";",
"/** @var TokenInterface $token */",
"foreach",
"(",
"$",
"tokens",
"as",
"$",
"token",
")",
"{",
"$",
"... | Stores some information about the authenticated accounts in the session data.
This method will check if a session has already been started, which is
the case after tokens relying on a session have been authenticated: the
UsernamePasswordToken does, for example, start a session in its authenticate()
method.
Because more than one account can be authenticated at a time, this method
accepts an array of tokens instead of a single account.
Note that if a session is started after tokens have been authenticated, the
session will NOT be tagged with authenticated accounts.
@param array<TokenInterface>
@return void | [
"Stores",
"some",
"information",
"about",
"the",
"authenticated",
"accounts",
"in",
"the",
"session",
"data",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Session/Session.php#L723-L736 |
neos/flow-development-collection | Neos.Flow/Classes/Session/Session.php | Session.writeSessionMetaDataCacheEntry | protected function writeSessionMetaDataCacheEntry()
{
$sessionInfo = [
'lastActivityTimestamp' => $this->lastActivityTimestamp,
'storageIdentifier' => $this->storageIdentifier,
'tags' => $this->tags
];
$tagsForCacheEntry = array_map(function ($tag) {
return Session::TAG_PREFIX . $tag;
}, $this->tags);
$tagsForCacheEntry[] = $this->sessionIdentifier;
$tagsForCacheEntry[] = 'session';
$this->metaDataCache->set($this->sessionIdentifier, $sessionInfo, $tagsForCacheEntry, 0);
} | php | protected function writeSessionMetaDataCacheEntry()
{
$sessionInfo = [
'lastActivityTimestamp' => $this->lastActivityTimestamp,
'storageIdentifier' => $this->storageIdentifier,
'tags' => $this->tags
];
$tagsForCacheEntry = array_map(function ($tag) {
return Session::TAG_PREFIX . $tag;
}, $this->tags);
$tagsForCacheEntry[] = $this->sessionIdentifier;
$tagsForCacheEntry[] = 'session';
$this->metaDataCache->set($this->sessionIdentifier, $sessionInfo, $tagsForCacheEntry, 0);
} | [
"protected",
"function",
"writeSessionMetaDataCacheEntry",
"(",
")",
"{",
"$",
"sessionInfo",
"=",
"[",
"'lastActivityTimestamp'",
"=>",
"$",
"this",
"->",
"lastActivityTimestamp",
",",
"'storageIdentifier'",
"=>",
"$",
"this",
"->",
"storageIdentifier",
",",
"'tags'"... | Writes the cache entry containing information about the session, such as the
last activity time and the storage identifier.
This function does not write the whole session _data_ into the storage cache,
but only the "head" cache entry containing meta information.
The session cache entry is also tagged with "session", the session identifier
and any custom tags of this session, prefixed with TAG_PREFIX.
@return void | [
"Writes",
"the",
"cache",
"entry",
"containing",
"information",
"about",
"the",
"session",
"such",
"as",
"the",
"last",
"activity",
"time",
"and",
"the",
"storage",
"identifier",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Session/Session.php#L750-L765 |
neos/flow-development-collection | Neos.Flow/Classes/ObjectManagement/Configuration/ConfigurationProperty.php | ConfigurationProperty.set | public function set($name, $value, $type = self::PROPERTY_TYPES_STRAIGHTVALUE, $objectConfiguration = null, $lazyLoading = true)
{
$this->name = $name;
$this->value = $value;
$this->type = $type;
$this->objectConfiguration = $objectConfiguration;
$this->lazyLoading = $lazyLoading;
} | php | public function set($name, $value, $type = self::PROPERTY_TYPES_STRAIGHTVALUE, $objectConfiguration = null, $lazyLoading = true)
{
$this->name = $name;
$this->value = $value;
$this->type = $type;
$this->objectConfiguration = $objectConfiguration;
$this->lazyLoading = $lazyLoading;
} | [
"public",
"function",
"set",
"(",
"$",
"name",
",",
"$",
"value",
",",
"$",
"type",
"=",
"self",
"::",
"PROPERTY_TYPES_STRAIGHTVALUE",
",",
"$",
"objectConfiguration",
"=",
"null",
",",
"$",
"lazyLoading",
"=",
"true",
")",
"{",
"$",
"this",
"->",
"name"... | Sets the name, type and value of the property
@param string $name Name of the property
@param mixed $value Value of the property
@param integer $type Type of the property - one of the PROPERTY_TYPE_* constants
@param Configuration $objectConfiguration If $type is OBJECT, a custom object configuration may be specified
@param boolean $lazyLoading
@return void | [
"Sets",
"the",
"name",
"type",
"and",
"value",
"of",
"the",
"property"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ObjectManagement/Configuration/ConfigurationProperty.php#L84-L91 |
neos/flow-development-collection | Neos.Flow/Classes/Log/LoggerBackendConfigurationHelper.php | LoggerBackendConfigurationHelper.getNormalizedLegacyConfiguration | public function getNormalizedLegacyConfiguration(): array
{
$normalizedConfiguration = [];
foreach ($this->legacyConfiguration as $logIdentifier => $configuration) {
// Skip everything that is not an actual log configuration.
if (!isset($configuration['backend'])) {
continue;
}
$backendObjectNames = $configuration['backend'];
$backendOptions = $configuration['backendOptions'] ?? [];
$normalizedConfiguration[$logIdentifier] = $this->mapLoggerConfiguration($backendObjectNames, $backendOptions);
}
return $normalizedConfiguration;
} | php | public function getNormalizedLegacyConfiguration(): array
{
$normalizedConfiguration = [];
foreach ($this->legacyConfiguration as $logIdentifier => $configuration) {
// Skip everything that is not an actual log configuration.
if (!isset($configuration['backend'])) {
continue;
}
$backendObjectNames = $configuration['backend'];
$backendOptions = $configuration['backendOptions'] ?? [];
$normalizedConfiguration[$logIdentifier] = $this->mapLoggerConfiguration($backendObjectNames, $backendOptions);
}
return $normalizedConfiguration;
} | [
"public",
"function",
"getNormalizedLegacyConfiguration",
"(",
")",
":",
"array",
"{",
"$",
"normalizedConfiguration",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"legacyConfiguration",
"as",
"$",
"logIdentifier",
"=>",
"$",
"configuration",
")",
"{",... | Normalize a backend configuration to a unified format.
@return array | [
"Normalize",
"a",
"backend",
"configuration",
"to",
"a",
"unified",
"format",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Log/LoggerBackendConfigurationHelper.php#L29-L44 |
neos/flow-development-collection | Neos.FluidAdaptor/Classes/ViewHelpers/Validation/IfHasErrorsViewHelper.php | IfHasErrorsViewHelper.render | public function render()
{
if (self::evaluateCondition($this->arguments, $this->renderingContext)) {
return $this->renderThenChild();
} else {
return $this->renderElseChild();
}
} | php | public function render()
{
if (self::evaluateCondition($this->arguments, $this->renderingContext)) {
return $this->renderThenChild();
} else {
return $this->renderElseChild();
}
} | [
"public",
"function",
"render",
"(",
")",
"{",
"if",
"(",
"self",
"::",
"evaluateCondition",
"(",
"$",
"this",
"->",
"arguments",
",",
"$",
"this",
"->",
"renderingContext",
")",
")",
"{",
"return",
"$",
"this",
"->",
"renderThenChild",
"(",
")",
";",
... | Renders <f:then> child if there are validation errors. The check can be narrowed down to
specific property paths.
If no errors are there, it renders the <f:else>-child.
@return mixed
@api | [
"Renders",
"<f",
":",
"then",
">",
"child",
"if",
"there",
"are",
"validation",
"errors",
".",
"The",
"check",
"can",
"be",
"narrowed",
"down",
"to",
"specific",
"property",
"paths",
".",
"If",
"no",
"errors",
"are",
"there",
"it",
"renders",
"the",
"<f"... | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.FluidAdaptor/Classes/ViewHelpers/Validation/IfHasErrorsViewHelper.php#L64-L71 |
neos/flow-development-collection | Neos.Flow/Classes/Persistence/Doctrine/QueryResult.php | QueryResult.getFirst | public function getFirst()
{
if (is_array($this->rows)) {
$rows = &$this->rows;
} else {
$query = clone $this->query;
$query->setLimit(1);
$rows = $query->getResult();
}
return (isset($rows[0])) ? $rows[0] : null;
} | php | public function getFirst()
{
if (is_array($this->rows)) {
$rows = &$this->rows;
} else {
$query = clone $this->query;
$query->setLimit(1);
$rows = $query->getResult();
}
return (isset($rows[0])) ? $rows[0] : null;
} | [
"public",
"function",
"getFirst",
"(",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"rows",
")",
")",
"{",
"$",
"rows",
"=",
"&",
"$",
"this",
"->",
"rows",
";",
"}",
"else",
"{",
"$",
"query",
"=",
"clone",
"$",
"this",
"->",
"quer... | Returns the first object in the result set
@return object
@api | [
"Returns",
"the",
"first",
"object",
"in",
"the",
"result",
"set"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Persistence/Doctrine/QueryResult.php#L78-L89 |
neos/flow-development-collection | Neos.Flow/Classes/Persistence/Doctrine/QueryResult.php | QueryResult.count | public function count()
{
if ($this->numberOfRows === null) {
if (is_array($this->rows)) {
$this->numberOfRows = count($this->rows);
} else {
$this->numberOfRows = $this->query->count();
}
}
return $this->numberOfRows;
} | php | public function count()
{
if ($this->numberOfRows === null) {
if (is_array($this->rows)) {
$this->numberOfRows = count($this->rows);
} else {
$this->numberOfRows = $this->query->count();
}
}
return $this->numberOfRows;
} | [
"public",
"function",
"count",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"numberOfRows",
"===",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"rows",
")",
")",
"{",
"$",
"this",
"->",
"numberOfRows",
"=",
"count",
"(",
"$",
... | Returns the number of objects in the result
@return integer The number of matching objects
@api | [
"Returns",
"the",
"number",
"of",
"objects",
"in",
"the",
"result"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Persistence/Doctrine/QueryResult.php#L97-L107 |
neos/flow-development-collection | Neos.Flow/Classes/Http/UploadedFile.php | UploadedFile.getStream | public function getStream()
{
$this->throwExceptionIfNotAccessible();
if ($this->stream instanceof StreamInterface) {
return $this->stream;
}
return new ContentStream($this->file, 'r+');
} | php | public function getStream()
{
$this->throwExceptionIfNotAccessible();
if ($this->stream instanceof StreamInterface) {
return $this->stream;
}
return new ContentStream($this->file, 'r+');
} | [
"public",
"function",
"getStream",
"(",
")",
"{",
"$",
"this",
"->",
"throwExceptionIfNotAccessible",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"stream",
"instanceof",
"StreamInterface",
")",
"{",
"return",
"$",
"this",
"->",
"stream",
";",
"}",
"return... | Retrieve a stream representing the uploaded file.
This method MUST return a StreamInterface instance, representing the
uploaded file. The purpose of this method is to allow utilizing native PHP
stream functionality to manipulate the file upload, such as
stream_copy_to_stream() (though the result will need to be decorated in a
native PHP stream wrapper to work with such functions).
If the moveTo() method has been called previously, this method MUST raise
an exception.
@throws RuntimeException if the upload was not successful.
@api PSR-7 | [
"Retrieve",
"a",
"stream",
"representing",
"the",
"uploaded",
"file",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Http/UploadedFile.php#L125-L134 |
neos/flow-development-collection | Neos.Flow/Classes/Http/UploadedFile.php | UploadedFile.moveTo | public function moveTo($targetPath)
{
$this->throwExceptionIfNotAccessible();
if (!is_string($targetPath) || empty($targetPath)) {
throw new InvalidArgumentException('Invalid path provided to move uploaded file to. Must be a non-empty string', 1479747624);
}
if ($this->stream !== null || ($this->file !== null && FLOW_SAPITYPE === 'CLI')) {
$this->moved = $this->writeFile($targetPath);
}
if ($this->file !== null && FLOW_SAPITYPE !== 'CLI') {
$this->moved = move_uploaded_file($this->file, $targetPath);
}
if ($this->moved === false) {
throw new RuntimeException(sprintf('Uploaded file could not be moved to %s', $targetPath), 1479747889);
}
} | php | public function moveTo($targetPath)
{
$this->throwExceptionIfNotAccessible();
if (!is_string($targetPath) || empty($targetPath)) {
throw new InvalidArgumentException('Invalid path provided to move uploaded file to. Must be a non-empty string', 1479747624);
}
if ($this->stream !== null || ($this->file !== null && FLOW_SAPITYPE === 'CLI')) {
$this->moved = $this->writeFile($targetPath);
}
if ($this->file !== null && FLOW_SAPITYPE !== 'CLI') {
$this->moved = move_uploaded_file($this->file, $targetPath);
}
if ($this->moved === false) {
throw new RuntimeException(sprintf('Uploaded file could not be moved to %s', $targetPath), 1479747889);
}
} | [
"public",
"function",
"moveTo",
"(",
"$",
"targetPath",
")",
"{",
"$",
"this",
"->",
"throwExceptionIfNotAccessible",
"(",
")",
";",
"if",
"(",
"!",
"is_string",
"(",
"$",
"targetPath",
")",
"||",
"empty",
"(",
"$",
"targetPath",
")",
")",
"{",
"throw",
... | Move the uploaded file to a new location.
Use this method as an alternative to move_uploaded_file(). This method is
guaranteed to work in both SAPI and non-SAPI environments.
Implementations must determine which environment they are in, and use the
appropriate method (move_uploaded_file(), rename(), or a stream
operation) to perform the operation.
$targetPath may be an absolute path, or a relative path. If it is a
relative path, resolution should be the same as used by PHP's rename()
function.
The original file or stream MUST be removed on completion.
If this method is called more than once, any subsequent calls MUST raise
an exception.
When used in an SAPI environment where $_FILES is populated, when writing
files via moveTo(), is_uploaded_file() and move_uploaded_file() SHOULD be
used to ensure permissions and upload status are verified correctly.
If you wish to move to a stream, use getStream(), as SAPI operations
cannot guarantee writing to stream destinations.
@see http://php.net/is_uploaded_file
@see http://php.net/move_uploaded_file
@param string $targetPath Path to which to move the uploaded file.
@throws RuntimeException if the upload was not successful.
@throws InvalidArgumentException if the $path specified is invalid.
@throws RuntimeException on any error during the move operation, or on
the second or subsequent call to the method.
@api PSR-7 | [
"Move",
"the",
"uploaded",
"file",
"to",
"a",
"new",
"location",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Http/UploadedFile.php#L170-L189 |
neos/flow-development-collection | Neos.Flow/Classes/Mvc/Controller/MvcPropertyMappingConfigurationService.php | MvcPropertyMappingConfigurationService.generateTrustedPropertiesToken | public function generateTrustedPropertiesToken($formFieldNames, $fieldNamePrefix = '')
{
$formFieldArray = [];
foreach ($formFieldNames as $formField) {
$formFieldParts = explode('[', $formField);
$currentPosition =& $formFieldArray;
$formFieldPartsCount = count($formFieldParts);
for ($i = 0; $i < $formFieldPartsCount; $i++) {
$formFieldPart = $formFieldParts[$i];
$formFieldPart = rtrim($formFieldPart, ']');
if (!is_array($currentPosition)) {
throw new InvalidArgumentForHashGenerationException('The form field "' . $formField . '" is declared as array, but it collides with a previous form field of the same name which declared the field as string. This is an inconsistency you need to fix inside your Fluid form. (String overridden by Array)', 1255072196);
}
if ($i === count($formFieldParts) - 1) {
if (isset($currentPosition[$formFieldPart]) && is_array($currentPosition[$formFieldPart])) {
throw new InvalidArgumentForHashGenerationException('The form field "' . $formField . '" is declared as string, but it collides with a previous form field of the same name which declared the field as array. This is an inconsistency you need to fix inside your Fluid form. (Array overridden by String)', 1255072587);
}
// Last iteration - add a string
if ($formFieldPart === '') {
$currentPosition[] = 1;
} else {
$currentPosition[$formFieldPart] = 1;
}
} else {
if ($formFieldPart === '') {
throw new InvalidArgumentForHashGenerationException('The form field "' . $formField . '" is invalid. Reason: "[]" used not as last argument, but somewhere in the middle (like foo[][bar]).', 1255072832);
}
if (!isset($currentPosition[$formFieldPart])) {
$currentPosition[$formFieldPart] = [];
}
$currentPosition =& $currentPosition[$formFieldPart];
}
}
}
if ($fieldNamePrefix !== '') {
$formFieldArray = (isset($formFieldArray[$fieldNamePrefix]) ? $formFieldArray[$fieldNamePrefix] : []);
}
return $this->serializeAndHashFormFieldArray($formFieldArray);
} | php | public function generateTrustedPropertiesToken($formFieldNames, $fieldNamePrefix = '')
{
$formFieldArray = [];
foreach ($formFieldNames as $formField) {
$formFieldParts = explode('[', $formField);
$currentPosition =& $formFieldArray;
$formFieldPartsCount = count($formFieldParts);
for ($i = 0; $i < $formFieldPartsCount; $i++) {
$formFieldPart = $formFieldParts[$i];
$formFieldPart = rtrim($formFieldPart, ']');
if (!is_array($currentPosition)) {
throw new InvalidArgumentForHashGenerationException('The form field "' . $formField . '" is declared as array, but it collides with a previous form field of the same name which declared the field as string. This is an inconsistency you need to fix inside your Fluid form. (String overridden by Array)', 1255072196);
}
if ($i === count($formFieldParts) - 1) {
if (isset($currentPosition[$formFieldPart]) && is_array($currentPosition[$formFieldPart])) {
throw new InvalidArgumentForHashGenerationException('The form field "' . $formField . '" is declared as string, but it collides with a previous form field of the same name which declared the field as array. This is an inconsistency you need to fix inside your Fluid form. (Array overridden by String)', 1255072587);
}
// Last iteration - add a string
if ($formFieldPart === '') {
$currentPosition[] = 1;
} else {
$currentPosition[$formFieldPart] = 1;
}
} else {
if ($formFieldPart === '') {
throw new InvalidArgumentForHashGenerationException('The form field "' . $formField . '" is invalid. Reason: "[]" used not as last argument, but somewhere in the middle (like foo[][bar]).', 1255072832);
}
if (!isset($currentPosition[$formFieldPart])) {
$currentPosition[$formFieldPart] = [];
}
$currentPosition =& $currentPosition[$formFieldPart];
}
}
}
if ($fieldNamePrefix !== '') {
$formFieldArray = (isset($formFieldArray[$fieldNamePrefix]) ? $formFieldArray[$fieldNamePrefix] : []);
}
return $this->serializeAndHashFormFieldArray($formFieldArray);
} | [
"public",
"function",
"generateTrustedPropertiesToken",
"(",
"$",
"formFieldNames",
",",
"$",
"fieldNamePrefix",
"=",
"''",
")",
"{",
"$",
"formFieldArray",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"formFieldNames",
"as",
"$",
"formField",
")",
"{",
"$",
"fo... | Generate a request hash for a list of form fields
@param array $formFieldNames Array of form fields
@param string $fieldNamePrefix
@return string trusted properties token
@throws InvalidArgumentForHashGenerationException | [
"Generate",
"a",
"request",
"hash",
"for",
"a",
"list",
"of",
"form",
"fields"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Mvc/Controller/MvcPropertyMappingConfigurationService.php#L55-L95 |
neos/flow-development-collection | Neos.Flow/Classes/Mvc/Controller/MvcPropertyMappingConfigurationService.php | MvcPropertyMappingConfigurationService.initializePropertyMappingConfigurationFromRequest | public function initializePropertyMappingConfigurationFromRequest(ActionRequest $request, Arguments $controllerArguments)
{
$trustedPropertiesToken = $request->getInternalArgument('__trustedProperties');
if (!is_string($trustedPropertiesToken)) {
return;
}
$serializedTrustedProperties = $this->hashService->validateAndStripHmac($trustedPropertiesToken);
$trustedProperties = unserialize($serializedTrustedProperties);
foreach ($trustedProperties as $propertyName => $propertyConfiguration) {
if (!$controllerArguments->hasArgument($propertyName)) {
continue;
}
$propertyMappingConfiguration = $controllerArguments->getArgument($propertyName)->getPropertyMappingConfiguration();
$this->modifyPropertyMappingConfiguration($propertyConfiguration, $propertyMappingConfiguration);
}
} | php | public function initializePropertyMappingConfigurationFromRequest(ActionRequest $request, Arguments $controllerArguments)
{
$trustedPropertiesToken = $request->getInternalArgument('__trustedProperties');
if (!is_string($trustedPropertiesToken)) {
return;
}
$serializedTrustedProperties = $this->hashService->validateAndStripHmac($trustedPropertiesToken);
$trustedProperties = unserialize($serializedTrustedProperties);
foreach ($trustedProperties as $propertyName => $propertyConfiguration) {
if (!$controllerArguments->hasArgument($propertyName)) {
continue;
}
$propertyMappingConfiguration = $controllerArguments->getArgument($propertyName)->getPropertyMappingConfiguration();
$this->modifyPropertyMappingConfiguration($propertyConfiguration, $propertyMappingConfiguration);
}
} | [
"public",
"function",
"initializePropertyMappingConfigurationFromRequest",
"(",
"ActionRequest",
"$",
"request",
",",
"Arguments",
"$",
"controllerArguments",
")",
"{",
"$",
"trustedPropertiesToken",
"=",
"$",
"request",
"->",
"getInternalArgument",
"(",
"'__trustedProperti... | Initialize the property mapping configuration in $controllerArguments if
the trusted properties are set inside the request.
@param ActionRequest $request
@param Arguments $controllerArguments
@return void | [
"Initialize",
"the",
"property",
"mapping",
"configuration",
"in",
"$controllerArguments",
"if",
"the",
"trusted",
"properties",
"are",
"set",
"inside",
"the",
"request",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Mvc/Controller/MvcPropertyMappingConfigurationService.php#L118-L134 |
neos/flow-development-collection | Neos.Flow/Classes/Mvc/Controller/MvcPropertyMappingConfigurationService.php | MvcPropertyMappingConfigurationService.modifyPropertyMappingConfiguration | protected function modifyPropertyMappingConfiguration($propertyConfiguration, PropertyMappingConfiguration $propertyMappingConfiguration)
{
if (!is_array($propertyConfiguration)) {
return;
}
if (isset($propertyConfiguration['__identity'])) {
$propertyMappingConfiguration->setTypeConverterOption(PersistentObjectConverter::class, PersistentObjectConverter::CONFIGURATION_MODIFICATION_ALLOWED, true);
unset($propertyConfiguration['__identity']);
} else {
$propertyMappingConfiguration->setTypeConverterOption(PersistentObjectConverter::class, PersistentObjectConverter::CONFIGURATION_CREATION_ALLOWED, true);
}
foreach ($propertyConfiguration as $innerKey => $innerValue) {
if (is_array($innerValue)) {
$this->modifyPropertyMappingConfiguration($innerValue, $propertyMappingConfiguration->forProperty($innerKey));
}
$propertyMappingConfiguration->allowProperties($innerKey);
}
} | php | protected function modifyPropertyMappingConfiguration($propertyConfiguration, PropertyMappingConfiguration $propertyMappingConfiguration)
{
if (!is_array($propertyConfiguration)) {
return;
}
if (isset($propertyConfiguration['__identity'])) {
$propertyMappingConfiguration->setTypeConverterOption(PersistentObjectConverter::class, PersistentObjectConverter::CONFIGURATION_MODIFICATION_ALLOWED, true);
unset($propertyConfiguration['__identity']);
} else {
$propertyMappingConfiguration->setTypeConverterOption(PersistentObjectConverter::class, PersistentObjectConverter::CONFIGURATION_CREATION_ALLOWED, true);
}
foreach ($propertyConfiguration as $innerKey => $innerValue) {
if (is_array($innerValue)) {
$this->modifyPropertyMappingConfiguration($innerValue, $propertyMappingConfiguration->forProperty($innerKey));
}
$propertyMappingConfiguration->allowProperties($innerKey);
}
} | [
"protected",
"function",
"modifyPropertyMappingConfiguration",
"(",
"$",
"propertyConfiguration",
",",
"PropertyMappingConfiguration",
"$",
"propertyMappingConfiguration",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"propertyConfiguration",
")",
")",
"{",
"return",
... | Modify the passed $propertyMappingConfiguration according to the $propertyConfiguration which
has been generated by Fluid. In detail, if the $propertyConfiguration contains
an __identity field, we allow modification of objects; else we allow creation.
All other properties are specified as allowed properties.
@param array $propertyConfiguration
@param PropertyMappingConfiguration $propertyMappingConfiguration
@return void | [
"Modify",
"the",
"passed",
"$propertyMappingConfiguration",
"according",
"to",
"the",
"$propertyConfiguration",
"which",
"has",
"been",
"generated",
"by",
"Fluid",
".",
"In",
"detail",
"if",
"the",
"$propertyConfiguration",
"contains",
"an",
"__identity",
"field",
"we... | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Mvc/Controller/MvcPropertyMappingConfigurationService.php#L147-L165 |
neos/flow-development-collection | Neos.Utility.Unicode/Classes/TextIterator.php | TextIterator.valid | public function valid(): bool
{
if ($this->getCurrentElement() !== null && $this->getCurrentElement()->getValue() !== self::DONE && $this->getCurrentElement()->getOffset() !== -1) {
return true;
}
return false;
} | php | public function valid(): bool
{
if ($this->getCurrentElement() !== null && $this->getCurrentElement()->getValue() !== self::DONE && $this->getCurrentElement()->getOffset() !== -1) {
return true;
}
return false;
} | [
"public",
"function",
"valid",
"(",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"this",
"->",
"getCurrentElement",
"(",
")",
"!==",
"null",
"&&",
"$",
"this",
"->",
"getCurrentElement",
"(",
")",
"->",
"getValue",
"(",
")",
"!==",
"self",
"::",
"DONE",
"&... | Returns true, if the current element is not the end of the iterator
@return boolean True if the iterator has not reached it's end | [
"Returns",
"true",
"if",
"the",
"current",
"element",
"is",
"not",
"the",
"end",
"of",
"the",
"iterator"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Utility.Unicode/Classes/TextIterator.php#L143-L149 |
neos/flow-development-collection | Neos.Utility.Unicode/Classes/TextIterator.php | TextIterator.last | public function last(): string
{
$this->rewind();
$previousElement = $this->getCurrentElement();
while ($this->valid()) {
$previousElement = $this->getCurrentElement();
$this->next();
}
return $previousElement->getValue();
} | php | public function last(): string
{
$this->rewind();
$previousElement = $this->getCurrentElement();
while ($this->valid()) {
$previousElement = $this->getCurrentElement();
$this->next();
}
return $previousElement->getValue();
} | [
"public",
"function",
"last",
"(",
")",
":",
"string",
"{",
"$",
"this",
"->",
"rewind",
"(",
")",
";",
"$",
"previousElement",
"=",
"$",
"this",
"->",
"getCurrentElement",
"(",
")",
";",
"while",
"(",
"$",
"this",
"->",
"valid",
"(",
")",
")",
"{"... | Returns the last element of the iterator
@return string the last element of the iterator | [
"Returns",
"the",
"last",
"element",
"of",
"the",
"iterator"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Utility.Unicode/Classes/TextIterator.php#L186-L195 |
neos/flow-development-collection | Neos.Utility.Unicode/Classes/TextIterator.php | TextIterator.following | public function following(int $offset): string
{
$this->rewind();
while ($this->valid()) {
$this->next();
$nextElement = $this->getCurrentElement();
if ($nextElement->getOffset() >= $offset) {
return $nextElement->getOffset();
}
}
return $this->offset();
} | php | public function following(int $offset): string
{
$this->rewind();
while ($this->valid()) {
$this->next();
$nextElement = $this->getCurrentElement();
if ($nextElement->getOffset() >= $offset) {
return $nextElement->getOffset();
}
}
return $this->offset();
} | [
"public",
"function",
"following",
"(",
"int",
"$",
"offset",
")",
":",
"string",
"{",
"$",
"this",
"->",
"rewind",
"(",
")",
";",
"while",
"(",
"$",
"this",
"->",
"valid",
"(",
")",
")",
"{",
"$",
"this",
"->",
"next",
"(",
")",
";",
"$",
"nex... | Returns the next elment following the character of the original string
given by its offset
@param integer $offset The offset of the character
@return string The element following this character | [
"Returns",
"the",
"next",
"elment",
"following",
"the",
"character",
"of",
"the",
"original",
"string",
"given",
"by",
"its",
"offset"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Utility.Unicode/Classes/TextIterator.php#L204-L215 |
neos/flow-development-collection | Neos.Utility.Unicode/Classes/TextIterator.php | TextIterator.preceding | public function preceding(int $offset): string
{
$this->rewind();
while ($this->valid()) {
$previousElement = $this->getCurrentElement();
$this->next();
$currentElement = $this->getCurrentElement();
if (($currentElement->getOffset() + $currentElement->getLength()) >= $offset) {
return $previousElement->getOffset() + $previousElement->getLength();
}
}
return $currentElement->getOffset() + $currentElement->getLength();
} | php | public function preceding(int $offset): string
{
$this->rewind();
while ($this->valid()) {
$previousElement = $this->getCurrentElement();
$this->next();
$currentElement = $this->getCurrentElement();
if (($currentElement->getOffset() + $currentElement->getLength()) >= $offset) {
return $previousElement->getOffset() + $previousElement->getLength();
}
}
return $currentElement->getOffset() + $currentElement->getLength();
} | [
"public",
"function",
"preceding",
"(",
"int",
"$",
"offset",
")",
":",
"string",
"{",
"$",
"this",
"->",
"rewind",
"(",
")",
";",
"while",
"(",
"$",
"this",
"->",
"valid",
"(",
")",
")",
"{",
"$",
"previousElement",
"=",
"$",
"this",
"->",
"getCur... | Returns the element preceding the character of the original string given by its offset
@param integer $offset The offset of the character
@return string The element preceding this character | [
"Returns",
"the",
"element",
"preceding",
"the",
"character",
"of",
"the",
"original",
"string",
"given",
"by",
"its",
"offset"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Utility.Unicode/Classes/TextIterator.php#L223-L235 |
neos/flow-development-collection | Neos.Utility.Unicode/Classes/TextIterator.php | TextIterator.getAll | public function getAll(): array
{
$this->rewind();
$allValues = [];
while ($this->valid()) {
$allValues[] = $this->getCurrentElement()->getValue();
$this->next();
}
return $allValues;
} | php | public function getAll(): array
{
$this->rewind();
$allValues = [];
while ($this->valid()) {
$allValues[] = $this->getCurrentElement()->getValue();
$this->next();
}
return $allValues;
} | [
"public",
"function",
"getAll",
"(",
")",
":",
"array",
"{",
"$",
"this",
"->",
"rewind",
"(",
")",
";",
"$",
"allValues",
"=",
"[",
"]",
";",
"while",
"(",
"$",
"this",
"->",
"valid",
"(",
")",
")",
"{",
"$",
"allValues",
"[",
"]",
"=",
"$",
... | Returns all elements of the iterator in an array
@return array All elements of the iterator | [
"Returns",
"all",
"elements",
"of",
"the",
"iterator",
"in",
"an",
"array"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Utility.Unicode/Classes/TextIterator.php#L258-L267 |
neos/flow-development-collection | Neos.Utility.Unicode/Classes/TextIterator.php | TextIterator.generateIteratorElements | private function generateIteratorElements()
{
if ($this->subject === '') {
$this->iteratorCache->append(new TextIteratorElement(self::DONE, -1));
return;
}
if ($this->iteratorType === self::CODE_POINT) {
throw new UnsupportedFeatureException('Unsupported iterator type.', 1210849150);
} elseif ($this->iteratorType === self::COMB_SEQUENCE) {
throw new UnsupportedFeatureException('Unsupported iterator type.', 1210849151);
} elseif ($this->iteratorType === self::CHARACTER) {
$this->parseSubjectByCharacter();
} elseif ($this->iteratorType === self::WORD) {
$this->parseSubjectByWord();
} elseif ($this->iteratorType === self::LINE) {
$this->parseSubjectByLine();
} elseif ($this->iteratorType === self::SENTENCE) {
$this->parseSubjectBySentence();
}
$this->iteratorCache->append(new TextIteratorElement(self::DONE, -1));
$this->iteratorCacheIterator = $this->iteratorCache->getIterator();
} | php | private function generateIteratorElements()
{
if ($this->subject === '') {
$this->iteratorCache->append(new TextIteratorElement(self::DONE, -1));
return;
}
if ($this->iteratorType === self::CODE_POINT) {
throw new UnsupportedFeatureException('Unsupported iterator type.', 1210849150);
} elseif ($this->iteratorType === self::COMB_SEQUENCE) {
throw new UnsupportedFeatureException('Unsupported iterator type.', 1210849151);
} elseif ($this->iteratorType === self::CHARACTER) {
$this->parseSubjectByCharacter();
} elseif ($this->iteratorType === self::WORD) {
$this->parseSubjectByWord();
} elseif ($this->iteratorType === self::LINE) {
$this->parseSubjectByLine();
} elseif ($this->iteratorType === self::SENTENCE) {
$this->parseSubjectBySentence();
}
$this->iteratorCache->append(new TextIteratorElement(self::DONE, -1));
$this->iteratorCacheIterator = $this->iteratorCache->getIterator();
} | [
"private",
"function",
"generateIteratorElements",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"subject",
"===",
"''",
")",
"{",
"$",
"this",
"->",
"iteratorCache",
"->",
"append",
"(",
"new",
"TextIteratorElement",
"(",
"self",
"::",
"DONE",
",",
"-",
... | Helper function to coordinate the "string splitting"
@return void
@throws UnsupportedFeatureException | [
"Helper",
"function",
"to",
"coordinate",
"the",
"string",
"splitting"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Utility.Unicode/Classes/TextIterator.php#L310-L333 |
neos/flow-development-collection | Neos.Utility.Unicode/Classes/TextIterator.php | TextIterator.parseSubjectByCharacter | private function parseSubjectByCharacter()
{
$i = 0;
foreach (preg_split('//u', $this->subject) as $currentCharacter) {
if ($currentCharacter === '') {
continue;
}
$this->iteratorCache->append(new TextIteratorElement($currentCharacter, $i, 1, false));
$i++;
}
} | php | private function parseSubjectByCharacter()
{
$i = 0;
foreach (preg_split('//u', $this->subject) as $currentCharacter) {
if ($currentCharacter === '') {
continue;
}
$this->iteratorCache->append(new TextIteratorElement($currentCharacter, $i, 1, false));
$i++;
}
} | [
"private",
"function",
"parseSubjectByCharacter",
"(",
")",
"{",
"$",
"i",
"=",
"0",
";",
"foreach",
"(",
"preg_split",
"(",
"'//u'",
",",
"$",
"this",
"->",
"subject",
")",
"as",
"$",
"currentCharacter",
")",
"{",
"if",
"(",
"$",
"currentCharacter",
"==... | Helper function to do the splitting by character | [
"Helper",
"function",
"to",
"do",
"the",
"splitting",
"by",
"character"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Utility.Unicode/Classes/TextIterator.php#L339-L349 |
neos/flow-development-collection | Neos.Utility.Unicode/Classes/TextIterator.php | TextIterator.parseSubjectByWord | private function parseSubjectByWord()
{
$i = 0;
$isFirstIteration = true;
foreach (explode(' ', $this->subject) as $currentWord) {
$delimitersMatches = [];
$haveProcessedCurrentWord = false;
if (preg_match_all('/' . self::REGEXP_SENTENCE_DELIMITERS . '/', $currentWord, $delimitersMatches)) {
$this->iteratorCache->append(new TextIteratorElement(' ', $i, 1, true));
$j = 0;
$splittedWord = preg_split('/' . self::REGEXP_SENTENCE_DELIMITERS . '/', $currentWord);
foreach ($splittedWord as $currentPart) {
if ($currentPart !== '') {
$this->iteratorCache->append(new TextIteratorElement($currentPart, $i, Unicode\Functions::strlen($currentPart), false));
$i += Unicode\Functions::strlen($currentPart);
}
if ($j < count($delimitersMatches[0])) {
$this->iteratorCache->append(new TextIteratorElement($delimitersMatches[0][$j], $i, 1, true));
}
$i++;
$j++;
}
$haveProcessedCurrentWord = true;
}
if (!$isFirstIteration && !$haveProcessedCurrentWord) {
$this->iteratorCache->append(new TextIteratorElement(' ', $i, 1, true));
$i++;
} else {
$isFirstIteration = false;
}
if (!$haveProcessedCurrentWord) {
$this->iteratorCache->append(new TextIteratorElement($currentWord, $i, Unicode\Functions::strlen($currentWord), false));
$i += Unicode\Functions::strlen($currentWord);
}
unset($delimitersMatches);
}
} | php | private function parseSubjectByWord()
{
$i = 0;
$isFirstIteration = true;
foreach (explode(' ', $this->subject) as $currentWord) {
$delimitersMatches = [];
$haveProcessedCurrentWord = false;
if (preg_match_all('/' . self::REGEXP_SENTENCE_DELIMITERS . '/', $currentWord, $delimitersMatches)) {
$this->iteratorCache->append(new TextIteratorElement(' ', $i, 1, true));
$j = 0;
$splittedWord = preg_split('/' . self::REGEXP_SENTENCE_DELIMITERS . '/', $currentWord);
foreach ($splittedWord as $currentPart) {
if ($currentPart !== '') {
$this->iteratorCache->append(new TextIteratorElement($currentPart, $i, Unicode\Functions::strlen($currentPart), false));
$i += Unicode\Functions::strlen($currentPart);
}
if ($j < count($delimitersMatches[0])) {
$this->iteratorCache->append(new TextIteratorElement($delimitersMatches[0][$j], $i, 1, true));
}
$i++;
$j++;
}
$haveProcessedCurrentWord = true;
}
if (!$isFirstIteration && !$haveProcessedCurrentWord) {
$this->iteratorCache->append(new TextIteratorElement(' ', $i, 1, true));
$i++;
} else {
$isFirstIteration = false;
}
if (!$haveProcessedCurrentWord) {
$this->iteratorCache->append(new TextIteratorElement($currentWord, $i, Unicode\Functions::strlen($currentWord), false));
$i += Unicode\Functions::strlen($currentWord);
}
unset($delimitersMatches);
}
} | [
"private",
"function",
"parseSubjectByWord",
"(",
")",
"{",
"$",
"i",
"=",
"0",
";",
"$",
"isFirstIteration",
"=",
"true",
";",
"foreach",
"(",
"explode",
"(",
"' '",
",",
"$",
"this",
"->",
"subject",
")",
"as",
"$",
"currentWord",
")",
"{",
"$",
"d... | Helper function to do the splitting by word. Note: punctuation marks are
treated as words, spaces as boundary elements
@return void | [
"Helper",
"function",
"to",
"do",
"the",
"splitting",
"by",
"word",
".",
"Note",
":",
"punctuation",
"marks",
"are",
"treated",
"as",
"words",
"spaces",
"as",
"boundary",
"elements"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Utility.Unicode/Classes/TextIterator.php#L357-L398 |
neos/flow-development-collection | Neos.Utility.Unicode/Classes/TextIterator.php | TextIterator.parseSubjectByLine | private function parseSubjectByLine()
{
$i = 0;
$j = 0;
$lines = explode("\n", $this->subject);
foreach ($lines as $currentLine) {
$this->iteratorCache->append(new TextIteratorElement($currentLine, $i, Unicode\Functions::strlen($currentLine), false));
$i += Unicode\Functions::strlen($currentLine);
if (count($lines) - 1 > $j) {
$this->iteratorCache->append(new TextIteratorElement("\n", $i, 1, true));
$i++;
}
$j++;
}
} | php | private function parseSubjectByLine()
{
$i = 0;
$j = 0;
$lines = explode("\n", $this->subject);
foreach ($lines as $currentLine) {
$this->iteratorCache->append(new TextIteratorElement($currentLine, $i, Unicode\Functions::strlen($currentLine), false));
$i += Unicode\Functions::strlen($currentLine);
if (count($lines) - 1 > $j) {
$this->iteratorCache->append(new TextIteratorElement("\n", $i, 1, true));
$i++;
}
$j++;
}
} | [
"private",
"function",
"parseSubjectByLine",
"(",
")",
"{",
"$",
"i",
"=",
"0",
";",
"$",
"j",
"=",
"0",
";",
"$",
"lines",
"=",
"explode",
"(",
"\"\\n\"",
",",
"$",
"this",
"->",
"subject",
")",
";",
"foreach",
"(",
"$",
"lines",
"as",
"$",
"cur... | Helper function to do the splitting by line. Note: one punctuations mark
belongs to the preceding sentence.
"\n" is boundary element.
@return void | [
"Helper",
"function",
"to",
"do",
"the",
"splitting",
"by",
"line",
".",
"Note",
":",
"one",
"punctuations",
"mark",
"belongs",
"to",
"the",
"preceding",
"sentence",
".",
"\\",
"n",
"is",
"boundary",
"element",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Utility.Unicode/Classes/TextIterator.php#L407-L422 |
neos/flow-development-collection | Neos.Utility.Unicode/Classes/TextIterator.php | TextIterator.parseSubjectBySentence | private function parseSubjectBySentence()
{
$i = 0;
$j = 0;
$count = 0;
$delimitersMatches = [];
preg_match_all('/' . self::REGEXP_SENTENCE_DELIMITERS . '/', $this->subject, $delimitersMatches);
$splittedSentence = preg_split('/' . self::REGEXP_SENTENCE_DELIMITERS . '/', $this->subject);
if (count($splittedSentence) == 1) {
$this->iteratorCache->append(new TextIteratorElement($splittedSentence[0], 0, Unicode\Functions::strlen($splittedSentence[0]), false));
return;
}
foreach ($splittedSentence as $currentPart) {
$currentPart = preg_replace('/^\s|\s$/', '', $currentPart, -1, $count);
$whiteSpace = '';
for ($k = 0; $k < $count; $k++) {
$whiteSpace .= ' ';
}
if ($whiteSpace !== '') {
$this->iteratorCache->append(new TextIteratorElement($whiteSpace, $i, $count, true));
}
$i += $count;
if ($j >= count($delimitersMatches[0])) {
continue;
}
if ($currentPart !== '') {
$this->iteratorCache->append(new TextIteratorElement($currentPart . $delimitersMatches[0][$j], $i, Unicode\Functions::strlen($currentPart . $delimitersMatches[0][$j]), false));
$i += Unicode\Functions::strlen($currentPart . $delimitersMatches[0][$j]);
$j++;
} else {
$this->iteratorCache->append(new TextIteratorElement($delimitersMatches[0][$j], $i, 1, true));
$i++;
$j++;
}
}
} | php | private function parseSubjectBySentence()
{
$i = 0;
$j = 0;
$count = 0;
$delimitersMatches = [];
preg_match_all('/' . self::REGEXP_SENTENCE_DELIMITERS . '/', $this->subject, $delimitersMatches);
$splittedSentence = preg_split('/' . self::REGEXP_SENTENCE_DELIMITERS . '/', $this->subject);
if (count($splittedSentence) == 1) {
$this->iteratorCache->append(new TextIteratorElement($splittedSentence[0], 0, Unicode\Functions::strlen($splittedSentence[0]), false));
return;
}
foreach ($splittedSentence as $currentPart) {
$currentPart = preg_replace('/^\s|\s$/', '', $currentPart, -1, $count);
$whiteSpace = '';
for ($k = 0; $k < $count; $k++) {
$whiteSpace .= ' ';
}
if ($whiteSpace !== '') {
$this->iteratorCache->append(new TextIteratorElement($whiteSpace, $i, $count, true));
}
$i += $count;
if ($j >= count($delimitersMatches[0])) {
continue;
}
if ($currentPart !== '') {
$this->iteratorCache->append(new TextIteratorElement($currentPart . $delimitersMatches[0][$j], $i, Unicode\Functions::strlen($currentPart . $delimitersMatches[0][$j]), false));
$i += Unicode\Functions::strlen($currentPart . $delimitersMatches[0][$j]);
$j++;
} else {
$this->iteratorCache->append(new TextIteratorElement($delimitersMatches[0][$j], $i, 1, true));
$i++;
$j++;
}
}
} | [
"private",
"function",
"parseSubjectBySentence",
"(",
")",
"{",
"$",
"i",
"=",
"0",
";",
"$",
"j",
"=",
"0",
";",
"$",
"count",
"=",
"0",
";",
"$",
"delimitersMatches",
"=",
"[",
"]",
";",
"preg_match_all",
"(",
"'/'",
".",
"self",
"::",
"REGEXP_SENT... | Helper function to do the splitting by sentence. Note: one punctuations
mark belongs to the preceding sentence. Whitespace between sentences is
marked as boundary.
@return void | [
"Helper",
"function",
"to",
"do",
"the",
"splitting",
"by",
"sentence",
".",
"Note",
":",
"one",
"punctuations",
"mark",
"belongs",
"to",
"the",
"preceding",
"sentence",
".",
"Whitespace",
"between",
"sentences",
"is",
"marked",
"as",
"boundary",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Utility.Unicode/Classes/TextIterator.php#L431-L470 |
neos/flow-development-collection | Neos.Flow/Classes/ObjectManagement/Configuration/ConfigurationArgument.php | ConfigurationArgument.set | public function set($index, $value, $type = self::ARGUMENT_TYPES_STRAIGHTVALUE)
{
$this->index = $index;
$this->value = $value;
$this->type = $type;
} | php | public function set($index, $value, $type = self::ARGUMENT_TYPES_STRAIGHTVALUE)
{
$this->index = $index;
$this->value = $value;
$this->type = $type;
} | [
"public",
"function",
"set",
"(",
"$",
"index",
",",
"$",
"value",
",",
"$",
"type",
"=",
"self",
"::",
"ARGUMENT_TYPES_STRAIGHTVALUE",
")",
"{",
"$",
"this",
"->",
"index",
"=",
"$",
"index",
";",
"$",
"this",
"->",
"value",
"=",
"$",
"value",
";",
... | Sets the index, value, type of the argument and object configuration
@param integer $index Index of the argument (counting starts at "1")
@param mixed $value Value of the argument
@param integer $type Type of the argument - one of the ARGUMENT_TYPE_* constants
@return void | [
"Sets",
"the",
"index",
"value",
"type",
"of",
"the",
"argument",
"and",
"object",
"configuration"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ObjectManagement/Configuration/ConfigurationArgument.php#L69-L74 |
neos/flow-development-collection | Neos.Flow/Classes/Http/UriTemplate.php | UriTemplate.expand | public static function expand($template, array $variables)
{
if (strpos($template, '{') === false) {
return $template;
}
self::$variables = $variables;
return preg_replace_callback('/\{([^\}]+)\}/', [UriTemplate::class, 'expandMatch'], $template);
} | php | public static function expand($template, array $variables)
{
if (strpos($template, '{') === false) {
return $template;
}
self::$variables = $variables;
return preg_replace_callback('/\{([^\}]+)\}/', [UriTemplate::class, 'expandMatch'], $template);
} | [
"public",
"static",
"function",
"expand",
"(",
"$",
"template",
",",
"array",
"$",
"variables",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"template",
",",
"'{'",
")",
"===",
"false",
")",
"{",
"return",
"$",
"template",
";",
"}",
"self",
"::",
"$",
... | Expand the template string using the supplied variables
@param string $template URI template to expand
@param array $variables variables to use with the expansion
@return string | [
"Expand",
"the",
"template",
"string",
"using",
"the",
"supplied",
"variables"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Http/UriTemplate.php#L53-L62 |
neos/flow-development-collection | Neos.Flow/Classes/Http/UriTemplate.php | UriTemplate.expandMatch | protected static function expandMatch(array $matches)
{
$parsed = self::parseExpression($matches[1]);
$replacements = [];
$prefix = $parsed['operator'];
$separator = $parsed['operator'];
$queryStringShouldBeUsed = false;
switch ($parsed['operator']) {
case '?':
$separator = '&';
$queryStringShouldBeUsed = true;
break;
case '#':
$separator = ',';
break;
case '&':
case ';':
$queryStringShouldBeUsed = true;
break;
case '+':
case '':
$separator = ',';
$prefix = '';
break;
}
foreach ($parsed['values'] as $value) {
if (!array_key_exists($value['value'], self::$variables) || self::$variables[$value['value']] === null) {
continue;
}
$variable = self::$variables[$value['value']];
$useQueryString = $queryStringShouldBeUsed;
if (is_array($variable)) {
$expanded = self::encodeArrayVariable($variable, $value, $parsed['operator'], $separator, $useQueryString);
} else {
if ($value['modifier'] === ':') {
$variable = substr($variable, 0, $value['position']);
}
$expanded = rawurlencode($variable);
if ($parsed['operator'] === '+' || $parsed['operator'] === '#') {
$expanded = self::decodeReservedDelimiters($expanded);
}
}
if ($useQueryString) {
if ($expanded === '' && $separator !== '&') {
$expanded = $value['value'];
} else {
$expanded = $value['value'] . '=' . $expanded;
}
}
$replacements[] = $expanded;
}
$result = implode($separator, $replacements);
if ($result !== '' && $prefix !== '') {
return $prefix . $result;
}
return $result;
} | php | protected static function expandMatch(array $matches)
{
$parsed = self::parseExpression($matches[1]);
$replacements = [];
$prefix = $parsed['operator'];
$separator = $parsed['operator'];
$queryStringShouldBeUsed = false;
switch ($parsed['operator']) {
case '?':
$separator = '&';
$queryStringShouldBeUsed = true;
break;
case '#':
$separator = ',';
break;
case '&':
case ';':
$queryStringShouldBeUsed = true;
break;
case '+':
case '':
$separator = ',';
$prefix = '';
break;
}
foreach ($parsed['values'] as $value) {
if (!array_key_exists($value['value'], self::$variables) || self::$variables[$value['value']] === null) {
continue;
}
$variable = self::$variables[$value['value']];
$useQueryString = $queryStringShouldBeUsed;
if (is_array($variable)) {
$expanded = self::encodeArrayVariable($variable, $value, $parsed['operator'], $separator, $useQueryString);
} else {
if ($value['modifier'] === ':') {
$variable = substr($variable, 0, $value['position']);
}
$expanded = rawurlencode($variable);
if ($parsed['operator'] === '+' || $parsed['operator'] === '#') {
$expanded = self::decodeReservedDelimiters($expanded);
}
}
if ($useQueryString) {
if ($expanded === '' && $separator !== '&') {
$expanded = $value['value'];
} else {
$expanded = $value['value'] . '=' . $expanded;
}
}
$replacements[] = $expanded;
}
$result = implode($separator, $replacements);
if ($result !== '' && $prefix !== '') {
return $prefix . $result;
}
return $result;
} | [
"protected",
"static",
"function",
"expandMatch",
"(",
"array",
"$",
"matches",
")",
"{",
"$",
"parsed",
"=",
"self",
"::",
"parseExpression",
"(",
"$",
"matches",
"[",
"1",
"]",
")",
";",
"$",
"replacements",
"=",
"[",
"]",
";",
"$",
"prefix",
"=",
... | Process an expansion
@param array $matches matches found in preg_replace_callback
@return string replacement string | [
"Process",
"an",
"expansion"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Http/UriTemplate.php#L70-L134 |
neos/flow-development-collection | Neos.Flow/Classes/Http/UriTemplate.php | UriTemplate.parseExpression | protected static function parseExpression($expression)
{
if (isset(self::$operators[$expression[0]])) {
$operator = $expression[0];
$expression = substr($expression, 1);
} else {
$operator = '';
}
$explodedExpression = explode(',', $expression);
foreach ($explodedExpression as &$expressionPart) {
$configuration = [];
$expressionPart = trim($expressionPart);
$colonPosition = strpos($expressionPart, ':');
if ($colonPosition) {
$configuration['value'] = substr($expressionPart, 0, $colonPosition);
$configuration['modifier'] = ':';
$configuration['position'] = (int)substr($expressionPart, $colonPosition + 1);
} elseif (substr($expressionPart, -1) === '*') {
$configuration['modifier'] = '*';
$configuration['value'] = substr($expressionPart, 0, -1);
} else {
$configuration['value'] = (string)$expressionPart;
$configuration['modifier'] = '';
}
$expressionPart = $configuration;
}
return [
'operator' => $operator,
'values' => $explodedExpression
];
} | php | protected static function parseExpression($expression)
{
if (isset(self::$operators[$expression[0]])) {
$operator = $expression[0];
$expression = substr($expression, 1);
} else {
$operator = '';
}
$explodedExpression = explode(',', $expression);
foreach ($explodedExpression as &$expressionPart) {
$configuration = [];
$expressionPart = trim($expressionPart);
$colonPosition = strpos($expressionPart, ':');
if ($colonPosition) {
$configuration['value'] = substr($expressionPart, 0, $colonPosition);
$configuration['modifier'] = ':';
$configuration['position'] = (int)substr($expressionPart, $colonPosition + 1);
} elseif (substr($expressionPart, -1) === '*') {
$configuration['modifier'] = '*';
$configuration['value'] = substr($expressionPart, 0, -1);
} else {
$configuration['value'] = (string)$expressionPart;
$configuration['modifier'] = '';
}
$expressionPart = $configuration;
}
return [
'operator' => $operator,
'values' => $explodedExpression
];
} | [
"protected",
"static",
"function",
"parseExpression",
"(",
"$",
"expression",
")",
"{",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"operators",
"[",
"$",
"expression",
"[",
"0",
"]",
"]",
")",
")",
"{",
"$",
"operator",
"=",
"$",
"expression",
"[",
... | Parse an expression into parts
@param string $expression Expression to parse
@return array associative array of parts | [
"Parse",
"an",
"expression",
"into",
"parts"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Http/UriTemplate.php#L142-L176 |
neos/flow-development-collection | Neos.Flow/Classes/Http/UriTemplate.php | UriTemplate.encodeArrayVariable | protected static function encodeArrayVariable(array $variable, array $value, $operator, $separator, &$useQueryString)
{
$isAssociativeArray = self::isAssociative($variable);
$keyValuePairs = [];
foreach ($variable as $key => $var) {
if ($isAssociativeArray) {
$key = rawurlencode($key);
$isNestedArray = is_array($var);
} else {
$isNestedArray = false;
}
if (!$isNestedArray) {
$var = rawurlencode($var);
if ($operator === '+' || $operator === '#') {
$var = self::decodeReservedDelimiters($var);
}
}
if ($value['modifier'] === '*') {
if ($isAssociativeArray) {
if ($isNestedArray) {
// allow for deeply nested structures
$var = strtr(http_build_query([$key => $var]), ['+' => '%20', '%7e' => '~']);
} else {
$var = $key . '=' . $var;
}
} elseif ($key > 0 && $useQueryString) {
$var = $value['value'] . '=' . $var;
}
}
$keyValuePairs[$key] = $var;
}
$expanded = '';
if (empty($variable)) {
$useQueryString = false;
} elseif ($value['modifier'] === '*') {
$expanded = implode($separator, $keyValuePairs);
if ($isAssociativeArray) {
// Don't prepend the value name when using the explode modifier with an associative array
$useQueryString = false;
}
} else {
if ($isAssociativeArray) {
// The result must be a comma separated list of keys followed by their respective values
// if the explode modifier is not set on an associative array
foreach ($keyValuePairs as $k => &$v) {
$v = $k . ',' . $v;
}
}
$expanded = implode(',', $keyValuePairs);
}
return $expanded;
} | php | protected static function encodeArrayVariable(array $variable, array $value, $operator, $separator, &$useQueryString)
{
$isAssociativeArray = self::isAssociative($variable);
$keyValuePairs = [];
foreach ($variable as $key => $var) {
if ($isAssociativeArray) {
$key = rawurlencode($key);
$isNestedArray = is_array($var);
} else {
$isNestedArray = false;
}
if (!$isNestedArray) {
$var = rawurlencode($var);
if ($operator === '+' || $operator === '#') {
$var = self::decodeReservedDelimiters($var);
}
}
if ($value['modifier'] === '*') {
if ($isAssociativeArray) {
if ($isNestedArray) {
// allow for deeply nested structures
$var = strtr(http_build_query([$key => $var]), ['+' => '%20', '%7e' => '~']);
} else {
$var = $key . '=' . $var;
}
} elseif ($key > 0 && $useQueryString) {
$var = $value['value'] . '=' . $var;
}
}
$keyValuePairs[$key] = $var;
}
$expanded = '';
if (empty($variable)) {
$useQueryString = false;
} elseif ($value['modifier'] === '*') {
$expanded = implode($separator, $keyValuePairs);
if ($isAssociativeArray) {
// Don't prepend the value name when using the explode modifier with an associative array
$useQueryString = false;
}
} else {
if ($isAssociativeArray) {
// The result must be a comma separated list of keys followed by their respective values
// if the explode modifier is not set on an associative array
foreach ($keyValuePairs as $k => &$v) {
$v = $k . ',' . $v;
}
}
$expanded = implode(',', $keyValuePairs);
}
return $expanded;
} | [
"protected",
"static",
"function",
"encodeArrayVariable",
"(",
"array",
"$",
"variable",
",",
"array",
"$",
"value",
",",
"$",
"operator",
",",
"$",
"separator",
",",
"&",
"$",
"useQueryString",
")",
"{",
"$",
"isAssociativeArray",
"=",
"self",
"::",
"isAsso... | Encode arrays for use in the expanded URI string
@param array $variable
@param array $value
@param string $operator
@param string $separator
@param $useQueryString
@return string | [
"Encode",
"arrays",
"for",
"use",
"in",
"the",
"expanded",
"URI",
"string"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Http/UriTemplate.php#L188-L245 |
neos/flow-development-collection | Neos.Flow/Classes/Aop/Pointcut/RuntimeExpressionEvaluator.php | RuntimeExpressionEvaluator.injectObjectManager | public function injectObjectManager(ObjectManagerInterface $objectManager): void
{
if ($this->objectManager === null) {
$this->objectManager = $objectManager;
/** @var CacheManager $cacheManager */
$cacheManager = $this->objectManager->get(CacheManager::class);
$this->runtimeExpressionsCache = $cacheManager->getCache('Flow_Aop_RuntimeExpressions');
}
} | php | public function injectObjectManager(ObjectManagerInterface $objectManager): void
{
if ($this->objectManager === null) {
$this->objectManager = $objectManager;
/** @var CacheManager $cacheManager */
$cacheManager = $this->objectManager->get(CacheManager::class);
$this->runtimeExpressionsCache = $cacheManager->getCache('Flow_Aop_RuntimeExpressions');
}
} | [
"public",
"function",
"injectObjectManager",
"(",
"ObjectManagerInterface",
"$",
"objectManager",
")",
":",
"void",
"{",
"if",
"(",
"$",
"this",
"->",
"objectManager",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"objectManager",
"=",
"$",
"objectManager",
";",... | This object is created very early and is part of the blacklisted "Neos\Flow\Aop" namespace so we can't rely on AOP for the property injection.
@param ObjectManagerInterface $objectManager
@return void | [
"This",
"object",
"is",
"created",
"very",
"early",
"and",
"is",
"part",
"of",
"the",
"blacklisted",
"Neos",
"\\",
"Flow",
"\\",
"Aop",
"namespace",
"so",
"we",
"can",
"t",
"rely",
"on",
"AOP",
"for",
"the",
"property",
"injection",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Aop/Pointcut/RuntimeExpressionEvaluator.php#L52-L60 |
neos/flow-development-collection | Neos.Flow/Classes/Aop/Pointcut/RuntimeExpressionEvaluator.php | RuntimeExpressionEvaluator.evaluate | public function evaluate(string $privilegeIdentifier, JoinPointInterface $joinPoint)
{
$functionName = $this->generateExpressionFunctionName($privilegeIdentifier);
if (isset($this->runtimeExpressions[$functionName])) {
return $this->runtimeExpressions[$functionName]->__invoke($joinPoint, $this->objectManager);
}
$expression = $this->runtimeExpressionsCache->get($functionName);
if (!$expression) {
throw new Exception('Runtime expression "' . $functionName . '" does not exist. Flushing the code caches may help to solve this.', 1428694144);
}
$this->runtimeExpressions[$functionName] = eval($expression);
return $this->runtimeExpressions[$functionName]->__invoke($joinPoint, $this->objectManager);
} | php | public function evaluate(string $privilegeIdentifier, JoinPointInterface $joinPoint)
{
$functionName = $this->generateExpressionFunctionName($privilegeIdentifier);
if (isset($this->runtimeExpressions[$functionName])) {
return $this->runtimeExpressions[$functionName]->__invoke($joinPoint, $this->objectManager);
}
$expression = $this->runtimeExpressionsCache->get($functionName);
if (!$expression) {
throw new Exception('Runtime expression "' . $functionName . '" does not exist. Flushing the code caches may help to solve this.', 1428694144);
}
$this->runtimeExpressions[$functionName] = eval($expression);
return $this->runtimeExpressions[$functionName]->__invoke($joinPoint, $this->objectManager);
} | [
"public",
"function",
"evaluate",
"(",
"string",
"$",
"privilegeIdentifier",
",",
"JoinPointInterface",
"$",
"joinPoint",
")",
"{",
"$",
"functionName",
"=",
"$",
"this",
"->",
"generateExpressionFunctionName",
"(",
"$",
"privilegeIdentifier",
")",
";",
"if",
"(",... | Evaluate an expression with the given JoinPoint
@param string $privilegeIdentifier MD5 hash that identifies a privilege
@param JoinPointInterface $joinPoint
@return mixed
@throws Exception | [
"Evaluate",
"an",
"expression",
"with",
"the",
"given",
"JoinPoint"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Aop/Pointcut/RuntimeExpressionEvaluator.php#L70-L85 |
neos/flow-development-collection | Neos.Flow/Classes/Aop/Pointcut/RuntimeExpressionEvaluator.php | RuntimeExpressionEvaluator.addExpression | public function addExpression(string $privilegeIdentifier, string $expression): void
{
$functionName = $this->generateExpressionFunctionName($privilegeIdentifier);
$wrappedExpression = 'return ' . $expression . ';';
$this->runtimeExpressionsCache->set($functionName, $wrappedExpression);
$this->runtimeExpressions[$functionName] = eval($wrappedExpression);
} | php | public function addExpression(string $privilegeIdentifier, string $expression): void
{
$functionName = $this->generateExpressionFunctionName($privilegeIdentifier);
$wrappedExpression = 'return ' . $expression . ';';
$this->runtimeExpressionsCache->set($functionName, $wrappedExpression);
$this->runtimeExpressions[$functionName] = eval($wrappedExpression);
} | [
"public",
"function",
"addExpression",
"(",
"string",
"$",
"privilegeIdentifier",
",",
"string",
"$",
"expression",
")",
":",
"void",
"{",
"$",
"functionName",
"=",
"$",
"this",
"->",
"generateExpressionFunctionName",
"(",
"$",
"privilegeIdentifier",
")",
";",
"... | Add expression to the evaluator
@param string $privilegeIdentifier MD5 hash that identifies a privilege
@param string $expression
@return void | [
"Add",
"expression",
"to",
"the",
"evaluator"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Aop/Pointcut/RuntimeExpressionEvaluator.php#L94-L100 |
neos/flow-development-collection | Neos.Flow/Classes/ObjectManagement/Proxy/ProxyConstructor.php | ProxyConstructor.render | public function render()
{
$methodDocumentation = $this->buildMethodDocumentation($this->fullOriginalClassName, $this->methodName);
$callParentMethodCode = $this->buildCallParentMethodCode($this->fullOriginalClassName, $this->methodName);
$finalKeyword = $this->reflectionService->isMethodFinal($this->fullOriginalClassName, $this->methodName) ? 'final ' : '';
$staticKeyword = $this->reflectionService->isMethodStatic($this->fullOriginalClassName, $this->methodName) ? 'static ' : '';
$code = '';
if ($this->addedPreParentCallCode !== '' || $this->addedPostParentCallCode !== '') {
$argumentsCode = (count($this->reflectionService->getMethodParameters($this->fullOriginalClassName, $this->methodName)) > 0) ? ' $arguments = func_get_args();' . "\n" : '';
$code = "\n" .
$methodDocumentation .
' ' . $finalKeyword . $staticKeyword . "public function __construct()\n {\n" .
$argumentsCode .
$this->addedPreParentCallCode . $callParentMethodCode . $this->addedPostParentCallCode .
" }\n";
}
return $code;
} | php | public function render()
{
$methodDocumentation = $this->buildMethodDocumentation($this->fullOriginalClassName, $this->methodName);
$callParentMethodCode = $this->buildCallParentMethodCode($this->fullOriginalClassName, $this->methodName);
$finalKeyword = $this->reflectionService->isMethodFinal($this->fullOriginalClassName, $this->methodName) ? 'final ' : '';
$staticKeyword = $this->reflectionService->isMethodStatic($this->fullOriginalClassName, $this->methodName) ? 'static ' : '';
$code = '';
if ($this->addedPreParentCallCode !== '' || $this->addedPostParentCallCode !== '') {
$argumentsCode = (count($this->reflectionService->getMethodParameters($this->fullOriginalClassName, $this->methodName)) > 0) ? ' $arguments = func_get_args();' . "\n" : '';
$code = "\n" .
$methodDocumentation .
' ' . $finalKeyword . $staticKeyword . "public function __construct()\n {\n" .
$argumentsCode .
$this->addedPreParentCallCode . $callParentMethodCode . $this->addedPostParentCallCode .
" }\n";
}
return $code;
} | [
"public",
"function",
"render",
"(",
")",
"{",
"$",
"methodDocumentation",
"=",
"$",
"this",
"->",
"buildMethodDocumentation",
"(",
"$",
"this",
"->",
"fullOriginalClassName",
",",
"$",
"this",
"->",
"methodName",
")",
";",
"$",
"callParentMethodCode",
"=",
"$... | Renders the code for a proxy constructor
@return string PHP code | [
"Renders",
"the",
"code",
"for",
"a",
"proxy",
"constructor"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ObjectManagement/Proxy/ProxyConstructor.php#L42-L61 |
neos/flow-development-collection | Neos.Flow/Classes/ObjectManagement/Proxy/ProxyConstructor.php | ProxyConstructor.buildCallParentMethodCode | protected function buildCallParentMethodCode($fullClassName, $methodName)
{
if (!$this->reflectionService->hasMethod($fullClassName, $methodName)) {
return '';
}
if (count($this->reflectionService->getMethodParameters($this->fullOriginalClassName, $this->methodName)) > 0) {
return " call_user_func_array('parent::" . $methodName . "', \$arguments);\n";
} else {
return " parent::" . $methodName . "();\n";
}
} | php | protected function buildCallParentMethodCode($fullClassName, $methodName)
{
if (!$this->reflectionService->hasMethod($fullClassName, $methodName)) {
return '';
}
if (count($this->reflectionService->getMethodParameters($this->fullOriginalClassName, $this->methodName)) > 0) {
return " call_user_func_array('parent::" . $methodName . "', \$arguments);\n";
} else {
return " parent::" . $methodName . "();\n";
}
} | [
"protected",
"function",
"buildCallParentMethodCode",
"(",
"$",
"fullClassName",
",",
"$",
"methodName",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"reflectionService",
"->",
"hasMethod",
"(",
"$",
"fullClassName",
",",
"$",
"methodName",
")",
")",
"{",
"r... | Builds PHP code which calls the original (ie. parent) method after the added code has been executed.
@param string $fullClassName Fully qualified name of the original class
@param string $methodName Name of the original method
@return string PHP code | [
"Builds",
"PHP",
"code",
"which",
"calls",
"the",
"original",
"(",
"ie",
".",
"parent",
")",
"method",
"after",
"the",
"added",
"code",
"has",
"been",
"executed",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ObjectManagement/Proxy/ProxyConstructor.php#L70-L80 |
neos/flow-development-collection | Neos.Flow/Scripts/Migrations/Manager.php | Manager.getStatus | public function getStatus($packageKey, $versionNumber = null)
{
$status = array();
$migrations = $this->getMigrations($versionNumber);
foreach ($this->getPackagesData($packageKey) as &$this->currentPackageData) {
$packageStatus = array();
foreach ($migrations as $migration) {
if ($this->hasMigrationApplied($migration)) {
$state = self::STATE_MIGRATED;
} else {
$state = self::STATE_NOT_MIGRATED;
}
$packageStatus[$migration->getVersionNumber()] = array('migration' => $migration, 'state' => $state);
}
$status[$this->currentPackageData['packageKey']] = $packageStatus;
}
return $status;
} | php | public function getStatus($packageKey, $versionNumber = null)
{
$status = array();
$migrations = $this->getMigrations($versionNumber);
foreach ($this->getPackagesData($packageKey) as &$this->currentPackageData) {
$packageStatus = array();
foreach ($migrations as $migration) {
if ($this->hasMigrationApplied($migration)) {
$state = self::STATE_MIGRATED;
} else {
$state = self::STATE_NOT_MIGRATED;
}
$packageStatus[$migration->getVersionNumber()] = array('migration' => $migration, 'state' => $state);
}
$status[$this->currentPackageData['packageKey']] = $packageStatus;
}
return $status;
} | [
"public",
"function",
"getStatus",
"(",
"$",
"packageKey",
",",
"$",
"versionNumber",
"=",
"null",
")",
"{",
"$",
"status",
"=",
"array",
"(",
")",
";",
"$",
"migrations",
"=",
"$",
"this",
"->",
"getMigrations",
"(",
"$",
"versionNumber",
")",
";",
"f... | Returns the migration status for all packages.
@param string $packageKey key of the package to fetch the migration status for
@param string $versionNumber version of the migration to fetch the status for (e.g. "20120126163610"), or NULL to consider all migrations
@return array in the format [<versionNumber> => ['migration' => <AbstractMigration>, 'state' => <STATE_*>], [...]] | [
"Returns",
"the",
"migration",
"status",
"for",
"all",
"packages",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Scripts/Migrations/Manager.php#L93-L110 |
neos/flow-development-collection | Neos.Flow/Scripts/Migrations/Manager.php | Manager.migrate | public function migrate($packageKey, $versionNumber = null, $force = false)
{
$packagesData = $this->getPackagesData($packageKey);
foreach ($this->getMigrations($versionNumber) as $migration) {
$this->triggerEvent(self::EVENT_MIGRATION_START, array($migration));
foreach ($packagesData as &$this->currentPackageData) {
$this->migratePackage($migration, $force);
}
$this->triggerEvent(self::EVENT_MIGRATION_DONE, array($migration));
}
} | php | public function migrate($packageKey, $versionNumber = null, $force = false)
{
$packagesData = $this->getPackagesData($packageKey);
foreach ($this->getMigrations($versionNumber) as $migration) {
$this->triggerEvent(self::EVENT_MIGRATION_START, array($migration));
foreach ($packagesData as &$this->currentPackageData) {
$this->migratePackage($migration, $force);
}
$this->triggerEvent(self::EVENT_MIGRATION_DONE, array($migration));
}
} | [
"public",
"function",
"migrate",
"(",
"$",
"packageKey",
",",
"$",
"versionNumber",
"=",
"null",
",",
"$",
"force",
"=",
"false",
")",
"{",
"$",
"packagesData",
"=",
"$",
"this",
"->",
"getPackagesData",
"(",
"$",
"packageKey",
")",
";",
"foreach",
"(",
... | This iterates over available migrations and applies them to
the existing packages if
- the package needs the migration
- is a clean git working copy
@param string $packageKey key of the package to migrate
@param string $versionNumber version of the migration to execute (e.g. "20120126163610"), or NULL to execute all migrations
@param boolean $force if true migrations will be applied even if the corresponding package is not a git working copy or contains local changes
@return void | [
"This",
"iterates",
"over",
"available",
"migrations",
"and",
"applies",
"them",
"to",
"the",
"existing",
"packages",
"if",
"-",
"the",
"package",
"needs",
"the",
"migration",
"-",
"is",
"a",
"clean",
"git",
"working",
"copy"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Scripts/Migrations/Manager.php#L123-L133 |
neos/flow-development-collection | Neos.Flow/Scripts/Migrations/Manager.php | Manager.migratePackage | protected function migratePackage(AbstractMigration $migration, $force = false)
{
$packagePath = $this->currentPackageData['path'];
if ($this->hasMigrationApplied($migration)) {
$this->triggerEvent(self::EVENT_MIGRATION_ALREADY_APPLIED, array($migration, 'Migration already applied'));
return;
}
$isWorkingCopy = Git::isWorkingCopy($packagePath);
$hasLocalChanges = Git::isWorkingCopyDirty($packagePath);
if (!$force) {
if (!$isWorkingCopy) {
$this->triggerEvent(self::EVENT_MIGRATION_SKIPPED, array($migration, 'Not a Git working copy, use --force to apply changes anyways'));
return;
}
if ($hasLocalChanges) {
$this->triggerEvent(self::EVENT_MIGRATION_SKIPPED, array($migration, 'Working copy contains local changes, use --force to apply changes anyways'));
return;
}
}
if ($isWorkingCopy) {
$importResult = $this->importMigrationLogFromGitHistory(!$hasLocalChanges);
if ($importResult !== null) {
$this->triggerEvent(self::EVENT_MIGRATION_LOG_IMPORTED, array($migration, $importResult));
}
}
$this->triggerEvent(self::EVENT_MIGRATION_EXECUTE, array($migration));
try {
$migration->prepare($this->currentPackageData);
$migration->up();
$migration->execute();
$commitMessageNotice = null;
if ($isWorkingCopy && !Git::isWorkingCopyDirty($packagePath)) {
$commitMessageNotice = 'Note: This migration did not produce any changes, so the commit simply marks the migration as applied. This makes sure it will not be applied again.';
}
$this->markMigrationApplied($migration);
$this->triggerEvent(self::EVENT_MIGRATION_EXECUTED, array($migration));
if ($hasLocalChanges || !$isWorkingCopy) {
$this->triggerEvent(self::EVENT_MIGRATION_COMMIT_SKIPPED, array($migration, $hasLocalChanges ? 'Working copy contains local changes' : 'No Git working copy'));
} else {
$migrationResult = $this->commitMigration($migration, $commitMessageNotice);
$this->triggerEvent(self::EVENT_MIGRATION_COMMITTED, array($migration, $migrationResult));
}
} catch (\Exception $exception) {
throw new \RuntimeException(sprintf('Applying migration "%s" to "%s" failed: "%s"', $migration->getIdentifier(), $this->currentPackageData['packageKey'], $exception->getMessage()), 1421692982, $exception);
}
} | php | protected function migratePackage(AbstractMigration $migration, $force = false)
{
$packagePath = $this->currentPackageData['path'];
if ($this->hasMigrationApplied($migration)) {
$this->triggerEvent(self::EVENT_MIGRATION_ALREADY_APPLIED, array($migration, 'Migration already applied'));
return;
}
$isWorkingCopy = Git::isWorkingCopy($packagePath);
$hasLocalChanges = Git::isWorkingCopyDirty($packagePath);
if (!$force) {
if (!$isWorkingCopy) {
$this->triggerEvent(self::EVENT_MIGRATION_SKIPPED, array($migration, 'Not a Git working copy, use --force to apply changes anyways'));
return;
}
if ($hasLocalChanges) {
$this->triggerEvent(self::EVENT_MIGRATION_SKIPPED, array($migration, 'Working copy contains local changes, use --force to apply changes anyways'));
return;
}
}
if ($isWorkingCopy) {
$importResult = $this->importMigrationLogFromGitHistory(!$hasLocalChanges);
if ($importResult !== null) {
$this->triggerEvent(self::EVENT_MIGRATION_LOG_IMPORTED, array($migration, $importResult));
}
}
$this->triggerEvent(self::EVENT_MIGRATION_EXECUTE, array($migration));
try {
$migration->prepare($this->currentPackageData);
$migration->up();
$migration->execute();
$commitMessageNotice = null;
if ($isWorkingCopy && !Git::isWorkingCopyDirty($packagePath)) {
$commitMessageNotice = 'Note: This migration did not produce any changes, so the commit simply marks the migration as applied. This makes sure it will not be applied again.';
}
$this->markMigrationApplied($migration);
$this->triggerEvent(self::EVENT_MIGRATION_EXECUTED, array($migration));
if ($hasLocalChanges || !$isWorkingCopy) {
$this->triggerEvent(self::EVENT_MIGRATION_COMMIT_SKIPPED, array($migration, $hasLocalChanges ? 'Working copy contains local changes' : 'No Git working copy'));
} else {
$migrationResult = $this->commitMigration($migration, $commitMessageNotice);
$this->triggerEvent(self::EVENT_MIGRATION_COMMITTED, array($migration, $migrationResult));
}
} catch (\Exception $exception) {
throw new \RuntimeException(sprintf('Applying migration "%s" to "%s" failed: "%s"', $migration->getIdentifier(), $this->currentPackageData['packageKey'], $exception->getMessage()), 1421692982, $exception);
}
} | [
"protected",
"function",
"migratePackage",
"(",
"AbstractMigration",
"$",
"migration",
",",
"$",
"force",
"=",
"false",
")",
"{",
"$",
"packagePath",
"=",
"$",
"this",
"->",
"currentPackageData",
"[",
"'path'",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"hasM... | Apply the given migration to the package and commit the result.
@param AbstractMigration $migration
@param boolean $force if true the migration will be applied even if the current package is not a git working copy or contains local changes
@return void
@throws \RuntimeException | [
"Apply",
"the",
"given",
"migration",
"to",
"the",
"package",
"and",
"commit",
"the",
"result",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Scripts/Migrations/Manager.php#L143-L190 |
neos/flow-development-collection | Neos.Flow/Scripts/Migrations/Manager.php | Manager.hasMigrationApplied | protected function hasMigrationApplied(AbstractMigration $migration)
{
// if the "applied-flow-migrations" section doesn't exist, we fall back to checking the git log for applied migrations for backwards compatibility
if (!isset($this->currentPackageData['composerManifest']['extra']['applied-flow-migrations'])) {
return Git::logContains($this->currentPackageData['path'], 'Migration: ' . $migration->getIdentifier());
}
return in_array($migration->getIdentifier(), $this->currentPackageData['composerManifest']['extra']['applied-flow-migrations']);
} | php | protected function hasMigrationApplied(AbstractMigration $migration)
{
// if the "applied-flow-migrations" section doesn't exist, we fall back to checking the git log for applied migrations for backwards compatibility
if (!isset($this->currentPackageData['composerManifest']['extra']['applied-flow-migrations'])) {
return Git::logContains($this->currentPackageData['path'], 'Migration: ' . $migration->getIdentifier());
}
return in_array($migration->getIdentifier(), $this->currentPackageData['composerManifest']['extra']['applied-flow-migrations']);
} | [
"protected",
"function",
"hasMigrationApplied",
"(",
"AbstractMigration",
"$",
"migration",
")",
"{",
"// if the \"applied-flow-migrations\" section doesn't exist, we fall back to checking the git log for applied migrations for backwards compatibility",
"if",
"(",
"!",
"isset",
"(",
"$... | Whether or not the given $migration has been applied to the current package
@param AbstractMigration $migration
@return boolean | [
"Whether",
"or",
"not",
"the",
"given",
"$migration",
"has",
"been",
"applied",
"to",
"the",
"current",
"package"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Scripts/Migrations/Manager.php#L198-L205 |
neos/flow-development-collection | Neos.Flow/Scripts/Migrations/Manager.php | Manager.importMigrationLogFromGitHistory | protected function importMigrationLogFromGitHistory($commitChanges = false)
{
if (isset($this->currentPackageData['composerManifest']['extra']['applied-flow-migrations'])) {
return null;
}
$migrationCommitMessages = Git::getLog($this->currentPackageData['path'], 'Migration:');
$appliedMigrationIdentifiers = [];
foreach ($migrationCommitMessages as $commitMessage) {
if (preg_match('/^\s*Migration\:\s?([^\s]*)/', $commitMessage, $matches) === 1) {
$appliedMigrationIdentifiers[] = $matches[1];
}
}
if ($appliedMigrationIdentifiers === array()) {
return null;
}
if (!isset($this->currentPackageData['composerManifest']['extra'])) {
$this->currentPackageData['composerManifest']['extra'] = [];
}
$this->currentPackageData['composerManifest']['extra']['applied-flow-migrations'] = array_unique($appliedMigrationIdentifiers);
$this->writeComposerManifest();
$this->currentPackageData['composerManifest']['extra']['applied-flow-migrations'] = array_values(array_unique($appliedMigrationIdentifiers));
$composerFilePathAndName = Files::concatenatePaths([$this->currentPackageData['path'], 'composer.json']);
Tools::writeComposerManifest($this->currentPackageData['composerManifest'], $composerFilePathAndName);
if ($commitChanges) {
$commitMessageSubject = 'TASK: Import core migration log to composer.json';
if (!Git::isWorkingCopyRoot($this->currentPackageData['path'])) {
$commitMessageSubject .= sprintf(' of "%s"', $this->currentPackageData['packageKey']);
}
$commitMessage = $commitMessageSubject . chr(10) . chr(10);
$commitMessage .= wordwrap('This commit imports the core migration log to the "extra" section of the composer manifest.', 72);
list($returnCode, $output) = Git::commitAll($this->currentPackageData['path'], $commitMessage);
if ($returnCode === 0) {
return ' ' . implode(PHP_EOL . ' ', $output) . PHP_EOL;
} else {
return ' No changes were committed.' . PHP_EOL;
}
}
} | php | protected function importMigrationLogFromGitHistory($commitChanges = false)
{
if (isset($this->currentPackageData['composerManifest']['extra']['applied-flow-migrations'])) {
return null;
}
$migrationCommitMessages = Git::getLog($this->currentPackageData['path'], 'Migration:');
$appliedMigrationIdentifiers = [];
foreach ($migrationCommitMessages as $commitMessage) {
if (preg_match('/^\s*Migration\:\s?([^\s]*)/', $commitMessage, $matches) === 1) {
$appliedMigrationIdentifiers[] = $matches[1];
}
}
if ($appliedMigrationIdentifiers === array()) {
return null;
}
if (!isset($this->currentPackageData['composerManifest']['extra'])) {
$this->currentPackageData['composerManifest']['extra'] = [];
}
$this->currentPackageData['composerManifest']['extra']['applied-flow-migrations'] = array_unique($appliedMigrationIdentifiers);
$this->writeComposerManifest();
$this->currentPackageData['composerManifest']['extra']['applied-flow-migrations'] = array_values(array_unique($appliedMigrationIdentifiers));
$composerFilePathAndName = Files::concatenatePaths([$this->currentPackageData['path'], 'composer.json']);
Tools::writeComposerManifest($this->currentPackageData['composerManifest'], $composerFilePathAndName);
if ($commitChanges) {
$commitMessageSubject = 'TASK: Import core migration log to composer.json';
if (!Git::isWorkingCopyRoot($this->currentPackageData['path'])) {
$commitMessageSubject .= sprintf(' of "%s"', $this->currentPackageData['packageKey']);
}
$commitMessage = $commitMessageSubject . chr(10) . chr(10);
$commitMessage .= wordwrap('This commit imports the core migration log to the "extra" section of the composer manifest.', 72);
list($returnCode, $output) = Git::commitAll($this->currentPackageData['path'], $commitMessage);
if ($returnCode === 0) {
return ' ' . implode(PHP_EOL . ' ', $output) . PHP_EOL;
} else {
return ' No changes were committed.' . PHP_EOL;
}
}
} | [
"protected",
"function",
"importMigrationLogFromGitHistory",
"(",
"$",
"commitChanges",
"=",
"false",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"currentPackageData",
"[",
"'composerManifest'",
"]",
"[",
"'extra'",
"]",
"[",
"'applied-flow-migrations'",
... | Imports the core migration log from the git history if it has not been imported previously (the "applied-flow-migrations" composer manifest property does not exist)
@param boolean $commitChanges if true the modified composer manifest is committed - if it changed
@return string | [
"Imports",
"the",
"core",
"migration",
"log",
"from",
"the",
"git",
"history",
"if",
"it",
"has",
"not",
"been",
"imported",
"previously",
"(",
"the",
"applied",
"-",
"flow",
"-",
"migrations",
"composer",
"manifest",
"property",
"does",
"not",
"exist",
")"
... | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Scripts/Migrations/Manager.php#L222-L263 |
neos/flow-development-collection | Neos.Flow/Scripts/Migrations/Manager.php | Manager.markMigrationApplied | protected function markMigrationApplied(AbstractMigration $migration)
{
if (!isset($this->currentPackageData['composerManifest']['extra']['applied-flow-migrations'])) {
$this->currentPackageData['composerManifest']['extra']['applied-flow-migrations'] = [];
}
$this->currentPackageData['composerManifest']['extra']['applied-flow-migrations'][] = $migration->getIdentifier();
$composerFilePathAndName = Files::concatenatePaths([$this->currentPackageData['path'], 'composer.json']);
Tools::writeComposerManifest($this->currentPackageData['composerManifest'], $composerFilePathAndName);
} | php | protected function markMigrationApplied(AbstractMigration $migration)
{
if (!isset($this->currentPackageData['composerManifest']['extra']['applied-flow-migrations'])) {
$this->currentPackageData['composerManifest']['extra']['applied-flow-migrations'] = [];
}
$this->currentPackageData['composerManifest']['extra']['applied-flow-migrations'][] = $migration->getIdentifier();
$composerFilePathAndName = Files::concatenatePaths([$this->currentPackageData['path'], 'composer.json']);
Tools::writeComposerManifest($this->currentPackageData['composerManifest'], $composerFilePathAndName);
} | [
"protected",
"function",
"markMigrationApplied",
"(",
"AbstractMigration",
"$",
"migration",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"currentPackageData",
"[",
"'composerManifest'",
"]",
"[",
"'extra'",
"]",
"[",
"'applied-flow-migrations'",
"]"... | Whether or not the given migration has been applied in the given path
@param AbstractMigration $migration
@return boolean | [
"Whether",
"or",
"not",
"the",
"given",
"migration",
"has",
"been",
"applied",
"in",
"the",
"given",
"path"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Scripts/Migrations/Manager.php#L271-L279 |
neos/flow-development-collection | Neos.Flow/Scripts/Migrations/Manager.php | Manager.commitMigration | protected function commitMigration(AbstractMigration $migration, $commitMessageNotice = null)
{
$migrationIdentifier = $migration->getIdentifier();
$commitMessageSubject = sprintf('TASK: Apply migration %s', $migrationIdentifier);
if (!Git::isWorkingCopyRoot($this->currentPackageData['path'])) {
$commitMessageSubject .= sprintf(' to package "%s"', $this->currentPackageData['packageKey']);
}
$commitMessage = $commitMessageSubject . chr(10) . chr(10);
$description = $migration->getDescription();
if ($description !== null) {
$commitMessage .= wordwrap($description, 72);
} else {
$commitMessage .= wordwrap(sprintf('This commit contains the result of applying migration %s to this package.', $migrationIdentifier), 72);
}
if ($commitMessageNotice !== null) {
$commitMessage .= chr(10) . chr(10) . wordwrap($commitMessageNotice, 72) . chr(10) . chr(10);
}
list($returnCode, $output) = Git::commitAll($this->currentPackageData['path'], $commitMessage);
if ($returnCode === 0) {
return ' ' . implode(PHP_EOL . ' ', $output) . PHP_EOL;
} else {
return ' No changes were committed.' . PHP_EOL;
}
} | php | protected function commitMigration(AbstractMigration $migration, $commitMessageNotice = null)
{
$migrationIdentifier = $migration->getIdentifier();
$commitMessageSubject = sprintf('TASK: Apply migration %s', $migrationIdentifier);
if (!Git::isWorkingCopyRoot($this->currentPackageData['path'])) {
$commitMessageSubject .= sprintf(' to package "%s"', $this->currentPackageData['packageKey']);
}
$commitMessage = $commitMessageSubject . chr(10) . chr(10);
$description = $migration->getDescription();
if ($description !== null) {
$commitMessage .= wordwrap($description, 72);
} else {
$commitMessage .= wordwrap(sprintf('This commit contains the result of applying migration %s to this package.', $migrationIdentifier), 72);
}
if ($commitMessageNotice !== null) {
$commitMessage .= chr(10) . chr(10) . wordwrap($commitMessageNotice, 72) . chr(10) . chr(10);
}
list($returnCode, $output) = Git::commitAll($this->currentPackageData['path'], $commitMessage);
if ($returnCode === 0) {
return ' ' . implode(PHP_EOL . ' ', $output) . PHP_EOL;
} else {
return ' No changes were committed.' . PHP_EOL;
}
} | [
"protected",
"function",
"commitMigration",
"(",
"AbstractMigration",
"$",
"migration",
",",
"$",
"commitMessageNotice",
"=",
"null",
")",
"{",
"$",
"migrationIdentifier",
"=",
"$",
"migration",
"->",
"getIdentifier",
"(",
")",
";",
"$",
"commitMessageSubject",
"=... | Commit changes done to the package described by $packageData. The migration
that was did the changes is given with $versionNumber and $versionPackageKey
and will be recorded in the commit message.
@param AbstractMigration $migration
@param string $commitMessageNotice
@return string | [
"Commit",
"changes",
"done",
"to",
"the",
"package",
"described",
"by",
"$packageData",
".",
"The",
"migration",
"that",
"was",
"did",
"the",
"changes",
"is",
"given",
"with",
"$versionNumber",
"and",
"$versionPackageKey",
"and",
"will",
"be",
"recorded",
"in",
... | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Scripts/Migrations/Manager.php#L290-L315 |
neos/flow-development-collection | Neos.Flow/Scripts/Migrations/Manager.php | Manager.triggerEvent | protected function triggerEvent($eventIdentifier, array $eventData = null)
{
if (!isset($this->eventCallbacks[$eventIdentifier])) {
return;
}
/** @var \Closure $callback */
foreach ($this->eventCallbacks[$eventIdentifier] as $callback) {
call_user_func_array($callback, $eventData);
}
} | php | protected function triggerEvent($eventIdentifier, array $eventData = null)
{
if (!isset($this->eventCallbacks[$eventIdentifier])) {
return;
}
/** @var \Closure $callback */
foreach ($this->eventCallbacks[$eventIdentifier] as $callback) {
call_user_func_array($callback, $eventData);
}
} | [
"protected",
"function",
"triggerEvent",
"(",
"$",
"eventIdentifier",
",",
"array",
"$",
"eventData",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"eventCallbacks",
"[",
"$",
"eventIdentifier",
"]",
")",
")",
"{",
"return",
";"... | Trigger a custom event
@param string $eventIdentifier one of the EVENT_* constants
@param array $eventData optional arguments to be passed to the handler closure | [
"Trigger",
"a",
"custom",
"event"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Scripts/Migrations/Manager.php#L334-L343 |
neos/flow-development-collection | Neos.Flow/Scripts/Migrations/Manager.php | Manager.initialize | protected function initialize()
{
if ($this->packagesData !== null) {
return;
}
$this->packagesData = Tools::getPackagesData($this->packagesPath);
$this->migrations = array();
foreach ($this->packagesData as $packageKey => $packageData) {
$this->registerMigrationFiles(Files::concatenatePaths(array($this->packagesPath, $packageData['category'], $packageKey)));
}
ksort($this->migrations);
} | php | protected function initialize()
{
if ($this->packagesData !== null) {
return;
}
$this->packagesData = Tools::getPackagesData($this->packagesPath);
$this->migrations = array();
foreach ($this->packagesData as $packageKey => $packageData) {
$this->registerMigrationFiles(Files::concatenatePaths(array($this->packagesPath, $packageData['category'], $packageKey)));
}
ksort($this->migrations);
} | [
"protected",
"function",
"initialize",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"packagesData",
"!==",
"null",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"packagesData",
"=",
"Tools",
"::",
"getPackagesData",
"(",
"$",
"this",
"->",
"packagesPa... | Initialize the manager: read package information and register migrations.
@return void | [
"Initialize",
"the",
"manager",
":",
"read",
"package",
"information",
"and",
"register",
"migrations",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Scripts/Migrations/Manager.php#L351-L363 |
neos/flow-development-collection | Neos.Flow/Scripts/Migrations/Manager.php | Manager.registerMigrationFiles | protected function registerMigrationFiles($packagePath)
{
$packagePath = rtrim($packagePath, '/');
$packageKey = substr($packagePath, strrpos($packagePath, '/') + 1);
$migrationsDirectory = Files::concatenatePaths(array($packagePath, 'Migrations/Code'));
if (!is_dir($migrationsDirectory)) {
return;
}
foreach (Files::getRecursiveDirectoryGenerator($migrationsDirectory, '.php') as $filenameAndPath) {
/** @noinspection PhpIncludeInspection */
require_once($filenameAndPath);
$baseFilename = basename($filenameAndPath, '.php');
$className = '\\Neos\\Flow\\Core\\Migrations\\' . $baseFilename;
/** @var AbstractMigration $migration */
$migration = new $className($this, $packageKey);
$this->migrations[$migration->getVersionNumber()] = $migration;
}
} | php | protected function registerMigrationFiles($packagePath)
{
$packagePath = rtrim($packagePath, '/');
$packageKey = substr($packagePath, strrpos($packagePath, '/') + 1);
$migrationsDirectory = Files::concatenatePaths(array($packagePath, 'Migrations/Code'));
if (!is_dir($migrationsDirectory)) {
return;
}
foreach (Files::getRecursiveDirectoryGenerator($migrationsDirectory, '.php') as $filenameAndPath) {
/** @noinspection PhpIncludeInspection */
require_once($filenameAndPath);
$baseFilename = basename($filenameAndPath, '.php');
$className = '\\Neos\\Flow\\Core\\Migrations\\' . $baseFilename;
/** @var AbstractMigration $migration */
$migration = new $className($this, $packageKey);
$this->migrations[$migration->getVersionNumber()] = $migration;
}
} | [
"protected",
"function",
"registerMigrationFiles",
"(",
"$",
"packagePath",
")",
"{",
"$",
"packagePath",
"=",
"rtrim",
"(",
"$",
"packagePath",
",",
"'/'",
")",
";",
"$",
"packageKey",
"=",
"substr",
"(",
"$",
"packagePath",
",",
"strrpos",
"(",
"$",
"pac... | Look for code migration files in the given package path and register them
for further action.
@param string $packagePath
@return void | [
"Look",
"for",
"code",
"migration",
"files",
"in",
"the",
"given",
"package",
"path",
"and",
"register",
"them",
"for",
"further",
"action",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Scripts/Migrations/Manager.php#L372-L390 |
neos/flow-development-collection | Neos.Flow/Classes/Security/Authentication/EntryPoint/WebRedirect.php | WebRedirect.startAuthentication | public function startAuthentication(Request $request, Response $response)
{
if (isset($this->options['routeValues'])) {
$routeValues = $this->options['routeValues'];
if (!is_array($routeValues)) {
throw new MissingConfigurationException(sprintf('The configuration for the WebRedirect authentication entry point is incorrect. "routeValues" must be an array, got "%s".', gettype($routeValues)), 1345040415);
}
$actionRequest = new ActionRequest($request);
$this->uriBuilder->setRequest($actionRequest);
$actionName = $this->extractRouteValue($routeValues, '@action');
$controllerName = $this->extractRouteValue($routeValues, '@controller');
$packageKey = $this->extractRouteValue($routeValues, '@package');
$subPackageKey = $this->extractRouteValue($routeValues, '@subpackage');
$uri = $this->uriBuilder->setCreateAbsoluteUri(true)->uriFor($actionName, $routeValues, $controllerName, $packageKey, $subPackageKey);
} elseif (isset($this->options['uri'])) {
$uri = strpos($this->options['uri'], '://') !== false ? $this->options['uri'] : $request->getBaseUri() . $this->options['uri'];
} else {
throw new MissingConfigurationException('The configuration for the WebRedirect authentication entry point is incorrect or missing. You need to specify either the target "uri" or "routeValues".', 1237282583);
}
$response->setContent(sprintf('<html><head><meta http-equiv="refresh" content="0;url=%s"/></head></html>', htmlentities($uri, ENT_QUOTES, 'utf-8')));
$response->setStatus(303);
$response->setHeader('Location', $uri);
} | php | public function startAuthentication(Request $request, Response $response)
{
if (isset($this->options['routeValues'])) {
$routeValues = $this->options['routeValues'];
if (!is_array($routeValues)) {
throw new MissingConfigurationException(sprintf('The configuration for the WebRedirect authentication entry point is incorrect. "routeValues" must be an array, got "%s".', gettype($routeValues)), 1345040415);
}
$actionRequest = new ActionRequest($request);
$this->uriBuilder->setRequest($actionRequest);
$actionName = $this->extractRouteValue($routeValues, '@action');
$controllerName = $this->extractRouteValue($routeValues, '@controller');
$packageKey = $this->extractRouteValue($routeValues, '@package');
$subPackageKey = $this->extractRouteValue($routeValues, '@subpackage');
$uri = $this->uriBuilder->setCreateAbsoluteUri(true)->uriFor($actionName, $routeValues, $controllerName, $packageKey, $subPackageKey);
} elseif (isset($this->options['uri'])) {
$uri = strpos($this->options['uri'], '://') !== false ? $this->options['uri'] : $request->getBaseUri() . $this->options['uri'];
} else {
throw new MissingConfigurationException('The configuration for the WebRedirect authentication entry point is incorrect or missing. You need to specify either the target "uri" or "routeValues".', 1237282583);
}
$response->setContent(sprintf('<html><head><meta http-equiv="refresh" content="0;url=%s"/></head></html>', htmlentities($uri, ENT_QUOTES, 'utf-8')));
$response->setStatus(303);
$response->setHeader('Location', $uri);
} | [
"public",
"function",
"startAuthentication",
"(",
"Request",
"$",
"request",
",",
"Response",
"$",
"response",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"options",
"[",
"'routeValues'",
"]",
")",
")",
"{",
"$",
"routeValues",
"=",
"$",
"this"... | Starts the authentication: Redirect to login page
@param Request $request The current request
@param Response $response The current response
@return void
@throws MissingConfigurationException | [
"Starts",
"the",
"authentication",
":",
"Redirect",
"to",
"login",
"page"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Authentication/EntryPoint/WebRedirect.php#L41-L65 |
neos/flow-development-collection | Neos.Flow/Classes/Security/Authentication/EntryPoint/WebRedirect.php | WebRedirect.extractRouteValue | protected function extractRouteValue(array &$routeValues, $key)
{
if (!isset($routeValues[$key])) {
return null;
}
$routeValue = $routeValues[$key];
unset($routeValues[$key]);
return $routeValue;
} | php | protected function extractRouteValue(array &$routeValues, $key)
{
if (!isset($routeValues[$key])) {
return null;
}
$routeValue = $routeValues[$key];
unset($routeValues[$key]);
return $routeValue;
} | [
"protected",
"function",
"extractRouteValue",
"(",
"array",
"&",
"$",
"routeValues",
",",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"routeValues",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"routeValue",
"=",... | Returns the entry $key from the array $routeValues removing the original array item.
If $key does not exist, NULL is returned.
@param array $routeValues
@param string $key
@return mixed the specified route value or NULL if it is not set | [
"Returns",
"the",
"entry",
"$key",
"from",
"the",
"array",
"$routeValues",
"removing",
"the",
"original",
"array",
"item",
".",
"If",
"$key",
"does",
"not",
"exist",
"NULL",
"is",
"returned",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Authentication/EntryPoint/WebRedirect.php#L75-L83 |
neos/flow-development-collection | Neos.Flow/Classes/Security/Authorization/Privilege/Entity/Doctrine/SqlFilter.php | SqlFilter.addFilterConstraint | public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias)
{
$this->initializeDependencies();
/*
* TODO: Instead of checking for class account we could introduce some interface for white listing entities from entity security checks
* Problem with checking the Account is, that this filter calls getRoles() on the security context while accounts are not
* yet fully initialized. By this we get a half built account object that will end up in access denied exception,
* as it has no roles (and other properties) set
*/
if ($this->securityContext->areAuthorizationChecksDisabled() || $targetEntity->getName() === Account::class) {
return '';
}
if (!$this->securityContext->isInitialized()) {
if (!$this->securityContext->canBeInitialized()) {
return '';
}
$this->securityContext->initialize();
}
// This is needed to include the current context of roles into query cache identifier
$this->setParameter('__contextHash', $this->securityContext->getContextHash(), 'string');
$sqlConstraints = [];
$grantedConstraints = [];
$deniedConstraints = [];
foreach ($this->securityContext->getRoles() as $role) {
$entityPrivileges = $role->getPrivilegesByType(EntityPrivilegeInterface::class);
/** @var EntityPrivilegeInterface $privilege */
foreach ($entityPrivileges as $privilege) {
if (!$privilege->matchesEntityType($targetEntity->getName())) {
continue;
}
$sqlConstraint = $privilege->getSqlConstraint($targetEntity, $targetTableAlias);
if ($sqlConstraint === null) {
continue;
}
$sqlConstraints[] = ' NOT (' . $sqlConstraint . ')';
if ($privilege->isGranted()) {
$grantedConstraints[] = ' NOT (' . $sqlConstraint . ')';
} elseif ($privilege->isDenied()) {
$deniedConstraints[] = ' NOT (' . $sqlConstraint . ')';
}
}
}
$grantedConstraints = array_diff($grantedConstraints, $deniedConstraints);
$effectiveConstraints = array_diff($sqlConstraints, $grantedConstraints);
if (count($effectiveConstraints) > 0) {
return ' (' . implode(') AND (', $effectiveConstraints) . ') ';
}
return '';
} | php | public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias)
{
$this->initializeDependencies();
/*
* TODO: Instead of checking for class account we could introduce some interface for white listing entities from entity security checks
* Problem with checking the Account is, that this filter calls getRoles() on the security context while accounts are not
* yet fully initialized. By this we get a half built account object that will end up in access denied exception,
* as it has no roles (and other properties) set
*/
if ($this->securityContext->areAuthorizationChecksDisabled() || $targetEntity->getName() === Account::class) {
return '';
}
if (!$this->securityContext->isInitialized()) {
if (!$this->securityContext->canBeInitialized()) {
return '';
}
$this->securityContext->initialize();
}
// This is needed to include the current context of roles into query cache identifier
$this->setParameter('__contextHash', $this->securityContext->getContextHash(), 'string');
$sqlConstraints = [];
$grantedConstraints = [];
$deniedConstraints = [];
foreach ($this->securityContext->getRoles() as $role) {
$entityPrivileges = $role->getPrivilegesByType(EntityPrivilegeInterface::class);
/** @var EntityPrivilegeInterface $privilege */
foreach ($entityPrivileges as $privilege) {
if (!$privilege->matchesEntityType($targetEntity->getName())) {
continue;
}
$sqlConstraint = $privilege->getSqlConstraint($targetEntity, $targetTableAlias);
if ($sqlConstraint === null) {
continue;
}
$sqlConstraints[] = ' NOT (' . $sqlConstraint . ')';
if ($privilege->isGranted()) {
$grantedConstraints[] = ' NOT (' . $sqlConstraint . ')';
} elseif ($privilege->isDenied()) {
$deniedConstraints[] = ' NOT (' . $sqlConstraint . ')';
}
}
}
$grantedConstraints = array_diff($grantedConstraints, $deniedConstraints);
$effectiveConstraints = array_diff($sqlConstraints, $grantedConstraints);
if (count($effectiveConstraints) > 0) {
return ' (' . implode(') AND (', $effectiveConstraints) . ') ';
}
return '';
} | [
"public",
"function",
"addFilterConstraint",
"(",
"ClassMetadata",
"$",
"targetEntity",
",",
"$",
"targetTableAlias",
")",
"{",
"$",
"this",
"->",
"initializeDependencies",
"(",
")",
";",
"/*\n * TODO: Instead of checking for class account we could introduce some interf... | Gets the SQL query part to add to a query.
@param ClassMetaData $targetEntity Metadata object for the target entity to be filtered
@param string $targetTableAlias The target table alias used in the current query
@return string The constraint SQL if there is available, empty string otherwise | [
"Gets",
"the",
"SQL",
"query",
"part",
"to",
"add",
"to",
"a",
"query",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Authorization/Privilege/Entity/Doctrine/SqlFilter.php#L47-L101 |
neos/flow-development-collection | Neos.Flow/Classes/Security/Authorization/Privilege/Entity/Doctrine/SqlFilter.php | SqlFilter.initializeDependencies | protected function initializeDependencies()
{
if ($this->securityContext === null) {
$this->securityContext = Bootstrap::$staticObjectManager->get(Context::class);
}
if ($this->policyService === null) {
$this->policyService = Bootstrap::$staticObjectManager->get(PolicyService::class);
}
} | php | protected function initializeDependencies()
{
if ($this->securityContext === null) {
$this->securityContext = Bootstrap::$staticObjectManager->get(Context::class);
}
if ($this->policyService === null) {
$this->policyService = Bootstrap::$staticObjectManager->get(PolicyService::class);
}
} | [
"protected",
"function",
"initializeDependencies",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"securityContext",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"securityContext",
"=",
"Bootstrap",
"::",
"$",
"staticObjectManager",
"->",
"get",
"(",
"Context",
... | Initializes the dependencies by retrieving them from the object manager
@return void | [
"Initializes",
"the",
"dependencies",
"by",
"retrieving",
"them",
"from",
"the",
"object",
"manager"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Authorization/Privilege/Entity/Doctrine/SqlFilter.php#L108-L117 |
neos/flow-development-collection | Neos.Flow/Classes/Persistence/Doctrine/Service.php | Service.validateMapping | public function validateMapping()
{
try {
$validator = new SchemaValidator($this->entityManager);
return $validator->validateMapping();
} catch (\Exception $exception) {
return [[$exception->getMessage()]];
}
} | php | public function validateMapping()
{
try {
$validator = new SchemaValidator($this->entityManager);
return $validator->validateMapping();
} catch (\Exception $exception) {
return [[$exception->getMessage()]];
}
} | [
"public",
"function",
"validateMapping",
"(",
")",
"{",
"try",
"{",
"$",
"validator",
"=",
"new",
"SchemaValidator",
"(",
"$",
"this",
"->",
"entityManager",
")",
";",
"return",
"$",
"validator",
"->",
"validateMapping",
"(",
")",
";",
"}",
"catch",
"(",
... | Validates the metadata mapping for Doctrine, using the SchemaValidator
of Doctrine.
@return array | [
"Validates",
"the",
"metadata",
"mapping",
"for",
"Doctrine",
"using",
"the",
"SchemaValidator",
"of",
"Doctrine",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Persistence/Doctrine/Service.php#L75-L83 |
neos/flow-development-collection | Neos.Flow/Classes/Persistence/Doctrine/Service.php | Service.createSchema | public function createSchema($outputPathAndFilename = null)
{
$schemaTool = new SchemaTool($this->entityManager);
$allMetaData = $this->entityManager->getMetadataFactory()->getAllMetadata();
if ($outputPathAndFilename === null) {
$schemaTool->createSchema($allMetaData);
} else {
$createSchemaSqlStatements = $schemaTool->getCreateSchemaSql($allMetaData);
file_put_contents($outputPathAndFilename, implode(PHP_EOL, $createSchemaSqlStatements));
}
} | php | public function createSchema($outputPathAndFilename = null)
{
$schemaTool = new SchemaTool($this->entityManager);
$allMetaData = $this->entityManager->getMetadataFactory()->getAllMetadata();
if ($outputPathAndFilename === null) {
$schemaTool->createSchema($allMetaData);
} else {
$createSchemaSqlStatements = $schemaTool->getCreateSchemaSql($allMetaData);
file_put_contents($outputPathAndFilename, implode(PHP_EOL, $createSchemaSqlStatements));
}
} | [
"public",
"function",
"createSchema",
"(",
"$",
"outputPathAndFilename",
"=",
"null",
")",
"{",
"$",
"schemaTool",
"=",
"new",
"SchemaTool",
"(",
"$",
"this",
"->",
"entityManager",
")",
";",
"$",
"allMetaData",
"=",
"$",
"this",
"->",
"entityManager",
"->",... | Creates the needed DB schema using Doctrine's SchemaTool. If tables already
exist, this will throw an exception.
@param string $outputPathAndFilename A file to write SQL to, instead of executing it
@return string
@throws ToolsException | [
"Creates",
"the",
"needed",
"DB",
"schema",
"using",
"Doctrine",
"s",
"SchemaTool",
".",
"If",
"tables",
"already",
"exist",
"this",
"will",
"throw",
"an",
"exception",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Persistence/Doctrine/Service.php#L93-L103 |
neos/flow-development-collection | Neos.Flow/Classes/Persistence/Doctrine/Service.php | Service.updateSchema | public function updateSchema($safeMode = true, $outputPathAndFilename = null)
{
$schemaTool = new SchemaTool($this->entityManager);
$allMetaData = $this->entityManager->getMetadataFactory()->getAllMetadata();
if ($outputPathAndFilename === null) {
$schemaTool->updateSchema($allMetaData, $safeMode);
} else {
$updateSchemaSqlStatements = $schemaTool->getUpdateSchemaSql($allMetaData, $safeMode);
file_put_contents($outputPathAndFilename, implode(PHP_EOL, $updateSchemaSqlStatements));
}
} | php | public function updateSchema($safeMode = true, $outputPathAndFilename = null)
{
$schemaTool = new SchemaTool($this->entityManager);
$allMetaData = $this->entityManager->getMetadataFactory()->getAllMetadata();
if ($outputPathAndFilename === null) {
$schemaTool->updateSchema($allMetaData, $safeMode);
} else {
$updateSchemaSqlStatements = $schemaTool->getUpdateSchemaSql($allMetaData, $safeMode);
file_put_contents($outputPathAndFilename, implode(PHP_EOL, $updateSchemaSqlStatements));
}
} | [
"public",
"function",
"updateSchema",
"(",
"$",
"safeMode",
"=",
"true",
",",
"$",
"outputPathAndFilename",
"=",
"null",
")",
"{",
"$",
"schemaTool",
"=",
"new",
"SchemaTool",
"(",
"$",
"this",
"->",
"entityManager",
")",
";",
"$",
"allMetaData",
"=",
"$",... | Updates the DB schema using Doctrine's SchemaTool. The $safeMode flag is passed
to SchemaTool unchanged.
@param boolean $safeMode
@param string $outputPathAndFilename A file to write SQL to, instead of executing it
@return string | [
"Updates",
"the",
"DB",
"schema",
"using",
"Doctrine",
"s",
"SchemaTool",
".",
"The",
"$safeMode",
"flag",
"is",
"passed",
"to",
"SchemaTool",
"unchanged",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Persistence/Doctrine/Service.php#L113-L123 |
neos/flow-development-collection | Neos.Flow/Classes/Persistence/Doctrine/Service.php | Service.compileProxies | public function compileProxies()
{
Files::emptyDirectoryRecursively(Files::concatenatePaths([$this->environment->getPathToTemporaryDirectory(), 'Doctrine/Proxies']));
/** @var \Doctrine\ORM\Proxy\ProxyFactory $proxyFactory */
$proxyFactory = $this->entityManager->getProxyFactory();
$proxyFactory->generateProxyClasses($this->entityManager->getMetadataFactory()->getAllMetadata());
} | php | public function compileProxies()
{
Files::emptyDirectoryRecursively(Files::concatenatePaths([$this->environment->getPathToTemporaryDirectory(), 'Doctrine/Proxies']));
/** @var \Doctrine\ORM\Proxy\ProxyFactory $proxyFactory */
$proxyFactory = $this->entityManager->getProxyFactory();
$proxyFactory->generateProxyClasses($this->entityManager->getMetadataFactory()->getAllMetadata());
} | [
"public",
"function",
"compileProxies",
"(",
")",
"{",
"Files",
"::",
"emptyDirectoryRecursively",
"(",
"Files",
"::",
"concatenatePaths",
"(",
"[",
"$",
"this",
"->",
"environment",
"->",
"getPathToTemporaryDirectory",
"(",
")",
",",
"'Doctrine/Proxies'",
"]",
")... | Compiles the Doctrine proxy class code using the Doctrine ProxyFactory.
@return void
@throws FilesException | [
"Compiles",
"the",
"Doctrine",
"proxy",
"class",
"code",
"using",
"the",
"Doctrine",
"ProxyFactory",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Persistence/Doctrine/Service.php#L131-L137 |
neos/flow-development-collection | Neos.Flow/Classes/Persistence/Doctrine/Service.php | Service.getEntityStatus | public function getEntityStatus()
{
$info = [];
$entityClassNames = $this->entityManager->getConfiguration()->getMetadataDriverImpl()->getAllClassNames();
foreach ($entityClassNames as $entityClassName) {
try {
$info[$entityClassName] = $this->entityManager->getClassMetadata($entityClassName);
} catch (MappingException $e) {
$info[$entityClassName] = $e->getMessage();
}
}
return $info;
} | php | public function getEntityStatus()
{
$info = [];
$entityClassNames = $this->entityManager->getConfiguration()->getMetadataDriverImpl()->getAllClassNames();
foreach ($entityClassNames as $entityClassName) {
try {
$info[$entityClassName] = $this->entityManager->getClassMetadata($entityClassName);
} catch (MappingException $e) {
$info[$entityClassName] = $e->getMessage();
}
}
return $info;
} | [
"public",
"function",
"getEntityStatus",
"(",
")",
"{",
"$",
"info",
"=",
"[",
"]",
";",
"$",
"entityClassNames",
"=",
"$",
"this",
"->",
"entityManager",
"->",
"getConfiguration",
"(",
")",
"->",
"getMetadataDriverImpl",
"(",
")",
"->",
"getAllClassNames",
... | Returns information about which entities exist and possibly if their
mapping information contains errors or not.
@return array
@throws \Doctrine\ORM\ORMException | [
"Returns",
"information",
"about",
"which",
"entities",
"exist",
"and",
"possibly",
"if",
"their",
"mapping",
"information",
"contains",
"errors",
"or",
"not",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Persistence/Doctrine/Service.php#L146-L159 |
neos/flow-development-collection | Neos.Flow/Classes/Persistence/Doctrine/Service.php | Service.runDql | public function runDql($dql, $hydrationMode = \Doctrine\ORM\Query::HYDRATE_OBJECT, $firstResult = null, $maxResult = null)
{
/** @var \Doctrine\ORM\Query $query */
$query = $this->entityManager->createQuery($dql);
if ($firstResult !== null) {
$query->setFirstResult($firstResult);
}
if ($maxResult !== null) {
$query->setMaxResults($maxResult);
}
return $query->execute([], $hydrationMode);
} | php | public function runDql($dql, $hydrationMode = \Doctrine\ORM\Query::HYDRATE_OBJECT, $firstResult = null, $maxResult = null)
{
/** @var \Doctrine\ORM\Query $query */
$query = $this->entityManager->createQuery($dql);
if ($firstResult !== null) {
$query->setFirstResult($firstResult);
}
if ($maxResult !== null) {
$query->setMaxResults($maxResult);
}
return $query->execute([], $hydrationMode);
} | [
"public",
"function",
"runDql",
"(",
"$",
"dql",
",",
"$",
"hydrationMode",
"=",
"\\",
"Doctrine",
"\\",
"ORM",
"\\",
"Query",
"::",
"HYDRATE_OBJECT",
",",
"$",
"firstResult",
"=",
"null",
",",
"$",
"maxResult",
"=",
"null",
")",
"{",
"/** @var \\Doctrine\... | Run DQL and return the result as-is.
@param string $dql
@param integer $hydrationMode
@param integer $firstResult
@param integer $maxResult
@return mixed | [
"Run",
"DQL",
"and",
"return",
"the",
"result",
"as",
"-",
"is",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Persistence/Doctrine/Service.php#L170-L182 |
neos/flow-development-collection | Neos.Flow/Classes/Persistence/Doctrine/Service.php | Service.getMigrationConfiguration | protected function getMigrationConfiguration()
{
$this->output = [];
$that = $this;
$outputWriter = new OutputWriter(
function ($message) use ($that) {
$that->output[] = $message;
}
);
/** @var \Doctrine\DBAL\Connection $connection */
$connection = $this->entityManager->getConnection();
$schemaManager = $connection->getSchemaManager();
if ($schemaManager->tablesExist(['flow3_doctrine_migrationstatus']) === true) {
$schemaManager->renameTable('flow3_doctrine_migrationstatus', self::DOCTRINE_MIGRATIONSTABLENAME);
}
$configuration = new Configuration($connection, $outputWriter);
$configuration->setMigrationsNamespace('Neos\Flow\Persistence\Doctrine\Migrations');
$configuration->setMigrationsDirectory(Files::concatenatePaths([FLOW_PATH_DATA, 'DoctrineMigrations']));
$configuration->setMigrationsTableName(self::DOCTRINE_MIGRATIONSTABLENAME);
$configuration->createMigrationTable();
$databasePlatformName = $this->getDatabasePlatformName();
/** @var PackageInterface $package */
foreach ($this->packageManager->getAvailablePackages() as $package) {
$path = Files::concatenatePaths([
$package->getPackagePath(),
'Migrations',
$databasePlatformName
]);
if (is_dir($path)) {
$configuration->registerMigrationsFromDirectory($path);
}
}
return $configuration;
} | php | protected function getMigrationConfiguration()
{
$this->output = [];
$that = $this;
$outputWriter = new OutputWriter(
function ($message) use ($that) {
$that->output[] = $message;
}
);
/** @var \Doctrine\DBAL\Connection $connection */
$connection = $this->entityManager->getConnection();
$schemaManager = $connection->getSchemaManager();
if ($schemaManager->tablesExist(['flow3_doctrine_migrationstatus']) === true) {
$schemaManager->renameTable('flow3_doctrine_migrationstatus', self::DOCTRINE_MIGRATIONSTABLENAME);
}
$configuration = new Configuration($connection, $outputWriter);
$configuration->setMigrationsNamespace('Neos\Flow\Persistence\Doctrine\Migrations');
$configuration->setMigrationsDirectory(Files::concatenatePaths([FLOW_PATH_DATA, 'DoctrineMigrations']));
$configuration->setMigrationsTableName(self::DOCTRINE_MIGRATIONSTABLENAME);
$configuration->createMigrationTable();
$databasePlatformName = $this->getDatabasePlatformName();
/** @var PackageInterface $package */
foreach ($this->packageManager->getAvailablePackages() as $package) {
$path = Files::concatenatePaths([
$package->getPackagePath(),
'Migrations',
$databasePlatformName
]);
if (is_dir($path)) {
$configuration->registerMigrationsFromDirectory($path);
}
}
return $configuration;
} | [
"protected",
"function",
"getMigrationConfiguration",
"(",
")",
"{",
"$",
"this",
"->",
"output",
"=",
"[",
"]",
";",
"$",
"that",
"=",
"$",
"this",
";",
"$",
"outputWriter",
"=",
"new",
"OutputWriter",
"(",
"function",
"(",
"$",
"message",
")",
"use",
... | Return the configuration needed for Migrations.
@return Configuration
@throws DBALException | [
"Return",
"the",
"configuration",
"needed",
"for",
"Migrations",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Persistence/Doctrine/Service.php#L190-L228 |
neos/flow-development-collection | Neos.Flow/Classes/Persistence/Doctrine/Service.php | Service.getMigrationStatus | public function getMigrationStatus()
{
$configuration = $this->getMigrationConfiguration();
$executedMigrations = $configuration->getMigratedVersions();
$availableMigrations = $configuration->getAvailableVersions();
$executedUnavailableMigrations = array_diff($executedMigrations, $availableMigrations);
$numExecutedUnavailableMigrations = count($executedUnavailableMigrations);
$numNewMigrations = count(array_diff($availableMigrations, $executedMigrations));
return [
'Name' => $configuration->getName() ? $configuration->getName() : 'Doctrine Database Migrations',
'Database Driver' => $configuration->getConnection()->getDriver()->getName(),
'Database Name' => $configuration->getConnection()->getDatabase(),
'Configuration Source' => 'manually configured',
'Version Table Name' => $configuration->getMigrationsTableName(),
'Version Column Name' => $configuration->getMigrationsColumnName(),
'Migrations Namespace' => $configuration->getMigrationsNamespace(),
'Migrations Target Directory' => $configuration->getMigrationsDirectory(),
'Previous Version' => $this->getFormattedVersionAlias('prev', $configuration),
'Current Version' => $this->getFormattedVersionAlias('current', $configuration),
'Next Version' => $this->getFormattedVersionAlias('next', $configuration),
'Latest Version' => $this->getFormattedVersionAlias('latest', $configuration),
'Executed Migrations' => count($executedMigrations),
'Executed Unavailable Migrations' => $numExecutedUnavailableMigrations,
'Available Migrations' => count($availableMigrations),
'New Migrations' => $numNewMigrations,
];
} | php | public function getMigrationStatus()
{
$configuration = $this->getMigrationConfiguration();
$executedMigrations = $configuration->getMigratedVersions();
$availableMigrations = $configuration->getAvailableVersions();
$executedUnavailableMigrations = array_diff($executedMigrations, $availableMigrations);
$numExecutedUnavailableMigrations = count($executedUnavailableMigrations);
$numNewMigrations = count(array_diff($availableMigrations, $executedMigrations));
return [
'Name' => $configuration->getName() ? $configuration->getName() : 'Doctrine Database Migrations',
'Database Driver' => $configuration->getConnection()->getDriver()->getName(),
'Database Name' => $configuration->getConnection()->getDatabase(),
'Configuration Source' => 'manually configured',
'Version Table Name' => $configuration->getMigrationsTableName(),
'Version Column Name' => $configuration->getMigrationsColumnName(),
'Migrations Namespace' => $configuration->getMigrationsNamespace(),
'Migrations Target Directory' => $configuration->getMigrationsDirectory(),
'Previous Version' => $this->getFormattedVersionAlias('prev', $configuration),
'Current Version' => $this->getFormattedVersionAlias('current', $configuration),
'Next Version' => $this->getFormattedVersionAlias('next', $configuration),
'Latest Version' => $this->getFormattedVersionAlias('latest', $configuration),
'Executed Migrations' => count($executedMigrations),
'Executed Unavailable Migrations' => $numExecutedUnavailableMigrations,
'Available Migrations' => count($availableMigrations),
'New Migrations' => $numNewMigrations,
];
} | [
"public",
"function",
"getMigrationStatus",
"(",
")",
"{",
"$",
"configuration",
"=",
"$",
"this",
"->",
"getMigrationConfiguration",
"(",
")",
";",
"$",
"executedMigrations",
"=",
"$",
"configuration",
"->",
"getMigratedVersions",
"(",
")",
";",
"$",
"available... | Returns the current migration status as an array.
@return array
@throws DBALException | [
"Returns",
"the",
"current",
"migration",
"status",
"as",
"an",
"array",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Persistence/Doctrine/Service.php#L236-L265 |
neos/flow-development-collection | Neos.Flow/Classes/Persistence/Doctrine/Service.php | Service.getFormattedMigrationStatus | public function getFormattedMigrationStatus($showMigrations = false, $showDescriptions = false)
{
$statusInformation = $this->getMigrationStatus();
$output = PHP_EOL . '<info>==</info> Configuration' . PHP_EOL;
foreach ($statusInformation as $name => $value) {
if ($name == 'New Migrations') {
$value = $value > 0 ? '<question>' . $value . '</question>' : 0;
}
if ($name == 'Executed Unavailable Migrations') {
$value = $value > 0 ? '<error>' . $value . '</error>' : 0;
}
$output .= ' <comment>></comment> ' . $name . ': ' . str_repeat(' ', 35 - strlen($name)) . $value . PHP_EOL;
}
if ($showMigrations) {
$configuration = $this->getMigrationConfiguration();
$executedMigrations = $configuration->getMigratedVersions();
$availableMigrations = $configuration->getAvailableVersions();
$executedUnavailableMigrations = array_diff($executedMigrations, $availableMigrations);
if ($migrations = $configuration->getMigrations()) {
$docCommentParser = new DocCommentParser();
$output .= PHP_EOL . ' <info>==</info> Available Migration Versions' . PHP_EOL;
/** @var Version $version */
foreach ($migrations as $version) {
$packageKey = $this->getPackageKeyFromMigrationVersion($version);
$croppedPackageKey = strlen($packageKey) < 30 ? $packageKey : substr($packageKey, 0, 29) . '~';
$packageKeyColumn = ' ' . str_pad($croppedPackageKey, 30, ' ');
$isMigrated = in_array($version->getVersion(), $executedMigrations);
$status = $isMigrated ? '<info>migrated</info>' : '<error>not migrated</error>';
$migrationDescription = '';
if ($showDescriptions) {
$migrationDescription = str_repeat(' ', 2) . $this->getMigrationDescription($version, $docCommentParser);
}
$formattedVersion = $configuration->getDateTime($version->getVersion());
$output .= ' <comment>></comment> ' . $formattedVersion .
' (<comment>' . $version->getVersion() . '</comment>)' . $packageKeyColumn .
str_repeat(' ', 2) . $status . $migrationDescription . PHP_EOL;
}
}
if (count($executedUnavailableMigrations)) {
$output .= PHP_EOL . ' <info>==</info> Previously Executed Unavailable Migration Versions' . PHP_EOL;
foreach ($executedUnavailableMigrations as $executedUnavailableMigration) {
$output .= ' <comment>></comment> ' . $configuration->getDateTime($executedUnavailableMigration) .
' (<comment>' . $executedUnavailableMigration . '</comment>)' . PHP_EOL;
}
}
}
return $output;
} | php | public function getFormattedMigrationStatus($showMigrations = false, $showDescriptions = false)
{
$statusInformation = $this->getMigrationStatus();
$output = PHP_EOL . '<info>==</info> Configuration' . PHP_EOL;
foreach ($statusInformation as $name => $value) {
if ($name == 'New Migrations') {
$value = $value > 0 ? '<question>' . $value . '</question>' : 0;
}
if ($name == 'Executed Unavailable Migrations') {
$value = $value > 0 ? '<error>' . $value . '</error>' : 0;
}
$output .= ' <comment>></comment> ' . $name . ': ' . str_repeat(' ', 35 - strlen($name)) . $value . PHP_EOL;
}
if ($showMigrations) {
$configuration = $this->getMigrationConfiguration();
$executedMigrations = $configuration->getMigratedVersions();
$availableMigrations = $configuration->getAvailableVersions();
$executedUnavailableMigrations = array_diff($executedMigrations, $availableMigrations);
if ($migrations = $configuration->getMigrations()) {
$docCommentParser = new DocCommentParser();
$output .= PHP_EOL . ' <info>==</info> Available Migration Versions' . PHP_EOL;
/** @var Version $version */
foreach ($migrations as $version) {
$packageKey = $this->getPackageKeyFromMigrationVersion($version);
$croppedPackageKey = strlen($packageKey) < 30 ? $packageKey : substr($packageKey, 0, 29) . '~';
$packageKeyColumn = ' ' . str_pad($croppedPackageKey, 30, ' ');
$isMigrated = in_array($version->getVersion(), $executedMigrations);
$status = $isMigrated ? '<info>migrated</info>' : '<error>not migrated</error>';
$migrationDescription = '';
if ($showDescriptions) {
$migrationDescription = str_repeat(' ', 2) . $this->getMigrationDescription($version, $docCommentParser);
}
$formattedVersion = $configuration->getDateTime($version->getVersion());
$output .= ' <comment>></comment> ' . $formattedVersion .
' (<comment>' . $version->getVersion() . '</comment>)' . $packageKeyColumn .
str_repeat(' ', 2) . $status . $migrationDescription . PHP_EOL;
}
}
if (count($executedUnavailableMigrations)) {
$output .= PHP_EOL . ' <info>==</info> Previously Executed Unavailable Migration Versions' . PHP_EOL;
foreach ($executedUnavailableMigrations as $executedUnavailableMigration) {
$output .= ' <comment>></comment> ' . $configuration->getDateTime($executedUnavailableMigration) .
' (<comment>' . $executedUnavailableMigration . '</comment>)' . PHP_EOL;
}
}
}
return $output;
} | [
"public",
"function",
"getFormattedMigrationStatus",
"(",
"$",
"showMigrations",
"=",
"false",
",",
"$",
"showDescriptions",
"=",
"false",
")",
"{",
"$",
"statusInformation",
"=",
"$",
"this",
"->",
"getMigrationStatus",
"(",
")",
";",
"$",
"output",
"=",
"PHP... | Returns a formatted string of current database migration status.
@param boolean $showMigrations
@param boolean $showDescriptions
@return string
@throws \ReflectionException
@throws DBALException | [
"Returns",
"a",
"formatted",
"string",
"of",
"current",
"database",
"migration",
"status",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Persistence/Doctrine/Service.php#L276-L331 |
neos/flow-development-collection | Neos.Flow/Classes/Persistence/Doctrine/Service.php | Service.getPackageKeyFromMigrationVersion | protected function getPackageKeyFromMigrationVersion(Version $version)
{
$sortedAvailablePackages = $this->packageManager->getAvailablePackages();
usort($sortedAvailablePackages, function (PackageInterface $packageOne, PackageInterface $packageTwo) {
return strlen($packageTwo->getPackagePath()) - strlen($packageOne->getPackagePath());
});
$reflectedClass = new \ReflectionClass($version->getMigration());
$classPathAndFilename = Files::getUnixStylePath($reflectedClass->getFileName());
/** @var $package PackageInterface */
foreach ($sortedAvailablePackages as $package) {
$packagePath = Files::getUnixStylePath($package->getPackagePath());
if (strpos($classPathAndFilename, $packagePath) === 0) {
return $package->getPackageKey();
}
}
return '';
} | php | protected function getPackageKeyFromMigrationVersion(Version $version)
{
$sortedAvailablePackages = $this->packageManager->getAvailablePackages();
usort($sortedAvailablePackages, function (PackageInterface $packageOne, PackageInterface $packageTwo) {
return strlen($packageTwo->getPackagePath()) - strlen($packageOne->getPackagePath());
});
$reflectedClass = new \ReflectionClass($version->getMigration());
$classPathAndFilename = Files::getUnixStylePath($reflectedClass->getFileName());
/** @var $package PackageInterface */
foreach ($sortedAvailablePackages as $package) {
$packagePath = Files::getUnixStylePath($package->getPackagePath());
if (strpos($classPathAndFilename, $packagePath) === 0) {
return $package->getPackageKey();
}
}
return '';
} | [
"protected",
"function",
"getPackageKeyFromMigrationVersion",
"(",
"Version",
"$",
"version",
")",
"{",
"$",
"sortedAvailablePackages",
"=",
"$",
"this",
"->",
"packageManager",
"->",
"getAvailablePackages",
"(",
")",
";",
"usort",
"(",
"$",
"sortedAvailablePackages",... | Tries to find out a package key which the Version belongs to. If no
package could be found, an empty string is returned.
@param Version $version
@return string
@throws \ReflectionException | [
"Tries",
"to",
"find",
"out",
"a",
"package",
"key",
"which",
"the",
"Version",
"belongs",
"to",
".",
"If",
"no",
"package",
"could",
"be",
"found",
"an",
"empty",
"string",
"is",
"returned",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Persistence/Doctrine/Service.php#L341-L360 |
neos/flow-development-collection | Neos.Flow/Classes/Persistence/Doctrine/Service.php | Service.getFormattedVersionAlias | protected function getFormattedVersionAlias($alias, Configuration $configuration)
{
$version = $configuration->resolveVersionAlias($alias);
if ($version === null) {
if ($alias == 'next') {
return 'Already at latest version';
} elseif ($alias == 'prev') {
return 'Already at first version';
}
}
if ($version === '0') {
return '<comment>0</comment>';
}
return $configuration->getDateTime($version) . ' (<comment>' . $version . '</comment>)';
} | php | protected function getFormattedVersionAlias($alias, Configuration $configuration)
{
$version = $configuration->resolveVersionAlias($alias);
if ($version === null) {
if ($alias == 'next') {
return 'Already at latest version';
} elseif ($alias == 'prev') {
return 'Already at first version';
}
}
if ($version === '0') {
return '<comment>0</comment>';
}
return $configuration->getDateTime($version) . ' (<comment>' . $version . '</comment>)';
} | [
"protected",
"function",
"getFormattedVersionAlias",
"(",
"$",
"alias",
",",
"Configuration",
"$",
"configuration",
")",
"{",
"$",
"version",
"=",
"$",
"configuration",
"->",
"resolveVersionAlias",
"(",
"$",
"alias",
")",
";",
"if",
"(",
"$",
"version",
"===",... | Returns a formatted version string for the alias.
@param string $alias
@param Configuration $configuration
@return string | [
"Returns",
"a",
"formatted",
"version",
"string",
"for",
"the",
"alias",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Persistence/Doctrine/Service.php#L369-L386 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.