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/Persistence/Doctrine/PersistenceManager.php | PersistenceManager.tearDown | public function tearDown()
{
// "driver" is used only for Doctrine, thus we (mis-)use it here
// additionally, when no path is set, skip this step, assuming no DB is needed
if ($this->settings['backendOptions']['driver'] !== null && $this->settings['backendOptions']['path'] !== null) {
$this->entityManager->clear();
$schemaTool = new SchemaTool($this->entityManager);
$schemaTool->dropDatabase();
$this->logger->notice('Doctrine 2 schema destroyed.');
} else {
$this->logger->notice('Doctrine 2 destroy skipped, driver and path backend options not set!');
}
} | php | public function tearDown()
{
// "driver" is used only for Doctrine, thus we (mis-)use it here
// additionally, when no path is set, skip this step, assuming no DB is needed
if ($this->settings['backendOptions']['driver'] !== null && $this->settings['backendOptions']['path'] !== null) {
$this->entityManager->clear();
$schemaTool = new SchemaTool($this->entityManager);
$schemaTool->dropDatabase();
$this->logger->notice('Doctrine 2 schema destroyed.');
} else {
$this->logger->notice('Doctrine 2 destroy skipped, driver and path backend options not set!');
}
} | [
"public",
"function",
"tearDown",
"(",
")",
"{",
"// \"driver\" is used only for Doctrine, thus we (mis-)use it here",
"// additionally, when no path is set, skip this step, assuming no DB is needed",
"if",
"(",
"$",
"this",
"->",
"settings",
"[",
"'backendOptions'",
"]",
"[",
"'... | Called after a functional test in Flow, dumps everything in the database.
@return void | [
"Called",
"after",
"a",
"functional",
"test",
"in",
"Flow",
"dumps",
"everything",
"in",
"the",
"database",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Persistence/Doctrine/PersistenceManager.php#L314-L327 |
neos/flow-development-collection | Neos.Flow/Classes/Persistence/Doctrine/PersistenceManager.php | PersistenceManager.hasUnpersistedChanges | public function hasUnpersistedChanges()
{
$unitOfWork = $this->entityManager->getUnitOfWork();
$unitOfWork->computeChangeSets();
if ($unitOfWork->getScheduledEntityInsertions() !== []
|| $unitOfWork->getScheduledEntityUpdates() !== []
|| $unitOfWork->getScheduledEntityDeletions() !== []
|| $unitOfWork->getScheduledCollectionDeletions() !== []
|| $unitOfWork->getScheduledCollectionUpdates() !== []
) {
return true;
}
return false;
} | php | public function hasUnpersistedChanges()
{
$unitOfWork = $this->entityManager->getUnitOfWork();
$unitOfWork->computeChangeSets();
if ($unitOfWork->getScheduledEntityInsertions() !== []
|| $unitOfWork->getScheduledEntityUpdates() !== []
|| $unitOfWork->getScheduledEntityDeletions() !== []
|| $unitOfWork->getScheduledCollectionDeletions() !== []
|| $unitOfWork->getScheduledCollectionUpdates() !== []
) {
return true;
}
return false;
} | [
"public",
"function",
"hasUnpersistedChanges",
"(",
")",
"{",
"$",
"unitOfWork",
"=",
"$",
"this",
"->",
"entityManager",
"->",
"getUnitOfWork",
"(",
")",
";",
"$",
"unitOfWork",
"->",
"computeChangeSets",
"(",
")",
";",
"if",
"(",
"$",
"unitOfWork",
"->",
... | Gives feedback if the persistence Manager has unpersisted changes.
This is primarily used to inform the user if he tries to save
data in an unsafe request.
@return boolean | [
"Gives",
"feedback",
"if",
"the",
"persistence",
"Manager",
"has",
"unpersisted",
"changes",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Persistence/Doctrine/PersistenceManager.php#L347-L362 |
neos/flow-development-collection | Neos.Flow/Classes/Configuration/Source/YamlSource.php | YamlSource.has | public function has(string $pathAndFilename, bool $allowSplitSource = false): bool
{
if ($allowSplitSource === true) {
$pathsAndFileNames = glob($pathAndFilename . '.*.yaml');
if ($pathsAndFileNames !== false) {
foreach ($pathsAndFileNames as $pathAndFilename) {
if (is_file($pathAndFilename)) {
return true;
}
}
}
}
if (is_file($pathAndFilename . '.yaml')) {
return true;
}
return false;
} | php | public function has(string $pathAndFilename, bool $allowSplitSource = false): bool
{
if ($allowSplitSource === true) {
$pathsAndFileNames = glob($pathAndFilename . '.*.yaml');
if ($pathsAndFileNames !== false) {
foreach ($pathsAndFileNames as $pathAndFilename) {
if (is_file($pathAndFilename)) {
return true;
}
}
}
}
if (is_file($pathAndFilename . '.yaml')) {
return true;
}
return false;
} | [
"public",
"function",
"has",
"(",
"string",
"$",
"pathAndFilename",
",",
"bool",
"$",
"allowSplitSource",
"=",
"false",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"allowSplitSource",
"===",
"true",
")",
"{",
"$",
"pathsAndFileNames",
"=",
"glob",
"(",
"$",
"... | Checks for the specified configuration file and returns true if it exists.
@param string $pathAndFilename Full path and filename of the file to load, excluding the file extension (ie. ".yaml")
@param boolean $allowSplitSource If true, the type will be used as a prefix when looking for configuration files
@return boolean | [
"Checks",
"for",
"the",
"specified",
"configuration",
"file",
"and",
"returns",
"true",
"if",
"it",
"exists",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Configuration/Source/YamlSource.php#L52-L69 |
neos/flow-development-collection | Neos.Flow/Classes/Configuration/Source/YamlSource.php | YamlSource.load | public function load(string $pathAndFilename, bool $allowSplitSource = false): array
{
$this->detectFilesWithWrongExtension($pathAndFilename, $allowSplitSource);
$pathsAndFileNames = [$pathAndFilename . '.yaml'];
if ($allowSplitSource === true) {
$splitSourcePathsAndFileNames = glob($pathAndFilename . '.*.yaml');
$splitSourcePathsAndFileNames = array_merge($splitSourcePathsAndFileNames, glob($pathAndFilename . '.*.yml'));
if ($splitSourcePathsAndFileNames !== false) {
sort($splitSourcePathsAndFileNames);
$pathsAndFileNames = array_merge($pathsAndFileNames, $splitSourcePathsAndFileNames);
}
}
$configuration = [];
foreach ($pathsAndFileNames as $pathAndFilename) {
$configuration = $this->mergeFileContent($pathAndFilename, $configuration);
}
return $configuration;
} | php | public function load(string $pathAndFilename, bool $allowSplitSource = false): array
{
$this->detectFilesWithWrongExtension($pathAndFilename, $allowSplitSource);
$pathsAndFileNames = [$pathAndFilename . '.yaml'];
if ($allowSplitSource === true) {
$splitSourcePathsAndFileNames = glob($pathAndFilename . '.*.yaml');
$splitSourcePathsAndFileNames = array_merge($splitSourcePathsAndFileNames, glob($pathAndFilename . '.*.yml'));
if ($splitSourcePathsAndFileNames !== false) {
sort($splitSourcePathsAndFileNames);
$pathsAndFileNames = array_merge($pathsAndFileNames, $splitSourcePathsAndFileNames);
}
}
$configuration = [];
foreach ($pathsAndFileNames as $pathAndFilename) {
$configuration = $this->mergeFileContent($pathAndFilename, $configuration);
}
return $configuration;
} | [
"public",
"function",
"load",
"(",
"string",
"$",
"pathAndFilename",
",",
"bool",
"$",
"allowSplitSource",
"=",
"false",
")",
":",
"array",
"{",
"$",
"this",
"->",
"detectFilesWithWrongExtension",
"(",
"$",
"pathAndFilename",
",",
"$",
"allowSplitSource",
")",
... | Loads the specified configuration file and returns its content as an
array. If the file does not exist or could not be loaded, an empty
array is returned
@param string $pathAndFilename Full path and filename of the file to load, excluding the file extension (ie. ".yaml")
@param boolean $allowSplitSource If true, the type will be used as a prefix when looking for configuration files
@return array
@throws ParseErrorException
@throws \Neos\Flow\Configuration\Exception | [
"Loads",
"the",
"specified",
"configuration",
"file",
"and",
"returns",
"its",
"content",
"as",
"an",
"array",
".",
"If",
"the",
"file",
"does",
"not",
"exist",
"or",
"could",
"not",
"be",
"loaded",
"an",
"empty",
"array",
"is",
"returned"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Configuration/Source/YamlSource.php#L82-L99 |
neos/flow-development-collection | Neos.Flow/Classes/Configuration/Source/YamlSource.php | YamlSource.mergeFileContent | protected function mergeFileContent(string $pathAndFilename, array $configuration): array
{
if (!is_file($pathAndFilename)) {
return $configuration;
}
try {
$yaml = file_get_contents($pathAndFilename);
if ($this->usePhpYamlExtension) {
$loadedConfiguration = @yaml_parse($yaml);
if ($loadedConfiguration === false) {
throw new ParseErrorException('A parse error occurred while parsing file "' . $pathAndFilename . '".', 1391894094);
}
} else {
$loadedConfiguration = Yaml::parse($yaml);
}
unset($yaml);
if (is_array($loadedConfiguration)) {
$configuration = Arrays::arrayMergeRecursiveOverrule($configuration, $loadedConfiguration);
}
} catch (Exception $exception) {
throw new ParseErrorException('A parse error occurred while parsing file "' . $pathAndFilename . '". Error message: ' . $exception->getMessage(), 1232014321);
}
return $configuration;
} | php | protected function mergeFileContent(string $pathAndFilename, array $configuration): array
{
if (!is_file($pathAndFilename)) {
return $configuration;
}
try {
$yaml = file_get_contents($pathAndFilename);
if ($this->usePhpYamlExtension) {
$loadedConfiguration = @yaml_parse($yaml);
if ($loadedConfiguration === false) {
throw new ParseErrorException('A parse error occurred while parsing file "' . $pathAndFilename . '".', 1391894094);
}
} else {
$loadedConfiguration = Yaml::parse($yaml);
}
unset($yaml);
if (is_array($loadedConfiguration)) {
$configuration = Arrays::arrayMergeRecursiveOverrule($configuration, $loadedConfiguration);
}
} catch (Exception $exception) {
throw new ParseErrorException('A parse error occurred while parsing file "' . $pathAndFilename . '". Error message: ' . $exception->getMessage(), 1232014321);
}
return $configuration;
} | [
"protected",
"function",
"mergeFileContent",
"(",
"string",
"$",
"pathAndFilename",
",",
"array",
"$",
"configuration",
")",
":",
"array",
"{",
"if",
"(",
"!",
"is_file",
"(",
"$",
"pathAndFilename",
")",
")",
"{",
"return",
"$",
"configuration",
";",
"}",
... | Loads the file with the given path and merge it's contents into the configuration array.
@param string $pathAndFilename
@param array $configuration
@return array
@throws ParseErrorException | [
"Loads",
"the",
"file",
"with",
"the",
"given",
"path",
"and",
"merge",
"it",
"s",
"contents",
"into",
"the",
"configuration",
"array",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Configuration/Source/YamlSource.php#L131-L157 |
neos/flow-development-collection | Neos.Flow/Classes/Configuration/Source/YamlSource.php | YamlSource.save | public function save(string $pathAndFilename, array $configuration)
{
$header = '';
if (file_exists($pathAndFilename . '.yaml')) {
$header = $this->getHeaderFromFile($pathAndFilename . '.yaml');
}
$yaml = Yaml::dump($configuration, 99, 2);
file_put_contents($pathAndFilename . '.yaml', $header . chr(10) . $yaml);
} | php | public function save(string $pathAndFilename, array $configuration)
{
$header = '';
if (file_exists($pathAndFilename . '.yaml')) {
$header = $this->getHeaderFromFile($pathAndFilename . '.yaml');
}
$yaml = Yaml::dump($configuration, 99, 2);
file_put_contents($pathAndFilename . '.yaml', $header . chr(10) . $yaml);
} | [
"public",
"function",
"save",
"(",
"string",
"$",
"pathAndFilename",
",",
"array",
"$",
"configuration",
")",
"{",
"$",
"header",
"=",
"''",
";",
"if",
"(",
"file_exists",
"(",
"$",
"pathAndFilename",
".",
"'.yaml'",
")",
")",
"{",
"$",
"header",
"=",
... | Save the specified configuration array to the given file in YAML format.
@param string $pathAndFilename Full path and filename of the file to write to, excluding the dot and file extension (i.e. ".yaml")
@param array $configuration The configuration to save
@return void | [
"Save",
"the",
"specified",
"configuration",
"array",
"to",
"the",
"given",
"file",
"in",
"YAML",
"format",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Configuration/Source/YamlSource.php#L166-L174 |
neos/flow-development-collection | Neos.Flow/Classes/Configuration/Source/YamlSource.php | YamlSource.getHeaderFromFile | protected function getHeaderFromFile(string $pathAndFilename): string
{
$header = '';
$fileHandle = fopen($pathAndFilename, 'r');
while ($line = fgets($fileHandle)) {
if (preg_match('/^#/', $line)) {
$header .= $line;
} else {
break;
}
}
fclose($fileHandle);
return $header;
} | php | protected function getHeaderFromFile(string $pathAndFilename): string
{
$header = '';
$fileHandle = fopen($pathAndFilename, 'r');
while ($line = fgets($fileHandle)) {
if (preg_match('/^#/', $line)) {
$header .= $line;
} else {
break;
}
}
fclose($fileHandle);
return $header;
} | [
"protected",
"function",
"getHeaderFromFile",
"(",
"string",
"$",
"pathAndFilename",
")",
":",
"string",
"{",
"$",
"header",
"=",
"''",
";",
"$",
"fileHandle",
"=",
"fopen",
"(",
"$",
"pathAndFilename",
",",
"'r'",
")",
";",
"while",
"(",
"$",
"line",
"=... | Read the header part from the given file. That means, every line
until the first non comment line is found.
@param string $pathAndFilename
@return string The header of the given YAML file | [
"Read",
"the",
"header",
"part",
"from",
"the",
"given",
"file",
".",
"That",
"means",
"every",
"line",
"until",
"the",
"first",
"non",
"comment",
"line",
"is",
"found",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Configuration/Source/YamlSource.php#L183-L196 |
neos/flow-development-collection | Neos.Flow/Classes/Validation/Validator/AbstractCompositeValidator.php | AbstractCompositeValidator.addValidator | public function addValidator(ValidatorInterface $validator)
{
if ($validator instanceof ObjectValidatorInterface) {
$validator->setValidatedInstancesContainer = $this->validatedInstancesContainer;
}
$this->validators->attach($validator);
} | php | public function addValidator(ValidatorInterface $validator)
{
if ($validator instanceof ObjectValidatorInterface) {
$validator->setValidatedInstancesContainer = $this->validatedInstancesContainer;
}
$this->validators->attach($validator);
} | [
"public",
"function",
"addValidator",
"(",
"ValidatorInterface",
"$",
"validator",
")",
"{",
"if",
"(",
"$",
"validator",
"instanceof",
"ObjectValidatorInterface",
")",
"{",
"$",
"validator",
"->",
"setValidatedInstancesContainer",
"=",
"$",
"this",
"->",
"validated... | Adds a new validator to the conjunction.
@param ValidatorInterface $validator The validator that should be added
@return void
@api | [
"Adds",
"a",
"new",
"validator",
"to",
"the",
"conjunction",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Validation/Validator/AbstractCompositeValidator.php#L103-L109 |
neos/flow-development-collection | Neos.Flow/Classes/Validation/Validator/AbstractCompositeValidator.php | AbstractCompositeValidator.removeValidator | public function removeValidator(ValidatorInterface $validator)
{
if (!$this->validators->contains($validator)) {
throw new NoSuchValidatorException('Cannot remove validator because its not in the conjunction.', 1207020177);
}
$this->validators->detach($validator);
} | php | public function removeValidator(ValidatorInterface $validator)
{
if (!$this->validators->contains($validator)) {
throw new NoSuchValidatorException('Cannot remove validator because its not in the conjunction.', 1207020177);
}
$this->validators->detach($validator);
} | [
"public",
"function",
"removeValidator",
"(",
"ValidatorInterface",
"$",
"validator",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"validators",
"->",
"contains",
"(",
"$",
"validator",
")",
")",
"{",
"throw",
"new",
"NoSuchValidatorException",
"(",
"'Cannot r... | Removes the specified validator.
@param ValidatorInterface $validator The validator to remove
@throws NoSuchValidatorException
@api | [
"Removes",
"the",
"specified",
"validator",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Validation/Validator/AbstractCompositeValidator.php#L118-L124 |
neos/flow-development-collection | Neos.Flow/Migrations/Mysql/Version20141113173712.php | Version20141113173712.migrateAccountRolesUp | protected function migrateAccountRolesUp()
{
if (!$this->sm->tablesExist(['typo3_flow_security_account_roles_join', 'typo3_flow_security_policy_role'])) {
return;
}
$accountsWithRoles = array();
$accountRolesResult = $this->connection->executeQuery('SELECT j.flow_security_account, r.identifier FROM typo3_flow_security_account_roles_join as j LEFT JOIN typo3_flow_security_policy_role AS r ON j.flow_policy_role = r.identifier');
while ($accountIdentifierAndRole = $accountRolesResult->fetch(\PDO::FETCH_ASSOC)) {
$accountIdentifier = $accountIdentifierAndRole['flow_security_account'];
$accountsWithRoles[$accountIdentifier][] = $accountIdentifierAndRole['identifier'];
}
foreach ($accountsWithRoles as $accountIdentifier => $roles) {
$this->addSql("UPDATE typo3_flow_security_account SET roleidentifiers = " . $this->connection->quote(implode(',', $roles)) . " WHERE persistence_object_identifier = " . $this->connection->quote($accountIdentifier));
}
} | php | protected function migrateAccountRolesUp()
{
if (!$this->sm->tablesExist(['typo3_flow_security_account_roles_join', 'typo3_flow_security_policy_role'])) {
return;
}
$accountsWithRoles = array();
$accountRolesResult = $this->connection->executeQuery('SELECT j.flow_security_account, r.identifier FROM typo3_flow_security_account_roles_join as j LEFT JOIN typo3_flow_security_policy_role AS r ON j.flow_policy_role = r.identifier');
while ($accountIdentifierAndRole = $accountRolesResult->fetch(\PDO::FETCH_ASSOC)) {
$accountIdentifier = $accountIdentifierAndRole['flow_security_account'];
$accountsWithRoles[$accountIdentifier][] = $accountIdentifierAndRole['identifier'];
}
foreach ($accountsWithRoles as $accountIdentifier => $roles) {
$this->addSql("UPDATE typo3_flow_security_account SET roleidentifiers = " . $this->connection->quote(implode(',', $roles)) . " WHERE persistence_object_identifier = " . $this->connection->quote($accountIdentifier));
}
} | [
"protected",
"function",
"migrateAccountRolesUp",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"sm",
"->",
"tablesExist",
"(",
"[",
"'typo3_flow_security_account_roles_join'",
",",
"'typo3_flow_security_policy_role'",
"]",
")",
")",
"{",
"return",
";",
"}",
... | Generate SQL statements to migrate accounts up to embedded roles.
@return void | [
"Generate",
"SQL",
"statements",
"to",
"migrate",
"accounts",
"up",
"to",
"embedded",
"roles",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Migrations/Mysql/Version20141113173712.php#L65-L81 |
neos/flow-development-collection | Neos.Flow/Migrations/Mysql/Version20141113173712.php | Version20141113173712.migrateAccountRolesDown | protected function migrateAccountRolesDown()
{
if (!$this->sm->tablesExist(['typo3_flow_security_account', 'typo3_flow_security_policy_role', 'typo3_flow_security_account_roles_join'])) {
return;
}
$allRolesAndAccounts = array();
$accountRolesResult = $this->connection->executeQuery('SELECT persistence_object_identifier, roleidentifiers FROM typo3_flow_security_account');
while ($accountIdentifierAndRoles = $accountRolesResult->fetch(\PDO::FETCH_ASSOC)) {
$accountIdentifier = $accountIdentifierAndRoles['persistence_object_identifier'];
$roleIdentifiers = explode(',', $accountIdentifierAndRoles['roleidentifiers']);
foreach ($roleIdentifiers as $roleIdentifier) {
if (!isset($allRolesAndAccounts[$roleIdentifier])) {
$allRolesAndAccounts[$roleIdentifier] = array();
}
$allRolesAndAccounts[$roleIdentifier][] = $accountIdentifier;
}
}
$this->addSql("INSERT INTO typo3_flow_security_policy_role (identifier, sourcehint) VALUES ('Everybody', 'system')");
$this->addSql("INSERT INTO typo3_flow_security_policy_role (identifier, sourcehint) VALUES ('Anonymous', 'system')");
$this->addSql("INSERT INTO typo3_flow_security_policy_role (identifier, sourcehint) VALUES ('AuthenticatedUser', 'system')");
foreach ($allRolesAndAccounts as $roleIdentifier => $accountIdentifiers) {
$this->addSql("INSERT INTO typo3_flow_security_policy_role (identifier, sourcehint) VALUES (" . $this->connection->quote($roleIdentifier) . ", 'policy')");
foreach ($accountIdentifiers as $accountIdentifier) {
$this->addSql("INSERT INTO typo3_flow_security_account_roles_join (flow_security_account, flow_policy_role) VALUES (" . $this->connection->quote($accountIdentifier) . ", " . $this->connection->quote($roleIdentifier) . ")");
}
}
} | php | protected function migrateAccountRolesDown()
{
if (!$this->sm->tablesExist(['typo3_flow_security_account', 'typo3_flow_security_policy_role', 'typo3_flow_security_account_roles_join'])) {
return;
}
$allRolesAndAccounts = array();
$accountRolesResult = $this->connection->executeQuery('SELECT persistence_object_identifier, roleidentifiers FROM typo3_flow_security_account');
while ($accountIdentifierAndRoles = $accountRolesResult->fetch(\PDO::FETCH_ASSOC)) {
$accountIdentifier = $accountIdentifierAndRoles['persistence_object_identifier'];
$roleIdentifiers = explode(',', $accountIdentifierAndRoles['roleidentifiers']);
foreach ($roleIdentifiers as $roleIdentifier) {
if (!isset($allRolesAndAccounts[$roleIdentifier])) {
$allRolesAndAccounts[$roleIdentifier] = array();
}
$allRolesAndAccounts[$roleIdentifier][] = $accountIdentifier;
}
}
$this->addSql("INSERT INTO typo3_flow_security_policy_role (identifier, sourcehint) VALUES ('Everybody', 'system')");
$this->addSql("INSERT INTO typo3_flow_security_policy_role (identifier, sourcehint) VALUES ('Anonymous', 'system')");
$this->addSql("INSERT INTO typo3_flow_security_policy_role (identifier, sourcehint) VALUES ('AuthenticatedUser', 'system')");
foreach ($allRolesAndAccounts as $roleIdentifier => $accountIdentifiers) {
$this->addSql("INSERT INTO typo3_flow_security_policy_role (identifier, sourcehint) VALUES (" . $this->connection->quote($roleIdentifier) . ", 'policy')");
foreach ($accountIdentifiers as $accountIdentifier) {
$this->addSql("INSERT INTO typo3_flow_security_account_roles_join (flow_security_account, flow_policy_role) VALUES (" . $this->connection->quote($accountIdentifier) . ", " . $this->connection->quote($roleIdentifier) . ")");
}
}
} | [
"protected",
"function",
"migrateAccountRolesDown",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"sm",
"->",
"tablesExist",
"(",
"[",
"'typo3_flow_security_account'",
",",
"'typo3_flow_security_policy_role'",
",",
"'typo3_flow_security_account_roles_join'",
"]",
")... | Generate SQL statements to migrate accounts down to embedded roles.
@return void | [
"Generate",
"SQL",
"statements",
"to",
"migrate",
"accounts",
"down",
"to",
"embedded",
"roles",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Migrations/Mysql/Version20141113173712.php#L88-L114 |
neos/flow-development-collection | Neos.Flow/Classes/Aop/Advice/AdviceChain.php | AdviceChain.proceed | public function proceed(JoinPointInterface &$joinPoint)
{
$this->adviceIndex++;
if ($this->adviceIndex < count($this->advices)) {
$result = $this->advices[$this->adviceIndex]->invoke($joinPoint);
} else {
$result = $joinPoint->getProxy()->Flow_Aop_Proxy_invokeJoinpoint($joinPoint);
}
return $result;
} | php | public function proceed(JoinPointInterface &$joinPoint)
{
$this->adviceIndex++;
if ($this->adviceIndex < count($this->advices)) {
$result = $this->advices[$this->adviceIndex]->invoke($joinPoint);
} else {
$result = $joinPoint->getProxy()->Flow_Aop_Proxy_invokeJoinpoint($joinPoint);
}
return $result;
} | [
"public",
"function",
"proceed",
"(",
"JoinPointInterface",
"&",
"$",
"joinPoint",
")",
"{",
"$",
"this",
"->",
"adviceIndex",
"++",
";",
"if",
"(",
"$",
"this",
"->",
"adviceIndex",
"<",
"count",
"(",
"$",
"this",
"->",
"advices",
")",
")",
"{",
"$",
... | An advice usually calls (but doesn't have to necessarily) this method
in order to proceed with the next advice in the chain. If no advice is
left in the chain, the proxy classes' method invokeJoinpoint() will finally
be called.
@param JoinPointInterface $joinPoint The current join point (ie. the context)
@return mixed Result of the advice or the original method of the target class | [
"An",
"advice",
"usually",
"calls",
"(",
"but",
"doesn",
"t",
"have",
"to",
"necessarily",
")",
"this",
"method",
"in",
"order",
"to",
"proceed",
"with",
"the",
"next",
"advice",
"in",
"the",
"chain",
".",
"If",
"no",
"advice",
"is",
"left",
"in",
"the... | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Aop/Advice/AdviceChain.php#L53-L62 |
neos/flow-development-collection | Neos.Flow/Classes/I18n/Cldr/Reader/NumbersReader.php | NumbersReader.initializeObject | public function initializeObject()
{
if ($this->cache->has('parsedFormats') && $this->cache->has('parsedFormatsIndices') && $this->cache->has('localizedSymbols')) {
$this->parsedFormats = $this->cache->get('parsedFormats');
$this->parsedFormatsIndices = $this->cache->get('parsedFormatsIndices');
$this->localizedSymbols = $this->cache->get('localizedSymbols');
}
} | php | public function initializeObject()
{
if ($this->cache->has('parsedFormats') && $this->cache->has('parsedFormatsIndices') && $this->cache->has('localizedSymbols')) {
$this->parsedFormats = $this->cache->get('parsedFormats');
$this->parsedFormatsIndices = $this->cache->get('parsedFormatsIndices');
$this->localizedSymbols = $this->cache->get('localizedSymbols');
}
} | [
"public",
"function",
"initializeObject",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"cache",
"->",
"has",
"(",
"'parsedFormats'",
")",
"&&",
"$",
"this",
"->",
"cache",
"->",
"has",
"(",
"'parsedFormatsIndices'",
")",
"&&",
"$",
"this",
"->",
"cache",... | Constructs the reader, loading parsed data from cache if available.
@return void | [
"Constructs",
"the",
"reader",
"loading",
"parsed",
"data",
"from",
"cache",
"if",
"available",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/I18n/Cldr/Reader/NumbersReader.php#L187-L194 |
neos/flow-development-collection | Neos.Flow/Classes/I18n/Cldr/Reader/NumbersReader.php | NumbersReader.shutdownObject | public function shutdownObject()
{
$this->cache->set('parsedFormats', $this->parsedFormats);
$this->cache->set('parsedFormatsIndices', $this->parsedFormatsIndices);
$this->cache->set('localizedSymbols', $this->localizedSymbols);
} | php | public function shutdownObject()
{
$this->cache->set('parsedFormats', $this->parsedFormats);
$this->cache->set('parsedFormatsIndices', $this->parsedFormatsIndices);
$this->cache->set('localizedSymbols', $this->localizedSymbols);
} | [
"public",
"function",
"shutdownObject",
"(",
")",
"{",
"$",
"this",
"->",
"cache",
"->",
"set",
"(",
"'parsedFormats'",
",",
"$",
"this",
"->",
"parsedFormats",
")",
";",
"$",
"this",
"->",
"cache",
"->",
"set",
"(",
"'parsedFormatsIndices'",
",",
"$",
"... | Shutdowns the object, saving parsed format strings to the cache.
@return void | [
"Shutdowns",
"the",
"object",
"saving",
"parsed",
"format",
"strings",
"to",
"the",
"cache",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/I18n/Cldr/Reader/NumbersReader.php#L201-L206 |
neos/flow-development-collection | Neos.Flow/Classes/I18n/Cldr/Reader/NumbersReader.php | NumbersReader.parseFormatFromCldr | public function parseFormatFromCldr(Locale $locale, $formatType, $formatLength = self::FORMAT_LENGTH_DEFAULT)
{
self::validateFormatType($formatType);
self::validateFormatLength($formatLength);
if (isset($this->parsedFormatsIndices[(string)$locale][$formatType][$formatLength])) {
return $this->parsedFormats[$this->parsedFormatsIndices[(string)$locale][$formatType][$formatLength]];
}
if ($formatLength === self::FORMAT_LENGTH_DEFAULT) {
$formatPath = 'numbers/' . $formatType . 'Formats/' . $formatType . 'FormatLength/' . $formatType . 'Format/pattern';
} else {
$formatPath = 'numbers/' . $formatType . 'Formats/' . $formatType . 'FormatLength[@type="' . $formatLength . '"]/' . $formatType . 'Format/pattern';
}
$model = $this->cldrRepository->getModelForLocale($locale);
$format = $model->getElement($formatPath);
if (empty($format)) {
throw new Exception\UnableToFindFormatException('Number format was not found. Please check whether CLDR repository is valid.', 1280218995);
}
$parsedFormat = $this->parseFormat($format);
$this->parsedFormatsIndices[(string)$locale][$formatType][$formatLength] = $format;
return $this->parsedFormats[$format] = $parsedFormat;
} | php | public function parseFormatFromCldr(Locale $locale, $formatType, $formatLength = self::FORMAT_LENGTH_DEFAULT)
{
self::validateFormatType($formatType);
self::validateFormatLength($formatLength);
if (isset($this->parsedFormatsIndices[(string)$locale][$formatType][$formatLength])) {
return $this->parsedFormats[$this->parsedFormatsIndices[(string)$locale][$formatType][$formatLength]];
}
if ($formatLength === self::FORMAT_LENGTH_DEFAULT) {
$formatPath = 'numbers/' . $formatType . 'Formats/' . $formatType . 'FormatLength/' . $formatType . 'Format/pattern';
} else {
$formatPath = 'numbers/' . $formatType . 'Formats/' . $formatType . 'FormatLength[@type="' . $formatLength . '"]/' . $formatType . 'Format/pattern';
}
$model = $this->cldrRepository->getModelForLocale($locale);
$format = $model->getElement($formatPath);
if (empty($format)) {
throw new Exception\UnableToFindFormatException('Number format was not found. Please check whether CLDR repository is valid.', 1280218995);
}
$parsedFormat = $this->parseFormat($format);
$this->parsedFormatsIndices[(string)$locale][$formatType][$formatLength] = $format;
return $this->parsedFormats[$format] = $parsedFormat;
} | [
"public",
"function",
"parseFormatFromCldr",
"(",
"Locale",
"$",
"locale",
",",
"$",
"formatType",
",",
"$",
"formatLength",
"=",
"self",
"::",
"FORMAT_LENGTH_DEFAULT",
")",
"{",
"self",
"::",
"validateFormatType",
"(",
"$",
"formatType",
")",
";",
"self",
"::... | Returns parsed number format basing on locale and desired format length
if provided.
When third parameter ($formatLength) equals 'default', default format for a
locale will be used.
@param Locale $locale
@param string $formatType A type of format (one of constant values)
@param string $formatLength A length of format (one of constant values)
@return array An array representing parsed format
@throws Exception\UnableToFindFormatException When there is no proper format string in CLDR | [
"Returns",
"parsed",
"number",
"format",
"basing",
"on",
"locale",
"and",
"desired",
"format",
"length",
"if",
"provided",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/I18n/Cldr/Reader/NumbersReader.php#L221-L247 |
neos/flow-development-collection | Neos.Flow/Classes/I18n/Cldr/Reader/NumbersReader.php | NumbersReader.parseCustomFormat | public function parseCustomFormat($format)
{
if (isset($this->parsedFormats[$format])) {
return $this->parsedFormats[$format];
}
return $this->parsedFormats[$format] = $this->parseFormat($format);
} | php | public function parseCustomFormat($format)
{
if (isset($this->parsedFormats[$format])) {
return $this->parsedFormats[$format];
}
return $this->parsedFormats[$format] = $this->parseFormat($format);
} | [
"public",
"function",
"parseCustomFormat",
"(",
"$",
"format",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"parsedFormats",
"[",
"$",
"format",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"parsedFormats",
"[",
"$",
"format",
"]",
";",
... | Returns parsed date or time format string provided as parameter.
@param string $format Format string to parse
@return array An array representing parsed format | [
"Returns",
"parsed",
"date",
"or",
"time",
"format",
"string",
"provided",
"as",
"parameter",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/I18n/Cldr/Reader/NumbersReader.php#L255-L262 |
neos/flow-development-collection | Neos.Flow/Classes/I18n/Cldr/Reader/NumbersReader.php | NumbersReader.getLocalizedSymbolsForLocale | public function getLocalizedSymbolsForLocale(Locale $locale)
{
if (isset($this->localizedSymbols[(string)$locale])) {
return $this->localizedSymbols[(string)$locale];
}
$model = $this->cldrRepository->getModelForLocale($locale);
return $this->localizedSymbols[(string)$locale] = $model->getRawArray('numbers/symbols');
} | php | public function getLocalizedSymbolsForLocale(Locale $locale)
{
if (isset($this->localizedSymbols[(string)$locale])) {
return $this->localizedSymbols[(string)$locale];
}
$model = $this->cldrRepository->getModelForLocale($locale);
return $this->localizedSymbols[(string)$locale] = $model->getRawArray('numbers/symbols');
} | [
"public",
"function",
"getLocalizedSymbolsForLocale",
"(",
"Locale",
"$",
"locale",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"localizedSymbols",
"[",
"(",
"string",
")",
"$",
"locale",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"locali... | Returns symbols array for provided locale.
Symbols are elements defined in tag symbols from CLDR. They define
localized versions of various number-related elements, like decimal
separator, group separator or minus sign.
Symbols arrays for every requested locale are cached.
@param Locale $locale
@return array Symbols array | [
"Returns",
"symbols",
"array",
"for",
"provided",
"locale",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/I18n/Cldr/Reader/NumbersReader.php#L276-L284 |
neos/flow-development-collection | Neos.Flow/Classes/I18n/Cldr/Reader/NumbersReader.php | NumbersReader.validateFormatType | public static function validateFormatType($formatType)
{
if (!in_array($formatType, [self::FORMAT_TYPE_DECIMAL, self::FORMAT_TYPE_PERCENT, self::FORMAT_TYPE_CURRENCY])) {
throw new Exception\InvalidFormatTypeException('Provided formatType, "' . $formatType . '", is not one of allowed values.', 1281439179);
}
} | php | public static function validateFormatType($formatType)
{
if (!in_array($formatType, [self::FORMAT_TYPE_DECIMAL, self::FORMAT_TYPE_PERCENT, self::FORMAT_TYPE_CURRENCY])) {
throw new Exception\InvalidFormatTypeException('Provided formatType, "' . $formatType . '", is not one of allowed values.', 1281439179);
}
} | [
"public",
"static",
"function",
"validateFormatType",
"(",
"$",
"formatType",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"formatType",
",",
"[",
"self",
"::",
"FORMAT_TYPE_DECIMAL",
",",
"self",
"::",
"FORMAT_TYPE_PERCENT",
",",
"self",
"::",
"FORMAT_TYPE... | Validates provided format type and throws exception if value is not
allowed.
@param string $formatType
@return void
@throws Exception\InvalidFormatTypeException When value is unallowed | [
"Validates",
"provided",
"format",
"type",
"and",
"throws",
"exception",
"if",
"value",
"is",
"not",
"allowed",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/I18n/Cldr/Reader/NumbersReader.php#L294-L299 |
neos/flow-development-collection | Neos.Flow/Classes/I18n/Cldr/Reader/NumbersReader.php | NumbersReader.parseFormat | protected function parseFormat($format)
{
foreach (['E', '@', '*', '\''] as $unsupportedFeature) {
if (strpos($format, $unsupportedFeature) !== false) {
throw new Exception\UnsupportedNumberFormatException('Encountered unsupported format characters in format string.', 1280219449);
}
}
$parsedFormat = [
'positivePrefix' => '',
'positiveSuffix' => '',
'negativePrefix' => '-',
'negativeSuffix' => '',
'multiplier' => 1,
'minDecimalDigits' => 0,
'maxDecimalDigits' => 0,
'minIntegerDigits' => 1,
'primaryGroupingSize' => 0,
'secondaryGroupingSize' => 0,
'rounding' => 0.0,
];
if (strpos($format, ';') !== false) {
list($positiveFormat, $negativeFormat) = explode(';', $format);
$format = $positiveFormat;
} else {
$positiveFormat = $format;
$negativeFormat = null;
}
if (preg_match(self::PATTERN_MATCH_SUBFORMAT, $positiveFormat, $matches) === 1) {
$parsedFormat['positivePrefix'] = $matches[1];
$parsedFormat['positiveSuffix'] = $matches[2];
}
if ($negativeFormat !== null && preg_match(self::PATTERN_MATCH_SUBFORMAT, $negativeFormat, $matches) === 1) {
$parsedFormat['negativePrefix'] = $matches[1];
$parsedFormat['negativeSuffix'] = $matches[2];
} else {
$parsedFormat['negativePrefix'] = '-' . $parsedFormat['positivePrefix'];
$parsedFormat['negativeSuffix'] = $parsedFormat['positiveSuffix'];
}
if (strpos($format, '%') !== false) {
$parsedFormat['multiplier'] = 100;
} elseif (strpos($format, '‰') !== false) {
$parsedFormat['multiplier'] = 1000;
}
if (preg_match(self::PATTERN_MATCH_ROUNDING, $format, $matches) === 1) {
$parsedFormat['rounding'] = (float)$matches[1];
$format = preg_replace('/[1-9]/', '0', $format);
}
if (($positionOfDecimalSeparator = strpos($format, '.')) !== false) {
if (($positionOfLastZero = strrpos($format, '0')) > $positionOfDecimalSeparator) {
$parsedFormat['minDecimalDigits'] = $positionOfLastZero - $positionOfDecimalSeparator;
}
if (($positionOfLastHash = strrpos($format, '#')) >= $positionOfLastZero) {
$parsedFormat['maxDecimalDigits'] = $positionOfLastHash - $positionOfDecimalSeparator;
} else {
$parsedFormat['maxDecimalDigits'] = $parsedFormat['minDecimalDigits'];
}
$format = substr($format, 0, $positionOfDecimalSeparator);
}
$formatWithoutGroupSeparators = str_replace(',', '', $format);
if (($positionOfFirstZero = strpos($formatWithoutGroupSeparators, '0')) !== false) {
$parsedFormat['minIntegerDigits'] = strrpos($formatWithoutGroupSeparators, '0') - $positionOfFirstZero + 1;
}
$formatWithoutHashes = str_replace('#', '0', $format);
if (($positionOfPrimaryGroupSeparator = strrpos($format, ',')) !== false) {
$parsedFormat['primaryGroupingSize'] = strrpos($formatWithoutHashes, '0') - $positionOfPrimaryGroupSeparator;
if (($positionOfSecondaryGroupSeparator = strrpos(substr($formatWithoutHashes, 0, $positionOfPrimaryGroupSeparator), ',')) !== false) {
$parsedFormat['secondaryGroupingSize'] = $positionOfPrimaryGroupSeparator - $positionOfSecondaryGroupSeparator - 1;
} else {
$parsedFormat['secondaryGroupingSize'] = $parsedFormat['primaryGroupingSize'];
}
}
return $parsedFormat;
} | php | protected function parseFormat($format)
{
foreach (['E', '@', '*', '\''] as $unsupportedFeature) {
if (strpos($format, $unsupportedFeature) !== false) {
throw new Exception\UnsupportedNumberFormatException('Encountered unsupported format characters in format string.', 1280219449);
}
}
$parsedFormat = [
'positivePrefix' => '',
'positiveSuffix' => '',
'negativePrefix' => '-',
'negativeSuffix' => '',
'multiplier' => 1,
'minDecimalDigits' => 0,
'maxDecimalDigits' => 0,
'minIntegerDigits' => 1,
'primaryGroupingSize' => 0,
'secondaryGroupingSize' => 0,
'rounding' => 0.0,
];
if (strpos($format, ';') !== false) {
list($positiveFormat, $negativeFormat) = explode(';', $format);
$format = $positiveFormat;
} else {
$positiveFormat = $format;
$negativeFormat = null;
}
if (preg_match(self::PATTERN_MATCH_SUBFORMAT, $positiveFormat, $matches) === 1) {
$parsedFormat['positivePrefix'] = $matches[1];
$parsedFormat['positiveSuffix'] = $matches[2];
}
if ($negativeFormat !== null && preg_match(self::PATTERN_MATCH_SUBFORMAT, $negativeFormat, $matches) === 1) {
$parsedFormat['negativePrefix'] = $matches[1];
$parsedFormat['negativeSuffix'] = $matches[2];
} else {
$parsedFormat['negativePrefix'] = '-' . $parsedFormat['positivePrefix'];
$parsedFormat['negativeSuffix'] = $parsedFormat['positiveSuffix'];
}
if (strpos($format, '%') !== false) {
$parsedFormat['multiplier'] = 100;
} elseif (strpos($format, '‰') !== false) {
$parsedFormat['multiplier'] = 1000;
}
if (preg_match(self::PATTERN_MATCH_ROUNDING, $format, $matches) === 1) {
$parsedFormat['rounding'] = (float)$matches[1];
$format = preg_replace('/[1-9]/', '0', $format);
}
if (($positionOfDecimalSeparator = strpos($format, '.')) !== false) {
if (($positionOfLastZero = strrpos($format, '0')) > $positionOfDecimalSeparator) {
$parsedFormat['minDecimalDigits'] = $positionOfLastZero - $positionOfDecimalSeparator;
}
if (($positionOfLastHash = strrpos($format, '#')) >= $positionOfLastZero) {
$parsedFormat['maxDecimalDigits'] = $positionOfLastHash - $positionOfDecimalSeparator;
} else {
$parsedFormat['maxDecimalDigits'] = $parsedFormat['minDecimalDigits'];
}
$format = substr($format, 0, $positionOfDecimalSeparator);
}
$formatWithoutGroupSeparators = str_replace(',', '', $format);
if (($positionOfFirstZero = strpos($formatWithoutGroupSeparators, '0')) !== false) {
$parsedFormat['minIntegerDigits'] = strrpos($formatWithoutGroupSeparators, '0') - $positionOfFirstZero + 1;
}
$formatWithoutHashes = str_replace('#', '0', $format);
if (($positionOfPrimaryGroupSeparator = strrpos($format, ',')) !== false) {
$parsedFormat['primaryGroupingSize'] = strrpos($formatWithoutHashes, '0') - $positionOfPrimaryGroupSeparator;
if (($positionOfSecondaryGroupSeparator = strrpos(substr($formatWithoutHashes, 0, $positionOfPrimaryGroupSeparator), ',')) !== false) {
$parsedFormat['secondaryGroupingSize'] = $positionOfPrimaryGroupSeparator - $positionOfSecondaryGroupSeparator - 1;
} else {
$parsedFormat['secondaryGroupingSize'] = $parsedFormat['primaryGroupingSize'];
}
}
return $parsedFormat;
} | [
"protected",
"function",
"parseFormat",
"(",
"$",
"format",
")",
"{",
"foreach",
"(",
"[",
"'E'",
",",
"'@'",
",",
"'*'",
",",
"'\\''",
"]",
"as",
"$",
"unsupportedFeature",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"format",
",",
"$",
"unsupportedFeatu... | Parses a number format (with syntax defined in CLDR).
Not all features from CLDR specification are implemented. Please see the
documentation for this class for details what is missing.
@param string $format
@return array Parsed format
@throws Exception\UnsupportedNumberFormatException When unsupported format characters encountered
@see NumbersReader::$parsedFormats | [
"Parses",
"a",
"number",
"format",
"(",
"with",
"syntax",
"defined",
"in",
"CLDR",
")",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/I18n/Cldr/Reader/NumbersReader.php#L327-L417 |
neos/flow-development-collection | Neos.Flow/Classes/Mvc/Controller/ActionController.php | ActionController.processRequest | public function processRequest(RequestInterface $request, ResponseInterface $response)
{
$this->initializeController($request, $response);
$this->actionMethodName = $this->resolveActionMethodName();
$this->initializeActionMethodArguments();
$this->initializeActionMethodValidators();
$this->initializeAction();
$actionInitializationMethodName = 'initialize' . ucfirst($this->actionMethodName);
if (method_exists($this, $actionInitializationMethodName)) {
call_user_func([$this, $actionInitializationMethodName]);
}
$this->mvcPropertyMappingConfigurationService->initializePropertyMappingConfigurationFromRequest($this->request, $this->arguments);
$this->mapRequestArgumentsToControllerArguments();
if ($this->view === null) {
$this->view = $this->resolveView();
}
if ($this->view !== null) {
$this->view->assign('settings', $this->settings);
$this->view->setControllerContext($this->controllerContext);
$this->initializeView($this->view);
}
$this->callActionMethod();
} | php | public function processRequest(RequestInterface $request, ResponseInterface $response)
{
$this->initializeController($request, $response);
$this->actionMethodName = $this->resolveActionMethodName();
$this->initializeActionMethodArguments();
$this->initializeActionMethodValidators();
$this->initializeAction();
$actionInitializationMethodName = 'initialize' . ucfirst($this->actionMethodName);
if (method_exists($this, $actionInitializationMethodName)) {
call_user_func([$this, $actionInitializationMethodName]);
}
$this->mvcPropertyMappingConfigurationService->initializePropertyMappingConfigurationFromRequest($this->request, $this->arguments);
$this->mapRequestArgumentsToControllerArguments();
if ($this->view === null) {
$this->view = $this->resolveView();
}
if ($this->view !== null) {
$this->view->assign('settings', $this->settings);
$this->view->setControllerContext($this->controllerContext);
$this->initializeView($this->view);
}
$this->callActionMethod();
} | [
"public",
"function",
"processRequest",
"(",
"RequestInterface",
"$",
"request",
",",
"ResponseInterface",
"$",
"response",
")",
"{",
"$",
"this",
"->",
"initializeController",
"(",
"$",
"request",
",",
"$",
"response",
")",
";",
"$",
"this",
"->",
"actionMeth... | Handles a request. The result output is returned by altering the given response.
@param RequestInterface $request The request object
@param ResponseInterface|ActionResponse $response The response, modified by this handler
@return void
@throws UnsupportedRequestTypeException
@api | [
"Handles",
"a",
"request",
".",
"The",
"result",
"output",
"is",
"returned",
"by",
"altering",
"the",
"given",
"response",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Mvc/Controller/ActionController.php#L189-L217 |
neos/flow-development-collection | Neos.Flow/Classes/Mvc/Controller/ActionController.php | ActionController.resolveActionMethodName | protected function resolveActionMethodName()
{
$actionMethodName = $this->request->getControllerActionName() . 'Action';
if (!is_callable([$this, $actionMethodName])) {
throw new NoSuchActionException(sprintf('An action "%s" does not exist in controller "%s".', $actionMethodName, get_class($this)), 1186669086);
}
$publicActionMethods = static::getPublicActionMethods($this->objectManager);
if (!isset($publicActionMethods[$actionMethodName])) {
throw new InvalidActionVisibilityException(sprintf('The action "%s" in controller "%s" is not public!', $actionMethodName, get_class($this)), 1186669086);
}
return $actionMethodName;
} | php | protected function resolveActionMethodName()
{
$actionMethodName = $this->request->getControllerActionName() . 'Action';
if (!is_callable([$this, $actionMethodName])) {
throw new NoSuchActionException(sprintf('An action "%s" does not exist in controller "%s".', $actionMethodName, get_class($this)), 1186669086);
}
$publicActionMethods = static::getPublicActionMethods($this->objectManager);
if (!isset($publicActionMethods[$actionMethodName])) {
throw new InvalidActionVisibilityException(sprintf('The action "%s" in controller "%s" is not public!', $actionMethodName, get_class($this)), 1186669086);
}
return $actionMethodName;
} | [
"protected",
"function",
"resolveActionMethodName",
"(",
")",
"{",
"$",
"actionMethodName",
"=",
"$",
"this",
"->",
"request",
"->",
"getControllerActionName",
"(",
")",
".",
"'Action'",
";",
"if",
"(",
"!",
"is_callable",
"(",
"[",
"$",
"this",
",",
"$",
... | Resolves and checks the current action method name
@return string Method name of the current action
@throws NoSuchActionException
@throws InvalidActionVisibilityException | [
"Resolves",
"and",
"checks",
"the",
"current",
"action",
"method",
"name"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Mvc/Controller/ActionController.php#L226-L237 |
neos/flow-development-collection | Neos.Flow/Classes/Mvc/Controller/ActionController.php | ActionController.initializeActionMethodArguments | protected function initializeActionMethodArguments()
{
$actionMethodParameters = static::getActionMethodParameters($this->objectManager);
if (isset($actionMethodParameters[$this->actionMethodName])) {
$methodParameters = $actionMethodParameters[$this->actionMethodName];
} else {
$methodParameters = [];
}
$this->arguments->removeAll();
foreach ($methodParameters as $parameterName => $parameterInfo) {
$dataType = null;
if (isset($parameterInfo['type'])) {
$dataType = $parameterInfo['type'];
} elseif ($parameterInfo['array']) {
$dataType = 'array';
}
if ($dataType === null) {
throw new InvalidArgumentTypeException('The argument type for parameter $' . $parameterName . ' of method ' . get_class($this) . '->' . $this->actionMethodName . '() could not be detected.', 1253175643);
}
$defaultValue = (isset($parameterInfo['defaultValue']) ? $parameterInfo['defaultValue'] : null);
if ($parameterInfo['optional'] === true && $defaultValue === null) {
$dataType = TypeHandling::stripNullableType($dataType);
}
$this->arguments->addNewArgument($parameterName, $dataType, ($parameterInfo['optional'] === false), $defaultValue);
}
} | php | protected function initializeActionMethodArguments()
{
$actionMethodParameters = static::getActionMethodParameters($this->objectManager);
if (isset($actionMethodParameters[$this->actionMethodName])) {
$methodParameters = $actionMethodParameters[$this->actionMethodName];
} else {
$methodParameters = [];
}
$this->arguments->removeAll();
foreach ($methodParameters as $parameterName => $parameterInfo) {
$dataType = null;
if (isset($parameterInfo['type'])) {
$dataType = $parameterInfo['type'];
} elseif ($parameterInfo['array']) {
$dataType = 'array';
}
if ($dataType === null) {
throw new InvalidArgumentTypeException('The argument type for parameter $' . $parameterName . ' of method ' . get_class($this) . '->' . $this->actionMethodName . '() could not be detected.', 1253175643);
}
$defaultValue = (isset($parameterInfo['defaultValue']) ? $parameterInfo['defaultValue'] : null);
if ($parameterInfo['optional'] === true && $defaultValue === null) {
$dataType = TypeHandling::stripNullableType($dataType);
}
$this->arguments->addNewArgument($parameterName, $dataType, ($parameterInfo['optional'] === false), $defaultValue);
}
} | [
"protected",
"function",
"initializeActionMethodArguments",
"(",
")",
"{",
"$",
"actionMethodParameters",
"=",
"static",
"::",
"getActionMethodParameters",
"(",
"$",
"this",
"->",
"objectManager",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"actionMethodParameters",
"["... | Implementation of the arguments initialization in the action controller:
Automatically registers arguments of the current action
Don't override this method - use initializeAction() instead.
@return void
@throws InvalidArgumentTypeException
@see initializeArguments() | [
"Implementation",
"of",
"the",
"arguments",
"initialization",
"in",
"the",
"action",
"controller",
":",
"Automatically",
"registers",
"arguments",
"of",
"the",
"current",
"action"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Mvc/Controller/ActionController.php#L249-L275 |
neos/flow-development-collection | Neos.Flow/Classes/Mvc/Controller/ActionController.php | ActionController.getActionMethodParameters | public static function getActionMethodParameters($objectManager)
{
$reflectionService = $objectManager->get(ReflectionService::class);
$result = [];
$className = get_called_class();
$methodNames = get_class_methods($className);
foreach ($methodNames as $methodName) {
if (strlen($methodName) > 6 && strpos($methodName, 'Action', strlen($methodName) - 6) !== false) {
$result[$methodName] = $reflectionService->getMethodParameters($className, $methodName);
}
}
return $result;
} | php | public static function getActionMethodParameters($objectManager)
{
$reflectionService = $objectManager->get(ReflectionService::class);
$result = [];
$className = get_called_class();
$methodNames = get_class_methods($className);
foreach ($methodNames as $methodName) {
if (strlen($methodName) > 6 && strpos($methodName, 'Action', strlen($methodName) - 6) !== false) {
$result[$methodName] = $reflectionService->getMethodParameters($className, $methodName);
}
}
return $result;
} | [
"public",
"static",
"function",
"getActionMethodParameters",
"(",
"$",
"objectManager",
")",
"{",
"$",
"reflectionService",
"=",
"$",
"objectManager",
"->",
"get",
"(",
"ReflectionService",
"::",
"class",
")",
";",
"$",
"result",
"=",
"[",
"]",
";",
"$",
"cl... | Returns a map of action method names and their parameters.
@param ObjectManagerInterface $objectManager
@return array Array of method parameters by action name
@Flow\CompileStatic | [
"Returns",
"a",
"map",
"of",
"action",
"method",
"names",
"and",
"their",
"parameters",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Mvc/Controller/ActionController.php#L284-L299 |
neos/flow-development-collection | Neos.Flow/Classes/Mvc/Controller/ActionController.php | ActionController.getInformationNeededForInitializeActionMethodValidators | protected function getInformationNeededForInitializeActionMethodValidators()
{
return [
static::getActionValidationGroups($this->objectManager),
static::getActionMethodParameters($this->objectManager),
static::getActionValidateAnnotationData($this->objectManager),
static::getActionIgnoredValidationArguments($this->objectManager)
];
} | php | protected function getInformationNeededForInitializeActionMethodValidators()
{
return [
static::getActionValidationGroups($this->objectManager),
static::getActionMethodParameters($this->objectManager),
static::getActionValidateAnnotationData($this->objectManager),
static::getActionIgnoredValidationArguments($this->objectManager)
];
} | [
"protected",
"function",
"getInformationNeededForInitializeActionMethodValidators",
"(",
")",
"{",
"return",
"[",
"static",
"::",
"getActionValidationGroups",
"(",
"$",
"this",
"->",
"objectManager",
")",
",",
"static",
"::",
"getActionMethodParameters",
"(",
"$",
"this... | This is a helper method purely used to make initializeActionMethodValidators()
testable without mocking static methods.
@return array | [
"This",
"is",
"a",
"helper",
"method",
"purely",
"used",
"to",
"make",
"initializeActionMethodValidators",
"()",
"testable",
"without",
"mocking",
"static",
"methods",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Mvc/Controller/ActionController.php#L307-L315 |
neos/flow-development-collection | Neos.Flow/Classes/Mvc/Controller/ActionController.php | ActionController.initializeActionMethodValidators | protected function initializeActionMethodValidators()
{
list($validateGroupAnnotations, $actionMethodParameters, $actionValidateAnnotations, $actionIgnoredArguments) = $this->getInformationNeededForInitializeActionMethodValidators();
if (isset($validateGroupAnnotations[$this->actionMethodName])) {
$validationGroups = $validateGroupAnnotations[$this->actionMethodName];
} else {
$validationGroups = ['Default', 'Controller'];
}
if (isset($actionMethodParameters[$this->actionMethodName])) {
$methodParameters = $actionMethodParameters[$this->actionMethodName];
} else {
$methodParameters = [];
}
if (isset($actionValidateAnnotations[$this->actionMethodName])) {
$validateAnnotations = $actionValidateAnnotations[$this->actionMethodName];
} else {
$validateAnnotations = [];
}
$parameterValidators = $this->validatorResolver->buildMethodArgumentsValidatorConjunctions(get_class($this), $this->actionMethodName, $methodParameters, $validateAnnotations);
if (isset($actionIgnoredArguments[$this->actionMethodName])) {
$ignoredArguments = $actionIgnoredArguments[$this->actionMethodName];
} else {
$ignoredArguments = [];
}
foreach ($this->arguments as $argument) {
$argumentName = $argument->getName();
if (isset($ignoredArguments[$argumentName]) && !$ignoredArguments[$argumentName]['evaluate']) {
continue;
}
$validator = $parameterValidators[$argumentName];
$baseValidatorConjunction = $this->validatorResolver->getBaseValidatorConjunction($argument->getDataType(), $validationGroups);
if (count($baseValidatorConjunction) > 0) {
$validator->addValidator($baseValidatorConjunction);
}
$argument->setValidator($validator);
}
} | php | protected function initializeActionMethodValidators()
{
list($validateGroupAnnotations, $actionMethodParameters, $actionValidateAnnotations, $actionIgnoredArguments) = $this->getInformationNeededForInitializeActionMethodValidators();
if (isset($validateGroupAnnotations[$this->actionMethodName])) {
$validationGroups = $validateGroupAnnotations[$this->actionMethodName];
} else {
$validationGroups = ['Default', 'Controller'];
}
if (isset($actionMethodParameters[$this->actionMethodName])) {
$methodParameters = $actionMethodParameters[$this->actionMethodName];
} else {
$methodParameters = [];
}
if (isset($actionValidateAnnotations[$this->actionMethodName])) {
$validateAnnotations = $actionValidateAnnotations[$this->actionMethodName];
} else {
$validateAnnotations = [];
}
$parameterValidators = $this->validatorResolver->buildMethodArgumentsValidatorConjunctions(get_class($this), $this->actionMethodName, $methodParameters, $validateAnnotations);
if (isset($actionIgnoredArguments[$this->actionMethodName])) {
$ignoredArguments = $actionIgnoredArguments[$this->actionMethodName];
} else {
$ignoredArguments = [];
}
foreach ($this->arguments as $argument) {
$argumentName = $argument->getName();
if (isset($ignoredArguments[$argumentName]) && !$ignoredArguments[$argumentName]['evaluate']) {
continue;
}
$validator = $parameterValidators[$argumentName];
$baseValidatorConjunction = $this->validatorResolver->getBaseValidatorConjunction($argument->getDataType(), $validationGroups);
if (count($baseValidatorConjunction) > 0) {
$validator->addValidator($baseValidatorConjunction);
}
$argument->setValidator($validator);
}
} | [
"protected",
"function",
"initializeActionMethodValidators",
"(",
")",
"{",
"list",
"(",
"$",
"validateGroupAnnotations",
",",
"$",
"actionMethodParameters",
",",
"$",
"actionValidateAnnotations",
",",
"$",
"actionIgnoredArguments",
")",
"=",
"$",
"this",
"->",
"getIn... | Adds the needed validators to the Arguments:
- Validators checking the data type from the @param annotation
- Custom validators specified with validate annotations.
- Model-based validators (validate annotations in the model)
- Custom model validator classes
@return void | [
"Adds",
"the",
"needed",
"validators",
"to",
"the",
"Arguments",
":"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Mvc/Controller/ActionController.php#L327-L370 |
neos/flow-development-collection | Neos.Flow/Classes/Mvc/Controller/ActionController.php | ActionController.getActionValidationGroups | public static function getActionValidationGroups($objectManager)
{
$reflectionService = $objectManager->get(ReflectionService::class);
$result = [];
$className = get_called_class();
$methodNames = get_class_methods($className);
foreach ($methodNames as $methodName) {
if (strlen($methodName) > 6 && strpos($methodName, 'Action', strlen($methodName) - 6) !== false) {
$validationGroupsAnnotation = $reflectionService->getMethodAnnotation($className, $methodName, Flow\ValidationGroups::class);
if ($validationGroupsAnnotation !== null) {
$result[$methodName] = $validationGroupsAnnotation->validationGroups;
}
}
}
return $result;
} | php | public static function getActionValidationGroups($objectManager)
{
$reflectionService = $objectManager->get(ReflectionService::class);
$result = [];
$className = get_called_class();
$methodNames = get_class_methods($className);
foreach ($methodNames as $methodName) {
if (strlen($methodName) > 6 && strpos($methodName, 'Action', strlen($methodName) - 6) !== false) {
$validationGroupsAnnotation = $reflectionService->getMethodAnnotation($className, $methodName, Flow\ValidationGroups::class);
if ($validationGroupsAnnotation !== null) {
$result[$methodName] = $validationGroupsAnnotation->validationGroups;
}
}
}
return $result;
} | [
"public",
"static",
"function",
"getActionValidationGroups",
"(",
"$",
"objectManager",
")",
"{",
"$",
"reflectionService",
"=",
"$",
"objectManager",
"->",
"get",
"(",
"ReflectionService",
"::",
"class",
")",
";",
"$",
"result",
"=",
"[",
"]",
";",
"$",
"cl... | Returns a map of action method names and their validation groups.
@param ObjectManagerInterface $objectManager
@return array Array of validation groups by action method name
@Flow\CompileStatic | [
"Returns",
"a",
"map",
"of",
"action",
"method",
"names",
"and",
"their",
"validation",
"groups",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Mvc/Controller/ActionController.php#L379-L397 |
neos/flow-development-collection | Neos.Flow/Classes/Mvc/Controller/ActionController.php | ActionController.getActionValidateAnnotationData | public static function getActionValidateAnnotationData($objectManager)
{
$reflectionService = $objectManager->get(ReflectionService::class);
$result = [];
$className = get_called_class();
$methodNames = get_class_methods($className);
foreach ($methodNames as $methodName) {
if (strlen($methodName) > 6 && strpos($methodName, 'Action', strlen($methodName) - 6) !== false) {
$validateAnnotations = $reflectionService->getMethodAnnotations($className, $methodName, Flow\Validate::class);
$result[$methodName] = array_map(function ($validateAnnotation) {
return [
'type' => $validateAnnotation->type,
'options' => $validateAnnotation->options,
'argumentName' => $validateAnnotation->argumentName,
];
}, $validateAnnotations);
}
}
return $result;
} | php | public static function getActionValidateAnnotationData($objectManager)
{
$reflectionService = $objectManager->get(ReflectionService::class);
$result = [];
$className = get_called_class();
$methodNames = get_class_methods($className);
foreach ($methodNames as $methodName) {
if (strlen($methodName) > 6 && strpos($methodName, 'Action', strlen($methodName) - 6) !== false) {
$validateAnnotations = $reflectionService->getMethodAnnotations($className, $methodName, Flow\Validate::class);
$result[$methodName] = array_map(function ($validateAnnotation) {
return [
'type' => $validateAnnotation->type,
'options' => $validateAnnotation->options,
'argumentName' => $validateAnnotation->argumentName,
];
}, $validateAnnotations);
}
}
return $result;
} | [
"public",
"static",
"function",
"getActionValidateAnnotationData",
"(",
"$",
"objectManager",
")",
"{",
"$",
"reflectionService",
"=",
"$",
"objectManager",
"->",
"get",
"(",
"ReflectionService",
"::",
"class",
")",
";",
"$",
"result",
"=",
"[",
"]",
";",
"$",... | Returns a map of action method names and their validation parameters.
@param ObjectManagerInterface $objectManager
@return array Array of validate annotation parameters by action method name
@Flow\CompileStatic | [
"Returns",
"a",
"map",
"of",
"action",
"method",
"names",
"and",
"their",
"validation",
"parameters",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Mvc/Controller/ActionController.php#L406-L428 |
neos/flow-development-collection | Neos.Flow/Classes/Mvc/Controller/ActionController.php | ActionController.callActionMethod | protected function callActionMethod()
{
$preparedArguments = [];
foreach ($this->arguments as $argument) {
$preparedArguments[] = $argument->getValue();
}
$validationResult = $this->arguments->getValidationResults();
if (!$validationResult->hasErrors()) {
$actionResult = call_user_func_array([$this, $this->actionMethodName], $preparedArguments);
} else {
$actionIgnoredArguments = static::getActionIgnoredValidationArguments($this->objectManager);
if (isset($actionIgnoredArguments[$this->actionMethodName])) {
$ignoredArguments = $actionIgnoredArguments[$this->actionMethodName];
} else {
$ignoredArguments = [];
}
// if there exists more errors than in ignoreValidationAnnotations => call error method
// else => call action method
$shouldCallActionMethod = true;
/** @var Result $subValidationResult */
foreach ($validationResult->getSubResults() as $argumentName => $subValidationResult) {
if (!$subValidationResult->hasErrors()) {
continue;
}
if (isset($ignoredArguments[$argumentName]) && $subValidationResult->getErrors(TargetNotFoundError::class) === []) {
continue;
}
$shouldCallActionMethod = false;
break;
}
if ($shouldCallActionMethod) {
$actionResult = call_user_func_array([$this, $this->actionMethodName], $preparedArguments);
} else {
$actionResult = call_user_func([$this, $this->errorMethodName]);
}
}
if ($actionResult === null && $this->view instanceof ViewInterface) {
$this->response->appendContent($this->view->render());
} elseif (is_string($actionResult) && strlen($actionResult) > 0) {
$this->response->appendContent($actionResult);
} elseif (is_object($actionResult) && method_exists($actionResult, '__toString')) {
$this->response->appendContent((string)$actionResult);
}
} | php | protected function callActionMethod()
{
$preparedArguments = [];
foreach ($this->arguments as $argument) {
$preparedArguments[] = $argument->getValue();
}
$validationResult = $this->arguments->getValidationResults();
if (!$validationResult->hasErrors()) {
$actionResult = call_user_func_array([$this, $this->actionMethodName], $preparedArguments);
} else {
$actionIgnoredArguments = static::getActionIgnoredValidationArguments($this->objectManager);
if (isset($actionIgnoredArguments[$this->actionMethodName])) {
$ignoredArguments = $actionIgnoredArguments[$this->actionMethodName];
} else {
$ignoredArguments = [];
}
// if there exists more errors than in ignoreValidationAnnotations => call error method
// else => call action method
$shouldCallActionMethod = true;
/** @var Result $subValidationResult */
foreach ($validationResult->getSubResults() as $argumentName => $subValidationResult) {
if (!$subValidationResult->hasErrors()) {
continue;
}
if (isset($ignoredArguments[$argumentName]) && $subValidationResult->getErrors(TargetNotFoundError::class) === []) {
continue;
}
$shouldCallActionMethod = false;
break;
}
if ($shouldCallActionMethod) {
$actionResult = call_user_func_array([$this, $this->actionMethodName], $preparedArguments);
} else {
$actionResult = call_user_func([$this, $this->errorMethodName]);
}
}
if ($actionResult === null && $this->view instanceof ViewInterface) {
$this->response->appendContent($this->view->render());
} elseif (is_string($actionResult) && strlen($actionResult) > 0) {
$this->response->appendContent($actionResult);
} elseif (is_object($actionResult) && method_exists($actionResult, '__toString')) {
$this->response->appendContent((string)$actionResult);
}
} | [
"protected",
"function",
"callActionMethod",
"(",
")",
"{",
"$",
"preparedArguments",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"arguments",
"as",
"$",
"argument",
")",
"{",
"$",
"preparedArguments",
"[",
"]",
"=",
"$",
"argument",
"->",
"ge... | Calls the specified action method and passes the arguments.
If the action returns a string, it is appended to the content in the
response object. If the action doesn't return anything and a valid
view exists, the view is rendered automatically.
TODO: In next major this will no longer append content and the response will probably be unique per call.
@return void | [
"Calls",
"the",
"specified",
"action",
"method",
"and",
"passes",
"the",
"arguments",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Mvc/Controller/ActionController.php#L455-L503 |
neos/flow-development-collection | Neos.Flow/Classes/Mvc/Controller/ActionController.php | ActionController.resolveView | protected function resolveView()
{
$viewsConfiguration = $this->viewConfigurationManager->getViewConfiguration($this->request);
$viewObjectName = $this->defaultViewImplementation;
if (!empty($this->defaultViewObjectName)) {
$viewObjectName = $this->defaultViewObjectName;
}
$viewObjectName = $this->resolveViewObjectName() ?: $viewObjectName;
if (isset($viewsConfiguration['viewObjectName'])) {
$viewObjectName = $viewsConfiguration['viewObjectName'];
}
if (!is_a($viewObjectName, ViewInterface::class, true)) {
throw new ViewNotFoundException(sprintf('View class has to implement ViewInterface but "%s" in action "%s" of controller "%s" does not.',
$viewObjectName, $this->request->getControllerActionName(), get_class($this)), 1355153188);
}
$viewOptions = isset($viewsConfiguration['options']) ? $viewsConfiguration['options'] : [];
$view = $viewObjectName::createWithOptions($viewOptions);
return $view;
} | php | protected function resolveView()
{
$viewsConfiguration = $this->viewConfigurationManager->getViewConfiguration($this->request);
$viewObjectName = $this->defaultViewImplementation;
if (!empty($this->defaultViewObjectName)) {
$viewObjectName = $this->defaultViewObjectName;
}
$viewObjectName = $this->resolveViewObjectName() ?: $viewObjectName;
if (isset($viewsConfiguration['viewObjectName'])) {
$viewObjectName = $viewsConfiguration['viewObjectName'];
}
if (!is_a($viewObjectName, ViewInterface::class, true)) {
throw new ViewNotFoundException(sprintf('View class has to implement ViewInterface but "%s" in action "%s" of controller "%s" does not.',
$viewObjectName, $this->request->getControllerActionName(), get_class($this)), 1355153188);
}
$viewOptions = isset($viewsConfiguration['options']) ? $viewsConfiguration['options'] : [];
$view = $viewObjectName::createWithOptions($viewOptions);
return $view;
} | [
"protected",
"function",
"resolveView",
"(",
")",
"{",
"$",
"viewsConfiguration",
"=",
"$",
"this",
"->",
"viewConfigurationManager",
"->",
"getViewConfiguration",
"(",
"$",
"this",
"->",
"request",
")",
";",
"$",
"viewObjectName",
"=",
"$",
"this",
"->",
"def... | Prepares a view for the current action and stores it in $this->view.
By default, this method tries to locate a view with a name matching
the current action.
@return ViewInterface the resolved view
@throws ViewNotFoundException if no view can be resolved | [
"Prepares",
"a",
"view",
"for",
"the",
"current",
"action",
"and",
"stores",
"it",
"in",
"$this",
"-",
">",
"view",
".",
"By",
"default",
"this",
"method",
"tries",
"to",
"locate",
"a",
"view",
"with",
"a",
"name",
"matching",
"the",
"current",
"action",... | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Mvc/Controller/ActionController.php#L569-L590 |
neos/flow-development-collection | Neos.Flow/Classes/Mvc/Controller/ActionController.php | ActionController.resolveViewObjectName | protected function resolveViewObjectName()
{
$possibleViewObjectName = $this->viewObjectNamePattern;
$packageKey = $this->request->getControllerPackageKey();
$subpackageKey = $this->request->getControllerSubpackageKey();
$format = $this->request->getFormat();
if ($subpackageKey !== null && $subpackageKey !== '') {
$packageKey .= '\\' . $subpackageKey;
}
$possibleViewObjectName = str_replace('@package', str_replace('.', '\\', $packageKey), $possibleViewObjectName);
$possibleViewObjectName = str_replace('@controller', $this->request->getControllerName(), $possibleViewObjectName);
$possibleViewObjectName = str_replace('@action', $this->request->getControllerActionName(), $possibleViewObjectName);
$viewObjectName = $this->objectManager->getCaseSensitiveObjectName(strtolower(str_replace('@format', $format, $possibleViewObjectName)));
if ($viewObjectName === false) {
$viewObjectName = $this->objectManager->getCaseSensitiveObjectName(strtolower(str_replace('@format', '', $possibleViewObjectName)));
}
if ($viewObjectName === false && isset($this->viewFormatToObjectNameMap[$format])) {
$viewObjectName = $this->viewFormatToObjectNameMap[$format];
}
return $viewObjectName;
} | php | protected function resolveViewObjectName()
{
$possibleViewObjectName = $this->viewObjectNamePattern;
$packageKey = $this->request->getControllerPackageKey();
$subpackageKey = $this->request->getControllerSubpackageKey();
$format = $this->request->getFormat();
if ($subpackageKey !== null && $subpackageKey !== '') {
$packageKey .= '\\' . $subpackageKey;
}
$possibleViewObjectName = str_replace('@package', str_replace('.', '\\', $packageKey), $possibleViewObjectName);
$possibleViewObjectName = str_replace('@controller', $this->request->getControllerName(), $possibleViewObjectName);
$possibleViewObjectName = str_replace('@action', $this->request->getControllerActionName(), $possibleViewObjectName);
$viewObjectName = $this->objectManager->getCaseSensitiveObjectName(strtolower(str_replace('@format', $format, $possibleViewObjectName)));
if ($viewObjectName === false) {
$viewObjectName = $this->objectManager->getCaseSensitiveObjectName(strtolower(str_replace('@format', '', $possibleViewObjectName)));
}
if ($viewObjectName === false && isset($this->viewFormatToObjectNameMap[$format])) {
$viewObjectName = $this->viewFormatToObjectNameMap[$format];
}
return $viewObjectName;
} | [
"protected",
"function",
"resolveViewObjectName",
"(",
")",
"{",
"$",
"possibleViewObjectName",
"=",
"$",
"this",
"->",
"viewObjectNamePattern",
";",
"$",
"packageKey",
"=",
"$",
"this",
"->",
"request",
"->",
"getControllerPackageKey",
"(",
")",
";",
"$",
"subp... | Determines the fully qualified view object name.
@return mixed The fully qualified view object name or false if no matching view could be found.
@api | [
"Determines",
"the",
"fully",
"qualified",
"view",
"object",
"name",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Mvc/Controller/ActionController.php#L598-L620 |
neos/flow-development-collection | Neos.Flow/Classes/Mvc/Controller/ActionController.php | ActionController.handleTargetNotFoundError | protected function handleTargetNotFoundError()
{
foreach (array_keys($this->request->getArguments()) as $argumentName) {
/** @var TargetNotFoundError $targetNotFoundError */
$targetNotFoundError = $this->arguments->getValidationResults()->forProperty($argumentName)->getFirstError(TargetNotFoundError::class);
if ($targetNotFoundError !== false) {
throw new TargetNotFoundException($targetNotFoundError->getMessage(), $targetNotFoundError->getCode());
}
}
} | php | protected function handleTargetNotFoundError()
{
foreach (array_keys($this->request->getArguments()) as $argumentName) {
/** @var TargetNotFoundError $targetNotFoundError */
$targetNotFoundError = $this->arguments->getValidationResults()->forProperty($argumentName)->getFirstError(TargetNotFoundError::class);
if ($targetNotFoundError !== false) {
throw new TargetNotFoundException($targetNotFoundError->getMessage(), $targetNotFoundError->getCode());
}
}
} | [
"protected",
"function",
"handleTargetNotFoundError",
"(",
")",
"{",
"foreach",
"(",
"array_keys",
"(",
"$",
"this",
"->",
"request",
"->",
"getArguments",
"(",
")",
")",
"as",
"$",
"argumentName",
")",
"{",
"/** @var TargetNotFoundError $targetNotFoundError */",
"$... | Checks if the arguments validation result contain errors of type TargetNotFoundError and throws a TargetNotFoundException if that's the case for a top-level object.
You can override this method (or the errorAction()) if you need a different behavior
@return void
@throws TargetNotFoundException
@api | [
"Checks",
"if",
"the",
"arguments",
"validation",
"result",
"contain",
"errors",
"of",
"type",
"TargetNotFoundError",
"and",
"throws",
"a",
"TargetNotFoundException",
"if",
"that",
"s",
"the",
"case",
"for",
"a",
"top",
"-",
"level",
"object",
".",
"You",
"can... | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Mvc/Controller/ActionController.php#L663-L672 |
neos/flow-development-collection | Neos.Flow/Classes/Mvc/Controller/ActionController.php | ActionController.addErrorFlashMessage | protected function addErrorFlashMessage()
{
$errorFlashMessage = $this->getErrorFlashMessage();
if ($errorFlashMessage !== false) {
$this->flashMessageContainer->addMessage($errorFlashMessage);
}
} | php | protected function addErrorFlashMessage()
{
$errorFlashMessage = $this->getErrorFlashMessage();
if ($errorFlashMessage !== false) {
$this->flashMessageContainer->addMessage($errorFlashMessage);
}
} | [
"protected",
"function",
"addErrorFlashMessage",
"(",
")",
"{",
"$",
"errorFlashMessage",
"=",
"$",
"this",
"->",
"getErrorFlashMessage",
"(",
")",
";",
"if",
"(",
"$",
"errorFlashMessage",
"!==",
"false",
")",
"{",
"$",
"this",
"->",
"flashMessageContainer",
... | If an error occurred during this request, this adds a flash message describing the error to the flash
message container.
@return void | [
"If",
"an",
"error",
"occurred",
"during",
"this",
"request",
"this",
"adds",
"a",
"flash",
"message",
"describing",
"the",
"error",
"to",
"the",
"flash",
"message",
"container",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Mvc/Controller/ActionController.php#L680-L686 |
neos/flow-development-collection | Neos.Flow/Classes/Mvc/Controller/ActionController.php | ActionController.forwardToReferringRequest | protected function forwardToReferringRequest()
{
$referringRequest = $this->request->getReferringRequest();
if ($referringRequest === null) {
return;
}
$packageKey = $referringRequest->getControllerPackageKey();
$subpackageKey = $referringRequest->getControllerSubpackageKey();
if ($subpackageKey !== null) {
$packageKey .= '\\' . $subpackageKey;
}
$argumentsForNextController = $referringRequest->getArguments();
$argumentsForNextController['__submittedArguments'] = $this->request->getArguments();
$argumentsForNextController['__submittedArgumentValidationResults'] = $this->arguments->getValidationResults();
$this->forward($referringRequest->getControllerActionName(), $referringRequest->getControllerName(), $packageKey, $argumentsForNextController);
} | php | protected function forwardToReferringRequest()
{
$referringRequest = $this->request->getReferringRequest();
if ($referringRequest === null) {
return;
}
$packageKey = $referringRequest->getControllerPackageKey();
$subpackageKey = $referringRequest->getControllerSubpackageKey();
if ($subpackageKey !== null) {
$packageKey .= '\\' . $subpackageKey;
}
$argumentsForNextController = $referringRequest->getArguments();
$argumentsForNextController['__submittedArguments'] = $this->request->getArguments();
$argumentsForNextController['__submittedArgumentValidationResults'] = $this->arguments->getValidationResults();
$this->forward($referringRequest->getControllerActionName(), $referringRequest->getControllerName(), $packageKey, $argumentsForNextController);
} | [
"protected",
"function",
"forwardToReferringRequest",
"(",
")",
"{",
"$",
"referringRequest",
"=",
"$",
"this",
"->",
"request",
"->",
"getReferringRequest",
"(",
")",
";",
"if",
"(",
"$",
"referringRequest",
"===",
"null",
")",
"{",
"return",
";",
"}",
"$",... | If information on the request before the current request was sent, this method forwards back
to the originating request. This effectively ends processing of the current request, so do not
call this method before you have finished the necessary business logic!
@return void
@throws ForwardException | [
"If",
"information",
"on",
"the",
"request",
"before",
"the",
"current",
"request",
"was",
"sent",
"this",
"method",
"forwards",
"back",
"to",
"the",
"originating",
"request",
".",
"This",
"effectively",
"ends",
"processing",
"of",
"the",
"current",
"request",
... | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Mvc/Controller/ActionController.php#L696-L712 |
neos/flow-development-collection | Neos.Flow/Classes/Mvc/Controller/ActionController.php | ActionController.getFlattenedValidationErrorMessage | protected function getFlattenedValidationErrorMessage()
{
$outputMessage = 'Validation failed while trying to call ' . get_class($this) . '->' . $this->actionMethodName . '().' . PHP_EOL;
$logMessage = $outputMessage;
foreach ($this->arguments->getValidationResults()->getFlattenedErrors() as $propertyPath => $errors) {
foreach ($errors as $error) {
$logMessage .= 'Error for ' . $propertyPath . ': ' . $error->render() . PHP_EOL;
}
}
$this->logger->error($logMessage, LogEnvironment::fromMethodName(__METHOD__));
return $outputMessage;
} | php | protected function getFlattenedValidationErrorMessage()
{
$outputMessage = 'Validation failed while trying to call ' . get_class($this) . '->' . $this->actionMethodName . '().' . PHP_EOL;
$logMessage = $outputMessage;
foreach ($this->arguments->getValidationResults()->getFlattenedErrors() as $propertyPath => $errors) {
foreach ($errors as $error) {
$logMessage .= 'Error for ' . $propertyPath . ': ' . $error->render() . PHP_EOL;
}
}
$this->logger->error($logMessage, LogEnvironment::fromMethodName(__METHOD__));
return $outputMessage;
} | [
"protected",
"function",
"getFlattenedValidationErrorMessage",
"(",
")",
"{",
"$",
"outputMessage",
"=",
"'Validation failed while trying to call '",
".",
"get_class",
"(",
"$",
"this",
")",
".",
"'->'",
".",
"$",
"this",
"->",
"actionMethodName",
".",
"'().'",
".",... | Returns a string containing all validation errors separated by PHP_EOL.
@return string | [
"Returns",
"a",
"string",
"containing",
"all",
"validation",
"errors",
"separated",
"by",
"PHP_EOL",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Mvc/Controller/ActionController.php#L719-L732 |
neos/flow-development-collection | Neos.Flow/Classes/Security/RequestPattern/Host.php | Host.matchRequest | public function matchRequest(RequestInterface $request)
{
if (!isset($this->options['hostPattern'])) {
throw new InvalidRequestPatternException('Missing option "hostPattern" in the Host request pattern configuration', 1446224510);
}
if (!$request instanceof ActionRequest) {
return false;
}
$hostPattern = str_replace('\\*', '.*', preg_quote($this->options['hostPattern'], '/'));
return preg_match('/^' . $hostPattern . '$/', $request->getHttpRequest()->getUri()->getHost()) === 1;
} | php | public function matchRequest(RequestInterface $request)
{
if (!isset($this->options['hostPattern'])) {
throw new InvalidRequestPatternException('Missing option "hostPattern" in the Host request pattern configuration', 1446224510);
}
if (!$request instanceof ActionRequest) {
return false;
}
$hostPattern = str_replace('\\*', '.*', preg_quote($this->options['hostPattern'], '/'));
return preg_match('/^' . $hostPattern . '$/', $request->getHttpRequest()->getUri()->getHost()) === 1;
} | [
"public",
"function",
"matchRequest",
"(",
"RequestInterface",
"$",
"request",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"options",
"[",
"'hostPattern'",
"]",
")",
")",
"{",
"throw",
"new",
"InvalidRequestPatternException",
"(",
"'Missing opti... | Matches a \Neos\Flow\Mvc\RequestInterface against its set host pattern rules
@param RequestInterface $request The request that should be matched
@return boolean true if the pattern matched, false otherwise
@throws InvalidRequestPatternException | [
"Matches",
"a",
"\\",
"Neos",
"\\",
"Flow",
"\\",
"Mvc",
"\\",
"RequestInterface",
"against",
"its",
"set",
"host",
"pattern",
"rules"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/RequestPattern/Host.php#L50-L60 |
neos/flow-development-collection | Neos.FluidAdaptor/Classes/ViewHelpers/Format/NumberViewHelper.php | NumberViewHelper.initializeArguments | public function initializeArguments()
{
$this->registerArgument('decimals', 'integer', 'The number of digits after the decimal point', false, 2);
$this->registerArgument('decimalSeparator', 'string', 'The decimal point character', false, '.');
$this->registerArgument('thousandsSeparator', 'string', 'The character for grouping the thousand digits', false, ',');
$this->registerArgument('localeFormatLength', 'string', 'Format length if locale set in $forceLocale. Must be one of Neos\Flow\I18n\Cldr\Reader\NumbersReader::FORMAT_LENGTH_*\'s constants.', false, NumbersReader::FORMAT_LENGTH_DEFAULT);
} | php | public function initializeArguments()
{
$this->registerArgument('decimals', 'integer', 'The number of digits after the decimal point', false, 2);
$this->registerArgument('decimalSeparator', 'string', 'The decimal point character', false, '.');
$this->registerArgument('thousandsSeparator', 'string', 'The character for grouping the thousand digits', false, ',');
$this->registerArgument('localeFormatLength', 'string', 'Format length if locale set in $forceLocale. Must be one of Neos\Flow\I18n\Cldr\Reader\NumbersReader::FORMAT_LENGTH_*\'s constants.', false, NumbersReader::FORMAT_LENGTH_DEFAULT);
} | [
"public",
"function",
"initializeArguments",
"(",
")",
"{",
"$",
"this",
"->",
"registerArgument",
"(",
"'decimals'",
",",
"'integer'",
",",
"'The number of digits after the decimal point'",
",",
"false",
",",
"2",
")",
";",
"$",
"this",
"->",
"registerArgument",
... | Initialize the arguments.
@return void
@api | [
"Initialize",
"the",
"arguments",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.FluidAdaptor/Classes/ViewHelpers/Format/NumberViewHelper.php#L73-L79 |
neos/flow-development-collection | Neos.FluidAdaptor/Classes/ViewHelpers/Format/NumberViewHelper.php | NumberViewHelper.render | public function render()
{
$stringToFormat = $this->renderChildren();
$useLocale = $this->getLocale();
if ($useLocale !== null) {
try {
$output = $this->numberFormatter->formatDecimalNumber($stringToFormat, $useLocale, $this->arguments['localeFormatLength']);
} catch (I18nException $exception) {
throw new ViewHelperException($exception->getMessage(), 1382351148, $exception);
}
} else {
$output = number_format((float)$stringToFormat, $this->arguments['decimals'], $this->arguments['decimalSeparator'], $this->arguments['thousandsSeparator']);
}
return $output;
} | php | public function render()
{
$stringToFormat = $this->renderChildren();
$useLocale = $this->getLocale();
if ($useLocale !== null) {
try {
$output = $this->numberFormatter->formatDecimalNumber($stringToFormat, $useLocale, $this->arguments['localeFormatLength']);
} catch (I18nException $exception) {
throw new ViewHelperException($exception->getMessage(), 1382351148, $exception);
}
} else {
$output = number_format((float)$stringToFormat, $this->arguments['decimals'], $this->arguments['decimalSeparator'], $this->arguments['thousandsSeparator']);
}
return $output;
} | [
"public",
"function",
"render",
"(",
")",
"{",
"$",
"stringToFormat",
"=",
"$",
"this",
"->",
"renderChildren",
"(",
")",
";",
"$",
"useLocale",
"=",
"$",
"this",
"->",
"getLocale",
"(",
")",
";",
"if",
"(",
"$",
"useLocale",
"!==",
"null",
")",
"{",... | Format the numeric value as a number with grouped thousands, decimal point and
precision.
@return string The formatted number
@api
@throws ViewHelperException | [
"Format",
"the",
"numeric",
"value",
"as",
"a",
"number",
"with",
"grouped",
"thousands",
"decimal",
"point",
"and",
"precision",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.FluidAdaptor/Classes/ViewHelpers/Format/NumberViewHelper.php#L89-L104 |
neos/flow-development-collection | Neos.Flow.Log/Classes/DefaultLogger.php | DefaultLogger.setBackend | public function setBackend(Backend\BackendInterface $backend)
{
if ($this->psrCompatibleLoggerWasInjected) {
throw new Exception('A PSR-3 logger was injected so setting backends is not possible. Create a new instance.', 1515342951935);
}
foreach ($this->backends as $backend) {
$backend->close();
}
$this->backends = new \SplObjectStorage();
$this->backends->attach($backend);
} | php | public function setBackend(Backend\BackendInterface $backend)
{
if ($this->psrCompatibleLoggerWasInjected) {
throw new Exception('A PSR-3 logger was injected so setting backends is not possible. Create a new instance.', 1515342951935);
}
foreach ($this->backends as $backend) {
$backend->close();
}
$this->backends = new \SplObjectStorage();
$this->backends->attach($backend);
} | [
"public",
"function",
"setBackend",
"(",
"Backend",
"\\",
"BackendInterface",
"$",
"backend",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"psrCompatibleLoggerWasInjected",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'A PSR-3 logger was injected so setting backends is not p... | Sets the given backend as the only backend for this Logger.
This method allows for conveniently injecting a backend through some Objects.yaml configuration.
@param Backend\BackendInterface $backend A backend implementation
@return void
@api
@throws Exception | [
"Sets",
"the",
"given",
"backend",
"as",
"the",
"only",
"backend",
"for",
"this",
"Logger",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow.Log/Classes/DefaultLogger.php#L102-L113 |
neos/flow-development-collection | Neos.Flow.Log/Classes/DefaultLogger.php | DefaultLogger.addBackend | public function addBackend(Backend\BackendInterface $backend)
{
if ($this->psrCompatibleLoggerWasInjected) {
throw new Exception('A PSR-3 logger was injected so adding backends is not possible. Create a new instance.', 1515343013004);
}
$this->backends->attach($backend);
} | php | public function addBackend(Backend\BackendInterface $backend)
{
if ($this->psrCompatibleLoggerWasInjected) {
throw new Exception('A PSR-3 logger was injected so adding backends is not possible. Create a new instance.', 1515343013004);
}
$this->backends->attach($backend);
} | [
"public",
"function",
"addBackend",
"(",
"Backend",
"\\",
"BackendInterface",
"$",
"backend",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"psrCompatibleLoggerWasInjected",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'A PSR-3 logger was injected so adding backends is not po... | Adds the backend to which the logger sends the logging data
@param Backend\BackendInterface $backend A backend implementation
@return void
@api
@throws Exception | [
"Adds",
"the",
"backend",
"to",
"which",
"the",
"logger",
"sends",
"the",
"logging",
"data"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow.Log/Classes/DefaultLogger.php#L123-L130 |
neos/flow-development-collection | Neos.Flow.Log/Classes/DefaultLogger.php | DefaultLogger.removeBackend | public function removeBackend(Backend\BackendInterface $backend)
{
if ($this->psrCompatibleLoggerWasInjected) {
throw new Exception('A PSR-3 logger was injected so removing backends is not possible. Create a new instance.', 1515343007859);
}
if (!$this->backends->contains($backend)) {
throw new NoSuchBackendException('Backend is unknown to this logger.', 1229430381);
}
$backend->close();
$this->backends->detach($backend);
// This needs to be reset in order to re-create a new PSR compatible logger with the remaining backends attached.
$this->internalPsrCompatibleLogger = null;
} | php | public function removeBackend(Backend\BackendInterface $backend)
{
if ($this->psrCompatibleLoggerWasInjected) {
throw new Exception('A PSR-3 logger was injected so removing backends is not possible. Create a new instance.', 1515343007859);
}
if (!$this->backends->contains($backend)) {
throw new NoSuchBackendException('Backend is unknown to this logger.', 1229430381);
}
$backend->close();
$this->backends->detach($backend);
// This needs to be reset in order to re-create a new PSR compatible logger with the remaining backends attached.
$this->internalPsrCompatibleLogger = null;
} | [
"public",
"function",
"removeBackend",
"(",
"Backend",
"\\",
"BackendInterface",
"$",
"backend",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"psrCompatibleLoggerWasInjected",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'A PSR-3 logger was injected so removing backends is n... | Runs the close() method of a backend and removes the backend
from the logger.
@param Backend\BackendInterface $backend The backend to remove
@return void
@throws NoSuchBackendException if the given backend is unknown to this logger
@api
@throws Exception | [
"Runs",
"the",
"close",
"()",
"method",
"of",
"a",
"backend",
"and",
"removes",
"the",
"backend",
"from",
"the",
"logger",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow.Log/Classes/DefaultLogger.php#L142-L155 |
neos/flow-development-collection | Neos.Flow.Log/Classes/DefaultLogger.php | DefaultLogger.log | public function log($message, $severity = LOG_INFO, $additionalData = null, $packageKey = null, $className = null, $methodName = null)
{
if ($this->internalPsrCompatibleLogger === null) {
$this->internalPsrCompatibleLogger = $this->createDefaultPsrLogger();
}
$psrLogLevel = self::LOGLEVEL_MAPPING[$severity] ?? LOG_INFO;
$context = [];
if ($additionalData !== null) {
// In PSR-3 context must always be an array, therefore we create an outer array if different type.
$context = is_array($additionalData) ? $additionalData : ['additionalData' => $additionalData];
}
if ($packageKey !== null || $className !== null || $methodName !== null) {
$context['FLOW_LOG_ENVIRONMENT'] = $this->createFlowLogEnvironment($packageKey, $className, $methodName);
}
$this->internalPsrCompatibleLogger->log($psrLogLevel, $message, $context);
} | php | public function log($message, $severity = LOG_INFO, $additionalData = null, $packageKey = null, $className = null, $methodName = null)
{
if ($this->internalPsrCompatibleLogger === null) {
$this->internalPsrCompatibleLogger = $this->createDefaultPsrLogger();
}
$psrLogLevel = self::LOGLEVEL_MAPPING[$severity] ?? LOG_INFO;
$context = [];
if ($additionalData !== null) {
// In PSR-3 context must always be an array, therefore we create an outer array if different type.
$context = is_array($additionalData) ? $additionalData : ['additionalData' => $additionalData];
}
if ($packageKey !== null || $className !== null || $methodName !== null) {
$context['FLOW_LOG_ENVIRONMENT'] = $this->createFlowLogEnvironment($packageKey, $className, $methodName);
}
$this->internalPsrCompatibleLogger->log($psrLogLevel, $message, $context);
} | [
"public",
"function",
"log",
"(",
"$",
"message",
",",
"$",
"severity",
"=",
"LOG_INFO",
",",
"$",
"additionalData",
"=",
"null",
",",
"$",
"packageKey",
"=",
"null",
",",
"$",
"className",
"=",
"null",
",",
"$",
"methodName",
"=",
"null",
")",
"{",
... | Writes the given message along with the additional information into the log.
@param string $message The message to log
@param integer $severity An integer value, one of the LOG_* constants
@param mixed $additionalData A variable containing more information about the event to be logged
@param string $packageKey Key of the package triggering the log (determined automatically if not specified)
@param string $className Name of the class triggering the log (determined automatically if not specified)
@param string $methodName Name of the method triggering the log (determined automatically if not specified)
@return void
@api | [
"Writes",
"the",
"given",
"message",
"along",
"with",
"the",
"additional",
"information",
"into",
"the",
"log",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow.Log/Classes/DefaultLogger.php#L169-L188 |
neos/flow-development-collection | Neos.Flow.Log/Classes/DefaultLogger.php | DefaultLogger.shutdownObject | public function shutdownObject()
{
$this->internalPsrCompatibleLogger = null;
foreach ($this->backends as $backend) {
$backend->close();
}
} | php | public function shutdownObject()
{
$this->internalPsrCompatibleLogger = null;
foreach ($this->backends as $backend) {
$backend->close();
}
} | [
"public",
"function",
"shutdownObject",
"(",
")",
"{",
"$",
"this",
"->",
"internalPsrCompatibleLogger",
"=",
"null",
";",
"foreach",
"(",
"$",
"this",
"->",
"backends",
"as",
"$",
"backend",
")",
"{",
"$",
"backend",
"->",
"close",
"(",
")",
";",
"}",
... | Cleanly closes all registered backends before destructing this Logger
@return void | [
"Cleanly",
"closes",
"all",
"registered",
"backends",
"before",
"destructing",
"this",
"Logger"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow.Log/Classes/DefaultLogger.php#L242-L248 |
neos/flow-development-collection | Neos.Utility.Schema/Classes/SchemaValidator.php | SchemaValidator.validate | public function validate($value, $schema, array $types = []): ErrorResult
{
$result = new ErrorResult();
if (is_array($schema)) {
foreach ($schema as $possibleTypeKey => $possibleTypeSchema) {
if (substr($possibleTypeKey, 0, 1) === '@') {
if (array_key_exists($possibleTypeKey, $types)) {
$result->addError($this->createError('CustomType "' . $possibleTypeKey . '" is already defined'));
continue;
}
$typeSchema = $possibleTypeSchema;
if (array_key_exists('superTypes', $possibleTypeSchema)) {
foreach ($possibleTypeSchema['superTypes'] as $superTypeKey) {
if (!array_key_exists($superTypeKey, $types)) {
$result->addError($this->createError('SuperType "' . $superTypeKey . '" is unknown'));
continue;
}
$typeSchema = Arrays::arrayMergeRecursiveOverrule($types[$superTypeKey], $typeSchema);
}
}
$types[$possibleTypeKey] = $typeSchema;
unset($schema[$possibleTypeKey]);
}
}
}
if (is_string($schema) === true) {
$result->merge($this->validateType($value, ['type' => $schema], $types));
} elseif ($this->isNumericallyIndexedArray($schema)) {
$isValid = false;
foreach ($schema as $singleSchema) {
$singleResult = $this->validate($value, $singleSchema, $types);
if ($singleResult->hasErrors() === false) {
$isValid = true;
}
}
if ($isValid === false) {
$result->addError($this->createError('None of the given schemas matched ' . $this->renderValue($value)));
}
} elseif ($this->isSchema($schema)) {
if (isset($schema['type'])) {
if (is_array($schema['type'])) {
$result->merge($this->validateTypeArray($value, $schema, $types));
} else {
$result->merge($this->validateType($value, $schema, $types));
}
}
if (isset($schema['disallow'])) {
$subresult = $this->validate($value, ['type' => $schema['disallow']], $types);
if ($subresult->hasErrors() === false) {
$result->addError($this->createError('Disallow rule matched for "' . $this->renderValue($value) . '"'));
}
}
if (isset($schema['enum'])) {
$isValid = false;
foreach ($schema['enum'] as $allowedValue) {
if ($value === $allowedValue) {
$isValid = true;
break;
}
}
if ($isValid === false) {
$result->addError($this->createError('"' . $this->renderValue($value) . '" is not in enum-rule "' . implode(', ', $schema['enum']) . '"'));
}
}
}
return $result;
} | php | public function validate($value, $schema, array $types = []): ErrorResult
{
$result = new ErrorResult();
if (is_array($schema)) {
foreach ($schema as $possibleTypeKey => $possibleTypeSchema) {
if (substr($possibleTypeKey, 0, 1) === '@') {
if (array_key_exists($possibleTypeKey, $types)) {
$result->addError($this->createError('CustomType "' . $possibleTypeKey . '" is already defined'));
continue;
}
$typeSchema = $possibleTypeSchema;
if (array_key_exists('superTypes', $possibleTypeSchema)) {
foreach ($possibleTypeSchema['superTypes'] as $superTypeKey) {
if (!array_key_exists($superTypeKey, $types)) {
$result->addError($this->createError('SuperType "' . $superTypeKey . '" is unknown'));
continue;
}
$typeSchema = Arrays::arrayMergeRecursiveOverrule($types[$superTypeKey], $typeSchema);
}
}
$types[$possibleTypeKey] = $typeSchema;
unset($schema[$possibleTypeKey]);
}
}
}
if (is_string($schema) === true) {
$result->merge($this->validateType($value, ['type' => $schema], $types));
} elseif ($this->isNumericallyIndexedArray($schema)) {
$isValid = false;
foreach ($schema as $singleSchema) {
$singleResult = $this->validate($value, $singleSchema, $types);
if ($singleResult->hasErrors() === false) {
$isValid = true;
}
}
if ($isValid === false) {
$result->addError($this->createError('None of the given schemas matched ' . $this->renderValue($value)));
}
} elseif ($this->isSchema($schema)) {
if (isset($schema['type'])) {
if (is_array($schema['type'])) {
$result->merge($this->validateTypeArray($value, $schema, $types));
} else {
$result->merge($this->validateType($value, $schema, $types));
}
}
if (isset($schema['disallow'])) {
$subresult = $this->validate($value, ['type' => $schema['disallow']], $types);
if ($subresult->hasErrors() === false) {
$result->addError($this->createError('Disallow rule matched for "' . $this->renderValue($value) . '"'));
}
}
if (isset($schema['enum'])) {
$isValid = false;
foreach ($schema['enum'] as $allowedValue) {
if ($value === $allowedValue) {
$isValid = true;
break;
}
}
if ($isValid === false) {
$result->addError($this->createError('"' . $this->renderValue($value) . '" is not in enum-rule "' . implode(', ', $schema['enum']) . '"'));
}
}
}
return $result;
} | [
"public",
"function",
"validate",
"(",
"$",
"value",
",",
"$",
"schema",
",",
"array",
"$",
"types",
"=",
"[",
"]",
")",
":",
"ErrorResult",
"{",
"$",
"result",
"=",
"new",
"ErrorResult",
"(",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"schema",
")... | Validate array with the given schema
The following properties are handled in given $schema:
- type : value is of given type or schema (array of schemas is allowed)
- disallow : value is NOT of given type or schema (array of schemas is allowed)
- enum : value is equal to one of the given values
@param mixed $value value to validate
@param mixed $schema type as string, schema or array of schemas
@param array $types the additional type schemas
@return ErrorResult | [
"Validate",
"array",
"with",
"the",
"given",
"schema"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Utility.Schema/Classes/SchemaValidator.php#L75-L144 |
neos/flow-development-collection | Neos.Utility.Schema/Classes/SchemaValidator.php | SchemaValidator.validateType | protected function validateType($value, array $schema, array $types = []): ErrorResult
{
$result = new ErrorResult();
if (isset($schema['type'])) {
if (is_array($schema['type'])) {
$type = $schema['type'][0];
if (in_array(gettype($value), $schema['type'])) {
$type = gettype($value);
}
} else {
$type = $schema['type'];
}
switch ($type) {
case 'string':
$result->merge($this->validateStringType($value, $schema, $types));
break;
case 'number':
$result->merge($this->validateNumberType($value, $schema));
break;
case 'integer':
$result->merge($this->validateIntegerType($value, $schema));
break;
case 'boolean':
$result->merge($this->validateBooleanType($value, $schema));
break;
case 'array':
$result->merge($this->validateArrayType($value, $schema, $types));
break;
case 'dictionary':
$result->merge($this->validateDictionaryType($value, $schema, $types));
break;
case 'null':
$result->merge($this->validateNullType($value, $schema));
break;
case 'any':
$result->merge($this->validateAnyType($value, $schema));
break;
default:
if (is_string($type) && substr($type, 0, 1) === '@') {
if (array_key_exists($type, $types)) {
$result->merge($this->validate($value, $types[$type], $types));
break;
}
}
$result->addError($this->createError('Type "' . $type . '" is unknown'));
break;
}
} else {
$result->addError($this->createError('Type constraint is required'));
}
return $result;
} | php | protected function validateType($value, array $schema, array $types = []): ErrorResult
{
$result = new ErrorResult();
if (isset($schema['type'])) {
if (is_array($schema['type'])) {
$type = $schema['type'][0];
if (in_array(gettype($value), $schema['type'])) {
$type = gettype($value);
}
} else {
$type = $schema['type'];
}
switch ($type) {
case 'string':
$result->merge($this->validateStringType($value, $schema, $types));
break;
case 'number':
$result->merge($this->validateNumberType($value, $schema));
break;
case 'integer':
$result->merge($this->validateIntegerType($value, $schema));
break;
case 'boolean':
$result->merge($this->validateBooleanType($value, $schema));
break;
case 'array':
$result->merge($this->validateArrayType($value, $schema, $types));
break;
case 'dictionary':
$result->merge($this->validateDictionaryType($value, $schema, $types));
break;
case 'null':
$result->merge($this->validateNullType($value, $schema));
break;
case 'any':
$result->merge($this->validateAnyType($value, $schema));
break;
default:
if (is_string($type) && substr($type, 0, 1) === '@') {
if (array_key_exists($type, $types)) {
$result->merge($this->validate($value, $types[$type], $types));
break;
}
}
$result->addError($this->createError('Type "' . $type . '" is unknown'));
break;
}
} else {
$result->addError($this->createError('Type constraint is required'));
}
return $result;
} | [
"protected",
"function",
"validateType",
"(",
"$",
"value",
",",
"array",
"$",
"schema",
",",
"array",
"$",
"types",
"=",
"[",
"]",
")",
":",
"ErrorResult",
"{",
"$",
"result",
"=",
"new",
"ErrorResult",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
... | Validate a value for a given type
@param mixed $value
@param array $schema
@param array $types
@return ErrorResult | [
"Validate",
"a",
"value",
"for",
"a",
"given",
"type"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Utility.Schema/Classes/SchemaValidator.php#L154-L206 |
neos/flow-development-collection | Neos.Utility.Schema/Classes/SchemaValidator.php | SchemaValidator.validateTypeArray | protected function validateTypeArray($value, array $schema, array $types = []): ErrorResult
{
$result = new ErrorResult();
$isValid = false;
foreach ($schema['type'] as $type) {
$partResult = $this->validate($value, $type, $types);
if ($partResult->hasErrors() === false) {
$isValid = true;
}
}
if ($isValid === false) {
$possibleTypes = [];
foreach ($schema['type'] as $type) {
if (is_scalar($type)) {
$possibleTypes[] = $type;
} elseif (is_array($type) && array_key_exists('type', $type)) {
$possibleTypes[] = $type['type'];
}
}
$error = $this->createError(sprintf('None of the given schemas %s matched %s',
implode(',', $possibleTypes),
is_scalar($value) ? (string)$value : gettype($value)
));
$result->addError($error);
}
return $result;
} | php | protected function validateTypeArray($value, array $schema, array $types = []): ErrorResult
{
$result = new ErrorResult();
$isValid = false;
foreach ($schema['type'] as $type) {
$partResult = $this->validate($value, $type, $types);
if ($partResult->hasErrors() === false) {
$isValid = true;
}
}
if ($isValid === false) {
$possibleTypes = [];
foreach ($schema['type'] as $type) {
if (is_scalar($type)) {
$possibleTypes[] = $type;
} elseif (is_array($type) && array_key_exists('type', $type)) {
$possibleTypes[] = $type['type'];
}
}
$error = $this->createError(sprintf('None of the given schemas %s matched %s',
implode(',', $possibleTypes),
is_scalar($value) ? (string)$value : gettype($value)
));
$result->addError($error);
}
return $result;
} | [
"protected",
"function",
"validateTypeArray",
"(",
"$",
"value",
",",
"array",
"$",
"schema",
",",
"array",
"$",
"types",
"=",
"[",
"]",
")",
":",
"ErrorResult",
"{",
"$",
"result",
"=",
"new",
"ErrorResult",
"(",
")",
";",
"$",
"isValid",
"=",
"false"... | Validate a value with a given list of allowed types
@param mixed $value
@param array $schema
@param array $types
@return ErrorResult | [
"Validate",
"a",
"value",
"with",
"a",
"given",
"list",
"of",
"allowed",
"types"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Utility.Schema/Classes/SchemaValidator.php#L216-L243 |
neos/flow-development-collection | Neos.Utility.Schema/Classes/SchemaValidator.php | SchemaValidator.validateNumberType | protected function validateNumberType($value, array $schema): ErrorResult
{
$result = new ErrorResult();
if (is_numeric($value) === false) {
$result->addError($this->createError('type=number', 'type=' . gettype($value)));
return $result;
}
if (isset($schema['maximum'])) {
if (isset($schema['exclusiveMaximum']) && $schema['exclusiveMaximum'] === true) {
if ($value >= $schema['maximum']) {
$result->addError($this->createError('maximum(exclusive)=' . $schema['maximum'], $value));
}
} else {
if ($value > $schema['maximum']) {
$result->addError($this->createError('maximum=' . $schema['maximum'], $value));
}
}
}
if (isset($schema['minimum'])) {
if (isset($schema['exclusiveMinimum']) && $schema['exclusiveMinimum'] === true) {
if ($value <= $schema['minimum']) {
$result->addError($this->createError('minimum(exclusive)=' . $schema['minimum'], $value));
}
} else {
if ($value < $schema['minimum']) {
$result->addError($this->createError('minimum=' . $schema['minimum'], $value));
}
}
}
if (isset($schema['divisibleBy']) && $value % $schema['divisibleBy'] !== 0) {
$result->addError($this->createError('divisibleBy=' . $schema['divisibleBy'], $value));
}
return $result;
} | php | protected function validateNumberType($value, array $schema): ErrorResult
{
$result = new ErrorResult();
if (is_numeric($value) === false) {
$result->addError($this->createError('type=number', 'type=' . gettype($value)));
return $result;
}
if (isset($schema['maximum'])) {
if (isset($schema['exclusiveMaximum']) && $schema['exclusiveMaximum'] === true) {
if ($value >= $schema['maximum']) {
$result->addError($this->createError('maximum(exclusive)=' . $schema['maximum'], $value));
}
} else {
if ($value > $schema['maximum']) {
$result->addError($this->createError('maximum=' . $schema['maximum'], $value));
}
}
}
if (isset($schema['minimum'])) {
if (isset($schema['exclusiveMinimum']) && $schema['exclusiveMinimum'] === true) {
if ($value <= $schema['minimum']) {
$result->addError($this->createError('minimum(exclusive)=' . $schema['minimum'], $value));
}
} else {
if ($value < $schema['minimum']) {
$result->addError($this->createError('minimum=' . $schema['minimum'], $value));
}
}
}
if (isset($schema['divisibleBy']) && $value % $schema['divisibleBy'] !== 0) {
$result->addError($this->createError('divisibleBy=' . $schema['divisibleBy'], $value));
}
return $result;
} | [
"protected",
"function",
"validateNumberType",
"(",
"$",
"value",
",",
"array",
"$",
"schema",
")",
":",
"ErrorResult",
"{",
"$",
"result",
"=",
"new",
"ErrorResult",
"(",
")",
";",
"if",
"(",
"is_numeric",
"(",
"$",
"value",
")",
"===",
"false",
")",
... | Validate an integer value with the given schema
The following properties are handled in given $schema:
- maximum : maximum allowed value
- minimum : minimum allowed value
- exclusiveMinimum : boolean to use exclusive minimum
- exclusiveMaximum : boolean to use exclusive maximum
- divisibleBy : value is divisibleBy the given number
@param mixed $value
@param array $schema
@return ErrorResult | [
"Validate",
"an",
"integer",
"value",
"with",
"the",
"given",
"schema"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Utility.Schema/Classes/SchemaValidator.php#L259-L296 |
neos/flow-development-collection | Neos.Utility.Schema/Classes/SchemaValidator.php | SchemaValidator.validateBooleanType | protected function validateBooleanType($value, array $schema): ErrorResult
{
$result = new ErrorResult();
if (is_bool($value) === false) {
$result->addError($this->createError('type=boolean', 'type=' . gettype($value)));
return $result;
}
return $result;
} | php | protected function validateBooleanType($value, array $schema): ErrorResult
{
$result = new ErrorResult();
if (is_bool($value) === false) {
$result->addError($this->createError('type=boolean', 'type=' . gettype($value)));
return $result;
}
return $result;
} | [
"protected",
"function",
"validateBooleanType",
"(",
"$",
"value",
",",
"array",
"$",
"schema",
")",
":",
"ErrorResult",
"{",
"$",
"result",
"=",
"new",
"ErrorResult",
"(",
")",
";",
"if",
"(",
"is_bool",
"(",
"$",
"value",
")",
"===",
"false",
")",
"{... | Validate a boolean value with the given schema
@param mixed $value
@param array $schema
@return ErrorResult | [
"Validate",
"a",
"boolean",
"value",
"with",
"the",
"given",
"schema"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Utility.Schema/Classes/SchemaValidator.php#L328-L336 |
neos/flow-development-collection | Neos.Utility.Schema/Classes/SchemaValidator.php | SchemaValidator.validateArrayType | protected function validateArrayType($value, array $schema, array $types = []): ErrorResult
{
$result = new ErrorResult();
if (is_array($value) === false || $this->isNumericallyIndexedArray($value) === false) {
$result->addError($this->createError('type=array', 'type=' . gettype($value)));
return $result;
}
if (isset($schema['minItems']) && count($value) < $schema['minItems']) {
$result->addError($this->createError('minItems=' . $schema['minItems'], count($value) . ' items'));
}
if (isset($schema['maxItems']) && count($value) > $schema['maxItems']) {
$result->addError($this->createError('maxItems=' . $schema['maxItems'], count($value) . ' items'));
}
if (isset($schema['items'])) {
foreach ($value as $index => $itemValue) {
$itemResult = $this->validate($itemValue, $schema['items'], $types);
if ($itemResult->hasErrors() === true) {
$result->forProperty('__index_' . $index)->merge($itemResult);
}
}
}
if (isset($schema['uniqueItems']) && $schema['uniqueItems'] === true) {
$values = [];
foreach ($value as $itemValue) {
$itemHash = is_array($itemValue) ? serialize($itemValue) : $itemValue;
if (in_array($itemHash, $values)) {
$result->addError($this->createError('Unique values are expected'));
break;
}
$values[] = $itemHash;
}
}
return $result;
} | php | protected function validateArrayType($value, array $schema, array $types = []): ErrorResult
{
$result = new ErrorResult();
if (is_array($value) === false || $this->isNumericallyIndexedArray($value) === false) {
$result->addError($this->createError('type=array', 'type=' . gettype($value)));
return $result;
}
if (isset($schema['minItems']) && count($value) < $schema['minItems']) {
$result->addError($this->createError('minItems=' . $schema['minItems'], count($value) . ' items'));
}
if (isset($schema['maxItems']) && count($value) > $schema['maxItems']) {
$result->addError($this->createError('maxItems=' . $schema['maxItems'], count($value) . ' items'));
}
if (isset($schema['items'])) {
foreach ($value as $index => $itemValue) {
$itemResult = $this->validate($itemValue, $schema['items'], $types);
if ($itemResult->hasErrors() === true) {
$result->forProperty('__index_' . $index)->merge($itemResult);
}
}
}
if (isset($schema['uniqueItems']) && $schema['uniqueItems'] === true) {
$values = [];
foreach ($value as $itemValue) {
$itemHash = is_array($itemValue) ? serialize($itemValue) : $itemValue;
if (in_array($itemHash, $values)) {
$result->addError($this->createError('Unique values are expected'));
break;
}
$values[] = $itemHash;
}
}
return $result;
} | [
"protected",
"function",
"validateArrayType",
"(",
"$",
"value",
",",
"array",
"$",
"schema",
",",
"array",
"$",
"types",
"=",
"[",
"]",
")",
":",
"ErrorResult",
"{",
"$",
"result",
"=",
"new",
"ErrorResult",
"(",
")",
";",
"if",
"(",
"is_array",
"(",
... | Validate an array value with the given schema
The following properties are handled in given $schema:
- minItems : minimal allowed item Number
- maxItems : maximal allowed item Number
- items : schema for all instances of the array
- uniqueItems : allow only unique values
@param mixed $value
@param array $schema
@param array $types
@return ErrorResult | [
"Validate",
"an",
"array",
"value",
"with",
"the",
"given",
"schema"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Utility.Schema/Classes/SchemaValidator.php#L352-L390 |
neos/flow-development-collection | Neos.Utility.Schema/Classes/SchemaValidator.php | SchemaValidator.validateDictionaryType | protected function validateDictionaryType($value, array $schema, array $types = []): ErrorResult
{
$result = new ErrorResult();
if (is_array($value) === false || $this->isDictionary($value) === false) {
$result->addError($this->createError('type=dictionary', 'type=' . gettype($value)));
return $result;
}
$propertyKeysToHandle = array_keys($value);
if (isset($schema['properties'])) {
foreach ($schema['properties'] as $propertyName => $propertySchema) {
if (array_key_exists($propertyName, $value)) {
$propertyValue = $value[$propertyName];
$subresult = $this->validate($propertyValue, $propertySchema, $types);
if ($subresult->hasErrors()) {
$result->forProperty($propertyName)->merge($subresult);
}
$propertyKeysToHandle = array_diff($propertyKeysToHandle, [$propertyName]);
} elseif (is_array($propertySchema) && $this->isSchema($propertySchema) && isset($propertySchema['required']) && $propertySchema['required'] === true) {
// is subproperty required
$result->addError($this->createError('Property ' . $propertyName . ' is required'));
}
}
}
if (isset($schema['patternProperties']) && count($propertyKeysToHandle) > 0 && $this->isDictionary($schema['patternProperties'])) {
foreach (array_values($propertyKeysToHandle) as $propertyKey) {
foreach ($schema['patternProperties'] as $propertyPattern => $propertySchema) {
$keyResult = $this->validateStringType($propertyKey, ['pattern' => $propertyPattern], $types);
if ($keyResult->hasErrors() === true) {
continue;
}
$subresult = $this->validate($value[$propertyKey], $propertySchema, $types);
if ($subresult->hasErrors()) {
$result->forProperty($propertyKey)->merge($subresult);
}
$propertyKeysToHandle = array_diff($propertyKeysToHandle, [$propertyKey]);
}
}
}
if (isset($schema['formatProperties']) && count($propertyKeysToHandle) > 0 && $this->isDictionary($schema['formatProperties'])) {
foreach (array_values($propertyKeysToHandle) as $propertyKey) {
foreach ($schema['formatProperties'] as $propertyPattern => $propertySchema) {
$keyResult = $this->validateStringType($propertyKey, ['format' => $propertyPattern], $types);
if ($keyResult->hasErrors() === true) {
continue;
}
$subresult = $this->validate($value[$propertyKey], $propertySchema, $types);
if ($subresult->hasErrors()) {
$result->forProperty($propertyKey)->merge($subresult);
}
$propertyKeysToHandle = array_diff($propertyKeysToHandle, [$propertyKey]);
}
}
}
if (isset($schema['additionalProperties']) && $schema['additionalProperties'] !== true && count($propertyKeysToHandle) > 0) {
if ($schema['additionalProperties'] === false) {
foreach ($propertyKeysToHandle as $propertyKey) {
$result->forProperty($propertyKey)->addError($this->createError('This property is not allowed here, check the spelling if you think it belongs here.'));
}
} else {
foreach ($propertyKeysToHandle as $propertyKey) {
$subresult = $this->validate($value[$propertyKey], $schema['additionalProperties'], $types);
if ($subresult->hasErrors()) {
$result->forProperty($propertyKey)->merge($subresult);
}
}
}
}
return $result;
} | php | protected function validateDictionaryType($value, array $schema, array $types = []): ErrorResult
{
$result = new ErrorResult();
if (is_array($value) === false || $this->isDictionary($value) === false) {
$result->addError($this->createError('type=dictionary', 'type=' . gettype($value)));
return $result;
}
$propertyKeysToHandle = array_keys($value);
if (isset($schema['properties'])) {
foreach ($schema['properties'] as $propertyName => $propertySchema) {
if (array_key_exists($propertyName, $value)) {
$propertyValue = $value[$propertyName];
$subresult = $this->validate($propertyValue, $propertySchema, $types);
if ($subresult->hasErrors()) {
$result->forProperty($propertyName)->merge($subresult);
}
$propertyKeysToHandle = array_diff($propertyKeysToHandle, [$propertyName]);
} elseif (is_array($propertySchema) && $this->isSchema($propertySchema) && isset($propertySchema['required']) && $propertySchema['required'] === true) {
// is subproperty required
$result->addError($this->createError('Property ' . $propertyName . ' is required'));
}
}
}
if (isset($schema['patternProperties']) && count($propertyKeysToHandle) > 0 && $this->isDictionary($schema['patternProperties'])) {
foreach (array_values($propertyKeysToHandle) as $propertyKey) {
foreach ($schema['patternProperties'] as $propertyPattern => $propertySchema) {
$keyResult = $this->validateStringType($propertyKey, ['pattern' => $propertyPattern], $types);
if ($keyResult->hasErrors() === true) {
continue;
}
$subresult = $this->validate($value[$propertyKey], $propertySchema, $types);
if ($subresult->hasErrors()) {
$result->forProperty($propertyKey)->merge($subresult);
}
$propertyKeysToHandle = array_diff($propertyKeysToHandle, [$propertyKey]);
}
}
}
if (isset($schema['formatProperties']) && count($propertyKeysToHandle) > 0 && $this->isDictionary($schema['formatProperties'])) {
foreach (array_values($propertyKeysToHandle) as $propertyKey) {
foreach ($schema['formatProperties'] as $propertyPattern => $propertySchema) {
$keyResult = $this->validateStringType($propertyKey, ['format' => $propertyPattern], $types);
if ($keyResult->hasErrors() === true) {
continue;
}
$subresult = $this->validate($value[$propertyKey], $propertySchema, $types);
if ($subresult->hasErrors()) {
$result->forProperty($propertyKey)->merge($subresult);
}
$propertyKeysToHandle = array_diff($propertyKeysToHandle, [$propertyKey]);
}
}
}
if (isset($schema['additionalProperties']) && $schema['additionalProperties'] !== true && count($propertyKeysToHandle) > 0) {
if ($schema['additionalProperties'] === false) {
foreach ($propertyKeysToHandle as $propertyKey) {
$result->forProperty($propertyKey)->addError($this->createError('This property is not allowed here, check the spelling if you think it belongs here.'));
}
} else {
foreach ($propertyKeysToHandle as $propertyKey) {
$subresult = $this->validate($value[$propertyKey], $schema['additionalProperties'], $types);
if ($subresult->hasErrors()) {
$result->forProperty($propertyKey)->merge($subresult);
}
}
}
}
return $result;
} | [
"protected",
"function",
"validateDictionaryType",
"(",
"$",
"value",
",",
"array",
"$",
"schema",
",",
"array",
"$",
"types",
"=",
"[",
"]",
")",
":",
"ErrorResult",
"{",
"$",
"result",
"=",
"new",
"ErrorResult",
"(",
")",
";",
"if",
"(",
"is_array",
... | Validate a dictionary value with the given schema
The following properties are handled in given $schema:
- properties : array of keys and schemas that have to validate
- formatProperties : dictionary of schemas, the schemas are used to validate all keys that match the string-format
- patternProperties : dictionary of schemas, the schemas are used to validate all keys that match the string-pattern
- additionalProperties : if false is given all additionalProperties are forbidden, if a schema is given all additional properties have to match the schema
@param mixed $value
@param array $schema
@param array $types
@return ErrorResult | [
"Validate",
"a",
"dictionary",
"value",
"with",
"the",
"given",
"schema"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Utility.Schema/Classes/SchemaValidator.php#L406-L480 |
neos/flow-development-collection | Neos.Utility.Schema/Classes/SchemaValidator.php | SchemaValidator.validateStringType | protected function validateStringType($value, array $schema, array $types = []): ErrorResult
{
$result = new ErrorResult();
if (is_string($value) === false) {
$result->addError($this->createError('type=string', 'type=' . gettype($value)));
return $result;
}
if (isset($schema['pattern'])) {
if (preg_match($schema['pattern'], $value) === 0) {
$result->addError($this->createError('pattern=' . $schema['pattern'], $value));
}
}
if (isset($schema['minLength'])) {
if (strlen($value) < (int)$schema['minLength']) {
$result->addError($this->createError('minLength=' . $schema['minLength'], 'strlen=' . strlen($value)));
}
}
if (isset($schema['maxLength'])) {
if (strlen($value) > (int)$schema['maxLength']) {
$result->addError($this->createError('maxLength=' . $schema['maxLength'], 'strlen=' . strlen($value)));
}
}
if (isset($schema['format'])) {
switch ($schema['format']) {
case 'date-time':
// YYYY-MM-DDThh:mm:ssZ ISO8601
\DateTime::createFromFormat(\DateTime::ISO8601, $value);
$parseErrors = \DateTime::getLastErrors();
if ($parseErrors['error_count'] > 0) {
$result->addError($this->createError('format=datetime', $value));
}
break;
case 'date':
// YYYY-MM-DD
\DateTime::createFromFormat('Y-m-d', $value);
$parseErrors = \DateTime::getLastErrors();
if ($parseErrors['error_count'] > 0) {
$result->addError($this->createError('format=date', $value));
}
break;
case 'time':
// hh:mm:ss
\DateTime::createFromFormat('H:i:s', $value);
$parseErrors = \DateTime::getLastErrors();
if ($parseErrors['error_count'] > 0) {
$result->addError($this->createError('format=time', $value));
}
break;
case 'uri':
if (filter_var($value, FILTER_VALIDATE_URL) === false) {
$result->addError($this->createError('format=uri', $value));
}
break;
case 'email':
if (filter_var($value, FILTER_VALIDATE_EMAIL) === false) {
$result->addError($this->createError('format=email', $value));
}
break;
case 'ipv4':
if (filter_var($value, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) === false) {
$result->addError($this->createError('format=ipv4', $value));
}
break;
case 'ipv6':
if (filter_var($value, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) === false) {
$result->addError($this->createError('format=ipv6', $value));
}
break;
case 'ip-address':
if (filter_var($value, FILTER_VALIDATE_IP) === false) {
$result->addError($this->createError('format=ip-address', $value));
}
break;
case 'host-name':
if (gethostbyname($value) === $value) {
$result->addError($this->createError('format=host-name', $value));
}
break;
case 'class-name':
if (class_exists($value) === false && interface_exists($value) === false) {
$result->addError($this->createError('format=class-name', $value));
}
break;
case 'interface-name':
if (interface_exists($value) === false) {
$result->addError($this->createError('format=interface-name', $value));
}
break;
default:
$result->addError($this->createError('Expected string-format "' . $schema['format'] . '" is unknown'));
break;
}
}
return $result;
} | php | protected function validateStringType($value, array $schema, array $types = []): ErrorResult
{
$result = new ErrorResult();
if (is_string($value) === false) {
$result->addError($this->createError('type=string', 'type=' . gettype($value)));
return $result;
}
if (isset($schema['pattern'])) {
if (preg_match($schema['pattern'], $value) === 0) {
$result->addError($this->createError('pattern=' . $schema['pattern'], $value));
}
}
if (isset($schema['minLength'])) {
if (strlen($value) < (int)$schema['minLength']) {
$result->addError($this->createError('minLength=' . $schema['minLength'], 'strlen=' . strlen($value)));
}
}
if (isset($schema['maxLength'])) {
if (strlen($value) > (int)$schema['maxLength']) {
$result->addError($this->createError('maxLength=' . $schema['maxLength'], 'strlen=' . strlen($value)));
}
}
if (isset($schema['format'])) {
switch ($schema['format']) {
case 'date-time':
// YYYY-MM-DDThh:mm:ssZ ISO8601
\DateTime::createFromFormat(\DateTime::ISO8601, $value);
$parseErrors = \DateTime::getLastErrors();
if ($parseErrors['error_count'] > 0) {
$result->addError($this->createError('format=datetime', $value));
}
break;
case 'date':
// YYYY-MM-DD
\DateTime::createFromFormat('Y-m-d', $value);
$parseErrors = \DateTime::getLastErrors();
if ($parseErrors['error_count'] > 0) {
$result->addError($this->createError('format=date', $value));
}
break;
case 'time':
// hh:mm:ss
\DateTime::createFromFormat('H:i:s', $value);
$parseErrors = \DateTime::getLastErrors();
if ($parseErrors['error_count'] > 0) {
$result->addError($this->createError('format=time', $value));
}
break;
case 'uri':
if (filter_var($value, FILTER_VALIDATE_URL) === false) {
$result->addError($this->createError('format=uri', $value));
}
break;
case 'email':
if (filter_var($value, FILTER_VALIDATE_EMAIL) === false) {
$result->addError($this->createError('format=email', $value));
}
break;
case 'ipv4':
if (filter_var($value, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) === false) {
$result->addError($this->createError('format=ipv4', $value));
}
break;
case 'ipv6':
if (filter_var($value, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) === false) {
$result->addError($this->createError('format=ipv6', $value));
}
break;
case 'ip-address':
if (filter_var($value, FILTER_VALIDATE_IP) === false) {
$result->addError($this->createError('format=ip-address', $value));
}
break;
case 'host-name':
if (gethostbyname($value) === $value) {
$result->addError($this->createError('format=host-name', $value));
}
break;
case 'class-name':
if (class_exists($value) === false && interface_exists($value) === false) {
$result->addError($this->createError('format=class-name', $value));
}
break;
case 'interface-name':
if (interface_exists($value) === false) {
$result->addError($this->createError('format=interface-name', $value));
}
break;
default:
$result->addError($this->createError('Expected string-format "' . $schema['format'] . '" is unknown'));
break;
}
}
return $result;
} | [
"protected",
"function",
"validateStringType",
"(",
"$",
"value",
",",
"array",
"$",
"schema",
",",
"array",
"$",
"types",
"=",
"[",
"]",
")",
":",
"ErrorResult",
"{",
"$",
"result",
"=",
"new",
"ErrorResult",
"(",
")",
";",
"if",
"(",
"is_string",
"("... | Validate a string value with the given schema
The following properties are handled in given $schema:
- pattern : Regular expression that matches the $value
- minLength : minimal allowed string length
- maxLength : maximal allowed string length
- format : some predefined formats
[date-time|date|time|uri|email|ipv4|ipv6|ip-address|host-name|class-name|interface-name]
@param mixed $value
@param array $schema
@param array $types
@return ErrorResult | [
"Validate",
"a",
"string",
"value",
"with",
"the",
"given",
"schema"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Utility.Schema/Classes/SchemaValidator.php#L498-L596 |
neos/flow-development-collection | Neos.Utility.Schema/Classes/SchemaValidator.php | SchemaValidator.validateNullType | protected function validateNullType($value, array $schema): ErrorResult
{
$result = new ErrorResult();
if ($value !== null) {
$result->addError($this->createError('type=NULL', 'type=' . gettype($value)));
}
return $result;
} | php | protected function validateNullType($value, array $schema): ErrorResult
{
$result = new ErrorResult();
if ($value !== null) {
$result->addError($this->createError('type=NULL', 'type=' . gettype($value)));
}
return $result;
} | [
"protected",
"function",
"validateNullType",
"(",
"$",
"value",
",",
"array",
"$",
"schema",
")",
":",
"ErrorResult",
"{",
"$",
"result",
"=",
"new",
"ErrorResult",
"(",
")",
";",
"if",
"(",
"$",
"value",
"!==",
"null",
")",
"{",
"$",
"result",
"->",
... | Validate a null value with the given schema
@param mixed $value
@param array $schema
@return ErrorResult | [
"Validate",
"a",
"null",
"value",
"with",
"the",
"given",
"schema"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Utility.Schema/Classes/SchemaValidator.php#L605-L612 |
neos/flow-development-collection | Neos.Utility.Schema/Classes/SchemaValidator.php | SchemaValidator.createError | protected function createError(string $expectation, $value = null): Error
{
if ($value !== null) {
$error = new Error('expected: %s found: %s', 1328557141, [$expectation, $this->renderValue($value)],
'Validation Error');
} else {
$error = new Error($expectation, 1328557141, [], 'Validation Error');
}
return $error;
} | php | protected function createError(string $expectation, $value = null): Error
{
if ($value !== null) {
$error = new Error('expected: %s found: %s', 1328557141, [$expectation, $this->renderValue($value)],
'Validation Error');
} else {
$error = new Error($expectation, 1328557141, [], 'Validation Error');
}
return $error;
} | [
"protected",
"function",
"createError",
"(",
"string",
"$",
"expectation",
",",
"$",
"value",
"=",
"null",
")",
":",
"Error",
"{",
"if",
"(",
"$",
"value",
"!==",
"null",
")",
"{",
"$",
"error",
"=",
"new",
"Error",
"(",
"'expected: %s found: %s'",
",",
... | Create Error Object
@param string $expectation
@param mixed $value
@return Error | [
"Create",
"Error",
"Object"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Utility.Schema/Classes/SchemaValidator.php#L644-L653 |
neos/flow-development-collection | Neos.Utility.Schema/Classes/SchemaValidator.php | SchemaValidator.isNumericallyIndexedArray | protected function isNumericallyIndexedArray(array $phpArray): bool
{
foreach (array_keys($phpArray) as $key) {
if (is_numeric($key) === false) {
return false;
}
}
return true;
} | php | protected function isNumericallyIndexedArray(array $phpArray): bool
{
foreach (array_keys($phpArray) as $key) {
if (is_numeric($key) === false) {
return false;
}
}
return true;
} | [
"protected",
"function",
"isNumericallyIndexedArray",
"(",
"array",
"$",
"phpArray",
")",
":",
"bool",
"{",
"foreach",
"(",
"array_keys",
"(",
"$",
"phpArray",
")",
"as",
"$",
"key",
")",
"{",
"if",
"(",
"is_numeric",
"(",
"$",
"key",
")",
"===",
"false"... | Determine whether the given php array is a plain numerically indexed array
@param array $phpArray
@return boolean | [
"Determine",
"whether",
"the",
"given",
"php",
"array",
"is",
"a",
"plain",
"numerically",
"indexed",
"array"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Utility.Schema/Classes/SchemaValidator.php#L674-L682 |
neos/flow-development-collection | Neos.Flow/Classes/Mvc/Routing/Dto/RouteTags.php | RouteTags.merge | public function merge(RouteTags $tags): self
{
$mergedTags = array_unique(array_merge($this->tags, $tags->tags));
return new static($mergedTags);
} | php | public function merge(RouteTags $tags): self
{
$mergedTags = array_unique(array_merge($this->tags, $tags->tags));
return new static($mergedTags);
} | [
"public",
"function",
"merge",
"(",
"RouteTags",
"$",
"tags",
")",
":",
"self",
"{",
"$",
"mergedTags",
"=",
"array_unique",
"(",
"array_merge",
"(",
"$",
"this",
"->",
"tags",
",",
"$",
"tags",
"->",
"tags",
")",
")",
";",
"return",
"new",
"static",
... | Merges two instances of this class combining and unifying all tags
@param RouteTags $tags
@return RouteTags | [
"Merges",
"two",
"instances",
"of",
"this",
"class",
"combining",
"and",
"unifying",
"all",
"tags"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Mvc/Routing/Dto/RouteTags.php#L85-L89 |
neos/flow-development-collection | Neos.Flow/Classes/Mvc/Routing/Dto/RouteTags.php | RouteTags.withTag | public function withTag(string $tag): self
{
if ($this->has($tag)) {
return $this;
}
self::validateTag($tag);
$newTags = $this->tags;
$newTags[] = $tag;
return new static($newTags);
} | php | public function withTag(string $tag): self
{
if ($this->has($tag)) {
return $this;
}
self::validateTag($tag);
$newTags = $this->tags;
$newTags[] = $tag;
return new static($newTags);
} | [
"public",
"function",
"withTag",
"(",
"string",
"$",
"tag",
")",
":",
"self",
"{",
"if",
"(",
"$",
"this",
"->",
"has",
"(",
"$",
"tag",
")",
")",
"{",
"return",
"$",
"this",
";",
"}",
"self",
"::",
"validateTag",
"(",
"$",
"tag",
")",
";",
"$"... | Creates a new instance with the given $tag added
If the $tag has been added already, this instance is returned
@param string $tag
@return RouteTags | [
"Creates",
"a",
"new",
"instance",
"with",
"the",
"given",
"$tag",
"added",
"If",
"the",
"$tag",
"has",
"been",
"added",
"already",
"this",
"instance",
"is",
"returned"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Mvc/Routing/Dto/RouteTags.php#L98-L107 |
neos/flow-development-collection | Neos.Flow/Classes/Mvc/Routing/Dto/RouteTags.php | RouteTags.validateTag | private static function validateTag($tag)
{
if (!is_string($tag)) {
throw new \InvalidArgumentException(sprintf('RouteTags have to be strings, %s given', is_object($tag) ? get_class($tag) : gettype($tag)), 1512553153);
}
if (preg_match(self::PATTERN_TAG, $tag) !== 1) {
throw new \InvalidArgumentException(sprintf('The given string "%s" is not a valid tag', $tag), 1511807639);
}
} | php | private static function validateTag($tag)
{
if (!is_string($tag)) {
throw new \InvalidArgumentException(sprintf('RouteTags have to be strings, %s given', is_object($tag) ? get_class($tag) : gettype($tag)), 1512553153);
}
if (preg_match(self::PATTERN_TAG, $tag) !== 1) {
throw new \InvalidArgumentException(sprintf('The given string "%s" is not a valid tag', $tag), 1511807639);
}
} | [
"private",
"static",
"function",
"validateTag",
"(",
"$",
"tag",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"tag",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'RouteTags have to be strings, %s given'",
",",
"is_... | Checks the format of a given $tag string and throws an exception if it does not conform to the PATTERN_TAG regex
@param string $tag
@throws \InvalidArgumentException | [
"Checks",
"the",
"format",
"of",
"a",
"given",
"$tag",
"string",
"and",
"throws",
"an",
"exception",
"if",
"it",
"does",
"not",
"conform",
"to",
"the",
"PATTERN_TAG",
"regex"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Mvc/Routing/Dto/RouteTags.php#L115-L123 |
neos/flow-development-collection | Neos.Cache/Classes/Backend/PdoBackend.php | PdoBackend.set | public function set(string $entryIdentifier, string $data, array $tags = [], int $lifetime = null)
{
$this->connect();
if (!$this->cache instanceof FrontendInterface) {
throw new Exception('No cache frontend has been set yet via setCache().', 1259515600);
}
$this->remove($entryIdentifier);
$lifetime = ($lifetime === null) ? $this->defaultLifetime : $lifetime;
// Convert binary data into hexadecimal representation,
// because it is not allowed to store null bytes in PostgreSQL.
if ($this->pdoDriver === 'pgsql') {
$data = bin2hex($data);
}
$statementHandle = $this->databaseHandle->prepare('INSERT INTO "' . $this->cacheTableName . '" ("identifier", "context", "cache", "created", "lifetime", "content") VALUES (?, ?, ?, ?, ?, ?)');
$result = $statementHandle->execute([$entryIdentifier, $this->context(), $this->cacheIdentifier, time(), $lifetime, $data]);
if ($result === false) {
throw new Exception('The cache entry "' . $entryIdentifier . '" could not be written.', 1259530791);
}
$statementHandle = $this->databaseHandle->prepare('INSERT INTO "' . $this->tagsTableName . '" ("identifier", "context", "cache", "tag") VALUES (?, ?, ?, ?)');
foreach ($tags as $tag) {
$result = $statementHandle->execute([$entryIdentifier, $this->context(), $this->cacheIdentifier, $tag]);
if ($result === false) {
throw new Exception('The tag "' . $tag . ' for cache entry "' . $entryIdentifier . '" could not be written.', 1259530751);
}
}
} | php | public function set(string $entryIdentifier, string $data, array $tags = [], int $lifetime = null)
{
$this->connect();
if (!$this->cache instanceof FrontendInterface) {
throw new Exception('No cache frontend has been set yet via setCache().', 1259515600);
}
$this->remove($entryIdentifier);
$lifetime = ($lifetime === null) ? $this->defaultLifetime : $lifetime;
// Convert binary data into hexadecimal representation,
// because it is not allowed to store null bytes in PostgreSQL.
if ($this->pdoDriver === 'pgsql') {
$data = bin2hex($data);
}
$statementHandle = $this->databaseHandle->prepare('INSERT INTO "' . $this->cacheTableName . '" ("identifier", "context", "cache", "created", "lifetime", "content") VALUES (?, ?, ?, ?, ?, ?)');
$result = $statementHandle->execute([$entryIdentifier, $this->context(), $this->cacheIdentifier, time(), $lifetime, $data]);
if ($result === false) {
throw new Exception('The cache entry "' . $entryIdentifier . '" could not be written.', 1259530791);
}
$statementHandle = $this->databaseHandle->prepare('INSERT INTO "' . $this->tagsTableName . '" ("identifier", "context", "cache", "tag") VALUES (?, ?, ?, ?)');
foreach ($tags as $tag) {
$result = $statementHandle->execute([$entryIdentifier, $this->context(), $this->cacheIdentifier, $tag]);
if ($result === false) {
throw new Exception('The tag "' . $tag . ' for cache entry "' . $entryIdentifier . '" could not be written.', 1259530751);
}
}
} | [
"public",
"function",
"set",
"(",
"string",
"$",
"entryIdentifier",
",",
"string",
"$",
"data",
",",
"array",
"$",
"tags",
"=",
"[",
"]",
",",
"int",
"$",
"lifetime",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"connect",
"(",
")",
";",
"if",
"(",
... | Saves data in the cache.
@param string $entryIdentifier An identifier for this specific cache entry
@param string $data The data to be stored
@param array $tags Tags to associate with this cache entry
@param integer $lifetime Lifetime of this cache entry in seconds. If NULL is specified, the default lifetime is used. "0" means unlimited lifetime.
@return void
@throws Exception if no cache frontend has been set.
@throws \InvalidArgumentException if the identifier is not valid
@throws FilesException
@api | [
"Saves",
"data",
"in",
"the",
"cache",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Cache/Classes/Backend/PdoBackend.php#L157-L188 |
neos/flow-development-collection | Neos.Cache/Classes/Backend/PdoBackend.php | PdoBackend.get | public function get(string $entryIdentifier)
{
$this->connect();
$statementHandle = $this->databaseHandle->prepare('SELECT "content" FROM "' . $this->cacheTableName . '" WHERE "identifier"=? AND "context"=? AND "cache"=?' . $this->getNotExpiredStatement());
$statementHandle->execute([$entryIdentifier, $this->context(), $this->cacheIdentifier]);
$fetchedColumn = $statementHandle->fetchColumn();
// Convert hexadecimal data into binary string,
// because it is not allowed to store null bytes in PostgreSQL.
if ($fetchedColumn !== false && $this->pdoDriver === 'pgsql') {
$fetchedColumn = hex2bin($fetchedColumn);
}
return $fetchedColumn;
} | php | public function get(string $entryIdentifier)
{
$this->connect();
$statementHandle = $this->databaseHandle->prepare('SELECT "content" FROM "' . $this->cacheTableName . '" WHERE "identifier"=? AND "context"=? AND "cache"=?' . $this->getNotExpiredStatement());
$statementHandle->execute([$entryIdentifier, $this->context(), $this->cacheIdentifier]);
$fetchedColumn = $statementHandle->fetchColumn();
// Convert hexadecimal data into binary string,
// because it is not allowed to store null bytes in PostgreSQL.
if ($fetchedColumn !== false && $this->pdoDriver === 'pgsql') {
$fetchedColumn = hex2bin($fetchedColumn);
}
return $fetchedColumn;
} | [
"public",
"function",
"get",
"(",
"string",
"$",
"entryIdentifier",
")",
"{",
"$",
"this",
"->",
"connect",
"(",
")",
";",
"$",
"statementHandle",
"=",
"$",
"this",
"->",
"databaseHandle",
"->",
"prepare",
"(",
"'SELECT \"content\" FROM \"'",
".",
"$",
"this... | Loads data from the cache.
@param string $entryIdentifier An identifier which describes the cache entry to load
@return mixed The cache entry's content as a string or false if the cache entry could not be loaded
@throws Exception
@throws FilesException
@api | [
"Loads",
"data",
"from",
"the",
"cache",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Cache/Classes/Backend/PdoBackend.php#L199-L214 |
neos/flow-development-collection | Neos.Cache/Classes/Backend/PdoBackend.php | PdoBackend.has | public function has(string $entryIdentifier): bool
{
$this->connect();
$statementHandle = $this->databaseHandle->prepare('SELECT COUNT("identifier") FROM "' . $this->cacheTableName . '" WHERE "identifier"=? AND "context"=? AND "cache"=?' . $this->getNotExpiredStatement());
$statementHandle->execute([$entryIdentifier, $this->context(), $this->cacheIdentifier]);
return ($statementHandle->fetchColumn() > 0);
} | php | public function has(string $entryIdentifier): bool
{
$this->connect();
$statementHandle = $this->databaseHandle->prepare('SELECT COUNT("identifier") FROM "' . $this->cacheTableName . '" WHERE "identifier"=? AND "context"=? AND "cache"=?' . $this->getNotExpiredStatement());
$statementHandle->execute([$entryIdentifier, $this->context(), $this->cacheIdentifier]);
return ($statementHandle->fetchColumn() > 0);
} | [
"public",
"function",
"has",
"(",
"string",
"$",
"entryIdentifier",
")",
":",
"bool",
"{",
"$",
"this",
"->",
"connect",
"(",
")",
";",
"$",
"statementHandle",
"=",
"$",
"this",
"->",
"databaseHandle",
"->",
"prepare",
"(",
"'SELECT COUNT(\"identifier\") FROM ... | Checks if a cache entry with the specified identifier exists.
@param string $entryIdentifier An identifier specifying the cache entry
@return boolean true if such an entry exists, false if not
@throws Exception
@throws FilesException
@api | [
"Checks",
"if",
"a",
"cache",
"entry",
"with",
"the",
"specified",
"identifier",
"exists",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Cache/Classes/Backend/PdoBackend.php#L225-L232 |
neos/flow-development-collection | Neos.Cache/Classes/Backend/PdoBackend.php | PdoBackend.remove | public function remove(string $entryIdentifier): bool
{
$this->connect();
$statementHandle = $this->databaseHandle->prepare('DELETE FROM "' . $this->tagsTableName . '" WHERE "identifier"=? AND "context"=? AND "cache"=?');
$statementHandle->execute([$entryIdentifier, $this->context(), $this->cacheIdentifier]);
$statementHandle = $this->databaseHandle->prepare('DELETE FROM "' . $this->cacheTableName . '" WHERE "identifier"=? AND "context"=? AND "cache"=?');
$statementHandle->execute([$entryIdentifier, $this->context(), $this->cacheIdentifier]);
return ($statementHandle->rowCount() > 0);
} | php | public function remove(string $entryIdentifier): bool
{
$this->connect();
$statementHandle = $this->databaseHandle->prepare('DELETE FROM "' . $this->tagsTableName . '" WHERE "identifier"=? AND "context"=? AND "cache"=?');
$statementHandle->execute([$entryIdentifier, $this->context(), $this->cacheIdentifier]);
$statementHandle = $this->databaseHandle->prepare('DELETE FROM "' . $this->cacheTableName . '" WHERE "identifier"=? AND "context"=? AND "cache"=?');
$statementHandle->execute([$entryIdentifier, $this->context(), $this->cacheIdentifier]);
return ($statementHandle->rowCount() > 0);
} | [
"public",
"function",
"remove",
"(",
"string",
"$",
"entryIdentifier",
")",
":",
"bool",
"{",
"$",
"this",
"->",
"connect",
"(",
")",
";",
"$",
"statementHandle",
"=",
"$",
"this",
"->",
"databaseHandle",
"->",
"prepare",
"(",
"'DELETE FROM \"'",
".",
"$",... | Removes all cache entries matching the specified identifier.
Usually this only affects one entry but if - for what reason ever -
old entries for the identifier still exist, they are removed as well.
@param string $entryIdentifier Specifies the cache entry to remove
@return boolean true if (at least) an entry could be removed or false if no entry was found
@throws Exception
@throws FilesException
@api | [
"Removes",
"all",
"cache",
"entries",
"matching",
"the",
"specified",
"identifier",
".",
"Usually",
"this",
"only",
"affects",
"one",
"entry",
"but",
"if",
"-",
"for",
"what",
"reason",
"ever",
"-",
"old",
"entries",
"for",
"the",
"identifier",
"still",
"exi... | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Cache/Classes/Backend/PdoBackend.php#L245-L256 |
neos/flow-development-collection | Neos.Cache/Classes/Backend/PdoBackend.php | PdoBackend.flush | public function flush()
{
$this->connect();
$statementHandle = $this->databaseHandle->prepare('DELETE FROM "' . $this->tagsTableName . '" WHERE "context"=? AND "cache"=?');
try {
$statementHandle->execute([$this->context(), $this->cacheIdentifier]);
} catch (\PDOException $exception) {
}
$statementHandle = $this->databaseHandle->prepare('DELETE FROM "' . $this->cacheTableName . '" WHERE "context"=? AND "cache"=?');
try {
$statementHandle->execute([$this->context(), $this->cacheIdentifier]);
} catch (\PDOException $exception) {
}
} | php | public function flush()
{
$this->connect();
$statementHandle = $this->databaseHandle->prepare('DELETE FROM "' . $this->tagsTableName . '" WHERE "context"=? AND "cache"=?');
try {
$statementHandle->execute([$this->context(), $this->cacheIdentifier]);
} catch (\PDOException $exception) {
}
$statementHandle = $this->databaseHandle->prepare('DELETE FROM "' . $this->cacheTableName . '" WHERE "context"=? AND "cache"=?');
try {
$statementHandle->execute([$this->context(), $this->cacheIdentifier]);
} catch (\PDOException $exception) {
}
} | [
"public",
"function",
"flush",
"(",
")",
"{",
"$",
"this",
"->",
"connect",
"(",
")",
";",
"$",
"statementHandle",
"=",
"$",
"this",
"->",
"databaseHandle",
"->",
"prepare",
"(",
"'DELETE FROM \"'",
".",
"$",
"this",
"->",
"tagsTableName",
".",
"'\" WHERE ... | Removes all cache entries of this cache.
@return void
@throws Exception
@throws FilesException
@api | [
"Removes",
"all",
"cache",
"entries",
"of",
"this",
"cache",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Cache/Classes/Backend/PdoBackend.php#L266-L281 |
neos/flow-development-collection | Neos.Cache/Classes/Backend/PdoBackend.php | PdoBackend.flushByTag | public function flushByTag(string $tag): int
{
$this->connect();
$statementHandle = $this->databaseHandle->prepare('DELETE FROM "' . $this->cacheTableName . '" WHERE "context"=? AND "cache"=? AND "identifier" IN (SELECT "identifier" FROM "tags" WHERE "context"=? AND "cache"=? AND "tag"=?)');
$statementHandle->execute([$this->context(), $this->cacheIdentifier, $this->context(), $this->cacheIdentifier, $tag]);
$flushed = $statementHandle->rowCount();
$statementHandle = $this->databaseHandle->prepare('DELETE FROM "' . $this->tagsTableName . '" WHERE "context"=? AND "cache"=? AND "tag"=?');
$statementHandle->execute([$this->context(), $this->cacheIdentifier, $tag]);
return $flushed;
} | php | public function flushByTag(string $tag): int
{
$this->connect();
$statementHandle = $this->databaseHandle->prepare('DELETE FROM "' . $this->cacheTableName . '" WHERE "context"=? AND "cache"=? AND "identifier" IN (SELECT "identifier" FROM "tags" WHERE "context"=? AND "cache"=? AND "tag"=?)');
$statementHandle->execute([$this->context(), $this->cacheIdentifier, $this->context(), $this->cacheIdentifier, $tag]);
$flushed = $statementHandle->rowCount();
$statementHandle = $this->databaseHandle->prepare('DELETE FROM "' . $this->tagsTableName . '" WHERE "context"=? AND "cache"=? AND "tag"=?');
$statementHandle->execute([$this->context(), $this->cacheIdentifier, $tag]);
return $flushed;
} | [
"public",
"function",
"flushByTag",
"(",
"string",
"$",
"tag",
")",
":",
"int",
"{",
"$",
"this",
"->",
"connect",
"(",
")",
";",
"$",
"statementHandle",
"=",
"$",
"this",
"->",
"databaseHandle",
"->",
"prepare",
"(",
"'DELETE FROM \"'",
".",
"$",
"this"... | Removes all cache entries of this cache which are tagged by the specified tag.
@param string $tag The tag the entries must have
@return integer
@throws Exception
@throws FilesException
@api | [
"Removes",
"all",
"cache",
"entries",
"of",
"this",
"cache",
"which",
"are",
"tagged",
"by",
"the",
"specified",
"tag",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Cache/Classes/Backend/PdoBackend.php#L292-L305 |
neos/flow-development-collection | Neos.Cache/Classes/Backend/PdoBackend.php | PdoBackend.findIdentifiersByTag | public function findIdentifiersByTag(string $tag): array
{
$this->connect();
$statementHandle = $this->databaseHandle->prepare('SELECT "identifier" FROM "' . $this->tagsTableName . '" WHERE "context"=? AND "cache"=? AND "tag"=?');
$statementHandle->execute([$this->context(), $this->cacheIdentifier, $tag]);
return $statementHandle->fetchAll(\PDO::FETCH_COLUMN);
} | php | public function findIdentifiersByTag(string $tag): array
{
$this->connect();
$statementHandle = $this->databaseHandle->prepare('SELECT "identifier" FROM "' . $this->tagsTableName . '" WHERE "context"=? AND "cache"=? AND "tag"=?');
$statementHandle->execute([$this->context(), $this->cacheIdentifier, $tag]);
return $statementHandle->fetchAll(\PDO::FETCH_COLUMN);
} | [
"public",
"function",
"findIdentifiersByTag",
"(",
"string",
"$",
"tag",
")",
":",
"array",
"{",
"$",
"this",
"->",
"connect",
"(",
")",
";",
"$",
"statementHandle",
"=",
"$",
"this",
"->",
"databaseHandle",
"->",
"prepare",
"(",
"'SELECT \"identifier\" FROM \... | Finds and returns all cache entry identifiers which are tagged by the
specified tag.
@param string $tag The tag to search for
@return array An array with identifiers of all matching entries. An empty array if no entries matched
@throws Exception
@throws FilesException
@api | [
"Finds",
"and",
"returns",
"all",
"cache",
"entry",
"identifiers",
"which",
"are",
"tagged",
"by",
"the",
"specified",
"tag",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Cache/Classes/Backend/PdoBackend.php#L317-L324 |
neos/flow-development-collection | Neos.Cache/Classes/Backend/PdoBackend.php | PdoBackend.collectGarbage | public function collectGarbage()
{
$this->connect();
$statementHandle = $this->databaseHandle->prepare('DELETE FROM "' . $this->tagsTableName . '" WHERE "context"=? AND "cache"=? AND "identifier" IN (SELECT "identifier" FROM "cache" WHERE "context"=? AND "cache"=? AND "lifetime" > 0 AND "created" + "lifetime" < ' . time() . ')');
$statementHandle->execute([$this->context(), $this->cacheIdentifier, $this->context(), $this->cacheIdentifier]);
$statementHandle = $this->databaseHandle->prepare('DELETE FROM "' . $this->cacheTableName . '" WHERE "context"=? AND "cache"=? AND "lifetime" > 0 AND "created" + "lifetime" < ' . time());
$statementHandle->execute([$this->context(), $this->cacheIdentifier]);
} | php | public function collectGarbage()
{
$this->connect();
$statementHandle = $this->databaseHandle->prepare('DELETE FROM "' . $this->tagsTableName . '" WHERE "context"=? AND "cache"=? AND "identifier" IN (SELECT "identifier" FROM "cache" WHERE "context"=? AND "cache"=? AND "lifetime" > 0 AND "created" + "lifetime" < ' . time() . ')');
$statementHandle->execute([$this->context(), $this->cacheIdentifier, $this->context(), $this->cacheIdentifier]);
$statementHandle = $this->databaseHandle->prepare('DELETE FROM "' . $this->cacheTableName . '" WHERE "context"=? AND "cache"=? AND "lifetime" > 0 AND "created" + "lifetime" < ' . time());
$statementHandle->execute([$this->context(), $this->cacheIdentifier]);
} | [
"public",
"function",
"collectGarbage",
"(",
")",
"{",
"$",
"this",
"->",
"connect",
"(",
")",
";",
"$",
"statementHandle",
"=",
"$",
"this",
"->",
"databaseHandle",
"->",
"prepare",
"(",
"'DELETE FROM \"'",
".",
"$",
"this",
"->",
"tagsTableName",
".",
"'... | Does garbage collection
@return void
@throws Exception
@throws FilesException
@api | [
"Does",
"garbage",
"collection"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Cache/Classes/Backend/PdoBackend.php#L334-L343 |
neos/flow-development-collection | Neos.Cache/Classes/Backend/PdoBackend.php | PdoBackend.connect | protected function connect()
{
if ($this->databaseHandle !== null) {
return;
}
try {
$splitdsn = explode(':', $this->dataSourceName, 2);
$this->pdoDriver = $splitdsn[0];
if ($this->pdoDriver === 'sqlite' && !file_exists($splitdsn[1])) {
if (!file_exists(dirname($splitdsn[1]))) {
Files::createDirectoryRecursively(dirname($splitdsn[1]));
}
$this->databaseHandle = new \PDO($this->dataSourceName, $this->username, $this->password);
$this->createCacheTables();
} else {
$this->databaseHandle = new \PDO($this->dataSourceName, $this->username, $this->password);
}
$this->databaseHandle->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
if ($this->pdoDriver === 'mysql') {
$this->databaseHandle->exec('SET SESSION sql_mode=\'ANSI\';');
}
} catch (\PDOException $exception) {
throw new Exception('Could not connect to cache table with DSN "' . $this->dataSourceName . '". PDO error: ' . $exception->getMessage(), 1334736164);
}
} | php | protected function connect()
{
if ($this->databaseHandle !== null) {
return;
}
try {
$splitdsn = explode(':', $this->dataSourceName, 2);
$this->pdoDriver = $splitdsn[0];
if ($this->pdoDriver === 'sqlite' && !file_exists($splitdsn[1])) {
if (!file_exists(dirname($splitdsn[1]))) {
Files::createDirectoryRecursively(dirname($splitdsn[1]));
}
$this->databaseHandle = new \PDO($this->dataSourceName, $this->username, $this->password);
$this->createCacheTables();
} else {
$this->databaseHandle = new \PDO($this->dataSourceName, $this->username, $this->password);
}
$this->databaseHandle->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
if ($this->pdoDriver === 'mysql') {
$this->databaseHandle->exec('SET SESSION sql_mode=\'ANSI\';');
}
} catch (\PDOException $exception) {
throw new Exception('Could not connect to cache table with DSN "' . $this->dataSourceName . '". PDO error: ' . $exception->getMessage(), 1334736164);
}
} | [
"protected",
"function",
"connect",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"databaseHandle",
"!==",
"null",
")",
"{",
"return",
";",
"}",
"try",
"{",
"$",
"splitdsn",
"=",
"explode",
"(",
"':'",
",",
"$",
"this",
"->",
"dataSourceName",
",",
"2... | Connect to the database
@return void
@throws Exception if the connection cannot be established
@throws FilesException | [
"Connect",
"to",
"the",
"database"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Cache/Classes/Backend/PdoBackend.php#L362-L388 |
neos/flow-development-collection | Neos.Cache/Classes/Backend/PdoBackend.php | PdoBackend.createCacheTables | protected function createCacheTables()
{
$this->connect();
try {
PdoHelper::importSql($this->databaseHandle, $this->pdoDriver, __DIR__ . '/../../Resources/Private/DDL.sql');
} catch (\PDOException $exception) {
throw new Exception('Could not create cache tables with DSN "' . $this->dataSourceName . '". PDO error: ' . $exception->getMessage(), 1259576985);
}
} | php | protected function createCacheTables()
{
$this->connect();
try {
PdoHelper::importSql($this->databaseHandle, $this->pdoDriver, __DIR__ . '/../../Resources/Private/DDL.sql');
} catch (\PDOException $exception) {
throw new Exception('Could not create cache tables with DSN "' . $this->dataSourceName . '". PDO error: ' . $exception->getMessage(), 1259576985);
}
} | [
"protected",
"function",
"createCacheTables",
"(",
")",
"{",
"$",
"this",
"->",
"connect",
"(",
")",
";",
"try",
"{",
"PdoHelper",
"::",
"importSql",
"(",
"$",
"this",
"->",
"databaseHandle",
",",
"$",
"this",
"->",
"pdoDriver",
",",
"__DIR__",
".",
"'/.... | Creates the tables needed for the cache backend.
@return void
@throws Exception if something goes wrong
@throws FilesException | [
"Creates",
"the",
"tables",
"needed",
"for",
"the",
"cache",
"backend",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Cache/Classes/Backend/PdoBackend.php#L397-L405 |
neos/flow-development-collection | Neos.Cache/Classes/Backend/PdoBackend.php | PdoBackend.key | public function key(): string
{
if ($this->cacheEntriesIterator === null) {
$this->rewind();
}
return $this->cacheEntriesIterator->key();
} | php | public function key(): string
{
if ($this->cacheEntriesIterator === null) {
$this->rewind();
}
return $this->cacheEntriesIterator->key();
} | [
"public",
"function",
"key",
"(",
")",
":",
"string",
"{",
"if",
"(",
"$",
"this",
"->",
"cacheEntriesIterator",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"rewind",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"cacheEntriesIterator",
"->",
"key",... | Returns the identifier of the current cache entry pointed to by the cache
entry iterator.
@return string
@api | [
"Returns",
"the",
"identifier",
"of",
"the",
"current",
"cache",
"entry",
"pointed",
"to",
"by",
"the",
"cache",
"entry",
"iterator",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Cache/Classes/Backend/PdoBackend.php#L443-L449 |
neos/flow-development-collection | Neos.Cache/Classes/Backend/PdoBackend.php | PdoBackend.valid | public function valid(): bool
{
if ($this->cacheEntriesIterator === null) {
$this->rewind();
}
return $this->cacheEntriesIterator->valid();
} | php | public function valid(): bool
{
if ($this->cacheEntriesIterator === null) {
$this->rewind();
}
return $this->cacheEntriesIterator->valid();
} | [
"public",
"function",
"valid",
"(",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"this",
"->",
"cacheEntriesIterator",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"rewind",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"cacheEntriesIterator",
"->",
"valid... | Checks if the current position of the cache entry iterator is valid.
@return boolean true if the current position is valid, otherwise false
@api | [
"Checks",
"if",
"the",
"current",
"position",
"of",
"the",
"cache",
"entry",
"iterator",
"is",
"valid",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Cache/Classes/Backend/PdoBackend.php#L457-L463 |
neos/flow-development-collection | Neos.Cache/Classes/Backend/PdoBackend.php | PdoBackend.rewind | public function rewind()
{
if ($this->cacheEntriesIterator !== null) {
$this->cacheEntriesIterator->rewind();
return;
}
$cacheEntries = [];
$statementHandle = $this->databaseHandle->prepare('SELECT "identifier", "content" FROM "' . $this->cacheTableName . '" WHERE "context"=? AND "cache"=?' . $this->getNotExpiredStatement());
$statementHandle->execute([$this->context(), $this->cacheIdentifier]);
$fetchedColumns = $statementHandle->fetchAll();
foreach ($fetchedColumns as $fetchedColumn) {
// Convert hexadecimal data into binary string,
// because it is not allowed to store null bytes in PostgreSQL.
if ($this->pdoDriver === 'pgsql') {
$fetchedColumn['content'] = hex2bin($fetchedColumn['content']);
}
$cacheEntries[$fetchedColumn['identifier']] = $fetchedColumn['content'];
}
$this->cacheEntriesIterator = new \ArrayIterator($cacheEntries);
} | php | public function rewind()
{
if ($this->cacheEntriesIterator !== null) {
$this->cacheEntriesIterator->rewind();
return;
}
$cacheEntries = [];
$statementHandle = $this->databaseHandle->prepare('SELECT "identifier", "content" FROM "' . $this->cacheTableName . '" WHERE "context"=? AND "cache"=?' . $this->getNotExpiredStatement());
$statementHandle->execute([$this->context(), $this->cacheIdentifier]);
$fetchedColumns = $statementHandle->fetchAll();
foreach ($fetchedColumns as $fetchedColumn) {
// Convert hexadecimal data into binary string,
// because it is not allowed to store null bytes in PostgreSQL.
if ($this->pdoDriver === 'pgsql') {
$fetchedColumn['content'] = hex2bin($fetchedColumn['content']);
}
$cacheEntries[$fetchedColumn['identifier']] = $fetchedColumn['content'];
}
$this->cacheEntriesIterator = new \ArrayIterator($cacheEntries);
} | [
"public",
"function",
"rewind",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"cacheEntriesIterator",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"cacheEntriesIterator",
"->",
"rewind",
"(",
")",
";",
"return",
";",
"}",
"$",
"cacheEntries",
"=",
"[",
"... | Rewinds the cache entry iterator to the first element
and fetches cacheEntries.
@return void
@api | [
"Rewinds",
"the",
"cache",
"entry",
"iterator",
"to",
"the",
"first",
"element",
"and",
"fetches",
"cacheEntries",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Cache/Classes/Backend/PdoBackend.php#L472-L496 |
neos/flow-development-collection | Neos.Cache/Classes/Backend/PdoBackend.php | PdoBackend.setup | public function setup(): Result
{
$result = new Result();
try {
$this->connect();
$connection = DriverManager::getConnection(['pdo' => $this->databaseHandle]);
} catch (Exception | FilesException |DBALException $exception) {
$result->addError(new Error($exception->getMessage(), $exception->getCode(), [], 'Connection failed'));
return $result;
}
try {
$tablesExist = $connection->getSchemaManager()->tablesExist([$this->cacheTableName, $this->tagsTableName]);
} /** @noinspection PhpRedundantCatchClauseInspection */ catch (DBALException $exception) {
$result->addError(new Error($exception->getMessage(), $exception->getCode(), [], 'Connection failed'));
return $result;
}
if ($tablesExist) {
$result->addNotice(new Notice('Tables "%s" and "%s" (already exists)', null, [$this->cacheTableName, $this->tagsTableName]));
} else {
$result->addNotice(new Notice('Creating database tables "%s" & "%s"...', null, [$this->cacheTableName, $this->tagsTableName]));
}
$fromSchema = $connection->getSchemaManager()->createSchema();
$schemaDiff = (new Comparator())->compare($fromSchema, $this->getCacheTablesSchema());
try {
$statements = $schemaDiff->toSaveSql($connection->getDatabasePlatform());
} catch (DBALException $exception) {
$result->addError(new Error($exception->getMessage(), $exception->getCode(), [], 'Connection failed'));
return $result;
}
if ($statements === []) {
$result->addNotice(new Notice('Table schema is up to date, no migration required'));
return $result;
}
$connection->beginTransaction();
try {
foreach ($statements as $statement) {
$result->addNotice(new Notice('<info>++</info> %s', null, [$statement]));
$connection->exec($statement);
}
$connection->commit();
} catch (\Exception $exception) {
try {
$connection->rollBack();
} catch (\Exception $exception) {
}
$result->addError(new Error('Exception while trying to setup PdoBackend: %s', $exception->getCode(), [$exception->getMessage()]));
}
return $result;
} | php | public function setup(): Result
{
$result = new Result();
try {
$this->connect();
$connection = DriverManager::getConnection(['pdo' => $this->databaseHandle]);
} catch (Exception | FilesException |DBALException $exception) {
$result->addError(new Error($exception->getMessage(), $exception->getCode(), [], 'Connection failed'));
return $result;
}
try {
$tablesExist = $connection->getSchemaManager()->tablesExist([$this->cacheTableName, $this->tagsTableName]);
} /** @noinspection PhpRedundantCatchClauseInspection */ catch (DBALException $exception) {
$result->addError(new Error($exception->getMessage(), $exception->getCode(), [], 'Connection failed'));
return $result;
}
if ($tablesExist) {
$result->addNotice(new Notice('Tables "%s" and "%s" (already exists)', null, [$this->cacheTableName, $this->tagsTableName]));
} else {
$result->addNotice(new Notice('Creating database tables "%s" & "%s"...', null, [$this->cacheTableName, $this->tagsTableName]));
}
$fromSchema = $connection->getSchemaManager()->createSchema();
$schemaDiff = (new Comparator())->compare($fromSchema, $this->getCacheTablesSchema());
try {
$statements = $schemaDiff->toSaveSql($connection->getDatabasePlatform());
} catch (DBALException $exception) {
$result->addError(new Error($exception->getMessage(), $exception->getCode(), [], 'Connection failed'));
return $result;
}
if ($statements === []) {
$result->addNotice(new Notice('Table schema is up to date, no migration required'));
return $result;
}
$connection->beginTransaction();
try {
foreach ($statements as $statement) {
$result->addNotice(new Notice('<info>++</info> %s', null, [$statement]));
$connection->exec($statement);
}
$connection->commit();
} catch (\Exception $exception) {
try {
$connection->rollBack();
} catch (\Exception $exception) {
}
$result->addError(new Error('Exception while trying to setup PdoBackend: %s', $exception->getCode(), [$exception->getMessage()]));
}
return $result;
} | [
"public",
"function",
"setup",
"(",
")",
":",
"Result",
"{",
"$",
"result",
"=",
"new",
"Result",
"(",
")",
";",
"try",
"{",
"$",
"this",
"->",
"connect",
"(",
")",
";",
"$",
"connection",
"=",
"DriverManager",
"::",
"getConnection",
"(",
"[",
"'pdo'... | Connects to the configured PDO database and adds/updates table schema if required
@return Result
@api | [
"Connects",
"to",
"the",
"configured",
"PDO",
"database",
"and",
"adds",
"/",
"updates",
"table",
"schema",
"if",
"required"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Cache/Classes/Backend/PdoBackend.php#L515-L566 |
neos/flow-development-collection | Neos.Cache/Classes/Backend/PdoBackend.php | PdoBackend.getStatus | public function getStatus(): Result
{
$result = new Result();
try {
$this->connect();
$connection = DriverManager::getConnection(['pdo' => $this->databaseHandle]);
} catch (\Exception $exception) {
$result->addError(new Error($exception->getMessage(), $exception->getCode(), [], 'Connection failed'));
return $result;
}
try {
$cacheTableExists = $connection->getSchemaManager()->tablesExist([$this->cacheTableName]);
$tagsTableExists = $connection->getSchemaManager()->tablesExist([$this->tagsTableName]);
} /** @noinspection PhpRedundantCatchClauseInspection */ catch (DBALException $exception) {
$result->addError(new Error($exception->getMessage(), $exception->getCode(), [], 'Connection failed'));
return $result;
}
$result->addNotice(new Notice((string)$connection->getDatabase(), null, [], 'Database'));
$result->addNotice(new Notice((string)$connection->getDriver()->getName(), null, [], 'Driver'));
if (!$cacheTableExists) {
$result->addError(new Error('%s (missing)', null, [$this->cacheTableName], 'Table'));
}
if (!$tagsTableExists) {
$result->addError(new Error('%s (missing)', null, [$this->tagsTableName], 'Table'));
}
if (!$cacheTableExists || !$tagsTableExists) {
return $result;
}
$fromSchema = $connection->getSchemaManager()->createSchema();
$schemaDiff = (new Comparator())->compare($fromSchema, $this->getCacheTablesSchema());
try {
$statements = $schemaDiff->toSaveSql($connection->getDatabasePlatform());
} catch (DBALException $exception) {
$result->addError(new Error($exception->getMessage(), $exception->getCode(), [], 'Connection failed'));
return $result;
}
if ($statements !== []) {
$result->addError(new Error('The schema of the cache tables is not up-to-date', null, [], 'Table schema'));
foreach ($statements as $statement) {
$result->addWarning(new Warning($statement, null, [], 'Required statement'));
}
}
return $result;
} | php | public function getStatus(): Result
{
$result = new Result();
try {
$this->connect();
$connection = DriverManager::getConnection(['pdo' => $this->databaseHandle]);
} catch (\Exception $exception) {
$result->addError(new Error($exception->getMessage(), $exception->getCode(), [], 'Connection failed'));
return $result;
}
try {
$cacheTableExists = $connection->getSchemaManager()->tablesExist([$this->cacheTableName]);
$tagsTableExists = $connection->getSchemaManager()->tablesExist([$this->tagsTableName]);
} /** @noinspection PhpRedundantCatchClauseInspection */ catch (DBALException $exception) {
$result->addError(new Error($exception->getMessage(), $exception->getCode(), [], 'Connection failed'));
return $result;
}
$result->addNotice(new Notice((string)$connection->getDatabase(), null, [], 'Database'));
$result->addNotice(new Notice((string)$connection->getDriver()->getName(), null, [], 'Driver'));
if (!$cacheTableExists) {
$result->addError(new Error('%s (missing)', null, [$this->cacheTableName], 'Table'));
}
if (!$tagsTableExists) {
$result->addError(new Error('%s (missing)', null, [$this->tagsTableName], 'Table'));
}
if (!$cacheTableExists || !$tagsTableExists) {
return $result;
}
$fromSchema = $connection->getSchemaManager()->createSchema();
$schemaDiff = (new Comparator())->compare($fromSchema, $this->getCacheTablesSchema());
try {
$statements = $schemaDiff->toSaveSql($connection->getDatabasePlatform());
} catch (DBALException $exception) {
$result->addError(new Error($exception->getMessage(), $exception->getCode(), [], 'Connection failed'));
return $result;
}
if ($statements !== []) {
$result->addError(new Error('The schema of the cache tables is not up-to-date', null, [], 'Table schema'));
foreach ($statements as $statement) {
$result->addWarning(new Warning($statement, null, [], 'Required statement'));
}
}
return $result;
} | [
"public",
"function",
"getStatus",
"(",
")",
":",
"Result",
"{",
"$",
"result",
"=",
"new",
"Result",
"(",
")",
";",
"try",
"{",
"$",
"this",
"->",
"connect",
"(",
")",
";",
"$",
"connection",
"=",
"DriverManager",
"::",
"getConnection",
"(",
"[",
"'... | Validates that configured database is accessible and schema up to date
@return Result
@api | [
"Validates",
"that",
"configured",
"database",
"is",
"accessible",
"and",
"schema",
"up",
"to",
"date"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Cache/Classes/Backend/PdoBackend.php#L574-L618 |
neos/flow-development-collection | Neos.Cache/Classes/Backend/PdoBackend.php | PdoBackend.getCacheTablesSchema | private function getCacheTablesSchema(): Schema
{
$schema = new Schema();
$cacheTable = $schema->createTable($this->cacheTableName);
$cacheTable->addColumn('identifier', Type::STRING, ['length' => 250]);
$cacheTable->addColumn('cache', Type::STRING, ['length' => 250]);
$cacheTable->addColumn('context', Type::STRING, ['length' => 150]);
$cacheTable->addColumn('created', Type::INTEGER, ['unsigned' => true, 'default' => 0]);
$cacheTable->addColumn('lifetime', Type::INTEGER, ['unsigned' => true, 'default' => 0]);
$cacheTable->addColumn('content', Type::TEXT);
$cacheTable->setPrimaryKey(['identifier', 'cache', 'context']);
$tagsTable = $schema->createTable($this->tagsTableName);
$tagsTable->addColumn('identifier', Type::STRING, ['length' => 255]);
$tagsTable->addColumn('cache', Type::STRING, ['length' => 250]);
$tagsTable->addColumn('context', Type::STRING, ['length' => 150]);
$tagsTable->addColumn('tag', Type::STRING, ['length' => 255]);
$tagsTable->addIndex(['identifier', 'cache', 'context'], 'identifier');
$tagsTable->addIndex(['tag'], 'tag');
return $schema;
} | php | private function getCacheTablesSchema(): Schema
{
$schema = new Schema();
$cacheTable = $schema->createTable($this->cacheTableName);
$cacheTable->addColumn('identifier', Type::STRING, ['length' => 250]);
$cacheTable->addColumn('cache', Type::STRING, ['length' => 250]);
$cacheTable->addColumn('context', Type::STRING, ['length' => 150]);
$cacheTable->addColumn('created', Type::INTEGER, ['unsigned' => true, 'default' => 0]);
$cacheTable->addColumn('lifetime', Type::INTEGER, ['unsigned' => true, 'default' => 0]);
$cacheTable->addColumn('content', Type::TEXT);
$cacheTable->setPrimaryKey(['identifier', 'cache', 'context']);
$tagsTable = $schema->createTable($this->tagsTableName);
$tagsTable->addColumn('identifier', Type::STRING, ['length' => 255]);
$tagsTable->addColumn('cache', Type::STRING, ['length' => 250]);
$tagsTable->addColumn('context', Type::STRING, ['length' => 150]);
$tagsTable->addColumn('tag', Type::STRING, ['length' => 255]);
$tagsTable->addIndex(['identifier', 'cache', 'context'], 'identifier');
$tagsTable->addIndex(['tag'], 'tag');
return $schema;
} | [
"private",
"function",
"getCacheTablesSchema",
"(",
")",
":",
"Schema",
"{",
"$",
"schema",
"=",
"new",
"Schema",
"(",
")",
";",
"$",
"cacheTable",
"=",
"$",
"schema",
"->",
"createTable",
"(",
"$",
"this",
"->",
"cacheTableName",
")",
";",
"$",
"cacheTa... | Returns the Doctrine DBAL schema of the configured cache and tag tables
@return Schema | [
"Returns",
"the",
"Doctrine",
"DBAL",
"schema",
"of",
"the",
"configured",
"cache",
"and",
"tag",
"tables"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Cache/Classes/Backend/PdoBackend.php#L625-L650 |
neos/flow-development-collection | Neos.Flow/Classes/Http/ContentStream.php | ContentStream.fromContents | public static function fromContents(string $contents): self
{
$handle = fopen('php://memory', 'r+');
fwrite($handle, $contents);
rewind($handle);
return new static($handle);
} | php | public static function fromContents(string $contents): self
{
$handle = fopen('php://memory', 'r+');
fwrite($handle, $contents);
rewind($handle);
return new static($handle);
} | [
"public",
"static",
"function",
"fromContents",
"(",
"string",
"$",
"contents",
")",
":",
"self",
"{",
"$",
"handle",
"=",
"fopen",
"(",
"'php://memory'",
",",
"'r+'",
")",
";",
"fwrite",
"(",
"$",
"handle",
",",
"$",
"contents",
")",
";",
"rewind",
"(... | Creates an instance representing the given $contents string
@param string $contents
@return self | [
"Creates",
"an",
"instance",
"representing",
"the",
"given",
"$contents",
"string"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Http/ContentStream.php#L58-L64 |
neos/flow-development-collection | Neos.Flow/Classes/Http/ContentStream.php | ContentStream.replace | public function replace($stream, $mode = 'r')
{
$this->close();
if (!is_resource($stream)) {
$stream = @fopen($stream, $mode);
}
if (!$this->isValidResource($stream)) {
throw new \InvalidArgumentException('Invalid stream provided; must be a string or stream resource', 1453891861);
}
$this->resource = $stream;
} | php | public function replace($stream, $mode = 'r')
{
$this->close();
if (!is_resource($stream)) {
$stream = @fopen($stream, $mode);
}
if (!$this->isValidResource($stream)) {
throw new \InvalidArgumentException('Invalid stream provided; must be a string or stream resource', 1453891861);
}
$this->resource = $stream;
} | [
"public",
"function",
"replace",
"(",
"$",
"stream",
",",
"$",
"mode",
"=",
"'r'",
")",
"{",
"$",
"this",
"->",
"close",
"(",
")",
";",
"if",
"(",
"!",
"is_resource",
"(",
"$",
"stream",
")",
")",
"{",
"$",
"stream",
"=",
"@",
"fopen",
"(",
"$"... | Attach a new stream/resource to the instance.
@param string|resource $stream
@param string $mode | [
"Attach",
"a",
"new",
"stream",
"/",
"resource",
"to",
"the",
"instance",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Http/ContentStream.php#L102-L114 |
neos/flow-development-collection | Neos.Flow/Classes/Http/ContentStream.php | ContentStream.isSeekable | public function isSeekable()
{
if (!$this->isValidResource($this->resource)) {
return false;
}
$meta = stream_get_meta_data($this->resource);
return $meta['seekable'];
} | php | public function isSeekable()
{
if (!$this->isValidResource($this->resource)) {
return false;
}
$meta = stream_get_meta_data($this->resource);
return $meta['seekable'];
} | [
"public",
"function",
"isSeekable",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isValidResource",
"(",
"$",
"this",
"->",
"resource",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"meta",
"=",
"stream_get_meta_data",
"(",
"$",
"this",
"->",
... | Returns whether or not the stream is seekable.
@return bool | [
"Returns",
"whether",
"or",
"not",
"the",
"stream",
"is",
"seekable",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Http/ContentStream.php#L169-L178 |
neos/flow-development-collection | Neos.Flow/Classes/Http/ContentStream.php | ContentStream.isWritable | public function isWritable()
{
if (!$this->isValidResource($this->resource)) {
return false;
}
$meta = stream_get_meta_data($this->resource);
$mode = $meta['mode'];
return (
strstr($mode, 'x')
|| strstr($mode, 'w')
|| strstr($mode, 'c')
|| strstr($mode, 'a')
|| strstr($mode, '+')
);
} | php | public function isWritable()
{
if (!$this->isValidResource($this->resource)) {
return false;
}
$meta = stream_get_meta_data($this->resource);
$mode = $meta['mode'];
return (
strstr($mode, 'x')
|| strstr($mode, 'w')
|| strstr($mode, 'c')
|| strstr($mode, 'a')
|| strstr($mode, '+')
);
} | [
"public",
"function",
"isWritable",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isValidResource",
"(",
"$",
"this",
"->",
"resource",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"meta",
"=",
"stream_get_meta_data",
"(",
"$",
"this",
"->",
... | Returns whether or not the stream is writable.
@return bool | [
"Returns",
"whether",
"or",
"not",
"the",
"stream",
"is",
"writable",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Http/ContentStream.php#L230-L246 |
neos/flow-development-collection | Neos.Flow/Classes/Http/ContentStream.php | ContentStream.read | public function read($length)
{
$this->ensureResourceReadable();
$result = fread($this->resource, $length);
if ($result === false) {
throw new \RuntimeException('Error reading stream', 1453892260);
}
return $result;
} | php | public function read($length)
{
$this->ensureResourceReadable();
$result = fread($this->resource, $length);
if ($result === false) {
throw new \RuntimeException('Error reading stream', 1453892260);
}
return $result;
} | [
"public",
"function",
"read",
"(",
"$",
"length",
")",
"{",
"$",
"this",
"->",
"ensureResourceReadable",
"(",
")",
";",
"$",
"result",
"=",
"fread",
"(",
"$",
"this",
"->",
"resource",
",",
"$",
"length",
")",
";",
"if",
"(",
"$",
"result",
"===",
... | Read data from the stream.
@param int $length Read up to $length bytes from the object and return
them. Fewer than $length bytes may be returned if underlying stream
call returns fewer bytes.
@return string Returns the data read from the stream, or an empty string
if no bytes are available.
@throws \RuntimeException if an error occurs. | [
"Read",
"data",
"from",
"the",
"stream",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Http/ContentStream.php#L297-L308 |
neos/flow-development-collection | Neos.Flow/Classes/Http/ContentStream.php | ContentStream.getContents | public function getContents()
{
$this->ensureResourceReadable();
$result = stream_get_contents($this->resource);
if ($result === false) {
throw new \RuntimeException('Error reading from stream', 1453892266);
}
return $result;
} | php | public function getContents()
{
$this->ensureResourceReadable();
$result = stream_get_contents($this->resource);
if ($result === false) {
throw new \RuntimeException('Error reading from stream', 1453892266);
}
return $result;
} | [
"public",
"function",
"getContents",
"(",
")",
"{",
"$",
"this",
"->",
"ensureResourceReadable",
"(",
")",
";",
"$",
"result",
"=",
"stream_get_contents",
"(",
"$",
"this",
"->",
"resource",
")",
";",
"if",
"(",
"$",
"result",
"===",
"false",
")",
"{",
... | Returns the remaining contents in a string
@return string
@throws \RuntimeException if unable to read or an error occurs while
reading. | [
"Returns",
"the",
"remaining",
"contents",
"in",
"a",
"string"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Http/ContentStream.php#L317-L327 |
neos/flow-development-collection | Neos.Utility.ObjectHandling/Classes/TypeHandling.php | TypeHandling.parseType | public static function parseType(string $type): array
{
$matches = [];
if (preg_match(self::PARSE_TYPE_PATTERN, $type, $matches) === 0) {
throw new InvalidTypeException('Found an invalid element type declaration in %s. A type "' . var_export($type, true) . '" does not exist.', 1264093630);
}
$type = self::normalizeType($matches['type']);
$elementType = isset($matches['elementType']) ? self::normalizeType($matches['elementType']) : null;
if ($elementType !== null && !self::isCollectionType($type)) {
throw new InvalidTypeException('Found an invalid element type declaration in %s. Type "' . $type . '" must not have an element type hint (' . $elementType . ').', 1264093642);
}
return [
'type' => $type,
'elementType' => $elementType
];
} | php | public static function parseType(string $type): array
{
$matches = [];
if (preg_match(self::PARSE_TYPE_PATTERN, $type, $matches) === 0) {
throw new InvalidTypeException('Found an invalid element type declaration in %s. A type "' . var_export($type, true) . '" does not exist.', 1264093630);
}
$type = self::normalizeType($matches['type']);
$elementType = isset($matches['elementType']) ? self::normalizeType($matches['elementType']) : null;
if ($elementType !== null && !self::isCollectionType($type)) {
throw new InvalidTypeException('Found an invalid element type declaration in %s. Type "' . $type . '" must not have an element type hint (' . $elementType . ').', 1264093642);
}
return [
'type' => $type,
'elementType' => $elementType
];
} | [
"public",
"static",
"function",
"parseType",
"(",
"string",
"$",
"type",
")",
":",
"array",
"{",
"$",
"matches",
"=",
"[",
"]",
";",
"if",
"(",
"preg_match",
"(",
"self",
"::",
"PARSE_TYPE_PATTERN",
",",
"$",
"type",
",",
"$",
"matches",
")",
"===",
... | Returns an array with type information, including element type for
collection types (array, SplObjectStorage, ...)
@param string $type Type of the property (see PARSE_TYPE_PATTERN)
@return array An array with information about the type
@throws InvalidTypeException | [
"Returns",
"an",
"array",
"with",
"type",
"information",
"including",
"element",
"type",
"for",
"collection",
"types",
"(",
"array",
"SplObjectStorage",
"...",
")"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Utility.ObjectHandling/Classes/TypeHandling.php#L47-L65 |
neos/flow-development-collection | Neos.Utility.ObjectHandling/Classes/TypeHandling.php | TypeHandling.isCollectionType | public static function isCollectionType(string $type): bool
{
if (in_array($type, self::$collectionTypes, true)) {
return true;
}
if (class_exists($type) === true || interface_exists($type) === true) {
foreach (self::$collectionTypes as $collectionType) {
if (is_subclass_of($type, $collectionType) === true) {
return true;
}
}
}
return false;
} | php | public static function isCollectionType(string $type): bool
{
if (in_array($type, self::$collectionTypes, true)) {
return true;
}
if (class_exists($type) === true || interface_exists($type) === true) {
foreach (self::$collectionTypes as $collectionType) {
if (is_subclass_of($type, $collectionType) === true) {
return true;
}
}
}
return false;
} | [
"public",
"static",
"function",
"isCollectionType",
"(",
"string",
"$",
"type",
")",
":",
"bool",
"{",
"if",
"(",
"in_array",
"(",
"$",
"type",
",",
"self",
"::",
"$",
"collectionTypes",
",",
"true",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"... | Returns true if the $type is a collection type.
@param string $type
@return boolean | [
"Returns",
"true",
"if",
"the",
"$type",
"is",
"a",
"collection",
"type",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Utility.ObjectHandling/Classes/TypeHandling.php#L120-L135 |
neos/flow-development-collection | Neos.Utility.ObjectHandling/Classes/TypeHandling.php | TypeHandling.truncateElementType | public static function truncateElementType(string $type): string
{
if (strpos($type, '<') === false) {
return $type;
}
return substr($type, 0, strpos($type, '<'));
} | php | public static function truncateElementType(string $type): string
{
if (strpos($type, '<') === false) {
return $type;
}
return substr($type, 0, strpos($type, '<'));
} | [
"public",
"static",
"function",
"truncateElementType",
"(",
"string",
"$",
"type",
")",
":",
"string",
"{",
"if",
"(",
"strpos",
"(",
"$",
"type",
",",
"'<'",
")",
"===",
"false",
")",
"{",
"return",
"$",
"type",
";",
"}",
"return",
"substr",
"(",
"$... | Parses a composite type like "\Foo\Collection<\Bar\Entity>" into "\Foo\Collection"
Note: If the given type does not specify an element type it is not changed
@param string $type
@return string The original type without its element type (if any) | [
"Parses",
"a",
"composite",
"type",
"like",
"\\",
"Foo",
"\\",
"Collection<",
"\\",
"Bar",
"\\",
"Entity",
">",
"into",
"\\",
"Foo",
"\\",
"Collection",
"Note",
":",
"If",
"the",
"given",
"type",
"does",
"not",
"specify",
"an",
"element",
"type",
"it",
... | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Utility.ObjectHandling/Classes/TypeHandling.php#L144-L150 |
neos/flow-development-collection | Neos.Utility.ObjectHandling/Classes/TypeHandling.php | TypeHandling.getTypeForValue | public static function getTypeForValue($value): string
{
if (is_object($value)) {
if ($value instanceof Proxy) {
$type = get_parent_class($value);
} else {
$type = get_class($value);
}
} else {
$type = gettype($value);
}
return $type;
} | php | public static function getTypeForValue($value): string
{
if (is_object($value)) {
if ($value instanceof Proxy) {
$type = get_parent_class($value);
} else {
$type = get_class($value);
}
} else {
$type = gettype($value);
}
return $type;
} | [
"public",
"static",
"function",
"getTypeForValue",
"(",
"$",
"value",
")",
":",
"string",
"{",
"if",
"(",
"is_object",
"(",
"$",
"value",
")",
")",
"{",
"if",
"(",
"$",
"value",
"instanceof",
"Proxy",
")",
"{",
"$",
"type",
"=",
"get_parent_class",
"("... | Return simple type or class for object
@param mixed $value
@return string | [
"Return",
"simple",
"type",
"or",
"class",
"for",
"object"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Utility.ObjectHandling/Classes/TypeHandling.php#L170-L182 |
neos/flow-development-collection | Neos.Flow/Classes/Security/Authentication/TokenAndProviderFactory.php | TokenAndProviderFactory.buildProvidersAndTokensFromConfiguration | protected function buildProvidersAndTokensFromConfiguration()
{
if ($this->isInitialized) {
return;
}
$this->tokens = [];
$this->providers = [];
foreach ($this->providerConfigurations as $providerName => $providerConfiguration) {
if (!is_array($providerConfiguration) || !isset($providerConfiguration['provider'])) {
throw new Exception\InvalidAuthenticationProviderException('The configured authentication provider "' . $providerName . '" needs a "provider" option!', 1248209521);
}
$providerObjectName = $this->providerResolver->resolveProviderClass((string)$providerConfiguration['provider']);
if ($providerObjectName === null) {
throw new Exception\InvalidAuthenticationProviderException('The configured authentication provider "' . $providerConfiguration['provider'] . '" could not be found!', 1237330453);
}
$providerOptions = [];
if (isset($providerConfiguration['providerOptions']) && is_array($providerConfiguration['providerOptions'])) {
$providerOptions = $providerConfiguration['providerOptions'];
}
/** @var $providerInstance AuthenticationProviderInterface */
$providerInstance = $providerObjectName::create($providerName, $providerOptions);
$this->providers[$providerName] = $providerInstance;
/** @var $tokenInstance TokenInterface */
$tokenInstance = null;
foreach ($providerInstance->getTokenClassNames() as $tokenClassName) {
if (isset($providerConfiguration['token']) && $providerConfiguration['token'] !== $tokenClassName) {
continue;
}
$tokenInstance = new $tokenClassName();
$tokenInstance->setAuthenticationProviderName($providerName);
$this->tokens[] = $tokenInstance;
break;
}
if (isset($providerConfiguration['requestPatterns']) && is_array($providerConfiguration['requestPatterns'])) {
$requestPatterns = [];
foreach ($providerConfiguration['requestPatterns'] as $patternName => $patternConfiguration) {
// skip request patterns that are set to NULL (i.e. `somePattern: ~` in a YAML file)
if ($patternConfiguration === null) {
continue;
}
$patternType = $patternConfiguration['pattern'];
$patternOptions = isset($patternConfiguration['patternOptions']) ? $patternConfiguration['patternOptions'] : [];
$patternClassName = $this->requestPatternResolver->resolveRequestPatternClass($patternType);
$requestPattern = new $patternClassName($patternOptions);
if (!$requestPattern instanceof RequestPatternInterface) {
throw new Exception\InvalidRequestPatternException(sprintf('Invalid request pattern configuration in setting "Neos:Flow:security:authentication:providers:%s": Class "%s" does not implement RequestPatternInterface', $providerName, $patternClassName), 1446222774);
}
$requestPatterns[] = $requestPattern;
}
if ($tokenInstance !== null) {
$tokenInstance->setRequestPatterns($requestPatterns);
}
}
if (isset($providerConfiguration['entryPoint'])) {
if (is_array($providerConfiguration['entryPoint'])) {
$message = 'Invalid entry point configuration in setting "Neos:Flow:security:authentication:providers:' . $providerName . '. Check your settings and make sure to specify only one entry point for each provider.';
throw new Exception\InvalidAuthenticationProviderException($message, 1327671458);
}
$entryPointName = $providerConfiguration['entryPoint'];
$entryPointClassName = $entryPointName;
if (!class_exists($entryPointClassName)) {
$entryPointClassName = 'Neos\Flow\Security\Authentication\EntryPoint\\' . $entryPointClassName;
}
if (!class_exists($entryPointClassName)) {
throw new Exception\NoEntryPointFoundException('An entry point with the name: "' . $entryPointName . '" could not be resolved. Make sure it is a valid class name, either fully qualified or relative to Neos\Flow\Security\Authentication\EntryPoint!', 1236767282);
}
/** @var $entryPoint EntryPointInterface */
$entryPoint = new $entryPointClassName();
if (isset($providerConfiguration['entryPointOptions'])) {
$entryPoint->setOptions($providerConfiguration['entryPointOptions']);
}
$tokenInstance->setAuthenticationEntryPoint($entryPoint);
}
}
$this->isInitialized = true;
} | php | protected function buildProvidersAndTokensFromConfiguration()
{
if ($this->isInitialized) {
return;
}
$this->tokens = [];
$this->providers = [];
foreach ($this->providerConfigurations as $providerName => $providerConfiguration) {
if (!is_array($providerConfiguration) || !isset($providerConfiguration['provider'])) {
throw new Exception\InvalidAuthenticationProviderException('The configured authentication provider "' . $providerName . '" needs a "provider" option!', 1248209521);
}
$providerObjectName = $this->providerResolver->resolveProviderClass((string)$providerConfiguration['provider']);
if ($providerObjectName === null) {
throw new Exception\InvalidAuthenticationProviderException('The configured authentication provider "' . $providerConfiguration['provider'] . '" could not be found!', 1237330453);
}
$providerOptions = [];
if (isset($providerConfiguration['providerOptions']) && is_array($providerConfiguration['providerOptions'])) {
$providerOptions = $providerConfiguration['providerOptions'];
}
/** @var $providerInstance AuthenticationProviderInterface */
$providerInstance = $providerObjectName::create($providerName, $providerOptions);
$this->providers[$providerName] = $providerInstance;
/** @var $tokenInstance TokenInterface */
$tokenInstance = null;
foreach ($providerInstance->getTokenClassNames() as $tokenClassName) {
if (isset($providerConfiguration['token']) && $providerConfiguration['token'] !== $tokenClassName) {
continue;
}
$tokenInstance = new $tokenClassName();
$tokenInstance->setAuthenticationProviderName($providerName);
$this->tokens[] = $tokenInstance;
break;
}
if (isset($providerConfiguration['requestPatterns']) && is_array($providerConfiguration['requestPatterns'])) {
$requestPatterns = [];
foreach ($providerConfiguration['requestPatterns'] as $patternName => $patternConfiguration) {
// skip request patterns that are set to NULL (i.e. `somePattern: ~` in a YAML file)
if ($patternConfiguration === null) {
continue;
}
$patternType = $patternConfiguration['pattern'];
$patternOptions = isset($patternConfiguration['patternOptions']) ? $patternConfiguration['patternOptions'] : [];
$patternClassName = $this->requestPatternResolver->resolveRequestPatternClass($patternType);
$requestPattern = new $patternClassName($patternOptions);
if (!$requestPattern instanceof RequestPatternInterface) {
throw new Exception\InvalidRequestPatternException(sprintf('Invalid request pattern configuration in setting "Neos:Flow:security:authentication:providers:%s": Class "%s" does not implement RequestPatternInterface', $providerName, $patternClassName), 1446222774);
}
$requestPatterns[] = $requestPattern;
}
if ($tokenInstance !== null) {
$tokenInstance->setRequestPatterns($requestPatterns);
}
}
if (isset($providerConfiguration['entryPoint'])) {
if (is_array($providerConfiguration['entryPoint'])) {
$message = 'Invalid entry point configuration in setting "Neos:Flow:security:authentication:providers:' . $providerName . '. Check your settings and make sure to specify only one entry point for each provider.';
throw new Exception\InvalidAuthenticationProviderException($message, 1327671458);
}
$entryPointName = $providerConfiguration['entryPoint'];
$entryPointClassName = $entryPointName;
if (!class_exists($entryPointClassName)) {
$entryPointClassName = 'Neos\Flow\Security\Authentication\EntryPoint\\' . $entryPointClassName;
}
if (!class_exists($entryPointClassName)) {
throw new Exception\NoEntryPointFoundException('An entry point with the name: "' . $entryPointName . '" could not be resolved. Make sure it is a valid class name, either fully qualified or relative to Neos\Flow\Security\Authentication\EntryPoint!', 1236767282);
}
/** @var $entryPoint EntryPointInterface */
$entryPoint = new $entryPointClassName();
if (isset($providerConfiguration['entryPointOptions'])) {
$entryPoint->setOptions($providerConfiguration['entryPointOptions']);
}
$tokenInstance->setAuthenticationEntryPoint($entryPoint);
}
}
$this->isInitialized = true;
} | [
"protected",
"function",
"buildProvidersAndTokensFromConfiguration",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isInitialized",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"tokens",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"providers",
"=",
"[",
"]... | Builds the provider and token objects based on the given configuration
@return void
@throws Exception\InvalidAuthenticationProviderException
@throws Exception\InvalidRequestPatternException
@throws Exception\NoAuthenticationProviderFoundException
@throws Exception\NoEntryPointFoundException
@throws Exception\NoRequestPatternFoundException | [
"Builds",
"the",
"provider",
"and",
"token",
"objects",
"based",
"on",
"the",
"given",
"configuration"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Authentication/TokenAndProviderFactory.php#L125-L213 |
neos/flow-development-collection | Neos.Flow/Classes/Validation/ValidatorResolver.php | ValidatorResolver.createValidator | public function createValidator($validatorType, array $validatorOptions = [])
{
$validatorObjectName = $this->resolveValidatorObjectName($validatorType);
if ($validatorObjectName === false) {
return null;
}
switch ($this->objectManager->getScope($validatorObjectName)) {
case Configuration::SCOPE_PROTOTYPE:
$validator = new $validatorObjectName($validatorOptions);
break;
case Configuration::SCOPE_SINGLETON:
if (count($validatorOptions) > 0) {
throw new Exception\InvalidValidationConfigurationException('The validator "' . $validatorObjectName . '" is of scope singleton, but configured to be used with options. A validator with options must be of scope prototype.', 1358958575);
}
$validator = $this->objectManager->get($validatorObjectName);
break;
default:
throw new Exception\NoSuchValidatorException('The validator "' . $validatorObjectName . '" is not of scope singleton or prototype!', 1300694835);
}
if (!($validator instanceof ValidatorInterface)) {
throw new Exception\NoSuchValidatorException(sprintf('The validator "%s" does not implement %s!', $validatorObjectName, ValidatorInterface::class), 1300694875);
}
return $validator;
} | php | public function createValidator($validatorType, array $validatorOptions = [])
{
$validatorObjectName = $this->resolveValidatorObjectName($validatorType);
if ($validatorObjectName === false) {
return null;
}
switch ($this->objectManager->getScope($validatorObjectName)) {
case Configuration::SCOPE_PROTOTYPE:
$validator = new $validatorObjectName($validatorOptions);
break;
case Configuration::SCOPE_SINGLETON:
if (count($validatorOptions) > 0) {
throw new Exception\InvalidValidationConfigurationException('The validator "' . $validatorObjectName . '" is of scope singleton, but configured to be used with options. A validator with options must be of scope prototype.', 1358958575);
}
$validator = $this->objectManager->get($validatorObjectName);
break;
default:
throw new Exception\NoSuchValidatorException('The validator "' . $validatorObjectName . '" is not of scope singleton or prototype!', 1300694835);
}
if (!($validator instanceof ValidatorInterface)) {
throw new Exception\NoSuchValidatorException(sprintf('The validator "%s" does not implement %s!', $validatorObjectName, ValidatorInterface::class), 1300694875);
}
return $validator;
} | [
"public",
"function",
"createValidator",
"(",
"$",
"validatorType",
",",
"array",
"$",
"validatorOptions",
"=",
"[",
"]",
")",
"{",
"$",
"validatorObjectName",
"=",
"$",
"this",
"->",
"resolveValidatorObjectName",
"(",
"$",
"validatorType",
")",
";",
"if",
"("... | Get a validator for a given data type. Returns a validator implementing
the ValidatorInterface or NULL if no validator
could be resolved.
@param string $validatorType Either one of the built-in data types or fully qualified validator class name
@param array $validatorOptions Options to be passed to the validator
@return ValidatorInterface
@throws Exception\NoSuchValidatorException
@throws Exception\InvalidValidationConfigurationException
@api | [
"Get",
"a",
"validator",
"for",
"a",
"given",
"data",
"type",
".",
"Returns",
"a",
"validator",
"implementing",
"the",
"ValidatorInterface",
"or",
"NULL",
"if",
"no",
"validator",
"could",
"be",
"resolved",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Validation/ValidatorResolver.php#L95-L121 |
neos/flow-development-collection | Neos.Flow/Classes/Validation/ValidatorResolver.php | ValidatorResolver.getBaseValidatorConjunction | public function getBaseValidatorConjunction($targetClassName, array $validationGroups = ['Default'])
{
$targetClassName = trim($targetClassName, ' \\');
$indexKey = $targetClassName . '##' . implode('##', $validationGroups);
if (!array_key_exists($indexKey, $this->baseValidatorConjunctions)) {
$this->buildBaseValidatorConjunction($indexKey, $targetClassName, $validationGroups);
}
return $this->baseValidatorConjunctions[$indexKey];
} | php | public function getBaseValidatorConjunction($targetClassName, array $validationGroups = ['Default'])
{
$targetClassName = trim($targetClassName, ' \\');
$indexKey = $targetClassName . '##' . implode('##', $validationGroups);
if (!array_key_exists($indexKey, $this->baseValidatorConjunctions)) {
$this->buildBaseValidatorConjunction($indexKey, $targetClassName, $validationGroups);
}
return $this->baseValidatorConjunctions[$indexKey];
} | [
"public",
"function",
"getBaseValidatorConjunction",
"(",
"$",
"targetClassName",
",",
"array",
"$",
"validationGroups",
"=",
"[",
"'Default'",
"]",
")",
"{",
"$",
"targetClassName",
"=",
"trim",
"(",
"$",
"targetClassName",
",",
"' \\\\'",
")",
";",
"$",
"ind... | Resolves and returns the base validator conjunction for the given data type.
If no validation is necessary, the returned validator is empty.
@param string $targetClassName Fully qualified class name of the target class, ie. the class which should be validated
@param array $validationGroups The validation groups to build the validator for
@return ConjunctionValidator The validator conjunction
@throws Exception\InvalidValidationConfigurationException
@throws Exception\InvalidValidationOptionsException
@throws Exception\NoSuchValidatorException
@api | [
"Resolves",
"and",
"returns",
"the",
"base",
"validator",
"conjunction",
"for",
"the",
"given",
"data",
"type",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Validation/ValidatorResolver.php#L136-L145 |
neos/flow-development-collection | Neos.Flow/Classes/Validation/ValidatorResolver.php | ValidatorResolver.buildMethodArgumentsValidatorConjunctions | public function buildMethodArgumentsValidatorConjunctions($className, $methodName, array $methodParameters = null, array $methodValidateAnnotations = null)
{
$validatorConjunctions = [];
if ($methodParameters === null) {
$methodParameters = $this->reflectionService->getMethodParameters($className, $methodName);
}
if (count($methodParameters) === 0) {
return $validatorConjunctions;
}
foreach ($methodParameters as $parameterName => $methodParameter) {
/** @var ConjunctionValidator $validatorConjunction */
$validatorConjunction = $this->createValidator(ConjunctionValidator::class);
if (!array_key_exists('type', $methodParameter)) {
throw new Exception\InvalidTypeHintException('Missing type information, probably no @param annotation for parameter "$' . $parameterName . '" in ' . $className . '->' . $methodName . '()', 1281962564);
}
if (strpos($methodParameter['type'], '\\') === false) {
$typeValidator = $this->createValidator($methodParameter['type']);
} else {
$typeValidator = null;
}
if ($typeValidator !== null) {
$validatorConjunction->addValidator($typeValidator);
}
$validatorConjunctions[$parameterName] = $validatorConjunction;
}
if ($methodValidateAnnotations === null) {
$validateAnnotations = $this->reflectionService->getMethodAnnotations($className, $methodName, Flow\Validate::class);
$methodValidateAnnotations = array_map(function ($validateAnnotation) {
return [
'type' => $validateAnnotation->type,
'options' => $validateAnnotation->options,
'argumentName' => $validateAnnotation->argumentName,
];
}, $validateAnnotations);
}
foreach ($methodValidateAnnotations as $annotationParameters) {
$newValidator = $this->createValidator($annotationParameters['type'], $annotationParameters['options']);
if ($newValidator === null) {
throw new Exception\NoSuchValidatorException('Invalid validate annotation in ' . $className . '->' . $methodName . '(): Could not resolve class name for validator "' . $annotationParameters['type'] . '".', 1239853109);
}
if (isset($validatorConjunctions[$annotationParameters['argumentName']])) {
$validatorConjunctions[$annotationParameters['argumentName']]->addValidator($newValidator);
} elseif (strpos($annotationParameters['argumentName'], '.') !== false) {
$objectPath = explode('.', $annotationParameters['argumentName']);
$argumentName = array_shift($objectPath);
$validatorConjunctions[$argumentName]->addValidator($this->buildSubObjectValidator($objectPath, $newValidator));
} else {
throw new Exception\InvalidValidationConfigurationException('Invalid validate annotation in ' . $className . '->' . $methodName . '(): Validator specified for argument name "' . $annotationParameters['argumentName'] . '", but this argument does not exist.', 1253172726);
}
}
return $validatorConjunctions;
} | php | public function buildMethodArgumentsValidatorConjunctions($className, $methodName, array $methodParameters = null, array $methodValidateAnnotations = null)
{
$validatorConjunctions = [];
if ($methodParameters === null) {
$methodParameters = $this->reflectionService->getMethodParameters($className, $methodName);
}
if (count($methodParameters) === 0) {
return $validatorConjunctions;
}
foreach ($methodParameters as $parameterName => $methodParameter) {
/** @var ConjunctionValidator $validatorConjunction */
$validatorConjunction = $this->createValidator(ConjunctionValidator::class);
if (!array_key_exists('type', $methodParameter)) {
throw new Exception\InvalidTypeHintException('Missing type information, probably no @param annotation for parameter "$' . $parameterName . '" in ' . $className . '->' . $methodName . '()', 1281962564);
}
if (strpos($methodParameter['type'], '\\') === false) {
$typeValidator = $this->createValidator($methodParameter['type']);
} else {
$typeValidator = null;
}
if ($typeValidator !== null) {
$validatorConjunction->addValidator($typeValidator);
}
$validatorConjunctions[$parameterName] = $validatorConjunction;
}
if ($methodValidateAnnotations === null) {
$validateAnnotations = $this->reflectionService->getMethodAnnotations($className, $methodName, Flow\Validate::class);
$methodValidateAnnotations = array_map(function ($validateAnnotation) {
return [
'type' => $validateAnnotation->type,
'options' => $validateAnnotation->options,
'argumentName' => $validateAnnotation->argumentName,
];
}, $validateAnnotations);
}
foreach ($methodValidateAnnotations as $annotationParameters) {
$newValidator = $this->createValidator($annotationParameters['type'], $annotationParameters['options']);
if ($newValidator === null) {
throw new Exception\NoSuchValidatorException('Invalid validate annotation in ' . $className . '->' . $methodName . '(): Could not resolve class name for validator "' . $annotationParameters['type'] . '".', 1239853109);
}
if (isset($validatorConjunctions[$annotationParameters['argumentName']])) {
$validatorConjunctions[$annotationParameters['argumentName']]->addValidator($newValidator);
} elseif (strpos($annotationParameters['argumentName'], '.') !== false) {
$objectPath = explode('.', $annotationParameters['argumentName']);
$argumentName = array_shift($objectPath);
$validatorConjunctions[$argumentName]->addValidator($this->buildSubObjectValidator($objectPath, $newValidator));
} else {
throw new Exception\InvalidValidationConfigurationException('Invalid validate annotation in ' . $className . '->' . $methodName . '(): Validator specified for argument name "' . $annotationParameters['argumentName'] . '", but this argument does not exist.', 1253172726);
}
}
return $validatorConjunctions;
} | [
"public",
"function",
"buildMethodArgumentsValidatorConjunctions",
"(",
"$",
"className",
",",
"$",
"methodName",
",",
"array",
"$",
"methodParameters",
"=",
"null",
",",
"array",
"$",
"methodValidateAnnotations",
"=",
"null",
")",
"{",
"$",
"validatorConjunctions",
... | Detects and registers any validators for arguments:
- by the data type specified in the param annotations
- additional validators specified in the validate annotations of a method
@param string $className
@param string $methodName
@param array $methodParameters Optional pre-compiled array of method parameters
@param array $methodValidateAnnotations Optional pre-compiled array of validate annotations (as array)
@return array An Array of ValidatorConjunctions for each method parameters.
@throws Exception\InvalidValidationConfigurationException
@throws Exception\NoSuchValidatorException
@throws Exception\InvalidTypeHintException
@throws Exception\InvalidValidationOptionsException | [
"Detects",
"and",
"registers",
"any",
"validators",
"for",
"arguments",
":",
"-",
"by",
"the",
"data",
"type",
"specified",
"in",
"the",
"param",
"annotations",
"-",
"additional",
"validators",
"specified",
"in",
"the",
"validate",
"annotations",
"of",
"a",
"m... | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Validation/ValidatorResolver.php#L162-L220 |
neos/flow-development-collection | Neos.Flow/Classes/Validation/ValidatorResolver.php | ValidatorResolver.buildSubObjectValidator | protected function buildSubObjectValidator(array $objectPath, ValidatorInterface $propertyValidator)
{
$rootObjectValidator = new GenericObjectValidator([]);
$parentObjectValidator = $rootObjectValidator;
while (count($objectPath) > 1) {
$subObjectValidator = new GenericObjectValidator([]);
$subPropertyName = array_shift($objectPath);
$parentObjectValidator->addPropertyValidator($subPropertyName, $subObjectValidator);
$parentObjectValidator = $subObjectValidator;
}
$parentObjectValidator->addPropertyValidator(array_shift($objectPath), $propertyValidator);
return $rootObjectValidator;
} | php | protected function buildSubObjectValidator(array $objectPath, ValidatorInterface $propertyValidator)
{
$rootObjectValidator = new GenericObjectValidator([]);
$parentObjectValidator = $rootObjectValidator;
while (count($objectPath) > 1) {
$subObjectValidator = new GenericObjectValidator([]);
$subPropertyName = array_shift($objectPath);
$parentObjectValidator->addPropertyValidator($subPropertyName, $subObjectValidator);
$parentObjectValidator = $subObjectValidator;
}
$parentObjectValidator->addPropertyValidator(array_shift($objectPath), $propertyValidator);
return $rootObjectValidator;
} | [
"protected",
"function",
"buildSubObjectValidator",
"(",
"array",
"$",
"objectPath",
",",
"ValidatorInterface",
"$",
"propertyValidator",
")",
"{",
"$",
"rootObjectValidator",
"=",
"new",
"GenericObjectValidator",
"(",
"[",
"]",
")",
";",
"$",
"parentObjectValidator",... | Builds a chain of nested object validators by specification of the given
object path.
@param array $objectPath The object path
@param ValidatorInterface $propertyValidator The validator which should be added to the property specified by objectPath
@return GenericObjectValidator
@throws Exception\InvalidValidationOptionsException | [
"Builds",
"a",
"chain",
"of",
"nested",
"object",
"validators",
"by",
"specification",
"of",
"the",
"given",
"object",
"path",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Validation/ValidatorResolver.php#L242-L257 |
neos/flow-development-collection | Neos.Flow/Classes/Validation/ValidatorResolver.php | ValidatorResolver.buildBaseValidatorConjunction | protected function buildBaseValidatorConjunction($indexKey, $targetClassName, array $validationGroups)
{
$conjunctionValidator = new ConjunctionValidator([]);
$this->baseValidatorConjunctions[$indexKey] = $conjunctionValidator;
if (!TypeHandling::isSimpleType($targetClassName) && class_exists($targetClassName)) {
// Model based validator
$classSchema = $this->reflectionService->getClassSchema($targetClassName);
if ($classSchema !== null && $classSchema->isAggregateRoot()) {
$objectValidator = new AggregateBoundaryValidator([]);
} else {
$objectValidator = new GenericObjectValidator([]);
}
$conjunctionValidator->addValidator($objectValidator);
foreach ($this->reflectionService->getClassPropertyNames($targetClassName) as $classPropertyName) {
$classPropertyTagsValues = $this->reflectionService->getPropertyTagsValues($targetClassName, $classPropertyName);
if (!isset($classPropertyTagsValues['var'])) {
throw new \InvalidArgumentException(sprintf('There is no @var annotation for property "%s" in class "%s".', $classPropertyName, $targetClassName), 1363778104);
}
try {
$parsedType = TypeHandling::parseType(trim(implode('', $classPropertyTagsValues['var']), ' \\'));
} catch (InvalidTypeException $exception) {
throw new \InvalidArgumentException(sprintf(' @var annotation of ' . $exception->getMessage(), 'class "' . $targetClassName . '", property "' . $classPropertyName . '"'), 1315564744, $exception);
}
if ($this->reflectionService->isPropertyAnnotatedWith($targetClassName, $classPropertyName, Flow\IgnoreValidation::class)) {
continue;
}
$propertyTargetClassName = $parsedType['type'];
$needsCollectionValidator = TypeHandling::isCollectionType($propertyTargetClassName);
$needsObjectValidator = (!TypeHandling::isSimpleType($propertyTargetClassName) && $this->objectManager->isRegistered($propertyTargetClassName) && $this->objectManager->getScope($propertyTargetClassName) === Configuration::SCOPE_PROTOTYPE);
$validateAnnotations = $this->reflectionService->getPropertyAnnotations($targetClassName, $classPropertyName, Flow\Validate::class);
foreach ($validateAnnotations as $validateAnnotation) {
if ($validateAnnotation->type === 'Collection') {
$needsCollectionValidator = false;
$validateAnnotation->options = array_merge(['elementType' => $parsedType['elementType'], 'validationGroups' => $validationGroups], $validateAnnotation->options);
}
if (count(array_intersect($validateAnnotation->validationGroups, $validationGroups)) === 0) {
if ($validateAnnotation->type === 'GenericObject') {
$needsObjectValidator = false;
}
// In this case, the validation groups for the property do not match current validation context
continue;
}
if ($validateAnnotation->type === 'GenericObject') {
continue;
}
$newValidator = $this->createValidator($validateAnnotation->type, $validateAnnotation->options);
if ($newValidator === null) {
throw new Exception\NoSuchValidatorException('Invalid validate annotation in ' . $targetClassName . '::' . $classPropertyName . ': Could not resolve class name for validator "' . $validateAnnotation->type . '".', 1241098027);
}
$objectValidator->addPropertyValidator($classPropertyName, $newValidator);
}
if ($needsCollectionValidator) {
$collectionValidator = $this->createValidator(Validator\CollectionValidator::class, ['elementType' => $parsedType['elementType'], 'validationGroups' => $validationGroups]);
$objectValidator->addPropertyValidator($classPropertyName, $collectionValidator);
}
if ($needsObjectValidator) {
$validatorForProperty = $this->getBaseValidatorConjunction($propertyTargetClassName, $validationGroups);
if (count($validatorForProperty) > 0) {
$objectValidator->addPropertyValidator($classPropertyName, $validatorForProperty);
}
}
}
if (count($objectValidator->getPropertyValidators()) === 0) {
$conjunctionValidator->removeValidator($objectValidator);
}
}
$this->addCustomValidators($targetClassName, $conjunctionValidator);
} | php | protected function buildBaseValidatorConjunction($indexKey, $targetClassName, array $validationGroups)
{
$conjunctionValidator = new ConjunctionValidator([]);
$this->baseValidatorConjunctions[$indexKey] = $conjunctionValidator;
if (!TypeHandling::isSimpleType($targetClassName) && class_exists($targetClassName)) {
// Model based validator
$classSchema = $this->reflectionService->getClassSchema($targetClassName);
if ($classSchema !== null && $classSchema->isAggregateRoot()) {
$objectValidator = new AggregateBoundaryValidator([]);
} else {
$objectValidator = new GenericObjectValidator([]);
}
$conjunctionValidator->addValidator($objectValidator);
foreach ($this->reflectionService->getClassPropertyNames($targetClassName) as $classPropertyName) {
$classPropertyTagsValues = $this->reflectionService->getPropertyTagsValues($targetClassName, $classPropertyName);
if (!isset($classPropertyTagsValues['var'])) {
throw new \InvalidArgumentException(sprintf('There is no @var annotation for property "%s" in class "%s".', $classPropertyName, $targetClassName), 1363778104);
}
try {
$parsedType = TypeHandling::parseType(trim(implode('', $classPropertyTagsValues['var']), ' \\'));
} catch (InvalidTypeException $exception) {
throw new \InvalidArgumentException(sprintf(' @var annotation of ' . $exception->getMessage(), 'class "' . $targetClassName . '", property "' . $classPropertyName . '"'), 1315564744, $exception);
}
if ($this->reflectionService->isPropertyAnnotatedWith($targetClassName, $classPropertyName, Flow\IgnoreValidation::class)) {
continue;
}
$propertyTargetClassName = $parsedType['type'];
$needsCollectionValidator = TypeHandling::isCollectionType($propertyTargetClassName);
$needsObjectValidator = (!TypeHandling::isSimpleType($propertyTargetClassName) && $this->objectManager->isRegistered($propertyTargetClassName) && $this->objectManager->getScope($propertyTargetClassName) === Configuration::SCOPE_PROTOTYPE);
$validateAnnotations = $this->reflectionService->getPropertyAnnotations($targetClassName, $classPropertyName, Flow\Validate::class);
foreach ($validateAnnotations as $validateAnnotation) {
if ($validateAnnotation->type === 'Collection') {
$needsCollectionValidator = false;
$validateAnnotation->options = array_merge(['elementType' => $parsedType['elementType'], 'validationGroups' => $validationGroups], $validateAnnotation->options);
}
if (count(array_intersect($validateAnnotation->validationGroups, $validationGroups)) === 0) {
if ($validateAnnotation->type === 'GenericObject') {
$needsObjectValidator = false;
}
// In this case, the validation groups for the property do not match current validation context
continue;
}
if ($validateAnnotation->type === 'GenericObject') {
continue;
}
$newValidator = $this->createValidator($validateAnnotation->type, $validateAnnotation->options);
if ($newValidator === null) {
throw new Exception\NoSuchValidatorException('Invalid validate annotation in ' . $targetClassName . '::' . $classPropertyName . ': Could not resolve class name for validator "' . $validateAnnotation->type . '".', 1241098027);
}
$objectValidator->addPropertyValidator($classPropertyName, $newValidator);
}
if ($needsCollectionValidator) {
$collectionValidator = $this->createValidator(Validator\CollectionValidator::class, ['elementType' => $parsedType['elementType'], 'validationGroups' => $validationGroups]);
$objectValidator->addPropertyValidator($classPropertyName, $collectionValidator);
}
if ($needsObjectValidator) {
$validatorForProperty = $this->getBaseValidatorConjunction($propertyTargetClassName, $validationGroups);
if (count($validatorForProperty) > 0) {
$objectValidator->addPropertyValidator($classPropertyName, $validatorForProperty);
}
}
}
if (count($objectValidator->getPropertyValidators()) === 0) {
$conjunctionValidator->removeValidator($objectValidator);
}
}
$this->addCustomValidators($targetClassName, $conjunctionValidator);
} | [
"protected",
"function",
"buildBaseValidatorConjunction",
"(",
"$",
"indexKey",
",",
"$",
"targetClassName",
",",
"array",
"$",
"validationGroups",
")",
"{",
"$",
"conjunctionValidator",
"=",
"new",
"ConjunctionValidator",
"(",
"[",
"]",
")",
";",
"$",
"this",
"... | Builds a base validator conjunction for the given data type.
The base validation rules are those which were declared directly in a class (typically
a model) through some validate annotations on properties.
If a property holds a class for which a base validator exists, that property will be
checked as well, regardless of a validate annotation
Additionally, if a custom validator was defined for the class in question, it will be added
to the end of the conjunction. A custom validator is found if it follows the naming convention
"Replace '\Model\' by '\Validator\' and append 'Validator'".
Example: $targetClassName is Neos\Foo\Domain\Model\Quux, then the validator will be found if it has the
name Neos\Foo\Domain\Validator\QuuxValidator
@param string $indexKey The key to use as index in $this->baseValidatorConjunctions; calculated from target class name and validation groups
@param string $targetClassName The data type to build the validation conjunction for. Needs to be the fully qualified class name.
@param array $validationGroups The validation groups to build the validator for
@return void
@throws Exception\NoSuchValidatorException
@throws \InvalidArgumentException
@throws Exception\InvalidValidationOptionsException
@throws Exception\InvalidValidationConfigurationException | [
"Builds",
"a",
"base",
"validator",
"conjunction",
"for",
"the",
"given",
"data",
"type",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Validation/ValidatorResolver.php#L284-L357 |
neos/flow-development-collection | Neos.Flow/Classes/Validation/ValidatorResolver.php | ValidatorResolver.addCustomValidators | protected function addCustomValidators($targetClassName, ConjunctionValidator &$conjunctionValidator)
{
// Custom validator for the class
$addedValidatorClassName = null;
$possibleValidatorClassName = str_replace('\\Model\\', '\\Validator\\', $targetClassName) . 'Validator';
$customValidator = $this->createValidator($possibleValidatorClassName);
if ($customValidator !== null) {
$conjunctionValidator->addValidator($customValidator);
$addedValidatorClassName = get_class($customValidator);
}
// find polytype validator for class
$acceptablePolyTypeValidators = [];
$polyTypeObjectValidatorImplementationClassNames = static::getPolyTypeObjectValidatorImplementationClassNames($this->objectManager);
foreach ($polyTypeObjectValidatorImplementationClassNames as $validatorImplementationClassName) {
/** @var PolyTypeObjectValidatorInterface $acceptablePolyTypeValidator */
$acceptablePolyTypeValidator = $this->createValidator($validatorImplementationClassName);
// skip custom validator already added above
if ($addedValidatorClassName === get_class($acceptablePolyTypeValidator)) {
continue;
}
if ($acceptablePolyTypeValidator->canValidate($targetClassName)) {
$acceptablePolyTypeValidators[$acceptablePolyTypeValidator->getPriority()] = $acceptablePolyTypeValidator;
}
}
if (count($acceptablePolyTypeValidators) > 0) {
ksort($acceptablePolyTypeValidators);
$conjunctionValidator->addValidator(array_pop($acceptablePolyTypeValidators));
}
} | php | protected function addCustomValidators($targetClassName, ConjunctionValidator &$conjunctionValidator)
{
// Custom validator for the class
$addedValidatorClassName = null;
$possibleValidatorClassName = str_replace('\\Model\\', '\\Validator\\', $targetClassName) . 'Validator';
$customValidator = $this->createValidator($possibleValidatorClassName);
if ($customValidator !== null) {
$conjunctionValidator->addValidator($customValidator);
$addedValidatorClassName = get_class($customValidator);
}
// find polytype validator for class
$acceptablePolyTypeValidators = [];
$polyTypeObjectValidatorImplementationClassNames = static::getPolyTypeObjectValidatorImplementationClassNames($this->objectManager);
foreach ($polyTypeObjectValidatorImplementationClassNames as $validatorImplementationClassName) {
/** @var PolyTypeObjectValidatorInterface $acceptablePolyTypeValidator */
$acceptablePolyTypeValidator = $this->createValidator($validatorImplementationClassName);
// skip custom validator already added above
if ($addedValidatorClassName === get_class($acceptablePolyTypeValidator)) {
continue;
}
if ($acceptablePolyTypeValidator->canValidate($targetClassName)) {
$acceptablePolyTypeValidators[$acceptablePolyTypeValidator->getPriority()] = $acceptablePolyTypeValidator;
}
}
if (count($acceptablePolyTypeValidators) > 0) {
ksort($acceptablePolyTypeValidators);
$conjunctionValidator->addValidator(array_pop($acceptablePolyTypeValidators));
}
} | [
"protected",
"function",
"addCustomValidators",
"(",
"$",
"targetClassName",
",",
"ConjunctionValidator",
"&",
"$",
"conjunctionValidator",
")",
"{",
"// Custom validator for the class",
"$",
"addedValidatorClassName",
"=",
"null",
";",
"$",
"possibleValidatorClassName",
"=... | This adds custom validators to the passed $conjunctionValidator.
A custom validator is found if it follows the naming convention "Replace '\Model\' by '\Validator\' and
append 'Validator'". If found, it will be added to the $conjunctionValidator.
In addition canValidate() will be called on all implementations of the ObjectValidatorInterface to find
all validators that could validate the target. The one with the highest priority will be added as well.
If multiple validators have the same priority, which one will be added is not deterministic.
@param string $targetClassName
@param ConjunctionValidator $conjunctionValidator
@return void
@throws Exception\InvalidValidationConfigurationException
@throws Exception\NoSuchValidatorException | [
"This",
"adds",
"custom",
"validators",
"to",
"the",
"passed",
"$conjunctionValidator",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Validation/ValidatorResolver.php#L375-L404 |
neos/flow-development-collection | Neos.Flow/Classes/Validation/ValidatorResolver.php | ValidatorResolver.getPolyTypeObjectValidatorImplementationClassNames | public static function getPolyTypeObjectValidatorImplementationClassNames($objectManager)
{
$reflectionService = $objectManager->get(ReflectionService::class);
$result = $reflectionService->getAllImplementationClassNamesForInterface(Validator\PolyTypeObjectValidatorInterface::class);
return $result;
} | php | public static function getPolyTypeObjectValidatorImplementationClassNames($objectManager)
{
$reflectionService = $objectManager->get(ReflectionService::class);
$result = $reflectionService->getAllImplementationClassNamesForInterface(Validator\PolyTypeObjectValidatorInterface::class);
return $result;
} | [
"public",
"static",
"function",
"getPolyTypeObjectValidatorImplementationClassNames",
"(",
"$",
"objectManager",
")",
"{",
"$",
"reflectionService",
"=",
"$",
"objectManager",
"->",
"get",
"(",
"ReflectionService",
"::",
"class",
")",
";",
"$",
"result",
"=",
"$",
... | Returns a map of object validator class names.
@param ObjectManagerInterface $objectManager
@return array Array of object validator class names
@Flow\CompileStatic | [
"Returns",
"a",
"map",
"of",
"object",
"validator",
"class",
"names",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Validation/ValidatorResolver.php#L413-L418 |
neos/flow-development-collection | Neos.Flow/Classes/Validation/ValidatorResolver.php | ValidatorResolver.resolveValidatorObjectName | protected function resolveValidatorObjectName($validatorType)
{
$validatorType = ltrim($validatorType, '\\');
$validatorClassNames = static::getValidatorImplementationClassNames($this->objectManager);
if ($this->objectManager->isRegistered($validatorType) && isset($validatorClassNames[$validatorType])) {
return $validatorType;
}
if (strpos($validatorType, ':') !== false) {
list($packageName, $packageValidatorType) = explode(':', $validatorType);
$possibleClassName = sprintf('%s\Validation\Validator\%sValidator', str_replace('.', '\\', $packageName), $this->getValidatorType($packageValidatorType));
} else {
$possibleClassName = sprintf('Neos\Flow\Validation\Validator\%sValidator', $this->getValidatorType($validatorType));
}
if ($this->objectManager->isRegistered($possibleClassName) && isset($validatorClassNames[$possibleClassName])) {
return $possibleClassName;
}
return false;
} | php | protected function resolveValidatorObjectName($validatorType)
{
$validatorType = ltrim($validatorType, '\\');
$validatorClassNames = static::getValidatorImplementationClassNames($this->objectManager);
if ($this->objectManager->isRegistered($validatorType) && isset($validatorClassNames[$validatorType])) {
return $validatorType;
}
if (strpos($validatorType, ':') !== false) {
list($packageName, $packageValidatorType) = explode(':', $validatorType);
$possibleClassName = sprintf('%s\Validation\Validator\%sValidator', str_replace('.', '\\', $packageName), $this->getValidatorType($packageValidatorType));
} else {
$possibleClassName = sprintf('Neos\Flow\Validation\Validator\%sValidator', $this->getValidatorType($validatorType));
}
if ($this->objectManager->isRegistered($possibleClassName) && isset($validatorClassNames[$possibleClassName])) {
return $possibleClassName;
}
return false;
} | [
"protected",
"function",
"resolveValidatorObjectName",
"(",
"$",
"validatorType",
")",
"{",
"$",
"validatorType",
"=",
"ltrim",
"(",
"$",
"validatorType",
",",
"'\\\\'",
")",
";",
"$",
"validatorClassNames",
"=",
"static",
"::",
"getValidatorImplementationClassNames",... | Returns the class name of an appropriate validator for the given type. If no
validator is available false is returned
@param string $validatorType Either the fully qualified class name of the validator or the short name of a built-in validator
@return string|boolean Class name of the validator or false if not available | [
"Returns",
"the",
"class",
"name",
"of",
"an",
"appropriate",
"validator",
"for",
"the",
"given",
"type",
".",
"If",
"no",
"validator",
"is",
"available",
"false",
"is",
"returned"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Validation/ValidatorResolver.php#L427-L448 |
neos/flow-development-collection | Neos.Flow/Classes/Validation/ValidatorResolver.php | ValidatorResolver.getValidatorImplementationClassNames | public static function getValidatorImplementationClassNames($objectManager)
{
$reflectionService = $objectManager->get(ReflectionService::class);
$classNames = $reflectionService->getAllImplementationClassNamesForInterface(ValidatorInterface::class);
return array_flip($classNames);
} | php | public static function getValidatorImplementationClassNames($objectManager)
{
$reflectionService = $objectManager->get(ReflectionService::class);
$classNames = $reflectionService->getAllImplementationClassNamesForInterface(ValidatorInterface::class);
return array_flip($classNames);
} | [
"public",
"static",
"function",
"getValidatorImplementationClassNames",
"(",
"$",
"objectManager",
")",
"{",
"$",
"reflectionService",
"=",
"$",
"objectManager",
"->",
"get",
"(",
"ReflectionService",
"::",
"class",
")",
";",
"$",
"classNames",
"=",
"$",
"reflecti... | Returns all class names implementing the ValidatorInterface.
@param ObjectManagerInterface $objectManager
@return array Array of class names implementing ValidatorInterface indexed by class name
@Flow\CompileStatic | [
"Returns",
"all",
"class",
"names",
"implementing",
"the",
"ValidatorInterface",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Validation/ValidatorResolver.php#L457-L462 |
neos/flow-development-collection | Neos.Flow/Classes/Validation/ValidatorResolver.php | ValidatorResolver.getValidatorType | protected function getValidatorType($type)
{
switch ($type) {
case 'int':
$type = 'Integer';
break;
case 'bool':
$type = 'Boolean';
break;
case 'double':
$type = 'Float';
break;
case 'numeric':
$type = 'Number';
break;
case 'mixed':
$type = 'Raw';
break;
default:
$type = ucfirst($type);
}
return $type;
} | php | protected function getValidatorType($type)
{
switch ($type) {
case 'int':
$type = 'Integer';
break;
case 'bool':
$type = 'Boolean';
break;
case 'double':
$type = 'Float';
break;
case 'numeric':
$type = 'Number';
break;
case 'mixed':
$type = 'Raw';
break;
default:
$type = ucfirst($type);
}
return $type;
} | [
"protected",
"function",
"getValidatorType",
"(",
"$",
"type",
")",
"{",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"'int'",
":",
"$",
"type",
"=",
"'Integer'",
";",
"break",
";",
"case",
"'bool'",
":",
"$",
"type",
"=",
"'Boolean'",
";",
"break",
... | Used to map PHP types to validator types.
@param string $type Data type to unify
@return string unified data type | [
"Used",
"to",
"map",
"PHP",
"types",
"to",
"validator",
"types",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Validation/ValidatorResolver.php#L470-L492 |
neos/flow-development-collection | Neos.Flow/Classes/Validation/Validator/AggregateBoundaryValidator.php | AggregateBoundaryValidator.isValid | public function isValid($value)
{
/**
* The idea is that Aggregates form a consistency boundary, and an Aggregate only needs to be
* validated if it changed state. Also since all entity relations are lazy loaded by default,
* and the relation will only be initialized when it gets accessed (e.g. during property mapping),
* we can just skip validation of an uninitialized aggregate.
* This greatly improves validation performance for domain models with lots of small aggregate
* relations. Therefore proper Aggregate Design becomes a performance optimization.
*/
if ($value instanceof \Doctrine\ORM\Proxy\Proxy && !$value->__isInitialized()) {
return;
}
parent::isValid($value);
} | php | public function isValid($value)
{
/**
* The idea is that Aggregates form a consistency boundary, and an Aggregate only needs to be
* validated if it changed state. Also since all entity relations are lazy loaded by default,
* and the relation will only be initialized when it gets accessed (e.g. during property mapping),
* we can just skip validation of an uninitialized aggregate.
* This greatly improves validation performance for domain models with lots of small aggregate
* relations. Therefore proper Aggregate Design becomes a performance optimization.
*/
if ($value instanceof \Doctrine\ORM\Proxy\Proxy && !$value->__isInitialized()) {
return;
}
parent::isValid($value);
} | [
"public",
"function",
"isValid",
"(",
"$",
"value",
")",
"{",
"/**\n * The idea is that Aggregates form a consistency boundary, and an Aggregate only needs to be\n * validated if it changed state. Also since all entity relations are lazy loaded by default,\n * and the relatio... | Checks if the given value is valid according to the validator, and returns
the Error Messages object which occurred. Will skip validation if value is
an uninitialized lazy loading proxy.
@param mixed $value The value that should be validated
@return void
@api | [
"Checks",
"if",
"the",
"given",
"value",
"is",
"valid",
"according",
"to",
"the",
"validator",
"and",
"returns",
"the",
"Error",
"Messages",
"object",
"which",
"occurred",
".",
"Will",
"skip",
"validation",
"if",
"value",
"is",
"an",
"uninitialized",
"lazy",
... | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Validation/Validator/AggregateBoundaryValidator.php#L32-L46 |
neos/flow-development-collection | Neos.Flow/Classes/Configuration/RouteConfigurationProcessor.php | RouteConfigurationProcessor.includeSubRoutesFromSettings | protected function includeSubRoutesFromSettings($routeDefinitions)
{
if ($this->routeSettings === null) {
return;
}
$sortedRouteSettings = (new PositionalArraySorter($this->routeSettings))->toArray();
foreach ($sortedRouteSettings as $packageKey => $routeFromSettings) {
if ($routeFromSettings === false) {
continue;
}
$subRoutesName = $packageKey . 'SubRoutes';
$subRoutesConfiguration = ['package' => $packageKey];
if (isset($routeFromSettings['variables'])) {
$subRoutesConfiguration['variables'] = $routeFromSettings['variables'];
}
if (isset($routeFromSettings['suffix'])) {
$subRoutesConfiguration['suffix'] = $routeFromSettings['suffix'];
}
$routeDefinitions[] = [
'name' => $packageKey,
'uriPattern' => '<' . $subRoutesName . '>',
'subRoutes' => [
$subRoutesName => $subRoutesConfiguration
]
];
}
return $routeDefinitions;
} | php | protected function includeSubRoutesFromSettings($routeDefinitions)
{
if ($this->routeSettings === null) {
return;
}
$sortedRouteSettings = (new PositionalArraySorter($this->routeSettings))->toArray();
foreach ($sortedRouteSettings as $packageKey => $routeFromSettings) {
if ($routeFromSettings === false) {
continue;
}
$subRoutesName = $packageKey . 'SubRoutes';
$subRoutesConfiguration = ['package' => $packageKey];
if (isset($routeFromSettings['variables'])) {
$subRoutesConfiguration['variables'] = $routeFromSettings['variables'];
}
if (isset($routeFromSettings['suffix'])) {
$subRoutesConfiguration['suffix'] = $routeFromSettings['suffix'];
}
$routeDefinitions[] = [
'name' => $packageKey,
'uriPattern' => '<' . $subRoutesName . '>',
'subRoutes' => [
$subRoutesName => $subRoutesConfiguration
]
];
}
return $routeDefinitions;
} | [
"protected",
"function",
"includeSubRoutesFromSettings",
"(",
"$",
"routeDefinitions",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"routeSettings",
"===",
"null",
")",
"{",
"return",
";",
"}",
"$",
"sortedRouteSettings",
"=",
"(",
"new",
"PositionalArraySorter",
"("... | Merges routes from Neos.Flow.mvc.routes settings into $routeDefinitions
NOTE: Routes from settings will always be appended to existing route definitions from the main Routes configuration!
@param array $routeDefinitions
@return array | [
"Merges",
"routes",
"from",
"Neos",
".",
"Flow",
".",
"mvc",
".",
"routes",
"settings",
"into",
"$routeDefinitions",
"NOTE",
":",
"Routes",
"from",
"settings",
"will",
"always",
"be",
"appended",
"to",
"existing",
"route",
"definitions",
"from",
"the",
"main",... | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Configuration/RouteConfigurationProcessor.php#L85-L113 |
neos/flow-development-collection | Neos.Flow/Classes/Configuration/RouteConfigurationProcessor.php | RouteConfigurationProcessor.mergeRoutesWithSubRoutes | protected function mergeRoutesWithSubRoutes(array $routesConfiguration)
{
$mergedRoutesConfiguration = [];
foreach ($routesConfiguration as $routeConfiguration) {
if (!isset($routeConfiguration['subRoutes'])) {
$mergedRoutesConfiguration[] = $routeConfiguration;
continue;
}
$mergedSubRoutesConfiguration = [$routeConfiguration];
foreach ($routeConfiguration['subRoutes'] as $subRouteKey => $subRouteOptions) {
if (!isset($subRouteOptions['package'])) {
throw new Exception\ParseErrorException(sprintf('Missing package configuration for SubRoute in Route "%s".', (isset($routeConfiguration['name']) ? $routeConfiguration['name'] : 'unnamed Route')), 1318414040);
}
if (!isset($this->packages[$subRouteOptions['package']])) {
throw new Exception\ParseErrorException(sprintf('The SubRoute Package "%s" referenced in Route "%s" is not available.', $subRouteOptions['package'], (isset($routeConfiguration['name']) ? $routeConfiguration['name'] : 'unnamed Route')), 1318414040);
}
/** @var $package PackageInterface */
$package = $this->packages[$subRouteOptions['package']];
$subRouteFilename = 'Routes';
if (isset($subRouteOptions['suffix'])) {
$subRouteFilename .= '.' . $subRouteOptions['suffix'];
}
$subRouteConfiguration = [];
foreach (array_reverse($this->orderedListOfContextNames) as $contextName) {
$subRouteFilePathAndName = $package->getConfigurationPath() . $contextName . '/' . $subRouteFilename;
$subRouteConfiguration = array_merge($subRouteConfiguration, $this->configurationSource->load($subRouteFilePathAndName));
}
$subRouteFilePathAndName = $package->getConfigurationPath() . $subRouteFilename;
$subRouteConfiguration = array_merge($subRouteConfiguration, $this->configurationSource->load($subRouteFilePathAndName));
if ($this->subRoutesRecursionLevel > self::MAXIMUM_SUBROUTE_RECURSIONS) {
throw new Exception\RecursionException(sprintf('Recursion level of SubRoutes exceed ' . self::MAXIMUM_SUBROUTE_RECURSIONS . ', probably because of a circular reference. Last successfully loaded route configuration is "%s".', $subRouteFilePathAndName), 1361535753);
}
$this->subRoutesRecursionLevel++;
$subRouteConfiguration = $this->mergeRoutesWithSubRoutes($subRouteConfiguration);
$this->subRoutesRecursionLevel--;
$mergedSubRoutesConfiguration = $this->buildSubRouteConfigurations($mergedSubRoutesConfiguration, $subRouteConfiguration, $subRouteKey, $subRouteOptions);
}
$mergedRoutesConfiguration = array_merge($mergedRoutesConfiguration, $mergedSubRoutesConfiguration);
}
return $mergedRoutesConfiguration;
} | php | protected function mergeRoutesWithSubRoutes(array $routesConfiguration)
{
$mergedRoutesConfiguration = [];
foreach ($routesConfiguration as $routeConfiguration) {
if (!isset($routeConfiguration['subRoutes'])) {
$mergedRoutesConfiguration[] = $routeConfiguration;
continue;
}
$mergedSubRoutesConfiguration = [$routeConfiguration];
foreach ($routeConfiguration['subRoutes'] as $subRouteKey => $subRouteOptions) {
if (!isset($subRouteOptions['package'])) {
throw new Exception\ParseErrorException(sprintf('Missing package configuration for SubRoute in Route "%s".', (isset($routeConfiguration['name']) ? $routeConfiguration['name'] : 'unnamed Route')), 1318414040);
}
if (!isset($this->packages[$subRouteOptions['package']])) {
throw new Exception\ParseErrorException(sprintf('The SubRoute Package "%s" referenced in Route "%s" is not available.', $subRouteOptions['package'], (isset($routeConfiguration['name']) ? $routeConfiguration['name'] : 'unnamed Route')), 1318414040);
}
/** @var $package PackageInterface */
$package = $this->packages[$subRouteOptions['package']];
$subRouteFilename = 'Routes';
if (isset($subRouteOptions['suffix'])) {
$subRouteFilename .= '.' . $subRouteOptions['suffix'];
}
$subRouteConfiguration = [];
foreach (array_reverse($this->orderedListOfContextNames) as $contextName) {
$subRouteFilePathAndName = $package->getConfigurationPath() . $contextName . '/' . $subRouteFilename;
$subRouteConfiguration = array_merge($subRouteConfiguration, $this->configurationSource->load($subRouteFilePathAndName));
}
$subRouteFilePathAndName = $package->getConfigurationPath() . $subRouteFilename;
$subRouteConfiguration = array_merge($subRouteConfiguration, $this->configurationSource->load($subRouteFilePathAndName));
if ($this->subRoutesRecursionLevel > self::MAXIMUM_SUBROUTE_RECURSIONS) {
throw new Exception\RecursionException(sprintf('Recursion level of SubRoutes exceed ' . self::MAXIMUM_SUBROUTE_RECURSIONS . ', probably because of a circular reference. Last successfully loaded route configuration is "%s".', $subRouteFilePathAndName), 1361535753);
}
$this->subRoutesRecursionLevel++;
$subRouteConfiguration = $this->mergeRoutesWithSubRoutes($subRouteConfiguration);
$this->subRoutesRecursionLevel--;
$mergedSubRoutesConfiguration = $this->buildSubRouteConfigurations($mergedSubRoutesConfiguration, $subRouteConfiguration, $subRouteKey, $subRouteOptions);
}
$mergedRoutesConfiguration = array_merge($mergedRoutesConfiguration, $mergedSubRoutesConfiguration);
}
return $mergedRoutesConfiguration;
} | [
"protected",
"function",
"mergeRoutesWithSubRoutes",
"(",
"array",
"$",
"routesConfiguration",
")",
"{",
"$",
"mergedRoutesConfiguration",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"routesConfiguration",
"as",
"$",
"routeConfiguration",
")",
"{",
"if",
"(",
"!",
... | Loads specified sub routes and builds composite routes.
@param array $routesConfiguration
@return array
@throws Exception\ParseErrorException
@throws Exception\RecursionException | [
"Loads",
"specified",
"sub",
"routes",
"and",
"builds",
"composite",
"routes",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Configuration/RouteConfigurationProcessor.php#L123-L165 |
neos/flow-development-collection | Neos.Flow/Classes/Configuration/RouteConfigurationProcessor.php | RouteConfigurationProcessor.buildSubRouteConfigurations | protected function buildSubRouteConfigurations(array $routesConfiguration, array $subRoutesConfiguration, $subRouteKey, array $subRouteOptions)
{
$variables = isset($subRouteOptions['variables']) ? $subRouteOptions['variables'] : [];
$mergedSubRoutesConfigurations = [];
foreach ($subRoutesConfiguration as $subRouteConfiguration) {
foreach ($routesConfiguration as $routeConfiguration) {
$mergedSubRouteConfiguration = $subRouteConfiguration;
$mergedSubRouteConfiguration['name'] = sprintf('%s :: %s', isset($routeConfiguration['name']) ? $routeConfiguration['name'] : 'Unnamed Route', isset($subRouteConfiguration['name']) ? $subRouteConfiguration['name'] : 'Unnamed Subroute');
$mergedSubRouteConfiguration['name'] = $this->replacePlaceholders($mergedSubRouteConfiguration['name'], $variables);
if (!isset($mergedSubRouteConfiguration['uriPattern'])) {
throw new Exception\ParseErrorException('No uriPattern defined in route configuration "' . $mergedSubRouteConfiguration['name'] . '".', 1274197615);
}
if ($mergedSubRouteConfiguration['uriPattern'] !== '') {
$mergedSubRouteConfiguration['uriPattern'] = $this->replacePlaceholders($mergedSubRouteConfiguration['uriPattern'], $variables);
$mergedSubRouteConfiguration['uriPattern'] = $this->replacePlaceholders($routeConfiguration['uriPattern'], [$subRouteKey => $mergedSubRouteConfiguration['uriPattern']]);
} else {
$mergedSubRouteConfiguration['uriPattern'] = rtrim($this->replacePlaceholders($routeConfiguration['uriPattern'], [$subRouteKey => '']), '/');
}
if (isset($mergedSubRouteConfiguration['defaults'])) {
foreach ($mergedSubRouteConfiguration['defaults'] as $key => $defaultValue) {
$mergedSubRouteConfiguration['defaults'][$key] = $this->replacePlaceholders($defaultValue, $variables);
}
}
$mergedSubRouteConfiguration = Arrays::arrayMergeRecursiveOverrule($routeConfiguration, $mergedSubRouteConfiguration);
unset($mergedSubRouteConfiguration['subRoutes']);
$mergedSubRoutesConfigurations[] = $mergedSubRouteConfiguration;
}
}
return $mergedSubRoutesConfigurations;
} | php | protected function buildSubRouteConfigurations(array $routesConfiguration, array $subRoutesConfiguration, $subRouteKey, array $subRouteOptions)
{
$variables = isset($subRouteOptions['variables']) ? $subRouteOptions['variables'] : [];
$mergedSubRoutesConfigurations = [];
foreach ($subRoutesConfiguration as $subRouteConfiguration) {
foreach ($routesConfiguration as $routeConfiguration) {
$mergedSubRouteConfiguration = $subRouteConfiguration;
$mergedSubRouteConfiguration['name'] = sprintf('%s :: %s', isset($routeConfiguration['name']) ? $routeConfiguration['name'] : 'Unnamed Route', isset($subRouteConfiguration['name']) ? $subRouteConfiguration['name'] : 'Unnamed Subroute');
$mergedSubRouteConfiguration['name'] = $this->replacePlaceholders($mergedSubRouteConfiguration['name'], $variables);
if (!isset($mergedSubRouteConfiguration['uriPattern'])) {
throw new Exception\ParseErrorException('No uriPattern defined in route configuration "' . $mergedSubRouteConfiguration['name'] . '".', 1274197615);
}
if ($mergedSubRouteConfiguration['uriPattern'] !== '') {
$mergedSubRouteConfiguration['uriPattern'] = $this->replacePlaceholders($mergedSubRouteConfiguration['uriPattern'], $variables);
$mergedSubRouteConfiguration['uriPattern'] = $this->replacePlaceholders($routeConfiguration['uriPattern'], [$subRouteKey => $mergedSubRouteConfiguration['uriPattern']]);
} else {
$mergedSubRouteConfiguration['uriPattern'] = rtrim($this->replacePlaceholders($routeConfiguration['uriPattern'], [$subRouteKey => '']), '/');
}
if (isset($mergedSubRouteConfiguration['defaults'])) {
foreach ($mergedSubRouteConfiguration['defaults'] as $key => $defaultValue) {
$mergedSubRouteConfiguration['defaults'][$key] = $this->replacePlaceholders($defaultValue, $variables);
}
}
$mergedSubRouteConfiguration = Arrays::arrayMergeRecursiveOverrule($routeConfiguration, $mergedSubRouteConfiguration);
unset($mergedSubRouteConfiguration['subRoutes']);
$mergedSubRoutesConfigurations[] = $mergedSubRouteConfiguration;
}
}
return $mergedSubRoutesConfigurations;
} | [
"protected",
"function",
"buildSubRouteConfigurations",
"(",
"array",
"$",
"routesConfiguration",
",",
"array",
"$",
"subRoutesConfiguration",
",",
"$",
"subRouteKey",
",",
"array",
"$",
"subRouteOptions",
")",
"{",
"$",
"variables",
"=",
"isset",
"(",
"$",
"subRo... | Merges all routes in $routesConfiguration with the sub routes in $subRoutesConfiguration
@param array $routesConfiguration
@param array $subRoutesConfiguration
@param string $subRouteKey the key of the sub route: <subRouteKey>
@param array $subRouteOptions
@return array the merged route configuration
@throws Exception\ParseErrorException | [
"Merges",
"all",
"routes",
"in",
"$routesConfiguration",
"with",
"the",
"sub",
"routes",
"in",
"$subRoutesConfiguration"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Configuration/RouteConfigurationProcessor.php#L177-L207 |
neos/flow-development-collection | Neos.Flow/Classes/Configuration/RouteConfigurationProcessor.php | RouteConfigurationProcessor.replacePlaceholders | protected function replacePlaceholders($string, array $variables)
{
foreach ($variables as $variableName => $variableValue) {
$string = str_replace('<' . $variableName . '>', $variableValue, $string);
}
return $string;
} | php | protected function replacePlaceholders($string, array $variables)
{
foreach ($variables as $variableName => $variableValue) {
$string = str_replace('<' . $variableName . '>', $variableValue, $string);
}
return $string;
} | [
"protected",
"function",
"replacePlaceholders",
"(",
"$",
"string",
",",
"array",
"$",
"variables",
")",
"{",
"foreach",
"(",
"$",
"variables",
"as",
"$",
"variableName",
"=>",
"$",
"variableValue",
")",
"{",
"$",
"string",
"=",
"str_replace",
"(",
"'<'",
... | Replaces placeholders in the format <variableName> with the corresponding variable of the specified $variables collection.
@param string $string
@param array $variables
@return string | [
"Replaces",
"placeholders",
"in",
"the",
"format",
"<variableName",
">",
"with",
"the",
"corresponding",
"variable",
"of",
"the",
"specified",
"$variables",
"collection",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Configuration/RouteConfigurationProcessor.php#L216-L223 |
neos/flow-development-collection | Neos.Flow/Classes/Aop/AdvicesTrait.php | AdvicesTrait.Flow_Aop_Proxy_getAdviceChains | private function Flow_Aop_Proxy_getAdviceChains(string $methodName): array
{
if (isset($this->Flow_Aop_Proxy_groupedAdviceChains[$methodName])) {
return $this->Flow_Aop_Proxy_groupedAdviceChains[$methodName];
}
$adviceChains = [];
if (isset($this->Flow_Aop_Proxy_targetMethodsAndGroupedAdvices[$methodName])) {
$groupedAdvices = $this->Flow_Aop_Proxy_targetMethodsAndGroupedAdvices[$methodName];
if (isset($groupedAdvices[\Neos\Flow\Aop\Advice\AroundAdvice::class])) {
$this->Flow_Aop_Proxy_groupedAdviceChains[$methodName][\Neos\Flow\Aop\Advice\AroundAdvice::class] = new \Neos\Flow\Aop\Advice\AdviceChain($groupedAdvices[\Neos\Flow\Aop\Advice\AroundAdvice::class]);
$adviceChains = $this->Flow_Aop_Proxy_groupedAdviceChains[$methodName];
}
}
return $adviceChains;
} | php | private function Flow_Aop_Proxy_getAdviceChains(string $methodName): array
{
if (isset($this->Flow_Aop_Proxy_groupedAdviceChains[$methodName])) {
return $this->Flow_Aop_Proxy_groupedAdviceChains[$methodName];
}
$adviceChains = [];
if (isset($this->Flow_Aop_Proxy_targetMethodsAndGroupedAdvices[$methodName])) {
$groupedAdvices = $this->Flow_Aop_Proxy_targetMethodsAndGroupedAdvices[$methodName];
if (isset($groupedAdvices[\Neos\Flow\Aop\Advice\AroundAdvice::class])) {
$this->Flow_Aop_Proxy_groupedAdviceChains[$methodName][\Neos\Flow\Aop\Advice\AroundAdvice::class] = new \Neos\Flow\Aop\Advice\AdviceChain($groupedAdvices[\Neos\Flow\Aop\Advice\AroundAdvice::class]);
$adviceChains = $this->Flow_Aop_Proxy_groupedAdviceChains[$methodName];
}
}
return $adviceChains;
} | [
"private",
"function",
"Flow_Aop_Proxy_getAdviceChains",
"(",
"string",
"$",
"methodName",
")",
":",
"array",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"Flow_Aop_Proxy_groupedAdviceChains",
"[",
"$",
"methodName",
"]",
")",
")",
"{",
"return",
"$",
"thi... | Used in AOP proxies to get the advice chain for a given method.
@param string $methodName
@return array | [
"Used",
"in",
"AOP",
"proxies",
"to",
"get",
"the",
"advice",
"chain",
"for",
"a",
"given",
"method",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Aop/AdvicesTrait.php#L26-L42 |
neos/flow-development-collection | Neos.Flow/Classes/Aop/AdvicesTrait.php | AdvicesTrait.Flow_Aop_Proxy_invokeJoinPoint | public function Flow_Aop_Proxy_invokeJoinPoint(\Neos\Flow\Aop\JoinPointInterface $joinPoint)
{
if (__CLASS__ !== $joinPoint->getClassName()) {
return parent::Flow_Aop_Proxy_invokeJoinPoint($joinPoint);
}
if (isset($this->Flow_Aop_Proxy_methodIsInAdviceMode[$joinPoint->getMethodName()])) {
return call_user_func_array(['self', $joinPoint->getMethodName()], $joinPoint->getMethodArguments());
}
} | php | public function Flow_Aop_Proxy_invokeJoinPoint(\Neos\Flow\Aop\JoinPointInterface $joinPoint)
{
if (__CLASS__ !== $joinPoint->getClassName()) {
return parent::Flow_Aop_Proxy_invokeJoinPoint($joinPoint);
}
if (isset($this->Flow_Aop_Proxy_methodIsInAdviceMode[$joinPoint->getMethodName()])) {
return call_user_func_array(['self', $joinPoint->getMethodName()], $joinPoint->getMethodArguments());
}
} | [
"public",
"function",
"Flow_Aop_Proxy_invokeJoinPoint",
"(",
"\\",
"Neos",
"\\",
"Flow",
"\\",
"Aop",
"\\",
"JoinPointInterface",
"$",
"joinPoint",
")",
"{",
"if",
"(",
"__CLASS__",
"!==",
"$",
"joinPoint",
"->",
"getClassName",
"(",
")",
")",
"{",
"return",
... | Invokes a given join point
@param \Neos\Flow\Aop\JoinPointInterface $joinPoint
@return mixed | [
"Invokes",
"a",
"given",
"join",
"point"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Aop/AdvicesTrait.php#L50-L58 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.