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.Flow/Classes/Security/Policy/PolicyService.php | PolicyService.getRoles | public function getRoles($includeAbstract = false)
{
$this->initialize();
if (!$includeAbstract) {
return array_filter($this->roles, function (Role $role) {
return $role->isAbstract() !== true;
});
}
return $this->roles;
} | php | public function getRoles($includeAbstract = false)
{
$this->initialize();
if (!$includeAbstract) {
return array_filter($this->roles, function (Role $role) {
return $role->isAbstract() !== true;
});
}
return $this->roles;
} | [
"public",
"function",
"getRoles",
"(",
"$",
"includeAbstract",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"initialize",
"(",
")",
";",
"if",
"(",
"!",
"$",
"includeAbstract",
")",
"{",
"return",
"array_filter",
"(",
"$",
"this",
"->",
"roles",
",",
"fu... | Returns an array of all configured roles
@param boolean $includeAbstract If true the result includes abstract roles, otherwise those will be skipped
@return Role[] Array of all configured roles, indexed by role identifier | [
"Returns",
"an",
"array",
"of",
"all",
"configured",
"roles"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Policy/PolicyService.php#L239-L248 |
neos/flow-development-collection | Neos.Flow/Classes/Security/Policy/PolicyService.php | PolicyService.getAllPrivilegesByType | public function getAllPrivilegesByType($type)
{
$this->initialize();
$privileges = [];
foreach ($this->roles as $role) {
$privileges = array_merge($privileges, $role->getPrivilegesByType($type));
}
return $privileges;
} | php | public function getAllPrivilegesByType($type)
{
$this->initialize();
$privileges = [];
foreach ($this->roles as $role) {
$privileges = array_merge($privileges, $role->getPrivilegesByType($type));
}
return $privileges;
} | [
"public",
"function",
"getAllPrivilegesByType",
"(",
"$",
"type",
")",
"{",
"$",
"this",
"->",
"initialize",
"(",
")",
";",
"$",
"privileges",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"roles",
"as",
"$",
"role",
")",
"{",
"$",
"privileg... | Returns all privileges of the given type
@param string $type Full qualified class or interface name
@return array | [
"Returns",
"all",
"privileges",
"of",
"the",
"given",
"type"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Policy/PolicyService.php#L256-L264 |
neos/flow-development-collection | Neos.Flow/Classes/Security/Policy/PolicyService.php | PolicyService.getPrivilegeTargetByIdentifier | public function getPrivilegeTargetByIdentifier($privilegeTargetIdentifier)
{
$this->initialize();
return isset($this->privilegeTargets[$privilegeTargetIdentifier]) ? $this->privilegeTargets[$privilegeTargetIdentifier] : null;
} | php | public function getPrivilegeTargetByIdentifier($privilegeTargetIdentifier)
{
$this->initialize();
return isset($this->privilegeTargets[$privilegeTargetIdentifier]) ? $this->privilegeTargets[$privilegeTargetIdentifier] : null;
} | [
"public",
"function",
"getPrivilegeTargetByIdentifier",
"(",
"$",
"privilegeTargetIdentifier",
")",
"{",
"$",
"this",
"->",
"initialize",
"(",
")",
";",
"return",
"isset",
"(",
"$",
"this",
"->",
"privilegeTargets",
"[",
"$",
"privilegeTargetIdentifier",
"]",
")",... | Returns the privilege target identified by the given string
@param string $privilegeTargetIdentifier Identifier of a privilege target
@return PrivilegeTarget | [
"Returns",
"the",
"privilege",
"target",
"identified",
"by",
"the",
"given",
"string"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Policy/PolicyService.php#L283-L287 |
neos/flow-development-collection | Neos.Flow/Classes/Persistence/Generic/DataMapper.php | DataMapper.mapToObjects | public function mapToObjects(array $objectsData)
{
$objects = [];
foreach ($objectsData as $objectData) {
$objects[] = $this->mapToObject($objectData);
}
return $objects;
} | php | public function mapToObjects(array $objectsData)
{
$objects = [];
foreach ($objectsData as $objectData) {
$objects[] = $this->mapToObject($objectData);
}
return $objects;
} | [
"public",
"function",
"mapToObjects",
"(",
"array",
"$",
"objectsData",
")",
"{",
"$",
"objects",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"objectsData",
"as",
"$",
"objectData",
")",
"{",
"$",
"objects",
"[",
"]",
"=",
"$",
"this",
"->",
"mapToObject"... | Maps the (aggregate root) node data and registers the objects as
reconstituted with the session.
Note: QueryResult relies on the fact that the first object of $objects has the numeric index "0"
@param array $objectsData
@return array | [
"Maps",
"the",
"(",
"aggregate",
"root",
")",
"node",
"data",
"and",
"registers",
"the",
"objects",
"as",
"reconstituted",
"with",
"the",
"session",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Persistence/Generic/DataMapper.php#L88-L96 |
neos/flow-development-collection | Neos.Flow/Classes/Persistence/Generic/DataMapper.php | DataMapper.mapToObject | public function mapToObject(array $objectData)
{
if ($objectData === []) {
throw new Exception\InvalidObjectDataException('The array with object data was empty, probably object not found or access denied.', 1277974338);
}
if ($this->persistenceSession->hasIdentifier($objectData['identifier'])) {
return $this->persistenceSession->getObjectByIdentifier($objectData['identifier']);
} else {
$className = $objectData['classname'];
$classSchema = $this->reflectionService->getClassSchema($className);
$object = unserialize('O:' . strlen($className) . ':"' . $className . '":0:{};');
$this->persistenceSession->registerObject($object, $objectData['identifier']);
if ($classSchema->getModelType() === ClassSchema::MODELTYPE_ENTITY) {
$this->persistenceSession->registerReconstitutedEntity($object, $objectData);
}
if ($objectData['properties'] === []) {
if (!$classSchema->isLazyLoadableObject()) {
throw new PersistenceException('The object of type "' . $className . '" is not marked as lazy loadable.', 1268309017);
}
$persistenceManager = $this->persistenceManager;
$persistenceSession = $this->persistenceSession;
$dataMapper = $this;
$identifier = $objectData['identifier'];
$modelType = $classSchema->getModelType();
$object->Flow_Persistence_LazyLoadingObject_thawProperties = function ($object) use ($persistenceManager, $persistenceSession, $dataMapper, $identifier, $modelType) {
$objectData = $persistenceManager->getObjectDataByIdentifier($identifier);
$dataMapper->thawProperties($object, $identifier, $objectData);
if ($modelType === ClassSchema::MODELTYPE_ENTITY) {
$persistenceSession->registerReconstitutedEntity($object, $objectData);
}
};
} else {
$this->thawProperties($object, $objectData['identifier'], $objectData);
}
return $object;
}
} | php | public function mapToObject(array $objectData)
{
if ($objectData === []) {
throw new Exception\InvalidObjectDataException('The array with object data was empty, probably object not found or access denied.', 1277974338);
}
if ($this->persistenceSession->hasIdentifier($objectData['identifier'])) {
return $this->persistenceSession->getObjectByIdentifier($objectData['identifier']);
} else {
$className = $objectData['classname'];
$classSchema = $this->reflectionService->getClassSchema($className);
$object = unserialize('O:' . strlen($className) . ':"' . $className . '":0:{};');
$this->persistenceSession->registerObject($object, $objectData['identifier']);
if ($classSchema->getModelType() === ClassSchema::MODELTYPE_ENTITY) {
$this->persistenceSession->registerReconstitutedEntity($object, $objectData);
}
if ($objectData['properties'] === []) {
if (!$classSchema->isLazyLoadableObject()) {
throw new PersistenceException('The object of type "' . $className . '" is not marked as lazy loadable.', 1268309017);
}
$persistenceManager = $this->persistenceManager;
$persistenceSession = $this->persistenceSession;
$dataMapper = $this;
$identifier = $objectData['identifier'];
$modelType = $classSchema->getModelType();
$object->Flow_Persistence_LazyLoadingObject_thawProperties = function ($object) use ($persistenceManager, $persistenceSession, $dataMapper, $identifier, $modelType) {
$objectData = $persistenceManager->getObjectDataByIdentifier($identifier);
$dataMapper->thawProperties($object, $identifier, $objectData);
if ($modelType === ClassSchema::MODELTYPE_ENTITY) {
$persistenceSession->registerReconstitutedEntity($object, $objectData);
}
};
} else {
$this->thawProperties($object, $objectData['identifier'], $objectData);
}
return $object;
}
} | [
"public",
"function",
"mapToObject",
"(",
"array",
"$",
"objectData",
")",
"{",
"if",
"(",
"$",
"objectData",
"===",
"[",
"]",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"InvalidObjectDataException",
"(",
"'The array with object data was empty, probably object not f... | Maps a single record into the object it represents and registers it as
reconstituted with the session.
@param array $objectData
@return object
@throws Exception\InvalidObjectDataException
@throws PersistenceException | [
"Maps",
"a",
"single",
"record",
"into",
"the",
"object",
"it",
"represents",
"and",
"registers",
"it",
"as",
"reconstituted",
"with",
"the",
"session",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Persistence/Generic/DataMapper.php#L107-L146 |
neos/flow-development-collection | Neos.Flow/Classes/Persistence/Generic/DataMapper.php | DataMapper.thawProperties | public function thawProperties($object, $identifier, array $objectData)
{
$classSchema = $this->reflectionService->getClassSchema($objectData['classname']);
foreach ($objectData['properties'] as $propertyName => $propertyData) {
if (!$classSchema->hasProperty($propertyName) ||
$classSchema->isPropertyTransient($propertyName)) {
continue;
}
$propertyValue = null;
if ($propertyData['value'] !== null) {
switch ($propertyData['type']) {
case 'integer':
$propertyValue = (int) $propertyData['value'];
break;
case 'float':
$propertyValue = (float) $propertyData['value'];
break;
case 'boolean':
$propertyValue = (boolean) $propertyData['value'];
break;
case 'string':
$propertyValue = (string) $propertyData['value'];
break;
case 'array':
$propertyValue = $this->mapArray($propertyData['value']);
break;
case 'Doctrine\Common\Collections\Collection':
case 'Doctrine\Common\Collections\ArrayCollection':
$propertyValue = new ArrayCollection($this->mapArray($propertyData['value']));
break;
case 'SplObjectStorage':
$propertyValue = $this->mapSplObjectStorage($propertyData['value'], $classSchema->isPropertyLazy($propertyName));
break;
case 'DateTime':
$propertyValue = $this->mapDateTime($propertyData['value']);
break;
default:
if ($propertyData['value'] === false) {
throw new UnknownObjectException('An expected object was not found by the backend. It was expected for ' . $objectData['classname'] . '::' . $propertyName, 1289509867);
}
$propertyValue = $this->mapToObject($propertyData['value']);
break;
}
} else {
switch ($propertyData['type']) {
case 'NULL':
break;
case 'array':
$propertyValue = $this->mapArray(null);
break;
case Collection::class:
case ArrayCollection::class:
$propertyValue = new ArrayCollection();
break;
case 'SplObjectStorage':
$propertyValue = $this->mapSplObjectStorage(null);
break;
}
}
ObjectAccess::setProperty($object, $propertyName, $propertyValue, true);
}
if (isset($objectData['metadata'])) {
$object->Flow_Persistence_Metadata = $objectData['metadata'];
}
ObjectAccess::setProperty($object, 'Persistence_Object_Identifier', $identifier, true);
} | php | public function thawProperties($object, $identifier, array $objectData)
{
$classSchema = $this->reflectionService->getClassSchema($objectData['classname']);
foreach ($objectData['properties'] as $propertyName => $propertyData) {
if (!$classSchema->hasProperty($propertyName) ||
$classSchema->isPropertyTransient($propertyName)) {
continue;
}
$propertyValue = null;
if ($propertyData['value'] !== null) {
switch ($propertyData['type']) {
case 'integer':
$propertyValue = (int) $propertyData['value'];
break;
case 'float':
$propertyValue = (float) $propertyData['value'];
break;
case 'boolean':
$propertyValue = (boolean) $propertyData['value'];
break;
case 'string':
$propertyValue = (string) $propertyData['value'];
break;
case 'array':
$propertyValue = $this->mapArray($propertyData['value']);
break;
case 'Doctrine\Common\Collections\Collection':
case 'Doctrine\Common\Collections\ArrayCollection':
$propertyValue = new ArrayCollection($this->mapArray($propertyData['value']));
break;
case 'SplObjectStorage':
$propertyValue = $this->mapSplObjectStorage($propertyData['value'], $classSchema->isPropertyLazy($propertyName));
break;
case 'DateTime':
$propertyValue = $this->mapDateTime($propertyData['value']);
break;
default:
if ($propertyData['value'] === false) {
throw new UnknownObjectException('An expected object was not found by the backend. It was expected for ' . $objectData['classname'] . '::' . $propertyName, 1289509867);
}
$propertyValue = $this->mapToObject($propertyData['value']);
break;
}
} else {
switch ($propertyData['type']) {
case 'NULL':
break;
case 'array':
$propertyValue = $this->mapArray(null);
break;
case Collection::class:
case ArrayCollection::class:
$propertyValue = new ArrayCollection();
break;
case 'SplObjectStorage':
$propertyValue = $this->mapSplObjectStorage(null);
break;
}
}
ObjectAccess::setProperty($object, $propertyName, $propertyValue, true);
}
if (isset($objectData['metadata'])) {
$object->Flow_Persistence_Metadata = $objectData['metadata'];
}
ObjectAccess::setProperty($object, 'Persistence_Object_Identifier', $identifier, true);
} | [
"public",
"function",
"thawProperties",
"(",
"$",
"object",
",",
"$",
"identifier",
",",
"array",
"$",
"objectData",
")",
"{",
"$",
"classSchema",
"=",
"$",
"this",
"->",
"reflectionService",
"->",
"getClassSchema",
"(",
"$",
"objectData",
"[",
"'classname'",
... | Sets the given properties on the object.
@param object $object The object to set properties on
@param string $identifier The identifier of the object
@param array $objectData
@return void
@throws UnknownObjectException | [
"Sets",
"the",
"given",
"properties",
"on",
"the",
"object",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Persistence/Generic/DataMapper.php#L157-L227 |
neos/flow-development-collection | Neos.Flow/Classes/Persistence/Generic/DataMapper.php | DataMapper.mapArray | protected function mapArray(array $arrayValues = null)
{
if ($arrayValues === null) {
return [];
}
$array = [];
foreach ($arrayValues as $arrayValue) {
if ($arrayValue['value'] === null) {
$array[$arrayValue['index']] = null;
} else {
switch ($arrayValue['type']) {
case 'integer':
$array[$arrayValue['index']] = (int) $arrayValue['value'];
break;
case 'float':
$array[$arrayValue['index']] = (float) $arrayValue['value'];
break;
case 'boolean':
$array[$arrayValue['index']] = (boolean) $arrayValue['value'];
break;
case 'string':
$array[$arrayValue['index']] = (string) $arrayValue['value'];
break;
case 'DateTime':
$array[$arrayValue['index']] = $this->mapDateTime($arrayValue['value']);
break;
case 'array':
$array[$arrayValue['index']] = $this->mapArray($arrayValue['value']);
break;
case 'SplObjectStorage':
$array[$arrayValue['index']] = $this->mapSplObjectStorage($arrayValue['value']);
break;
default:
$array[$arrayValue['index']] = $this->mapToObject($arrayValue['value']);
break;
}
}
}
return $array;
} | php | protected function mapArray(array $arrayValues = null)
{
if ($arrayValues === null) {
return [];
}
$array = [];
foreach ($arrayValues as $arrayValue) {
if ($arrayValue['value'] === null) {
$array[$arrayValue['index']] = null;
} else {
switch ($arrayValue['type']) {
case 'integer':
$array[$arrayValue['index']] = (int) $arrayValue['value'];
break;
case 'float':
$array[$arrayValue['index']] = (float) $arrayValue['value'];
break;
case 'boolean':
$array[$arrayValue['index']] = (boolean) $arrayValue['value'];
break;
case 'string':
$array[$arrayValue['index']] = (string) $arrayValue['value'];
break;
case 'DateTime':
$array[$arrayValue['index']] = $this->mapDateTime($arrayValue['value']);
break;
case 'array':
$array[$arrayValue['index']] = $this->mapArray($arrayValue['value']);
break;
case 'SplObjectStorage':
$array[$arrayValue['index']] = $this->mapSplObjectStorage($arrayValue['value']);
break;
default:
$array[$arrayValue['index']] = $this->mapToObject($arrayValue['value']);
break;
}
}
}
return $array;
} | [
"protected",
"function",
"mapArray",
"(",
"array",
"$",
"arrayValues",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"arrayValues",
"===",
"null",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"array",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"arrayValues",
... | Maps an array proxy structure back to a native PHP array
@param array $arrayValues
@return array | [
"Maps",
"an",
"array",
"proxy",
"structure",
"back",
"to",
"a",
"native",
"PHP",
"array"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Persistence/Generic/DataMapper.php#L249-L290 |
neos/flow-development-collection | Neos.Flow/Classes/Persistence/Generic/DataMapper.php | DataMapper.mapSplObjectStorage | protected function mapSplObjectStorage(array $objectStorageValues = null, $createLazySplObjectStorage = false)
{
if ($objectStorageValues === null) {
return new \SplObjectStorage();
}
if ($createLazySplObjectStorage) {
$objectIdentifiers = [];
foreach ($objectStorageValues as $arrayValue) {
if ($arrayValue['value'] !== null) {
$objectIdentifiers[] = $arrayValue['value']['identifier'];
}
}
return new LazySplObjectStorage($objectIdentifiers);
} else {
$objectStorage = new \SplObjectStorage();
foreach ($objectStorageValues as $arrayValue) {
if ($arrayValue['value'] !== null) {
$objectStorage->attach($this->mapToObject($arrayValue['value']));
}
}
return $objectStorage;
}
} | php | protected function mapSplObjectStorage(array $objectStorageValues = null, $createLazySplObjectStorage = false)
{
if ($objectStorageValues === null) {
return new \SplObjectStorage();
}
if ($createLazySplObjectStorage) {
$objectIdentifiers = [];
foreach ($objectStorageValues as $arrayValue) {
if ($arrayValue['value'] !== null) {
$objectIdentifiers[] = $arrayValue['value']['identifier'];
}
}
return new LazySplObjectStorage($objectIdentifiers);
} else {
$objectStorage = new \SplObjectStorage();
foreach ($objectStorageValues as $arrayValue) {
if ($arrayValue['value'] !== null) {
$objectStorage->attach($this->mapToObject($arrayValue['value']));
}
}
return $objectStorage;
}
} | [
"protected",
"function",
"mapSplObjectStorage",
"(",
"array",
"$",
"objectStorageValues",
"=",
"null",
",",
"$",
"createLazySplObjectStorage",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"objectStorageValues",
"===",
"null",
")",
"{",
"return",
"new",
"\\",
"SplObje... | Maps an SplObjectStorage proxy record back to an SplObjectStorage
@param array $objectStorageValues
@param boolean $createLazySplObjectStorage
@return \SplObjectStorage
@todo restore information attached to objects? | [
"Maps",
"an",
"SplObjectStorage",
"proxy",
"record",
"back",
"to",
"an",
"SplObjectStorage"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Persistence/Generic/DataMapper.php#L300-L324 |
neos/flow-development-collection | Neos.Utility.ObjectHandling/Classes/ObjectAccess.php | ObjectAccess.getProperty | public static function getProperty($subject, $propertyName, bool $forceDirectAccess = false)
{
if (!is_object($subject) && !is_array($subject)) {
throw new \InvalidArgumentException('$subject must be an object or array, ' . gettype($subject) . ' given.', 1237301367);
}
if (!is_string($propertyName) && !is_int($propertyName)) {
throw new \InvalidArgumentException('Given property name/index is not of type string or integer.', 1231178303);
}
$propertyExists = false;
$propertyValue = self::getPropertyInternal($subject, $propertyName, $forceDirectAccess, $propertyExists);
if ($propertyExists === true) {
return $propertyValue;
}
throw new PropertyNotAccessibleException('The property "' . $propertyName . '" on the subject was not accessible.', 1263391473);
} | php | public static function getProperty($subject, $propertyName, bool $forceDirectAccess = false)
{
if (!is_object($subject) && !is_array($subject)) {
throw new \InvalidArgumentException('$subject must be an object or array, ' . gettype($subject) . ' given.', 1237301367);
}
if (!is_string($propertyName) && !is_int($propertyName)) {
throw new \InvalidArgumentException('Given property name/index is not of type string or integer.', 1231178303);
}
$propertyExists = false;
$propertyValue = self::getPropertyInternal($subject, $propertyName, $forceDirectAccess, $propertyExists);
if ($propertyExists === true) {
return $propertyValue;
}
throw new PropertyNotAccessibleException('The property "' . $propertyName . '" on the subject was not accessible.', 1263391473);
} | [
"public",
"static",
"function",
"getProperty",
"(",
"$",
"subject",
",",
"$",
"propertyName",
",",
"bool",
"$",
"forceDirectAccess",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"is_object",
"(",
"$",
"subject",
")",
"&&",
"!",
"is_array",
"(",
"$",
"subject"... | Get a property of a given object or array.
Tries to get the property the following ways:
- if the target is an array, and has this property, we return it.
- if super cow powers should be used, fetch value through reflection
- if public getter method exists, call it.
- if the target object is an instance of ArrayAccess, it gets the property
on it if it exists.
- if public property exists, return the value of it.
- else, throw exception
@param mixed $subject Object or array to get the property from
@param string|integer $propertyName Name or index of the property to retrieve
@param boolean $forceDirectAccess Directly access property using reflection(!)
@return mixed Value of the property
@throws \InvalidArgumentException in case $subject was not an object or $propertyName was not a string
@throws PropertyNotAccessibleException if the property was not accessible | [
"Get",
"a",
"property",
"of",
"a",
"given",
"object",
"or",
"array",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Utility.ObjectHandling/Classes/ObjectAccess.php#L67-L82 |
neos/flow-development-collection | Neos.Utility.ObjectHandling/Classes/ObjectAccess.php | ObjectAccess.getPropertyInternal | protected static function getPropertyInternal($subject, string $propertyName, bool $forceDirectAccess, bool &$propertyExists)
{
if ($subject === null) {
return null;
}
if (is_array($subject)) {
$propertyExists = array_key_exists($propertyName, $subject);
return $propertyExists ? $subject[$propertyName] : null;
}
if (!is_object($subject)) {
return null;
}
$propertyExists = true;
$className = TypeHandling::getTypeForValue($subject);
if ($forceDirectAccess === true) {
if (property_exists($className, $propertyName)) {
$propertyReflection = new \ReflectionProperty($className, $propertyName);
$propertyReflection->setAccessible(true);
return $propertyReflection->getValue($subject);
}
if (property_exists($subject, $propertyName)) {
return $subject->$propertyName;
}
throw new PropertyNotAccessibleException('The property "' . $propertyName . '" on the subject does not exist.', 1302855001);
}
if ($subject instanceof \stdClass) {
if (array_key_exists($propertyName, get_object_vars($subject))) {
return $subject->$propertyName;
}
$propertyExists = false;
return null;
}
$cacheIdentifier = $className . '|' . $propertyName;
self::initializePropertyGetterCache($cacheIdentifier, $subject, $propertyName);
if (isset(self::$propertyGetterCache[$cacheIdentifier]['accessorMethod'])) {
$method = self::$propertyGetterCache[$cacheIdentifier]['accessorMethod'];
return $subject->$method();
}
if (isset(self::$propertyGetterCache[$cacheIdentifier]['publicProperty'])) {
return $subject->$propertyName;
}
if (($subject instanceof \ArrayAccess) && !($subject instanceof \SplObjectStorage) && $subject->offsetExists($propertyName)) {
return $subject->offsetGet($propertyName);
}
$propertyExists = false;
return null;
} | php | protected static function getPropertyInternal($subject, string $propertyName, bool $forceDirectAccess, bool &$propertyExists)
{
if ($subject === null) {
return null;
}
if (is_array($subject)) {
$propertyExists = array_key_exists($propertyName, $subject);
return $propertyExists ? $subject[$propertyName] : null;
}
if (!is_object($subject)) {
return null;
}
$propertyExists = true;
$className = TypeHandling::getTypeForValue($subject);
if ($forceDirectAccess === true) {
if (property_exists($className, $propertyName)) {
$propertyReflection = new \ReflectionProperty($className, $propertyName);
$propertyReflection->setAccessible(true);
return $propertyReflection->getValue($subject);
}
if (property_exists($subject, $propertyName)) {
return $subject->$propertyName;
}
throw new PropertyNotAccessibleException('The property "' . $propertyName . '" on the subject does not exist.', 1302855001);
}
if ($subject instanceof \stdClass) {
if (array_key_exists($propertyName, get_object_vars($subject))) {
return $subject->$propertyName;
}
$propertyExists = false;
return null;
}
$cacheIdentifier = $className . '|' . $propertyName;
self::initializePropertyGetterCache($cacheIdentifier, $subject, $propertyName);
if (isset(self::$propertyGetterCache[$cacheIdentifier]['accessorMethod'])) {
$method = self::$propertyGetterCache[$cacheIdentifier]['accessorMethod'];
return $subject->$method();
}
if (isset(self::$propertyGetterCache[$cacheIdentifier]['publicProperty'])) {
return $subject->$propertyName;
}
if (($subject instanceof \ArrayAccess) && !($subject instanceof \SplObjectStorage) && $subject->offsetExists($propertyName)) {
return $subject->offsetGet($propertyName);
}
$propertyExists = false;
return null;
} | [
"protected",
"static",
"function",
"getPropertyInternal",
"(",
"$",
"subject",
",",
"string",
"$",
"propertyName",
",",
"bool",
"$",
"forceDirectAccess",
",",
"bool",
"&",
"$",
"propertyExists",
")",
"{",
"if",
"(",
"$",
"subject",
"===",
"null",
")",
"{",
... | Gets a property of a given object or array.
This is an internal method that does only limited type checking for performance reasons.
If you can't make sure that $subject is either of type array or object and $propertyName
of type string you should use getProperty() instead.
@param mixed $subject Object or array to get the property from
@param string $propertyName name of the property to retrieve
@param boolean $forceDirectAccess directly access property using reflection(!)
@param boolean $propertyExists (by reference) will be set to true if the specified property exists and is gettable
@return mixed Value of the property
@throws PropertyNotAccessibleException
@see getProperty() | [
"Gets",
"a",
"property",
"of",
"a",
"given",
"object",
"or",
"array",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Utility.ObjectHandling/Classes/ObjectAccess.php#L100-L153 |
neos/flow-development-collection | Neos.Utility.ObjectHandling/Classes/ObjectAccess.php | ObjectAccess.getPropertyPath | public static function getPropertyPath($subject, string $propertyPath = null)
{
// TODO: This default value handling is only in place for b/c to have this method accept nulls.
// It can be removed with Flow 5.0 and other breaking typehint changes.
if ($propertyPath === null) {
return null;
}
$propertyPathSegments = explode('.', $propertyPath);
foreach ($propertyPathSegments as $pathSegment) {
$propertyExists = false;
$propertyValue = self::getPropertyInternal($subject, $pathSegment, false, $propertyExists);
if ($propertyExists !== true && (is_array($subject) || $subject instanceof \ArrayAccess) && isset($subject[$pathSegment])) {
$subject = $subject[$pathSegment];
} else {
$subject = $propertyValue;
}
}
return $subject;
} | php | public static function getPropertyPath($subject, string $propertyPath = null)
{
// TODO: This default value handling is only in place for b/c to have this method accept nulls.
// It can be removed with Flow 5.0 and other breaking typehint changes.
if ($propertyPath === null) {
return null;
}
$propertyPathSegments = explode('.', $propertyPath);
foreach ($propertyPathSegments as $pathSegment) {
$propertyExists = false;
$propertyValue = self::getPropertyInternal($subject, $pathSegment, false, $propertyExists);
if ($propertyExists !== true && (is_array($subject) || $subject instanceof \ArrayAccess) && isset($subject[$pathSegment])) {
$subject = $subject[$pathSegment];
} else {
$subject = $propertyValue;
}
}
return $subject;
} | [
"public",
"static",
"function",
"getPropertyPath",
"(",
"$",
"subject",
",",
"string",
"$",
"propertyPath",
"=",
"null",
")",
"{",
"// TODO: This default value handling is only in place for b/c to have this method accept nulls.",
"// It can be removed with Flow 5.0 and other br... | Gets a property path from a given object or array.
If propertyPath is "bla.blubb", then we first call getProperty($object, 'bla'),
and on the resulting object we call getProperty(..., 'blubb').
For arrays the keys are checked likewise.
@param mixed $subject An object or array
@param string $propertyPath
@return mixed Value of the property | [
"Gets",
"a",
"property",
"path",
"from",
"a",
"given",
"object",
"or",
"array",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Utility.ObjectHandling/Classes/ObjectAccess.php#L195-L213 |
neos/flow-development-collection | Neos.Utility.ObjectHandling/Classes/ObjectAccess.php | ObjectAccess.setProperty | public static function setProperty(&$subject, $propertyName, $propertyValue, bool $forceDirectAccess = false): bool
{
if (is_array($subject)) {
$subject[$propertyName] = $propertyValue;
return true;
}
if (!is_object($subject)) {
throw new \InvalidArgumentException('subject must be an object or array, ' . gettype($subject) . ' given.', 1237301368);
}
if (!is_string($propertyName) && !is_int($propertyName)) {
throw new \InvalidArgumentException('Given property name/index is not of type string or integer.', 1231178878);
}
if ($forceDirectAccess === true) {
$className = TypeHandling::getTypeForValue($subject);
if (property_exists($className, $propertyName)) {
$propertyReflection = new \ReflectionProperty($className, $propertyName);
$propertyReflection->setAccessible(true);
$propertyReflection->setValue($subject, $propertyValue);
} else {
$subject->$propertyName = $propertyValue;
}
} elseif (is_callable([$subject, $setterMethodName = self::buildSetterMethodName($propertyName)])) {
$subject->$setterMethodName($propertyValue);
} elseif ($subject instanceof \ArrayAccess) {
$subject[$propertyName] = $propertyValue;
} elseif (array_key_exists($propertyName, get_object_vars($subject))) {
$subject->$propertyName = $propertyValue;
} else {
return false;
}
return true;
} | php | public static function setProperty(&$subject, $propertyName, $propertyValue, bool $forceDirectAccess = false): bool
{
if (is_array($subject)) {
$subject[$propertyName] = $propertyValue;
return true;
}
if (!is_object($subject)) {
throw new \InvalidArgumentException('subject must be an object or array, ' . gettype($subject) . ' given.', 1237301368);
}
if (!is_string($propertyName) && !is_int($propertyName)) {
throw new \InvalidArgumentException('Given property name/index is not of type string or integer.', 1231178878);
}
if ($forceDirectAccess === true) {
$className = TypeHandling::getTypeForValue($subject);
if (property_exists($className, $propertyName)) {
$propertyReflection = new \ReflectionProperty($className, $propertyName);
$propertyReflection->setAccessible(true);
$propertyReflection->setValue($subject, $propertyValue);
} else {
$subject->$propertyName = $propertyValue;
}
} elseif (is_callable([$subject, $setterMethodName = self::buildSetterMethodName($propertyName)])) {
$subject->$setterMethodName($propertyValue);
} elseif ($subject instanceof \ArrayAccess) {
$subject[$propertyName] = $propertyValue;
} elseif (array_key_exists($propertyName, get_object_vars($subject))) {
$subject->$propertyName = $propertyValue;
} else {
return false;
}
return true;
} | [
"public",
"static",
"function",
"setProperty",
"(",
"&",
"$",
"subject",
",",
"$",
"propertyName",
",",
"$",
"propertyValue",
",",
"bool",
"$",
"forceDirectAccess",
"=",
"false",
")",
":",
"bool",
"{",
"if",
"(",
"is_array",
"(",
"$",
"subject",
")",
")"... | Set a property for a given object.
Tries to set the property the following ways:
- if target is an array, set value
- if super cow powers should be used, set value through reflection
- if public setter method exists, call it.
- if public property exists, set it directly.
- if the target object is an instance of ArrayAccess, it sets the property
on it without checking if it existed.
- else, return false
@param mixed $subject The target object or array
@param string|integer $propertyName Name or index of the property to set
@param mixed $propertyValue Value of the property
@param boolean $forceDirectAccess directly access property using reflection(!)
@return boolean true if the property could be set, false otherwise
@throws \InvalidArgumentException in case $object was not an object or $propertyName was not a string | [
"Set",
"a",
"property",
"for",
"a",
"given",
"object",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Utility.ObjectHandling/Classes/ObjectAccess.php#L235-L268 |
neos/flow-development-collection | Neos.Utility.ObjectHandling/Classes/ObjectAccess.php | ObjectAccess.getGettablePropertyNames | public static function getGettablePropertyNames($object): array
{
if (!is_object($object)) {
throw new \InvalidArgumentException('$object must be an object, ' . gettype($object) . ' given.', 1237301369);
}
if ($object instanceof \stdClass) {
$declaredPropertyNames = array_keys(get_object_vars($object));
$className = 'stdClass';
unset(self::$gettablePropertyNamesCache[$className]);
} else {
$className = TypeHandling::getTypeForValue($object);
$declaredPropertyNames = array_keys(get_class_vars($className));
}
if (!isset(self::$gettablePropertyNamesCache[$className])) {
foreach (get_class_methods($object) as $methodName) {
if (is_callable([$object, $methodName])) {
$methodNameLength = strlen($methodName);
if ($methodNameLength > 2 && substr($methodName, 0, 2) === 'is') {
$declaredPropertyNames[] = lcfirst(substr($methodName, 2));
} elseif ($methodNameLength > 3 && (($methodNamePrefix = substr($methodName, 0, 3)) === 'get' || $methodNamePrefix === 'has')) {
$declaredPropertyNames[] = lcfirst(substr($methodName, 3));
}
}
}
$propertyNames = array_unique($declaredPropertyNames);
sort($propertyNames);
self::$gettablePropertyNamesCache[$className] = $propertyNames;
}
return self::$gettablePropertyNamesCache[$className];
} | php | public static function getGettablePropertyNames($object): array
{
if (!is_object($object)) {
throw new \InvalidArgumentException('$object must be an object, ' . gettype($object) . ' given.', 1237301369);
}
if ($object instanceof \stdClass) {
$declaredPropertyNames = array_keys(get_object_vars($object));
$className = 'stdClass';
unset(self::$gettablePropertyNamesCache[$className]);
} else {
$className = TypeHandling::getTypeForValue($object);
$declaredPropertyNames = array_keys(get_class_vars($className));
}
if (!isset(self::$gettablePropertyNamesCache[$className])) {
foreach (get_class_methods($object) as $methodName) {
if (is_callable([$object, $methodName])) {
$methodNameLength = strlen($methodName);
if ($methodNameLength > 2 && substr($methodName, 0, 2) === 'is') {
$declaredPropertyNames[] = lcfirst(substr($methodName, 2));
} elseif ($methodNameLength > 3 && (($methodNamePrefix = substr($methodName, 0, 3)) === 'get' || $methodNamePrefix === 'has')) {
$declaredPropertyNames[] = lcfirst(substr($methodName, 3));
}
}
}
$propertyNames = array_unique($declaredPropertyNames);
sort($propertyNames);
self::$gettablePropertyNamesCache[$className] = $propertyNames;
}
return self::$gettablePropertyNamesCache[$className];
} | [
"public",
"static",
"function",
"getGettablePropertyNames",
"(",
"$",
"object",
")",
":",
"array",
"{",
"if",
"(",
"!",
"is_object",
"(",
"$",
"object",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'$object must be an object, '",
".",
... | Returns an array of properties which can be get with the getProperty()
method.
Includes the following properties:
- which can be get through a public getter method.
- public properties which can be directly get.
@param object $object Object to receive property names for
@return array Array of all gettable property names
@throws \InvalidArgumentException | [
"Returns",
"an",
"array",
"of",
"properties",
"which",
"can",
"be",
"get",
"with",
"the",
"getProperty",
"()",
"method",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Utility.ObjectHandling/Classes/ObjectAccess.php#L283-L314 |
neos/flow-development-collection | Neos.Utility.ObjectHandling/Classes/ObjectAccess.php | ObjectAccess.getSettablePropertyNames | public static function getSettablePropertyNames($object): array
{
if (!is_object($object)) {
throw new \InvalidArgumentException('$object must be an object, ' . gettype($object) . ' given.', 1264022994);
}
if ($object instanceof \stdClass) {
$declaredPropertyNames = array_keys(get_object_vars($object));
} else {
$className = TypeHandling::getTypeForValue($object);
$declaredPropertyNames = array_keys(get_class_vars($className));
}
foreach (get_class_methods($object) as $methodName) {
if (substr($methodName, 0, 3) === 'set' && strlen($methodName) > 3 && is_callable([$object, $methodName])) {
$declaredPropertyNames[] = lcfirst(substr($methodName, 3));
}
}
$propertyNames = array_unique($declaredPropertyNames);
sort($propertyNames);
return $propertyNames;
} | php | public static function getSettablePropertyNames($object): array
{
if (!is_object($object)) {
throw new \InvalidArgumentException('$object must be an object, ' . gettype($object) . ' given.', 1264022994);
}
if ($object instanceof \stdClass) {
$declaredPropertyNames = array_keys(get_object_vars($object));
} else {
$className = TypeHandling::getTypeForValue($object);
$declaredPropertyNames = array_keys(get_class_vars($className));
}
foreach (get_class_methods($object) as $methodName) {
if (substr($methodName, 0, 3) === 'set' && strlen($methodName) > 3 && is_callable([$object, $methodName])) {
$declaredPropertyNames[] = lcfirst(substr($methodName, 3));
}
}
$propertyNames = array_unique($declaredPropertyNames);
sort($propertyNames);
return $propertyNames;
} | [
"public",
"static",
"function",
"getSettablePropertyNames",
"(",
"$",
"object",
")",
":",
"array",
"{",
"if",
"(",
"!",
"is_object",
"(",
"$",
"object",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'$object must be an object, '",
".",
... | Returns an array of properties which can be set with the setProperty()
method.
Includes the following properties:
- which can be set through a public setter method.
- public properties which can be directly set.
@param object $object Object to receive property names for
@return array Array of all settable property names
@throws \InvalidArgumentException | [
"Returns",
"an",
"array",
"of",
"properties",
"which",
"can",
"be",
"set",
"with",
"the",
"setProperty",
"()",
"method",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Utility.ObjectHandling/Classes/ObjectAccess.php#L329-L350 |
neos/flow-development-collection | Neos.Utility.ObjectHandling/Classes/ObjectAccess.php | ObjectAccess.isPropertySettable | public static function isPropertySettable($object, string $propertyName): bool
{
if (!is_object($object)) {
throw new \InvalidArgumentException('$object must be an object, ' . gettype($object) . ' given.', 1259828920);
}
$className = TypeHandling::getTypeForValue($object);
if (($object instanceof \stdClass && array_key_exists($propertyName, get_object_vars($object))) || array_key_exists($propertyName, get_class_vars($className))) {
return true;
}
return is_callable([$object, self::buildSetterMethodName($propertyName)]);
} | php | public static function isPropertySettable($object, string $propertyName): bool
{
if (!is_object($object)) {
throw new \InvalidArgumentException('$object must be an object, ' . gettype($object) . ' given.', 1259828920);
}
$className = TypeHandling::getTypeForValue($object);
if (($object instanceof \stdClass && array_key_exists($propertyName, get_object_vars($object))) || array_key_exists($propertyName, get_class_vars($className))) {
return true;
}
return is_callable([$object, self::buildSetterMethodName($propertyName)]);
} | [
"public",
"static",
"function",
"isPropertySettable",
"(",
"$",
"object",
",",
"string",
"$",
"propertyName",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"is_object",
"(",
"$",
"object",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'$o... | Tells if the value of the specified property can be set by this Object Accessor.
@param object $object Object containing the property
@param string $propertyName Name of the property to check
@return boolean
@throws \InvalidArgumentException | [
"Tells",
"if",
"the",
"value",
"of",
"the",
"specified",
"property",
"can",
"be",
"set",
"by",
"this",
"Object",
"Accessor",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Utility.ObjectHandling/Classes/ObjectAccess.php#L360-L371 |
neos/flow-development-collection | Neos.Utility.ObjectHandling/Classes/ObjectAccess.php | ObjectAccess.isPropertyGettable | public static function isPropertyGettable($object, string $propertyName): bool
{
if (!is_object($object)) {
throw new \InvalidArgumentException('$object must be an object, ' . gettype($object) . ' given.', 1259828921);
}
if (($object instanceof \ArrayAccess && $object->offsetExists($propertyName)) || ($object instanceof \stdClass && array_key_exists($propertyName, get_object_vars($object)))) {
return true;
}
$uppercasePropertyName = ucfirst($propertyName);
if (is_callable([$object, 'get' . $uppercasePropertyName]) || is_callable([$object, 'is' . $uppercasePropertyName]) || is_callable([$object, 'has' . $uppercasePropertyName])) {
return true;
}
$className = TypeHandling::getTypeForValue($object);
return array_key_exists($propertyName, get_class_vars($className));
} | php | public static function isPropertyGettable($object, string $propertyName): bool
{
if (!is_object($object)) {
throw new \InvalidArgumentException('$object must be an object, ' . gettype($object) . ' given.', 1259828921);
}
if (($object instanceof \ArrayAccess && $object->offsetExists($propertyName)) || ($object instanceof \stdClass && array_key_exists($propertyName, get_object_vars($object)))) {
return true;
}
$uppercasePropertyName = ucfirst($propertyName);
if (is_callable([$object, 'get' . $uppercasePropertyName]) || is_callable([$object, 'is' . $uppercasePropertyName]) || is_callable([$object, 'has' . $uppercasePropertyName])) {
return true;
}
$className = TypeHandling::getTypeForValue($object);
return array_key_exists($propertyName, get_class_vars($className));
} | [
"public",
"static",
"function",
"isPropertyGettable",
"(",
"$",
"object",
",",
"string",
"$",
"propertyName",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"is_object",
"(",
"$",
"object",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'$o... | Tells if the value of the specified property can be retrieved by this Object Accessor.
@param object $object Object containing the property
@param string $propertyName Name of the property to check
@return boolean
@throws \InvalidArgumentException | [
"Tells",
"if",
"the",
"value",
"of",
"the",
"specified",
"property",
"can",
"be",
"retrieved",
"by",
"this",
"Object",
"Accessor",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Utility.ObjectHandling/Classes/ObjectAccess.php#L381-L395 |
neos/flow-development-collection | Neos.Utility.ObjectHandling/Classes/ObjectAccess.php | ObjectAccess.getGettableProperties | public static function getGettableProperties($object): array
{
if (!is_object($object)) {
throw new \InvalidArgumentException('$object must be an object, ' . gettype($object) . ' given.', 1237301370);
}
$properties = [];
foreach (self::getGettablePropertyNames($object) as $propertyName) {
$propertyExists = false;
$propertyValue = self::getPropertyInternal($object, $propertyName, false, $propertyExists);
if ($propertyExists === true) {
$properties[$propertyName] = $propertyValue;
}
}
return $properties;
} | php | public static function getGettableProperties($object): array
{
if (!is_object($object)) {
throw new \InvalidArgumentException('$object must be an object, ' . gettype($object) . ' given.', 1237301370);
}
$properties = [];
foreach (self::getGettablePropertyNames($object) as $propertyName) {
$propertyExists = false;
$propertyValue = self::getPropertyInternal($object, $propertyName, false, $propertyExists);
if ($propertyExists === true) {
$properties[$propertyName] = $propertyValue;
}
}
return $properties;
} | [
"public",
"static",
"function",
"getGettableProperties",
"(",
"$",
"object",
")",
":",
"array",
"{",
"if",
"(",
"!",
"is_object",
"(",
"$",
"object",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'$object must be an object, '",
".",
"g... | Get all properties (names and their current values) of the current
$object that are accessible through this class.
@param object $object Object to get all properties from.
@return array Associative array of all properties.
@throws \InvalidArgumentException
@todo What to do with ArrayAccess | [
"Get",
"all",
"properties",
"(",
"names",
"and",
"their",
"current",
"values",
")",
"of",
"the",
"current",
"$object",
"that",
"are",
"accessible",
"through",
"this",
"class",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Utility.ObjectHandling/Classes/ObjectAccess.php#L406-L420 |
neos/flow-development-collection | Neos.Utility.ObjectHandling/Classes/ObjectAccess.php | ObjectAccess.instantiateClass | public static function instantiateClass($className, $arguments)
{
switch (count($arguments)) {
case 0:
$object = new $className();
break;
case 1:
$object = new $className($arguments[0]);
break;
case 2:
$object = new $className($arguments[0], $arguments[1]);
break;
case 3:
$object = new $className($arguments[0], $arguments[1], $arguments[2]);
break;
case 4:
$object = new $className($arguments[0], $arguments[1], $arguments[2], $arguments[3]);
break;
case 5:
$object = new $className($arguments[0], $arguments[1], $arguments[2], $arguments[3], $arguments[4]);
break;
case 6:
$object = new $className($arguments[0], $arguments[1], $arguments[2], $arguments[3], $arguments[4], $arguments[5]);
break;
default:
$class = new \ReflectionClass($className);
$object = $class->newInstanceArgs($arguments);
}
return $object;
} | php | public static function instantiateClass($className, $arguments)
{
switch (count($arguments)) {
case 0:
$object = new $className();
break;
case 1:
$object = new $className($arguments[0]);
break;
case 2:
$object = new $className($arguments[0], $arguments[1]);
break;
case 3:
$object = new $className($arguments[0], $arguments[1], $arguments[2]);
break;
case 4:
$object = new $className($arguments[0], $arguments[1], $arguments[2], $arguments[3]);
break;
case 5:
$object = new $className($arguments[0], $arguments[1], $arguments[2], $arguments[3], $arguments[4]);
break;
case 6:
$object = new $className($arguments[0], $arguments[1], $arguments[2], $arguments[3], $arguments[4], $arguments[5]);
break;
default:
$class = new \ReflectionClass($className);
$object = $class->newInstanceArgs($arguments);
}
return $object;
} | [
"public",
"static",
"function",
"instantiateClass",
"(",
"$",
"className",
",",
"$",
"arguments",
")",
"{",
"switch",
"(",
"count",
"(",
"$",
"arguments",
")",
")",
"{",
"case",
"0",
":",
"$",
"object",
"=",
"new",
"$",
"className",
"(",
")",
";",
"b... | Instantiates the class named `$className` using the `$arguments` as constructor
arguments (in array order).
For less than 7 arguments `new` is used, for more a `ReflectionClass` is created
and `newInstanceArgs` is used.
Note: this should be used sparingly, just calling `new` yourself or using Dependency
Injection are most probably better alternatives.
@param string $className
@param array $arguments
@return object | [
"Instantiates",
"the",
"class",
"named",
"$className",
"using",
"the",
"$arguments",
"as",
"constructor",
"arguments",
"(",
"in",
"array",
"order",
")",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Utility.ObjectHandling/Classes/ObjectAccess.php#L448-L478 |
neos/flow-development-collection | Neos.Flow/Classes/Validation/Validator/StringLengthValidator.php | StringLengthValidator.isValid | protected function isValid($value)
{
if ($this->options['maximum'] < $this->options['minimum']) {
throw new InvalidValidationOptionsException('The \'maximum\' is less than the \'minimum\' in the StringLengthValidator.', 1238107096);
}
if (is_object($value)) {
if (!method_exists($value, '__toString')) {
$this->addError('The given object could not be converted to a string.', 1238110957);
return;
}
} elseif (!is_string($value)) {
$this->addError('The given value was not a valid string.', 1269883975);
return;
}
$stringLength = Unicode\Functions::strlen($value);
$isValid = true;
if ($stringLength < $this->options['minimum']) {
$isValid = false;
}
if ($stringLength > $this->options['maximum']) {
$isValid = false;
}
if ($isValid === false) {
if ($this->options['minimum'] > 0 && $this->options['maximum'] < PHP_INT_MAX) {
$this->addError('The length of this text must be between %1$d and %2$d characters.', 1238108067, [$this->options['minimum'], $this->options['maximum']]);
} elseif ($this->options['minimum'] > 0) {
$this->addError('This field must contain at least %1$d characters.', 1238108068, [$this->options['minimum']]);
} else {
$this->addError('This text may not exceed %1$d characters.', 1238108069, [$this->options['maximum']]);
}
}
} | php | protected function isValid($value)
{
if ($this->options['maximum'] < $this->options['minimum']) {
throw new InvalidValidationOptionsException('The \'maximum\' is less than the \'minimum\' in the StringLengthValidator.', 1238107096);
}
if (is_object($value)) {
if (!method_exists($value, '__toString')) {
$this->addError('The given object could not be converted to a string.', 1238110957);
return;
}
} elseif (!is_string($value)) {
$this->addError('The given value was not a valid string.', 1269883975);
return;
}
$stringLength = Unicode\Functions::strlen($value);
$isValid = true;
if ($stringLength < $this->options['minimum']) {
$isValid = false;
}
if ($stringLength > $this->options['maximum']) {
$isValid = false;
}
if ($isValid === false) {
if ($this->options['minimum'] > 0 && $this->options['maximum'] < PHP_INT_MAX) {
$this->addError('The length of this text must be between %1$d and %2$d characters.', 1238108067, [$this->options['minimum'], $this->options['maximum']]);
} elseif ($this->options['minimum'] > 0) {
$this->addError('This field must contain at least %1$d characters.', 1238108068, [$this->options['minimum']]);
} else {
$this->addError('This text may not exceed %1$d characters.', 1238108069, [$this->options['maximum']]);
}
}
} | [
"protected",
"function",
"isValid",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"options",
"[",
"'maximum'",
"]",
"<",
"$",
"this",
"->",
"options",
"[",
"'minimum'",
"]",
")",
"{",
"throw",
"new",
"InvalidValidationOptionsException",
"(",
... | Checks if the given value is a valid string (or can be cast to a string
if an object is given) and its length is between minimum and maximum
specified in the validation options.
@param mixed $value The value that should be validated
@return void
@throws InvalidValidationOptionsException
@api | [
"Checks",
"if",
"the",
"given",
"value",
"is",
"a",
"valid",
"string",
"(",
"or",
"can",
"be",
"cast",
"to",
"a",
"string",
"if",
"an",
"object",
"is",
"given",
")",
"and",
"its",
"length",
"is",
"between",
"minimum",
"and",
"maximum",
"specified",
"in... | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Validation/Validator/StringLengthValidator.php#L42-L76 |
neos/flow-development-collection | Neos.Eel/Classes/FlowQuery/Operations/GetOperation.php | GetOperation.evaluate | public function evaluate(FlowQuery $flowQuery, array $arguments)
{
$context = $flowQuery->getContext();
if (isset($arguments[0])) {
$index = $arguments[0];
if (isset($context[$index])) {
return $context[$index];
} else {
return null;
}
} else {
return $context;
}
} | php | public function evaluate(FlowQuery $flowQuery, array $arguments)
{
$context = $flowQuery->getContext();
if (isset($arguments[0])) {
$index = $arguments[0];
if (isset($context[$index])) {
return $context[$index];
} else {
return null;
}
} else {
return $context;
}
} | [
"public",
"function",
"evaluate",
"(",
"FlowQuery",
"$",
"flowQuery",
",",
"array",
"$",
"arguments",
")",
"{",
"$",
"context",
"=",
"$",
"flowQuery",
"->",
"getContext",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"arguments",
"[",
"0",
"]",
")",
"... | {@inheritdoc}
@param FlowQuery $flowQuery the FlowQuery object
@param array $arguments the context index to fetch from
@return mixed | [
"{",
"@inheritdoc",
"}"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Eel/Classes/FlowQuery/Operations/GetOperation.php#L50-L63 |
neos/flow-development-collection | Neos.Flow/Classes/I18n/Cldr/CldrModel.php | CldrModel.initializeObject | public function initializeObject()
{
if ($this->cache->has($this->cacheKey)) {
$this->parsedData = $this->cache->get($this->cacheKey);
} else {
$this->parsedData = $this->parseFiles($this->sourcePaths);
$this->parsedData = $this->resolveAliases($this->parsedData, '');
$this->cache->set($this->cacheKey, $this->parsedData);
}
} | php | public function initializeObject()
{
if ($this->cache->has($this->cacheKey)) {
$this->parsedData = $this->cache->get($this->cacheKey);
} else {
$this->parsedData = $this->parseFiles($this->sourcePaths);
$this->parsedData = $this->resolveAliases($this->parsedData, '');
$this->cache->set($this->cacheKey, $this->parsedData);
}
} | [
"public",
"function",
"initializeObject",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"cache",
"->",
"has",
"(",
"$",
"this",
"->",
"cacheKey",
")",
")",
"{",
"$",
"this",
"->",
"parsedData",
"=",
"$",
"this",
"->",
"cache",
"->",
"get",
"(",
"$",... | When it's called, CLDR file is parsed or cache is loaded, if available.
@return void | [
"When",
"it",
"s",
"called",
"CLDR",
"file",
"is",
"parsed",
"or",
"cache",
"is",
"loaded",
"if",
"available",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/I18n/Cldr/CldrModel.php#L104-L113 |
neos/flow-development-collection | Neos.Flow/Classes/I18n/Cldr/CldrModel.php | CldrModel.getRawData | public function getRawData($path)
{
if ($path === '/') {
return $this->parsedData;
}
$pathElements = explode('/', trim($path, '/'));
$data = $this->parsedData;
foreach ($pathElements as $key) {
if (isset($data[$key])) {
$data = $data[$key];
} else {
return false;
}
}
return $data;
} | php | public function getRawData($path)
{
if ($path === '/') {
return $this->parsedData;
}
$pathElements = explode('/', trim($path, '/'));
$data = $this->parsedData;
foreach ($pathElements as $key) {
if (isset($data[$key])) {
$data = $data[$key];
} else {
return false;
}
}
return $data;
} | [
"public",
"function",
"getRawData",
"(",
"$",
"path",
")",
"{",
"if",
"(",
"$",
"path",
"===",
"'/'",
")",
"{",
"return",
"$",
"this",
"->",
"parsedData",
";",
"}",
"$",
"pathElements",
"=",
"explode",
"(",
"'/'",
",",
"trim",
"(",
"$",
"path",
","... | Returns multi-dimensional array representing desired node and it's children,
or a string value if the path points to a leaf.
Syntax for paths is very simple. It's a group of array indices joined
with a slash. It tries to emulate XPath query syntax to some extent.
Examples:
plurals/pluralRules
dates/calendars/calendar[@type="gregorian"]
Please see the documentation for CldrParser for details about parsed data
structure.
@param string $path A path to the node to get
@return mixed Array or string of matching data, or false on failure
@see CldrParser | [
"Returns",
"multi",
"-",
"dimensional",
"array",
"representing",
"desired",
"node",
"and",
"it",
"s",
"children",
"or",
"a",
"string",
"value",
"if",
"the",
"path",
"points",
"to",
"a",
"leaf",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/I18n/Cldr/CldrModel.php#L133-L151 |
neos/flow-development-collection | Neos.Flow/Classes/I18n/Cldr/CldrModel.php | CldrModel.getRawArray | public function getRawArray($path)
{
$data = $this->getRawData($path);
if (!is_array($data)) {
return false;
}
return $data;
} | php | public function getRawArray($path)
{
$data = $this->getRawData($path);
if (!is_array($data)) {
return false;
}
return $data;
} | [
"public",
"function",
"getRawArray",
"(",
"$",
"path",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"getRawData",
"(",
"$",
"path",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"data",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"$... | Returns multi-dimensional array representing desired node and it's children.
This method will return false if the path points to a leaf (i.e. a string,
not an array).
@param string $path A path to the node to get
@return mixed Array of matching data, or false on failure
@see CldrParser
@see CldrModel::getRawData() | [
"Returns",
"multi",
"-",
"dimensional",
"array",
"representing",
"desired",
"node",
"and",
"it",
"s",
"children",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/I18n/Cldr/CldrModel.php#L164-L173 |
neos/flow-development-collection | Neos.Flow/Classes/I18n/Cldr/CldrModel.php | CldrModel.getElement | public function getElement($path)
{
$data = $this->getRawData($path);
if (is_array($data)) {
return false;
} else {
return $data;
}
} | php | public function getElement($path)
{
$data = $this->getRawData($path);
if (is_array($data)) {
return false;
} else {
return $data;
}
} | [
"public",
"function",
"getElement",
"(",
"$",
"path",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"getRawData",
"(",
"$",
"path",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"data",
")",
")",
"{",
"return",
"false",
";",
"}",
"else",
"{",
"retu... | Returns string value from a path given.
Path must point to leaf. Syntax for paths is same as for getRawData.
@param string $path A path to the element to get
@return mixed String with desired element, or false on failure | [
"Returns",
"string",
"value",
"from",
"a",
"path",
"given",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/I18n/Cldr/CldrModel.php#L183-L192 |
neos/flow-development-collection | Neos.Flow/Classes/I18n/Cldr/CldrModel.php | CldrModel.findNodesWithinPath | public function findNodesWithinPath($path, $nodeName)
{
$data = $this->getRawArray($path);
if ($data === false) {
return false;
}
$filteredData = [];
foreach ($data as $nodeString => $children) {
if ($this->getNodeName($nodeString) === $nodeName) {
$filteredData[$nodeString] = $children;
}
}
return $filteredData;
} | php | public function findNodesWithinPath($path, $nodeName)
{
$data = $this->getRawArray($path);
if ($data === false) {
return false;
}
$filteredData = [];
foreach ($data as $nodeString => $children) {
if ($this->getNodeName($nodeString) === $nodeName) {
$filteredData[$nodeString] = $children;
}
}
return $filteredData;
} | [
"public",
"function",
"findNodesWithinPath",
"(",
"$",
"path",
",",
"$",
"nodeName",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"getRawArray",
"(",
"$",
"path",
")",
";",
"if",
"(",
"$",
"data",
"===",
"false",
")",
"{",
"return",
"false",
";",
... | Returns all nodes with given name found within given path
@param string $path A path to search in
@param string $nodeName A name of the nodes to return
@return mixed String with desired element, or false on failure | [
"Returns",
"all",
"nodes",
"with",
"given",
"name",
"found",
"within",
"given",
"path"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/I18n/Cldr/CldrModel.php#L201-L217 |
neos/flow-development-collection | Neos.Flow/Classes/I18n/Cldr/CldrModel.php | CldrModel.getNodeName | public static function getNodeName($nodeString)
{
$positionOfFirstAttribute = strpos($nodeString, '[@');
if ($positionOfFirstAttribute === false) {
return $nodeString;
}
return substr($nodeString, 0, $positionOfFirstAttribute);
} | php | public static function getNodeName($nodeString)
{
$positionOfFirstAttribute = strpos($nodeString, '[@');
if ($positionOfFirstAttribute === false) {
return $nodeString;
}
return substr($nodeString, 0, $positionOfFirstAttribute);
} | [
"public",
"static",
"function",
"getNodeName",
"(",
"$",
"nodeString",
")",
"{",
"$",
"positionOfFirstAttribute",
"=",
"strpos",
"(",
"$",
"nodeString",
",",
"'[@'",
")",
";",
"if",
"(",
"$",
"positionOfFirstAttribute",
"===",
"false",
")",
"{",
"return",
"$... | Returns node name extracted from node string
The internal representation of CLDR uses array keys like:
'calendar[@type="gregorian"]'
This method helps to extract the node name from such keys.
@param string $nodeString String with node name and optional attribute(s)
@return string Name of the node | [
"Returns",
"node",
"name",
"extracted",
"from",
"node",
"string"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/I18n/Cldr/CldrModel.php#L229-L238 |
neos/flow-development-collection | Neos.Flow/Classes/I18n/Cldr/CldrModel.php | CldrModel.getAttributeValue | public static function getAttributeValue($nodeString, $attributeName)
{
$attributeName = '[@' . $attributeName . '="';
$positionOfAttributeName = strpos($nodeString, $attributeName);
if ($positionOfAttributeName === false) {
return false;
}
$positionOfAttributeValue = $positionOfAttributeName + strlen($attributeName);
return substr($nodeString, $positionOfAttributeValue, strpos($nodeString, '"]', $positionOfAttributeValue) - $positionOfAttributeValue);
} | php | public static function getAttributeValue($nodeString, $attributeName)
{
$attributeName = '[@' . $attributeName . '="';
$positionOfAttributeName = strpos($nodeString, $attributeName);
if ($positionOfAttributeName === false) {
return false;
}
$positionOfAttributeValue = $positionOfAttributeName + strlen($attributeName);
return substr($nodeString, $positionOfAttributeValue, strpos($nodeString, '"]', $positionOfAttributeValue) - $positionOfAttributeValue);
} | [
"public",
"static",
"function",
"getAttributeValue",
"(",
"$",
"nodeString",
",",
"$",
"attributeName",
")",
"{",
"$",
"attributeName",
"=",
"'[@'",
".",
"$",
"attributeName",
".",
"'=\"'",
";",
"$",
"positionOfAttributeName",
"=",
"strpos",
"(",
"$",
"nodeStr... | Parses the node string and returns a value of attribute for name provided.
An internal representation of CLDR data used by this class is a simple
multi dimensional array where keys are nodes' names. If node has attributes,
they are all stored as one string (e.g. 'calendar[@type="gregorian"]' or
'calendar[@type="gregorian"][@alt="proposed-x1001"').
This convenient method extracts a value of desired attribute by its name
(in example above, in order to get the value 'gregorian', 'type' should
be passed as the second parameter to this method).
Note: this method does not validate the input!
@param string $nodeString A node key to parse
@param string $attributeName Name of the attribute to find
@return mixed Value of desired attribute, or false if there is no such attribute | [
"Parses",
"the",
"node",
"string",
"and",
"returns",
"a",
"value",
"of",
"attribute",
"for",
"name",
"provided",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/I18n/Cldr/CldrModel.php#L258-L269 |
neos/flow-development-collection | Neos.Flow/Classes/I18n/Cldr/CldrModel.php | CldrModel.parseFiles | protected function parseFiles(array $sourcePaths)
{
$parsedFiles = [];
foreach ($sourcePaths as $sourcePath) {
$parsedFiles[] = $this->cldrParser->getParsedData($sourcePath);
}
// Merge all data starting with most generic file so we get proper inheritance
$parsedData = $parsedFiles[0];
$parsedFilesCount = count($parsedFiles);
for ($i = 1; $i < $parsedFilesCount; ++$i) {
$parsedData = $this->mergeTwoParsedFiles($parsedData, $parsedFiles[$i]);
}
return $parsedData;
} | php | protected function parseFiles(array $sourcePaths)
{
$parsedFiles = [];
foreach ($sourcePaths as $sourcePath) {
$parsedFiles[] = $this->cldrParser->getParsedData($sourcePath);
}
// Merge all data starting with most generic file so we get proper inheritance
$parsedData = $parsedFiles[0];
$parsedFilesCount = count($parsedFiles);
for ($i = 1; $i < $parsedFilesCount; ++$i) {
$parsedData = $this->mergeTwoParsedFiles($parsedData, $parsedFiles[$i]);
}
return $parsedData;
} | [
"protected",
"function",
"parseFiles",
"(",
"array",
"$",
"sourcePaths",
")",
"{",
"$",
"parsedFiles",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"sourcePaths",
"as",
"$",
"sourcePath",
")",
"{",
"$",
"parsedFiles",
"[",
"]",
"=",
"$",
"this",
"->",
"cld... | Parses given CLDR files using CldrParser and merges parsed data.
Merging is done with inheritance in mind, as defined in CLDR specification.
@param array<string> $sourcePaths Absolute paths to CLDR files (can be one file)
@return array Parsed and merged data | [
"Parses",
"given",
"CLDR",
"files",
"using",
"CldrParser",
"and",
"merges",
"parsed",
"data",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/I18n/Cldr/CldrModel.php#L279-L296 |
neos/flow-development-collection | Neos.Flow/Classes/I18n/Cldr/CldrModel.php | CldrModel.mergeTwoParsedFiles | protected function mergeTwoParsedFiles($firstParsedData, $secondParsedData)
{
$mergedData = $firstParsedData;
if (is_array($secondParsedData)) {
foreach ($secondParsedData as $nodeString => $children) {
if (isset($firstParsedData[$nodeString])) {
$mergedData[$nodeString] = $this->mergeTwoParsedFiles($firstParsedData[$nodeString], $children);
} else {
$mergedData[$nodeString] = $children;
}
}
} else {
$mergedData = $secondParsedData;
}
return $mergedData;
} | php | protected function mergeTwoParsedFiles($firstParsedData, $secondParsedData)
{
$mergedData = $firstParsedData;
if (is_array($secondParsedData)) {
foreach ($secondParsedData as $nodeString => $children) {
if (isset($firstParsedData[$nodeString])) {
$mergedData[$nodeString] = $this->mergeTwoParsedFiles($firstParsedData[$nodeString], $children);
} else {
$mergedData[$nodeString] = $children;
}
}
} else {
$mergedData = $secondParsedData;
}
return $mergedData;
} | [
"protected",
"function",
"mergeTwoParsedFiles",
"(",
"$",
"firstParsedData",
",",
"$",
"secondParsedData",
")",
"{",
"$",
"mergedData",
"=",
"$",
"firstParsedData",
";",
"if",
"(",
"is_array",
"(",
"$",
"secondParsedData",
")",
")",
"{",
"foreach",
"(",
"$",
... | Merges two sets of data from two separate CLDR files into one array.
Merging is done with inheritance in mind, as defined in CLDR specification.
@param mixed $firstParsedData Part of data from first file (either array or string)
@param mixed $secondParsedData Part of data from second file (either array or string)
@return array Data merged from two files | [
"Merges",
"two",
"sets",
"of",
"data",
"from",
"two",
"separate",
"CLDR",
"files",
"into",
"one",
"array",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/I18n/Cldr/CldrModel.php#L307-L324 |
neos/flow-development-collection | Neos.Flow/Classes/I18n/Cldr/CldrModel.php | CldrModel.resolveAliases | protected function resolveAliases($data, $currentPath)
{
if (!is_array($data)) {
return $data;
}
foreach ($data as $nodeString => $nodeChildren) {
if (self::getNodeName($nodeString) === 'alias') {
if (self::getAttributeValue($nodeString, 'source') !== 'locale') {
// Value of source attribute can be 'locale' or particular locale identifier, but we do not support the second mode, ignore it silently
break;
}
$sourcePath = self::getAttributeValue($nodeString, 'path');
// Change relative path to absolute one
$sourcePath = str_replace('../', '', $sourcePath, $countOfJumpsToParentNode);
$sourcePath = str_replace('\'', '"', $sourcePath);
$currentPathNodeNames = explode('/', $currentPath);
for ($i = 0; $i < $countOfJumpsToParentNode; ++$i) {
unset($currentPathNodeNames[count($currentPathNodeNames) - 1]);
}
$sourcePath = implode('/', $currentPathNodeNames) . '/' . $sourcePath;
unset($data[$nodeString]);
$sourceData = $this->getRawData($sourcePath);
if (is_array($sourceData)) {
$data = array_merge($sourceData, $data);
}
break;
} else {
$data[$nodeString] = $this->resolveAliases($data[$nodeString], ($currentPath === '') ? $nodeString : ($currentPath . '/' . $nodeString));
}
}
return $data;
} | php | protected function resolveAliases($data, $currentPath)
{
if (!is_array($data)) {
return $data;
}
foreach ($data as $nodeString => $nodeChildren) {
if (self::getNodeName($nodeString) === 'alias') {
if (self::getAttributeValue($nodeString, 'source') !== 'locale') {
// Value of source attribute can be 'locale' or particular locale identifier, but we do not support the second mode, ignore it silently
break;
}
$sourcePath = self::getAttributeValue($nodeString, 'path');
// Change relative path to absolute one
$sourcePath = str_replace('../', '', $sourcePath, $countOfJumpsToParentNode);
$sourcePath = str_replace('\'', '"', $sourcePath);
$currentPathNodeNames = explode('/', $currentPath);
for ($i = 0; $i < $countOfJumpsToParentNode; ++$i) {
unset($currentPathNodeNames[count($currentPathNodeNames) - 1]);
}
$sourcePath = implode('/', $currentPathNodeNames) . '/' . $sourcePath;
unset($data[$nodeString]);
$sourceData = $this->getRawData($sourcePath);
if (is_array($sourceData)) {
$data = array_merge($sourceData, $data);
}
break;
} else {
$data[$nodeString] = $this->resolveAliases($data[$nodeString], ($currentPath === '') ? $nodeString : ($currentPath . '/' . $nodeString));
}
}
return $data;
} | [
"protected",
"function",
"resolveAliases",
"(",
"$",
"data",
",",
"$",
"currentPath",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"data",
")",
")",
"{",
"return",
"$",
"data",
";",
"}",
"foreach",
"(",
"$",
"data",
"as",
"$",
"nodeString",
"=>",
... | Resolves any 'alias' nodes in parsed CLDR data.
CLDR uses 'alias' tag which denotes places where data should be copied
from. This tag has 'source' attribute pointing (by relative XPath query)
to the source node - it should be copied with all it's children.
@param mixed $data Part of internal array to resolve aliases for (string if leaf, array otherwise)
@param string $currentPath Path to currently analyzed part of data
@return mixed Modified (or unchanged) $data
@throws Exception\InvalidCldrDataException When found alias tag which has unexpected structure | [
"Resolves",
"any",
"alias",
"nodes",
"in",
"parsed",
"CLDR",
"data",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/I18n/Cldr/CldrModel.php#L338-L374 |
neos/flow-development-collection | Neos.Eel/Classes/Helper/MathHelper.php | MathHelper.round | public function round($subject, $precision = 0)
{
if (!is_numeric($subject)) {
return NAN;
}
$subject = floatval($subject);
if ($precision != null && !is_int($precision)) {
return NAN;
}
return round($subject, $precision);
} | php | public function round($subject, $precision = 0)
{
if (!is_numeric($subject)) {
return NAN;
}
$subject = floatval($subject);
if ($precision != null && !is_int($precision)) {
return NAN;
}
return round($subject, $precision);
} | [
"public",
"function",
"round",
"(",
"$",
"subject",
",",
"$",
"precision",
"=",
"0",
")",
"{",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"subject",
")",
")",
"{",
"return",
"NAN",
";",
"}",
"$",
"subject",
"=",
"floatval",
"(",
"$",
"subject",
")",
... | Rounds the subject to the given precision
The precision defines the number of digits after the decimal point.
Negative values are also supported (-1 rounds to full 10ths).
@param float $subject The value to round
@param integer $precision The precision (digits after decimal point) to use, defaults to 0
@return float The rounded value | [
"Rounds",
"the",
"subject",
"to",
"the",
"given",
"precision"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Eel/Classes/Helper/MathHelper.php#L407-L417 |
neos/flow-development-collection | Neos.Eel/Classes/Helper/MathHelper.php | MathHelper.trunc | public function trunc($x)
{
$sign = $this->sign($x);
switch ($sign) {
case -1:
return ceil($x);
case 1:
return floor($x);
default:
return $sign;
}
} | php | public function trunc($x)
{
$sign = $this->sign($x);
switch ($sign) {
case -1:
return ceil($x);
case 1:
return floor($x);
default:
return $sign;
}
} | [
"public",
"function",
"trunc",
"(",
"$",
"x",
")",
"{",
"$",
"sign",
"=",
"$",
"this",
"->",
"sign",
"(",
"$",
"x",
")",
";",
"switch",
"(",
"$",
"sign",
")",
"{",
"case",
"-",
"1",
":",
"return",
"ceil",
"(",
"$",
"x",
")",
";",
"case",
"1... | Get the integral part of the given number by removing any fractional digits
This function doesn't round the given number but merely calls ceil(x) or floor(x) depending
on the sign of the number.
@param float $x A number
@return integer The integral part of the given number | [
"Get",
"the",
"integral",
"part",
"of",
"the",
"given",
"number",
"by",
"removing",
"any",
"fractional",
"digits"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Eel/Classes/Helper/MathHelper.php#L492-L503 |
neos/flow-development-collection | Neos.Flow/Classes/Persistence/Generic/Backend/AbstractBackend.php | AbstractBackend.initialize | public function initialize(array $options)
{
foreach ($options as $optionName => $optionValue) {
$methodName = 'set' . ucfirst($optionName);
if (method_exists($this, $methodName)) {
$this->$methodName($optionValue);
}
}
} | php | public function initialize(array $options)
{
foreach ($options as $optionName => $optionValue) {
$methodName = 'set' . ucfirst($optionName);
if (method_exists($this, $methodName)) {
$this->$methodName($optionValue);
}
}
} | [
"public",
"function",
"initialize",
"(",
"array",
"$",
"options",
")",
"{",
"foreach",
"(",
"$",
"options",
"as",
"$",
"optionName",
"=>",
"$",
"optionValue",
")",
"{",
"$",
"methodName",
"=",
"'set'",
".",
"ucfirst",
"(",
"$",
"optionName",
")",
";",
... | Initializes the backend
@param array $options
@return void | [
"Initializes",
"the",
"backend"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Persistence/Generic/Backend/AbstractBackend.php#L217-L225 |
neos/flow-development-collection | Neos.Flow/Classes/Persistence/Generic/Backend/AbstractBackend.php | AbstractBackend.persistObjects | protected function persistObjects()
{
$this->visitedDuringPersistence = new \SplObjectStorage();
foreach ($this->aggregateRootObjects as $object) {
$this->persistObject($object, null);
}
foreach ($this->changedEntities as $object) {
$this->persistObject($object, null);
}
} | php | protected function persistObjects()
{
$this->visitedDuringPersistence = new \SplObjectStorage();
foreach ($this->aggregateRootObjects as $object) {
$this->persistObject($object, null);
}
foreach ($this->changedEntities as $object) {
$this->persistObject($object, null);
}
} | [
"protected",
"function",
"persistObjects",
"(",
")",
"{",
"$",
"this",
"->",
"visitedDuringPersistence",
"=",
"new",
"\\",
"SplObjectStorage",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"aggregateRootObjects",
"as",
"$",
"object",
")",
"{",
"$",
"this... | First persist new objects, then check reconstituted entities.
@return void | [
"First",
"persist",
"new",
"objects",
"then",
"check",
"reconstituted",
"entities",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Persistence/Generic/Backend/AbstractBackend.php#L288-L297 |
neos/flow-development-collection | Neos.Flow/Classes/Persistence/Generic/Backend/AbstractBackend.php | AbstractBackend.persistObject | protected function persistObject($object, $parentIdentifier)
{
if (isset($this->visitedDuringPersistence[$object])) {
return $this->visitedDuringPersistence[$object];
}
$identifier = $this->persistenceSession->getIdentifierByObject($object);
$this->visitedDuringPersistence[$object] = $identifier;
$objectData = [];
$objectState = $this->storeObject($object, $identifier, $parentIdentifier, $objectData);
if ($this->reflectionService->getClassSchema($object)->getModelType() === ClassSchema::MODELTYPE_ENTITY) {
$this->persistenceSession->registerReconstitutedEntity($object, $objectData);
}
$this->emitPersistedObject($object, $objectState);
return $identifier;
} | php | protected function persistObject($object, $parentIdentifier)
{
if (isset($this->visitedDuringPersistence[$object])) {
return $this->visitedDuringPersistence[$object];
}
$identifier = $this->persistenceSession->getIdentifierByObject($object);
$this->visitedDuringPersistence[$object] = $identifier;
$objectData = [];
$objectState = $this->storeObject($object, $identifier, $parentIdentifier, $objectData);
if ($this->reflectionService->getClassSchema($object)->getModelType() === ClassSchema::MODELTYPE_ENTITY) {
$this->persistenceSession->registerReconstitutedEntity($object, $objectData);
}
$this->emitPersistedObject($object, $objectState);
return $identifier;
} | [
"protected",
"function",
"persistObject",
"(",
"$",
"object",
",",
"$",
"parentIdentifier",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"visitedDuringPersistence",
"[",
"$",
"object",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"visitedDurin... | Stores or updates an object in the underlying storage.
@param object $object The object to persist
@param string $parentIdentifier
@return string
@api | [
"Stores",
"or",
"updates",
"an",
"object",
"in",
"the",
"underlying",
"storage",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Persistence/Generic/Backend/AbstractBackend.php#L307-L325 |
neos/flow-development-collection | Neos.Flow/Classes/Persistence/Generic/Backend/AbstractBackend.php | AbstractBackend.processDeletedObjects | protected function processDeletedObjects()
{
foreach ($this->deletedEntities as $entity) {
if ($this->persistenceSession->hasObject($entity)) {
$this->removeEntity($entity);
$this->persistenceSession->unregisterReconstitutedEntity($entity);
$this->persistenceSession->unregisterObject($entity);
}
}
$this->deletedEntities = new \SplObjectStorage();
} | php | protected function processDeletedObjects()
{
foreach ($this->deletedEntities as $entity) {
if ($this->persistenceSession->hasObject($entity)) {
$this->removeEntity($entity);
$this->persistenceSession->unregisterReconstitutedEntity($entity);
$this->persistenceSession->unregisterObject($entity);
}
}
$this->deletedEntities = new \SplObjectStorage();
} | [
"protected",
"function",
"processDeletedObjects",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"deletedEntities",
"as",
"$",
"entity",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"persistenceSession",
"->",
"hasObject",
"(",
"$",
"entity",
")",
")",
"{",
... | Iterate over deleted entities and process them
@return void | [
"Iterate",
"over",
"deleted",
"entities",
"and",
"process",
"them"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Persistence/Generic/Backend/AbstractBackend.php#L343-L353 |
neos/flow-development-collection | Neos.Flow/Classes/Persistence/Generic/Backend/AbstractBackend.php | AbstractBackend.validateObject | protected function validateObject($object)
{
$classSchema = $this->reflectionService->getClassSchema($object);
$validator = $this->validatorResolver->getBaseValidatorConjunction($classSchema->getClassName());
if ($validator === null) {
return;
}
$validationResult = $validator->validate($object);
if ($validationResult->hasErrors()) {
$errorMessages = '';
$allErrors = $validationResult->getFlattenedErrors();
foreach ($allErrors as $path => $errors) {
$errorMessages .= $path . ':' . PHP_EOL;
foreach ($errors as $error) {
$errorMessages .= (string)$error . PHP_EOL;
}
}
throw new ObjectValidationFailedException('An instance of "' . get_class($object) . '" failed to pass validation with ' . count($errors) . ' error(s): ' . PHP_EOL . $errorMessages, 1322585162);
}
} | php | protected function validateObject($object)
{
$classSchema = $this->reflectionService->getClassSchema($object);
$validator = $this->validatorResolver->getBaseValidatorConjunction($classSchema->getClassName());
if ($validator === null) {
return;
}
$validationResult = $validator->validate($object);
if ($validationResult->hasErrors()) {
$errorMessages = '';
$allErrors = $validationResult->getFlattenedErrors();
foreach ($allErrors as $path => $errors) {
$errorMessages .= $path . ':' . PHP_EOL;
foreach ($errors as $error) {
$errorMessages .= (string)$error . PHP_EOL;
}
}
throw new ObjectValidationFailedException('An instance of "' . get_class($object) . '" failed to pass validation with ' . count($errors) . ' error(s): ' . PHP_EOL . $errorMessages, 1322585162);
}
} | [
"protected",
"function",
"validateObject",
"(",
"$",
"object",
")",
"{",
"$",
"classSchema",
"=",
"$",
"this",
"->",
"reflectionService",
"->",
"getClassSchema",
"(",
"$",
"object",
")",
";",
"$",
"validator",
"=",
"$",
"this",
"->",
"validatorResolver",
"->... | Validates the given object and throws an exception if validation fails.
@param object $object
@return void
@throws ObjectValidationFailedException
@api | [
"Validates",
"the",
"given",
"object",
"and",
"throws",
"an",
"exception",
"if",
"validation",
"fails",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Persistence/Generic/Backend/AbstractBackend.php#L379-L398 |
neos/flow-development-collection | Neos.Flow/Classes/Persistence/Generic/Backend/AbstractBackend.php | AbstractBackend.getType | protected function getType($value)
{
if (is_object($value)) {
return get_class($value);
} else {
return gettype($value) === 'double' ? 'float' : gettype($value);
}
} | php | protected function getType($value)
{
if (is_object($value)) {
return get_class($value);
} else {
return gettype($value) === 'double' ? 'float' : gettype($value);
}
} | [
"protected",
"function",
"getType",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"value",
")",
")",
"{",
"return",
"get_class",
"(",
"$",
"value",
")",
";",
"}",
"else",
"{",
"return",
"gettype",
"(",
"$",
"value",
")",
"===",
"'d... | Returns the type of $value, i.e. the class name or primitive type.
@param mixed $value
@return string | [
"Returns",
"the",
"type",
"of",
"$value",
"i",
".",
"e",
".",
"the",
"class",
"name",
"or",
"primitive",
"type",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Persistence/Generic/Backend/AbstractBackend.php#L406-L413 |
neos/flow-development-collection | Neos.Flow/Classes/Persistence/Generic/Backend/AbstractBackend.php | AbstractBackend.flattenValue | protected function flattenValue($identifier, $object, $propertyName, array $propertyMetaData, array &$propertyData)
{
$propertyValue = ObjectAccess::getProperty($object, $propertyName, true);
if ($propertyValue instanceof PersistenceMagicInterface) {
$propertyData[$propertyName] = [
'type' => get_class($propertyValue),
'multivalue' => false,
'value' => $this->processObject($propertyValue, $identifier)
];
} else {
switch ($propertyMetaData['type']) {
case 'DateTime':
$propertyData[$propertyName] = [
'multivalue' => false,
'value' => $this->processDateTime($propertyValue)
];
break;
case Collection::class:
case ArrayCollection::class:
$propertyValue = $propertyValue === null ? [] : $propertyValue->toArray();
case 'array':
$propertyData[$propertyName] = [
'multivalue' => true,
'value' => $this->processArray($propertyValue, $identifier, $this->persistenceSession->getCleanStateOfProperty($object, $propertyName))
];
break;
case 'SplObjectStorage':
$propertyData[$propertyName] = [
'multivalue' => true,
'value' => $this->processSplObjectStorage($propertyValue, $identifier, $this->persistenceSession->getCleanStateOfProperty($object, $propertyName))
];
break;
default:
if ($propertyValue === null && !TypeHandling::isSimpleType($propertyMetaData['type'])) {
$this->removeDeletedReference($object, $propertyName, $propertyMetaData);
}
$propertyData[$propertyName] = [
'multivalue' => false,
'value' => $propertyValue
];
break;
}
$propertyData[$propertyName]['type'] = $propertyMetaData['type'];
}
} | php | protected function flattenValue($identifier, $object, $propertyName, array $propertyMetaData, array &$propertyData)
{
$propertyValue = ObjectAccess::getProperty($object, $propertyName, true);
if ($propertyValue instanceof PersistenceMagicInterface) {
$propertyData[$propertyName] = [
'type' => get_class($propertyValue),
'multivalue' => false,
'value' => $this->processObject($propertyValue, $identifier)
];
} else {
switch ($propertyMetaData['type']) {
case 'DateTime':
$propertyData[$propertyName] = [
'multivalue' => false,
'value' => $this->processDateTime($propertyValue)
];
break;
case Collection::class:
case ArrayCollection::class:
$propertyValue = $propertyValue === null ? [] : $propertyValue->toArray();
case 'array':
$propertyData[$propertyName] = [
'multivalue' => true,
'value' => $this->processArray($propertyValue, $identifier, $this->persistenceSession->getCleanStateOfProperty($object, $propertyName))
];
break;
case 'SplObjectStorage':
$propertyData[$propertyName] = [
'multivalue' => true,
'value' => $this->processSplObjectStorage($propertyValue, $identifier, $this->persistenceSession->getCleanStateOfProperty($object, $propertyName))
];
break;
default:
if ($propertyValue === null && !TypeHandling::isSimpleType($propertyMetaData['type'])) {
$this->removeDeletedReference($object, $propertyName, $propertyMetaData);
}
$propertyData[$propertyName] = [
'multivalue' => false,
'value' => $propertyValue
];
break;
}
$propertyData[$propertyName]['type'] = $propertyMetaData['type'];
}
} | [
"protected",
"function",
"flattenValue",
"(",
"$",
"identifier",
",",
"$",
"object",
",",
"$",
"propertyName",
",",
"array",
"$",
"propertyMetaData",
",",
"array",
"&",
"$",
"propertyData",
")",
"{",
"$",
"propertyValue",
"=",
"ObjectAccess",
"::",
"getPropert... | Convert a value to the internal object data format
@param string $identifier The object's identifier
@param object $object The object with the property to flatten
@param string $propertyName The name of the property
@param array $propertyMetaData The property metadata
@param array $propertyData Reference to the property data array
@return void
@api | [
"Convert",
"a",
"value",
"to",
"the",
"internal",
"object",
"data",
"format"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Persistence/Generic/Backend/AbstractBackend.php#L473-L518 |
neos/flow-development-collection | Neos.Flow/Classes/Persistence/Generic/Backend/AbstractBackend.php | AbstractBackend.removeDeletedReference | protected function removeDeletedReference($object, $propertyName, $propertyMetaData)
{
$previousValue = $this->persistenceSession->getCleanStateOfProperty($object, $propertyName);
if ($previousValue !== null && is_array($previousValue) && isset($previousValue['value']['identifier'])
&& $this->reflectionService->getClassSchema($propertyMetaData['type'])->getModelType() === ClassSchema::MODELTYPE_ENTITY
&& $this->reflectionService->getClassSchema($propertyMetaData['type'])->isAggregateRoot() === false) {
$object = $this->persistenceSession->getObjectByIdentifier($previousValue['value']['identifier']);
if (!$this->visitedDuringPersistence->contains($object)) {
$this->removeEntity($object);
}
}
} | php | protected function removeDeletedReference($object, $propertyName, $propertyMetaData)
{
$previousValue = $this->persistenceSession->getCleanStateOfProperty($object, $propertyName);
if ($previousValue !== null && is_array($previousValue) && isset($previousValue['value']['identifier'])
&& $this->reflectionService->getClassSchema($propertyMetaData['type'])->getModelType() === ClassSchema::MODELTYPE_ENTITY
&& $this->reflectionService->getClassSchema($propertyMetaData['type'])->isAggregateRoot() === false) {
$object = $this->persistenceSession->getObjectByIdentifier($previousValue['value']['identifier']);
if (!$this->visitedDuringPersistence->contains($object)) {
$this->removeEntity($object);
}
}
} | [
"protected",
"function",
"removeDeletedReference",
"(",
"$",
"object",
",",
"$",
"propertyName",
",",
"$",
"propertyMetaData",
")",
"{",
"$",
"previousValue",
"=",
"$",
"this",
"->",
"persistenceSession",
"->",
"getCleanStateOfProperty",
"(",
"$",
"object",
",",
... | Remove any unreferenced non aggregate root entity
@param object $object
@param string $propertyName
@param array $propertyMetaData
@return void | [
"Remove",
"any",
"unreferenced",
"non",
"aggregate",
"root",
"entity"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Persistence/Generic/Backend/AbstractBackend.php#L528-L539 |
neos/flow-development-collection | Neos.Flow/Classes/Persistence/Generic/Backend/AbstractBackend.php | AbstractBackend.checkPropertyValue | protected function checkPropertyValue($object, $propertyName, array $propertyMetaData)
{
$propertyValue = ObjectAccess::getProperty($object, $propertyName, true);
$propertyType = $propertyMetaData['type'];
if ($propertyType === 'ArrayObject') {
throw new PersistenceException('ArrayObject properties are not supported - missing feature?!?', 1283524355);
}
if (is_object($propertyValue)) {
if ($propertyType === 'object') {
if (!($propertyValue instanceof PersistenceMagicInterface)) {
throw new IllegalObjectTypeException('Property of generic type object holds "' . get_class($propertyValue) . '", which is not persistable (no entity or value object), in ' . get_class($object) . '::' . $propertyName, 1283531761);
}
} elseif (!($propertyValue instanceof $propertyType)) {
throw new UnexpectedTypeException('Expected property of type ' . $propertyType . ', but got ' . get_class($propertyValue) . ' for ' . get_class($object) . '::' . $propertyName, 1244465558);
}
} elseif ($propertyValue !== null && $propertyType !== $this->getType($propertyValue)) {
throw new UnexpectedTypeException('Expected property of type ' . $propertyType . ', but got ' . gettype($propertyValue) . ' for ' . get_class($object) . '::' . $propertyName, 1244465559);
}
return $propertyValue;
} | php | protected function checkPropertyValue($object, $propertyName, array $propertyMetaData)
{
$propertyValue = ObjectAccess::getProperty($object, $propertyName, true);
$propertyType = $propertyMetaData['type'];
if ($propertyType === 'ArrayObject') {
throw new PersistenceException('ArrayObject properties are not supported - missing feature?!?', 1283524355);
}
if (is_object($propertyValue)) {
if ($propertyType === 'object') {
if (!($propertyValue instanceof PersistenceMagicInterface)) {
throw new IllegalObjectTypeException('Property of generic type object holds "' . get_class($propertyValue) . '", which is not persistable (no entity or value object), in ' . get_class($object) . '::' . $propertyName, 1283531761);
}
} elseif (!($propertyValue instanceof $propertyType)) {
throw new UnexpectedTypeException('Expected property of type ' . $propertyType . ', but got ' . get_class($propertyValue) . ' for ' . get_class($object) . '::' . $propertyName, 1244465558);
}
} elseif ($propertyValue !== null && $propertyType !== $this->getType($propertyValue)) {
throw new UnexpectedTypeException('Expected property of type ' . $propertyType . ', but got ' . gettype($propertyValue) . ' for ' . get_class($object) . '::' . $propertyName, 1244465559);
}
return $propertyValue;
} | [
"protected",
"function",
"checkPropertyValue",
"(",
"$",
"object",
",",
"$",
"propertyName",
",",
"array",
"$",
"propertyMetaData",
")",
"{",
"$",
"propertyValue",
"=",
"ObjectAccess",
"::",
"getProperty",
"(",
"$",
"object",
",",
"$",
"propertyName",
",",
"tr... | Check the property value for allowed types and throw exceptions for
unsupported types.
@param object $object The object with the property to check
@param string $propertyName The name of the property to check
@param array $propertyMetaData Property metadata
@return mixed The value of the property
@throws UnexpectedTypeException
@throws PersistenceException
@throws IllegalObjectTypeException
@api | [
"Check",
"the",
"property",
"value",
"for",
"allowed",
"types",
"and",
"throw",
"exceptions",
"for",
"unsupported",
"types",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Persistence/Generic/Backend/AbstractBackend.php#L572-L593 |
neos/flow-development-collection | Neos.Flow/Classes/Persistence/Generic/Backend/AbstractBackend.php | AbstractBackend.processArray | protected function processArray(array $array = null, $parentIdentifier, array $previousArray = null)
{
if ($previousArray !== null && is_array($previousArray['value'])) {
$this->removeDeletedArrayEntries($array, $previousArray['value']);
}
if ($array === null) {
return null;
}
$values = [];
foreach ($array as $key => $value) {
if ($value instanceof \DateTimeInterface) {
$values[] = [
'type' => 'DateTime',
'index' => $key,
'value' => $this->processDateTime($value)
];
} elseif ($value instanceof \SplObjectStorage) {
throw new PersistenceException('SplObjectStorage instances in arrays are not supported - missing feature?!?', 1261048721);
} elseif ($value instanceof \ArrayObject) {
throw new PersistenceException('ArrayObject instances in arrays are not supported - missing feature?!?', 1283524345);
} elseif (is_object($value)) {
$values[] = [
'type' => $this->getType($value),
'index' => $key,
'value' => $this->processObject($value, $parentIdentifier)
];
} elseif (is_array($value)) {
$values[] = [
'type' => 'array',
'index' => $key,
'value' => $this->processNestedArray($parentIdentifier, $value)
];
} else {
$values[] = [
'type' => $this->getType($value),
'index' => $key,
'value' => $value
];
}
}
return $values;
} | php | protected function processArray(array $array = null, $parentIdentifier, array $previousArray = null)
{
if ($previousArray !== null && is_array($previousArray['value'])) {
$this->removeDeletedArrayEntries($array, $previousArray['value']);
}
if ($array === null) {
return null;
}
$values = [];
foreach ($array as $key => $value) {
if ($value instanceof \DateTimeInterface) {
$values[] = [
'type' => 'DateTime',
'index' => $key,
'value' => $this->processDateTime($value)
];
} elseif ($value instanceof \SplObjectStorage) {
throw new PersistenceException('SplObjectStorage instances in arrays are not supported - missing feature?!?', 1261048721);
} elseif ($value instanceof \ArrayObject) {
throw new PersistenceException('ArrayObject instances in arrays are not supported - missing feature?!?', 1283524345);
} elseif (is_object($value)) {
$values[] = [
'type' => $this->getType($value),
'index' => $key,
'value' => $this->processObject($value, $parentIdentifier)
];
} elseif (is_array($value)) {
$values[] = [
'type' => 'array',
'index' => $key,
'value' => $this->processNestedArray($parentIdentifier, $value)
];
} else {
$values[] = [
'type' => $this->getType($value),
'index' => $key,
'value' => $value
];
}
}
return $values;
} | [
"protected",
"function",
"processArray",
"(",
"array",
"$",
"array",
"=",
"null",
",",
"$",
"parentIdentifier",
",",
"array",
"$",
"previousArray",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"previousArray",
"!==",
"null",
"&&",
"is_array",
"(",
"$",
"previous... | Store an array as a set of records, with each array element becoming a
property named like the key and the value.
Note: Objects contained in the array will have a matching entry created,
the objects must be persisted elsewhere!
@param array $array The array to persist
@param string $parentIdentifier
@param array $previousArray the previously persisted state of the array
@return array An array with "flat" values representing the array
@throws PersistenceException | [
"Store",
"an",
"array",
"as",
"a",
"set",
"of",
"records",
"with",
"each",
"array",
"element",
"becoming",
"a",
"property",
"named",
"like",
"the",
"key",
"and",
"the",
"value",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Persistence/Generic/Backend/AbstractBackend.php#L608-L652 |
neos/flow-development-collection | Neos.Flow/Classes/Persistence/Generic/Backend/AbstractBackend.php | AbstractBackend.processNestedArray | protected function processNestedArray($parentIdentifier, array $nestedArray, \Closure $handler = null)
{
$identifier = 'a' . Algorithms::generateRandomString(23);
$data = [
'multivalue' => true,
'value' => $this->processArray($nestedArray, $parentIdentifier)
];
if ($handler instanceof \Closure) {
$handler($parentIdentifier, $identifier, $data);
}
return $identifier;
} | php | protected function processNestedArray($parentIdentifier, array $nestedArray, \Closure $handler = null)
{
$identifier = 'a' . Algorithms::generateRandomString(23);
$data = [
'multivalue' => true,
'value' => $this->processArray($nestedArray, $parentIdentifier)
];
if ($handler instanceof \Closure) {
$handler($parentIdentifier, $identifier, $data);
}
return $identifier;
} | [
"protected",
"function",
"processNestedArray",
"(",
"$",
"parentIdentifier",
",",
"array",
"$",
"nestedArray",
",",
"\\",
"Closure",
"$",
"handler",
"=",
"null",
")",
"{",
"$",
"identifier",
"=",
"'a'",
".",
"Algorithms",
"::",
"generateRandomString",
"(",
"23... | "Serializes" a nested array for storage.
@param string $parentIdentifier
@param array $nestedArray
@param \Closure $handler
@return string | [
"Serializes",
"a",
"nested",
"array",
"for",
"storage",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Persistence/Generic/Backend/AbstractBackend.php#L662-L673 |
neos/flow-development-collection | Neos.Flow/Classes/Persistence/Generic/Backend/AbstractBackend.php | AbstractBackend.removeDeletedArrayEntries | protected function removeDeletedArrayEntries(array $array = null, array $previousArray)
{
foreach ($previousArray as $item) {
if ($item['type'] === 'array') {
$this->removeDeletedArrayEntries($array[$item['index']], $item['value']);
} elseif ($this->getTypeName($item['type']) === 'object' && !($item['type'] === 'DateTime' || $item['type'] === 'SplObjectStorage')) {
if (!$this->persistenceSession->hasIdentifier($item['value']['identifier'])) {
// ingore this identifier, assume it was blocked by security query rewriting
continue;
}
$object = $this->persistenceSession->getObjectByIdentifier($item['value']['identifier']);
if ($array === null || !$this->arrayContainsObject($array, $object, $item['value']['identifier'])) {
if ($this->reflectionService->getClassSchema($item['type'])->getModelType() === ClassSchema::MODELTYPE_ENTITY
&& $this->reflectionService->getClassSchema($item['type'])->isAggregateRoot() === false) {
$this->removeEntity($this->persistenceSession->getObjectByIdentifier($item['value']['identifier']));
} elseif ($this->reflectionService->getClassSchema($item['type'])->getModelType() === ClassSchema::MODELTYPE_VALUEOBJECT) {
$this->removeValueObject($this->persistenceSession->getObjectByIdentifier($item['value']['identifier']));
}
}
}
}
} | php | protected function removeDeletedArrayEntries(array $array = null, array $previousArray)
{
foreach ($previousArray as $item) {
if ($item['type'] === 'array') {
$this->removeDeletedArrayEntries($array[$item['index']], $item['value']);
} elseif ($this->getTypeName($item['type']) === 'object' && !($item['type'] === 'DateTime' || $item['type'] === 'SplObjectStorage')) {
if (!$this->persistenceSession->hasIdentifier($item['value']['identifier'])) {
// ingore this identifier, assume it was blocked by security query rewriting
continue;
}
$object = $this->persistenceSession->getObjectByIdentifier($item['value']['identifier']);
if ($array === null || !$this->arrayContainsObject($array, $object, $item['value']['identifier'])) {
if ($this->reflectionService->getClassSchema($item['type'])->getModelType() === ClassSchema::MODELTYPE_ENTITY
&& $this->reflectionService->getClassSchema($item['type'])->isAggregateRoot() === false) {
$this->removeEntity($this->persistenceSession->getObjectByIdentifier($item['value']['identifier']));
} elseif ($this->reflectionService->getClassSchema($item['type'])->getModelType() === ClassSchema::MODELTYPE_VALUEOBJECT) {
$this->removeValueObject($this->persistenceSession->getObjectByIdentifier($item['value']['identifier']));
}
}
}
}
} | [
"protected",
"function",
"removeDeletedArrayEntries",
"(",
"array",
"$",
"array",
"=",
"null",
",",
"array",
"$",
"previousArray",
")",
"{",
"foreach",
"(",
"$",
"previousArray",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"$",
"item",
"[",
"'type'",
"]",
"=... | Remove objects removed from array compared to $previousArray.
@param array $array
@param array $previousArray
@return void | [
"Remove",
"objects",
"removed",
"from",
"array",
"compared",
"to",
"$previousArray",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Persistence/Generic/Backend/AbstractBackend.php#L682-L704 |
neos/flow-development-collection | Neos.Flow/Classes/Persistence/Generic/Backend/AbstractBackend.php | AbstractBackend.arrayContainsObject | protected function arrayContainsObject(array $array, $object, $identifier)
{
if (in_array($object, $array, true) === true) {
return true;
}
foreach ($array as $value) {
if ($value instanceof $object && $this->persistenceSession->getIdentifierByObject($value) === $identifier) {
return true;
}
}
return false;
} | php | protected function arrayContainsObject(array $array, $object, $identifier)
{
if (in_array($object, $array, true) === true) {
return true;
}
foreach ($array as $value) {
if ($value instanceof $object && $this->persistenceSession->getIdentifierByObject($value) === $identifier) {
return true;
}
}
return false;
} | [
"protected",
"function",
"arrayContainsObject",
"(",
"array",
"$",
"array",
",",
"$",
"object",
",",
"$",
"identifier",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"object",
",",
"$",
"array",
",",
"true",
")",
"===",
"true",
")",
"{",
"return",
"true",... | Checks whether the given object is contained in the array. This checks
for object identity in terms of the persistence layer, i.e. the UUID,
when comparing entities.
@param array $array
@param object $object
@param string $identifier
@return boolean | [
"Checks",
"whether",
"the",
"given",
"object",
"is",
"contained",
"in",
"the",
"array",
".",
"This",
"checks",
"for",
"object",
"identity",
"in",
"terms",
"of",
"the",
"persistence",
"layer",
"i",
".",
"e",
".",
"the",
"UUID",
"when",
"comparing",
"entitie... | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Persistence/Generic/Backend/AbstractBackend.php#L716-L729 |
neos/flow-development-collection | Neos.Flow/Classes/Persistence/Generic/Backend/AbstractBackend.php | AbstractBackend.processSplObjectStorage | protected function processSplObjectStorage(\SplObjectStorage $splObjectStorage = null, $parentIdentifier, array $previousObjectStorage = null)
{
if ($previousObjectStorage !== null && is_array($previousObjectStorage['value'])) {
$this->removeDeletedSplObjectStorageEntries($splObjectStorage, $previousObjectStorage['value']);
}
if ($splObjectStorage === null) {
return null;
}
$values = [];
foreach ($splObjectStorage as $object) {
if ($object instanceof \DateTimeInterface) {
$values[] = [
'type' => 'DateTime',
'index' => null,
'value' => $this->processDateTime($object)
];
} elseif ($object instanceof \SplObjectStorage) {
throw new PersistenceException('SplObjectStorage instances in SplObjectStorage are not supported - missing feature?!?', 1283524360);
} elseif ($object instanceof \ArrayObject) {
throw new PersistenceException('ArrayObject instances in SplObjectStorage are not supported - missing feature?!?', 1283524350);
} else {
$values[] = [
'type' => $this->getType($object),
'index' => null,
'value' => $this->processObject($object, $parentIdentifier)
];
}
}
return $values;
} | php | protected function processSplObjectStorage(\SplObjectStorage $splObjectStorage = null, $parentIdentifier, array $previousObjectStorage = null)
{
if ($previousObjectStorage !== null && is_array($previousObjectStorage['value'])) {
$this->removeDeletedSplObjectStorageEntries($splObjectStorage, $previousObjectStorage['value']);
}
if ($splObjectStorage === null) {
return null;
}
$values = [];
foreach ($splObjectStorage as $object) {
if ($object instanceof \DateTimeInterface) {
$values[] = [
'type' => 'DateTime',
'index' => null,
'value' => $this->processDateTime($object)
];
} elseif ($object instanceof \SplObjectStorage) {
throw new PersistenceException('SplObjectStorage instances in SplObjectStorage are not supported - missing feature?!?', 1283524360);
} elseif ($object instanceof \ArrayObject) {
throw new PersistenceException('ArrayObject instances in SplObjectStorage are not supported - missing feature?!?', 1283524350);
} else {
$values[] = [
'type' => $this->getType($object),
'index' => null,
'value' => $this->processObject($object, $parentIdentifier)
];
}
}
return $values;
} | [
"protected",
"function",
"processSplObjectStorage",
"(",
"\\",
"SplObjectStorage",
"$",
"splObjectStorage",
"=",
"null",
",",
"$",
"parentIdentifier",
",",
"array",
"$",
"previousObjectStorage",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"previousObjectStorage",
"!==",
... | Store an SplObjectStorage as a set of records.
Note: Objects contained in the SplObjectStorage will have a matching
entry created, the objects must be persisted elsewhere!
@param \SplObjectStorage $splObjectStorage The SplObjectStorage to persist
@param string $parentIdentifier
@param array $previousObjectStorage the previously persisted state of the SplObjectStorage
@return array An array with "flat" values representing the SplObjectStorage
@throws PersistenceException | [
"Store",
"an",
"SplObjectStorage",
"as",
"a",
"set",
"of",
"records",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Persistence/Generic/Backend/AbstractBackend.php#L743-L775 |
neos/flow-development-collection | Neos.Flow/Classes/Persistence/Generic/Backend/AbstractBackend.php | AbstractBackend.removeDeletedSplObjectStorageEntries | protected function removeDeletedSplObjectStorageEntries(\SplObjectStorage $splObjectStorage = null, array $previousObjectStorage)
{
// remove objects detached since reconstitution
foreach ($previousObjectStorage as $item) {
if ($splObjectStorage instanceof LazySplObjectStorage && !$this->persistenceSession->hasIdentifier($item['value']['identifier'])) {
// ingore this identifier, assume it was blocked by security query rewriting upon activation
continue;
}
$object = $this->persistenceSession->getObjectByIdentifier($item['value']['identifier']);
if ($splObjectStorage === null || !$splObjectStorage->contains($object)) {
if ($this->reflectionService->getClassSchema($object)->getModelType() === ClassSchema::MODELTYPE_ENTITY
&& $this->reflectionService->getClassSchema($object)->isAggregateRoot() === false) {
$this->removeEntity($object);
} elseif ($this->reflectionService->getClassSchema($object)->getModelType() === ClassSchema::MODELTYPE_VALUEOBJECT) {
$this->removeValueObject($object);
}
}
}
} | php | protected function removeDeletedSplObjectStorageEntries(\SplObjectStorage $splObjectStorage = null, array $previousObjectStorage)
{
// remove objects detached since reconstitution
foreach ($previousObjectStorage as $item) {
if ($splObjectStorage instanceof LazySplObjectStorage && !$this->persistenceSession->hasIdentifier($item['value']['identifier'])) {
// ingore this identifier, assume it was blocked by security query rewriting upon activation
continue;
}
$object = $this->persistenceSession->getObjectByIdentifier($item['value']['identifier']);
if ($splObjectStorage === null || !$splObjectStorage->contains($object)) {
if ($this->reflectionService->getClassSchema($object)->getModelType() === ClassSchema::MODELTYPE_ENTITY
&& $this->reflectionService->getClassSchema($object)->isAggregateRoot() === false) {
$this->removeEntity($object);
} elseif ($this->reflectionService->getClassSchema($object)->getModelType() === ClassSchema::MODELTYPE_VALUEOBJECT) {
$this->removeValueObject($object);
}
}
}
} | [
"protected",
"function",
"removeDeletedSplObjectStorageEntries",
"(",
"\\",
"SplObjectStorage",
"$",
"splObjectStorage",
"=",
"null",
",",
"array",
"$",
"previousObjectStorage",
")",
"{",
"// remove objects detached since reconstitution",
"foreach",
"(",
"$",
"previousObjectS... | Remove objects removed from SplObjectStorage compared to
$previousSplObjectStorage.
@param \SplObjectStorage $splObjectStorage
@param array $previousObjectStorage
@return void | [
"Remove",
"objects",
"removed",
"from",
"SplObjectStorage",
"compared",
"to",
"$previousSplObjectStorage",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Persistence/Generic/Backend/AbstractBackend.php#L785-L804 |
neos/flow-development-collection | Neos.Flow/Classes/I18n/Formatter/DatetimeFormatter.php | DatetimeFormatter.format | public function format($value, Locale $locale, array $styleProperties = [])
{
if (isset($styleProperties[0])) {
$formatType = $styleProperties[0];
DatesReader::validateFormatType($formatType);
} else {
$formatType = DatesReader::FORMAT_TYPE_DATETIME;
}
if (isset($styleProperties[1])) {
$formatLength = $styleProperties[1];
DatesReader::validateFormatLength($formatLength);
} else {
$formatLength = DatesReader::FORMAT_LENGTH_DEFAULT;
}
switch ($formatType) {
case DatesReader::FORMAT_TYPE_DATE:
return $this->formatDate($value, $locale, $formatLength);
case DatesReader::FORMAT_TYPE_TIME:
return $this->formatTime($value, $locale, $formatLength);
default:
return $this->formatDateTime($value, $locale, $formatLength);
}
} | php | public function format($value, Locale $locale, array $styleProperties = [])
{
if (isset($styleProperties[0])) {
$formatType = $styleProperties[0];
DatesReader::validateFormatType($formatType);
} else {
$formatType = DatesReader::FORMAT_TYPE_DATETIME;
}
if (isset($styleProperties[1])) {
$formatLength = $styleProperties[1];
DatesReader::validateFormatLength($formatLength);
} else {
$formatLength = DatesReader::FORMAT_LENGTH_DEFAULT;
}
switch ($formatType) {
case DatesReader::FORMAT_TYPE_DATE:
return $this->formatDate($value, $locale, $formatLength);
case DatesReader::FORMAT_TYPE_TIME:
return $this->formatTime($value, $locale, $formatLength);
default:
return $this->formatDateTime($value, $locale, $formatLength);
}
} | [
"public",
"function",
"format",
"(",
"$",
"value",
",",
"Locale",
"$",
"locale",
",",
"array",
"$",
"styleProperties",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"styleProperties",
"[",
"0",
"]",
")",
")",
"{",
"$",
"formatType",
"=",
"... | Formats provided value using optional style properties
@param mixed $value Formatter-specific variable to format (can be integer, \DateTime, etc)
@param Locale $locale Locale to use
@param array $styleProperties Integer-indexed array of formatter-specific style properties (can be empty)
@return string String representation of $value provided, or (string)$value
@api | [
"Formats",
"provided",
"value",
"using",
"optional",
"style",
"properties"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/I18n/Formatter/DatetimeFormatter.php#L55-L79 |
neos/flow-development-collection | Neos.Flow/Classes/I18n/Formatter/DatetimeFormatter.php | DatetimeFormatter.formatDateTimeWithCustomPattern | public function formatDateTimeWithCustomPattern(\DateTimeInterface $dateTime, $format, Locale $locale)
{
return $this->doFormattingWithParsedFormat($dateTime, $this->datesReader->parseCustomFormat($format), $this->datesReader->getLocalizedLiteralsForLocale($locale));
} | php | public function formatDateTimeWithCustomPattern(\DateTimeInterface $dateTime, $format, Locale $locale)
{
return $this->doFormattingWithParsedFormat($dateTime, $this->datesReader->parseCustomFormat($format), $this->datesReader->getLocalizedLiteralsForLocale($locale));
} | [
"public",
"function",
"formatDateTimeWithCustomPattern",
"(",
"\\",
"DateTimeInterface",
"$",
"dateTime",
",",
"$",
"format",
",",
"Locale",
"$",
"locale",
")",
"{",
"return",
"$",
"this",
"->",
"doFormattingWithParsedFormat",
"(",
"$",
"dateTime",
",",
"$",
"th... | Returns dateTime formatted by custom format, string provided in parameter.
Format must obey syntax defined in CLDR specification, excluding
unimplemented features (see documentation for DatesReader class).
Format is remembered in this classes cache and won't be parsed again for
some time.
@param \DateTimeInterface $dateTime PHP object representing particular point in time
@param string $format Format string
@param Locale $locale A locale used for finding literals array
@return string Formatted date / time. Unimplemented subformats in format string will be silently ignored
@api
@see \Neos\Flow\I18n\Cldr\Reader\DatesReader | [
"Returns",
"dateTime",
"formatted",
"by",
"custom",
"format",
"string",
"provided",
"in",
"parameter",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/I18n/Formatter/DatetimeFormatter.php#L97-L100 |
neos/flow-development-collection | Neos.Flow/Classes/I18n/Formatter/DatetimeFormatter.php | DatetimeFormatter.formatDate | public function formatDate(\DateTimeInterface $date, Locale $locale, $formatLength = DatesReader::FORMAT_LENGTH_DEFAULT)
{
DatesReader::validateFormatLength($formatLength);
return $this->doFormattingWithParsedFormat($date, $this->datesReader->parseFormatFromCldr($locale, DatesReader::FORMAT_TYPE_DATE, $formatLength), $this->datesReader->getLocalizedLiteralsForLocale($locale));
} | php | public function formatDate(\DateTimeInterface $date, Locale $locale, $formatLength = DatesReader::FORMAT_LENGTH_DEFAULT)
{
DatesReader::validateFormatLength($formatLength);
return $this->doFormattingWithParsedFormat($date, $this->datesReader->parseFormatFromCldr($locale, DatesReader::FORMAT_TYPE_DATE, $formatLength), $this->datesReader->getLocalizedLiteralsForLocale($locale));
} | [
"public",
"function",
"formatDate",
"(",
"\\",
"DateTimeInterface",
"$",
"date",
",",
"Locale",
"$",
"locale",
",",
"$",
"formatLength",
"=",
"DatesReader",
"::",
"FORMAT_LENGTH_DEFAULT",
")",
"{",
"DatesReader",
"::",
"validateFormatLength",
"(",
"$",
"formatLeng... | Formats date with format string for date defined in CLDR for particular
locale.
@param \DateTimeInterface $date PHP object representing particular point in time
@param Locale $locale
@param string $formatLength One of DatesReader FORMAT_LENGTH constants
@return string Formatted date
@api | [
"Formats",
"date",
"with",
"format",
"string",
"for",
"date",
"defined",
"in",
"CLDR",
"for",
"particular",
"locale",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/I18n/Formatter/DatetimeFormatter.php#L112-L116 |
neos/flow-development-collection | Neos.Flow/Classes/I18n/Formatter/DatetimeFormatter.php | DatetimeFormatter.formatTime | public function formatTime(\DateTimeInterface $time, Locale $locale, $formatLength = DatesReader::FORMAT_LENGTH_DEFAULT)
{
DatesReader::validateFormatLength($formatLength);
return $this->doFormattingWithParsedFormat($time, $this->datesReader->parseFormatFromCldr($locale, DatesReader::FORMAT_TYPE_TIME, $formatLength), $this->datesReader->getLocalizedLiteralsForLocale($locale));
} | php | public function formatTime(\DateTimeInterface $time, Locale $locale, $formatLength = DatesReader::FORMAT_LENGTH_DEFAULT)
{
DatesReader::validateFormatLength($formatLength);
return $this->doFormattingWithParsedFormat($time, $this->datesReader->parseFormatFromCldr($locale, DatesReader::FORMAT_TYPE_TIME, $formatLength), $this->datesReader->getLocalizedLiteralsForLocale($locale));
} | [
"public",
"function",
"formatTime",
"(",
"\\",
"DateTimeInterface",
"$",
"time",
",",
"Locale",
"$",
"locale",
",",
"$",
"formatLength",
"=",
"DatesReader",
"::",
"FORMAT_LENGTH_DEFAULT",
")",
"{",
"DatesReader",
"::",
"validateFormatLength",
"(",
"$",
"formatLeng... | Formats time with format string for time defined in CLDR for particular
locale.
@param \DateTimeInterface $time PHP object representing particular point in time
@param Locale $locale
@param string $formatLength One of DatesReader FORMAT_LENGTH constants
@return string Formatted time
@api | [
"Formats",
"time",
"with",
"format",
"string",
"for",
"time",
"defined",
"in",
"CLDR",
"for",
"particular",
"locale",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/I18n/Formatter/DatetimeFormatter.php#L128-L132 |
neos/flow-development-collection | Neos.Flow/Classes/I18n/Formatter/DatetimeFormatter.php | DatetimeFormatter.formatDateTime | public function formatDateTime(\DateTimeInterface $dateTime, Locale $locale, $formatLength = DatesReader::FORMAT_LENGTH_DEFAULT)
{
DatesReader::validateFormatLength($formatLength);
return $this->doFormattingWithParsedFormat($dateTime, $this->datesReader->parseFormatFromCldr($locale, DatesReader::FORMAT_TYPE_DATETIME, $formatLength), $this->datesReader->getLocalizedLiteralsForLocale($locale));
} | php | public function formatDateTime(\DateTimeInterface $dateTime, Locale $locale, $formatLength = DatesReader::FORMAT_LENGTH_DEFAULT)
{
DatesReader::validateFormatLength($formatLength);
return $this->doFormattingWithParsedFormat($dateTime, $this->datesReader->parseFormatFromCldr($locale, DatesReader::FORMAT_TYPE_DATETIME, $formatLength), $this->datesReader->getLocalizedLiteralsForLocale($locale));
} | [
"public",
"function",
"formatDateTime",
"(",
"\\",
"DateTimeInterface",
"$",
"dateTime",
",",
"Locale",
"$",
"locale",
",",
"$",
"formatLength",
"=",
"DatesReader",
"::",
"FORMAT_LENGTH_DEFAULT",
")",
"{",
"DatesReader",
"::",
"validateFormatLength",
"(",
"$",
"fo... | Formats dateTime with format string for date and time defined in CLDR for
particular locale.
First date and time are formatted separately, and then dateTime format
from CLDR is used to place date and time in correct order.
@param \DateTimeInterface $dateTime PHP object representing particular point in time
@param Locale $locale
@param string $formatLength One of DatesReader FORMAT_LENGTH constants
@return string Formatted date and time
@api | [
"Formats",
"dateTime",
"with",
"format",
"string",
"for",
"date",
"and",
"time",
"defined",
"in",
"CLDR",
"for",
"particular",
"locale",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/I18n/Formatter/DatetimeFormatter.php#L147-L151 |
neos/flow-development-collection | Neos.Flow/Classes/I18n/Formatter/DatetimeFormatter.php | DatetimeFormatter.doFormattingWithParsedFormat | protected function doFormattingWithParsedFormat(\DateTimeInterface $dateTime, array $parsedFormat, array $localizedLiterals)
{
$formattedDateTime = '';
foreach ($parsedFormat as $subformat) {
if (is_array($subformat)) {
// This is just a simple string we use literally
$formattedDateTime .= $subformat[0];
} else {
$formattedDateTime .= $this->doFormattingForSubpattern($dateTime, $subformat, $localizedLiterals);
}
}
return $formattedDateTime;
} | php | protected function doFormattingWithParsedFormat(\DateTimeInterface $dateTime, array $parsedFormat, array $localizedLiterals)
{
$formattedDateTime = '';
foreach ($parsedFormat as $subformat) {
if (is_array($subformat)) {
// This is just a simple string we use literally
$formattedDateTime .= $subformat[0];
} else {
$formattedDateTime .= $this->doFormattingForSubpattern($dateTime, $subformat, $localizedLiterals);
}
}
return $formattedDateTime;
} | [
"protected",
"function",
"doFormattingWithParsedFormat",
"(",
"\\",
"DateTimeInterface",
"$",
"dateTime",
",",
"array",
"$",
"parsedFormat",
",",
"array",
"$",
"localizedLiterals",
")",
"{",
"$",
"formattedDateTime",
"=",
"''",
";",
"foreach",
"(",
"$",
"parsedFor... | Formats provided dateTime object.
Format rules defined in $parsedFormat array are used. Localizable literals
are replaced with elements from $localizedLiterals array.
@param \DateTimeInterface $dateTime PHP object representing particular point in time
@param array $parsedFormat An array describing format (as in $parsedFormats property)
@param array $localizedLiterals An array with literals to use (as in $localizedLiterals property)
@return string Formatted date / time | [
"Formats",
"provided",
"dateTime",
"object",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/I18n/Formatter/DatetimeFormatter.php#L164-L178 |
neos/flow-development-collection | Neos.Flow/Classes/I18n/Formatter/DatetimeFormatter.php | DatetimeFormatter.doFormattingForSubpattern | protected function doFormattingForSubpattern(\DateTimeInterface $dateTime, $subformat, array $localizedLiterals)
{
$formatLengthOfSubformat = strlen($subformat);
switch ($subformat[0]) {
case 'h':
return $this->padString($dateTime->format('g'), $formatLengthOfSubformat);
case 'H':
return $this->padString($dateTime->format('G'), $formatLengthOfSubformat);
case 'K':
$hour = (int)($dateTime->format('g'));
if ($hour === 12) {
$hour = 0;
}
return $this->padString($hour, $formatLengthOfSubformat);
case 'k':
$hour = (int)($dateTime->format('G'));
if ($hour === 0) {
$hour = 24;
}
return $this->padString($hour, $formatLengthOfSubformat);
case 'a':
return $localizedLiterals['dayPeriods']['format']['wide'][$dateTime->format('a')];
case 'm':
return $this->padString((int)($dateTime->format('i')), $formatLengthOfSubformat);
case 's':
return $this->padString((int)($dateTime->format('s')), $formatLengthOfSubformat);
case 'S':
return (string)round($dateTime->format('u'), $formatLengthOfSubformat);
case 'd':
return $this->padString($dateTime->format('j'), $formatLengthOfSubformat);
case 'D':
return $this->padString((int)($dateTime->format('z') + 1), $formatLengthOfSubformat);
case 'F':
return (int)(($dateTime->format('j') + 6) / 7);
case 'M':
case 'L':
$month = (int)$dateTime->format('n');
$formatType = ($subformat[0] === 'L') ? 'stand-alone' : 'format';
if ($formatLengthOfSubformat <= 2) {
return $this->padString($month, $formatLengthOfSubformat);
} elseif ($formatLengthOfSubformat === 3) {
return $localizedLiterals['months'][$formatType]['abbreviated'][$month];
} elseif ($formatLengthOfSubformat === 4) {
return $localizedLiterals['months'][$formatType]['wide'][$month];
} else {
return $localizedLiterals['months'][$formatType]['narrow'][$month];
}
case 'y':
$year = (int)$dateTime->format('Y');
if ($formatLengthOfSubformat === 2) {
$year %= 100;
}
return $this->padString($year, $formatLengthOfSubformat);
case 'E':
$day = strtolower($dateTime->format('D'));
if ($formatLengthOfSubformat <= 3) {
return $localizedLiterals['days']['format']['abbreviated'][$day];
} elseif ($formatLengthOfSubformat === 4) {
return $localizedLiterals['days']['format']['wide'][$day];
} else {
return $localizedLiterals['days']['format']['narrow'][$day];
}
case 'w':
return $this->padString($dateTime->format('W'), $formatLengthOfSubformat);
case 'W':
return (string)((((int)$dateTime->format('W') - 1) % 4) + 1);
case 'Q':
case 'q':
$quarter = (int)($dateTime->format('n') / 3.1) + 1;
$formatType = ($subformat[0] === 'q') ? 'stand-alone' : 'format';
if ($formatLengthOfSubformat <= 2) {
return $this->padString($quarter, $formatLengthOfSubformat);
} elseif ($formatLengthOfSubformat === 3) {
return $localizedLiterals['quarters'][$formatType]['abbreviated'][$quarter];
} else {
return $localizedLiterals['quarters'][$formatType]['wide'][$quarter];
}
case 'G':
$era = (int)($dateTime->format('Y') > 0);
if ($formatLengthOfSubformat <= 3) {
return $localizedLiterals['eras']['eraAbbr'][$era];
} elseif ($formatLengthOfSubformat === 4) {
return $localizedLiterals['eras']['eraNames'][$era];
} else {
return $localizedLiterals['eras']['eraNarrow'][$era];
}
case 'v':
case 'z':
if ($formatLengthOfSubformat <= 3) {
return $dateTime->format('T');
} else {
return $dateTime->format('e');
}
case 'Y':
case 'u':
case 'l':
case 'g':
case 'e':
case 'c':
case 'A':
case 'Z':
case 'V':
// Silently ignore unsupported formats
return '';
default:
throw new InvalidArgumentException('Unexpected format symbol, "' . $subformat[0] . '" detected for date / time formatting.', 1276106678);
}
} | php | protected function doFormattingForSubpattern(\DateTimeInterface $dateTime, $subformat, array $localizedLiterals)
{
$formatLengthOfSubformat = strlen($subformat);
switch ($subformat[0]) {
case 'h':
return $this->padString($dateTime->format('g'), $formatLengthOfSubformat);
case 'H':
return $this->padString($dateTime->format('G'), $formatLengthOfSubformat);
case 'K':
$hour = (int)($dateTime->format('g'));
if ($hour === 12) {
$hour = 0;
}
return $this->padString($hour, $formatLengthOfSubformat);
case 'k':
$hour = (int)($dateTime->format('G'));
if ($hour === 0) {
$hour = 24;
}
return $this->padString($hour, $formatLengthOfSubformat);
case 'a':
return $localizedLiterals['dayPeriods']['format']['wide'][$dateTime->format('a')];
case 'm':
return $this->padString((int)($dateTime->format('i')), $formatLengthOfSubformat);
case 's':
return $this->padString((int)($dateTime->format('s')), $formatLengthOfSubformat);
case 'S':
return (string)round($dateTime->format('u'), $formatLengthOfSubformat);
case 'd':
return $this->padString($dateTime->format('j'), $formatLengthOfSubformat);
case 'D':
return $this->padString((int)($dateTime->format('z') + 1), $formatLengthOfSubformat);
case 'F':
return (int)(($dateTime->format('j') + 6) / 7);
case 'M':
case 'L':
$month = (int)$dateTime->format('n');
$formatType = ($subformat[0] === 'L') ? 'stand-alone' : 'format';
if ($formatLengthOfSubformat <= 2) {
return $this->padString($month, $formatLengthOfSubformat);
} elseif ($formatLengthOfSubformat === 3) {
return $localizedLiterals['months'][$formatType]['abbreviated'][$month];
} elseif ($formatLengthOfSubformat === 4) {
return $localizedLiterals['months'][$formatType]['wide'][$month];
} else {
return $localizedLiterals['months'][$formatType]['narrow'][$month];
}
case 'y':
$year = (int)$dateTime->format('Y');
if ($formatLengthOfSubformat === 2) {
$year %= 100;
}
return $this->padString($year, $formatLengthOfSubformat);
case 'E':
$day = strtolower($dateTime->format('D'));
if ($formatLengthOfSubformat <= 3) {
return $localizedLiterals['days']['format']['abbreviated'][$day];
} elseif ($formatLengthOfSubformat === 4) {
return $localizedLiterals['days']['format']['wide'][$day];
} else {
return $localizedLiterals['days']['format']['narrow'][$day];
}
case 'w':
return $this->padString($dateTime->format('W'), $formatLengthOfSubformat);
case 'W':
return (string)((((int)$dateTime->format('W') - 1) % 4) + 1);
case 'Q':
case 'q':
$quarter = (int)($dateTime->format('n') / 3.1) + 1;
$formatType = ($subformat[0] === 'q') ? 'stand-alone' : 'format';
if ($formatLengthOfSubformat <= 2) {
return $this->padString($quarter, $formatLengthOfSubformat);
} elseif ($formatLengthOfSubformat === 3) {
return $localizedLiterals['quarters'][$formatType]['abbreviated'][$quarter];
} else {
return $localizedLiterals['quarters'][$formatType]['wide'][$quarter];
}
case 'G':
$era = (int)($dateTime->format('Y') > 0);
if ($formatLengthOfSubformat <= 3) {
return $localizedLiterals['eras']['eraAbbr'][$era];
} elseif ($formatLengthOfSubformat === 4) {
return $localizedLiterals['eras']['eraNames'][$era];
} else {
return $localizedLiterals['eras']['eraNarrow'][$era];
}
case 'v':
case 'z':
if ($formatLengthOfSubformat <= 3) {
return $dateTime->format('T');
} else {
return $dateTime->format('e');
}
case 'Y':
case 'u':
case 'l':
case 'g':
case 'e':
case 'c':
case 'A':
case 'Z':
case 'V':
// Silently ignore unsupported formats
return '';
default:
throw new InvalidArgumentException('Unexpected format symbol, "' . $subformat[0] . '" detected for date / time formatting.', 1276106678);
}
} | [
"protected",
"function",
"doFormattingForSubpattern",
"(",
"\\",
"DateTimeInterface",
"$",
"dateTime",
",",
"$",
"subformat",
",",
"array",
"$",
"localizedLiterals",
")",
"{",
"$",
"formatLengthOfSubformat",
"=",
"strlen",
"(",
"$",
"subformat",
")",
";",
"switch"... | Formats date or time element according to the subpattern provided.
Returns a string with formatted one "part" of DateTime object (seconds,
day, month etc).
Not all pattern symbols defined in CLDR are supported; some of the rules
are simplified. Please see the documentation for DatesReader for details.
Cases in the code are ordered in such way that probably mostly used are
on the top (but they are also grouped by similarity).
@param \DateTimeInterface $dateTime PHP object representing particular point in time
@param string $subformat One element of format string (e.g., 'yyyy', 'mm', etc)
@param array $localizedLiterals Array of date / time literals from CLDR
@return string Formatted part of date / time
@throws InvalidArgumentException When $subformat use symbol that is not recognized
@see \Neos\Flow\I18n\Cldr\Reader\DatesReader | [
"Formats",
"date",
"or",
"time",
"element",
"according",
"to",
"the",
"subpattern",
"provided",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/I18n/Formatter/DatetimeFormatter.php#L199-L307 |
neos/flow-development-collection | Neos.Flow/Classes/Mvc/FlashMessageContainer.php | FlashMessageContainer.getMessages | public function getMessages($severity = null)
{
if ($severity === null) {
return $this->messages;
}
$messages = [];
foreach ($this->messages as $message) {
if ($message->getSeverity() === $severity) {
$messages[] = $message;
}
}
return $messages;
} | php | public function getMessages($severity = null)
{
if ($severity === null) {
return $this->messages;
}
$messages = [];
foreach ($this->messages as $message) {
if ($message->getSeverity() === $severity) {
$messages[] = $message;
}
}
return $messages;
} | [
"public",
"function",
"getMessages",
"(",
"$",
"severity",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"severity",
"===",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"messages",
";",
"}",
"$",
"messages",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"thi... | Returns all currently stored flash messages.
@param string $severity severity of messages (from Message::SEVERITY_* constants) to return.
@return array<Message>
@api | [
"Returns",
"all",
"currently",
"stored",
"flash",
"messages",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Mvc/FlashMessageContainer.php#L50-L63 |
neos/flow-development-collection | Neos.Flow/Classes/Mvc/FlashMessageContainer.php | FlashMessageContainer.flush | public function flush($severity = null)
{
if ($severity === null) {
$this->messages = [];
} else {
foreach ($this->messages as $index => $message) {
if ($message->getSeverity() === $severity) {
unset($this->messages[$index]);
}
}
}
} | php | public function flush($severity = null)
{
if ($severity === null) {
$this->messages = [];
} else {
foreach ($this->messages as $index => $message) {
if ($message->getSeverity() === $severity) {
unset($this->messages[$index]);
}
}
}
} | [
"public",
"function",
"flush",
"(",
"$",
"severity",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"severity",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"messages",
"=",
"[",
"]",
";",
"}",
"else",
"{",
"foreach",
"(",
"$",
"this",
"->",
"messages",
"... | Remove messages from this container.
@param string $severity severity of messages (from Message::SEVERITY_* constants) to remove.
@return void
@Flow\Session(autoStart=true)
@api | [
"Remove",
"messages",
"from",
"this",
"container",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Mvc/FlashMessageContainer.php#L73-L84 |
neos/flow-development-collection | Neos.Flow/Classes/Mvc/FlashMessageContainer.php | FlashMessageContainer.getMessagesAndFlush | public function getMessagesAndFlush($severity = null)
{
$messages = $this->getMessages($severity);
if (count($messages) > 0) {
$this->flush($severity);
}
return $messages;
} | php | public function getMessagesAndFlush($severity = null)
{
$messages = $this->getMessages($severity);
if (count($messages) > 0) {
$this->flush($severity);
}
return $messages;
} | [
"public",
"function",
"getMessagesAndFlush",
"(",
"$",
"severity",
"=",
"null",
")",
"{",
"$",
"messages",
"=",
"$",
"this",
"->",
"getMessages",
"(",
"$",
"severity",
")",
";",
"if",
"(",
"count",
"(",
"$",
"messages",
")",
">",
"0",
")",
"{",
"$",
... | Get all flash messages (with given severity) currently available and remove them from the container.
@param string $severity severity of the messages (One of the Message::SEVERITY_* constants)
@return array<Message>
@api | [
"Get",
"all",
"flash",
"messages",
"(",
"with",
"given",
"severity",
")",
"currently",
"available",
"and",
"remove",
"them",
"from",
"the",
"container",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Mvc/FlashMessageContainer.php#L93-L100 |
neos/flow-development-collection | Neos.Flow/Classes/Package/PackageOrderResolver.php | PackageOrderResolver.sort | public function sort()
{
if ($this->sortedPackages === null) {
$this->sortedPackages = [];
reset($this->unsortedPackages);
while (!empty($this->unsortedPackages)) {
$resolved = $this->sortPackage(key($this->unsortedPackages));
if ($resolved) {
reset($this->unsortedPackages);
} else {
next($this->unsortedPackages);
}
}
}
return $this->sortedPackages;
} | php | public function sort()
{
if ($this->sortedPackages === null) {
$this->sortedPackages = [];
reset($this->unsortedPackages);
while (!empty($this->unsortedPackages)) {
$resolved = $this->sortPackage(key($this->unsortedPackages));
if ($resolved) {
reset($this->unsortedPackages);
} else {
next($this->unsortedPackages);
}
}
}
return $this->sortedPackages;
} | [
"public",
"function",
"sort",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"sortedPackages",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"sortedPackages",
"=",
"[",
"]",
";",
"reset",
"(",
"$",
"this",
"->",
"unsortedPackages",
")",
";",
"while",
"("... | Sorts the packages and returns the sorted packages array
@return array | [
"Sorts",
"the",
"packages",
"and",
"returns",
"the",
"sorted",
"packages",
"array"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Package/PackageOrderResolver.php#L48-L64 |
neos/flow-development-collection | Neos.Flow/Classes/Package/PackageOrderResolver.php | PackageOrderResolver.sortPackage | protected function sortPackage($packageKey)
{
if (!isset($this->packageStates[$packageKey])) {
// Package does not exist; so that means it is just skipped; but that's to the outside as if sorting was successful.
return true;
}
if (!isset($this->unsortedPackages[$packageKey])) {
// Safeguard: Package is not unsorted anymore.
return true;
}
$iterationForPackage = $this->unsortedPackages[$packageKey];
// $iterationForPackage will be -1 if the package is already worked on in a stack, in that case we will return instantly.
if ($iterationForPackage === -1) {
return false;
}
$this->unsortedPackages[$packageKey] = -1;
$packageComposerManifest = $this->manifestData[$packageKey];
$unresolvedDependencies = 0;
$packageRequirements = isset($packageComposerManifest['require']) ? array_keys($packageComposerManifest['require']) : [];
$unresolvedDependencies += $this->sortListBefore($packageKey, $packageRequirements);
if (isset($packageComposerManifest['extra']['neos']['loading-order']['after']) && is_array($packageComposerManifest['extra']['neos']['loading-order']['after'])) {
$sortingConfiguration = $packageComposerManifest['extra']['neos']['loading-order']['after'];
$unresolvedDependencies += $this->sortListBefore($packageKey, $sortingConfiguration);
}
/** @var array $packageState */
$packageState = $this->packageStates[$packageKey];
$this->unsortedPackages[$packageKey] = $iterationForPackage + 1;
if ($unresolvedDependencies === 0) {
// we are validly able to sort the package to this position.
unset($this->unsortedPackages[$packageKey]);
$this->sortedPackages[$packageKey] = $packageState;
return true;
}
if ($this->unsortedPackages[$packageKey] > 20) {
// SECOND case: ERROR case. This happens with MANY cyclic dependencies, in this case we just degrade by arbitarily sorting the package; and continue. Alternative would be throwing an Exception.
unset($this->unsortedPackages[$packageKey]);
// In order to be able to debug this kind of error (if we hit it), we at least try to write to PackageStates.php
// so if people send it to us, we have some chance of finding the error.
$packageState['error-sorting-limit-reached'] = true;
$this->sortedPackages[$packageKey] = $packageState;
return true;
}
return false;
} | php | protected function sortPackage($packageKey)
{
if (!isset($this->packageStates[$packageKey])) {
// Package does not exist; so that means it is just skipped; but that's to the outside as if sorting was successful.
return true;
}
if (!isset($this->unsortedPackages[$packageKey])) {
// Safeguard: Package is not unsorted anymore.
return true;
}
$iterationForPackage = $this->unsortedPackages[$packageKey];
// $iterationForPackage will be -1 if the package is already worked on in a stack, in that case we will return instantly.
if ($iterationForPackage === -1) {
return false;
}
$this->unsortedPackages[$packageKey] = -1;
$packageComposerManifest = $this->manifestData[$packageKey];
$unresolvedDependencies = 0;
$packageRequirements = isset($packageComposerManifest['require']) ? array_keys($packageComposerManifest['require']) : [];
$unresolvedDependencies += $this->sortListBefore($packageKey, $packageRequirements);
if (isset($packageComposerManifest['extra']['neos']['loading-order']['after']) && is_array($packageComposerManifest['extra']['neos']['loading-order']['after'])) {
$sortingConfiguration = $packageComposerManifest['extra']['neos']['loading-order']['after'];
$unresolvedDependencies += $this->sortListBefore($packageKey, $sortingConfiguration);
}
/** @var array $packageState */
$packageState = $this->packageStates[$packageKey];
$this->unsortedPackages[$packageKey] = $iterationForPackage + 1;
if ($unresolvedDependencies === 0) {
// we are validly able to sort the package to this position.
unset($this->unsortedPackages[$packageKey]);
$this->sortedPackages[$packageKey] = $packageState;
return true;
}
if ($this->unsortedPackages[$packageKey] > 20) {
// SECOND case: ERROR case. This happens with MANY cyclic dependencies, in this case we just degrade by arbitarily sorting the package; and continue. Alternative would be throwing an Exception.
unset($this->unsortedPackages[$packageKey]);
// In order to be able to debug this kind of error (if we hit it), we at least try to write to PackageStates.php
// so if people send it to us, we have some chance of finding the error.
$packageState['error-sorting-limit-reached'] = true;
$this->sortedPackages[$packageKey] = $packageState;
return true;
}
return false;
} | [
"protected",
"function",
"sortPackage",
"(",
"$",
"packageKey",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"packageStates",
"[",
"$",
"packageKey",
"]",
")",
")",
"{",
"// Package does not exist; so that means it is just skipped; but that's to the outs... | Recursively sort dependencies of a package. This is a depth-first approach that recursively
adds all dependent packages to the sorted list before adding the given package. Visited
packages are flagged to break up cyclic dependencies.
@param string $packageKey Package key to process
@return boolean true if package was sorted; false otherwise. | [
"Recursively",
"sort",
"dependencies",
"of",
"a",
"package",
".",
"This",
"is",
"a",
"depth",
"-",
"first",
"approach",
"that",
"recursively",
"adds",
"all",
"dependent",
"packages",
"to",
"the",
"sorted",
"list",
"before",
"adding",
"the",
"given",
"package",... | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Package/PackageOrderResolver.php#L74-L125 |
neos/flow-development-collection | Neos.Flow/Classes/Package/PackageOrderResolver.php | PackageOrderResolver.sortListBefore | protected function sortListBefore($packageKey, array $packagesToLoadBefore)
{
$unresolvedDependencies = 0;
foreach ($packagesToLoadBefore as $composerNameToLoadBefore) {
if (!$this->packageRequirementIsComposerPackage($composerNameToLoadBefore)) {
continue;
}
if (isset($this->sortedPackages[$packageKey])) {
// "Success" case: a required package is already sorted in front of our current $packageKey.
continue;
}
if (isset($this->unsortedPackages[$composerNameToLoadBefore])) {
$resolved = $this->sortPackage($composerNameToLoadBefore);
if (!$resolved) {
$unresolvedDependencies++;
}
}
}
return $unresolvedDependencies;
} | php | protected function sortListBefore($packageKey, array $packagesToLoadBefore)
{
$unresolvedDependencies = 0;
foreach ($packagesToLoadBefore as $composerNameToLoadBefore) {
if (!$this->packageRequirementIsComposerPackage($composerNameToLoadBefore)) {
continue;
}
if (isset($this->sortedPackages[$packageKey])) {
// "Success" case: a required package is already sorted in front of our current $packageKey.
continue;
}
if (isset($this->unsortedPackages[$composerNameToLoadBefore])) {
$resolved = $this->sortPackage($composerNameToLoadBefore);
if (!$resolved) {
$unresolvedDependencies++;
}
}
}
return $unresolvedDependencies;
} | [
"protected",
"function",
"sortListBefore",
"(",
"$",
"packageKey",
",",
"array",
"$",
"packagesToLoadBefore",
")",
"{",
"$",
"unresolvedDependencies",
"=",
"0",
";",
"foreach",
"(",
"$",
"packagesToLoadBefore",
"as",
"$",
"composerNameToLoadBefore",
")",
"{",
"if"... | Tries to sort packages from the given list before the named package key.
Ignores non existing packages and any composer key without "/" (eg. "php").
@param string $packageKey
@param string[] $packagesToLoadBefore
@return int | [
"Tries",
"to",
"sort",
"packages",
"from",
"the",
"given",
"list",
"before",
"the",
"named",
"package",
"key",
".",
"Ignores",
"non",
"existing",
"packages",
"and",
"any",
"composer",
"key",
"without",
"/",
"(",
"eg",
".",
"php",
")",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Package/PackageOrderResolver.php#L135-L157 |
neos/flow-development-collection | Neos.Flow/Classes/ObjectManagement/Proxy/ObjectSerializationTrait.php | ObjectSerializationTrait.Flow_serializeRelatedEntities | private function Flow_serializeRelatedEntities(array $transientProperties, array $propertyVarTags)
{
$reflectedClass = new \ReflectionClass(__CLASS__);
$allReflectedProperties = $reflectedClass->getProperties();
foreach ($allReflectedProperties as $reflectionProperty) {
$propertyName = $reflectionProperty->name;
if (in_array($propertyName, [
'Flow_Aop_Proxy_targetMethodsAndGroupedAdvices',
'Flow_Aop_Proxy_groupedAdviceChains',
'Flow_Aop_Proxy_methodIsInAdviceMode'
])) {
continue;
}
if (isset($this->Flow_Injected_Properties) && is_array($this->Flow_Injected_Properties) && in_array($propertyName, $this->Flow_Injected_Properties)) {
continue;
}
if ($reflectionProperty->isStatic() || in_array($propertyName, $transientProperties)) {
continue;
}
if (is_array($this->$propertyName) || (is_object($this->$propertyName) && ($this->$propertyName instanceof \ArrayObject || $this->$propertyName instanceof \SplObjectStorage || $this->$propertyName instanceof Collection))) {
if (count($this->$propertyName) > 0) {
foreach ($this->$propertyName as $key => $value) {
$this->Flow_searchForEntitiesAndStoreIdentifierArray((string)$key, $value, $propertyName);
}
}
}
if (is_object($this->$propertyName) && !$this->$propertyName instanceof Collection) {
if ($this->$propertyName instanceof OrmProxy) {
$className = get_parent_class($this->$propertyName);
} else {
if (isset($propertyVarTags[$propertyName])) {
$className = trim($propertyVarTags[$propertyName], '\\');
}
if (Bootstrap::$staticObjectManager->isRegistered($className) === false) {
$className = Bootstrap::$staticObjectManager->getObjectNameByClassName(get_class($this->$propertyName));
}
}
if ($this->$propertyName instanceof PersistenceMagicInterface && !Bootstrap::$staticObjectManager->get(PersistenceManagerInterface::class)->isNewObject($this->$propertyName) || $this->$propertyName instanceof OrmProxy) {
if (!property_exists($this, 'Flow_Persistence_RelatedEntities') || !is_array($this->Flow_Persistence_RelatedEntities)) {
$this->Flow_Persistence_RelatedEntities = [];
$this->Flow_Object_PropertiesToSerialize[] = 'Flow_Persistence_RelatedEntities';
}
$identifier = Bootstrap::$staticObjectManager->get(PersistenceManagerInterface::class)->getIdentifierByObject($this->$propertyName);
if (!$identifier && $this->$propertyName instanceof OrmProxy) {
$identifier = current(ObjectAccess::getProperty($this->$propertyName, '_identifier', true));
}
$this->Flow_Persistence_RelatedEntities[$propertyName] = [
'propertyName' => $propertyName,
'entityType' => $className,
'identifier' => $identifier
];
continue;
}
if ($className !== false && (Bootstrap::$staticObjectManager->getScope($className) === Configuration::SCOPE_SINGLETON || $className === DependencyProxy::class)) {
continue;
}
}
$this->Flow_Object_PropertiesToSerialize[] = $propertyName;
}
return $this->Flow_Object_PropertiesToSerialize;
} | php | private function Flow_serializeRelatedEntities(array $transientProperties, array $propertyVarTags)
{
$reflectedClass = new \ReflectionClass(__CLASS__);
$allReflectedProperties = $reflectedClass->getProperties();
foreach ($allReflectedProperties as $reflectionProperty) {
$propertyName = $reflectionProperty->name;
if (in_array($propertyName, [
'Flow_Aop_Proxy_targetMethodsAndGroupedAdvices',
'Flow_Aop_Proxy_groupedAdviceChains',
'Flow_Aop_Proxy_methodIsInAdviceMode'
])) {
continue;
}
if (isset($this->Flow_Injected_Properties) && is_array($this->Flow_Injected_Properties) && in_array($propertyName, $this->Flow_Injected_Properties)) {
continue;
}
if ($reflectionProperty->isStatic() || in_array($propertyName, $transientProperties)) {
continue;
}
if (is_array($this->$propertyName) || (is_object($this->$propertyName) && ($this->$propertyName instanceof \ArrayObject || $this->$propertyName instanceof \SplObjectStorage || $this->$propertyName instanceof Collection))) {
if (count($this->$propertyName) > 0) {
foreach ($this->$propertyName as $key => $value) {
$this->Flow_searchForEntitiesAndStoreIdentifierArray((string)$key, $value, $propertyName);
}
}
}
if (is_object($this->$propertyName) && !$this->$propertyName instanceof Collection) {
if ($this->$propertyName instanceof OrmProxy) {
$className = get_parent_class($this->$propertyName);
} else {
if (isset($propertyVarTags[$propertyName])) {
$className = trim($propertyVarTags[$propertyName], '\\');
}
if (Bootstrap::$staticObjectManager->isRegistered($className) === false) {
$className = Bootstrap::$staticObjectManager->getObjectNameByClassName(get_class($this->$propertyName));
}
}
if ($this->$propertyName instanceof PersistenceMagicInterface && !Bootstrap::$staticObjectManager->get(PersistenceManagerInterface::class)->isNewObject($this->$propertyName) || $this->$propertyName instanceof OrmProxy) {
if (!property_exists($this, 'Flow_Persistence_RelatedEntities') || !is_array($this->Flow_Persistence_RelatedEntities)) {
$this->Flow_Persistence_RelatedEntities = [];
$this->Flow_Object_PropertiesToSerialize[] = 'Flow_Persistence_RelatedEntities';
}
$identifier = Bootstrap::$staticObjectManager->get(PersistenceManagerInterface::class)->getIdentifierByObject($this->$propertyName);
if (!$identifier && $this->$propertyName instanceof OrmProxy) {
$identifier = current(ObjectAccess::getProperty($this->$propertyName, '_identifier', true));
}
$this->Flow_Persistence_RelatedEntities[$propertyName] = [
'propertyName' => $propertyName,
'entityType' => $className,
'identifier' => $identifier
];
continue;
}
if ($className !== false && (Bootstrap::$staticObjectManager->getScope($className) === Configuration::SCOPE_SINGLETON || $className === DependencyProxy::class)) {
continue;
}
}
$this->Flow_Object_PropertiesToSerialize[] = $propertyName;
}
return $this->Flow_Object_PropertiesToSerialize;
} | [
"private",
"function",
"Flow_serializeRelatedEntities",
"(",
"array",
"$",
"transientProperties",
",",
"array",
"$",
"propertyVarTags",
")",
"{",
"$",
"reflectedClass",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"__CLASS__",
")",
";",
"$",
"allReflectedProperties",
"... | Code to find and serialize entities on sleep
@param array $transientProperties
@param array $propertyVarTags
@return array | [
"Code",
"to",
"find",
"and",
"serialize",
"entities",
"on",
"sleep"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ObjectManagement/Proxy/ObjectSerializationTrait.php#L37-L98 |
neos/flow-development-collection | Neos.Flow/Classes/ObjectManagement/Proxy/ObjectSerializationTrait.php | ObjectSerializationTrait.Flow_searchForEntitiesAndStoreIdentifierArray | private function Flow_searchForEntitiesAndStoreIdentifierArray($path, $propertyValue, $originalPropertyName)
{
if (is_array($propertyValue) || (is_object($propertyValue) && ($propertyValue instanceof \ArrayObject || $propertyValue instanceof \SplObjectStorage))) {
foreach ($propertyValue as $key => $value) {
$this->Flow_searchForEntitiesAndStoreIdentifierArray($path . '.' . $key, $value, $originalPropertyName);
}
} elseif ($propertyValue instanceof PersistenceMagicInterface && !Bootstrap::$staticObjectManager->get(PersistenceManagerInterface::class)->isNewObject($propertyValue) || $propertyValue instanceof OrmProxy) {
if (!property_exists($this, 'Flow_Persistence_RelatedEntities') || !is_array($this->Flow_Persistence_RelatedEntities)) {
$this->Flow_Persistence_RelatedEntities = [];
$this->Flow_Object_PropertiesToSerialize[] = 'Flow_Persistence_RelatedEntities';
}
if ($propertyValue instanceof OrmProxy) {
$className = get_parent_class($propertyValue);
} else {
$className = Bootstrap::$staticObjectManager->getObjectNameByClassName(get_class($propertyValue));
}
$identifier = Bootstrap::$staticObjectManager->get(PersistenceManagerInterface::class)->getIdentifierByObject($propertyValue);
if (!$identifier && $propertyValue instanceof OrmProxy) {
$identifier = current(ObjectAccess::getProperty($propertyValue, '_identifier', true));
}
$this->Flow_Persistence_RelatedEntities[$originalPropertyName . '.' . $path] = [
'propertyName' => $originalPropertyName,
'entityType' => $className,
'identifier' => $identifier,
'entityPath' => $path
];
$this->$originalPropertyName = Arrays::setValueByPath($this->$originalPropertyName, $path, null);
}
} | php | private function Flow_searchForEntitiesAndStoreIdentifierArray($path, $propertyValue, $originalPropertyName)
{
if (is_array($propertyValue) || (is_object($propertyValue) && ($propertyValue instanceof \ArrayObject || $propertyValue instanceof \SplObjectStorage))) {
foreach ($propertyValue as $key => $value) {
$this->Flow_searchForEntitiesAndStoreIdentifierArray($path . '.' . $key, $value, $originalPropertyName);
}
} elseif ($propertyValue instanceof PersistenceMagicInterface && !Bootstrap::$staticObjectManager->get(PersistenceManagerInterface::class)->isNewObject($propertyValue) || $propertyValue instanceof OrmProxy) {
if (!property_exists($this, 'Flow_Persistence_RelatedEntities') || !is_array($this->Flow_Persistence_RelatedEntities)) {
$this->Flow_Persistence_RelatedEntities = [];
$this->Flow_Object_PropertiesToSerialize[] = 'Flow_Persistence_RelatedEntities';
}
if ($propertyValue instanceof OrmProxy) {
$className = get_parent_class($propertyValue);
} else {
$className = Bootstrap::$staticObjectManager->getObjectNameByClassName(get_class($propertyValue));
}
$identifier = Bootstrap::$staticObjectManager->get(PersistenceManagerInterface::class)->getIdentifierByObject($propertyValue);
if (!$identifier && $propertyValue instanceof OrmProxy) {
$identifier = current(ObjectAccess::getProperty($propertyValue, '_identifier', true));
}
$this->Flow_Persistence_RelatedEntities[$originalPropertyName . '.' . $path] = [
'propertyName' => $originalPropertyName,
'entityType' => $className,
'identifier' => $identifier,
'entityPath' => $path
];
$this->$originalPropertyName = Arrays::setValueByPath($this->$originalPropertyName, $path, null);
}
} | [
"private",
"function",
"Flow_searchForEntitiesAndStoreIdentifierArray",
"(",
"$",
"path",
",",
"$",
"propertyValue",
",",
"$",
"originalPropertyName",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"propertyValue",
")",
"||",
"(",
"is_object",
"(",
"$",
"propertyValue... | Serialize entities that are inside an array or SplObjectStorage
@param string $path
@param mixed $propertyValue
@param string $originalPropertyName
@return void | [
"Serialize",
"entities",
"that",
"are",
"inside",
"an",
"array",
"or",
"SplObjectStorage"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ObjectManagement/Proxy/ObjectSerializationTrait.php#L108-L136 |
neos/flow-development-collection | Neos.Flow/Classes/ObjectManagement/Proxy/ObjectSerializationTrait.php | ObjectSerializationTrait.Flow_setRelatedEntities | private function Flow_setRelatedEntities()
{
if (property_exists($this, 'Flow_Persistence_RelatedEntities') && is_array($this->Flow_Persistence_RelatedEntities)) {
$persistenceManager = Bootstrap::$staticObjectManager->get(PersistenceManagerInterface::class);
foreach ($this->Flow_Persistence_RelatedEntities as $entityInformation) {
$entity = $persistenceManager->getObjectByIdentifier($entityInformation['identifier'], $entityInformation['entityType'], true);
if (isset($entityInformation['entityPath'])) {
$this->{$entityInformation['propertyName']} = Arrays::setValueByPath($this->{$entityInformation['propertyName']}, $entityInformation['entityPath'], $entity);
} else {
$this->{$entityInformation['propertyName']} = $entity;
}
}
unset($this->Flow_Persistence_RelatedEntities);
}
} | php | private function Flow_setRelatedEntities()
{
if (property_exists($this, 'Flow_Persistence_RelatedEntities') && is_array($this->Flow_Persistence_RelatedEntities)) {
$persistenceManager = Bootstrap::$staticObjectManager->get(PersistenceManagerInterface::class);
foreach ($this->Flow_Persistence_RelatedEntities as $entityInformation) {
$entity = $persistenceManager->getObjectByIdentifier($entityInformation['identifier'], $entityInformation['entityType'], true);
if (isset($entityInformation['entityPath'])) {
$this->{$entityInformation['propertyName']} = Arrays::setValueByPath($this->{$entityInformation['propertyName']}, $entityInformation['entityPath'], $entity);
} else {
$this->{$entityInformation['propertyName']} = $entity;
}
}
unset($this->Flow_Persistence_RelatedEntities);
}
} | [
"private",
"function",
"Flow_setRelatedEntities",
"(",
")",
"{",
"if",
"(",
"property_exists",
"(",
"$",
"this",
",",
"'Flow_Persistence_RelatedEntities'",
")",
"&&",
"is_array",
"(",
"$",
"this",
"->",
"Flow_Persistence_RelatedEntities",
")",
")",
"{",
"$",
"pers... | Reconstitues related entities to an unserialized object in __wakeup.
Used in __wakeup methods of proxy classes.
Note: This method adds code which ignores objects of type Neos\Flow\ResourceManagement\ResourcePointer in order to provide
backwards compatibility data generated with Flow 2.2.x which still provided that class.
@return void | [
"Reconstitues",
"related",
"entities",
"to",
"an",
"unserialized",
"object",
"in",
"__wakeup",
".",
"Used",
"in",
"__wakeup",
"methods",
"of",
"proxy",
"classes",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ObjectManagement/Proxy/ObjectSerializationTrait.php#L147-L161 |
neos/flow-development-collection | Neos.Flow/Classes/Validation/Validator/AbstractValidator.php | AbstractValidator.pushResult | protected function pushResult()
{
if ($this->result !== null) {
array_push($this->resultStack, $this->result);
}
$this->result = new ErrorResult();
return $this->result;
} | php | protected function pushResult()
{
if ($this->result !== null) {
array_push($this->resultStack, $this->result);
}
$this->result = new ErrorResult();
return $this->result;
} | [
"protected",
"function",
"pushResult",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"result",
"!==",
"null",
")",
"{",
"array_push",
"(",
"$",
"this",
"->",
"resultStack",
",",
"$",
"this",
"->",
"result",
")",
";",
"}",
"$",
"this",
"->",
"result",
... | Push a new Result onto the Result stack and return it in order to fix cyclic calls to a single validator.
@since Flow 4.3
@see https://github.com/neos/flow-development-collection/pull/1275#issuecomment-414052031
@return ErrorResult | [
"Push",
"a",
"new",
"Result",
"onto",
"the",
"Result",
"stack",
"and",
"return",
"it",
"in",
"order",
"to",
"fix",
"cyclic",
"calls",
"to",
"a",
"single",
"validator",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Validation/Validator/AbstractValidator.php#L109-L116 |
neos/flow-development-collection | Neos.Flow/Classes/Validation/Validator/AbstractValidator.php | AbstractValidator.popResult | protected function popResult()
{
$result = $this->result;
$this->result = array_pop($this->resultStack);
return $result;
} | php | protected function popResult()
{
$result = $this->result;
$this->result = array_pop($this->resultStack);
return $result;
} | [
"protected",
"function",
"popResult",
"(",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"result",
";",
"$",
"this",
"->",
"result",
"=",
"array_pop",
"(",
"$",
"this",
"->",
"resultStack",
")",
";",
"return",
"$",
"result",
";",
"}"
] | Pop and return the current Result from the stack and make $this->result point to the last Result again.
@since Flow 4.3
@return ErrorResult | [
"Pop",
"and",
"return",
"the",
"current",
"Result",
"from",
"the",
"stack",
"and",
"make",
"$this",
"-",
">",
"result",
"point",
"to",
"the",
"last",
"Result",
"again",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Validation/Validator/AbstractValidator.php#L123-L128 |
neos/flow-development-collection | Neos.Flow/Classes/Validation/Validator/AbstractValidator.php | AbstractValidator.validate | public function validate($value)
{
$this->pushResult();
if ($this->acceptsEmptyValues === false || $this->isEmpty($value) === false) {
$this->isValid($value);
}
return $this->popResult();
} | php | public function validate($value)
{
$this->pushResult();
if ($this->acceptsEmptyValues === false || $this->isEmpty($value) === false) {
$this->isValid($value);
}
return $this->popResult();
} | [
"public",
"function",
"validate",
"(",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"pushResult",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"acceptsEmptyValues",
"===",
"false",
"||",
"$",
"this",
"->",
"isEmpty",
"(",
"$",
"value",
")",
"===",
"fal... | Checks if the given value is valid according to the validator, and returns
the Error Messages object which occurred.
@param mixed $value The value that should be validated
@return ErrorResult
@api | [
"Checks",
"if",
"the",
"given",
"value",
"is",
"valid",
"according",
"to",
"the",
"validator",
"and",
"returns",
"the",
"Error",
"Messages",
"object",
"which",
"occurred",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Validation/Validator/AbstractValidator.php#L138-L145 |
neos/flow-development-collection | Neos.Flow/Classes/Validation/Validator/AbstractValidator.php | AbstractValidator.addError | protected function addError($message, $code, array $arguments = [])
{
$this->result->addError(new ValidationError($message, $code, $arguments));
} | php | protected function addError($message, $code, array $arguments = [])
{
$this->result->addError(new ValidationError($message, $code, $arguments));
} | [
"protected",
"function",
"addError",
"(",
"$",
"message",
",",
"$",
"code",
",",
"array",
"$",
"arguments",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"result",
"->",
"addError",
"(",
"new",
"ValidationError",
"(",
"$",
"message",
",",
"$",
"code",
... | Creates a new validation error object and adds it to $this->errors
@param string $message The error message
@param integer $code The error code (a unix timestamp)
@param array $arguments Arguments to be replaced in message
@return void
@api | [
"Creates",
"a",
"new",
"validation",
"error",
"object",
"and",
"adds",
"it",
"to",
"$this",
"-",
">",
"errors"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Validation/Validator/AbstractValidator.php#L166-L169 |
neos/flow-development-collection | Neos.Flow/Classes/ResourceManagement/PersistentResource.php | PersistentResource.setFilename | public function setFilename($filename)
{
$this->throwExceptionIfProtected();
$pathInfo = UnicodeFunctions::pathinfo($filename);
$extension = (isset($pathInfo['extension']) ? '.' . strtolower($pathInfo['extension']) : '');
$this->filename = $pathInfo['filename'] . $extension;
$this->mediaType = Utility\MediaTypes::getMediaTypeFromFilename($this->filename);
} | php | public function setFilename($filename)
{
$this->throwExceptionIfProtected();
$pathInfo = UnicodeFunctions::pathinfo($filename);
$extension = (isset($pathInfo['extension']) ? '.' . strtolower($pathInfo['extension']) : '');
$this->filename = $pathInfo['filename'] . $extension;
$this->mediaType = Utility\MediaTypes::getMediaTypeFromFilename($this->filename);
} | [
"public",
"function",
"setFilename",
"(",
"$",
"filename",
")",
"{",
"$",
"this",
"->",
"throwExceptionIfProtected",
"(",
")",
";",
"$",
"pathInfo",
"=",
"UnicodeFunctions",
"::",
"pathinfo",
"(",
"$",
"filename",
")",
";",
"$",
"extension",
"=",
"(",
"iss... | Sets the filename which is used when this resource is downloaded or saved as a file
@param string $filename
@return void
@api | [
"Sets",
"the",
"filename",
"which",
"is",
"used",
"when",
"this",
"resource",
"is",
"downloaded",
"or",
"saved",
"as",
"a",
"file"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ResourceManagement/PersistentResource.php#L185-L193 |
neos/flow-development-collection | Neos.Flow/Classes/ResourceManagement/PersistentResource.php | PersistentResource.getMediaType | public function getMediaType()
{
if ($this->mediaType === null) {
return Utility\MediaTypes::getMediaTypeFromFilename($this->filename);
} else {
return $this->mediaType;
}
} | php | public function getMediaType()
{
if ($this->mediaType === null) {
return Utility\MediaTypes::getMediaTypeFromFilename($this->filename);
} else {
return $this->mediaType;
}
} | [
"public",
"function",
"getMediaType",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"mediaType",
"===",
"null",
")",
"{",
"return",
"Utility",
"\\",
"MediaTypes",
"::",
"getMediaTypeFromFilename",
"(",
"$",
"this",
"->",
"filename",
")",
";",
"}",
"else",
... | Returns the Media Type for this resource
@return string The IANA Media Type
@api | [
"Returns",
"the",
"Media",
"Type",
"for",
"this",
"resource"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ResourceManagement/PersistentResource.php#L260-L267 |
neos/flow-development-collection | Neos.Flow/Classes/ResourceManagement/PersistentResource.php | PersistentResource.setSha1 | public function setSha1($sha1)
{
$this->throwExceptionIfProtected();
if (!is_string($sha1) || preg_match('/[A-Fa-f0-9]{40}/', $sha1) !== 1) {
throw new \InvalidArgumentException('Specified invalid hash to setSha1()', 1362564220);
}
$this->sha1 = strtolower($sha1);
} | php | public function setSha1($sha1)
{
$this->throwExceptionIfProtected();
if (!is_string($sha1) || preg_match('/[A-Fa-f0-9]{40}/', $sha1) !== 1) {
throw new \InvalidArgumentException('Specified invalid hash to setSha1()', 1362564220);
}
$this->sha1 = strtolower($sha1);
} | [
"public",
"function",
"setSha1",
"(",
"$",
"sha1",
")",
"{",
"$",
"this",
"->",
"throwExceptionIfProtected",
"(",
")",
";",
"if",
"(",
"!",
"is_string",
"(",
"$",
"sha1",
")",
"||",
"preg_match",
"(",
"'/[A-Fa-f0-9]{40}/'",
",",
"$",
"sha1",
")",
"!==",
... | Sets the SHA1 hash of the content of this resource
@param string $sha1 The sha1 hash
@return void
@api | [
"Sets",
"the",
"SHA1",
"hash",
"of",
"the",
"content",
"of",
"this",
"resource"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ResourceManagement/PersistentResource.php#L309-L316 |
neos/flow-development-collection | Neos.Flow/Classes/ResourceManagement/PersistentResource.php | PersistentResource.createTemporaryLocalCopy | public function createTemporaryLocalCopy()
{
if ($this->temporaryLocalCopyPathAndFilename === null) {
$temporaryPathAndFilename = $this->environment->getPathToTemporaryDirectory() . 'ResourceFiles/';
try {
Utility\Files::createDirectoryRecursively($temporaryPathAndFilename);
} catch (Utility\Exception\FilesException $e) {
throw new ResourceException(sprintf('Could not create the temporary directory %s while trying to create a temporary local copy of resource %s (%s).', $temporaryPathAndFilename, $this->sha1, $this->filename), 1416221864);
}
$temporaryPathAndFilename .= $this->getCacheEntryIdentifier();
$temporaryPathAndFilename .= '-' . microtime(true);
if (function_exists('posix_getpid')) {
$temporaryPathAndFilename .= '-' . str_pad(posix_getpid(), 10);
} else {
$temporaryPathAndFilename .= '-' . (string) getmypid();
}
$temporaryPathAndFilename = trim($temporaryPathAndFilename);
$temporaryFileHandle = fopen($temporaryPathAndFilename, 'w');
if ($temporaryFileHandle === false) {
throw new ResourceException(sprintf('Could not create the temporary file %s while trying to create a temporary local copy of resource %s (%s).', $temporaryPathAndFilename, $this->sha1, $this->filename), 1416221864);
}
$resourceStream = $this->getStream();
if ($resourceStream === false) {
throw new ResourceException(sprintf('Could not open stream for resource %s ("%s") from collection "%s" while trying to create a temporary local copy.', $this->sha1, $this->filename, $this->collectionName), 1416221863);
}
stream_copy_to_stream($resourceStream, $temporaryFileHandle);
fclose($resourceStream);
fclose($temporaryFileHandle);
$this->temporaryLocalCopyPathAndFilename = $temporaryPathAndFilename;
}
return $this->temporaryLocalCopyPathAndFilename;
} | php | public function createTemporaryLocalCopy()
{
if ($this->temporaryLocalCopyPathAndFilename === null) {
$temporaryPathAndFilename = $this->environment->getPathToTemporaryDirectory() . 'ResourceFiles/';
try {
Utility\Files::createDirectoryRecursively($temporaryPathAndFilename);
} catch (Utility\Exception\FilesException $e) {
throw new ResourceException(sprintf('Could not create the temporary directory %s while trying to create a temporary local copy of resource %s (%s).', $temporaryPathAndFilename, $this->sha1, $this->filename), 1416221864);
}
$temporaryPathAndFilename .= $this->getCacheEntryIdentifier();
$temporaryPathAndFilename .= '-' . microtime(true);
if (function_exists('posix_getpid')) {
$temporaryPathAndFilename .= '-' . str_pad(posix_getpid(), 10);
} else {
$temporaryPathAndFilename .= '-' . (string) getmypid();
}
$temporaryPathAndFilename = trim($temporaryPathAndFilename);
$temporaryFileHandle = fopen($temporaryPathAndFilename, 'w');
if ($temporaryFileHandle === false) {
throw new ResourceException(sprintf('Could not create the temporary file %s while trying to create a temporary local copy of resource %s (%s).', $temporaryPathAndFilename, $this->sha1, $this->filename), 1416221864);
}
$resourceStream = $this->getStream();
if ($resourceStream === false) {
throw new ResourceException(sprintf('Could not open stream for resource %s ("%s") from collection "%s" while trying to create a temporary local copy.', $this->sha1, $this->filename, $this->collectionName), 1416221863);
}
stream_copy_to_stream($resourceStream, $temporaryFileHandle);
fclose($resourceStream);
fclose($temporaryFileHandle);
$this->temporaryLocalCopyPathAndFilename = $temporaryPathAndFilename;
}
return $this->temporaryLocalCopyPathAndFilename;
} | [
"public",
"function",
"createTemporaryLocalCopy",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"temporaryLocalCopyPathAndFilename",
"===",
"null",
")",
"{",
"$",
"temporaryPathAndFilename",
"=",
"$",
"this",
"->",
"environment",
"->",
"getPathToTemporaryDirectory",
... | Returns the path to a local file representing this resource for use with read-only file operations such as reading or copying.
Note that you must not store or publish file paths returned from this method as they will change with every request.
@return string Absolute path and filename pointing to the temporary local copy of this resource
@throws Exception
@api | [
"Returns",
"the",
"path",
"to",
"a",
"local",
"file",
"representing",
"this",
"resource",
"for",
"use",
"with",
"read",
"-",
"only",
"file",
"operations",
"such",
"as",
"reading",
"or",
"copying",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ResourceManagement/PersistentResource.php#L351-L386 |
neos/flow-development-collection | Neos.Flow/Classes/ResourceManagement/PersistentResource.php | PersistentResource.postPersist | public function postPersist()
{
if ($this->lifecycleEventsActive) {
$collection = $this->resourceManager->getCollection($this->collectionName);
$collection->getTarget()->publishResource($this, $collection);
}
} | php | public function postPersist()
{
if ($this->lifecycleEventsActive) {
$collection = $this->resourceManager->getCollection($this->collectionName);
$collection->getTarget()->publishResource($this, $collection);
}
} | [
"public",
"function",
"postPersist",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"lifecycleEventsActive",
")",
"{",
"$",
"collection",
"=",
"$",
"this",
"->",
"resourceManager",
"->",
"getCollection",
"(",
"$",
"this",
"->",
"collectionName",
")",
";",
"$... | Doctrine lifecycle event callback which is triggered on "postPersist" events.
This method triggers the publication of this resource.
@return void
@ORM\PostPersist | [
"Doctrine",
"lifecycle",
"event",
"callback",
"which",
"is",
"triggered",
"on",
"postPersist",
"events",
".",
"This",
"method",
"triggers",
"the",
"publication",
"of",
"this",
"resource",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ResourceManagement/PersistentResource.php#L395-L401 |
neos/flow-development-collection | Neos.Flow/Classes/ResourceManagement/PersistentResource.php | PersistentResource.preRemove | public function preRemove()
{
if ($this->lifecycleEventsActive && $this->deleted === false) {
$this->resourceManager->deleteResource($this);
}
} | php | public function preRemove()
{
if ($this->lifecycleEventsActive && $this->deleted === false) {
$this->resourceManager->deleteResource($this);
}
} | [
"public",
"function",
"preRemove",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"lifecycleEventsActive",
"&&",
"$",
"this",
"->",
"deleted",
"===",
"false",
")",
"{",
"$",
"this",
"->",
"resourceManager",
"->",
"deleteResource",
"(",
"$",
"this",
")",
";... | Doctrine lifecycle event callback which is triggered on "preRemove" events.
This method triggers the deletion of data related to this resource.
@return void
@ORM\PreRemove | [
"Doctrine",
"lifecycle",
"event",
"callback",
"which",
"is",
"triggered",
"on",
"preRemove",
"events",
".",
"This",
"method",
"triggers",
"the",
"deletion",
"of",
"data",
"related",
"to",
"this",
"resource",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ResourceManagement/PersistentResource.php#L410-L415 |
neos/flow-development-collection | Neos.Flow/Classes/Property/TypeConverter/IntegerConverter.php | IntegerConverter.convertFrom | public function convertFrom($source, $targetType, array $convertedChildProperties = [], PropertyMappingConfigurationInterface $configuration = null)
{
if ($source instanceof \DateTimeInterface) {
return $source->format('U');
}
if ($source === null || strlen($source) === 0) {
return null;
}
if (!is_numeric($source)) {
return new Error('"%s" is not numeric.', 1332933658, [$source]);
}
return (integer)$source;
} | php | public function convertFrom($source, $targetType, array $convertedChildProperties = [], PropertyMappingConfigurationInterface $configuration = null)
{
if ($source instanceof \DateTimeInterface) {
return $source->format('U');
}
if ($source === null || strlen($source) === 0) {
return null;
}
if (!is_numeric($source)) {
return new Error('"%s" is not numeric.', 1332933658, [$source]);
}
return (integer)$source;
} | [
"public",
"function",
"convertFrom",
"(",
"$",
"source",
",",
"$",
"targetType",
",",
"array",
"$",
"convertedChildProperties",
"=",
"[",
"]",
",",
"PropertyMappingConfigurationInterface",
"$",
"configuration",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"source",
... | Actually convert from $source to $targetType, in fact a noop here.
@param mixed $source
@param string $targetType
@param array $convertedChildProperties
@param PropertyMappingConfigurationInterface $configuration
@return integer|Error
@api | [
"Actually",
"convert",
"from",
"$source",
"to",
"$targetType",
"in",
"fact",
"a",
"noop",
"here",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Property/TypeConverter/IntegerConverter.php#L55-L69 |
neos/flow-development-collection | Neos.Flow/Classes/Aop/Advice/AroundAdvice.php | AroundAdvice.invoke | public function invoke(JoinPointInterface $joinPoint)
{
if ($this->runtimeEvaluator !== null && $this->runtimeEvaluator->__invoke($joinPoint, $this->objectManager) === false) {
return $joinPoint->getAdviceChain()->proceed($joinPoint);
}
$adviceObject = $this->objectManager->get($this->aspectObjectName);
$methodName = $this->adviceMethodName;
return $adviceObject->$methodName($joinPoint);
} | php | public function invoke(JoinPointInterface $joinPoint)
{
if ($this->runtimeEvaluator !== null && $this->runtimeEvaluator->__invoke($joinPoint, $this->objectManager) === false) {
return $joinPoint->getAdviceChain()->proceed($joinPoint);
}
$adviceObject = $this->objectManager->get($this->aspectObjectName);
$methodName = $this->adviceMethodName;
return $adviceObject->$methodName($joinPoint);
} | [
"public",
"function",
"invoke",
"(",
"JoinPointInterface",
"$",
"joinPoint",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"runtimeEvaluator",
"!==",
"null",
"&&",
"$",
"this",
"->",
"runtimeEvaluator",
"->",
"__invoke",
"(",
"$",
"joinPoint",
",",
"$",
"this",
... | Invokes the advice method
@param JoinPointInterface $joinPoint The current join point which is passed to the advice method
@return mixed Result of the advice method | [
"Invokes",
"the",
"advice",
"method"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Aop/Advice/AroundAdvice.php#L27-L36 |
neos/flow-development-collection | Neos.Flow/Classes/I18n/AbstractXmlParser.php | AbstractXmlParser.getParsedData | public function getParsedData(string $sourcePath)
{
if (!isset($this->parsedFiles[$sourcePath])) {
$this->parsedFiles[$sourcePath] = $this->parseXmlFile($sourcePath);
}
return $this->parsedFiles[$sourcePath];
} | php | public function getParsedData(string $sourcePath)
{
if (!isset($this->parsedFiles[$sourcePath])) {
$this->parsedFiles[$sourcePath] = $this->parseXmlFile($sourcePath);
}
return $this->parsedFiles[$sourcePath];
} | [
"public",
"function",
"getParsedData",
"(",
"string",
"$",
"sourcePath",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"parsedFiles",
"[",
"$",
"sourcePath",
"]",
")",
")",
"{",
"$",
"this",
"->",
"parsedFiles",
"[",
"$",
"sourcePath",
"]"... | Returns parsed representation of XML file.
Parses XML if it wasn't done before. Caches parsed data.
@param string $sourcePath An absolute path to XML file
@return array Parsed XML file | [
"Returns",
"parsed",
"representation",
"of",
"XML",
"file",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/I18n/AbstractXmlParser.php#L38-L45 |
neos/flow-development-collection | Neos.Flow/Classes/I18n/AbstractXmlParser.php | AbstractXmlParser.parseXmlFile | protected function parseXmlFile(string $sourcePath)
{
$rootXmlNode = $this->getRootNode($sourcePath);
return $this->doParsingFromRoot($rootXmlNode);
} | php | protected function parseXmlFile(string $sourcePath)
{
$rootXmlNode = $this->getRootNode($sourcePath);
return $this->doParsingFromRoot($rootXmlNode);
} | [
"protected",
"function",
"parseXmlFile",
"(",
"string",
"$",
"sourcePath",
")",
"{",
"$",
"rootXmlNode",
"=",
"$",
"this",
"->",
"getRootNode",
"(",
"$",
"sourcePath",
")",
";",
"return",
"$",
"this",
"->",
"doParsingFromRoot",
"(",
"$",
"rootXmlNode",
")",
... | Reads and parses XML file and returns internal representation of data.
@param string $sourcePath An absolute path to XML file
@return array Parsed XML file | [
"Reads",
"and",
"parses",
"XML",
"file",
"and",
"returns",
"internal",
"representation",
"of",
"data",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/I18n/AbstractXmlParser.php#L80-L85 |
neos/flow-development-collection | Neos.Flow/Classes/Persistence/Doctrine/DataTypes/ObjectArray.php | ObjectArray.convertToPHPValue | public function convertToPHPValue($value, AbstractPlatform $platform)
{
$this->initializeDependencies();
switch ($platform->getName()) {
case 'postgresql':
$value = (is_resource($value)) ? stream_get_contents($value) : $value;
$array = parent::convertToPHPValue(hex2bin($value), $platform);
break;
default:
$array = parent::convertToPHPValue($value, $platform);
}
$this->decodeObjectReferences($array);
return $array;
} | php | public function convertToPHPValue($value, AbstractPlatform $platform)
{
$this->initializeDependencies();
switch ($platform->getName()) {
case 'postgresql':
$value = (is_resource($value)) ? stream_get_contents($value) : $value;
$array = parent::convertToPHPValue(hex2bin($value), $platform);
break;
default:
$array = parent::convertToPHPValue($value, $platform);
}
$this->decodeObjectReferences($array);
return $array;
} | [
"public",
"function",
"convertToPHPValue",
"(",
"$",
"value",
",",
"AbstractPlatform",
"$",
"platform",
")",
"{",
"$",
"this",
"->",
"initializeDependencies",
"(",
")",
";",
"switch",
"(",
"$",
"platform",
"->",
"getName",
"(",
")",
")",
"{",
"case",
"'pos... | Converts a value from its database representation to its PHP representation
of this type.
@param mixed $value The value to convert.
@param AbstractPlatform $platform The currently used database platform.
@return array The PHP representation of the value. | [
"Converts",
"a",
"value",
"from",
"its",
"database",
"representation",
"to",
"its",
"PHP",
"representation",
"of",
"this",
"type",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Persistence/Doctrine/DataTypes/ObjectArray.php#L77-L92 |
neos/flow-development-collection | Neos.Flow/Classes/Persistence/Doctrine/DataTypes/ObjectArray.php | ObjectArray.convertToDatabaseValue | public function convertToDatabaseValue($array, AbstractPlatform $platform)
{
$this->initializeDependencies();
$this->encodeObjectReferences($array);
switch ($platform->getName()) {
case 'postgresql':
return bin2hex(parent::convertToDatabaseValue($array, $platform));
default:
return parent::convertToDatabaseValue($array, $platform);
}
} | php | public function convertToDatabaseValue($array, AbstractPlatform $platform)
{
$this->initializeDependencies();
$this->encodeObjectReferences($array);
switch ($platform->getName()) {
case 'postgresql':
return bin2hex(parent::convertToDatabaseValue($array, $platform));
default:
return parent::convertToDatabaseValue($array, $platform);
}
} | [
"public",
"function",
"convertToDatabaseValue",
"(",
"$",
"array",
",",
"AbstractPlatform",
"$",
"platform",
")",
"{",
"$",
"this",
"->",
"initializeDependencies",
"(",
")",
";",
"$",
"this",
"->",
"encodeObjectReferences",
"(",
"$",
"array",
")",
";",
"switch... | Converts a value from its PHP representation to its database representation
of this type.
@param array $array The value to convert.
@param AbstractPlatform $platform The currently used database platform.
@return mixed The database representation of the value. | [
"Converts",
"a",
"value",
"from",
"its",
"PHP",
"representation",
"to",
"its",
"database",
"representation",
"of",
"this",
"type",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Persistence/Doctrine/DataTypes/ObjectArray.php#L102-L114 |
neos/flow-development-collection | Neos.Flow/Classes/Persistence/Doctrine/DataTypes/ObjectArray.php | ObjectArray.encodeObjectReferences | protected function encodeObjectReferences(array &$array)
{
foreach ($array as &$value) {
if (is_array($value)) {
$this->encodeObjectReferences($value);
}
if (!is_object($value) || (is_object($value) && $value instanceof DependencyProxy)) {
continue;
}
$propertyClassName = TypeHandling::getTypeForValue($value);
if ($value instanceof \SplObjectStorage) {
throw new \RuntimeException('SplObjectStorage in array properties is not supported', 1375196580);
} elseif ($value instanceof \Doctrine\Common\Collections\Collection) {
throw new \RuntimeException('Collection in array properties is not supported', 1375196581);
} elseif ($value instanceof \ArrayObject) {
throw new \RuntimeException('ArrayObject in array properties is not supported', 1375196582);
} elseif ($this->persistenceManager->isNewObject($value) === false
&& (
$this->reflectionService->isClassAnnotatedWith($propertyClassName, Flow\Entity::class)
|| $this->reflectionService->isClassAnnotatedWith($propertyClassName, Flow\ValueObject::class)
|| $this->reflectionService->isClassAnnotatedWith($propertyClassName, \Doctrine\ORM\Mapping\Entity::class)
)
) {
$value = [
'__flow_object_type' => $propertyClassName,
'__identifier' => $this->persistenceManager->getIdentifierByObject($value)
];
}
}
} | php | protected function encodeObjectReferences(array &$array)
{
foreach ($array as &$value) {
if (is_array($value)) {
$this->encodeObjectReferences($value);
}
if (!is_object($value) || (is_object($value) && $value instanceof DependencyProxy)) {
continue;
}
$propertyClassName = TypeHandling::getTypeForValue($value);
if ($value instanceof \SplObjectStorage) {
throw new \RuntimeException('SplObjectStorage in array properties is not supported', 1375196580);
} elseif ($value instanceof \Doctrine\Common\Collections\Collection) {
throw new \RuntimeException('Collection in array properties is not supported', 1375196581);
} elseif ($value instanceof \ArrayObject) {
throw new \RuntimeException('ArrayObject in array properties is not supported', 1375196582);
} elseif ($this->persistenceManager->isNewObject($value) === false
&& (
$this->reflectionService->isClassAnnotatedWith($propertyClassName, Flow\Entity::class)
|| $this->reflectionService->isClassAnnotatedWith($propertyClassName, Flow\ValueObject::class)
|| $this->reflectionService->isClassAnnotatedWith($propertyClassName, \Doctrine\ORM\Mapping\Entity::class)
)
) {
$value = [
'__flow_object_type' => $propertyClassName,
'__identifier' => $this->persistenceManager->getIdentifierByObject($value)
];
}
}
} | [
"protected",
"function",
"encodeObjectReferences",
"(",
"array",
"&",
"$",
"array",
")",
"{",
"foreach",
"(",
"$",
"array",
"as",
"&",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"this",
"->",
"encodeObjectRefe... | Traverses the $array and replaces known persisted objects with a tuple of
type and identifier.
@param array $array
@return void
@throws \RuntimeException | [
"Traverses",
"the",
"$array",
"and",
"replaces",
"known",
"persisted",
"objects",
"with",
"a",
"tuple",
"of",
"type",
"and",
"identifier",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Persistence/Doctrine/DataTypes/ObjectArray.php#L161-L192 |
neos/flow-development-collection | Neos.Flow/Classes/Error/DebugExceptionHandler.php | DebugExceptionHandler.echoExceptionWeb | protected function echoExceptionWeb($exception)
{
$statusCode = ($exception instanceof WithHttpStatusInterface) ? $exception->getStatusCode() : 500;
$statusMessage = ResponseInformationHelper::getStatusMessageByCode($statusCode);
if (!headers_sent()) {
header(sprintf('HTTP/1.1 %s %s', $statusCode, $statusMessage));
}
if (!isset($this->renderingOptions['templatePathAndFilename'])) {
$this->renderStatically($statusCode, $exception);
return;
}
try {
echo $this->buildView($exception, $this->renderingOptions)->render();
} catch (\Throwable $throwable) {
$this->renderStatically($statusCode, $throwable);
}
} | php | protected function echoExceptionWeb($exception)
{
$statusCode = ($exception instanceof WithHttpStatusInterface) ? $exception->getStatusCode() : 500;
$statusMessage = ResponseInformationHelper::getStatusMessageByCode($statusCode);
if (!headers_sent()) {
header(sprintf('HTTP/1.1 %s %s', $statusCode, $statusMessage));
}
if (!isset($this->renderingOptions['templatePathAndFilename'])) {
$this->renderStatically($statusCode, $exception);
return;
}
try {
echo $this->buildView($exception, $this->renderingOptions)->render();
} catch (\Throwable $throwable) {
$this->renderStatically($statusCode, $throwable);
}
} | [
"protected",
"function",
"echoExceptionWeb",
"(",
"$",
"exception",
")",
"{",
"$",
"statusCode",
"=",
"(",
"$",
"exception",
"instanceof",
"WithHttpStatusInterface",
")",
"?",
"$",
"exception",
"->",
"getStatusCode",
"(",
")",
":",
"500",
";",
"$",
"statusMess... | Formats and echoes the exception as XHTML.
@param \Throwable $exception
@return void | [
"Formats",
"and",
"echoes",
"the",
"exception",
"as",
"XHTML",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Error/DebugExceptionHandler.php#L59-L77 |
neos/flow-development-collection | Neos.Flow/Classes/Error/DebugExceptionHandler.php | DebugExceptionHandler.renderStatically | protected function renderStatically(int $statusCode, \Throwable $exception)
{
$statusMessage = ResponseInformationHelper::getStatusMessageByCode($statusCode);
$exceptionHeader = '<div class="Flow-Debug-Exception-Header">';
while (true) {
$filepaths = Debugger::findProxyAndShortFilePath($exception->getFile());
$filePathAndName = $filepaths['proxy'] !== '' ? $filepaths['proxy'] : $filepaths['short'];
$exceptionMessageParts = $this->splitExceptionMessage($exception->getMessage());
$exceptionHeader .= '<h1 class="ExceptionSubject">' . htmlspecialchars($exceptionMessageParts['subject']) . '</h1>';
if ($exceptionMessageParts['body'] !== '') {
$exceptionHeader .= '<p class="ExceptionBody">' . nl2br(htmlspecialchars($exceptionMessageParts['body'])) . '</p>';
}
$exceptionHeader .= '<table class="Flow-Debug-Exception-Meta"><tbody>';
$exceptionHeader .= '<tr><th>Exception Code</th><td class="ExceptionProperty">' . $exception->getCode() . '</td></tr>';
$exceptionHeader .= '<tr><th>Exception Type</th><td class="ExceptionProperty">' . get_class($exception) . '</td></tr>';
if ($exception instanceof WithReferenceCodeInterface) {
$exceptionHeader .= '<tr><th>Log Reference</th><td class="ExceptionProperty">' . $exception->getReferenceCode() . '</td></tr>';
}
$exceptionHeader .= '<tr><th>Thrown in File</th><td class="ExceptionProperty">' . $filePathAndName . '</td></tr>';
$exceptionHeader .= '<tr><th>Line</th><td class="ExceptionProperty">' . $exception->getLine() . '</td></tr>';
if ($filepaths['proxy'] !== '') {
$exceptionHeader .= '<tr><th>Original File</th><td class="ExceptionProperty">' . $filepaths['short'] . '</td></tr>';
}
$exceptionHeader .= '</tbody></table>';
if ($exception->getPrevious() === null) {
break;
}
$exceptionHeader .= '<br /><h2>Nested Exception</h2>';
$exception = $exception->getPrevious();
}
$exceptionHeader .= '</div>';
$backtraceCode = Debugger::getBacktraceCode($exception->getTrace());
$footer = '<div class="Flow-Debug-Exception-Footer">';
$footer .= '<table class="Flow-Debug-Exception-InstanceData"><tbody>';
if (defined('FLOW_PATH_ROOT')) {
$footer .= '<tr><th>Instance root</th><td class="ExceptionProperty">' . FLOW_PATH_ROOT . '</td></tr>';
}
if (Bootstrap::$staticObjectManager instanceof ObjectManagerInterface) {
$bootstrap = Bootstrap::$staticObjectManager->get(Bootstrap::class);
$footer .= '<tr><th>Application Context</th><td class="ExceptionProperty">' . $bootstrap->getContext() . '</td></tr>';
$footer .= '<tr><th>Request Handler</th><td class="ExceptionProperty">' . get_class($bootstrap->getActiveRequestHandler()) . '</td></tr>';
}
$footer .= '</tbody></table>';
$footer .= '</div>';
echo sprintf($this->htmlExceptionTemplate,
$statusCode . ' ' . $statusMessage,
file_get_contents(__DIR__ . '/../../Resources/Public/Error/Exception.css'),
$exceptionHeader,
$backtraceCode,
$footer
);
} | php | protected function renderStatically(int $statusCode, \Throwable $exception)
{
$statusMessage = ResponseInformationHelper::getStatusMessageByCode($statusCode);
$exceptionHeader = '<div class="Flow-Debug-Exception-Header">';
while (true) {
$filepaths = Debugger::findProxyAndShortFilePath($exception->getFile());
$filePathAndName = $filepaths['proxy'] !== '' ? $filepaths['proxy'] : $filepaths['short'];
$exceptionMessageParts = $this->splitExceptionMessage($exception->getMessage());
$exceptionHeader .= '<h1 class="ExceptionSubject">' . htmlspecialchars($exceptionMessageParts['subject']) . '</h1>';
if ($exceptionMessageParts['body'] !== '') {
$exceptionHeader .= '<p class="ExceptionBody">' . nl2br(htmlspecialchars($exceptionMessageParts['body'])) . '</p>';
}
$exceptionHeader .= '<table class="Flow-Debug-Exception-Meta"><tbody>';
$exceptionHeader .= '<tr><th>Exception Code</th><td class="ExceptionProperty">' . $exception->getCode() . '</td></tr>';
$exceptionHeader .= '<tr><th>Exception Type</th><td class="ExceptionProperty">' . get_class($exception) . '</td></tr>';
if ($exception instanceof WithReferenceCodeInterface) {
$exceptionHeader .= '<tr><th>Log Reference</th><td class="ExceptionProperty">' . $exception->getReferenceCode() . '</td></tr>';
}
$exceptionHeader .= '<tr><th>Thrown in File</th><td class="ExceptionProperty">' . $filePathAndName . '</td></tr>';
$exceptionHeader .= '<tr><th>Line</th><td class="ExceptionProperty">' . $exception->getLine() . '</td></tr>';
if ($filepaths['proxy'] !== '') {
$exceptionHeader .= '<tr><th>Original File</th><td class="ExceptionProperty">' . $filepaths['short'] . '</td></tr>';
}
$exceptionHeader .= '</tbody></table>';
if ($exception->getPrevious() === null) {
break;
}
$exceptionHeader .= '<br /><h2>Nested Exception</h2>';
$exception = $exception->getPrevious();
}
$exceptionHeader .= '</div>';
$backtraceCode = Debugger::getBacktraceCode($exception->getTrace());
$footer = '<div class="Flow-Debug-Exception-Footer">';
$footer .= '<table class="Flow-Debug-Exception-InstanceData"><tbody>';
if (defined('FLOW_PATH_ROOT')) {
$footer .= '<tr><th>Instance root</th><td class="ExceptionProperty">' . FLOW_PATH_ROOT . '</td></tr>';
}
if (Bootstrap::$staticObjectManager instanceof ObjectManagerInterface) {
$bootstrap = Bootstrap::$staticObjectManager->get(Bootstrap::class);
$footer .= '<tr><th>Application Context</th><td class="ExceptionProperty">' . $bootstrap->getContext() . '</td></tr>';
$footer .= '<tr><th>Request Handler</th><td class="ExceptionProperty">' . get_class($bootstrap->getActiveRequestHandler()) . '</td></tr>';
}
$footer .= '</tbody></table>';
$footer .= '</div>';
echo sprintf($this->htmlExceptionTemplate,
$statusCode . ' ' . $statusMessage,
file_get_contents(__DIR__ . '/../../Resources/Public/Error/Exception.css'),
$exceptionHeader,
$backtraceCode,
$footer
);
} | [
"protected",
"function",
"renderStatically",
"(",
"int",
"$",
"statusCode",
",",
"\\",
"Throwable",
"$",
"exception",
")",
"{",
"$",
"statusMessage",
"=",
"ResponseInformationHelper",
"::",
"getStatusMessageByCode",
"(",
"$",
"statusCode",
")",
";",
"$",
"exceptio... | Returns the statically rendered exception message
@param integer $statusCode
@param \Throwable $exception
@return void | [
"Returns",
"the",
"statically",
"rendered",
"exception",
"message"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Error/DebugExceptionHandler.php#L86-L146 |
neos/flow-development-collection | Neos.FluidAdaptor/Classes/Command/DocumentationCommandController.php | DocumentationCommandController.generateXsdCommand | public function generateXsdCommand(string $phpNamespace, string $xsdNamespace = null, string $targetFile = null, string $xsdDomain = ''): void
{
$xsdDomain = trim($xsdDomain);
$parsedDomain = parse_url($xsdDomain);
if (empty($xsdDomain) || !isset($parsedDomain['host'], $parsedDomain['scheme'])) {
$xsdDomain = 'https://neos.io';
}
if ($xsdNamespace === null) {
$xsdNamespace = sprintf('%s/ns/%s', $xsdDomain, str_replace('\\', '/', $phpNamespace));
}
$xsdSchema = '';
try {
$xsdSchema = $this->xsdGenerator->generateXsd($phpNamespace, $xsdNamespace);
} catch (Service\Exception $exception) {
$this->outputLine('An error occurred while trying to generate the XSD schema:');
$this->outputLine('%s', [$exception->getMessage()]);
$this->quit(1);
}
if ($targetFile === null) {
$this->output($xsdSchema);
} else {
file_put_contents($targetFile, $xsdSchema);
}
} | php | public function generateXsdCommand(string $phpNamespace, string $xsdNamespace = null, string $targetFile = null, string $xsdDomain = ''): void
{
$xsdDomain = trim($xsdDomain);
$parsedDomain = parse_url($xsdDomain);
if (empty($xsdDomain) || !isset($parsedDomain['host'], $parsedDomain['scheme'])) {
$xsdDomain = 'https://neos.io';
}
if ($xsdNamespace === null) {
$xsdNamespace = sprintf('%s/ns/%s', $xsdDomain, str_replace('\\', '/', $phpNamespace));
}
$xsdSchema = '';
try {
$xsdSchema = $this->xsdGenerator->generateXsd($phpNamespace, $xsdNamespace);
} catch (Service\Exception $exception) {
$this->outputLine('An error occurred while trying to generate the XSD schema:');
$this->outputLine('%s', [$exception->getMessage()]);
$this->quit(1);
}
if ($targetFile === null) {
$this->output($xsdSchema);
} else {
file_put_contents($targetFile, $xsdSchema);
}
} | [
"public",
"function",
"generateXsdCommand",
"(",
"string",
"$",
"phpNamespace",
",",
"string",
"$",
"xsdNamespace",
"=",
"null",
",",
"string",
"$",
"targetFile",
"=",
"null",
",",
"string",
"$",
"xsdDomain",
"=",
"''",
")",
":",
"void",
"{",
"$",
"xsdDoma... | Generate Fluid ViewHelper XSD Schema
Generates Schema documentation (XSD) for your ViewHelpers, preparing the
file to be placed online and used by any XSD-aware editor.
After creating the XSD file, reference it in your IDE and import the namespace
in your Fluid template by adding the xmlns:* attribute(s):
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:f="https://neos.io/ns/Neos/Neos/ViewHelpers" ...>
@param string $phpNamespace Namespace of the Fluid ViewHelpers without leading backslash (for example 'Neos\FluidAdaptor\ViewHelpers'). NOTE: Quote and/or escape this argument as needed to avoid backslashes from being interpreted!
@param string $xsdNamespace Unique target namespace used in the XSD schema (for example "http://yourdomain.org/ns/viewhelpers"). Defaults to "https://neos.io/ns/<php namespace>".
@param string $targetFile File path and name of the generated XSD schema. If not specified the schema will be output to standard output.
@param string $xsdDomain Domain used in the XSD schema (for example "http://yourdomain.org"). Defaults to "https://neos.io".
@return void | [
"Generate",
"Fluid",
"ViewHelper",
"XSD",
"Schema"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.FluidAdaptor/Classes/Command/DocumentationCommandController.php#L48-L71 |
neos/flow-development-collection | Neos.Flow/Classes/Security/RequestPattern/Ip.php | Ip.matchRequest | public function matchRequest(RequestInterface $request)
{
if (!isset($this->options['cidrPattern'])) {
throw new InvalidRequestPatternException('Missing option "cidrPattern" in the Ip request pattern configuration', 1446224520);
}
if (!$request instanceof ActionRequest) {
return false;
}
return (boolean)IpUtility::cidrMatch($request->getHttpRequest()->getClientIpAddress(), $this->options['cidrPattern']);
} | php | public function matchRequest(RequestInterface $request)
{
if (!isset($this->options['cidrPattern'])) {
throw new InvalidRequestPatternException('Missing option "cidrPattern" in the Ip request pattern configuration', 1446224520);
}
if (!$request instanceof ActionRequest) {
return false;
}
return (boolean)IpUtility::cidrMatch($request->getHttpRequest()->getClientIpAddress(), $this->options['cidrPattern']);
} | [
"public",
"function",
"matchRequest",
"(",
"RequestInterface",
"$",
"request",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"options",
"[",
"'cidrPattern'",
"]",
")",
")",
"{",
"throw",
"new",
"InvalidRequestPatternException",
"(",
"'Missing opti... | Matches a \Neos\Flow\Mvc\RequestInterface against the set IP pattern rules
@param RequestInterface $request The request that should be matched
@return boolean true if the pattern matched, false otherwise
@throws InvalidRequestPatternException | [
"Matches",
"a",
"\\",
"Neos",
"\\",
"Flow",
"\\",
"Mvc",
"\\",
"RequestInterface",
"against",
"the",
"set",
"IP",
"pattern",
"rules"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/RequestPattern/Ip.php#L59-L68 |
neos/flow-development-collection | Neos.Flow/Classes/Security/Authentication/Controller/AbstractAuthenticationController.php | AbstractAuthenticationController.authenticateAction | public function authenticateAction()
{
$authenticationException = null;
try {
$this->authenticationManager->authenticate();
} catch (AuthenticationRequiredException $exception) {
$authenticationException = $exception;
}
if (!$this->authenticationManager->isAuthenticated()) {
$this->onAuthenticationFailure($authenticationException);
return call_user_func([$this, $this->errorMethodName]);
}
$storedRequest = $this->securityContext->getInterceptedRequest();
if ($storedRequest !== null) {
$this->securityContext->setInterceptedRequest(null);
}
return $this->onAuthenticationSuccess($storedRequest);
} | php | public function authenticateAction()
{
$authenticationException = null;
try {
$this->authenticationManager->authenticate();
} catch (AuthenticationRequiredException $exception) {
$authenticationException = $exception;
}
if (!$this->authenticationManager->isAuthenticated()) {
$this->onAuthenticationFailure($authenticationException);
return call_user_func([$this, $this->errorMethodName]);
}
$storedRequest = $this->securityContext->getInterceptedRequest();
if ($storedRequest !== null) {
$this->securityContext->setInterceptedRequest(null);
}
return $this->onAuthenticationSuccess($storedRequest);
} | [
"public",
"function",
"authenticateAction",
"(",
")",
"{",
"$",
"authenticationException",
"=",
"null",
";",
"try",
"{",
"$",
"this",
"->",
"authenticationManager",
"->",
"authenticate",
"(",
")",
";",
"}",
"catch",
"(",
"AuthenticationRequiredException",
"$",
"... | Calls the authentication manager to authenticate all active tokens
and redirects to the original intercepted request on success if there
is one stored in the security context. If no intercepted request is
found, the function simply returns.
If authentication fails, the result of calling the defined
$errorMethodName is returned.
Note: Usually there is no need to override this action. You should use
the according callback methods instead (onAuthenticationSuccess() and
onAuthenticationFailure()).
@return string
@Flow\SkipCsrfProtection | [
"Calls",
"the",
"authentication",
"manager",
"to",
"authenticate",
"all",
"active",
"tokens",
"and",
"redirects",
"to",
"the",
"original",
"intercepted",
"request",
"on",
"success",
"if",
"there",
"is",
"one",
"stored",
"in",
"the",
"security",
"context",
".",
... | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Authentication/Controller/AbstractAuthenticationController.php#L77-L96 |
neos/flow-development-collection | Neos.Flow/Classes/Security/Authentication/Controller/AbstractAuthenticationController.php | AbstractAuthenticationController.onAuthenticationFailure | protected function onAuthenticationFailure(AuthenticationRequiredException $exception = null)
{
$this->flashMessageContainer->addMessage(new Error('Authentication failed!', ($exception === null ? 1347016771 : $exception->getCode())));
} | php | protected function onAuthenticationFailure(AuthenticationRequiredException $exception = null)
{
$this->flashMessageContainer->addMessage(new Error('Authentication failed!', ($exception === null ? 1347016771 : $exception->getCode())));
} | [
"protected",
"function",
"onAuthenticationFailure",
"(",
"AuthenticationRequiredException",
"$",
"exception",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"flashMessageContainer",
"->",
"addMessage",
"(",
"new",
"Error",
"(",
"'Authentication failed!'",
",",
"(",
"$",
... | Is called if authentication failed.
Override this method in your login controller to take any
custom action for this event. Most likely you would want
to redirect to some action showing the login form again.
@param AuthenticationRequiredException $exception The exception thrown while the authentication process
@return void | [
"Is",
"called",
"if",
"authentication",
"failed",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Authentication/Controller/AbstractAuthenticationController.php#L121-L124 |
neos/flow-development-collection | Neos.Flow/Classes/Aop/AspectContainer.php | AspectContainer.reduceTargetClassNames | public function reduceTargetClassNames(Builder\ClassNameIndex $classNameIndex): Builder\ClassNameIndex
{
$result = new Builder\ClassNameIndex();
foreach ($this->advisors as $advisor) {
$result->applyUnion($advisor->getPointcut()->reduceTargetClassNames($classNameIndex));
}
foreach ($this->interfaceIntroductions as $interfaceIntroduction) {
$result->applyUnion($interfaceIntroduction->getPointcut()->reduceTargetClassNames($classNameIndex));
}
foreach ($this->propertyIntroductions as $propertyIntroduction) {
$result->applyUnion($propertyIntroduction->getPointcut()->reduceTargetClassNames($classNameIndex));
}
foreach ($this->traitIntroductions as $traitIntroduction) {
$result->applyUnion($traitIntroduction->getPointcut()->reduceTargetClassNames($classNameIndex));
}
$this->cachedTargetClassNameCandidates = $result;
return $result;
} | php | public function reduceTargetClassNames(Builder\ClassNameIndex $classNameIndex): Builder\ClassNameIndex
{
$result = new Builder\ClassNameIndex();
foreach ($this->advisors as $advisor) {
$result->applyUnion($advisor->getPointcut()->reduceTargetClassNames($classNameIndex));
}
foreach ($this->interfaceIntroductions as $interfaceIntroduction) {
$result->applyUnion($interfaceIntroduction->getPointcut()->reduceTargetClassNames($classNameIndex));
}
foreach ($this->propertyIntroductions as $propertyIntroduction) {
$result->applyUnion($propertyIntroduction->getPointcut()->reduceTargetClassNames($classNameIndex));
}
foreach ($this->traitIntroductions as $traitIntroduction) {
$result->applyUnion($traitIntroduction->getPointcut()->reduceTargetClassNames($classNameIndex));
}
$this->cachedTargetClassNameCandidates = $result;
return $result;
} | [
"public",
"function",
"reduceTargetClassNames",
"(",
"Builder",
"\\",
"ClassNameIndex",
"$",
"classNameIndex",
")",
":",
"Builder",
"\\",
"ClassNameIndex",
"{",
"$",
"result",
"=",
"new",
"Builder",
"\\",
"ClassNameIndex",
"(",
")",
";",
"foreach",
"(",
"$",
"... | This method is used to optimize the matching process.
@param Builder\ClassNameIndex $classNameIndex
@return Builder\ClassNameIndex | [
"This",
"method",
"is",
"used",
"to",
"optimize",
"the",
"matching",
"process",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Aop/AspectContainer.php#L213-L230 |
neos/flow-development-collection | Neos.FluidAdaptor/Classes/ViewHelpers/Link/ActionViewHelper.php | ActionViewHelper.render | public function render()
{
$uriBuilder = $this->controllerContext->getUriBuilder();
if ($this->arguments['useParentRequest']) {
$request = $this->controllerContext->getRequest();
if ($request->isMainRequest()) {
throw new ViewHelper\Exception('You can\'t use the parent Request, you are already in the MainRequest.', 1360163536);
}
$uriBuilder = clone $uriBuilder;
$uriBuilder->setRequest($request->getParentRequest());
} elseif ($this->arguments['useMainRequest'] === true) {
$request = $this->controllerContext->getRequest();
if (!$request->isMainRequest()) {
$uriBuilder = clone $uriBuilder;
$uriBuilder->setRequest($request->getMainRequest());
}
}
$uriBuilder
->reset()
->setSection($this->arguments['section'])
->setCreateAbsoluteUri($this->arguments['absolute'])
->setArguments($this->arguments['additionalParams'])
->setAddQueryString($this->arguments['addQueryString'])
->setArgumentsToBeExcludedFromQueryString($this->arguments['argumentsToBeExcludedFromQueryString'])
->setFormat($this->arguments['format']);
try {
$uri = $uriBuilder->uriFor($this->arguments['action'], $this->arguments['arguments'], $this->arguments['controller'], $this->arguments['package'], $this->arguments['subpackage']);
} catch (\Exception $exception) {
throw new ViewHelper\Exception($exception->getMessage(), $exception->getCode(), $exception);
}
$this->tag->addAttribute('href', $uri);
$this->tag->setContent($this->renderChildren());
$this->tag->forceClosingTag(true);
return $this->tag->render();
} | php | public function render()
{
$uriBuilder = $this->controllerContext->getUriBuilder();
if ($this->arguments['useParentRequest']) {
$request = $this->controllerContext->getRequest();
if ($request->isMainRequest()) {
throw new ViewHelper\Exception('You can\'t use the parent Request, you are already in the MainRequest.', 1360163536);
}
$uriBuilder = clone $uriBuilder;
$uriBuilder->setRequest($request->getParentRequest());
} elseif ($this->arguments['useMainRequest'] === true) {
$request = $this->controllerContext->getRequest();
if (!$request->isMainRequest()) {
$uriBuilder = clone $uriBuilder;
$uriBuilder->setRequest($request->getMainRequest());
}
}
$uriBuilder
->reset()
->setSection($this->arguments['section'])
->setCreateAbsoluteUri($this->arguments['absolute'])
->setArguments($this->arguments['additionalParams'])
->setAddQueryString($this->arguments['addQueryString'])
->setArgumentsToBeExcludedFromQueryString($this->arguments['argumentsToBeExcludedFromQueryString'])
->setFormat($this->arguments['format']);
try {
$uri = $uriBuilder->uriFor($this->arguments['action'], $this->arguments['arguments'], $this->arguments['controller'], $this->arguments['package'], $this->arguments['subpackage']);
} catch (\Exception $exception) {
throw new ViewHelper\Exception($exception->getMessage(), $exception->getCode(), $exception);
}
$this->tag->addAttribute('href', $uri);
$this->tag->setContent($this->renderChildren());
$this->tag->forceClosingTag(true);
return $this->tag->render();
} | [
"public",
"function",
"render",
"(",
")",
"{",
"$",
"uriBuilder",
"=",
"$",
"this",
"->",
"controllerContext",
"->",
"getUriBuilder",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"arguments",
"[",
"'useParentRequest'",
"]",
")",
"{",
"$",
"request",
"=",... | Render the link.
@return string The rendered link
@throws ViewHelper\Exception
@api | [
"Render",
"the",
"link",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.FluidAdaptor/Classes/ViewHelpers/Link/ActionViewHelper.php#L82-L118 |
neos/flow-development-collection | Neos.Flow/Classes/Aop/Builder/ClassNameIndex.php | ClassNameIndex.setClassNames | public function setClassNames(array $classNames): void
{
$this->classNames = count($classNames) > 0 ? array_combine($classNames, array_fill(0, count($classNames), true)) : [];
} | php | public function setClassNames(array $classNames): void
{
$this->classNames = count($classNames) > 0 ? array_combine($classNames, array_fill(0, count($classNames), true)) : [];
} | [
"public",
"function",
"setClassNames",
"(",
"array",
"$",
"classNames",
")",
":",
"void",
"{",
"$",
"this",
"->",
"classNames",
"=",
"count",
"(",
"$",
"classNames",
")",
">",
"0",
"?",
"array_combine",
"(",
"$",
"classNames",
",",
"array_fill",
"(",
"0"... | Set the data of this index to the given class
names. Note: Make sure to sort the array before!
@param array $classNames
@return void | [
"Set",
"the",
"data",
"of",
"this",
"index",
"to",
"the",
"given",
"class",
"names",
".",
"Note",
":",
"Make",
"sure",
"to",
"sort",
"the",
"array",
"before!"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Aop/Builder/ClassNameIndex.php#L48-L51 |
neos/flow-development-collection | Neos.Flow/Classes/Aop/Builder/ClassNameIndex.php | ClassNameIndex.intersect | public function intersect(ClassNameIndex $classNameIndex): ClassNameIndex
{
return new ClassNameIndex(array_intersect_key($this->classNames, $classNameIndex->classNames));
} | php | public function intersect(ClassNameIndex $classNameIndex): ClassNameIndex
{
return new ClassNameIndex(array_intersect_key($this->classNames, $classNameIndex->classNames));
} | [
"public",
"function",
"intersect",
"(",
"ClassNameIndex",
"$",
"classNameIndex",
")",
":",
"ClassNameIndex",
"{",
"return",
"new",
"ClassNameIndex",
"(",
"array_intersect_key",
"(",
"$",
"this",
"->",
"classNames",
",",
"$",
"classNameIndex",
"->",
"classNames",
"... | Returns a new index object with all class names contained in this and
the given index
@param \Neos\Flow\Aop\Builder\ClassNameIndex $classNameIndex
@return \Neos\Flow\Aop\Builder\ClassNameIndex A new index object | [
"Returns",
"a",
"new",
"index",
"object",
"with",
"all",
"class",
"names",
"contained",
"in",
"this",
"and",
"the",
"given",
"index"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Aop/Builder/ClassNameIndex.php#L81-L84 |
neos/flow-development-collection | Neos.Flow/Classes/Aop/Builder/ClassNameIndex.php | ClassNameIndex.applyIntersect | public function applyIntersect(ClassNameIndex $classNameIndex): void
{
$this->classNames = array_intersect_key($this->classNames, $classNameIndex->classNames);
} | php | public function applyIntersect(ClassNameIndex $classNameIndex): void
{
$this->classNames = array_intersect_key($this->classNames, $classNameIndex->classNames);
} | [
"public",
"function",
"applyIntersect",
"(",
"ClassNameIndex",
"$",
"classNameIndex",
")",
":",
"void",
"{",
"$",
"this",
"->",
"classNames",
"=",
"array_intersect_key",
"(",
"$",
"this",
"->",
"classNames",
",",
"$",
"classNameIndex",
"->",
"classNames",
")",
... | Sets this index to all class names which are present currently and
contained in the given index
@param \Neos\Flow\Aop\Builder\ClassNameIndex $classNameIndex
@return void | [
"Sets",
"this",
"index",
"to",
"all",
"class",
"names",
"which",
"are",
"present",
"currently",
"and",
"contained",
"in",
"the",
"given",
"index"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Aop/Builder/ClassNameIndex.php#L93-L96 |
neos/flow-development-collection | Neos.Flow/Classes/Aop/Builder/ClassNameIndex.php | ClassNameIndex.union | public function union(ClassNameIndex $classNameIndex): ClassNameIndex
{
$result = clone $classNameIndex;
$result->applyUnion($this);
return $result;
} | php | public function union(ClassNameIndex $classNameIndex): ClassNameIndex
{
$result = clone $classNameIndex;
$result->applyUnion($this);
return $result;
} | [
"public",
"function",
"union",
"(",
"ClassNameIndex",
"$",
"classNameIndex",
")",
":",
"ClassNameIndex",
"{",
"$",
"result",
"=",
"clone",
"$",
"classNameIndex",
";",
"$",
"result",
"->",
"applyUnion",
"(",
"$",
"this",
")",
";",
"return",
"$",
"result",
"... | Returns a new index object containing all class names of
this index and the given one
@param \Neos\Flow\Aop\Builder\ClassNameIndex $classNameIndex
@return \Neos\Flow\Aop\Builder\ClassNameIndex A new index object | [
"Returns",
"a",
"new",
"index",
"object",
"containing",
"all",
"class",
"names",
"of",
"this",
"index",
"and",
"the",
"given",
"one"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Aop/Builder/ClassNameIndex.php#L105-L110 |
neos/flow-development-collection | Neos.Flow/Classes/Aop/Builder/ClassNameIndex.php | ClassNameIndex.applyUnion | public function applyUnion(ClassNameIndex $classNameIndex): void
{
if (count($this->classNames) > count($classNameIndex->classNames)) {
foreach ($classNameIndex->classNames as $className => $value) {
$this->classNames[$className] = true;
}
} else {
$unionClassNames = $classNameIndex->classNames;
foreach ($this->classNames as $className => $value) {
$unionClassNames[$className] = true;
}
$this->classNames = $unionClassNames;
}
} | php | public function applyUnion(ClassNameIndex $classNameIndex): void
{
if (count($this->classNames) > count($classNameIndex->classNames)) {
foreach ($classNameIndex->classNames as $className => $value) {
$this->classNames[$className] = true;
}
} else {
$unionClassNames = $classNameIndex->classNames;
foreach ($this->classNames as $className => $value) {
$unionClassNames[$className] = true;
}
$this->classNames = $unionClassNames;
}
} | [
"public",
"function",
"applyUnion",
"(",
"ClassNameIndex",
"$",
"classNameIndex",
")",
":",
"void",
"{",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"classNames",
")",
">",
"count",
"(",
"$",
"classNameIndex",
"->",
"classNames",
")",
")",
"{",
"foreach",
... | Sets this index to all class names which are either already present or are
contained in the given index
@param \Neos\Flow\Aop\Builder\ClassNameIndex $classNameIndex
@return void | [
"Sets",
"this",
"index",
"to",
"all",
"class",
"names",
"which",
"are",
"either",
"already",
"present",
"or",
"are",
"contained",
"in",
"the",
"given",
"index"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Aop/Builder/ClassNameIndex.php#L119-L132 |
neos/flow-development-collection | Neos.Flow/Classes/Aop/Builder/ClassNameIndex.php | ClassNameIndex.filterByPrefix | public function filterByPrefix(string $prefixFilter): ClassNameIndex
{
$pointcuts = array_keys($this->classNames);
$result = new ClassNameIndex();
$right = count($pointcuts) - 1;
$left = 0;
$found = false;
$currentPosition = -1;
while ($found === false) {
if ($left > $right) {
break;
}
$currentPosition = $left + floor(($right - $left) / 2);
if (strpos($pointcuts[$currentPosition], $prefixFilter) === 0) {
$found = true;
break;
} else {
$comparisonResult = strcmp($prefixFilter, $pointcuts[$currentPosition]);
if ($comparisonResult > 0) {
$left = $currentPosition + 1;
} else {
$right = $currentPosition - 1;
}
}
}
if ($found === true) {
$startIndex = $currentPosition;
while ($startIndex >= 0 && strpos($pointcuts[$startIndex], $prefixFilter) === 0) {
$startIndex--;
}
$startIndex++;
$endIndex = $currentPosition;
while ($endIndex < count($pointcuts) && strpos($pointcuts[$endIndex], $prefixFilter) === 0) {
$endIndex++;
}
$result->setClassNames(array_slice($pointcuts, $startIndex, $endIndex - $startIndex));
}
return $result;
} | php | public function filterByPrefix(string $prefixFilter): ClassNameIndex
{
$pointcuts = array_keys($this->classNames);
$result = new ClassNameIndex();
$right = count($pointcuts) - 1;
$left = 0;
$found = false;
$currentPosition = -1;
while ($found === false) {
if ($left > $right) {
break;
}
$currentPosition = $left + floor(($right - $left) / 2);
if (strpos($pointcuts[$currentPosition], $prefixFilter) === 0) {
$found = true;
break;
} else {
$comparisonResult = strcmp($prefixFilter, $pointcuts[$currentPosition]);
if ($comparisonResult > 0) {
$left = $currentPosition + 1;
} else {
$right = $currentPosition - 1;
}
}
}
if ($found === true) {
$startIndex = $currentPosition;
while ($startIndex >= 0 && strpos($pointcuts[$startIndex], $prefixFilter) === 0) {
$startIndex--;
}
$startIndex++;
$endIndex = $currentPosition;
while ($endIndex < count($pointcuts) && strpos($pointcuts[$endIndex], $prefixFilter) === 0) {
$endIndex++;
}
$result->setClassNames(array_slice($pointcuts, $startIndex, $endIndex - $startIndex));
}
return $result;
} | [
"public",
"function",
"filterByPrefix",
"(",
"string",
"$",
"prefixFilter",
")",
":",
"ClassNameIndex",
"{",
"$",
"pointcuts",
"=",
"array_keys",
"(",
"$",
"this",
"->",
"classNames",
")",
";",
"$",
"result",
"=",
"new",
"ClassNameIndex",
"(",
")",
";",
"$... | Returns a new index object which contains all class names of this index
starting with the given prefix
@param string $prefixFilter A prefix string to filter the class names of this index
@return \Neos\Flow\Aop\Builder\ClassNameIndex A new index object | [
"Returns",
"a",
"new",
"index",
"object",
"which",
"contains",
"all",
"class",
"names",
"of",
"this",
"index",
"starting",
"with",
"the",
"given",
"prefix"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Aop/Builder/ClassNameIndex.php#L157-L199 |
neos/flow-development-collection | Neos.Flow/Classes/Security/Authorization/Privilege/AbstractPrivilege.php | AbstractPrivilege.getParsedMatcher | public function getParsedMatcher()
{
$parsedMatcher = $this->matcher;
// TODO: handle parameters that are not strings
foreach ($this->parameters as $parameter) {
$parsedMatcher = str_replace('{parameters.' . $parameter->getName() . '}', $parameter->getValue(), $parsedMatcher);
}
return $parsedMatcher;
} | php | public function getParsedMatcher()
{
$parsedMatcher = $this->matcher;
// TODO: handle parameters that are not strings
foreach ($this->parameters as $parameter) {
$parsedMatcher = str_replace('{parameters.' . $parameter->getName() . '}', $parameter->getValue(), $parsedMatcher);
}
return $parsedMatcher;
} | [
"public",
"function",
"getParsedMatcher",
"(",
")",
"{",
"$",
"parsedMatcher",
"=",
"$",
"this",
"->",
"matcher",
";",
"// TODO: handle parameters that are not strings",
"foreach",
"(",
"$",
"this",
"->",
"parameters",
"as",
"$",
"parameter",
")",
"{",
"$",
"par... | Returns the matcher string with replaced parameter markers. @see getMatcher()
@return string | [
"Returns",
"the",
"matcher",
"string",
"with",
"replaced",
"parameter",
"markers",
".",
"@see",
"getMatcher",
"()"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Authorization/Privilege/AbstractPrivilege.php#L193-L201 |
neos/flow-development-collection | Neos.FluidAdaptor/Classes/View/StandaloneView.php | StandaloneView.initializeObject | public function initializeObject()
{
if ($this->request === null) {
$requestHandler = $this->bootstrap->getActiveRequestHandler();
if ($requestHandler instanceof HttpRequestHandlerInterface) {
$this->request = new ActionRequest($requestHandler->getHttpRequest());
} else {
$httpRequest = Request::createFromEnvironment();
$this->request = new ActionRequest($httpRequest);
}
}
$uriBuilder = new UriBuilder();
$uriBuilder->setRequest($this->request);
$this->setControllerContext(new ControllerContext(
$this->request,
new ActionResponse(),
new Arguments([]),
$uriBuilder
));
} | php | public function initializeObject()
{
if ($this->request === null) {
$requestHandler = $this->bootstrap->getActiveRequestHandler();
if ($requestHandler instanceof HttpRequestHandlerInterface) {
$this->request = new ActionRequest($requestHandler->getHttpRequest());
} else {
$httpRequest = Request::createFromEnvironment();
$this->request = new ActionRequest($httpRequest);
}
}
$uriBuilder = new UriBuilder();
$uriBuilder->setRequest($this->request);
$this->setControllerContext(new ControllerContext(
$this->request,
new ActionResponse(),
new Arguments([]),
$uriBuilder
));
} | [
"public",
"function",
"initializeObject",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"request",
"===",
"null",
")",
"{",
"$",
"requestHandler",
"=",
"$",
"this",
"->",
"bootstrap",
"->",
"getActiveRequestHandler",
"(",
")",
";",
"if",
"(",
"$",
"reques... | Initiates the StandaloneView by creating the required ControllerContext
@return void | [
"Initiates",
"the",
"StandaloneView",
"by",
"creating",
"the",
"required",
"ControllerContext"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.FluidAdaptor/Classes/View/StandaloneView.php#L111-L132 |
neos/flow-development-collection | Neos.FluidAdaptor/Classes/View/StandaloneView.php | StandaloneView.setFormat | public function setFormat($format)
{
$this->request->setFormat($format);
$this->baseRenderingContext->getTemplatePaths()->setFormat($format);
} | php | public function setFormat($format)
{
$this->request->setFormat($format);
$this->baseRenderingContext->getTemplatePaths()->setFormat($format);
} | [
"public",
"function",
"setFormat",
"(",
"$",
"format",
")",
"{",
"$",
"this",
"->",
"request",
"->",
"setFormat",
"(",
"$",
"format",
")",
";",
"$",
"this",
"->",
"baseRenderingContext",
"->",
"getTemplatePaths",
"(",
")",
"->",
"setFormat",
"(",
"$",
"f... | Sets the format of the current request (default format is "html")
@param string $format
@return void
@api | [
"Sets",
"the",
"format",
"of",
"the",
"current",
"request",
"(",
"default",
"format",
"is",
"html",
")"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.FluidAdaptor/Classes/View/StandaloneView.php#L149-L153 |
neos/flow-development-collection | Neos.FluidAdaptor/Classes/View/StandaloneView.php | StandaloneView.setTemplatePathAndFilename | public function setTemplatePathAndFilename($templatePathAndFilename)
{
$this->baseRenderingContext->getTemplatePaths()->setTemplatePathAndFilename($templatePathAndFilename);
$partialRootPaths = $this->baseRenderingContext->getTemplatePaths()->getPartialRootPaths();
$layoutRootPaths = $this->baseRenderingContext->getTemplatePaths()->getLayoutRootPaths();
array_unshift($partialRootPaths, Files::concatenatePaths([dirname($templatePathAndFilename), 'Partials']));
array_unshift($layoutRootPaths, Files::concatenatePaths([dirname($templatePathAndFilename), 'Layouts']));
$this->baseRenderingContext->getTemplatePaths()->setPartialRootPaths($partialRootPaths);
$this->baseRenderingContext->getTemplatePaths()->setLayoutRootPaths($layoutRootPaths);
} | php | public function setTemplatePathAndFilename($templatePathAndFilename)
{
$this->baseRenderingContext->getTemplatePaths()->setTemplatePathAndFilename($templatePathAndFilename);
$partialRootPaths = $this->baseRenderingContext->getTemplatePaths()->getPartialRootPaths();
$layoutRootPaths = $this->baseRenderingContext->getTemplatePaths()->getLayoutRootPaths();
array_unshift($partialRootPaths, Files::concatenatePaths([dirname($templatePathAndFilename), 'Partials']));
array_unshift($layoutRootPaths, Files::concatenatePaths([dirname($templatePathAndFilename), 'Layouts']));
$this->baseRenderingContext->getTemplatePaths()->setPartialRootPaths($partialRootPaths);
$this->baseRenderingContext->getTemplatePaths()->setLayoutRootPaths($layoutRootPaths);
} | [
"public",
"function",
"setTemplatePathAndFilename",
"(",
"$",
"templatePathAndFilename",
")",
"{",
"$",
"this",
"->",
"baseRenderingContext",
"->",
"getTemplatePaths",
"(",
")",
"->",
"setTemplatePathAndFilename",
"(",
"$",
"templatePathAndFilename",
")",
";",
"$",
"p... | Sets the absolute path to a Fluid template file
@param string $templatePathAndFilename Fluid template path
@return void
@api | [
"Sets",
"the",
"absolute",
"path",
"to",
"a",
"Fluid",
"template",
"file"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.FluidAdaptor/Classes/View/StandaloneView.php#L183-L193 |
neos/flow-development-collection | Neos.FluidAdaptor/Classes/View/StandaloneView.php | StandaloneView.getTemplatePathAndFilename | public function getTemplatePathAndFilename()
{
return $this->baseRenderingContext->getTemplatePaths()->resolveTemplateFileForControllerAndActionAndFormat($this->request->getControllerName(), $this->request->getControllerActionName(), $this->request->getFormat());
} | php | public function getTemplatePathAndFilename()
{
return $this->baseRenderingContext->getTemplatePaths()->resolveTemplateFileForControllerAndActionAndFormat($this->request->getControllerName(), $this->request->getControllerActionName(), $this->request->getFormat());
} | [
"public",
"function",
"getTemplatePathAndFilename",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"baseRenderingContext",
"->",
"getTemplatePaths",
"(",
")",
"->",
"resolveTemplateFileForControllerAndActionAndFormat",
"(",
"$",
"this",
"->",
"request",
"->",
"getControlle... | Returns the absolute path to a Fluid template file if it was specified with setTemplatePathAndFilename() before
@return string Fluid template path
@api | [
"Returns",
"the",
"absolute",
"path",
"to",
"a",
"Fluid",
"template",
"file",
"if",
"it",
"was",
"specified",
"with",
"setTemplatePathAndFilename",
"()",
"before"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.FluidAdaptor/Classes/View/StandaloneView.php#L201-L204 |
neos/flow-development-collection | Neos.FluidAdaptor/Classes/View/StandaloneView.php | StandaloneView.hasTemplate | public function hasTemplate()
{
try {
$this->baseRenderingContext->getTemplatePaths()->getTemplateSource(
$this->baseRenderingContext->getControllerName(),
$this->baseRenderingContext->getControllerAction()
);
return true;
} catch (InvalidTemplateResourceException $e) {
return false;
}
} | php | public function hasTemplate()
{
try {
$this->baseRenderingContext->getTemplatePaths()->getTemplateSource(
$this->baseRenderingContext->getControllerName(),
$this->baseRenderingContext->getControllerAction()
);
return true;
} catch (InvalidTemplateResourceException $e) {
return false;
}
} | [
"public",
"function",
"hasTemplate",
"(",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"baseRenderingContext",
"->",
"getTemplatePaths",
"(",
")",
"->",
"getTemplateSource",
"(",
"$",
"this",
"->",
"baseRenderingContext",
"->",
"getControllerName",
"(",
")",
",",
... | Checks whether a template can be resolved for the current request
@return bool
@api | [
"Checks",
"whether",
"a",
"template",
"can",
"be",
"resolved",
"for",
"the",
"current",
"request"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.FluidAdaptor/Classes/View/StandaloneView.php#L310-L322 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.