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.Kickstarter/Classes/Command/KickstartCommandController.php | KickstartCommandController.packageCommand | public function packageCommand($packageKey, $packageType = PackageInterface::DEFAULT_COMPOSER_TYPE)
{
$this->validatePackageKey($packageKey);
if ($this->packageManager->isPackageAvailable($packageKey)) {
$this->outputLine('Package "%s" already exists.', [$packageKey]);
exit(2);
}
if (!ComposerUtility::isFlowPackageType($packageType)) {
$this->outputLine('The package must be a Flow package, but "%s" is not a valid Flow package type.', [$packageType]);
$this->quit(1);
}
$this->packageManager->createPackage($packageKey, ['type' => $packageType]);
$this->actionControllerCommand($packageKey, 'Standard');
$this->documentationCommand($packageKey);
} | php | public function packageCommand($packageKey, $packageType = PackageInterface::DEFAULT_COMPOSER_TYPE)
{
$this->validatePackageKey($packageKey);
if ($this->packageManager->isPackageAvailable($packageKey)) {
$this->outputLine('Package "%s" already exists.', [$packageKey]);
exit(2);
}
if (!ComposerUtility::isFlowPackageType($packageType)) {
$this->outputLine('The package must be a Flow package, but "%s" is not a valid Flow package type.', [$packageType]);
$this->quit(1);
}
$this->packageManager->createPackage($packageKey, ['type' => $packageType]);
$this->actionControllerCommand($packageKey, 'Standard');
$this->documentationCommand($packageKey);
} | [
"public",
"function",
"packageCommand",
"(",
"$",
"packageKey",
",",
"$",
"packageType",
"=",
"PackageInterface",
"::",
"DEFAULT_COMPOSER_TYPE",
")",
"{",
"$",
"this",
"->",
"validatePackageKey",
"(",
"$",
"packageKey",
")",
";",
"if",
"(",
"$",
"this",
"->",
... | Kickstart a new package
Creates a new package and creates a standard Action Controller and a sample
template for its Index Action.
For creating a new package without sample code use the package:create command.
@param string $packageKey The package key, for example "MyCompany.MyPackageName"
@param string $packageType Optional package type, e.g. "neos-plugin"
@return string
@see neos.flow:package:create | [
"Kickstart",
"a",
"new",
"package"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Kickstarter/Classes/Command/KickstartCommandController.php#L53-L70 |
neos/flow-development-collection | Neos.Kickstarter/Classes/Command/KickstartCommandController.php | KickstartCommandController.actionControllerCommand | public function actionControllerCommand($packageKey, $controllerName, $generateActions = false, $generateTemplates = true, $generateRelated = false, $force = false)
{
$subpackageName = '';
if (strpos($packageKey, '/') !== false) {
list($packageKey, $subpackageName) = explode('/', $packageKey, 2);
}
$this->validatePackageKey($packageKey);
if (!$this->packageManager->isPackageAvailable($packageKey)) {
if ($generateRelated === false) {
$this->outputLine('Package "%s" is not available.', [$packageKey]);
$this->outputLine('Hint: Use --generate-related for creating it!');
exit(2);
}
$this->packageManager->createPackage($packageKey);
}
$generatedFiles = [];
$generatedModels = false;
$controllerNames = Arrays::trimExplode(',', $controllerName);
if ($generateActions === true) {
foreach ($controllerNames as $currentControllerName) {
$modelClassName = str_replace('.', '\\', $packageKey) . '\Domain\Model\\' . $currentControllerName;
if (!class_exists($modelClassName)) {
if ($generateRelated === true) {
$generatedFiles += $this->generatorService->generateModel($packageKey, $currentControllerName, ['name' => ['type' => 'string']]);
$generatedModels = true;
} else {
$this->outputLine('The model %s does not exist, but is necessary for creating the respective actions.', [$modelClassName]);
$this->outputLine('Hint: Use --generate-related for creating it!');
exit(3);
}
}
$repositoryClassName = str_replace('.', '\\', $packageKey) . '\Domain\Repository\\' . $currentControllerName . 'Repository';
if (!class_exists($repositoryClassName)) {
if ($generateRelated === true) {
$generatedFiles += $this->generatorService->generateRepository($packageKey, $currentControllerName);
} else {
$this->outputLine('The repository %s does not exist, but is necessary for creating the respective actions.', [$repositoryClassName]);
$this->outputLine('Hint: Use --generate-related for creating it!');
exit(4);
}
}
}
}
foreach ($controllerNames as $currentControllerName) {
if ($generateActions === true) {
$generatedFiles += $this->generatorService->generateCrudController($packageKey, $subpackageName, $currentControllerName, $force);
} else {
$generatedFiles += $this->generatorService->generateActionController($packageKey, $subpackageName, $currentControllerName, $force);
}
if ($generateTemplates === true) {
$generatedFiles += $this->generatorService->generateLayout($packageKey, 'Default', $force);
if ($generateActions === true) {
$generatedFiles += $this->generatorService->generateView($packageKey, $subpackageName, $currentControllerName, 'Index', 'Index', $force);
$generatedFiles += $this->generatorService->generateView($packageKey, $subpackageName, $currentControllerName, 'New', 'New', $force);
$generatedFiles += $this->generatorService->generateView($packageKey, $subpackageName, $currentControllerName, 'Edit', 'Edit', $force);
$generatedFiles += $this->generatorService->generateView($packageKey, $subpackageName, $currentControllerName, 'Show', 'Show', $force);
} else {
$generatedFiles += $this->generatorService->generateView($packageKey, $subpackageName, $currentControllerName, 'Index', 'SampleIndex', $force);
}
}
}
$this->outputLine(implode(PHP_EOL, $generatedFiles));
if ($generatedModels === true) {
$this->outputLine('As new models were generated, don\'t forget to update the database schema with the respective doctrine:* commands.');
}
} | php | public function actionControllerCommand($packageKey, $controllerName, $generateActions = false, $generateTemplates = true, $generateRelated = false, $force = false)
{
$subpackageName = '';
if (strpos($packageKey, '/') !== false) {
list($packageKey, $subpackageName) = explode('/', $packageKey, 2);
}
$this->validatePackageKey($packageKey);
if (!$this->packageManager->isPackageAvailable($packageKey)) {
if ($generateRelated === false) {
$this->outputLine('Package "%s" is not available.', [$packageKey]);
$this->outputLine('Hint: Use --generate-related for creating it!');
exit(2);
}
$this->packageManager->createPackage($packageKey);
}
$generatedFiles = [];
$generatedModels = false;
$controllerNames = Arrays::trimExplode(',', $controllerName);
if ($generateActions === true) {
foreach ($controllerNames as $currentControllerName) {
$modelClassName = str_replace('.', '\\', $packageKey) . '\Domain\Model\\' . $currentControllerName;
if (!class_exists($modelClassName)) {
if ($generateRelated === true) {
$generatedFiles += $this->generatorService->generateModel($packageKey, $currentControllerName, ['name' => ['type' => 'string']]);
$generatedModels = true;
} else {
$this->outputLine('The model %s does not exist, but is necessary for creating the respective actions.', [$modelClassName]);
$this->outputLine('Hint: Use --generate-related for creating it!');
exit(3);
}
}
$repositoryClassName = str_replace('.', '\\', $packageKey) . '\Domain\Repository\\' . $currentControllerName . 'Repository';
if (!class_exists($repositoryClassName)) {
if ($generateRelated === true) {
$generatedFiles += $this->generatorService->generateRepository($packageKey, $currentControllerName);
} else {
$this->outputLine('The repository %s does not exist, but is necessary for creating the respective actions.', [$repositoryClassName]);
$this->outputLine('Hint: Use --generate-related for creating it!');
exit(4);
}
}
}
}
foreach ($controllerNames as $currentControllerName) {
if ($generateActions === true) {
$generatedFiles += $this->generatorService->generateCrudController($packageKey, $subpackageName, $currentControllerName, $force);
} else {
$generatedFiles += $this->generatorService->generateActionController($packageKey, $subpackageName, $currentControllerName, $force);
}
if ($generateTemplates === true) {
$generatedFiles += $this->generatorService->generateLayout($packageKey, 'Default', $force);
if ($generateActions === true) {
$generatedFiles += $this->generatorService->generateView($packageKey, $subpackageName, $currentControllerName, 'Index', 'Index', $force);
$generatedFiles += $this->generatorService->generateView($packageKey, $subpackageName, $currentControllerName, 'New', 'New', $force);
$generatedFiles += $this->generatorService->generateView($packageKey, $subpackageName, $currentControllerName, 'Edit', 'Edit', $force);
$generatedFiles += $this->generatorService->generateView($packageKey, $subpackageName, $currentControllerName, 'Show', 'Show', $force);
} else {
$generatedFiles += $this->generatorService->generateView($packageKey, $subpackageName, $currentControllerName, 'Index', 'SampleIndex', $force);
}
}
}
$this->outputLine(implode(PHP_EOL, $generatedFiles));
if ($generatedModels === true) {
$this->outputLine('As new models were generated, don\'t forget to update the database schema with the respective doctrine:* commands.');
}
} | [
"public",
"function",
"actionControllerCommand",
"(",
"$",
"packageKey",
",",
"$",
"controllerName",
",",
"$",
"generateActions",
"=",
"false",
",",
"$",
"generateTemplates",
"=",
"true",
",",
"$",
"generateRelated",
"=",
"false",
",",
"$",
"force",
"=",
"fals... | Kickstart a new action controller
Generates an Action Controller with the given name in the specified package.
In its default mode it will create just the controller containing a sample
indexAction.
By specifying the --generate-actions flag, this command will also create a
set of actions. If no model or repository exists which matches the
controller name (for example "CoffeeRepository" for "CoffeeController"),
an error will be shown.
Likewise the command exits with an error if the specified package does not
exist. By using the --generate-related flag, a missing package, model or
repository can be created alongside, avoiding such an error.
By specifying the --generate-templates flag, this command will also create
matching Fluid templates for the actions created. This option can only be
used in combination with --generate-actions.
The default behavior is to not overwrite any existing code. This can be
overridden by specifying the --force flag.
@param string $packageKey The package key of the package for the new controller with an optional subpackage, (e.g. "MyCompany.MyPackage/Admin").
@param string $controllerName The name for the new controller. This may also be a comma separated list of controller names.
@param boolean $generateActions Also generate index, show, new, create, edit, update and delete actions.
@param boolean $generateTemplates Also generate the templates for each action.
@param boolean $generateRelated Also create the mentioned package, related model and repository if neccessary.
@param boolean $force Overwrite any existing controller or template code. Regardless of this flag, the package, model and repository will never be overwritten.
@return string
@see neos.kickstarter:kickstart:commandcontroller | [
"Kickstart",
"a",
"new",
"action",
"controller"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Kickstarter/Classes/Command/KickstartCommandController.php#L104-L174 |
neos/flow-development-collection | Neos.Kickstarter/Classes/Command/KickstartCommandController.php | KickstartCommandController.commandControllerCommand | public function commandControllerCommand($packageKey, $controllerName, $force = false)
{
$this->validatePackageKey($packageKey);
if (!$this->packageManager->isPackageAvailable($packageKey)) {
$this->outputLine('Package "%s" is not available.', [$packageKey]);
exit(2);
}
$generatedFiles = [];
$controllerNames = Arrays::trimExplode(',', $controllerName);
foreach ($controllerNames as $currentControllerName) {
$generatedFiles += $this->generatorService->generateCommandController($packageKey, $currentControllerName, $force);
}
$this->outputLine(implode(PHP_EOL, $generatedFiles));
} | php | public function commandControllerCommand($packageKey, $controllerName, $force = false)
{
$this->validatePackageKey($packageKey);
if (!$this->packageManager->isPackageAvailable($packageKey)) {
$this->outputLine('Package "%s" is not available.', [$packageKey]);
exit(2);
}
$generatedFiles = [];
$controllerNames = Arrays::trimExplode(',', $controllerName);
foreach ($controllerNames as $currentControllerName) {
$generatedFiles += $this->generatorService->generateCommandController($packageKey, $currentControllerName, $force);
}
$this->outputLine(implode(PHP_EOL, $generatedFiles));
} | [
"public",
"function",
"commandControllerCommand",
"(",
"$",
"packageKey",
",",
"$",
"controllerName",
",",
"$",
"force",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"validatePackageKey",
"(",
"$",
"packageKey",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
... | Kickstart a new command controller
Creates a new command controller with the given name in the specified
package. The generated controller class already contains an example command.
@param string $packageKey The package key of the package for the new controller
@param string $controllerName The name for the new controller. This may also be a comma separated list of controller names.
@param boolean $force Overwrite any existing controller.
@return string
@see neos.kickstarter:kickstart:actioncontroller | [
"Kickstart",
"a",
"new",
"command",
"controller"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Kickstarter/Classes/Command/KickstartCommandController.php#L188-L201 |
neos/flow-development-collection | Neos.Kickstarter/Classes/Command/KickstartCommandController.php | KickstartCommandController.modelCommand | public function modelCommand($packageKey, $modelName, $force = false)
{
$this->validatePackageKey($packageKey);
if (!$this->packageManager->isPackageAvailable($packageKey)) {
$this->outputLine('Package "%s" is not available.', [$packageKey]);
exit(2);
}
$this->validateModelName($modelName);
$fieldsArguments = $this->request->getExceedingArguments();
$fieldDefinitions = [];
foreach ($fieldsArguments as $fieldArgument) {
list($fieldName, $fieldType) = explode(':', $fieldArgument, 2);
$fieldDefinitions[$fieldName] = ['type' => $fieldType];
if (strpos($fieldType, 'array') !== false) {
$fieldDefinitions[$fieldName]['typeHint'] = 'array';
} elseif (strpos($fieldType, '\\') !== false) {
if (strpos($fieldType, '<') !== false) {
$fieldDefinitions[$fieldName]['typeHint'] = substr($fieldType, 0, strpos($fieldType, '<'));
} else {
$fieldDefinitions[$fieldName]['typeHint'] = $fieldType;
}
}
};
$generatedFiles = $this->generatorService->generateModel($packageKey, $modelName, $fieldDefinitions, $force);
$this->outputLine(implode(PHP_EOL, $generatedFiles));
$this->outputLine('As a new model was generated, don\'t forget to update the database schema with the respective doctrine:* commands.');
} | php | public function modelCommand($packageKey, $modelName, $force = false)
{
$this->validatePackageKey($packageKey);
if (!$this->packageManager->isPackageAvailable($packageKey)) {
$this->outputLine('Package "%s" is not available.', [$packageKey]);
exit(2);
}
$this->validateModelName($modelName);
$fieldsArguments = $this->request->getExceedingArguments();
$fieldDefinitions = [];
foreach ($fieldsArguments as $fieldArgument) {
list($fieldName, $fieldType) = explode(':', $fieldArgument, 2);
$fieldDefinitions[$fieldName] = ['type' => $fieldType];
if (strpos($fieldType, 'array') !== false) {
$fieldDefinitions[$fieldName]['typeHint'] = 'array';
} elseif (strpos($fieldType, '\\') !== false) {
if (strpos($fieldType, '<') !== false) {
$fieldDefinitions[$fieldName]['typeHint'] = substr($fieldType, 0, strpos($fieldType, '<'));
} else {
$fieldDefinitions[$fieldName]['typeHint'] = $fieldType;
}
}
};
$generatedFiles = $this->generatorService->generateModel($packageKey, $modelName, $fieldDefinitions, $force);
$this->outputLine(implode(PHP_EOL, $generatedFiles));
$this->outputLine('As a new model was generated, don\'t forget to update the database schema with the respective doctrine:* commands.');
} | [
"public",
"function",
"modelCommand",
"(",
"$",
"packageKey",
",",
"$",
"modelName",
",",
"$",
"force",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"validatePackageKey",
"(",
"$",
"packageKey",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"packageManager"... | Kickstart a new domain model
This command generates a new domain model class. The fields are specified as
a variable list of arguments with field name and type separated by a colon
(for example "title:string" "size:int" "type:MyType").
@param string $packageKey The package key of the package for the domain model
@param string $modelName The name of the new domain model class
@param boolean $force Overwrite any existing model.
@return string
@see neos.kickstarter:kickstart:repository | [
"Kickstart",
"a",
"new",
"domain",
"model"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Kickstarter/Classes/Command/KickstartCommandController.php#L216-L246 |
neos/flow-development-collection | Neos.Kickstarter/Classes/Command/KickstartCommandController.php | KickstartCommandController.repositoryCommand | public function repositoryCommand($packageKey, $modelName, $force = false)
{
$this->validatePackageKey($packageKey);
if (!$this->packageManager->isPackageAvailable($packageKey)) {
$this->outputLine('Package "%s" is not available.', [$packageKey]);
exit(2);
}
$generatedFiles = $this->generatorService->generateRepository($packageKey, $modelName, $force);
$this->outputLine(implode(PHP_EOL, $generatedFiles));
} | php | public function repositoryCommand($packageKey, $modelName, $force = false)
{
$this->validatePackageKey($packageKey);
if (!$this->packageManager->isPackageAvailable($packageKey)) {
$this->outputLine('Package "%s" is not available.', [$packageKey]);
exit(2);
}
$generatedFiles = $this->generatorService->generateRepository($packageKey, $modelName, $force);
$this->outputLine(implode(PHP_EOL, $generatedFiles));
} | [
"public",
"function",
"repositoryCommand",
"(",
"$",
"packageKey",
",",
"$",
"modelName",
",",
"$",
"force",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"validatePackageKey",
"(",
"$",
"packageKey",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"packageMan... | Kickstart a new domain repository
This command generates a new domain repository class for the given model name.
@param string $packageKey The package key
@param string $modelName The name of the domain model class
@param boolean $force Overwrite any existing repository.
@return string
@see neos.kickstarter:kickstart:model | [
"Kickstart",
"a",
"new",
"domain",
"repository"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Kickstarter/Classes/Command/KickstartCommandController.php#L259-L269 |
neos/flow-development-collection | Neos.Kickstarter/Classes/Command/KickstartCommandController.php | KickstartCommandController.documentationCommand | public function documentationCommand($packageKey)
{
$this->validatePackageKey($packageKey);
if (!$this->packageManager->isPackageAvailable($packageKey)) {
$this->outputLine('Package "%s" is not available.', [$packageKey]);
exit(2);
}
$generatedFiles = $this->generatorService->generateDocumentation($packageKey);
$this->outputLine(implode(PHP_EOL, $generatedFiles));
} | php | public function documentationCommand($packageKey)
{
$this->validatePackageKey($packageKey);
if (!$this->packageManager->isPackageAvailable($packageKey)) {
$this->outputLine('Package "%s" is not available.', [$packageKey]);
exit(2);
}
$generatedFiles = $this->generatorService->generateDocumentation($packageKey);
$this->outputLine(implode(PHP_EOL, $generatedFiles));
} | [
"public",
"function",
"documentationCommand",
"(",
"$",
"packageKey",
")",
"{",
"$",
"this",
"->",
"validatePackageKey",
"(",
"$",
"packageKey",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"packageManager",
"->",
"isPackageAvailable",
"(",
"$",
"packageKey",
... | Kickstart documentation
Generates a documentation skeleton for the given package.
@param string $packageKey The package key of the package for the documentation
@return string | [
"Kickstart",
"documentation"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Kickstarter/Classes/Command/KickstartCommandController.php#L279-L290 |
neos/flow-development-collection | Neos.Kickstarter/Classes/Command/KickstartCommandController.php | KickstartCommandController.translationCommand | public function translationCommand($packageKey, $sourceLanguageKey, array $targetLanguageKeys = [])
{
$this->validatePackageKey($packageKey);
if (!$this->packageManager->isPackageAvailable($packageKey)) {
$this->outputLine('Package "%s" is not available.', [$packageKey]);
exit(2);
}
$generateFiles = $this->generatorService->generateTranslation($packageKey, $sourceLanguageKey, $targetLanguageKeys);
$this->outputLine(implode(PHP_EOL, $generateFiles));
} | php | public function translationCommand($packageKey, $sourceLanguageKey, array $targetLanguageKeys = [])
{
$this->validatePackageKey($packageKey);
if (!$this->packageManager->isPackageAvailable($packageKey)) {
$this->outputLine('Package "%s" is not available.', [$packageKey]);
exit(2);
}
$generateFiles = $this->generatorService->generateTranslation($packageKey, $sourceLanguageKey, $targetLanguageKeys);
$this->outputLine(implode(PHP_EOL, $generateFiles));
} | [
"public",
"function",
"translationCommand",
"(",
"$",
"packageKey",
",",
"$",
"sourceLanguageKey",
",",
"array",
"$",
"targetLanguageKeys",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"validatePackageKey",
"(",
"$",
"packageKey",
")",
";",
"if",
"(",
"!",
... | Kickstart translation
Generates the translation files for the given package.
@param string $packageKey The package key of the package for the translation
@param string $sourceLanguageKey The language key of the default language
@param array $targetLanguageKeys Comma separated language keys for the target translations
@return void | [
"Kickstart",
"translation"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Kickstarter/Classes/Command/KickstartCommandController.php#L302-L313 |
neos/flow-development-collection | Neos.Kickstarter/Classes/Command/KickstartCommandController.php | KickstartCommandController.validatePackageKey | protected function validatePackageKey($packageKey)
{
if (!$this->packageManager->isPackageKeyValid($packageKey)) {
$this->outputLine('Package key "%s" is not valid. Only UpperCamelCase with alphanumeric characters in the format <VendorName>.<PackageKey>, please!', [$packageKey]);
exit(1);
}
} | php | protected function validatePackageKey($packageKey)
{
if (!$this->packageManager->isPackageKeyValid($packageKey)) {
$this->outputLine('Package key "%s" is not valid. Only UpperCamelCase with alphanumeric characters in the format <VendorName>.<PackageKey>, please!', [$packageKey]);
exit(1);
}
} | [
"protected",
"function",
"validatePackageKey",
"(",
"$",
"packageKey",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"packageManager",
"->",
"isPackageKeyValid",
"(",
"$",
"packageKey",
")",
")",
"{",
"$",
"this",
"->",
"outputLine",
"(",
"'Package key \"%s\" i... | Checks the syntax of the given $packageKey and quits with an error message if it's not valid
@param string $packageKey
@return void | [
"Checks",
"the",
"syntax",
"of",
"the",
"given",
"$packageKey",
"and",
"quits",
"with",
"an",
"error",
"message",
"if",
"it",
"s",
"not",
"valid"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Kickstarter/Classes/Command/KickstartCommandController.php#L321-L327 |
neos/flow-development-collection | Neos.Kickstarter/Classes/Command/KickstartCommandController.php | KickstartCommandController.validateModelName | protected function validateModelName($modelName)
{
if (Validation::isReservedKeyword($modelName)) {
$this->outputLine('The name of the model cannot be one of the reserved words of PHP!');
$this->outputLine('Have a look at: http://www.php.net/manual/en/reserved.keywords.php');
exit(3);
}
} | php | protected function validateModelName($modelName)
{
if (Validation::isReservedKeyword($modelName)) {
$this->outputLine('The name of the model cannot be one of the reserved words of PHP!');
$this->outputLine('Have a look at: http://www.php.net/manual/en/reserved.keywords.php');
exit(3);
}
} | [
"protected",
"function",
"validateModelName",
"(",
"$",
"modelName",
")",
"{",
"if",
"(",
"Validation",
"::",
"isReservedKeyword",
"(",
"$",
"modelName",
")",
")",
"{",
"$",
"this",
"->",
"outputLine",
"(",
"'The name of the model cannot be one of the reserved words o... | Check the given model name to be not one of the reserved words of PHP.
@param string $modelName
@return boolean
@see http://www.php.net/manual/en/reserved.keywords.php | [
"Check",
"the",
"given",
"model",
"name",
"to",
"be",
"not",
"one",
"of",
"the",
"reserved",
"words",
"of",
"PHP",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Kickstarter/Classes/Command/KickstartCommandController.php#L336-L343 |
neos/flow-development-collection | Neos.Flow/Scripts/Migrations/AbstractMigration.php | AbstractMigration.getDescription | public function getDescription()
{
$reflectionClass = new \ReflectionClass($this);
$lines = explode(chr(10), $reflectionClass->getDocComment());
foreach ($lines as $line) {
$line = trim($line);
if ($line === '' || $line === '/**' || $line === '*' || $line === '*/' || strpos($line, '* @') !== false) {
continue;
}
return preg_replace('/\s*\\/?[\\\\*]*\s?(.*)$/', '$1', $line);
}
} | php | public function getDescription()
{
$reflectionClass = new \ReflectionClass($this);
$lines = explode(chr(10), $reflectionClass->getDocComment());
foreach ($lines as $line) {
$line = trim($line);
if ($line === '' || $line === '/**' || $line === '*' || $line === '*/' || strpos($line, '* @') !== false) {
continue;
}
return preg_replace('/\s*\\/?[\\\\*]*\s?(.*)$/', '$1', $line);
}
} | [
"public",
"function",
"getDescription",
"(",
")",
"{",
"$",
"reflectionClass",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"this",
")",
";",
"$",
"lines",
"=",
"explode",
"(",
"chr",
"(",
"10",
")",
",",
"$",
"reflectionClass",
"->",
"getDocComment",
... | Returns the first line of the migration class doc comment
@return string | [
"Returns",
"the",
"first",
"line",
"of",
"the",
"migration",
"class",
"doc",
"comment"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Scripts/Migrations/AbstractMigration.php#L108-L119 |
neos/flow-development-collection | Neos.Flow/Scripts/Migrations/AbstractMigration.php | AbstractMigration.searchAndReplace | protected function searchAndReplace($search, $replacement, $filter = array('php', 'yaml', 'html'))
{
$this->operations['searchAndReplace'][] = array($search, $replacement, $filter, false);
} | php | protected function searchAndReplace($search, $replacement, $filter = array('php', 'yaml', 'html'))
{
$this->operations['searchAndReplace'][] = array($search, $replacement, $filter, false);
} | [
"protected",
"function",
"searchAndReplace",
"(",
"$",
"search",
",",
"$",
"replacement",
",",
"$",
"filter",
"=",
"array",
"(",
"'php'",
",",
"'yaml'",
",",
"'html'",
")",
")",
"{",
"$",
"this",
"->",
"operations",
"[",
"'searchAndReplace'",
"]",
"[",
"... | Does a simple search and replace on all (textual) files. The filter array can be
used to give file extensions to limit the operation to.
@param string $search
@param string $replacement
@param array|string $filter either an array with file extensions to consider or the full path to a single file to process
@return void
@api | [
"Does",
"a",
"simple",
"search",
"and",
"replace",
"on",
"all",
"(",
"textual",
")",
"files",
".",
"The",
"filter",
"array",
"can",
"be",
"used",
"to",
"give",
"file",
"extensions",
"to",
"limit",
"the",
"operation",
"to",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Scripts/Migrations/AbstractMigration.php#L218-L221 |
neos/flow-development-collection | Neos.Flow/Scripts/Migrations/AbstractMigration.php | AbstractMigration.searchAndReplaceRegex | protected function searchAndReplaceRegex($search, $replacement, $filter = array('php', 'yaml', 'html'))
{
$this->operations['searchAndReplace'][] = array($search, $replacement, $filter, true);
} | php | protected function searchAndReplaceRegex($search, $replacement, $filter = array('php', 'yaml', 'html'))
{
$this->operations['searchAndReplace'][] = array($search, $replacement, $filter, true);
} | [
"protected",
"function",
"searchAndReplaceRegex",
"(",
"$",
"search",
",",
"$",
"replacement",
",",
"$",
"filter",
"=",
"array",
"(",
"'php'",
",",
"'yaml'",
",",
"'html'",
")",
")",
"{",
"$",
"this",
"->",
"operations",
"[",
"'searchAndReplace'",
"]",
"["... | Does a regex search and replace on all (textual) files. The filter array can be
used to give file extensions to limit the operation to.
The patterns are used as is, no quoting is done. A closure can be given for
the $replacement variable. It should return a string and is given an
array of matches as parameter.
@param string $search
@param string|\Closure $replacement
@param array|string $filter either an array with file extensions to consider or the full path to a single file to process
@return void
@api | [
"Does",
"a",
"regex",
"search",
"and",
"replace",
"on",
"all",
"(",
"textual",
")",
"files",
".",
"The",
"filter",
"array",
"can",
"be",
"used",
"to",
"give",
"file",
"extensions",
"to",
"limit",
"the",
"operation",
"to",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Scripts/Migrations/AbstractMigration.php#L237-L240 |
neos/flow-development-collection | Neos.Flow/Scripts/Migrations/AbstractMigration.php | AbstractMigration.processConfiguration | protected function processConfiguration($configurationType, \Closure $processor, $saveResult = false)
{
if (is_dir($this->targetPackageData['path'] . '/Configuration') === false) {
return;
}
$yamlPathsAndFilenames = Files::readDirectoryRecursively($this->targetPackageData['path'] . '/Configuration', 'yaml', true);
$configurationPathsAndFilenames = array_filter($yamlPathsAndFilenames,
function ($pathAndFileName) use ($configurationType) {
if (strpos(basename($pathAndFileName, '.yaml'), $configurationType) === 0) {
return true;
} else {
return false;
}
}
);
$yamlSource = new YamlSource();
foreach ($configurationPathsAndFilenames as $pathAndFilename) {
$originalConfiguration = $configuration = $yamlSource->load(substr($pathAndFilename, 0, -5));
$processor($configuration);
if ($saveResult === true && $configuration !== $originalConfiguration) {
$yamlSource->save(substr($pathAndFilename, 0, -5), $configuration);
}
}
} | php | protected function processConfiguration($configurationType, \Closure $processor, $saveResult = false)
{
if (is_dir($this->targetPackageData['path'] . '/Configuration') === false) {
return;
}
$yamlPathsAndFilenames = Files::readDirectoryRecursively($this->targetPackageData['path'] . '/Configuration', 'yaml', true);
$configurationPathsAndFilenames = array_filter($yamlPathsAndFilenames,
function ($pathAndFileName) use ($configurationType) {
if (strpos(basename($pathAndFileName, '.yaml'), $configurationType) === 0) {
return true;
} else {
return false;
}
}
);
$yamlSource = new YamlSource();
foreach ($configurationPathsAndFilenames as $pathAndFilename) {
$originalConfiguration = $configuration = $yamlSource->load(substr($pathAndFilename, 0, -5));
$processor($configuration);
if ($saveResult === true && $configuration !== $originalConfiguration) {
$yamlSource->save(substr($pathAndFilename, 0, -5), $configuration);
}
}
} | [
"protected",
"function",
"processConfiguration",
"(",
"$",
"configurationType",
",",
"\\",
"Closure",
"$",
"processor",
",",
"$",
"saveResult",
"=",
"false",
")",
"{",
"if",
"(",
"is_dir",
"(",
"$",
"this",
"->",
"targetPackageData",
"[",
"'path'",
"]",
".",... | Apply the given processor to the raw results of loading the given configuration
type for the package from YAML. If multiple files exist (context configuration)
all are processed independently.
@param string $configurationType One of ConfigurationManager::CONFIGURATION_TYPE_*
@param \Closure $processor
@param boolean $saveResult
@return void | [
"Apply",
"the",
"given",
"processor",
"to",
"the",
"raw",
"results",
"of",
"loading",
"the",
"given",
"configuration",
"type",
"for",
"the",
"package",
"from",
"YAML",
".",
"If",
"multiple",
"files",
"exist",
"(",
"context",
"configuration",
")",
"all",
"are... | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Scripts/Migrations/AbstractMigration.php#L313-L338 |
neos/flow-development-collection | Neos.Flow/Scripts/Migrations/AbstractMigration.php | AbstractMigration.moveSettingsPaths | protected function moveSettingsPaths($sourcePath, $destinationPath)
{
$this->processConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS,
function (array &$configuration) use ($sourcePath, $destinationPath) {
$sourceConfigurationValue = Arrays::getValueByPath($configuration, $sourcePath);
$destinationConfigurationValue = Arrays::getValueByPath($configuration, $destinationPath);
if ($sourceConfigurationValue !== null) {
// source exists, so we need to move source to destination.
if ($destinationConfigurationValue !== null) {
// target exists as well; we need to MERGE source and target.
$destinationConfigurationValue = Arrays::arrayMergeRecursiveOverrule($sourceConfigurationValue, $destinationConfigurationValue);
} else {
// target does NOT exist; we directly set target = source
$destinationConfigurationValue = $sourceConfigurationValue;
}
// set the config on the new path
$configuration = Arrays::setValueByPath($configuration, $destinationPath, $destinationConfigurationValue);
// Unset the old configuration
$configuration = Arrays::unsetValueByPath($configuration, $sourcePath);
// remove empty keys before our removed key (if it exists)
$sourcePathExploded = explode('.', $sourcePath);
for ($length = count($sourcePathExploded) - 1; $length > 0; $length--) {
$temporaryPath = array_slice($sourcePathExploded, 0, $length);
$valueAtPath = Arrays::getValueByPath($configuration, $temporaryPath);
if (empty($valueAtPath)) {
$configuration = Arrays::unsetValueByPath($configuration, $temporaryPath);
} else {
break;
}
}
}
},
true
);
} | php | protected function moveSettingsPaths($sourcePath, $destinationPath)
{
$this->processConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS,
function (array &$configuration) use ($sourcePath, $destinationPath) {
$sourceConfigurationValue = Arrays::getValueByPath($configuration, $sourcePath);
$destinationConfigurationValue = Arrays::getValueByPath($configuration, $destinationPath);
if ($sourceConfigurationValue !== null) {
// source exists, so we need to move source to destination.
if ($destinationConfigurationValue !== null) {
// target exists as well; we need to MERGE source and target.
$destinationConfigurationValue = Arrays::arrayMergeRecursiveOverrule($sourceConfigurationValue, $destinationConfigurationValue);
} else {
// target does NOT exist; we directly set target = source
$destinationConfigurationValue = $sourceConfigurationValue;
}
// set the config on the new path
$configuration = Arrays::setValueByPath($configuration, $destinationPath, $destinationConfigurationValue);
// Unset the old configuration
$configuration = Arrays::unsetValueByPath($configuration, $sourcePath);
// remove empty keys before our removed key (if it exists)
$sourcePathExploded = explode('.', $sourcePath);
for ($length = count($sourcePathExploded) - 1; $length > 0; $length--) {
$temporaryPath = array_slice($sourcePathExploded, 0, $length);
$valueAtPath = Arrays::getValueByPath($configuration, $temporaryPath);
if (empty($valueAtPath)) {
$configuration = Arrays::unsetValueByPath($configuration, $temporaryPath);
} else {
break;
}
}
}
},
true
);
} | [
"protected",
"function",
"moveSettingsPaths",
"(",
"$",
"sourcePath",
",",
"$",
"destinationPath",
")",
"{",
"$",
"this",
"->",
"processConfiguration",
"(",
"ConfigurationManager",
"::",
"CONFIGURATION_TYPE_SETTINGS",
",",
"function",
"(",
"array",
"&",
"$",
"config... | Move a settings path from "source" to "destination"; best to be used when package names change.
@param string $sourcePath
@param string $destinationPath | [
"Move",
"a",
"settings",
"path",
"from",
"source",
"to",
"destination",
";",
"best",
"to",
"be",
"used",
"when",
"package",
"names",
"change",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Scripts/Migrations/AbstractMigration.php#L346-L386 |
neos/flow-development-collection | Neos.Flow/Scripts/Migrations/AbstractMigration.php | AbstractMigration.applySearchAndReplaceOperations | protected function applySearchAndReplaceOperations()
{
foreach (Files::getRecursiveDirectoryGenerator($this->targetPackageData['path'], null, true) as $pathAndFilename) {
$pathInfo = pathinfo($pathAndFilename);
if (!isset($pathInfo['filename'])) {
continue;
}
if (strpos($pathAndFilename, 'Migrations/Code') !== false) {
continue;
}
foreach ($this->operations['searchAndReplace'] as $operation) {
list($search, $replacement, $filter, $regularExpression) = $operation;
if (is_array($filter)) {
if ($filter !== array() && (!isset($pathInfo['extension']) || !in_array($pathInfo['extension'], $filter, true))) {
continue;
}
} elseif (substr($pathAndFilename, -strlen($filter)) !== $filter) {
continue;
}
Tools::searchAndReplace($search, $replacement, $pathAndFilename, $regularExpression);
}
}
} | php | protected function applySearchAndReplaceOperations()
{
foreach (Files::getRecursiveDirectoryGenerator($this->targetPackageData['path'], null, true) as $pathAndFilename) {
$pathInfo = pathinfo($pathAndFilename);
if (!isset($pathInfo['filename'])) {
continue;
}
if (strpos($pathAndFilename, 'Migrations/Code') !== false) {
continue;
}
foreach ($this->operations['searchAndReplace'] as $operation) {
list($search, $replacement, $filter, $regularExpression) = $operation;
if (is_array($filter)) {
if ($filter !== array() && (!isset($pathInfo['extension']) || !in_array($pathInfo['extension'], $filter, true))) {
continue;
}
} elseif (substr($pathAndFilename, -strlen($filter)) !== $filter) {
continue;
}
Tools::searchAndReplace($search, $replacement, $pathAndFilename, $regularExpression);
}
}
} | [
"protected",
"function",
"applySearchAndReplaceOperations",
"(",
")",
"{",
"foreach",
"(",
"Files",
"::",
"getRecursiveDirectoryGenerator",
"(",
"$",
"this",
"->",
"targetPackageData",
"[",
"'path'",
"]",
",",
"null",
",",
"true",
")",
"as",
"$",
"pathAndFilename"... | Applies all registered searchAndReplace operations.
@return void | [
"Applies",
"all",
"registered",
"searchAndReplace",
"operations",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Scripts/Migrations/AbstractMigration.php#L393-L416 |
neos/flow-development-collection | Neos.Flow/Scripts/Migrations/AbstractMigration.php | AbstractMigration.applyFileOperations | protected function applyFileOperations()
{
foreach ($this->operations['moveFile'] as $operation) {
$oldPath = Files::concatenatePaths(array($this->targetPackageData['path'] . '/' . $operation[0]));
$newPath = Files::concatenatePaths(array($this->targetPackageData['path'] . '/' . $operation[1]));
if (substr($oldPath, -1) === '*') {
$oldPath = substr($oldPath, 0, -1);
if (!file_exists($oldPath)) {
continue;
}
if (!file_exists($newPath)) {
Files::createDirectoryRecursively($newPath);
}
if (!is_dir($newPath)) {
continue;
}
foreach (Files::getRecursiveDirectoryGenerator($this->targetPackageData['path'], null, true) as $pathAndFilename) {
if (substr_compare($pathAndFilename, $oldPath, 0, strlen($oldPath)) === 0) {
$relativePathAndFilename = substr($pathAndFilename, strlen($oldPath));
if (!is_dir(dirname(Files::concatenatePaths(array($newPath, $relativePathAndFilename))))) {
Files::createDirectoryRecursively(dirname(Files::concatenatePaths(array($newPath, $relativePathAndFilename))));
}
Git::move($pathAndFilename, Files::concatenatePaths(array($newPath, $relativePathAndFilename)));
}
}
} else {
$oldPath = Files::concatenatePaths(array($this->targetPackageData['path'] . '/' . $operation[0]));
if (!file_exists($oldPath)) {
continue;
}
$newPath = Files::concatenatePaths(array($this->targetPackageData['path'] . '/' . $operation[1]));
Git::move($oldPath, $newPath);
}
}
foreach ($this->operations['deleteFile'] as $operation) {
$filename = Files::concatenatePaths(array($this->targetPackageData['path'] . '/' . $operation[0]));
if (file_exists($filename)) {
Git::remove($filename);
}
}
} | php | protected function applyFileOperations()
{
foreach ($this->operations['moveFile'] as $operation) {
$oldPath = Files::concatenatePaths(array($this->targetPackageData['path'] . '/' . $operation[0]));
$newPath = Files::concatenatePaths(array($this->targetPackageData['path'] . '/' . $operation[1]));
if (substr($oldPath, -1) === '*') {
$oldPath = substr($oldPath, 0, -1);
if (!file_exists($oldPath)) {
continue;
}
if (!file_exists($newPath)) {
Files::createDirectoryRecursively($newPath);
}
if (!is_dir($newPath)) {
continue;
}
foreach (Files::getRecursiveDirectoryGenerator($this->targetPackageData['path'], null, true) as $pathAndFilename) {
if (substr_compare($pathAndFilename, $oldPath, 0, strlen($oldPath)) === 0) {
$relativePathAndFilename = substr($pathAndFilename, strlen($oldPath));
if (!is_dir(dirname(Files::concatenatePaths(array($newPath, $relativePathAndFilename))))) {
Files::createDirectoryRecursively(dirname(Files::concatenatePaths(array($newPath, $relativePathAndFilename))));
}
Git::move($pathAndFilename, Files::concatenatePaths(array($newPath, $relativePathAndFilename)));
}
}
} else {
$oldPath = Files::concatenatePaths(array($this->targetPackageData['path'] . '/' . $operation[0]));
if (!file_exists($oldPath)) {
continue;
}
$newPath = Files::concatenatePaths(array($this->targetPackageData['path'] . '/' . $operation[1]));
Git::move($oldPath, $newPath);
}
}
foreach ($this->operations['deleteFile'] as $operation) {
$filename = Files::concatenatePaths(array($this->targetPackageData['path'] . '/' . $operation[0]));
if (file_exists($filename)) {
Git::remove($filename);
}
}
} | [
"protected",
"function",
"applyFileOperations",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"operations",
"[",
"'moveFile'",
"]",
"as",
"$",
"operation",
")",
"{",
"$",
"oldPath",
"=",
"Files",
"::",
"concatenatePaths",
"(",
"array",
"(",
"$",
"this"... | Applies all registered moveFile operations.
@return void | [
"Applies",
"all",
"registered",
"moveFile",
"operations",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Scripts/Migrations/AbstractMigration.php#L423-L465 |
neos/flow-development-collection | Neos.Flow/Classes/Reflection/ParameterReflection.php | ParameterReflection.getClass | public function getClass()
{
try {
$class = parent::getClass();
} catch (\Exception $exception) {
return null;
}
return is_object($class) ? new ClassReflection($class->getName()) : null;
} | php | public function getClass()
{
try {
$class = parent::getClass();
} catch (\Exception $exception) {
return null;
}
return is_object($class) ? new ClassReflection($class->getName()) : null;
} | [
"public",
"function",
"getClass",
"(",
")",
"{",
"try",
"{",
"$",
"class",
"=",
"parent",
"::",
"getClass",
"(",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"exception",
")",
"{",
"return",
"null",
";",
"}",
"return",
"is_object",
"(",
"$",
... | Returns the parameter class
@return ClassReflection The parameter class | [
"Returns",
"the",
"parameter",
"class"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Reflection/ParameterReflection.php#L43-L52 |
neos/flow-development-collection | Neos.Flow/Scripts/Migrations/Git.php | Git.isWorkingCopyRoot | public static function isWorkingCopyRoot($path)
{
if (!self::isWorkingCopy($path)) {
return false;
}
chdir($path);
$output = array();
exec('git rev-parse --show-cdup', $output);
return implode('', $output) === '';
} | php | public static function isWorkingCopyRoot($path)
{
if (!self::isWorkingCopy($path)) {
return false;
}
chdir($path);
$output = array();
exec('git rev-parse --show-cdup', $output);
return implode('', $output) === '';
} | [
"public",
"static",
"function",
"isWorkingCopyRoot",
"(",
"$",
"path",
")",
"{",
"if",
"(",
"!",
"self",
"::",
"isWorkingCopy",
"(",
"$",
"path",
")",
")",
"{",
"return",
"false",
";",
"}",
"chdir",
"(",
"$",
"path",
")",
";",
"$",
"output",
"=",
"... | Check whether the given $path points to the top-level of a git repository
@param string $path
@return boolean | [
"Check",
"whether",
"the",
"given",
"$path",
"points",
"to",
"the",
"top",
"-",
"level",
"of",
"a",
"git",
"repository"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Scripts/Migrations/Git.php#L38-L47 |
neos/flow-development-collection | Neos.Flow/Scripts/Migrations/Git.php | Git.getLog | public static function getLog($path, $searchTerm = null)
{
$output = array();
chdir($path);
if ($searchTerm !== null) {
exec('git log -F --grep=' . escapeshellarg($searchTerm), $output);
} else {
exec('git log', $output);
}
return $output;
} | php | public static function getLog($path, $searchTerm = null)
{
$output = array();
chdir($path);
if ($searchTerm !== null) {
exec('git log -F --grep=' . escapeshellarg($searchTerm), $output);
} else {
exec('git log', $output);
}
return $output;
} | [
"public",
"static",
"function",
"getLog",
"(",
"$",
"path",
",",
"$",
"searchTerm",
"=",
"null",
")",
"{",
"$",
"output",
"=",
"array",
"(",
")",
";",
"chdir",
"(",
"$",
"path",
")",
";",
"if",
"(",
"$",
"searchTerm",
"!==",
"null",
")",
"{",
"ex... | Returns the git log for the specified $path, optionally filtered for $searchTerm
@param string $path
@param string $searchTerm optional term to filter the log for
@return array | [
"Returns",
"the",
"git",
"log",
"for",
"the",
"specified",
"$path",
"optionally",
"filtered",
"for",
"$searchTerm"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Scripts/Migrations/Git.php#L155-L165 |
neos/flow-development-collection | Neos.Flow/Classes/Utility/Environment.php | Environment.getPathToTemporaryDirectory | public function getPathToTemporaryDirectory()
{
if ($this->temporaryDirectory !== null) {
return $this->temporaryDirectory;
}
$this->temporaryDirectory = $this->createTemporaryDirectory($this->temporaryDirectoryBase);
return $this->temporaryDirectory;
} | php | public function getPathToTemporaryDirectory()
{
if ($this->temporaryDirectory !== null) {
return $this->temporaryDirectory;
}
$this->temporaryDirectory = $this->createTemporaryDirectory($this->temporaryDirectoryBase);
return $this->temporaryDirectory;
} | [
"public",
"function",
"getPathToTemporaryDirectory",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"temporaryDirectory",
"!==",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"temporaryDirectory",
";",
"}",
"$",
"this",
"->",
"temporaryDirectory",
"=",
"$",
"... | Returns the full path to Flow's temporary directory.
@return string Path to PHP's temporary directory
@api | [
"Returns",
"the",
"full",
"path",
"to",
"Flow",
"s",
"temporary",
"directory",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Utility/Environment.php#L79-L88 |
neos/flow-development-collection | Neos.Flow/Classes/Utility/Environment.php | Environment.createTemporaryDirectory | protected function createTemporaryDirectory($temporaryDirectoryBase)
{
$temporaryDirectoryBase = Files::getUnixStylePath($temporaryDirectoryBase);
if (substr($temporaryDirectoryBase, -1, 1) !== '/') {
$temporaryDirectoryBase .= '/';
}
$temporaryDirectory = $temporaryDirectoryBase . str_replace('/', '/SubContext', (string)$this->context) . '/';
if (!is_dir($temporaryDirectory) && !is_link($temporaryDirectory)) {
try {
Files::createDirectoryRecursively($temporaryDirectory);
} catch (ErrorException $exception) {
throw new UtilityException('The temporary directory "' . $temporaryDirectory . '" could not be created. Please make sure permissions are correct for this path or define another temporary directory in your Settings.yaml with the path "Neos.Flow.utility.environment.temporaryDirectoryBase".', 1335382361);
}
}
if (!is_writable($temporaryDirectory)) {
throw new UtilityException('The temporary directory "' . $temporaryDirectory . '" is not writable. Please make this directory writable or define another temporary directory in your Settings.yaml with the path "Neos.Flow.utility.environment.temporaryDirectoryBase".', 1216287176);
}
return $temporaryDirectory;
} | php | protected function createTemporaryDirectory($temporaryDirectoryBase)
{
$temporaryDirectoryBase = Files::getUnixStylePath($temporaryDirectoryBase);
if (substr($temporaryDirectoryBase, -1, 1) !== '/') {
$temporaryDirectoryBase .= '/';
}
$temporaryDirectory = $temporaryDirectoryBase . str_replace('/', '/SubContext', (string)$this->context) . '/';
if (!is_dir($temporaryDirectory) && !is_link($temporaryDirectory)) {
try {
Files::createDirectoryRecursively($temporaryDirectory);
} catch (ErrorException $exception) {
throw new UtilityException('The temporary directory "' . $temporaryDirectory . '" could not be created. Please make sure permissions are correct for this path or define another temporary directory in your Settings.yaml with the path "Neos.Flow.utility.environment.temporaryDirectoryBase".', 1335382361);
}
}
if (!is_writable($temporaryDirectory)) {
throw new UtilityException('The temporary directory "' . $temporaryDirectory . '" is not writable. Please make this directory writable or define another temporary directory in your Settings.yaml with the path "Neos.Flow.utility.environment.temporaryDirectoryBase".', 1216287176);
}
return $temporaryDirectory;
} | [
"protected",
"function",
"createTemporaryDirectory",
"(",
"$",
"temporaryDirectoryBase",
")",
"{",
"$",
"temporaryDirectoryBase",
"=",
"Files",
"::",
"getUnixStylePath",
"(",
"$",
"temporaryDirectoryBase",
")",
";",
"if",
"(",
"substr",
"(",
"$",
"temporaryDirectoryBa... | Creates Flow's temporary directory - or at least asserts that it exists and is
writable.
For each Flow Application Context, we create an extra temporary folder,
and for nested contexts, the folders are prefixed with "SubContext" to
avoid ambiguity, and look like: Data/Temporary/Production/SubContextLive
@param string $temporaryDirectoryBase Full path to the base for the temporary directory
@return string The full path to the temporary directory
@throws UtilityException if the temporary directory could not be created or is not writable | [
"Creates",
"Flow",
"s",
"temporary",
"directory",
"-",
"or",
"at",
"least",
"asserts",
"that",
"it",
"exists",
"and",
"is",
"writable",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Utility/Environment.php#L122-L143 |
neos/flow-development-collection | Neos.Eel/Classes/FlowQuery/Operations/Object/PropertyOperation.php | PropertyOperation.evaluate | public function evaluate(FlowQuery $flowQuery, array $arguments)
{
if (!isset($arguments[0]) || empty($arguments[0]) || !is_string($arguments[0])) {
throw new FlowQueryException('property() must be given an attribute name when used on objects, fetching all attributes is not supported.', 1332492263);
}
$context = $flowQuery->getContext();
if (!isset($context[0])) {
return null;
}
$element = $context[0];
$propertyPath = $arguments[0];
return ObjectAccess::getPropertyPath($element, $propertyPath);
} | php | public function evaluate(FlowQuery $flowQuery, array $arguments)
{
if (!isset($arguments[0]) || empty($arguments[0]) || !is_string($arguments[0])) {
throw new FlowQueryException('property() must be given an attribute name when used on objects, fetching all attributes is not supported.', 1332492263);
}
$context = $flowQuery->getContext();
if (!isset($context[0])) {
return null;
}
$element = $context[0];
$propertyPath = $arguments[0];
return ObjectAccess::getPropertyPath($element, $propertyPath);
} | [
"public",
"function",
"evaluate",
"(",
"FlowQuery",
"$",
"flowQuery",
",",
"array",
"$",
"arguments",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"arguments",
"[",
"0",
"]",
")",
"||",
"empty",
"(",
"$",
"arguments",
"[",
"0",
"]",
")",
"||",
"!",... | {@inheritdoc}
@param FlowQuery $flowQuery the FlowQuery object
@param array $arguments the property path to use (in index 0)
@return mixed | [
"{",
"@inheritdoc",
"}"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Eel/Classes/FlowQuery/Operations/Object/PropertyOperation.php#L49-L63 |
neos/flow-development-collection | Neos.Flow/Classes/Property/TypeConverter/UriTypeConverter.php | UriTypeConverter.convertFrom | public function convertFrom($source, $targetType, array $convertedChildProperties = [], PropertyMappingConfigurationInterface $configuration = null)
{
try {
return new Uri($source);
} catch (\InvalidArgumentException $exception) {
return new Error('The given URI "%s" could not be converted', 1351594881, [$source]);
}
} | php | public function convertFrom($source, $targetType, array $convertedChildProperties = [], PropertyMappingConfigurationInterface $configuration = null)
{
try {
return new Uri($source);
} catch (\InvalidArgumentException $exception) {
return new Error('The given URI "%s" could not be converted', 1351594881, [$source]);
}
} | [
"public",
"function",
"convertFrom",
"(",
"$",
"source",
",",
"$",
"targetType",
",",
"array",
"$",
"convertedChildProperties",
"=",
"[",
"]",
",",
"PropertyMappingConfigurationInterface",
"$",
"configuration",
"=",
"null",
")",
"{",
"try",
"{",
"return",
"new",... | Converts the given string to a Uri object.
@param string $source The URI to be converted
@param string $targetType
@param array $convertedChildProperties
@param PropertyMappingConfigurationInterface $configuration
@return Uri|Error if the input format is not supported or could not be converted for other reasons | [
"Converts",
"the",
"given",
"string",
"to",
"a",
"Uri",
"object",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Property/TypeConverter/UriTypeConverter.php#L52-L59 |
neos/flow-development-collection | Neos.Flow/Classes/ObjectManagement/DependencyInjection/DependencyProxy.php | DependencyProxy._activateDependency | public function _activateDependency()
{
$realDependency = $this->builder->__invoke();
foreach ($this->propertyVariables as &$propertyVariable) {
$propertyVariable = $realDependency;
}
return $realDependency;
} | php | public function _activateDependency()
{
$realDependency = $this->builder->__invoke();
foreach ($this->propertyVariables as &$propertyVariable) {
$propertyVariable = $realDependency;
}
return $realDependency;
} | [
"public",
"function",
"_activateDependency",
"(",
")",
"{",
"$",
"realDependency",
"=",
"$",
"this",
"->",
"builder",
"->",
"__invoke",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"propertyVariables",
"as",
"&",
"$",
"propertyVariable",
")",
"{",
"$"... | Activate the dependency and set it in the object.
@return object The real dependency object
@api | [
"Activate",
"the",
"dependency",
"and",
"set",
"it",
"in",
"the",
"object",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/ObjectManagement/DependencyInjection/DependencyProxy.php#L57-L64 |
neos/flow-development-collection | Neos.Flow/Classes/Property/TypeConverter/TypedArrayConverter.php | TypedArrayConverter.getTypeOfChildProperty | public function getTypeOfChildProperty($targetType, $propertyName, PropertyMappingConfigurationInterface $configuration)
{
$parsedTargetType = TypeHandling::parseType($targetType);
return $parsedTargetType['elementType'];
} | php | public function getTypeOfChildProperty($targetType, $propertyName, PropertyMappingConfigurationInterface $configuration)
{
$parsedTargetType = TypeHandling::parseType($targetType);
return $parsedTargetType['elementType'];
} | [
"public",
"function",
"getTypeOfChildProperty",
"(",
"$",
"targetType",
",",
"$",
"propertyName",
",",
"PropertyMappingConfigurationInterface",
"$",
"configuration",
")",
"{",
"$",
"parsedTargetType",
"=",
"TypeHandling",
"::",
"parseType",
"(",
"$",
"targetType",
")"... | Return the type of a given sub-property inside the $targetType
@param string $targetType
@param string $propertyName
@param PropertyMappingConfigurationInterface $configuration
@return string | [
"Return",
"the",
"type",
"of",
"a",
"given",
"sub",
"-",
"property",
"inside",
"the",
"$targetType"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Property/TypeConverter/TypedArrayConverter.php#L90-L94 |
neos/flow-development-collection | Neos.Flow/Classes/Validation/Validator/RegularExpressionValidator.php | RegularExpressionValidator.isValid | protected function isValid($value)
{
$result = preg_match($this->options['regularExpression'], $value);
if ($result === 0) {
$this->addError('The given subject did not match the pattern. Got: %1$s', 1221565130, [$value]);
}
if ($result === false) {
throw new InvalidValidationOptionsException('regularExpression "' . $this->options['regularExpression'] . '" in RegularExpressionValidator contained an error.', 1298273089);
}
} | php | protected function isValid($value)
{
$result = preg_match($this->options['regularExpression'], $value);
if ($result === 0) {
$this->addError('The given subject did not match the pattern. Got: %1$s', 1221565130, [$value]);
}
if ($result === false) {
throw new InvalidValidationOptionsException('regularExpression "' . $this->options['regularExpression'] . '" in RegularExpressionValidator contained an error.', 1298273089);
}
} | [
"protected",
"function",
"isValid",
"(",
"$",
"value",
")",
"{",
"$",
"result",
"=",
"preg_match",
"(",
"$",
"this",
"->",
"options",
"[",
"'regularExpression'",
"]",
",",
"$",
"value",
")",
";",
"if",
"(",
"$",
"result",
"===",
"0",
")",
"{",
"$",
... | Checks if the given value matches the specified regular expression.
@param mixed $value The value that should be validated
@return void
@throws InvalidValidationOptionsException
@api | [
"Checks",
"if",
"the",
"given",
"value",
"matches",
"the",
"specified",
"regular",
"expression",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Validation/Validator/RegularExpressionValidator.php#L38-L47 |
neos/flow-development-collection | Neos.Flow/Classes/Command/SecurityCommandController.php | SecurityCommandController.importPublicKeyCommand | public function importPublicKeyCommand()
{
$keyData = '';
// no file_get_contents here because it does not work on php://stdin
$fp = fopen('php://stdin', 'rb');
while (!feof($fp)) {
$keyData .= fgets($fp, 4096);
}
fclose($fp);
$fingerprint = $this->rsaWalletService->registerPublicKeyFromString($keyData);
$this->outputLine('The public key has been successfully imported. Use the following fingerprint to refer to it in the RSAWalletService: ' . PHP_EOL . PHP_EOL . $fingerprint . PHP_EOL);
} | php | public function importPublicKeyCommand()
{
$keyData = '';
// no file_get_contents here because it does not work on php://stdin
$fp = fopen('php://stdin', 'rb');
while (!feof($fp)) {
$keyData .= fgets($fp, 4096);
}
fclose($fp);
$fingerprint = $this->rsaWalletService->registerPublicKeyFromString($keyData);
$this->outputLine('The public key has been successfully imported. Use the following fingerprint to refer to it in the RSAWalletService: ' . PHP_EOL . PHP_EOL . $fingerprint . PHP_EOL);
} | [
"public",
"function",
"importPublicKeyCommand",
"(",
")",
"{",
"$",
"keyData",
"=",
"''",
";",
"// no file_get_contents here because it does not work on php://stdin",
"$",
"fp",
"=",
"fopen",
"(",
"'php://stdin'",
",",
"'rb'",
")",
";",
"while",
"(",
"!",
"feof",
... | Import a public key
Read a PEM formatted public key from stdin and import it into the
RSAWalletService.
@return void
@see neos.flow:security:importprivatekey | [
"Import",
"a",
"public",
"key"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Command/SecurityCommandController.php#L85-L98 |
neos/flow-development-collection | Neos.Flow/Classes/Command/SecurityCommandController.php | SecurityCommandController.generateKeyPairCommand | public function generateKeyPairCommand(bool $usedForPasswords = false)
{
$fingerprint = $this->rsaWalletService->generateNewKeypair($usedForPasswords);
$this->outputLine('The key pair has been successfully generated. Use the following fingerprint to refer to it in the RSAWalletService: ' . PHP_EOL . PHP_EOL . $fingerprint . PHP_EOL);
} | php | public function generateKeyPairCommand(bool $usedForPasswords = false)
{
$fingerprint = $this->rsaWalletService->generateNewKeypair($usedForPasswords);
$this->outputLine('The key pair has been successfully generated. Use the following fingerprint to refer to it in the RSAWalletService: ' . PHP_EOL . PHP_EOL . $fingerprint . PHP_EOL);
} | [
"public",
"function",
"generateKeyPairCommand",
"(",
"bool",
"$",
"usedForPasswords",
"=",
"false",
")",
"{",
"$",
"fingerprint",
"=",
"$",
"this",
"->",
"rsaWalletService",
"->",
"generateNewKeypair",
"(",
"$",
"usedForPasswords",
")",
";",
"$",
"this",
"->",
... | Generate a public/private key pair and add it to the RSAWalletService
@param boolean $usedForPasswords If the private key should be used for passwords
@return void
@see neos.flow:security:importprivatekey | [
"Generate",
"a",
"public",
"/",
"private",
"key",
"pair",
"and",
"add",
"it",
"to",
"the",
"RSAWalletService"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Command/SecurityCommandController.php#L107-L112 |
neos/flow-development-collection | Neos.Flow/Classes/Command/SecurityCommandController.php | SecurityCommandController.importPrivateKeyCommand | public function importPrivateKeyCommand(bool $usedForPasswords = false)
{
$keyData = '';
// no file_get_contents here because it does not work on php://stdin
$fp = fopen('php://stdin', 'rb');
while (!feof($fp)) {
$keyData .= fgets($fp, 4096);
}
fclose($fp);
$fingerprint = $this->rsaWalletService->registerKeyPairFromPrivateKeyString($keyData, $usedForPasswords);
$this->outputLine('The keypair has been successfully imported. Use the following fingerprint to refer to it in the RSAWalletService: ' . PHP_EOL . PHP_EOL . $fingerprint . PHP_EOL);
} | php | public function importPrivateKeyCommand(bool $usedForPasswords = false)
{
$keyData = '';
// no file_get_contents here because it does not work on php://stdin
$fp = fopen('php://stdin', 'rb');
while (!feof($fp)) {
$keyData .= fgets($fp, 4096);
}
fclose($fp);
$fingerprint = $this->rsaWalletService->registerKeyPairFromPrivateKeyString($keyData, $usedForPasswords);
$this->outputLine('The keypair has been successfully imported. Use the following fingerprint to refer to it in the RSAWalletService: ' . PHP_EOL . PHP_EOL . $fingerprint . PHP_EOL);
} | [
"public",
"function",
"importPrivateKeyCommand",
"(",
"bool",
"$",
"usedForPasswords",
"=",
"false",
")",
"{",
"$",
"keyData",
"=",
"''",
";",
"// no file_get_contents here because it does not work on php://stdin",
"$",
"fp",
"=",
"fopen",
"(",
"'php://stdin'",
",",
"... | Import a private key
Read a PEM formatted private key from stdin and import it into the
RSAWalletService. The public key will be automatically extracted and stored
together with the private key as a key pair.
You can generate the same fingerprint returned from this using these commands:
ssh-keygen -yf my-key.pem > my-key.pub
ssh-keygen -lf my-key.pub
To create a private key to import using this method, you can use:
ssh-keygen -t rsa -f my-key
./flow security:importprivatekey < my-key
Again, the fingerprint can also be generated using:
ssh-keygen -lf my-key.pub
@param boolean $usedForPasswords If the private key should be used for passwords
@return void
@see neos.flow:security:importpublickey
@see neos.flow:security:generatekeypair | [
"Import",
"a",
"private",
"key"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Command/SecurityCommandController.php#L140-L153 |
neos/flow-development-collection | Neos.Flow/Classes/Command/SecurityCommandController.php | SecurityCommandController.showEffectivePolicyCommand | public function showEffectivePolicyCommand(string $privilegeType, string $roles = '')
{
$systemRoleIdentifiers = ['Neos.Flow:Everybody', 'Neos.Flow:Anonymous', 'Neos.Flow:AuthenticatedUser'];
if (strpos($privilegeType, '\\') === false) {
$privilegeType = sprintf('\Neos\Flow\Security\Authorization\Privilege\%s\%sPrivilegeInterface', ucfirst($privilegeType), ucfirst($privilegeType));
}
if (!class_exists($privilegeType) && !interface_exists($privilegeType)) {
$this->outputLine('The privilege type "%s" was not defined.', [$privilegeType]);
$this->quit(1);
}
if (!is_subclass_of($privilegeType, PrivilegeInterface::class)) {
$this->outputLine('"%s" does not refer to a valid Privilege', [$privilegeType]);
$this->quit(1);
}
$requestedRoles = [];
foreach (Arrays::trimExplode(',', $roles) as $roleIdentifier) {
try {
if (in_array($roleIdentifier, $systemRoleIdentifiers)) {
continue;
}
$currentRole = $this->policyService->getRole($roleIdentifier);
$requestedRoles[$roleIdentifier] = $currentRole;
foreach ($currentRole->getAllParentRoles() as $currentParentRole) {
if (!in_array($currentParentRole, $requestedRoles)) {
$requestedRoles[$currentParentRole->getIdentifier()] = $currentParentRole;
}
}
} catch (NoSuchRoleException $exception) {
$this->outputLine('The role %s was not defined.', [$roleIdentifier]);
$this->quit(1);
}
}
if (count($requestedRoles) > 0) {
$requestedRoles['Neos.Flow:AuthenticatedUser'] = $this->policyService->getRole('Neos.Flow:AuthenticatedUser');
} else {
$requestedRoles['Neos.Flow:Anonymous'] = $this->policyService->getRole('Neos.Flow:Anonymous');
}
$requestedRoles['Neos.Flow:Everybody'] = $this->policyService->getRole('Neos.Flow:Everybody');
$this->outputLine('Effective Permissions for the roles <b>%s</b> ', [implode(', ', $requestedRoles)]);
$this->outputLine(str_repeat('-', $this->output->getMaximumLineLength()));
$definedPrivileges = $this->policyService->getAllPrivilegesByType($privilegeType);
$permissions = [];
/** @var PrivilegeInterface $definedPrivilege */
foreach ($definedPrivileges as $definedPrivilege) {
$accessGrants = 0;
$accessDenies = 0;
$permission = 'ABSTAIN';
/** @var Role $requestedRole */
foreach ($requestedRoles as $requestedRole) {
$privilegeType = $requestedRole->getPrivilegeForTarget($definedPrivilege->getPrivilegeTarget()->getIdentifier());
if ($privilegeType === null) {
continue;
}
if ($privilegeType->isGranted()) {
$accessGrants++;
} elseif ($privilegeType->isDenied()) {
$accessDenies++;
}
}
if ($accessDenies > 0) {
$permission = '<error>DENY</error>';
}
if ($accessGrants > 0 && $accessDenies === 0) {
$permission = '<success>GRANT</success>';
}
$permissions[$definedPrivilege->getPrivilegeTarget()->getIdentifier()] = $permission;
}
ksort($permissions);
foreach ($permissions as $privilegeTargetIdentifier => $permission) {
$formattedPrivilegeTargetIdentifier = wordwrap($privilegeTargetIdentifier, $this->output->getMaximumLineLength() - 10, PHP_EOL . str_repeat(' ', 10), true);
$this->outputLine('%-70s %s', [$formattedPrivilegeTargetIdentifier, $permission]);
}
} | php | public function showEffectivePolicyCommand(string $privilegeType, string $roles = '')
{
$systemRoleIdentifiers = ['Neos.Flow:Everybody', 'Neos.Flow:Anonymous', 'Neos.Flow:AuthenticatedUser'];
if (strpos($privilegeType, '\\') === false) {
$privilegeType = sprintf('\Neos\Flow\Security\Authorization\Privilege\%s\%sPrivilegeInterface', ucfirst($privilegeType), ucfirst($privilegeType));
}
if (!class_exists($privilegeType) && !interface_exists($privilegeType)) {
$this->outputLine('The privilege type "%s" was not defined.', [$privilegeType]);
$this->quit(1);
}
if (!is_subclass_of($privilegeType, PrivilegeInterface::class)) {
$this->outputLine('"%s" does not refer to a valid Privilege', [$privilegeType]);
$this->quit(1);
}
$requestedRoles = [];
foreach (Arrays::trimExplode(',', $roles) as $roleIdentifier) {
try {
if (in_array($roleIdentifier, $systemRoleIdentifiers)) {
continue;
}
$currentRole = $this->policyService->getRole($roleIdentifier);
$requestedRoles[$roleIdentifier] = $currentRole;
foreach ($currentRole->getAllParentRoles() as $currentParentRole) {
if (!in_array($currentParentRole, $requestedRoles)) {
$requestedRoles[$currentParentRole->getIdentifier()] = $currentParentRole;
}
}
} catch (NoSuchRoleException $exception) {
$this->outputLine('The role %s was not defined.', [$roleIdentifier]);
$this->quit(1);
}
}
if (count($requestedRoles) > 0) {
$requestedRoles['Neos.Flow:AuthenticatedUser'] = $this->policyService->getRole('Neos.Flow:AuthenticatedUser');
} else {
$requestedRoles['Neos.Flow:Anonymous'] = $this->policyService->getRole('Neos.Flow:Anonymous');
}
$requestedRoles['Neos.Flow:Everybody'] = $this->policyService->getRole('Neos.Flow:Everybody');
$this->outputLine('Effective Permissions for the roles <b>%s</b> ', [implode(', ', $requestedRoles)]);
$this->outputLine(str_repeat('-', $this->output->getMaximumLineLength()));
$definedPrivileges = $this->policyService->getAllPrivilegesByType($privilegeType);
$permissions = [];
/** @var PrivilegeInterface $definedPrivilege */
foreach ($definedPrivileges as $definedPrivilege) {
$accessGrants = 0;
$accessDenies = 0;
$permission = 'ABSTAIN';
/** @var Role $requestedRole */
foreach ($requestedRoles as $requestedRole) {
$privilegeType = $requestedRole->getPrivilegeForTarget($definedPrivilege->getPrivilegeTarget()->getIdentifier());
if ($privilegeType === null) {
continue;
}
if ($privilegeType->isGranted()) {
$accessGrants++;
} elseif ($privilegeType->isDenied()) {
$accessDenies++;
}
}
if ($accessDenies > 0) {
$permission = '<error>DENY</error>';
}
if ($accessGrants > 0 && $accessDenies === 0) {
$permission = '<success>GRANT</success>';
}
$permissions[$definedPrivilege->getPrivilegeTarget()->getIdentifier()] = $permission;
}
ksort($permissions);
foreach ($permissions as $privilegeTargetIdentifier => $permission) {
$formattedPrivilegeTargetIdentifier = wordwrap($privilegeTargetIdentifier, $this->output->getMaximumLineLength() - 10, PHP_EOL . str_repeat(' ', 10), true);
$this->outputLine('%-70s %s', [$formattedPrivilegeTargetIdentifier, $permission]);
}
} | [
"public",
"function",
"showEffectivePolicyCommand",
"(",
"string",
"$",
"privilegeType",
",",
"string",
"$",
"roles",
"=",
"''",
")",
"{",
"$",
"systemRoleIdentifiers",
"=",
"[",
"'Neos.Flow:Everybody'",
",",
"'Neos.Flow:Anonymous'",
",",
"'Neos.Flow:AuthenticatedUser'"... | Shows a list of all defined privilege targets and the effective permissions
@param string $privilegeType The privilege type ("entity", "method" or the FQN of a class implementing PrivilegeInterface)
@param string $roles A comma separated list of role identifiers. Shows policy for an unauthenticated user when left empty. | [
"Shows",
"a",
"list",
"of",
"all",
"defined",
"privilege",
"targets",
"and",
"the",
"effective",
"permissions"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Command/SecurityCommandController.php#L161-L246 |
neos/flow-development-collection | Neos.Flow/Classes/Command/SecurityCommandController.php | SecurityCommandController.showUnprotectedActionsCommand | public function showUnprotectedActionsCommand()
{
$methodPrivileges = [];
foreach ($this->policyService->getRoles(true) as $role) {
$methodPrivileges = array_merge($methodPrivileges, $role->getPrivilegesByType(MethodPrivilegeInterface::class));
}
$controllerClassNames = $this->reflectionService->getAllSubClassNamesForClass(AbstractController::class);
$allActionsAreProtected = true;
foreach ($controllerClassNames as $controllerClassName) {
if ($this->reflectionService->isClassAbstract($controllerClassName)) {
continue;
}
$methodNames = get_class_methods($controllerClassName);
$foundUnprotectedAction = false;
foreach ($methodNames as $methodName) {
if (preg_match('/.*Action$/', $methodName) === 0 || $this->reflectionService->isMethodPublic($controllerClassName, $methodName) === false) {
continue;
}
/** @var MethodPrivilegeInterface $methodPrivilege */
foreach ($methodPrivileges as $methodPrivilege) {
if ($methodPrivilege->matchesMethod($controllerClassName, $methodName)) {
continue 2;
}
}
if ($foundUnprotectedAction === false) {
$this->outputLine(PHP_EOL . '<b>' . $controllerClassName . '</b>');
$foundUnprotectedAction = true;
$allActionsAreProtected = false;
}
$this->outputLine(' ' . $methodName);
}
}
if ($allActionsAreProtected === true) {
$this->outputLine('All public controller actions are covered by your security policy. Good job!');
}
} | php | public function showUnprotectedActionsCommand()
{
$methodPrivileges = [];
foreach ($this->policyService->getRoles(true) as $role) {
$methodPrivileges = array_merge($methodPrivileges, $role->getPrivilegesByType(MethodPrivilegeInterface::class));
}
$controllerClassNames = $this->reflectionService->getAllSubClassNamesForClass(AbstractController::class);
$allActionsAreProtected = true;
foreach ($controllerClassNames as $controllerClassName) {
if ($this->reflectionService->isClassAbstract($controllerClassName)) {
continue;
}
$methodNames = get_class_methods($controllerClassName);
$foundUnprotectedAction = false;
foreach ($methodNames as $methodName) {
if (preg_match('/.*Action$/', $methodName) === 0 || $this->reflectionService->isMethodPublic($controllerClassName, $methodName) === false) {
continue;
}
/** @var MethodPrivilegeInterface $methodPrivilege */
foreach ($methodPrivileges as $methodPrivilege) {
if ($methodPrivilege->matchesMethod($controllerClassName, $methodName)) {
continue 2;
}
}
if ($foundUnprotectedAction === false) {
$this->outputLine(PHP_EOL . '<b>' . $controllerClassName . '</b>');
$foundUnprotectedAction = true;
$allActionsAreProtected = false;
}
$this->outputLine(' ' . $methodName);
}
}
if ($allActionsAreProtected === true) {
$this->outputLine('All public controller actions are covered by your security policy. Good job!');
}
} | [
"public",
"function",
"showUnprotectedActionsCommand",
"(",
")",
"{",
"$",
"methodPrivileges",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"policyService",
"->",
"getRoles",
"(",
"true",
")",
"as",
"$",
"role",
")",
"{",
"$",
"methodPrivileges",
... | Lists all public controller actions not covered by the active security policy
@return void | [
"Lists",
"all",
"public",
"controller",
"actions",
"not",
"covered",
"by",
"the",
"active",
"security",
"policy"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Command/SecurityCommandController.php#L253-L292 |
neos/flow-development-collection | Neos.Flow/Classes/Command/SecurityCommandController.php | SecurityCommandController.showMethodsForPrivilegeTargetCommand | public function showMethodsForPrivilegeTargetCommand(string $privilegeTarget)
{
$privilegeTargetInstance = $this->policyService->getPrivilegeTargetByIdentifier($privilegeTarget);
if ($privilegeTargetInstance === null) {
$this->outputLine('The privilegeTarget "%s" is not defined', [$privilegeTarget]);
$this->quit(1);
}
$privilegeParameters = [];
foreach ($this->request->getExceedingArguments() as $argument) {
list($argumentName, $argumentValue) = explode(':', $argument, 2);
$privilegeParameters[$argumentName] = $argumentValue;
}
$privilege = $privilegeTargetInstance->createPrivilege(PrivilegeInterface::GRANT, $privilegeParameters);
if (!$privilege instanceof MethodPrivilegeInterface) {
$this->outputLine('The privilegeTarget "%s" does not refer to a MethodPrivilege but to a privilege of type "%s"', [$privilegeTarget, $privilege->getPrivilegeTarget()->getPrivilegeClassName()]);
$this->quit(1);
}
$matchedClassesAndMethods = [];
foreach ($this->reflectionService->getAllClassNames() as $className) {
try {
$reflectionClass = new \ReflectionClass($className);
} catch (\ReflectionException $exception) {
continue;
}
foreach ($reflectionClass->getMethods() as $reflectionMethod) {
$methodName = $reflectionMethod->getName();
if ($privilege->matchesMethod($className, $methodName)) {
$matchedClassesAndMethods[$className][$methodName] = $methodName;
}
}
}
if (count($matchedClassesAndMethods) === 0) {
$this->outputLine('The given privilegeTarget did not match any method.');
$this->quit(1);
}
foreach ($matchedClassesAndMethods as $className => $methods) {
$this->outputLine($className);
foreach ($methods as $methodName) {
$this->outputLine(' ' . $methodName);
}
$this->outputLine();
}
} | php | public function showMethodsForPrivilegeTargetCommand(string $privilegeTarget)
{
$privilegeTargetInstance = $this->policyService->getPrivilegeTargetByIdentifier($privilegeTarget);
if ($privilegeTargetInstance === null) {
$this->outputLine('The privilegeTarget "%s" is not defined', [$privilegeTarget]);
$this->quit(1);
}
$privilegeParameters = [];
foreach ($this->request->getExceedingArguments() as $argument) {
list($argumentName, $argumentValue) = explode(':', $argument, 2);
$privilegeParameters[$argumentName] = $argumentValue;
}
$privilege = $privilegeTargetInstance->createPrivilege(PrivilegeInterface::GRANT, $privilegeParameters);
if (!$privilege instanceof MethodPrivilegeInterface) {
$this->outputLine('The privilegeTarget "%s" does not refer to a MethodPrivilege but to a privilege of type "%s"', [$privilegeTarget, $privilege->getPrivilegeTarget()->getPrivilegeClassName()]);
$this->quit(1);
}
$matchedClassesAndMethods = [];
foreach ($this->reflectionService->getAllClassNames() as $className) {
try {
$reflectionClass = new \ReflectionClass($className);
} catch (\ReflectionException $exception) {
continue;
}
foreach ($reflectionClass->getMethods() as $reflectionMethod) {
$methodName = $reflectionMethod->getName();
if ($privilege->matchesMethod($className, $methodName)) {
$matchedClassesAndMethods[$className][$methodName] = $methodName;
}
}
}
if (count($matchedClassesAndMethods) === 0) {
$this->outputLine('The given privilegeTarget did not match any method.');
$this->quit(1);
}
foreach ($matchedClassesAndMethods as $className => $methods) {
$this->outputLine($className);
foreach ($methods as $methodName) {
$this->outputLine(' ' . $methodName);
}
$this->outputLine();
}
} | [
"public",
"function",
"showMethodsForPrivilegeTargetCommand",
"(",
"string",
"$",
"privilegeTarget",
")",
"{",
"$",
"privilegeTargetInstance",
"=",
"$",
"this",
"->",
"policyService",
"->",
"getPrivilegeTargetByIdentifier",
"(",
"$",
"privilegeTarget",
")",
";",
"if",
... | Shows the methods represented by the given security privilege target
If the privilege target has parameters those can be specified separated by a colon
for example "parameter1:value1" "parameter2:value2".
But be aware that this only works for parameters that have been specified in the policy
@param string $privilegeTarget The name of the privilegeTarget as stated in the policy
@return void | [
"Shows",
"the",
"methods",
"represented",
"by",
"the",
"given",
"security",
"privilege",
"target"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Command/SecurityCommandController.php#L304-L349 |
neos/flow-development-collection | Neos.Flow/Classes/Http/Helper/UploadedFilesHelper.php | UploadedFilesHelper.untangleFilesArray | public static function untangleFilesArray(array $convolutedFiles): array
{
$untangledFiles = [];
$fieldPaths = [];
foreach ($convolutedFiles as $firstLevelFieldName => $fieldInformation) {
if (!is_array($fieldInformation['error'])) {
$fieldPaths[] = [$firstLevelFieldName];
} else {
$newFieldPaths = self::calculateFieldPathsAsArray($fieldInformation['error'], $firstLevelFieldName);
$fieldPaths = array_merge($fieldPaths, $newFieldPaths);
}
}
foreach ($fieldPaths as $fieldPath) {
if (count($fieldPath) === 1) {
$fileInformation = $convolutedFiles[$fieldPath{0}];
} else {
$fileInformation = [];
foreach ($convolutedFiles[$fieldPath{0}] as $key => $subStructure) {
$fileInformation[$key] = Arrays::getValueByPath($subStructure, array_slice($fieldPath, 1));
}
}
if (isset($fileInformation['error']) && $fileInformation['error'] !== \UPLOAD_ERR_NO_FILE) {
$untangledFiles = Arrays::setValueByPath($untangledFiles, $fieldPath, $fileInformation);
}
}
return $untangledFiles;
} | php | public static function untangleFilesArray(array $convolutedFiles): array
{
$untangledFiles = [];
$fieldPaths = [];
foreach ($convolutedFiles as $firstLevelFieldName => $fieldInformation) {
if (!is_array($fieldInformation['error'])) {
$fieldPaths[] = [$firstLevelFieldName];
} else {
$newFieldPaths = self::calculateFieldPathsAsArray($fieldInformation['error'], $firstLevelFieldName);
$fieldPaths = array_merge($fieldPaths, $newFieldPaths);
}
}
foreach ($fieldPaths as $fieldPath) {
if (count($fieldPath) === 1) {
$fileInformation = $convolutedFiles[$fieldPath{0}];
} else {
$fileInformation = [];
foreach ($convolutedFiles[$fieldPath{0}] as $key => $subStructure) {
$fileInformation[$key] = Arrays::getValueByPath($subStructure, array_slice($fieldPath, 1));
}
}
if (isset($fileInformation['error']) && $fileInformation['error'] !== \UPLOAD_ERR_NO_FILE) {
$untangledFiles = Arrays::setValueByPath($untangledFiles, $fieldPath, $fileInformation);
}
}
return $untangledFiles;
} | [
"public",
"static",
"function",
"untangleFilesArray",
"(",
"array",
"$",
"convolutedFiles",
")",
":",
"array",
"{",
"$",
"untangledFiles",
"=",
"[",
"]",
";",
"$",
"fieldPaths",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"convolutedFiles",
"as",
"$",
"firstL... | Transforms the convoluted _FILES superglobal into a manageable form.
@param array $convolutedFiles The _FILES superglobal or something with the same structure
@return array Untangled files | [
"Transforms",
"the",
"convoluted",
"_FILES",
"superglobal",
"into",
"a",
"manageable",
"form",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Http/Helper/UploadedFilesHelper.php#L27-L56 |
neos/flow-development-collection | Neos.Flow/Classes/Http/Helper/UploadedFilesHelper.php | UploadedFilesHelper.calculateFieldPaths | protected static function calculateFieldPaths(array $structure, string $firstLevelFieldName = null): array
{
$fieldPaths = self::calculateFieldPathsAsArray($structure, $firstLevelFieldName);
array_walk($fieldPaths, function (&$fieldPath) {
$fieldPath = implode('/', $fieldPath);
});
return $fieldPaths;
} | php | protected static function calculateFieldPaths(array $structure, string $firstLevelFieldName = null): array
{
$fieldPaths = self::calculateFieldPathsAsArray($structure, $firstLevelFieldName);
array_walk($fieldPaths, function (&$fieldPath) {
$fieldPath = implode('/', $fieldPath);
});
return $fieldPaths;
} | [
"protected",
"static",
"function",
"calculateFieldPaths",
"(",
"array",
"$",
"structure",
",",
"string",
"$",
"firstLevelFieldName",
"=",
"null",
")",
":",
"array",
"{",
"$",
"fieldPaths",
"=",
"self",
"::",
"calculateFieldPathsAsArray",
"(",
"$",
"structure",
"... | Returns an array of all possible "field paths" for the given array.
@param array $structure The array to walk through
@param string $firstLevelFieldName
@return array An array of paths (as strings) in the format "key1/key2/key3" ...
@deprecated | [
"Returns",
"an",
"array",
"of",
"all",
"possible",
"field",
"paths",
"for",
"the",
"given",
"array",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Http/Helper/UploadedFilesHelper.php#L66-L73 |
neos/flow-development-collection | Neos.Flow/Classes/Http/Helper/UploadedFilesHelper.php | UploadedFilesHelper.calculateFieldPathsAsArray | protected static function calculateFieldPathsAsArray(array $structure, string $firstLevelFieldName = null): array
{
$fieldPaths = [];
foreach ($structure as $key => $subStructure) {
$fieldPath = [];
if ($firstLevelFieldName !== null) {
$fieldPath[] = $firstLevelFieldName;
}
$fieldPath[] = $key;
if (is_array($subStructure)) {
foreach (self::calculateFieldPathsAsArray($subStructure) as $subFieldPath) {
$fieldPaths[] = array_merge($fieldPath, $subFieldPath);
}
} else {
$fieldPaths[] = $fieldPath;
}
}
return $fieldPaths;
} | php | protected static function calculateFieldPathsAsArray(array $structure, string $firstLevelFieldName = null): array
{
$fieldPaths = [];
foreach ($structure as $key => $subStructure) {
$fieldPath = [];
if ($firstLevelFieldName !== null) {
$fieldPath[] = $firstLevelFieldName;
}
$fieldPath[] = $key;
if (is_array($subStructure)) {
foreach (self::calculateFieldPathsAsArray($subStructure) as $subFieldPath) {
$fieldPaths[] = array_merge($fieldPath, $subFieldPath);
}
} else {
$fieldPaths[] = $fieldPath;
}
}
return $fieldPaths;
} | [
"protected",
"static",
"function",
"calculateFieldPathsAsArray",
"(",
"array",
"$",
"structure",
",",
"string",
"$",
"firstLevelFieldName",
"=",
"null",
")",
":",
"array",
"{",
"$",
"fieldPaths",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"structure",
"as",
"$... | Returns an array of all possible "field paths" for the given array.
@param array $structure The array to walk through
@param string $firstLevelFieldName
@return array An array of paths (as arrays) in the format ["key1", "key2", "key3"] ... | [
"Returns",
"an",
"array",
"of",
"all",
"possible",
"field",
"paths",
"for",
"the",
"given",
"array",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Http/Helper/UploadedFilesHelper.php#L82-L101 |
neos/flow-development-collection | Neos.Flow/Classes/Persistence/Generic/QueryResult.php | QueryResult.initialize | protected function initialize()
{
if (!is_array($this->queryResult)) {
$this->queryResult = $this->dataMapper->mapToObjects($this->persistenceManager->getObjectDataByQuery($this->query));
}
} | php | protected function initialize()
{
if (!is_array($this->queryResult)) {
$this->queryResult = $this->dataMapper->mapToObjects($this->persistenceManager->getObjectDataByQuery($this->query));
}
} | [
"protected",
"function",
"initialize",
"(",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"this",
"->",
"queryResult",
")",
")",
"{",
"$",
"this",
"->",
"queryResult",
"=",
"$",
"this",
"->",
"dataMapper",
"->",
"mapToObjects",
"(",
"$",
"this",
"->"... | Loads the objects this QueryResult is supposed to hold
@return void | [
"Loads",
"the",
"objects",
"this",
"QueryResult",
"is",
"supposed",
"to",
"hold"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Persistence/Generic/QueryResult.php#L90-L95 |
neos/flow-development-collection | Neos.Flow/Classes/Persistence/Generic/QueryResult.php | QueryResult.getFirst | public function getFirst()
{
if (is_array($this->queryResult)) {
$queryResult = &$this->queryResult;
} else {
$query = clone $this->query;
$query->setLimit(1);
$queryResult = $this->dataMapper->mapToObjects($this->persistenceManager->getObjectDataByQuery($query));
}
return (isset($queryResult[0])) ? $queryResult[0] : null;
} | php | public function getFirst()
{
if (is_array($this->queryResult)) {
$queryResult = &$this->queryResult;
} else {
$query = clone $this->query;
$query->setLimit(1);
$queryResult = $this->dataMapper->mapToObjects($this->persistenceManager->getObjectDataByQuery($query));
}
return (isset($queryResult[0])) ? $queryResult[0] : null;
} | [
"public",
"function",
"getFirst",
"(",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"queryResult",
")",
")",
"{",
"$",
"queryResult",
"=",
"&",
"$",
"this",
"->",
"queryResult",
";",
"}",
"else",
"{",
"$",
"query",
"=",
"clone",
"$",
"t... | Returns the first object in the result set, if any.
@return mixed The first object of the result set or NULL if the result set was empty
@api | [
"Returns",
"the",
"first",
"object",
"in",
"the",
"result",
"set",
"if",
"any",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Persistence/Generic/QueryResult.php#L114-L124 |
neos/flow-development-collection | Neos.Flow/Classes/Persistence/Generic/QueryResult.php | QueryResult.count | public function count()
{
if ($this->numberOfResults === null) {
if (is_array($this->queryResult)) {
$this->numberOfResults = count($this->queryResult);
} else {
$this->numberOfResults = $this->persistenceManager->getObjectCountByQuery($this->query);
}
}
return $this->numberOfResults;
} | php | public function count()
{
if ($this->numberOfResults === null) {
if (is_array($this->queryResult)) {
$this->numberOfResults = count($this->queryResult);
} else {
$this->numberOfResults = $this->persistenceManager->getObjectCountByQuery($this->query);
}
}
return $this->numberOfResults;
} | [
"public",
"function",
"count",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"numberOfResults",
"===",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"queryResult",
")",
")",
"{",
"$",
"this",
"->",
"numberOfResults",
"=",
"count",
"... | Returns the number of objects in the result
@return integer The number of matching objects
@api | [
"Returns",
"the",
"number",
"of",
"objects",
"in",
"the",
"result"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Persistence/Generic/QueryResult.php#L132-L142 |
neos/flow-development-collection | Neos.FluidAdaptor/Classes/Core/ViewHelper/AbstractConditionViewHelper.php | AbstractConditionViewHelper.renderThenChild | protected function renderThenChild()
{
if ($this->hasArgument('then')) {
return $this->arguments['then'];
}
$elseViewHelperEncountered = false;
foreach ($this->childNodes as $childNode) {
if ($childNode instanceof ViewHelperNode
&& substr($childNode->getViewHelperClassName(), -14) === 'ThenViewHelper'
) {
$data = $childNode->evaluate($this->renderingContext);
return $data;
}
if ($childNode instanceof ViewHelperNode
&& substr($childNode->getViewHelperClassName(), -14) === 'ElseViewHelper'
) {
$elseViewHelperEncountered = true;
}
}
if ($elseViewHelperEncountered) {
return '';
} else {
return $this->renderChildren();
}
} | php | protected function renderThenChild()
{
if ($this->hasArgument('then')) {
return $this->arguments['then'];
}
$elseViewHelperEncountered = false;
foreach ($this->childNodes as $childNode) {
if ($childNode instanceof ViewHelperNode
&& substr($childNode->getViewHelperClassName(), -14) === 'ThenViewHelper'
) {
$data = $childNode->evaluate($this->renderingContext);
return $data;
}
if ($childNode instanceof ViewHelperNode
&& substr($childNode->getViewHelperClassName(), -14) === 'ElseViewHelper'
) {
$elseViewHelperEncountered = true;
}
}
if ($elseViewHelperEncountered) {
return '';
} else {
return $this->renderChildren();
}
} | [
"protected",
"function",
"renderThenChild",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasArgument",
"(",
"'then'",
")",
")",
"{",
"return",
"$",
"this",
"->",
"arguments",
"[",
"'then'",
"]",
";",
"}",
"$",
"elseViewHelperEncountered",
"=",
"false",
... | Returns value of "then" attribute.
If then attribute is not set, iterates through child nodes and renders ThenViewHelper.
If then attribute is not set and no ThenViewHelper and no ElseViewHelper is found, all child nodes are rendered
@return mixed rendered ThenViewHelper or contents of <f:if> if no ThenViewHelper was found
@api | [
"Returns",
"value",
"of",
"then",
"attribute",
".",
"If",
"then",
"attribute",
"is",
"not",
"set",
"iterates",
"through",
"child",
"nodes",
"and",
"renders",
"ThenViewHelper",
".",
"If",
"then",
"attribute",
"is",
"not",
"set",
"and",
"no",
"ThenViewHelper",
... | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.FluidAdaptor/Classes/Core/ViewHelper/AbstractConditionViewHelper.php#L134-L161 |
neos/flow-development-collection | Neos.FluidAdaptor/Classes/Core/ViewHelper/AbstractConditionViewHelper.php | AbstractConditionViewHelper.renderElseChild | protected function renderElseChild()
{
if ($this->hasArgument('else')) {
return $this->arguments['else'];
}
/** @var ViewHelperNode|NULL $elseNode */
$elseNode = null;
foreach ($this->childNodes as $childNode) {
if ($childNode instanceof ViewHelperNode
&& substr($childNode->getViewHelperClassName(), -14) === 'ElseViewHelper'
) {
$arguments = $childNode->getArguments();
if (isset($arguments['if']) && $arguments['if']->evaluate($this->renderingContext)) {
return $childNode->evaluate($this->renderingContext);
} else {
$elseNode = $childNode;
}
}
}
return $elseNode instanceof ViewHelperNode ? $elseNode->evaluate($this->renderingContext) : '';
} | php | protected function renderElseChild()
{
if ($this->hasArgument('else')) {
return $this->arguments['else'];
}
/** @var ViewHelperNode|NULL $elseNode */
$elseNode = null;
foreach ($this->childNodes as $childNode) {
if ($childNode instanceof ViewHelperNode
&& substr($childNode->getViewHelperClassName(), -14) === 'ElseViewHelper'
) {
$arguments = $childNode->getArguments();
if (isset($arguments['if']) && $arguments['if']->evaluate($this->renderingContext)) {
return $childNode->evaluate($this->renderingContext);
} else {
$elseNode = $childNode;
}
}
}
return $elseNode instanceof ViewHelperNode ? $elseNode->evaluate($this->renderingContext) : '';
} | [
"protected",
"function",
"renderElseChild",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasArgument",
"(",
"'else'",
")",
")",
"{",
"return",
"$",
"this",
"->",
"arguments",
"[",
"'else'",
"]",
";",
"}",
"/** @var ViewHelperNode|NULL $elseNode */",
"$",
"e... | Returns value of "else" attribute.
If else attribute is not set, iterates through child nodes and renders ElseViewHelper.
If else attribute is not set and no ElseViewHelper is found, an empty string will be returned.
@return string rendered ElseViewHelper or an empty string if no ThenViewHelper was found
@api | [
"Returns",
"value",
"of",
"else",
"attribute",
".",
"If",
"else",
"attribute",
"is",
"not",
"set",
"iterates",
"through",
"child",
"nodes",
"and",
"renders",
"ElseViewHelper",
".",
"If",
"else",
"attribute",
"is",
"not",
"set",
"and",
"no",
"ElseViewHelper",
... | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.FluidAdaptor/Classes/Core/ViewHelper/AbstractConditionViewHelper.php#L171-L193 |
neos/flow-development-collection | Neos.FluidAdaptor/Classes/Core/ViewHelper/AbstractConditionViewHelper.php | AbstractConditionViewHelper.compile | public function compile($argumentsName, $closureName, &$initializationPhpCode, ViewHelperNode $node, TemplateCompiler $compiler)
{
$thenViewHelperEncountered = $elseViewHelperEncountered = false;
foreach ($node->getChildNodes() as $childNode) {
if ($childNode instanceof ViewHelperNode) {
$viewHelperClassName = $childNode->getViewHelperClassName();
if (substr($viewHelperClassName, -14) === 'ThenViewHelper') {
$thenViewHelperEncountered = true;
$childNodesAsClosure = $compiler->wrapChildNodesInClosure($childNode);
$initializationPhpCode .= sprintf('%s[\'__thenClosure\'] = %s;', $argumentsName, $childNodesAsClosure) . chr(10);
} elseif (substr($viewHelperClassName, -14) === 'ElseViewHelper') {
$elseViewHelperEncountered = true;
$childNodesAsClosure = $compiler->wrapChildNodesInClosure($childNode);
$initializationPhpCode .= sprintf('%s[\'__elseClosures\'][] = %s;', $argumentsName, $childNodesAsClosure) . chr(10);
$arguments = $childNode->getArguments();
if (isset($arguments['if'])) {
// The "else" has an argument, indicating it has a secondary (elseif) condition.
// Compile a closure which will evaluate the condition.
$elseIfConditionAsClosure = $compiler->wrapViewHelperNodeArgumentEvaluationInClosure($childNode, 'if');
$initializationPhpCode .= sprintf('%s[\'__elseifClosures\'][] = %s;', $argumentsName, $elseIfConditionAsClosure) . chr(10);
}
}
}
}
if (!$thenViewHelperEncountered && !$elseViewHelperEncountered && !isset($node->getArguments()['then'])) {
$initializationPhpCode .= sprintf('%s[\'__thenClosure\'] = %s;', $argumentsName, $closureName) . chr(10);
}
return parent::compile($argumentsName, $closureName, $initializationPhpCode, $node, $compiler);
} | php | public function compile($argumentsName, $closureName, &$initializationPhpCode, ViewHelperNode $node, TemplateCompiler $compiler)
{
$thenViewHelperEncountered = $elseViewHelperEncountered = false;
foreach ($node->getChildNodes() as $childNode) {
if ($childNode instanceof ViewHelperNode) {
$viewHelperClassName = $childNode->getViewHelperClassName();
if (substr($viewHelperClassName, -14) === 'ThenViewHelper') {
$thenViewHelperEncountered = true;
$childNodesAsClosure = $compiler->wrapChildNodesInClosure($childNode);
$initializationPhpCode .= sprintf('%s[\'__thenClosure\'] = %s;', $argumentsName, $childNodesAsClosure) . chr(10);
} elseif (substr($viewHelperClassName, -14) === 'ElseViewHelper') {
$elseViewHelperEncountered = true;
$childNodesAsClosure = $compiler->wrapChildNodesInClosure($childNode);
$initializationPhpCode .= sprintf('%s[\'__elseClosures\'][] = %s;', $argumentsName, $childNodesAsClosure) . chr(10);
$arguments = $childNode->getArguments();
if (isset($arguments['if'])) {
// The "else" has an argument, indicating it has a secondary (elseif) condition.
// Compile a closure which will evaluate the condition.
$elseIfConditionAsClosure = $compiler->wrapViewHelperNodeArgumentEvaluationInClosure($childNode, 'if');
$initializationPhpCode .= sprintf('%s[\'__elseifClosures\'][] = %s;', $argumentsName, $elseIfConditionAsClosure) . chr(10);
}
}
}
}
if (!$thenViewHelperEncountered && !$elseViewHelperEncountered && !isset($node->getArguments()['then'])) {
$initializationPhpCode .= sprintf('%s[\'__thenClosure\'] = %s;', $argumentsName, $closureName) . chr(10);
}
return parent::compile($argumentsName, $closureName, $initializationPhpCode, $node, $compiler);
} | [
"public",
"function",
"compile",
"(",
"$",
"argumentsName",
",",
"$",
"closureName",
",",
"&",
"$",
"initializationPhpCode",
",",
"ViewHelperNode",
"$",
"node",
",",
"TemplateCompiler",
"$",
"compiler",
")",
"{",
"$",
"thenViewHelperEncountered",
"=",
"$",
"else... | The compiled ViewHelper adds two new ViewHelper arguments: __thenClosure and __elseClosure.
These contain closures which are be executed to render the then(), respectively else() case.
@param string $argumentsName
@param string $closureName
@param string $initializationPhpCode
@param ViewHelperNode $node
@param TemplateCompiler $compiler
@return string | [
"The",
"compiled",
"ViewHelper",
"adds",
"two",
"new",
"ViewHelper",
"arguments",
":",
"__thenClosure",
"and",
"__elseClosure",
".",
"These",
"contain",
"closures",
"which",
"are",
"be",
"executed",
"to",
"render",
"the",
"then",
"()",
"respectively",
"else",
"(... | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.FluidAdaptor/Classes/Core/ViewHelper/AbstractConditionViewHelper.php#L206-L235 |
neos/flow-development-collection | Neos.Flow/Classes/Validation/Validator/DateTimeValidator.php | DateTimeValidator.isValid | protected function isValid($value)
{
if ($value instanceof \DateTimeInterface) {
return;
}
if (!isset($this->options['locale'])) {
$locale = $this->localizationService->getConfiguration()->getDefaultLocale();
} elseif (is_string($this->options['locale'])) {
$locale = new I18n\Locale($this->options['locale']);
} elseif ($this->options['locale'] instanceof I18n\Locale) {
$locale = $this->options['locale'];
} else {
$this->addError('The "locale" option can be only set to string identifier, or Locale object.', 1281454676);
return;
}
$strictMode = $this->options['strictMode'];
$formatLength = $this->options['formatLength'];
DatesReader::validateFormatLength($formatLength);
$formatType = $this->options['formatType'];
DatesReader::validateFormatType($formatType);
if ($formatType === DatesReader::FORMAT_TYPE_TIME) {
if ($this->datetimeParser->parseTime($value, $locale, $formatLength, $strictMode) === false) {
$this->addError('A valid time is expected.', 1281454830);
}
} elseif ($formatType === DatesReader::FORMAT_TYPE_DATETIME) {
if ($this->datetimeParser->parseDateAndTime($value, $locale, $formatLength, $strictMode) === false) {
$this->addError('A valid date and time is expected.', 1281454831);
}
} else {
if ($this->datetimeParser->parseDate($value, $locale, $formatLength, $strictMode) === false) {
$this->addError('A valid date is expected.', 1281454832);
}
}
} | php | protected function isValid($value)
{
if ($value instanceof \DateTimeInterface) {
return;
}
if (!isset($this->options['locale'])) {
$locale = $this->localizationService->getConfiguration()->getDefaultLocale();
} elseif (is_string($this->options['locale'])) {
$locale = new I18n\Locale($this->options['locale']);
} elseif ($this->options['locale'] instanceof I18n\Locale) {
$locale = $this->options['locale'];
} else {
$this->addError('The "locale" option can be only set to string identifier, or Locale object.', 1281454676);
return;
}
$strictMode = $this->options['strictMode'];
$formatLength = $this->options['formatLength'];
DatesReader::validateFormatLength($formatLength);
$formatType = $this->options['formatType'];
DatesReader::validateFormatType($formatType);
if ($formatType === DatesReader::FORMAT_TYPE_TIME) {
if ($this->datetimeParser->parseTime($value, $locale, $formatLength, $strictMode) === false) {
$this->addError('A valid time is expected.', 1281454830);
}
} elseif ($formatType === DatesReader::FORMAT_TYPE_DATETIME) {
if ($this->datetimeParser->parseDateAndTime($value, $locale, $formatLength, $strictMode) === false) {
$this->addError('A valid date and time is expected.', 1281454831);
}
} else {
if ($this->datetimeParser->parseDate($value, $locale, $formatLength, $strictMode) === false) {
$this->addError('A valid date is expected.', 1281454832);
}
}
} | [
"protected",
"function",
"isValid",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"instanceof",
"\\",
"DateTimeInterface",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"options",
"[",
"'locale'",
"]",
")",
")... | Checks if the given value is a valid DateTime object.
@param mixed $value The value that should be validated
@return void
@api | [
"Checks",
"if",
"the",
"given",
"value",
"is",
"a",
"valid",
"DateTime",
"object",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Validation/Validator/DateTimeValidator.php#L54-L91 |
neos/flow-development-collection | Neos.Flow/Classes/Mvc/ViewConfigurationManager.php | ViewConfigurationManager.getViewConfiguration | public function getViewConfiguration(ActionRequest $request)
{
$cacheIdentifier = $this->createCacheIdentifier($request);
$viewConfiguration = $this->cache->get($cacheIdentifier);
if ($viewConfiguration === false) {
$configurations = $this->configurationManager->getConfiguration('Views');
$requestMatcher = new RequestMatcher($request);
$context = new Context($requestMatcher);
$viewConfiguration = [];
$highestWeight = -1;
foreach ($configurations as $order => $configuration) {
$requestMatcher->resetWeight();
if (!isset($configuration['requestFilter'])) {
$weight = $order;
} else {
$result = $this->eelEvaluator->evaluate($configuration['requestFilter'], $context);
if ($result === false) {
continue;
}
$weight = $requestMatcher->getWeight() + $order;
}
if ($weight > $highestWeight) {
$viewConfiguration = $configuration;
$highestWeight = $weight;
}
}
$this->cache->set($cacheIdentifier, $viewConfiguration);
}
return $viewConfiguration;
} | php | public function getViewConfiguration(ActionRequest $request)
{
$cacheIdentifier = $this->createCacheIdentifier($request);
$viewConfiguration = $this->cache->get($cacheIdentifier);
if ($viewConfiguration === false) {
$configurations = $this->configurationManager->getConfiguration('Views');
$requestMatcher = new RequestMatcher($request);
$context = new Context($requestMatcher);
$viewConfiguration = [];
$highestWeight = -1;
foreach ($configurations as $order => $configuration) {
$requestMatcher->resetWeight();
if (!isset($configuration['requestFilter'])) {
$weight = $order;
} else {
$result = $this->eelEvaluator->evaluate($configuration['requestFilter'], $context);
if ($result === false) {
continue;
}
$weight = $requestMatcher->getWeight() + $order;
}
if ($weight > $highestWeight) {
$viewConfiguration = $configuration;
$highestWeight = $weight;
}
}
$this->cache->set($cacheIdentifier, $viewConfiguration);
}
return $viewConfiguration;
} | [
"public",
"function",
"getViewConfiguration",
"(",
"ActionRequest",
"$",
"request",
")",
"{",
"$",
"cacheIdentifier",
"=",
"$",
"this",
"->",
"createCacheIdentifier",
"(",
"$",
"request",
")",
";",
"$",
"viewConfiguration",
"=",
"$",
"this",
"->",
"cache",
"->... | This method walks through the view configuration and applies
matching configurations in the order of their specifity score.
Possible options are currently the viewObjectName to specify
a different class that will be used to create the view and
an array of options that will be set on the view object.
@param ActionRequest $request
@return array | [
"This",
"method",
"walks",
"through",
"the",
"view",
"configuration",
"and",
"applies",
"matching",
"configurations",
"in",
"the",
"order",
"of",
"their",
"specifity",
"score",
".",
"Possible",
"options",
"are",
"currently",
"the",
"viewObjectName",
"to",
"specify... | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Mvc/ViewConfigurationManager.php#L58-L91 |
neos/flow-development-collection | Neos.Flow/Classes/Mvc/ViewConfigurationManager.php | ViewConfigurationManager.createCacheIdentifier | protected function createCacheIdentifier($request)
{
$cacheIdentifiersParts = [];
do {
$cacheIdentifiersParts[] = $request->getControllerPackageKey();
$cacheIdentifiersParts[] = $request->getControllerSubpackageKey();
$cacheIdentifiersParts[] = $request->getControllerName();
$cacheIdentifiersParts[] = $request->getControllerActionName();
$cacheIdentifiersParts[] = $request->getFormat();
$request = $request->getParentRequest();
} while ($request instanceof ActionRequest);
return md5(implode('-', $cacheIdentifiersParts));
} | php | protected function createCacheIdentifier($request)
{
$cacheIdentifiersParts = [];
do {
$cacheIdentifiersParts[] = $request->getControllerPackageKey();
$cacheIdentifiersParts[] = $request->getControllerSubpackageKey();
$cacheIdentifiersParts[] = $request->getControllerName();
$cacheIdentifiersParts[] = $request->getControllerActionName();
$cacheIdentifiersParts[] = $request->getFormat();
$request = $request->getParentRequest();
} while ($request instanceof ActionRequest);
return md5(implode('-', $cacheIdentifiersParts));
} | [
"protected",
"function",
"createCacheIdentifier",
"(",
"$",
"request",
")",
"{",
"$",
"cacheIdentifiersParts",
"=",
"[",
"]",
";",
"do",
"{",
"$",
"cacheIdentifiersParts",
"[",
"]",
"=",
"$",
"request",
"->",
"getControllerPackageKey",
"(",
")",
";",
"$",
"c... | Create a complete cache identifier for the given
request that conforms to cache identifier syntax
@param RequestInterface $request
@return string | [
"Create",
"a",
"complete",
"cache",
"identifier",
"for",
"the",
"given",
"request",
"that",
"conforms",
"to",
"cache",
"identifier",
"syntax"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Mvc/ViewConfigurationManager.php#L100-L112 |
neos/flow-development-collection | Neos.Flow/Classes/Security/Authorization/Privilege/Entity/Doctrine/EntityPrivilege.php | EntityPrivilege.getSqlConstraint | public function getSqlConstraint(ClassMetadata $targetEntity, $targetTableAlias)
{
$this->evaluateMatcher();
/** @var EntityManager $entityManager */
$entityManager = $this->objectManager->get(EntityManagerInterface::class);
$sqlFilter = new SqlFilter($entityManager);
if (!$this->matchesEntityType($targetEntity->getName())) {
return null;
}
return $this->conditionGenerator->getSql($sqlFilter, $targetEntity, $targetTableAlias);
} | php | public function getSqlConstraint(ClassMetadata $targetEntity, $targetTableAlias)
{
$this->evaluateMatcher();
/** @var EntityManager $entityManager */
$entityManager = $this->objectManager->get(EntityManagerInterface::class);
$sqlFilter = new SqlFilter($entityManager);
if (!$this->matchesEntityType($targetEntity->getName())) {
return null;
}
return $this->conditionGenerator->getSql($sqlFilter, $targetEntity, $targetTableAlias);
} | [
"public",
"function",
"getSqlConstraint",
"(",
"ClassMetadata",
"$",
"targetEntity",
",",
"$",
"targetTableAlias",
")",
"{",
"$",
"this",
"->",
"evaluateMatcher",
"(",
")",
";",
"/** @var EntityManager $entityManager */",
"$",
"entityManager",
"=",
"$",
"this",
"->"... | Note: The result of this method cannot be cached, as the target table alias might change for different query scenarios
@param ClassMetadata $targetEntity
@param string $targetTableAlias
@return string | [
"Note",
":",
"The",
"result",
"of",
"this",
"method",
"cannot",
"be",
"cached",
"as",
"the",
"target",
"table",
"alias",
"might",
"change",
"for",
"different",
"query",
"scenarios"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Authorization/Privilege/Entity/Doctrine/EntityPrivilege.php#L67-L80 |
neos/flow-development-collection | Neos.Flow/Classes/Security/Authorization/Privilege/Entity/Doctrine/EntityPrivilege.php | EntityPrivilege.evaluateMatcher | protected function evaluateMatcher()
{
if ($this->isEvaluated) {
return;
}
$context = new EelContext($this->getConditionGenerator());
/** @var EntityPrivilegeExpressionEvaluator $evaluator */
$evaluator = $this->objectManager->get(EntityPrivilegeExpressionEvaluator::class);
$result = $evaluator->evaluate($this->getParsedMatcher(), $context);
$this->entityType = $result['entityType'];
$this->conditionGenerator = $result['conditionGenerator'] !== null ? $result['conditionGenerator'] : new TrueConditionGenerator();
$this->isEvaluated = true;
} | php | protected function evaluateMatcher()
{
if ($this->isEvaluated) {
return;
}
$context = new EelContext($this->getConditionGenerator());
/** @var EntityPrivilegeExpressionEvaluator $evaluator */
$evaluator = $this->objectManager->get(EntityPrivilegeExpressionEvaluator::class);
$result = $evaluator->evaluate($this->getParsedMatcher(), $context);
$this->entityType = $result['entityType'];
$this->conditionGenerator = $result['conditionGenerator'] !== null ? $result['conditionGenerator'] : new TrueConditionGenerator();
$this->isEvaluated = true;
} | [
"protected",
"function",
"evaluateMatcher",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isEvaluated",
")",
"{",
"return",
";",
"}",
"$",
"context",
"=",
"new",
"EelContext",
"(",
"$",
"this",
"->",
"getConditionGenerator",
"(",
")",
")",
";",
"/** @var... | parses the matcher of this privilege using Eel and extracts "entityType" and "conditionGenerator"
@return void | [
"parses",
"the",
"matcher",
"of",
"this",
"privilege",
"using",
"Eel",
"and",
"extracts",
"entityType",
"and",
"conditionGenerator"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Authorization/Privilege/Entity/Doctrine/EntityPrivilege.php#L87-L100 |
neos/flow-development-collection | Neos.Cache/Classes/Psr/Cache/CacheFactory.php | CacheFactory.create | public function create($cacheIdentifier, $backendObjectName, array $backendOptions = []): CacheItemPoolInterface
{
$backend = $this->instantiateBackend($backendObjectName, $backendOptions, $this->environmentConfiguration);
$cache = $this->instantiateCache($cacheIdentifier, $backend);
// TODO: Remove this need.
$fakeFrontend = new VariableFrontend($cacheIdentifier, $backend);
$backend->setCache($fakeFrontend);
return $cache;
} | php | public function create($cacheIdentifier, $backendObjectName, array $backendOptions = []): CacheItemPoolInterface
{
$backend = $this->instantiateBackend($backendObjectName, $backendOptions, $this->environmentConfiguration);
$cache = $this->instantiateCache($cacheIdentifier, $backend);
// TODO: Remove this need.
$fakeFrontend = new VariableFrontend($cacheIdentifier, $backend);
$backend->setCache($fakeFrontend);
return $cache;
} | [
"public",
"function",
"create",
"(",
"$",
"cacheIdentifier",
",",
"$",
"backendObjectName",
",",
"array",
"$",
"backendOptions",
"=",
"[",
"]",
")",
":",
"CacheItemPoolInterface",
"{",
"$",
"backend",
"=",
"$",
"this",
"->",
"instantiateBackend",
"(",
"$",
"... | Factory method which creates the specified cache along with the specified kind of backend.
The identifier uniquely identifiers the specific cache, so that entries inside are unique.
@param string $cacheIdentifier The name / identifier of the cache to create.
@param string $backendObjectName Object name of the cache backend
@param array $backendOptions (optional) Array of backend options
@return CacheItemPoolInterface
@throws InvalidBackendException | [
"Factory",
"method",
"which",
"creates",
"the",
"specified",
"cache",
"along",
"with",
"the",
"specified",
"kind",
"of",
"backend",
".",
"The",
"identifier",
"uniquely",
"identifiers",
"the",
"specific",
"cache",
"so",
"that",
"entries",
"inside",
"are",
"unique... | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Cache/Classes/Psr/Cache/CacheFactory.php#L42-L51 |
neos/flow-development-collection | Neos.Eel/Classes/FlowQuery/Operations/SliceOperation.php | SliceOperation.evaluate | public function evaluate(FlowQuery $flowQuery, array $arguments)
{
$context = $flowQuery->getContext();
if ($context instanceof \Iterator) {
$context = iterator_to_array($context);
}
if (isset($arguments[0]) && isset($arguments[1])) {
$context = array_slice($context, (integer)$arguments[0], (integer)$arguments[1] - (integer)$arguments[0]);
} elseif (isset($arguments[0])) {
$context = array_slice($context, (integer)$arguments[0]);
}
$flowQuery->setContext($context);
} | php | public function evaluate(FlowQuery $flowQuery, array $arguments)
{
$context = $flowQuery->getContext();
if ($context instanceof \Iterator) {
$context = iterator_to_array($context);
}
if (isset($arguments[0]) && isset($arguments[1])) {
$context = array_slice($context, (integer)$arguments[0], (integer)$arguments[1] - (integer)$arguments[0]);
} elseif (isset($arguments[0])) {
$context = array_slice($context, (integer)$arguments[0]);
}
$flowQuery->setContext($context);
} | [
"public",
"function",
"evaluate",
"(",
"FlowQuery",
"$",
"flowQuery",
",",
"array",
"$",
"arguments",
")",
"{",
"$",
"context",
"=",
"$",
"flowQuery",
"->",
"getContext",
"(",
")",
";",
"if",
"(",
"$",
"context",
"instanceof",
"\\",
"Iterator",
")",
"{",... | {@inheritdoc}
@param FlowQuery $flowQuery the FlowQuery object
@param array $arguments A mandatory start and optional end index in the context, negative indices indicate an offset from the start or end respectively
@return void | [
"{",
"@inheritdoc",
"}"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Eel/Classes/FlowQuery/Operations/SliceOperation.php#L38-L51 |
neos/flow-development-collection | Neos.Flow/Classes/Log/LoggerFactory.php | LoggerFactory.create | public function create($identifier, $loggerObjectName, $backendObjectNames, array $backendOptions = [])
{
if (!isset($this->logInstanceCache[$identifier])) {
if (is_a($loggerObjectName, DefaultLogger::class, true)) {
$logger = $this->instantiateLogger($loggerObjectName, $backendObjectNames, $backendOptions);
} else {
$logger = $this->createPsrBasedLogger($identifier, $loggerObjectName);
}
$this->logInstanceCache[$identifier] = $logger;
}
return $this->logInstanceCache[$identifier];
} | php | public function create($identifier, $loggerObjectName, $backendObjectNames, array $backendOptions = [])
{
if (!isset($this->logInstanceCache[$identifier])) {
if (is_a($loggerObjectName, DefaultLogger::class, true)) {
$logger = $this->instantiateLogger($loggerObjectName, $backendObjectNames, $backendOptions);
} else {
$logger = $this->createPsrBasedLogger($identifier, $loggerObjectName);
}
$this->logInstanceCache[$identifier] = $logger;
}
return $this->logInstanceCache[$identifier];
} | [
"public",
"function",
"create",
"(",
"$",
"identifier",
",",
"$",
"loggerObjectName",
",",
"$",
"backendObjectNames",
",",
"array",
"$",
"backendOptions",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"logInstanceCache",
"[",
... | Factory method which creates the specified logger along with the specified backend(s).
@param string $identifier An identifier for the logger
@param string $loggerObjectName Object name of the log frontend
@param mixed $backendObjectNames Object name (or array of object names) of the log backend(s)
@param array $backendOptions (optional) Array of backend options. If more than one backend is specified, this is an array of array.
@return \Neos\Flow\Log\LoggerInterface The created logger frontend
@api | [
"Factory",
"method",
"which",
"creates",
"the",
"specified",
"logger",
"along",
"with",
"the",
"specified",
"backend",
"(",
"s",
")",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Log/LoggerFactory.php#L92-L105 |
neos/flow-development-collection | Neos.Flow/Classes/Log/LoggerFactory.php | LoggerFactory.instantiateLogger | protected function instantiateLogger(string $loggerObjectName, $backendObjectNames, array $backendOptions = []): LoggerInterface
{
$logger = new $loggerObjectName;
if (is_array($backendObjectNames)) {
foreach ($backendObjectNames as $i => $backendObjectName) {
if (isset($backendOptions[$i])) {
$backend = new $backendObjectName($backendOptions[$i]);
$logger->addBackend($backend);
}
}
} else {
$backend = new $backendObjectNames($backendOptions);
$logger->addBackend($backend);
}
$logger = $this->injectAdditionalDependencies($logger);
return $logger;
} | php | protected function instantiateLogger(string $loggerObjectName, $backendObjectNames, array $backendOptions = []): LoggerInterface
{
$logger = new $loggerObjectName;
if (is_array($backendObjectNames)) {
foreach ($backendObjectNames as $i => $backendObjectName) {
if (isset($backendOptions[$i])) {
$backend = new $backendObjectName($backendOptions[$i]);
$logger->addBackend($backend);
}
}
} else {
$backend = new $backendObjectNames($backendOptions);
$logger->addBackend($backend);
}
$logger = $this->injectAdditionalDependencies($logger);
return $logger;
} | [
"protected",
"function",
"instantiateLogger",
"(",
"string",
"$",
"loggerObjectName",
",",
"$",
"backendObjectNames",
",",
"array",
"$",
"backendOptions",
"=",
"[",
"]",
")",
":",
"LoggerInterface",
"{",
"$",
"logger",
"=",
"new",
"$",
"loggerObjectName",
";",
... | Create a new logger instance.
@param string $loggerObjectName
@param array|string $backendObjectNames
@param array $backendOptions
@return \Neos\Flow\Log\LoggerInterface | [
"Create",
"a",
"new",
"logger",
"instance",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Log/LoggerFactory.php#L128-L145 |
neos/flow-development-collection | Neos.Flow/Classes/Command/ServerCommandController.php | ServerCommandController.runCommand | public function runCommand(string $host = '127.0.0.1', int $port = 8081)
{
$command = Scripts::buildPhpCommand($this->settings);
$address = sprintf('%s:%s', $host, $port);
$command .= ' -S ' . escapeshellarg($address) . ' -t ' . escapeshellarg(FLOW_PATH_WEB) . ' ' . escapeshellarg(FLOW_PATH_FLOW . '/Scripts/PhpDevelopmentServerRouter.php');
$this->outputLine('Server running. Please go to <b>http://' . $address . '</b> to browse the application.');
exec($command);
} | php | public function runCommand(string $host = '127.0.0.1', int $port = 8081)
{
$command = Scripts::buildPhpCommand($this->settings);
$address = sprintf('%s:%s', $host, $port);
$command .= ' -S ' . escapeshellarg($address) . ' -t ' . escapeshellarg(FLOW_PATH_WEB) . ' ' . escapeshellarg(FLOW_PATH_FLOW . '/Scripts/PhpDevelopmentServerRouter.php');
$this->outputLine('Server running. Please go to <b>http://' . $address . '</b> to browse the application.');
exec($command);
} | [
"public",
"function",
"runCommand",
"(",
"string",
"$",
"host",
"=",
"'127.0.0.1'",
",",
"int",
"$",
"port",
"=",
"8081",
")",
"{",
"$",
"command",
"=",
"Scripts",
"::",
"buildPhpCommand",
"(",
"$",
"this",
"->",
"settings",
")",
";",
"$",
"address",
"... | Run a standalone development server
Starts an embedded server, see http://php.net/manual/en/features.commandline.webserver.php
Note: This requires PHP 5.4+
To change the context Flow will run in, you can set the <b>FLOW_CONTEXT</b> environment variable:
<i>export FLOW_CONTEXT=Development && ./flow server:run</i>
@param string $host The host name or IP address for the server to listen on
@param integer $port The server port to listen on
@return void | [
"Run",
"a",
"standalone",
"development",
"server"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Command/ServerCommandController.php#L44-L53 |
neos/flow-development-collection | Neos.Error.Messages/Classes/Result.php | Result.setParent | public function setParent(Result $parent)
{
if ($this->parent !== $parent) {
$this->parent = $parent;
if ($this->hasErrors()) {
$parent->setErrorsExist();
}
if ($this->hasWarnings()) {
$parent->setWarningsExist();
}
if ($this->hasNotices()) {
$parent->setNoticesExist();
}
}
} | php | public function setParent(Result $parent)
{
if ($this->parent !== $parent) {
$this->parent = $parent;
if ($this->hasErrors()) {
$parent->setErrorsExist();
}
if ($this->hasWarnings()) {
$parent->setWarningsExist();
}
if ($this->hasNotices()) {
$parent->setNoticesExist();
}
}
} | [
"public",
"function",
"setParent",
"(",
"Result",
"$",
"parent",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"parent",
"!==",
"$",
"parent",
")",
"{",
"$",
"this",
"->",
"parent",
"=",
"$",
"parent",
";",
"if",
"(",
"$",
"this",
"->",
"hasErrors",
"(",... | Injects the parent result and propagates the
cached error states upwards
@param Result $parent
@return void | [
"Injects",
"the",
"parent",
"result",
"and",
"propagates",
"the",
"cached",
"error",
"states",
"upwards"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Error.Messages/Classes/Result.php#L73-L87 |
neos/flow-development-collection | Neos.Error.Messages/Classes/Result.php | Result.getFirstError | public function getFirstError(string $messageTypeFilter = null)
{
$matchingErrors = $this->filterMessages($this->errors, $messageTypeFilter);
reset($matchingErrors);
return current($matchingErrors);
} | php | public function getFirstError(string $messageTypeFilter = null)
{
$matchingErrors = $this->filterMessages($this->errors, $messageTypeFilter);
reset($matchingErrors);
return current($matchingErrors);
} | [
"public",
"function",
"getFirstError",
"(",
"string",
"$",
"messageTypeFilter",
"=",
"null",
")",
"{",
"$",
"matchingErrors",
"=",
"$",
"this",
"->",
"filterMessages",
"(",
"$",
"this",
"->",
"errors",
",",
"$",
"messageTypeFilter",
")",
";",
"reset",
"(",
... | Get the first error object of the current Result object (non-recursive)
@param string $messageTypeFilter if specified only errors implementing the given class are considered
@return Error
@api | [
"Get",
"the",
"first",
"error",
"object",
"of",
"the",
"current",
"Result",
"object",
"(",
"non",
"-",
"recursive",
")"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Error.Messages/Classes/Result.php#L171-L176 |
neos/flow-development-collection | Neos.Error.Messages/Classes/Result.php | Result.getFirstWarning | public function getFirstWarning(string $messageTypeFilter = null)
{
$matchingWarnings = $this->filterMessages($this->warnings, $messageTypeFilter);
reset($matchingWarnings);
return current($matchingWarnings);
} | php | public function getFirstWarning(string $messageTypeFilter = null)
{
$matchingWarnings = $this->filterMessages($this->warnings, $messageTypeFilter);
reset($matchingWarnings);
return current($matchingWarnings);
} | [
"public",
"function",
"getFirstWarning",
"(",
"string",
"$",
"messageTypeFilter",
"=",
"null",
")",
"{",
"$",
"matchingWarnings",
"=",
"$",
"this",
"->",
"filterMessages",
"(",
"$",
"this",
"->",
"warnings",
",",
"$",
"messageTypeFilter",
")",
";",
"reset",
... | Get the first warning object of the current Result object (non-recursive)
@param string $messageTypeFilter if specified only warnings implementing the given class are considered
@return Warning
@api | [
"Get",
"the",
"first",
"warning",
"object",
"of",
"the",
"current",
"Result",
"object",
"(",
"non",
"-",
"recursive",
")"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Error.Messages/Classes/Result.php#L185-L190 |
neos/flow-development-collection | Neos.Error.Messages/Classes/Result.php | Result.getFirstNotice | public function getFirstNotice(string $messageTypeFilter = null)
{
$matchingNotices = $this->filterMessages($this->notices, $messageTypeFilter);
reset($matchingNotices);
return current($matchingNotices);
} | php | public function getFirstNotice(string $messageTypeFilter = null)
{
$matchingNotices = $this->filterMessages($this->notices, $messageTypeFilter);
reset($matchingNotices);
return current($matchingNotices);
} | [
"public",
"function",
"getFirstNotice",
"(",
"string",
"$",
"messageTypeFilter",
"=",
"null",
")",
"{",
"$",
"matchingNotices",
"=",
"$",
"this",
"->",
"filterMessages",
"(",
"$",
"this",
"->",
"notices",
",",
"$",
"messageTypeFilter",
")",
";",
"reset",
"("... | Get the first notice object of the current Result object (non-recursive)
@param string $messageTypeFilter if specified only notices implementing the given class are considered
@return Notice
@api | [
"Get",
"the",
"first",
"notice",
"object",
"of",
"the",
"current",
"Result",
"object",
"(",
"non",
"-",
"recursive",
")"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Error.Messages/Classes/Result.php#L199-L204 |
neos/flow-development-collection | Neos.Error.Messages/Classes/Result.php | Result.forProperty | public function forProperty(string $propertyPath = null): Result
{
if ($propertyPath === '' || $propertyPath === null) {
return $this;
}
if (strpos($propertyPath, '.') !== false) {
return $this->recurseThroughResult(explode('.', $propertyPath));
}
if (!isset($this->propertyResults[$propertyPath])) {
$newResult = new Result();
$newResult->setParent($this);
$this->propertyResults[$propertyPath] = $newResult;
}
return $this->propertyResults[$propertyPath];
} | php | public function forProperty(string $propertyPath = null): Result
{
if ($propertyPath === '' || $propertyPath === null) {
return $this;
}
if (strpos($propertyPath, '.') !== false) {
return $this->recurseThroughResult(explode('.', $propertyPath));
}
if (!isset($this->propertyResults[$propertyPath])) {
$newResult = new Result();
$newResult->setParent($this);
$this->propertyResults[$propertyPath] = $newResult;
}
return $this->propertyResults[$propertyPath];
} | [
"public",
"function",
"forProperty",
"(",
"string",
"$",
"propertyPath",
"=",
"null",
")",
":",
"Result",
"{",
"if",
"(",
"$",
"propertyPath",
"===",
"''",
"||",
"$",
"propertyPath",
"===",
"null",
")",
"{",
"return",
"$",
"this",
";",
"}",
"if",
"(",
... | Return a Result object for the given property path. This is
a fluent interface, so you will probably use it like:
$result->forProperty('foo.bar')->getErrors() -- to get all errors
for property "foo.bar"
@param string $propertyPath
@return Result
@api | [
"Return",
"a",
"Result",
"object",
"for",
"the",
"given",
"property",
"path",
".",
"This",
"is",
"a",
"fluent",
"interface",
"so",
"you",
"will",
"probably",
"use",
"it",
"like",
":",
"$result",
"-",
">",
"forProperty",
"(",
"foo",
".",
"bar",
")",
"-"... | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Error.Messages/Classes/Result.php#L216-L230 |
neos/flow-development-collection | Neos.Error.Messages/Classes/Result.php | Result.recurseThroughResult | public function recurseThroughResult(array $pathSegments): Result
{
if (count($pathSegments) === 0) {
return $this;
}
$propertyName = array_shift($pathSegments);
if (!isset($this->propertyResults[$propertyName])) {
$newResult = new Result();
$newResult->setParent($this);
$this->propertyResults[$propertyName] = $newResult;
}
/** @var Result $result */
$result = $this->propertyResults[$propertyName];
return $result->recurseThroughResult($pathSegments);
} | php | public function recurseThroughResult(array $pathSegments): Result
{
if (count($pathSegments) === 0) {
return $this;
}
$propertyName = array_shift($pathSegments);
if (!isset($this->propertyResults[$propertyName])) {
$newResult = new Result();
$newResult->setParent($this);
$this->propertyResults[$propertyName] = $newResult;
}
/** @var Result $result */
$result = $this->propertyResults[$propertyName];
return $result->recurseThroughResult($pathSegments);
} | [
"public",
"function",
"recurseThroughResult",
"(",
"array",
"$",
"pathSegments",
")",
":",
"Result",
"{",
"if",
"(",
"count",
"(",
"$",
"pathSegments",
")",
"===",
"0",
")",
"{",
"return",
"$",
"this",
";",
"}",
"$",
"propertyName",
"=",
"array_shift",
"... | Internal use only!
@param array $pathSegments
@return Result | [
"Internal",
"use",
"only!"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Error.Messages/Classes/Result.php#L238-L255 |
neos/flow-development-collection | Neos.Error.Messages/Classes/Result.php | Result.setErrorsExist | protected function setErrorsExist()
{
$this->errorsExist = true;
if ($this->parent !== null) {
$this->parent->setErrorsExist();
}
} | php | protected function setErrorsExist()
{
$this->errorsExist = true;
if ($this->parent !== null) {
$this->parent->setErrorsExist();
}
} | [
"protected",
"function",
"setErrorsExist",
"(",
")",
"{",
"$",
"this",
"->",
"errorsExist",
"=",
"true",
";",
"if",
"(",
"$",
"this",
"->",
"parent",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"parent",
"->",
"setErrorsExist",
"(",
")",
";",
"}",
"}... | Sets the error cache to true and propagates the information
upwards the Result-Object Tree
@return void | [
"Sets",
"the",
"error",
"cache",
"to",
"true",
"and",
"propagates",
"the",
"information",
"upwards",
"the",
"Result",
"-",
"Object",
"Tree"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Error.Messages/Classes/Result.php#L274-L280 |
neos/flow-development-collection | Neos.Error.Messages/Classes/Result.php | Result.setWarningsExist | protected function setWarningsExist()
{
$this->warningsExist = true;
if ($this->parent !== null) {
$this->parent->setWarningsExist();
}
} | php | protected function setWarningsExist()
{
$this->warningsExist = true;
if ($this->parent !== null) {
$this->parent->setWarningsExist();
}
} | [
"protected",
"function",
"setWarningsExist",
"(",
")",
"{",
"$",
"this",
"->",
"warningsExist",
"=",
"true",
";",
"if",
"(",
"$",
"this",
"->",
"parent",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"parent",
"->",
"setWarningsExist",
"(",
")",
";",
"}"... | Sets the warning cache to true and propagates the information
upwards the Result-Object Tree
@return void | [
"Sets",
"the",
"warning",
"cache",
"to",
"true",
"and",
"propagates",
"the",
"information",
"upwards",
"the",
"Result",
"-",
"Object",
"Tree"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Error.Messages/Classes/Result.php#L299-L305 |
neos/flow-development-collection | Neos.Error.Messages/Classes/Result.php | Result.setNoticesExist | protected function setNoticesExist()
{
$this->noticesExist = true;
if ($this->parent !== null) {
$this->parent->setNoticesExist();
}
} | php | protected function setNoticesExist()
{
$this->noticesExist = true;
if ($this->parent !== null) {
$this->parent->setNoticesExist();
}
} | [
"protected",
"function",
"setNoticesExist",
"(",
")",
"{",
"$",
"this",
"->",
"noticesExist",
"=",
"true",
";",
"if",
"(",
"$",
"this",
"->",
"parent",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"parent",
"->",
"setNoticesExist",
"(",
")",
";",
"}",
... | Sets the notices cache to true and propagates the information
upwards the Result-Object Tree
@return void | [
"Sets",
"the",
"notices",
"cache",
"to",
"true",
"and",
"propagates",
"the",
"information",
"upwards",
"the",
"Result",
"-",
"Object",
"Tree"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Error.Messages/Classes/Result.php#L324-L330 |
neos/flow-development-collection | Neos.Error.Messages/Classes/Result.php | Result.flattenTree | public function flattenTree(string $propertyName, array &$result, array $level = [], string $messageTypeFilter = null)
{
if (count($this->$propertyName) > 0) {
$propertyPath = implode('.', $level);
$result[$propertyPath] = $this->filterMessages($this->$propertyName, $messageTypeFilter);
}
/** @var Result $subResult */
foreach ($this->propertyResults as $subPropertyName => $subResult) {
array_push($level, $subPropertyName);
$subResult->flattenTree($propertyName, $result, $level, $messageTypeFilter);
array_pop($level);
}
} | php | public function flattenTree(string $propertyName, array &$result, array $level = [], string $messageTypeFilter = null)
{
if (count($this->$propertyName) > 0) {
$propertyPath = implode('.', $level);
$result[$propertyPath] = $this->filterMessages($this->$propertyName, $messageTypeFilter);
}
/** @var Result $subResult */
foreach ($this->propertyResults as $subPropertyName => $subResult) {
array_push($level, $subPropertyName);
$subResult->flattenTree($propertyName, $result, $level, $messageTypeFilter);
array_pop($level);
}
} | [
"public",
"function",
"flattenTree",
"(",
"string",
"$",
"propertyName",
",",
"array",
"&",
"$",
"result",
",",
"array",
"$",
"level",
"=",
"[",
"]",
",",
"string",
"$",
"messageTypeFilter",
"=",
"null",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"this",
... | Flatten a tree of Result objects, based on a certain property.
@param string $propertyName
@param array $result The current result to be flattened
@param array $level The property path in the format array('level1', 'level2', ...) for recursion
@param string $messageTypeFilter If specified only messages implementing the given class name are taken into account
@return void | [
"Flatten",
"a",
"tree",
"of",
"Result",
"objects",
"based",
"on",
"a",
"certain",
"property",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Error.Messages/Classes/Result.php#L413-L425 |
neos/flow-development-collection | Neos.Error.Messages/Classes/Result.php | Result.merge | public function merge(Result $otherResult)
{
if ($otherResult->errorsExist) {
$this->mergeProperty($otherResult, 'getErrors', 'addError');
}
if ($otherResult->warningsExist) {
$this->mergeProperty($otherResult, 'getWarnings', 'addWarning');
}
if ($otherResult->noticesExist) {
$this->mergeProperty($otherResult, 'getNotices', 'addNotice');
}
/** @var $subResult Result */
foreach ($otherResult->getSubResults() as $subPropertyName => $subResult) {
if (array_key_exists($subPropertyName, $this->propertyResults) && $this->propertyResults[$subPropertyName]->hasMessages()) {
$this->forProperty($subPropertyName)->merge($subResult);
} else {
$this->propertyResults[$subPropertyName] = $subResult;
$subResult->setParent($this);
}
}
} | php | public function merge(Result $otherResult)
{
if ($otherResult->errorsExist) {
$this->mergeProperty($otherResult, 'getErrors', 'addError');
}
if ($otherResult->warningsExist) {
$this->mergeProperty($otherResult, 'getWarnings', 'addWarning');
}
if ($otherResult->noticesExist) {
$this->mergeProperty($otherResult, 'getNotices', 'addNotice');
}
/** @var $subResult Result */
foreach ($otherResult->getSubResults() as $subPropertyName => $subResult) {
if (array_key_exists($subPropertyName, $this->propertyResults) && $this->propertyResults[$subPropertyName]->hasMessages()) {
$this->forProperty($subPropertyName)->merge($subResult);
} else {
$this->propertyResults[$subPropertyName] = $subResult;
$subResult->setParent($this);
}
}
} | [
"public",
"function",
"merge",
"(",
"Result",
"$",
"otherResult",
")",
"{",
"if",
"(",
"$",
"otherResult",
"->",
"errorsExist",
")",
"{",
"$",
"this",
"->",
"mergeProperty",
"(",
"$",
"otherResult",
",",
"'getErrors'",
",",
"'addError'",
")",
";",
"}",
"... | Merge the given Result object into this one.
@param Result $otherResult
@return void
@api | [
"Merge",
"the",
"given",
"Result",
"object",
"into",
"this",
"one",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Error.Messages/Classes/Result.php#L449-L470 |
neos/flow-development-collection | Neos.Error.Messages/Classes/Result.php | Result.mergeProperty | protected function mergeProperty(Result $otherResult, string $getterName, string $adderName)
{
foreach ($otherResult->$getterName() as $messageInOtherResult) {
$this->$adderName($messageInOtherResult);
}
} | php | protected function mergeProperty(Result $otherResult, string $getterName, string $adderName)
{
foreach ($otherResult->$getterName() as $messageInOtherResult) {
$this->$adderName($messageInOtherResult);
}
} | [
"protected",
"function",
"mergeProperty",
"(",
"Result",
"$",
"otherResult",
",",
"string",
"$",
"getterName",
",",
"string",
"$",
"adderName",
")",
"{",
"foreach",
"(",
"$",
"otherResult",
"->",
"$",
"getterName",
"(",
")",
"as",
"$",
"messageInOtherResult",
... | Merge a single property from the other result object.
@param Result $otherResult
@param string $getterName
@param string $adderName
@return void | [
"Merge",
"a",
"single",
"property",
"from",
"the",
"other",
"result",
"object",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Error.Messages/Classes/Result.php#L480-L485 |
neos/flow-development-collection | Neos.Error.Messages/Classes/Result.php | Result.clear | public function clear()
{
$this->errors = [];
$this->notices = [];
$this->warnings = [];
$this->warningsExist = false;
$this->noticesExist = false;
$this->errorsExist = false;
$this->propertyResults = [];
} | php | public function clear()
{
$this->errors = [];
$this->notices = [];
$this->warnings = [];
$this->warningsExist = false;
$this->noticesExist = false;
$this->errorsExist = false;
$this->propertyResults = [];
} | [
"public",
"function",
"clear",
"(",
")",
"{",
"$",
"this",
"->",
"errors",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"notices",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"warnings",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"warningsExist",
"=",
"false",
... | Clears the result
@return void | [
"Clears",
"the",
"result"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Error.Messages/Classes/Result.php#L502-L513 |
neos/flow-development-collection | Neos.Flow/Classes/Security/Authorization/Privilege/Method/MethodPrivilege.php | MethodPrivilege.matchesSubject | public function matchesSubject(PrivilegeSubjectInterface $subject): bool
{
if ($subject instanceof MethodPrivilegeSubject === false) {
throw new InvalidPrivilegeTypeException(sprintf('Privileges of type "%s" only support subjects of type "%s", but we got a subject of type: "%s".', MethodPrivilegeInterface::class, MethodPrivilegeSubject::class, get_class($subject)), 1416241148);
}
$this->initialize();
$joinPoint = $subject->getJoinPoint();
$methodIdentifier = strtolower($joinPoint->getClassName() . '->' . $joinPoint->getMethodName());
if (!isset(static::$methodPermissions[$methodIdentifier][$this->getCacheEntryIdentifier()])) {
return false;
}
if (
static::$methodPermissions[$methodIdentifier][$this->getCacheEntryIdentifier()]['hasRuntimeEvaluations']
&& $this->runtimeExpressionEvaluator->evaluate($this->getCacheEntryIdentifier(), $joinPoint) === false
) {
return false;
}
return true;
} | php | public function matchesSubject(PrivilegeSubjectInterface $subject): bool
{
if ($subject instanceof MethodPrivilegeSubject === false) {
throw new InvalidPrivilegeTypeException(sprintf('Privileges of type "%s" only support subjects of type "%s", but we got a subject of type: "%s".', MethodPrivilegeInterface::class, MethodPrivilegeSubject::class, get_class($subject)), 1416241148);
}
$this->initialize();
$joinPoint = $subject->getJoinPoint();
$methodIdentifier = strtolower($joinPoint->getClassName() . '->' . $joinPoint->getMethodName());
if (!isset(static::$methodPermissions[$methodIdentifier][$this->getCacheEntryIdentifier()])) {
return false;
}
if (
static::$methodPermissions[$methodIdentifier][$this->getCacheEntryIdentifier()]['hasRuntimeEvaluations']
&& $this->runtimeExpressionEvaluator->evaluate($this->getCacheEntryIdentifier(), $joinPoint) === false
) {
return false;
}
return true;
} | [
"public",
"function",
"matchesSubject",
"(",
"PrivilegeSubjectInterface",
"$",
"subject",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"subject",
"instanceof",
"MethodPrivilegeSubject",
"===",
"false",
")",
"{",
"throw",
"new",
"InvalidPrivilegeTypeException",
"(",
"sprin... | Returns true, if this privilege covers the given subject (join point)
@param PrivilegeSubjectInterface $subject
@return boolean
@throws InvalidPrivilegeTypeException
@throws \Neos\Flow\Exception
@throws \Neos\Cache\Exception\NoSuchCacheException | [
"Returns",
"true",
"if",
"this",
"privilege",
"covers",
"the",
"given",
"subject",
"(",
"join",
"point",
")"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Authorization/Privilege/Method/MethodPrivilege.php#L89-L112 |
neos/flow-development-collection | Neos.Flow/Classes/Security/Authorization/Privilege/Method/MethodPrivilege.php | MethodPrivilege.matchesMethod | public function matchesMethod($className, $methodName): bool
{
$this->initialize();
$methodIdentifier = strtolower($className . '->' . $methodName);
if (isset(static::$methodPermissions[$methodIdentifier][$this->getCacheEntryIdentifier()])) {
return true;
}
return false;
} | php | public function matchesMethod($className, $methodName): bool
{
$this->initialize();
$methodIdentifier = strtolower($className . '->' . $methodName);
if (isset(static::$methodPermissions[$methodIdentifier][$this->getCacheEntryIdentifier()])) {
return true;
}
return false;
} | [
"public",
"function",
"matchesMethod",
"(",
"$",
"className",
",",
"$",
"methodName",
")",
":",
"bool",
"{",
"$",
"this",
"->",
"initialize",
"(",
")",
";",
"$",
"methodIdentifier",
"=",
"strtolower",
"(",
"$",
"className",
".",
"'->'",
".",
"$",
"method... | Returns true, if this privilege covers the given method
@param string $className
@param string $methodName
@return boolean
@throws \Neos\Cache\Exception\NoSuchCacheException | [
"Returns",
"true",
"if",
"this",
"privilege",
"covers",
"the",
"given",
"method"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Authorization/Privilege/Method/MethodPrivilege.php#L122-L132 |
neos/flow-development-collection | Neos.Flow/Classes/Security/Authorization/Privilege/Method/MethodPrivilege.php | MethodPrivilege.getPointcutFilterComposite | public function getPointcutFilterComposite(): PointcutFilterComposite
{
if ($this->pointcutFilter === null) {
/** @var MethodTargetExpressionParser $methodTargetExpressionParser */
$methodTargetExpressionParser = $this->objectManager->get(MethodTargetExpressionParser::class);
$this->pointcutFilter = $methodTargetExpressionParser->parse($this->getParsedMatcher(), 'Policy privilege "' . $this->getPrivilegeTargetIdentifier() . '"');
}
return $this->pointcutFilter;
} | php | public function getPointcutFilterComposite(): PointcutFilterComposite
{
if ($this->pointcutFilter === null) {
/** @var MethodTargetExpressionParser $methodTargetExpressionParser */
$methodTargetExpressionParser = $this->objectManager->get(MethodTargetExpressionParser::class);
$this->pointcutFilter = $methodTargetExpressionParser->parse($this->getParsedMatcher(), 'Policy privilege "' . $this->getPrivilegeTargetIdentifier() . '"');
}
return $this->pointcutFilter;
} | [
"public",
"function",
"getPointcutFilterComposite",
"(",
")",
":",
"PointcutFilterComposite",
"{",
"if",
"(",
"$",
"this",
"->",
"pointcutFilter",
"===",
"null",
")",
"{",
"/** @var MethodTargetExpressionParser $methodTargetExpressionParser */",
"$",
"methodTargetExpressionPa... | Returns the pointcut filter composite, matching all methods covered by this privilege
@return PointcutFilterComposite
@throws \Neos\Flow\Aop\Exception
@throws \Neos\Flow\Aop\Exception\InvalidPointcutExpressionException | [
"Returns",
"the",
"pointcut",
"filter",
"composite",
"matching",
"all",
"methods",
"covered",
"by",
"this",
"privilege"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Authorization/Privilege/Method/MethodPrivilege.php#L141-L150 |
neos/flow-development-collection | Neos.Flow/Classes/Security/Authorization/FilterFirewall.php | FilterFirewall.injectSettings | public function injectSettings(array $settings)
{
$this->rejectAll = $settings['security']['firewall']['rejectAll'];
$this->filters = array_map([$this, 'createFilterFromConfiguration'], array_values($settings['security']['firewall']['filters']));
} | php | public function injectSettings(array $settings)
{
$this->rejectAll = $settings['security']['firewall']['rejectAll'];
$this->filters = array_map([$this, 'createFilterFromConfiguration'], array_values($settings['security']['firewall']['filters']));
} | [
"public",
"function",
"injectSettings",
"(",
"array",
"$",
"settings",
")",
"{",
"$",
"this",
"->",
"rejectAll",
"=",
"$",
"settings",
"[",
"'security'",
"]",
"[",
"'firewall'",
"]",
"[",
"'rejectAll'",
"]",
";",
"$",
"this",
"->",
"filters",
"=",
"array... | Injects the configuration settings
@param array $settings
@return void | [
"Injects",
"the",
"configuration",
"settings"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Authorization/FilterFirewall.php#L77-L81 |
neos/flow-development-collection | Neos.Flow/Classes/Security/Authorization/FilterFirewall.php | FilterFirewall.blockIllegalRequests | public function blockIllegalRequests(ActionRequest $request)
{
$filterMatched = array_reduce($this->filters, function (bool $filterMatched, RequestFilter $filter) use ($request) {
return ($filter->filterRequest($request) ? true : $filterMatched);
}, false);
if ($this->rejectAll && !$filterMatched) {
throw new AccessDeniedException('The request was blocked, because no request filter explicitly allowed it.', 1216923741);
}
} | php | public function blockIllegalRequests(ActionRequest $request)
{
$filterMatched = array_reduce($this->filters, function (bool $filterMatched, RequestFilter $filter) use ($request) {
return ($filter->filterRequest($request) ? true : $filterMatched);
}, false);
if ($this->rejectAll && !$filterMatched) {
throw new AccessDeniedException('The request was blocked, because no request filter explicitly allowed it.', 1216923741);
}
} | [
"public",
"function",
"blockIllegalRequests",
"(",
"ActionRequest",
"$",
"request",
")",
"{",
"$",
"filterMatched",
"=",
"array_reduce",
"(",
"$",
"this",
"->",
"filters",
",",
"function",
"(",
"bool",
"$",
"filterMatched",
",",
"RequestFilter",
"$",
"filter",
... | Analyzes a request against the configured firewall rules and blocks
any illegal request.
@param ActionRequest $request The request to be analyzed
@return void
@throws AccessDeniedException if the | [
"Analyzes",
"a",
"request",
"against",
"the",
"configured",
"firewall",
"rules",
"and",
"blocks",
"any",
"illegal",
"request",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Security/Authorization/FilterFirewall.php#L91-L100 |
neos/flow-development-collection | Neos.Flow/Classes/Composer/InstallerScripts.php | InstallerScripts.postUpdateAndInstall | public static function postUpdateAndInstall(Event $event)
{
if (!defined('FLOW_PATH_ROOT')) {
define('FLOW_PATH_ROOT', Files::getUnixStylePath(getcwd()) . '/');
}
if (!defined('FLOW_PATH_PACKAGES')) {
define('FLOW_PATH_PACKAGES', Files::getUnixStylePath(getcwd()) . '/Packages/');
}
if (!defined('FLOW_PATH_CONFIGURATION')) {
define('FLOW_PATH_CONFIGURATION', Files::getUnixStylePath(getcwd()) . '/Configuration/');
}
if (!defined('FLOW_PATH_TEMPORARY_BASE')) {
define('FLOW_PATH_TEMPORARY_BASE', Files::getUnixStylePath(getcwd()) . '/Data/Temporary');
}
Files::createDirectoryRecursively('Configuration');
Files::createDirectoryRecursively('Data');
Files::copyDirectoryRecursively('Packages/Framework/Neos.Flow/Resources/Private/Installer/Distribution/Essentials', './', false, true);
Files::copyDirectoryRecursively('Packages/Framework/Neos.Flow/Resources/Private/Installer/Distribution/Defaults', './', true, true);
$packageManager = new PackageManager(PackageManager::DEFAULT_PACKAGE_INFORMATION_CACHE_FILEPATH, FLOW_PATH_PACKAGES);
$packageManager->rescanPackages();
chmod('flow', 0755);
} | php | public static function postUpdateAndInstall(Event $event)
{
if (!defined('FLOW_PATH_ROOT')) {
define('FLOW_PATH_ROOT', Files::getUnixStylePath(getcwd()) . '/');
}
if (!defined('FLOW_PATH_PACKAGES')) {
define('FLOW_PATH_PACKAGES', Files::getUnixStylePath(getcwd()) . '/Packages/');
}
if (!defined('FLOW_PATH_CONFIGURATION')) {
define('FLOW_PATH_CONFIGURATION', Files::getUnixStylePath(getcwd()) . '/Configuration/');
}
if (!defined('FLOW_PATH_TEMPORARY_BASE')) {
define('FLOW_PATH_TEMPORARY_BASE', Files::getUnixStylePath(getcwd()) . '/Data/Temporary');
}
Files::createDirectoryRecursively('Configuration');
Files::createDirectoryRecursively('Data');
Files::copyDirectoryRecursively('Packages/Framework/Neos.Flow/Resources/Private/Installer/Distribution/Essentials', './', false, true);
Files::copyDirectoryRecursively('Packages/Framework/Neos.Flow/Resources/Private/Installer/Distribution/Defaults', './', true, true);
$packageManager = new PackageManager(PackageManager::DEFAULT_PACKAGE_INFORMATION_CACHE_FILEPATH, FLOW_PATH_PACKAGES);
$packageManager->rescanPackages();
chmod('flow', 0755);
} | [
"public",
"static",
"function",
"postUpdateAndInstall",
"(",
"Event",
"$",
"event",
")",
"{",
"if",
"(",
"!",
"defined",
"(",
"'FLOW_PATH_ROOT'",
")",
")",
"{",
"define",
"(",
"'FLOW_PATH_ROOT'",
",",
"Files",
"::",
"getUnixStylePath",
"(",
"getcwd",
"(",
")... | Make sure required paths and files are available outside of Package
Run on every Composer install or update - must be configured in root manifest
@param Event $event
@return void | [
"Make",
"sure",
"required",
"paths",
"and",
"files",
"are",
"available",
"outside",
"of",
"Package",
"Run",
"on",
"every",
"Composer",
"install",
"or",
"update",
"-",
"must",
"be",
"configured",
"in",
"root",
"manifest"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Composer/InstallerScripts.php#L33-L59 |
neos/flow-development-collection | Neos.Flow/Classes/Composer/InstallerScripts.php | InstallerScripts.postPackageUpdateAndInstall | public static function postPackageUpdateAndInstall(PackageEvent $event)
{
$operation = $event->getOperation();
if (!$operation instanceof InstallOperation && !$operation instanceof UpdateOperation) {
throw new Exception\UnexpectedOperationException('Handling of operation with type "' . $operation->getJobType() . '" not supported', 1348750840);
}
$package = ($operation->getJobType() === 'install') ? $operation->getPackage() : $operation->getTargetPackage();
$packageExtraConfig = $package->getExtra();
$installPath = $event->getComposer()->getInstallationManager()->getInstallPath($package);
$evaluatedInstallerResources = false;
if (isset($packageExtraConfig['neos']['installer-resource-folders'])) {
foreach ($packageExtraConfig['neos']['installer-resource-folders'] as $installerResourceDirectory) {
static::copyDistributionFiles($installPath . $installerResourceDirectory);
}
$evaluatedInstallerResources = true;
}
if ($operation->getJobType() === 'install') {
if (isset($packageExtraConfig['typo3/flow']['post-install'])) {
self::runPackageScripts($packageExtraConfig['typo3/flow']['post-install']);
}
if (isset($packageExtraConfig['neos/flow']['post-install'])) {
self::runPackageScripts($packageExtraConfig['neos/flow']['post-install']);
}
}
if ($operation->getJobType() === 'update') {
if (isset($packageExtraConfig['typo3/flow']['post-update'])) {
self::runPackageScripts($packageExtraConfig['typo3/flow']['post-update']);
}
if (isset($packageExtraConfig['neos/flow']['post-update'])) {
self::runPackageScripts($packageExtraConfig['neos/flow']['post-update']);
}
}
// TODO: Deprecated from Flow 3.1 remove three versions after.
if (!$evaluatedInstallerResources && isset($packageExtraConfig['typo3/flow']['manage-resources']) && $packageExtraConfig['typo3/flow']['manage-resources'] === true) {
static::copyDistributionFiles($installPath . 'Resources/Private/Installer/');
}
} | php | public static function postPackageUpdateAndInstall(PackageEvent $event)
{
$operation = $event->getOperation();
if (!$operation instanceof InstallOperation && !$operation instanceof UpdateOperation) {
throw new Exception\UnexpectedOperationException('Handling of operation with type "' . $operation->getJobType() . '" not supported', 1348750840);
}
$package = ($operation->getJobType() === 'install') ? $operation->getPackage() : $operation->getTargetPackage();
$packageExtraConfig = $package->getExtra();
$installPath = $event->getComposer()->getInstallationManager()->getInstallPath($package);
$evaluatedInstallerResources = false;
if (isset($packageExtraConfig['neos']['installer-resource-folders'])) {
foreach ($packageExtraConfig['neos']['installer-resource-folders'] as $installerResourceDirectory) {
static::copyDistributionFiles($installPath . $installerResourceDirectory);
}
$evaluatedInstallerResources = true;
}
if ($operation->getJobType() === 'install') {
if (isset($packageExtraConfig['typo3/flow']['post-install'])) {
self::runPackageScripts($packageExtraConfig['typo3/flow']['post-install']);
}
if (isset($packageExtraConfig['neos/flow']['post-install'])) {
self::runPackageScripts($packageExtraConfig['neos/flow']['post-install']);
}
}
if ($operation->getJobType() === 'update') {
if (isset($packageExtraConfig['typo3/flow']['post-update'])) {
self::runPackageScripts($packageExtraConfig['typo3/flow']['post-update']);
}
if (isset($packageExtraConfig['neos/flow']['post-update'])) {
self::runPackageScripts($packageExtraConfig['neos/flow']['post-update']);
}
}
// TODO: Deprecated from Flow 3.1 remove three versions after.
if (!$evaluatedInstallerResources && isset($packageExtraConfig['typo3/flow']['manage-resources']) && $packageExtraConfig['typo3/flow']['manage-resources'] === true) {
static::copyDistributionFiles($installPath . 'Resources/Private/Installer/');
}
} | [
"public",
"static",
"function",
"postPackageUpdateAndInstall",
"(",
"PackageEvent",
"$",
"event",
")",
"{",
"$",
"operation",
"=",
"$",
"event",
"->",
"getOperation",
"(",
")",
";",
"if",
"(",
"!",
"$",
"operation",
"instanceof",
"InstallOperation",
"&&",
"!",... | Calls actions and install scripts provided by installed packages.
@param PackageEvent $event
@return void
@throws Exception\UnexpectedOperationException | [
"Calls",
"actions",
"and",
"install",
"scripts",
"provided",
"by",
"installed",
"packages",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Composer/InstallerScripts.php#L68-L108 |
neos/flow-development-collection | Neos.Flow/Classes/Composer/InstallerScripts.php | InstallerScripts.copyDistributionFiles | protected static function copyDistributionFiles(string $installerResourcesDirectory)
{
$essentialsPath = $installerResourcesDirectory . 'Distribution/Essentials';
if (is_dir($essentialsPath)) {
Files::copyDirectoryRecursively($essentialsPath, Files::getUnixStylePath(getcwd()) . '/', false, true);
}
$defaultsPath = $installerResourcesDirectory . 'Distribution/Defaults';
if (is_dir($defaultsPath)) {
Files::copyDirectoryRecursively($defaultsPath, Files::getUnixStylePath(getcwd()) . '/', true, true);
}
} | php | protected static function copyDistributionFiles(string $installerResourcesDirectory)
{
$essentialsPath = $installerResourcesDirectory . 'Distribution/Essentials';
if (is_dir($essentialsPath)) {
Files::copyDirectoryRecursively($essentialsPath, Files::getUnixStylePath(getcwd()) . '/', false, true);
}
$defaultsPath = $installerResourcesDirectory . 'Distribution/Defaults';
if (is_dir($defaultsPath)) {
Files::copyDirectoryRecursively($defaultsPath, Files::getUnixStylePath(getcwd()) . '/', true, true);
}
} | [
"protected",
"static",
"function",
"copyDistributionFiles",
"(",
"string",
"$",
"installerResourcesDirectory",
")",
"{",
"$",
"essentialsPath",
"=",
"$",
"installerResourcesDirectory",
".",
"'Distribution/Essentials'",
";",
"if",
"(",
"is_dir",
"(",
"$",
"essentialsPath... | Copies any distribution files to their place if needed.
@param string $installerResourcesDirectory Path to the installer directory that contains the Distribution/Essentials and/or Distribution/Defaults directories.
@return void | [
"Copies",
"any",
"distribution",
"files",
"to",
"their",
"place",
"if",
"needed",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Composer/InstallerScripts.php#L116-L127 |
neos/flow-development-collection | Neos.Flow/Classes/Composer/InstallerScripts.php | InstallerScripts.runPackageScripts | protected static function runPackageScripts(string $staticMethodReference)
{
$className = substr($staticMethodReference, 0, strpos($staticMethodReference, '::'));
$methodName = substr($staticMethodReference, strpos($staticMethodReference, '::') + 2);
if (!class_exists($className)) {
throw new Exception\InvalidConfigurationException('Class "' . $className . '" is not autoloadable, can not call "' . $staticMethodReference . '"', 1348751076);
}
if (!is_callable($staticMethodReference)) {
throw new Exception\InvalidConfigurationException('Method "' . $staticMethodReference . '" is not callable', 1348751082);
}
$className::$methodName();
} | php | protected static function runPackageScripts(string $staticMethodReference)
{
$className = substr($staticMethodReference, 0, strpos($staticMethodReference, '::'));
$methodName = substr($staticMethodReference, strpos($staticMethodReference, '::') + 2);
if (!class_exists($className)) {
throw new Exception\InvalidConfigurationException('Class "' . $className . '" is not autoloadable, can not call "' . $staticMethodReference . '"', 1348751076);
}
if (!is_callable($staticMethodReference)) {
throw new Exception\InvalidConfigurationException('Method "' . $staticMethodReference . '" is not callable', 1348751082);
}
$className::$methodName();
} | [
"protected",
"static",
"function",
"runPackageScripts",
"(",
"string",
"$",
"staticMethodReference",
")",
"{",
"$",
"className",
"=",
"substr",
"(",
"$",
"staticMethodReference",
",",
"0",
",",
"strpos",
"(",
"$",
"staticMethodReference",
",",
"'::'",
")",
")",
... | Calls a static method from it's string representation
@param string $staticMethodReference
@return void
@throws Exception\InvalidConfigurationException | [
"Calls",
"a",
"static",
"method",
"from",
"it",
"s",
"string",
"representation"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Composer/InstallerScripts.php#L136-L148 |
neos/flow-development-collection | Neos.Flow/Classes/Error/Debugger.php | Debugger.renderDump | public static function renderDump($variable, int $level, bool $plaintext = false, bool $ansiColors = false): string
{
if ($level > self::getRecursionLimit()) {
return 'RECURSION ... ' . chr(10);
}
if (is_string($variable)) {
$croppedValue = (strlen($variable) > 2000) ? substr($variable, 0, 2000) . '…' : $variable;
if ($plaintext) {
$dump = 'string ' . self::ansiEscapeWrap('"' . $croppedValue . '"', '33', $ansiColors) . ' (' . strlen($variable) . ')';
} else {
$dump = sprintf('\'<span class="debug-string">%s</span>\' (%s)', htmlspecialchars($croppedValue), strlen($variable));
}
} elseif (is_numeric($variable)) {
$dump = sprintf('%s %s', gettype($variable), self::ansiEscapeWrap($variable, '35', $ansiColors));
} elseif (is_array($variable)) {
$dump = self::renderArrayDump($variable, $level + 1, $plaintext, $ansiColors);
} elseif (is_object($variable)) {
$dump = self::renderObjectDump($variable, $level + 1, true, $plaintext, $ansiColors);
} elseif (is_bool($variable)) {
$dump = $variable ? self::ansiEscapeWrap('true', '32', $ansiColors) : self::ansiEscapeWrap('false', '31', $ansiColors);
} elseif (is_null($variable) || is_resource($variable)) {
$dump = gettype($variable);
} else {
$dump = '[unhandled type]';
}
return $dump;
} | php | public static function renderDump($variable, int $level, bool $plaintext = false, bool $ansiColors = false): string
{
if ($level > self::getRecursionLimit()) {
return 'RECURSION ... ' . chr(10);
}
if (is_string($variable)) {
$croppedValue = (strlen($variable) > 2000) ? substr($variable, 0, 2000) . '…' : $variable;
if ($plaintext) {
$dump = 'string ' . self::ansiEscapeWrap('"' . $croppedValue . '"', '33', $ansiColors) . ' (' . strlen($variable) . ')';
} else {
$dump = sprintf('\'<span class="debug-string">%s</span>\' (%s)', htmlspecialchars($croppedValue), strlen($variable));
}
} elseif (is_numeric($variable)) {
$dump = sprintf('%s %s', gettype($variable), self::ansiEscapeWrap($variable, '35', $ansiColors));
} elseif (is_array($variable)) {
$dump = self::renderArrayDump($variable, $level + 1, $plaintext, $ansiColors);
} elseif (is_object($variable)) {
$dump = self::renderObjectDump($variable, $level + 1, true, $plaintext, $ansiColors);
} elseif (is_bool($variable)) {
$dump = $variable ? self::ansiEscapeWrap('true', '32', $ansiColors) : self::ansiEscapeWrap('false', '31', $ansiColors);
} elseif (is_null($variable) || is_resource($variable)) {
$dump = gettype($variable);
} else {
$dump = '[unhandled type]';
}
return $dump;
} | [
"public",
"static",
"function",
"renderDump",
"(",
"$",
"variable",
",",
"int",
"$",
"level",
",",
"bool",
"$",
"plaintext",
"=",
"false",
",",
"bool",
"$",
"ansiColors",
"=",
"false",
")",
":",
"string",
"{",
"if",
"(",
"$",
"level",
">",
"self",
":... | Renders a dump of the given variable
@param mixed $variable
@param integer $level
@param boolean $plaintext
@param boolean $ansiColors
@return string | [
"Renders",
"a",
"dump",
"of",
"the",
"given",
"variable"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Error/Debugger.php#L129-L156 |
neos/flow-development-collection | Neos.Flow/Classes/Error/Debugger.php | Debugger.renderArrayDump | protected static function renderArrayDump(array $array, int $level, bool $plaintext = false, bool $ansiColors = false): string
{
if (is_array($array)) {
$dump = 'array' . (count($array) ? '(' . count($array) . ')' : '(empty)');
} elseif ($array instanceof \Countable) {
$dump = get_class($array) . (count($array) ? '(' . count($array) . ')' : '(empty)');
} else {
$dump = get_class($array);
}
foreach ($array as $key => $value) {
$dump .= chr(10) . str_repeat(' ', $level) . self::renderDump($key, 0, $plaintext, $ansiColors) . ' => ';
$dump .= self::renderDump($value, $level + 1, $plaintext, $ansiColors);
}
return $dump;
} | php | protected static function renderArrayDump(array $array, int $level, bool $plaintext = false, bool $ansiColors = false): string
{
if (is_array($array)) {
$dump = 'array' . (count($array) ? '(' . count($array) . ')' : '(empty)');
} elseif ($array instanceof \Countable) {
$dump = get_class($array) . (count($array) ? '(' . count($array) . ')' : '(empty)');
} else {
$dump = get_class($array);
}
foreach ($array as $key => $value) {
$dump .= chr(10) . str_repeat(' ', $level) . self::renderDump($key, 0, $plaintext, $ansiColors) . ' => ';
$dump .= self::renderDump($value, $level + 1, $plaintext, $ansiColors);
}
return $dump;
} | [
"protected",
"static",
"function",
"renderArrayDump",
"(",
"array",
"$",
"array",
",",
"int",
"$",
"level",
",",
"bool",
"$",
"plaintext",
"=",
"false",
",",
"bool",
"$",
"ansiColors",
"=",
"false",
")",
":",
"string",
"{",
"if",
"(",
"is_array",
"(",
... | Renders a dump of the given array
@param array $array
@param integer $level
@param boolean $plaintext
@param boolean $ansiColors
@return string | [
"Renders",
"a",
"dump",
"of",
"the",
"given",
"array"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Error/Debugger.php#L167-L182 |
neos/flow-development-collection | Neos.Flow/Classes/Error/Debugger.php | Debugger.renderObjectDump | protected static function renderObjectDump($object, int $level, bool $renderProperties = true, bool $plaintext = false, bool $ansiColors = false): string
{
$dump = '';
$scope = '';
$additionalAttributes = '';
if ($object instanceof \Doctrine\Common\Collections\Collection || $object instanceof \ArrayObject) {
// The doctrine Debug utility usually returns a \stdClass object that we need to cast to array.
return self::renderArrayDump((array)\Doctrine\Common\Util\Debug::export($object, 3), $level, $plaintext, $ansiColors);
}
// Objects returned from Doctrine's Debug::export function are stdClass with special properties:
try {
$objectIdentifier = ObjectAccess::getProperty($object, 'Persistence_Object_Identifier', true);
} catch (\Neos\Utility\Exception\PropertyNotAccessibleException $exception) {
$objectIdentifier = spl_object_hash($object);
}
$className = ($object instanceof \stdClass && isset($object->__CLASS__)) ? $object->__CLASS__ : get_class($object);
if (isset(self::$renderedObjects[$objectIdentifier]) || preg_match(self::getIgnoredClassesRegex(), $className) !== 0) {
$renderProperties = false;
}
self::$renderedObjects[$objectIdentifier] = true;
if (self::$objectManager !== null) {
$objectName = self::$objectManager->getObjectNameByClassName(get_class($object));
if ($objectName !== false) {
switch (self::$objectManager->getScope($objectName)) {
case Configuration::SCOPE_PROTOTYPE:
$scope = 'prototype';
break;
case Configuration::SCOPE_SINGLETON:
$scope = 'singleton';
break;
case Configuration::SCOPE_SESSION:
$scope = 'session';
break;
}
} else {
$additionalAttributes .= ' debug-unregistered';
}
}
if ($renderProperties === true && !$plaintext) {
if ($scope === '') {
$scope = 'prototype';
}
$scope .= '<a id="o' . $objectIdentifier . '"></a>';
}
if ($plaintext) {
$dump .= $className;
$dump .= ($scope !== '') ? ' ' . self::ansiEscapeWrap($scope, '44;37', $ansiColors) : '';
} else {
$dump .= '<span class="debug-object' . $additionalAttributes . '" title="' . $objectIdentifier . '">' . $className . '</span>';
$dump .= ($scope !== '') ? '<span class="debug-scope">' . $scope . '</span>' : '';
}
if (property_exists($object, 'Persistence_Object_Identifier')) {
$persistenceIdentifier = $objectIdentifier;
$persistenceType = 'persistable';
} elseif ($object instanceof \Closure) {
$persistenceIdentifier = 'n/a';
$persistenceType = 'closure';
} else {
$persistenceIdentifier = 'unknown';
$persistenceType = 'object';
}
if ($plaintext) {
$dump .= ' ' . self::ansiEscapeWrap($persistenceType, '42;37', $ansiColors);
} else {
$dump .= '<span class="debug-ptype" title="' . $persistenceIdentifier . '">' . $persistenceType . '</span>';
}
if ($object instanceof ProxyInterface || (property_exists($object, '__IS_PROXY__') && $object->__IS_PROXY__ === true)) {
if ($plaintext) {
$dump .= ' ' . self::ansiEscapeWrap('proxy', '41;37', $ansiColors);
} else {
$dump .= '<span class="debug-proxy" title="' . $className . '">proxy</span>';
}
}
if ($renderProperties === true) {
if ($object instanceof \SplObjectStorage) {
$dump .= ' (' . (count($object) ?: 'empty') . ')';
foreach ($object as $value) {
$dump .= chr(10);
$dump .= str_repeat(' ', $level);
$dump .= self::renderObjectDump($value, 0, false, $plaintext, $ansiColors);
}
} else {
$objectReflection = new \ReflectionObject($object);
$properties = $objectReflection->getProperties();
foreach ($properties as $property) {
if (preg_match(self::$blacklistedPropertyNames, $property->getName())) {
continue;
}
$dump .= chr(10);
$dump .= str_repeat(' ', $level) . ($plaintext ? '' : '<span class="debug-property">') . self::ansiEscapeWrap($property->getName(), '36', $ansiColors) . ($plaintext ? '' : '</span>') . ' => ';
$property->setAccessible(true);
$value = $property->getValue($object);
if (is_array($value)) {
$dump .= self::renderDump($value, $level + 1, $plaintext, $ansiColors);
} elseif (is_object($value)) {
$dump .= self::renderObjectDump($value, $level + 1, true, $plaintext, $ansiColors);
} else {
$dump .= self::renderDump($value, $level, $plaintext, $ansiColors);
}
}
}
} elseif (isset(self::$renderedObjects[$objectIdentifier])) {
if (!$plaintext) {
$dump = '<a href="#o' . $objectIdentifier . '" onclick="document.location.hash=\'#o' . $objectIdentifier . '\'; return false;" class="debug-seeabove" title="see above">' . $dump . '</a>';
}
}
return $dump;
} | php | protected static function renderObjectDump($object, int $level, bool $renderProperties = true, bool $plaintext = false, bool $ansiColors = false): string
{
$dump = '';
$scope = '';
$additionalAttributes = '';
if ($object instanceof \Doctrine\Common\Collections\Collection || $object instanceof \ArrayObject) {
// The doctrine Debug utility usually returns a \stdClass object that we need to cast to array.
return self::renderArrayDump((array)\Doctrine\Common\Util\Debug::export($object, 3), $level, $plaintext, $ansiColors);
}
// Objects returned from Doctrine's Debug::export function are stdClass with special properties:
try {
$objectIdentifier = ObjectAccess::getProperty($object, 'Persistence_Object_Identifier', true);
} catch (\Neos\Utility\Exception\PropertyNotAccessibleException $exception) {
$objectIdentifier = spl_object_hash($object);
}
$className = ($object instanceof \stdClass && isset($object->__CLASS__)) ? $object->__CLASS__ : get_class($object);
if (isset(self::$renderedObjects[$objectIdentifier]) || preg_match(self::getIgnoredClassesRegex(), $className) !== 0) {
$renderProperties = false;
}
self::$renderedObjects[$objectIdentifier] = true;
if (self::$objectManager !== null) {
$objectName = self::$objectManager->getObjectNameByClassName(get_class($object));
if ($objectName !== false) {
switch (self::$objectManager->getScope($objectName)) {
case Configuration::SCOPE_PROTOTYPE:
$scope = 'prototype';
break;
case Configuration::SCOPE_SINGLETON:
$scope = 'singleton';
break;
case Configuration::SCOPE_SESSION:
$scope = 'session';
break;
}
} else {
$additionalAttributes .= ' debug-unregistered';
}
}
if ($renderProperties === true && !$plaintext) {
if ($scope === '') {
$scope = 'prototype';
}
$scope .= '<a id="o' . $objectIdentifier . '"></a>';
}
if ($plaintext) {
$dump .= $className;
$dump .= ($scope !== '') ? ' ' . self::ansiEscapeWrap($scope, '44;37', $ansiColors) : '';
} else {
$dump .= '<span class="debug-object' . $additionalAttributes . '" title="' . $objectIdentifier . '">' . $className . '</span>';
$dump .= ($scope !== '') ? '<span class="debug-scope">' . $scope . '</span>' : '';
}
if (property_exists($object, 'Persistence_Object_Identifier')) {
$persistenceIdentifier = $objectIdentifier;
$persistenceType = 'persistable';
} elseif ($object instanceof \Closure) {
$persistenceIdentifier = 'n/a';
$persistenceType = 'closure';
} else {
$persistenceIdentifier = 'unknown';
$persistenceType = 'object';
}
if ($plaintext) {
$dump .= ' ' . self::ansiEscapeWrap($persistenceType, '42;37', $ansiColors);
} else {
$dump .= '<span class="debug-ptype" title="' . $persistenceIdentifier . '">' . $persistenceType . '</span>';
}
if ($object instanceof ProxyInterface || (property_exists($object, '__IS_PROXY__') && $object->__IS_PROXY__ === true)) {
if ($plaintext) {
$dump .= ' ' . self::ansiEscapeWrap('proxy', '41;37', $ansiColors);
} else {
$dump .= '<span class="debug-proxy" title="' . $className . '">proxy</span>';
}
}
if ($renderProperties === true) {
if ($object instanceof \SplObjectStorage) {
$dump .= ' (' . (count($object) ?: 'empty') . ')';
foreach ($object as $value) {
$dump .= chr(10);
$dump .= str_repeat(' ', $level);
$dump .= self::renderObjectDump($value, 0, false, $plaintext, $ansiColors);
}
} else {
$objectReflection = new \ReflectionObject($object);
$properties = $objectReflection->getProperties();
foreach ($properties as $property) {
if (preg_match(self::$blacklistedPropertyNames, $property->getName())) {
continue;
}
$dump .= chr(10);
$dump .= str_repeat(' ', $level) . ($plaintext ? '' : '<span class="debug-property">') . self::ansiEscapeWrap($property->getName(), '36', $ansiColors) . ($plaintext ? '' : '</span>') . ' => ';
$property->setAccessible(true);
$value = $property->getValue($object);
if (is_array($value)) {
$dump .= self::renderDump($value, $level + 1, $plaintext, $ansiColors);
} elseif (is_object($value)) {
$dump .= self::renderObjectDump($value, $level + 1, true, $plaintext, $ansiColors);
} else {
$dump .= self::renderDump($value, $level, $plaintext, $ansiColors);
}
}
}
} elseif (isset(self::$renderedObjects[$objectIdentifier])) {
if (!$plaintext) {
$dump = '<a href="#o' . $objectIdentifier . '" onclick="document.location.hash=\'#o' . $objectIdentifier . '\'; return false;" class="debug-seeabove" title="see above">' . $dump . '</a>';
}
}
return $dump;
} | [
"protected",
"static",
"function",
"renderObjectDump",
"(",
"$",
"object",
",",
"int",
"$",
"level",
",",
"bool",
"$",
"renderProperties",
"=",
"true",
",",
"bool",
"$",
"plaintext",
"=",
"false",
",",
"bool",
"$",
"ansiColors",
"=",
"false",
")",
":",
"... | Renders a dump of the given object
@param object $object
@param integer $level
@param boolean $renderProperties
@param boolean $plaintext
@param boolean $ansiColors
@return string | [
"Renders",
"a",
"dump",
"of",
"the",
"given",
"object"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Error/Debugger.php#L194-L311 |
neos/flow-development-collection | Neos.Flow/Classes/Error/Debugger.php | Debugger.getBacktraceCode | public static function getBacktraceCode(array $trace, bool $includeCode = true, bool $plaintext = false): string
{
if ($plaintext) {
return static::getBacktraceCodePlaintext($trace, $includeCode);
}
$backtraceCode = '<ol class="Flow-Debug-Backtrace" reversed>';
foreach ($trace as $index => $step) {
$backtraceCode .= '<li class="Flow-Debug-Backtrace-Step">';
$class = isset($step['class']) ? $step['class'] . '<span class="color-muted">::</span>' : '';
$arguments = '';
if (isset($step['args']) && is_array($step['args'])) {
foreach ($step['args'] as $argument) {
$arguments .= (strlen($arguments) === 0) ? '' : '<span class="color-muted">,</span> ';
$arguments .= '<span class="color-text-inverted">';
if (is_object($argument)) {
$arguments .= '<em>' . get_class($argument) . '</em>';
} elseif (is_string($argument)) {
$preparedArgument = (strlen($argument) < 100) ? $argument : substr($argument, 0, 50) . '…' . substr($argument, -50);
$preparedArgument = htmlspecialchars($preparedArgument);
$preparedArgument = str_replace('…', '<span class="color-muted">…</span>', $preparedArgument);
$preparedArgument = str_replace("\n", '<span class="color-muted">⏎</span>', $preparedArgument);
$arguments .= '"<span title="' . htmlspecialchars($argument) . '">' . $preparedArgument . '</span>"';
} elseif (is_numeric($argument)) {
$arguments .= (string)$argument;
} elseif (is_bool($argument)) {
$arguments .= ($argument === true ? 'true' : 'false');
} elseif (is_array($argument)) {
$arguments .= sprintf(
'<em title="%s">array|%d|</em>',
htmlspecialchars(self::renderArrayDump($argument, 0, true)),
count($argument)
);
} else {
$arguments .= '<em>' . gettype($argument) . '</em>';
}
$arguments .= '</span>';
}
}
$backtraceCode .= '<pre class="Flow-Debug-Backtrace-Step-Function">';
$backtraceCode .= $class . $step['function'] . '<span class="color-muted">(' . $arguments . ')</span>';
$backtraceCode .= '</pre>';
if (isset($step['file']) && $includeCode) {
$backtraceCode .= self::getCodeSnippet($step['file'], $step['line']);
}
$backtraceCode .= '</li>';
}
$backtraceCode .= '</ol>';
return $backtraceCode;
} | php | public static function getBacktraceCode(array $trace, bool $includeCode = true, bool $plaintext = false): string
{
if ($plaintext) {
return static::getBacktraceCodePlaintext($trace, $includeCode);
}
$backtraceCode = '<ol class="Flow-Debug-Backtrace" reversed>';
foreach ($trace as $index => $step) {
$backtraceCode .= '<li class="Flow-Debug-Backtrace-Step">';
$class = isset($step['class']) ? $step['class'] . '<span class="color-muted">::</span>' : '';
$arguments = '';
if (isset($step['args']) && is_array($step['args'])) {
foreach ($step['args'] as $argument) {
$arguments .= (strlen($arguments) === 0) ? '' : '<span class="color-muted">,</span> ';
$arguments .= '<span class="color-text-inverted">';
if (is_object($argument)) {
$arguments .= '<em>' . get_class($argument) . '</em>';
} elseif (is_string($argument)) {
$preparedArgument = (strlen($argument) < 100) ? $argument : substr($argument, 0, 50) . '…' . substr($argument, -50);
$preparedArgument = htmlspecialchars($preparedArgument);
$preparedArgument = str_replace('…', '<span class="color-muted">…</span>', $preparedArgument);
$preparedArgument = str_replace("\n", '<span class="color-muted">⏎</span>', $preparedArgument);
$arguments .= '"<span title="' . htmlspecialchars($argument) . '">' . $preparedArgument . '</span>"';
} elseif (is_numeric($argument)) {
$arguments .= (string)$argument;
} elseif (is_bool($argument)) {
$arguments .= ($argument === true ? 'true' : 'false');
} elseif (is_array($argument)) {
$arguments .= sprintf(
'<em title="%s">array|%d|</em>',
htmlspecialchars(self::renderArrayDump($argument, 0, true)),
count($argument)
);
} else {
$arguments .= '<em>' . gettype($argument) . '</em>';
}
$arguments .= '</span>';
}
}
$backtraceCode .= '<pre class="Flow-Debug-Backtrace-Step-Function">';
$backtraceCode .= $class . $step['function'] . '<span class="color-muted">(' . $arguments . ')</span>';
$backtraceCode .= '</pre>';
if (isset($step['file']) && $includeCode) {
$backtraceCode .= self::getCodeSnippet($step['file'], $step['line']);
}
$backtraceCode .= '</li>';
}
$backtraceCode .= '</ol>';
return $backtraceCode;
} | [
"public",
"static",
"function",
"getBacktraceCode",
"(",
"array",
"$",
"trace",
",",
"bool",
"$",
"includeCode",
"=",
"true",
",",
"bool",
"$",
"plaintext",
"=",
"false",
")",
":",
"string",
"{",
"if",
"(",
"$",
"plaintext",
")",
"{",
"return",
"static",... | Renders some backtrace
@param array $trace The trace
@param boolean $includeCode Include code snippet
@param boolean $plaintext
@return string Backtrace information | [
"Renders",
"some",
"backtrace"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Error/Debugger.php#L321-L372 |
neos/flow-development-collection | Neos.Flow/Classes/Error/Debugger.php | Debugger.getCodeSnippet | public static function getCodeSnippet(string $filePathAndName, int $lineNumber, bool $plaintext = false): string
{
if ($plaintext) {
return static::getCodeSnippetPlaintext($filePathAndName, $lineNumber);
}
$codeSnippet = '<br />';
if (@file_exists($filePathAndName)) {
$phpFile = @file($filePathAndName);
if (!is_array($phpFile)) {
return $codeSnippet;
}
$filePaths = static::findProxyAndShortFilePath($filePathAndName);
$codeSnippet = '<div class="Flow-Debug-CodeSnippet">';
$filePathReal = $filePaths['proxy'] !== '' ? $filePaths['proxy'] : $filePaths['short'];
$codeSnippet .= '<div class="Flow-Debug-CodeSnippet-File">' . $filePathReal . '</div>';
if ($filePaths['proxy'] !== '') {
$codeSnippet .= '<div class="Flow-Debug-CodeSnippet-File">Original File: ' . $filePaths['short'] . '</div>';
}
$codeSnippet .= '<div class="Flow-Debug-CodeSnippet-Code">';
$startLine = ($lineNumber > 2) ? ($lineNumber - 2) : 1;
$endLine = ($lineNumber < (count($phpFile) - 2)) ? ($lineNumber + 3) : count($phpFile) + 1;
for ($line = $startLine; $line < $endLine; $line++) {
$codeSnippet .= '<pre class="' . (($line === $lineNumber) ? 'Flow-Debug-CodeSnippet-Code-Highlighted' : '') . '">';
$codeLine = str_replace("\t", ' ', $phpFile[$line - 1]);
$codeSnippet .= sprintf('%05d', $line) . ': ';
$codeSnippet .= htmlspecialchars($codeLine);
$codeSnippet .= '</pre>';
}
$codeSnippet .= '</div></div>';
}
return $codeSnippet;
} | php | public static function getCodeSnippet(string $filePathAndName, int $lineNumber, bool $plaintext = false): string
{
if ($plaintext) {
return static::getCodeSnippetPlaintext($filePathAndName, $lineNumber);
}
$codeSnippet = '<br />';
if (@file_exists($filePathAndName)) {
$phpFile = @file($filePathAndName);
if (!is_array($phpFile)) {
return $codeSnippet;
}
$filePaths = static::findProxyAndShortFilePath($filePathAndName);
$codeSnippet = '<div class="Flow-Debug-CodeSnippet">';
$filePathReal = $filePaths['proxy'] !== '' ? $filePaths['proxy'] : $filePaths['short'];
$codeSnippet .= '<div class="Flow-Debug-CodeSnippet-File">' . $filePathReal . '</div>';
if ($filePaths['proxy'] !== '') {
$codeSnippet .= '<div class="Flow-Debug-CodeSnippet-File">Original File: ' . $filePaths['short'] . '</div>';
}
$codeSnippet .= '<div class="Flow-Debug-CodeSnippet-Code">';
$startLine = ($lineNumber > 2) ? ($lineNumber - 2) : 1;
$endLine = ($lineNumber < (count($phpFile) - 2)) ? ($lineNumber + 3) : count($phpFile) + 1;
for ($line = $startLine; $line < $endLine; $line++) {
$codeSnippet .= '<pre class="' . (($line === $lineNumber) ? 'Flow-Debug-CodeSnippet-Code-Highlighted' : '') . '">';
$codeLine = str_replace("\t", ' ', $phpFile[$line - 1]);
$codeSnippet .= sprintf('%05d', $line) . ': ';
$codeSnippet .= htmlspecialchars($codeLine);
$codeSnippet .= '</pre>';
}
$codeSnippet .= '</div></div>';
}
return $codeSnippet;
} | [
"public",
"static",
"function",
"getCodeSnippet",
"(",
"string",
"$",
"filePathAndName",
",",
"int",
"$",
"lineNumber",
",",
"bool",
"$",
"plaintext",
"=",
"false",
")",
":",
"string",
"{",
"if",
"(",
"$",
"plaintext",
")",
"{",
"return",
"static",
"::",
... | Returns a code snippet from the specified file.
@param string $filePathAndName Absolute path and filename of the PHP file
@param integer $lineNumber Line number defining the center of the code snippet
@param boolean $plaintext
@return string The code snippet | [
"Returns",
"a",
"code",
"snippet",
"from",
"the",
"specified",
"file",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Error/Debugger.php#L425-L461 |
neos/flow-development-collection | Neos.Flow/Classes/Error/Debugger.php | Debugger.ansiEscapeWrap | protected static function ansiEscapeWrap(string $string, string $ansiColors, bool $enable = true): string
{
if ($enable) {
return "\x1B[" . $ansiColors . 'm' . $string . "\x1B[0m";
} else {
return $string;
}
} | php | protected static function ansiEscapeWrap(string $string, string $ansiColors, bool $enable = true): string
{
if ($enable) {
return "\x1B[" . $ansiColors . 'm' . $string . "\x1B[0m";
} else {
return $string;
}
} | [
"protected",
"static",
"function",
"ansiEscapeWrap",
"(",
"string",
"$",
"string",
",",
"string",
"$",
"ansiColors",
",",
"bool",
"$",
"enable",
"=",
"true",
")",
":",
"string",
"{",
"if",
"(",
"$",
"enable",
")",
"{",
"return",
"\"\\x1B[\"",
".",
"$",
... | Wrap a string with the ANSI escape sequence for colorful output
@param string $string The string to wrap
@param string $ansiColors The ansi color sequence (e.g. "1;37")
@param boolean $enable If false, the raw string will be returned
@return string The wrapped or raw string | [
"Wrap",
"a",
"string",
"with",
"the",
"ANSI",
"escape",
"sequence",
"for",
"colorful",
"output"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Error/Debugger.php#L518-L525 |
neos/flow-development-collection | Neos.Flow/Classes/Error/Debugger.php | Debugger.getIgnoredClassesRegex | public static function getIgnoredClassesRegex(): string
{
if (self::$ignoredClassesRegex !== '') {
return self::$ignoredClassesRegex;
}
$ignoredClassesConfiguration = self::$ignoredClassesFallback;
$ignoredClasses = [];
if (self::$objectManager instanceof ObjectManagerInterface) {
$configurationManager = self::$objectManager->get(ConfigurationManager::class);
if ($configurationManager instanceof ConfigurationManager) {
$ignoredClassesFromSettings = $configurationManager->getConfiguration('Settings', 'Neos.Flow.error.debugger.ignoredClasses');
if (is_array($ignoredClassesFromSettings)) {
$ignoredClassesConfiguration = Arrays::arrayMergeRecursiveOverrule($ignoredClassesConfiguration, $ignoredClassesFromSettings);
}
}
}
foreach ($ignoredClassesConfiguration as $classNamePattern => $active) {
if ($active === true) {
$ignoredClasses[] = $classNamePattern;
}
}
self::$ignoredClassesRegex = sprintf('/^%s$/xs', implode('$|^', $ignoredClasses));
return self::$ignoredClassesRegex;
} | php | public static function getIgnoredClassesRegex(): string
{
if (self::$ignoredClassesRegex !== '') {
return self::$ignoredClassesRegex;
}
$ignoredClassesConfiguration = self::$ignoredClassesFallback;
$ignoredClasses = [];
if (self::$objectManager instanceof ObjectManagerInterface) {
$configurationManager = self::$objectManager->get(ConfigurationManager::class);
if ($configurationManager instanceof ConfigurationManager) {
$ignoredClassesFromSettings = $configurationManager->getConfiguration('Settings', 'Neos.Flow.error.debugger.ignoredClasses');
if (is_array($ignoredClassesFromSettings)) {
$ignoredClassesConfiguration = Arrays::arrayMergeRecursiveOverrule($ignoredClassesConfiguration, $ignoredClassesFromSettings);
}
}
}
foreach ($ignoredClassesConfiguration as $classNamePattern => $active) {
if ($active === true) {
$ignoredClasses[] = $classNamePattern;
}
}
self::$ignoredClassesRegex = sprintf('/^%s$/xs', implode('$|^', $ignoredClasses));
return self::$ignoredClassesRegex;
} | [
"public",
"static",
"function",
"getIgnoredClassesRegex",
"(",
")",
":",
"string",
"{",
"if",
"(",
"self",
"::",
"$",
"ignoredClassesRegex",
"!==",
"''",
")",
"{",
"return",
"self",
"::",
"$",
"ignoredClassesRegex",
";",
"}",
"$",
"ignoredClassesConfiguration",
... | Tries to load the 'Neos.Flow.error.debugger.ignoredClasses' setting
to build a regular expression that can be used to filter ignored class names
If settings can't be loaded it uses self::$ignoredClassesFallback.
@return string | [
"Tries",
"to",
"load",
"the",
"Neos",
".",
"Flow",
".",
"error",
".",
"debugger",
".",
"ignoredClasses",
"setting",
"to",
"build",
"a",
"regular",
"expression",
"that",
"can",
"be",
"used",
"to",
"filter",
"ignored",
"class",
"names",
"If",
"settings",
"ca... | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Error/Debugger.php#L534-L562 |
neos/flow-development-collection | Neos.Flow/Classes/Error/Debugger.php | Debugger.getRecursionLimit | public static function getRecursionLimit(): int
{
if (self::$recursionLimit) {
return self::$recursionLimit;
}
self::$recursionLimit = self::$recursionLimitFallback;
if (self::$objectManager instanceof ObjectManagerInterface) {
$configurationManager = self::$objectManager->get(ConfigurationManager::class);
if ($configurationManager instanceof ConfigurationManager) {
$recursionLimitFromSettings = $configurationManager->getConfiguration('Settings', 'Neos.Flow.error.debugger.recursionLimit');
if (is_int($recursionLimitFromSettings)) {
self::$recursionLimit = $recursionLimitFromSettings;
}
}
}
return self::$recursionLimit;
} | php | public static function getRecursionLimit(): int
{
if (self::$recursionLimit) {
return self::$recursionLimit;
}
self::$recursionLimit = self::$recursionLimitFallback;
if (self::$objectManager instanceof ObjectManagerInterface) {
$configurationManager = self::$objectManager->get(ConfigurationManager::class);
if ($configurationManager instanceof ConfigurationManager) {
$recursionLimitFromSettings = $configurationManager->getConfiguration('Settings', 'Neos.Flow.error.debugger.recursionLimit');
if (is_int($recursionLimitFromSettings)) {
self::$recursionLimit = $recursionLimitFromSettings;
}
}
}
return self::$recursionLimit;
} | [
"public",
"static",
"function",
"getRecursionLimit",
"(",
")",
":",
"int",
"{",
"if",
"(",
"self",
"::",
"$",
"recursionLimit",
")",
"{",
"return",
"self",
"::",
"$",
"recursionLimit",
";",
"}",
"self",
"::",
"$",
"recursionLimit",
"=",
"self",
"::",
"$"... | Tries to load the 'Neos.Flow.error.debugger.recursionLimit' setting
to determine the maximal recursions-level fgor the debugger.
If settings can't be loaded it uses self::$ignoredClassesFallback.
@return integer | [
"Tries",
"to",
"load",
"the",
"Neos",
".",
"Flow",
".",
"error",
".",
"debugger",
".",
"recursionLimit",
"setting",
"to",
"determine",
"the",
"maximal",
"recursions",
"-",
"level",
"fgor",
"the",
"debugger",
".",
"If",
"settings",
"can",
"t",
"be",
"loaded... | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Error/Debugger.php#L571-L590 |
neos/flow-development-collection | Neos.Flow/Classes/Session/Aspect/LoggingAspect.php | LoggingAspect.logStart | public function logStart(JoinPointInterface $joinPoint)
{
$session = $joinPoint->getProxy();
if ($session->isStarted()) {
$this->logger->info(sprintf('%s: Started session with id %s.', $this->getClassName($joinPoint), $session->getId()), [
'packageKey' => 'Neos.Flow',
'className' => $joinPoint->getClassName(),
'methodName' => $joinPoint->getMethodName()
]);
}
} | php | public function logStart(JoinPointInterface $joinPoint)
{
$session = $joinPoint->getProxy();
if ($session->isStarted()) {
$this->logger->info(sprintf('%s: Started session with id %s.', $this->getClassName($joinPoint), $session->getId()), [
'packageKey' => 'Neos.Flow',
'className' => $joinPoint->getClassName(),
'methodName' => $joinPoint->getMethodName()
]);
}
} | [
"public",
"function",
"logStart",
"(",
"JoinPointInterface",
"$",
"joinPoint",
")",
"{",
"$",
"session",
"=",
"$",
"joinPoint",
"->",
"getProxy",
"(",
")",
";",
"if",
"(",
"$",
"session",
"->",
"isStarted",
"(",
")",
")",
"{",
"$",
"this",
"->",
"logge... | Logs calls of start()
@Flow\After("within(Neos\Flow\Session\SessionInterface) && method(.*->start())")
@param JoinPointInterface $joinPoint The current joinpoint
@return mixed The result of the target method if it has not been intercepted | [
"Logs",
"calls",
"of",
"start",
"()"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Session/Aspect/LoggingAspect.php#L50-L60 |
neos/flow-development-collection | Neos.Flow/Classes/Session/Aspect/LoggingAspect.php | LoggingAspect.logResume | public function logResume(JoinPointInterface $joinPoint)
{
$session = $joinPoint->getProxy();
if ($session->isStarted()) {
$inactivityInSeconds = $joinPoint->getResult();
if ($inactivityInSeconds === 1) {
$inactivityMessage = '1 second';
} elseif ($inactivityInSeconds < 120) {
$inactivityMessage = sprintf('%s seconds', $inactivityInSeconds);
} elseif ($inactivityInSeconds < 3600) {
$inactivityMessage = sprintf('%s minutes', intval($inactivityInSeconds / 60));
} elseif ($inactivityInSeconds < 7200) {
$inactivityMessage = 'more than an hour';
} else {
$inactivityMessage = sprintf('more than %s hours', intval($inactivityInSeconds / 3600));
}
$this->logger->debug(sprintf('%s: Resumed session with id %s which was inactive for %s. (%ss)', $this->getClassName($joinPoint), $joinPoint->getProxy()->getId(), $inactivityMessage, $inactivityInSeconds));
}
} | php | public function logResume(JoinPointInterface $joinPoint)
{
$session = $joinPoint->getProxy();
if ($session->isStarted()) {
$inactivityInSeconds = $joinPoint->getResult();
if ($inactivityInSeconds === 1) {
$inactivityMessage = '1 second';
} elseif ($inactivityInSeconds < 120) {
$inactivityMessage = sprintf('%s seconds', $inactivityInSeconds);
} elseif ($inactivityInSeconds < 3600) {
$inactivityMessage = sprintf('%s minutes', intval($inactivityInSeconds / 60));
} elseif ($inactivityInSeconds < 7200) {
$inactivityMessage = 'more than an hour';
} else {
$inactivityMessage = sprintf('more than %s hours', intval($inactivityInSeconds / 3600));
}
$this->logger->debug(sprintf('%s: Resumed session with id %s which was inactive for %s. (%ss)', $this->getClassName($joinPoint), $joinPoint->getProxy()->getId(), $inactivityMessage, $inactivityInSeconds));
}
} | [
"public",
"function",
"logResume",
"(",
"JoinPointInterface",
"$",
"joinPoint",
")",
"{",
"$",
"session",
"=",
"$",
"joinPoint",
"->",
"getProxy",
"(",
")",
";",
"if",
"(",
"$",
"session",
"->",
"isStarted",
"(",
")",
")",
"{",
"$",
"inactivityInSeconds",
... | Logs calls of resume()
@Flow\After("within(Neos\Flow\Session\SessionInterface) && method(.*->resume())")
@param JoinPointInterface $joinPoint The current joinpoint
@return mixed The result of the target method if it has not been intercepted | [
"Logs",
"calls",
"of",
"resume",
"()"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Session/Aspect/LoggingAspect.php#L69-L87 |
neos/flow-development-collection | Neos.Flow/Classes/Session/Aspect/LoggingAspect.php | LoggingAspect.logDestroy | public function logDestroy(JoinPointInterface $joinPoint)
{
$session = $joinPoint->getProxy();
if ($session->isStarted()) {
$reason = $joinPoint->isMethodArgument('reason') ? $joinPoint->getMethodArgument('reason') : 'no reason given';
$this->logger->debug(sprintf('%s: Destroyed session with id %s: %s', $this->getClassName($joinPoint), $joinPoint->getProxy()->getId(), $reason));
}
} | php | public function logDestroy(JoinPointInterface $joinPoint)
{
$session = $joinPoint->getProxy();
if ($session->isStarted()) {
$reason = $joinPoint->isMethodArgument('reason') ? $joinPoint->getMethodArgument('reason') : 'no reason given';
$this->logger->debug(sprintf('%s: Destroyed session with id %s: %s', $this->getClassName($joinPoint), $joinPoint->getProxy()->getId(), $reason));
}
} | [
"public",
"function",
"logDestroy",
"(",
"JoinPointInterface",
"$",
"joinPoint",
")",
"{",
"$",
"session",
"=",
"$",
"joinPoint",
"->",
"getProxy",
"(",
")",
";",
"if",
"(",
"$",
"session",
"->",
"isStarted",
"(",
")",
")",
"{",
"$",
"reason",
"=",
"$"... | Logs calls of destroy()
@Flow\Before("within(Neos\Flow\Session\SessionInterface) && method(.*->destroy())")
@param JoinPointInterface $joinPoint The current joinpoint
@return mixed The result of the target method if it has not been intercepted | [
"Logs",
"calls",
"of",
"destroy",
"()"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Session/Aspect/LoggingAspect.php#L96-L103 |
neos/flow-development-collection | Neos.Flow/Classes/Session/Aspect/LoggingAspect.php | LoggingAspect.logRenewId | public function logRenewId(JoinPointInterface $joinPoint)
{
$session = $joinPoint->getProxy();
$oldId = $session->getId();
$newId = $joinPoint->getAdviceChain()->proceed($joinPoint);
if ($session->isStarted()) {
$this->logger->info(sprintf('%s: Changed session id from %s to %s', $this->getClassName($joinPoint), $oldId, $newId), ['FLOW_LOG_ENVIRONMENT' => [
'packageKey' => 'Neos.Flow',
'className' => $joinPoint->getClassName(),
'methodName' => $joinPoint->getMethodName()
]]);
}
return $newId;
} | php | public function logRenewId(JoinPointInterface $joinPoint)
{
$session = $joinPoint->getProxy();
$oldId = $session->getId();
$newId = $joinPoint->getAdviceChain()->proceed($joinPoint);
if ($session->isStarted()) {
$this->logger->info(sprintf('%s: Changed session id from %s to %s', $this->getClassName($joinPoint), $oldId, $newId), ['FLOW_LOG_ENVIRONMENT' => [
'packageKey' => 'Neos.Flow',
'className' => $joinPoint->getClassName(),
'methodName' => $joinPoint->getMethodName()
]]);
}
return $newId;
} | [
"public",
"function",
"logRenewId",
"(",
"JoinPointInterface",
"$",
"joinPoint",
")",
"{",
"$",
"session",
"=",
"$",
"joinPoint",
"->",
"getProxy",
"(",
")",
";",
"$",
"oldId",
"=",
"$",
"session",
"->",
"getId",
"(",
")",
";",
"$",
"newId",
"=",
"$",
... | Logs calls of renewId()
@Flow\Around("within(Neos\Flow\Session\SessionInterface) && method(.*->renewId())")
@param JoinPointInterface $joinPoint The current joinpoint
@return mixed The result of the target method if it has not been intercepted | [
"Logs",
"calls",
"of",
"renewId",
"()"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Session/Aspect/LoggingAspect.php#L112-L125 |
neos/flow-development-collection | Neos.Flow/Classes/Session/Aspect/LoggingAspect.php | LoggingAspect.logCollectGarbage | public function logCollectGarbage(JoinPointInterface $joinPoint)
{
$logEnvironment = [
'FLOW_LOG_ENVIRONMENT' => [
'packageKey' => 'Neos.Flow',
'className' => $joinPoint->getClassName(),
'methodName' => $joinPoint->getMethodName()
]
];
$sessionRemovalCount = $joinPoint->getResult();
if ($sessionRemovalCount > 0) {
$this->logger->info(sprintf('%s: Triggered garbage collection and removed %s expired sessions.', $this->getClassName($joinPoint), $sessionRemovalCount), $logEnvironment);
} elseif ($sessionRemovalCount === 0) {
$this->logger->info(sprintf('%s: Triggered garbage collection but no sessions needed to be removed.', $this->getClassName($joinPoint)), $logEnvironment);
} elseif ($sessionRemovalCount === false) {
$this->logger->warning(sprintf('%s: Ommitting garbage collection because another process is already running. Consider lowering the GC propability if these messages appear a lot.', $this->getClassName($joinPoint)), $logEnvironment);
}
} | php | public function logCollectGarbage(JoinPointInterface $joinPoint)
{
$logEnvironment = [
'FLOW_LOG_ENVIRONMENT' => [
'packageKey' => 'Neos.Flow',
'className' => $joinPoint->getClassName(),
'methodName' => $joinPoint->getMethodName()
]
];
$sessionRemovalCount = $joinPoint->getResult();
if ($sessionRemovalCount > 0) {
$this->logger->info(sprintf('%s: Triggered garbage collection and removed %s expired sessions.', $this->getClassName($joinPoint), $sessionRemovalCount), $logEnvironment);
} elseif ($sessionRemovalCount === 0) {
$this->logger->info(sprintf('%s: Triggered garbage collection but no sessions needed to be removed.', $this->getClassName($joinPoint)), $logEnvironment);
} elseif ($sessionRemovalCount === false) {
$this->logger->warning(sprintf('%s: Ommitting garbage collection because another process is already running. Consider lowering the GC propability if these messages appear a lot.', $this->getClassName($joinPoint)), $logEnvironment);
}
} | [
"public",
"function",
"logCollectGarbage",
"(",
"JoinPointInterface",
"$",
"joinPoint",
")",
"{",
"$",
"logEnvironment",
"=",
"[",
"'FLOW_LOG_ENVIRONMENT'",
"=>",
"[",
"'packageKey'",
"=>",
"'Neos.Flow'",
",",
"'className'",
"=>",
"$",
"joinPoint",
"->",
"getClassNa... | Logs calls of collectGarbage()
@Flow\AfterReturning("within(Neos\Flow\Session\SessionInterface) && method(.*->collectGarbage())")
@param JoinPointInterface $joinPoint The current joinpoint
@return void | [
"Logs",
"calls",
"of",
"collectGarbage",
"()"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Session/Aspect/LoggingAspect.php#L134-L152 |
neos/flow-development-collection | Neos.Flow/Classes/Session/Aspect/LoggingAspect.php | LoggingAspect.getClassName | protected function getClassName(JoinPointInterface $joinPoint)
{
$className = $joinPoint->getClassName();
$sessionNamespace = substr(SessionInterface::class, 0, -strrpos(SessionInterface::class, '\\') + 1);
if (strpos($className, $sessionNamespace) === 0) {
$className = substr($className, strlen($sessionNamespace));
}
return $className;
} | php | protected function getClassName(JoinPointInterface $joinPoint)
{
$className = $joinPoint->getClassName();
$sessionNamespace = substr(SessionInterface::class, 0, -strrpos(SessionInterface::class, '\\') + 1);
if (strpos($className, $sessionNamespace) === 0) {
$className = substr($className, strlen($sessionNamespace));
}
return $className;
} | [
"protected",
"function",
"getClassName",
"(",
"JoinPointInterface",
"$",
"joinPoint",
")",
"{",
"$",
"className",
"=",
"$",
"joinPoint",
"->",
"getClassName",
"(",
")",
";",
"$",
"sessionNamespace",
"=",
"substr",
"(",
"SessionInterface",
"::",
"class",
",",
"... | Determines the short or full class name of the session implementation
@param JoinPointInterface $joinPoint
@return string | [
"Determines",
"the",
"short",
"or",
"full",
"class",
"name",
"of",
"the",
"session",
"implementation"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Session/Aspect/LoggingAspect.php#L160-L168 |
neos/flow-development-collection | Neos.Flow/Classes/I18n/Cldr/CldrParser.php | CldrParser.parseNode | protected function parseNode(\SimpleXMLElement $node)
{
$parsedNode = [];
if ($node->count() === 0) {
return (string)$node;
}
foreach ($node->children() as $child) {
$nameOfChild = $child->getName();
$parsedChild = $this->parseNode($child);
if (count($child->attributes()) > 0) {
$parsedAttributes = '';
foreach ($child->attributes() as $attributeName => $attributeValue) {
if ($this->isDistinguishingAttribute($attributeName)) {
$parsedAttributes .= '[@' . $attributeName . '="' . $attributeValue . '"]';
}
}
$nameOfChild .= $parsedAttributes;
}
if (!isset($parsedNode[$nameOfChild])) {
// We accept only first child when they are non distinguishable (i.e. they differs only by non-distinguishing attributes)
$parsedNode[$nameOfChild] = $parsedChild;
}
}
return $parsedNode;
} | php | protected function parseNode(\SimpleXMLElement $node)
{
$parsedNode = [];
if ($node->count() === 0) {
return (string)$node;
}
foreach ($node->children() as $child) {
$nameOfChild = $child->getName();
$parsedChild = $this->parseNode($child);
if (count($child->attributes()) > 0) {
$parsedAttributes = '';
foreach ($child->attributes() as $attributeName => $attributeValue) {
if ($this->isDistinguishingAttribute($attributeName)) {
$parsedAttributes .= '[@' . $attributeName . '="' . $attributeValue . '"]';
}
}
$nameOfChild .= $parsedAttributes;
}
if (!isset($parsedNode[$nameOfChild])) {
// We accept only first child when they are non distinguishable (i.e. they differs only by non-distinguishing attributes)
$parsedNode[$nameOfChild] = $parsedChild;
}
}
return $parsedNode;
} | [
"protected",
"function",
"parseNode",
"(",
"\\",
"SimpleXMLElement",
"$",
"node",
")",
"{",
"$",
"parsedNode",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"node",
"->",
"count",
"(",
")",
"===",
"0",
")",
"{",
"return",
"(",
"string",
")",
"$",
"node",
";"... | Returns array representation of XML data, starting from a node pointed by
$node variable.
Please see the documentation of this class for details about the internal
representation of XML data.
@param \SimpleXMLElement $node A node to start parsing from
@return mixed An array representing parsed XML node or string value if leaf | [
"Returns",
"array",
"representation",
"of",
"XML",
"data",
"starting",
"from",
"a",
"node",
"pointed",
"by",
"$node",
"variable",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/I18n/Cldr/CldrParser.php#L77-L108 |
neos/flow-development-collection | Neos.Flow/Classes/I18n/Cldr/CldrParser.php | CldrParser.isDistinguishingAttribute | protected function isDistinguishingAttribute($attributeName)
{
// Taken from SupplementalMetadata and hardcoded for now
$distinguishingAttributes = ['key', 'request', 'id', '_q', 'registry', 'alt', 'iso4217', 'iso3166', 'mzone', 'from', 'to', 'type'];
// These are not defined as distinguishing in CLDR but we need to preserve them for alias resolving later
$distinguishingAttributes[] = 'source';
$distinguishingAttributes[] = 'path';
// These are needed for proper plurals handling
$distinguishingAttributes[] = 'locales';
$distinguishingAttributes[] = 'count';
// we need this one for datetime parsing (default[@choice] nodes)
$distinguishingAttributes[] = 'choice';
return in_array($attributeName, $distinguishingAttributes);
} | php | protected function isDistinguishingAttribute($attributeName)
{
// Taken from SupplementalMetadata and hardcoded for now
$distinguishingAttributes = ['key', 'request', 'id', '_q', 'registry', 'alt', 'iso4217', 'iso3166', 'mzone', 'from', 'to', 'type'];
// These are not defined as distinguishing in CLDR but we need to preserve them for alias resolving later
$distinguishingAttributes[] = 'source';
$distinguishingAttributes[] = 'path';
// These are needed for proper plurals handling
$distinguishingAttributes[] = 'locales';
$distinguishingAttributes[] = 'count';
// we need this one for datetime parsing (default[@choice] nodes)
$distinguishingAttributes[] = 'choice';
return in_array($attributeName, $distinguishingAttributes);
} | [
"protected",
"function",
"isDistinguishingAttribute",
"(",
"$",
"attributeName",
")",
"{",
"// Taken from SupplementalMetadata and hardcoded for now",
"$",
"distinguishingAttributes",
"=",
"[",
"'key'",
",",
"'request'",
",",
"'id'",
",",
"'_q'",
",",
"'registry'",
",",
... | Checks if given attribute belongs to the group of distinguishing attributes
Distinguishing attributes in CLDR serves to distinguish multiple elements
at the same level (most notably 'type').
@param string $attributeName
@return boolean | [
"Checks",
"if",
"given",
"attribute",
"belongs",
"to",
"the",
"group",
"of",
"distinguishing",
"attributes"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/I18n/Cldr/CldrParser.php#L119-L136 |
neos/flow-development-collection | Neos.Flow/Classes/Aop/Builder/ProxyClassBuilder.php | ProxyClassBuilder.build | public function build(): void
{
$allAvailableClassNamesByPackage = $this->objectManager->getRegisteredClassNames();
$possibleTargetClassNames = $this->getProxyableClasses($allAvailableClassNamesByPackage);
$actualAspectClassNames = $this->reflectionService->getClassNamesByAnnotation(Flow\Aspect::class);
sort($possibleTargetClassNames);
sort($actualAspectClassNames);
$this->aspectContainers = $this->buildAspectContainers($actualAspectClassNames);
$rebuildEverything = false;
if ($this->objectConfigurationCache->has('allAspectClassesUpToDate') === false) {
$rebuildEverything = true;
$this->logger->info('Aspects have been modified, therefore rebuilding all target classes.', LogEnvironment::fromMethodName(__METHOD__));
$this->objectConfigurationCache->set('allAspectClassesUpToDate', true);
}
$possibleTargetClassNameIndex = new ClassNameIndex();
$possibleTargetClassNameIndex->setClassNames($possibleTargetClassNames);
$targetClassNameCandidates = new ClassNameIndex();
foreach ($this->aspectContainers as $aspectContainer) {
$targetClassNameCandidates->applyUnion($aspectContainer->reduceTargetClassNames($possibleTargetClassNameIndex));
}
$targetClassNameCandidates->sort();
$treatedSubClasses = new ClassNameIndex();
foreach ($targetClassNameCandidates->getClassNames() as $targetClassName) {
$isUnproxied = $this->objectConfigurationCache->has('unproxiedClass-' . str_replace('\\', '_', $targetClassName));
$hasCacheEntry = $this->compiler->hasCacheEntryForClass($targetClassName) || $isUnproxied;
if ($rebuildEverything === true || $hasCacheEntry === false) {
$proxyBuildResult = $this->buildProxyClass($targetClassName, $this->aspectContainers);
if ($proxyBuildResult === false) {
// In case the proxy was not build because there was nothing adviced,
// it might be an advice in the parent and so we need to try to treat this class.
$treatedSubClasses = $this->addBuildMethodsAndAdvicesCodeToClass($targetClassName, $treatedSubClasses);
}
$treatedSubClasses = $this->proxySubClassesOfClassToEnsureAdvices($targetClassName, $targetClassNameCandidates, $treatedSubClasses);
if ($proxyBuildResult !== false) {
if ($isUnproxied) {
$this->objectConfigurationCache->remove('unproxiedClass-' . str_replace('\\', '_', $targetClassName));
}
$this->logger->debug(sprintf('Built AOP proxy for class "%s".', $targetClassName));
} else {
$this->objectConfigurationCache->set('unproxiedClass-' . str_replace('\\', '_', $targetClassName), true);
}
}
}
} | php | public function build(): void
{
$allAvailableClassNamesByPackage = $this->objectManager->getRegisteredClassNames();
$possibleTargetClassNames = $this->getProxyableClasses($allAvailableClassNamesByPackage);
$actualAspectClassNames = $this->reflectionService->getClassNamesByAnnotation(Flow\Aspect::class);
sort($possibleTargetClassNames);
sort($actualAspectClassNames);
$this->aspectContainers = $this->buildAspectContainers($actualAspectClassNames);
$rebuildEverything = false;
if ($this->objectConfigurationCache->has('allAspectClassesUpToDate') === false) {
$rebuildEverything = true;
$this->logger->info('Aspects have been modified, therefore rebuilding all target classes.', LogEnvironment::fromMethodName(__METHOD__));
$this->objectConfigurationCache->set('allAspectClassesUpToDate', true);
}
$possibleTargetClassNameIndex = new ClassNameIndex();
$possibleTargetClassNameIndex->setClassNames($possibleTargetClassNames);
$targetClassNameCandidates = new ClassNameIndex();
foreach ($this->aspectContainers as $aspectContainer) {
$targetClassNameCandidates->applyUnion($aspectContainer->reduceTargetClassNames($possibleTargetClassNameIndex));
}
$targetClassNameCandidates->sort();
$treatedSubClasses = new ClassNameIndex();
foreach ($targetClassNameCandidates->getClassNames() as $targetClassName) {
$isUnproxied = $this->objectConfigurationCache->has('unproxiedClass-' . str_replace('\\', '_', $targetClassName));
$hasCacheEntry = $this->compiler->hasCacheEntryForClass($targetClassName) || $isUnproxied;
if ($rebuildEverything === true || $hasCacheEntry === false) {
$proxyBuildResult = $this->buildProxyClass($targetClassName, $this->aspectContainers);
if ($proxyBuildResult === false) {
// In case the proxy was not build because there was nothing adviced,
// it might be an advice in the parent and so we need to try to treat this class.
$treatedSubClasses = $this->addBuildMethodsAndAdvicesCodeToClass($targetClassName, $treatedSubClasses);
}
$treatedSubClasses = $this->proxySubClassesOfClassToEnsureAdvices($targetClassName, $targetClassNameCandidates, $treatedSubClasses);
if ($proxyBuildResult !== false) {
if ($isUnproxied) {
$this->objectConfigurationCache->remove('unproxiedClass-' . str_replace('\\', '_', $targetClassName));
}
$this->logger->debug(sprintf('Built AOP proxy for class "%s".', $targetClassName));
} else {
$this->objectConfigurationCache->set('unproxiedClass-' . str_replace('\\', '_', $targetClassName), true);
}
}
}
} | [
"public",
"function",
"build",
"(",
")",
":",
"void",
"{",
"$",
"allAvailableClassNamesByPackage",
"=",
"$",
"this",
"->",
"objectManager",
"->",
"getRegisteredClassNames",
"(",
")",
";",
"$",
"possibleTargetClassNames",
"=",
"$",
"this",
"->",
"getProxyableClasse... | Builds proxy class code which weaves advices into the respective target classes.
The object configurations provided by the Compiler are searched for possible aspect
annotations. If an aspect class is found, the pointcut expressions are parsed and
a new aspect with one or more advisors is added to the aspect registry of the AOP framework.
Finally all advices are woven into their target classes by generating proxy classes.
In general, the command neos.flow:core:compile is responsible for compilation
and calls this method to do so.
In order to distinguish between an emerged / changed possible target class and
a class which has been matched previously but just didn't have to be proxied,
the latter are kept track of by an "unproxiedClass-*" cache entry.
@return void | [
"Builds",
"proxy",
"class",
"code",
"which",
"weaves",
"advices",
"into",
"the",
"respective",
"target",
"classes",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Aop/Builder/ProxyClassBuilder.php#L193-L242 |
neos/flow-development-collection | Neos.Flow/Classes/Aop/Builder/ProxyClassBuilder.php | ProxyClassBuilder.findPointcut | public function findPointcut(string $aspectClassName, string $pointcutMethodName)
{
if (!isset($this->aspectContainers[$aspectClassName])) {
return false;
}
foreach ($this->aspectContainers[$aspectClassName]->getPointcuts() as $pointcut) {
if ($pointcut->getPointcutMethodName() === $pointcutMethodName) {
return $pointcut;
}
}
return false;
} | php | public function findPointcut(string $aspectClassName, string $pointcutMethodName)
{
if (!isset($this->aspectContainers[$aspectClassName])) {
return false;
}
foreach ($this->aspectContainers[$aspectClassName]->getPointcuts() as $pointcut) {
if ($pointcut->getPointcutMethodName() === $pointcutMethodName) {
return $pointcut;
}
}
return false;
} | [
"public",
"function",
"findPointcut",
"(",
"string",
"$",
"aspectClassName",
",",
"string",
"$",
"pointcutMethodName",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"aspectContainers",
"[",
"$",
"aspectClassName",
"]",
")",
")",
"{",
"return",
... | Traverses the aspect containers to find a pointcut from the aspect class name
and pointcut method name
@param string $aspectClassName Name of the aspect class where the pointcut has been declared
@param string $pointcutMethodName Method name of the pointcut
@return mixed The Aop\Pointcut\Pointcut or false if none was found | [
"Traverses",
"the",
"aspect",
"containers",
"to",
"find",
"a",
"pointcut",
"from",
"the",
"aspect",
"class",
"name",
"and",
"pointcut",
"method",
"name"
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Aop/Builder/ProxyClassBuilder.php#L252-L263 |
neos/flow-development-collection | Neos.Flow/Classes/Aop/Builder/ProxyClassBuilder.php | ProxyClassBuilder.getProxyableClasses | protected function getProxyableClasses(array $classNamesByPackage): array
{
$proxyableClasses = [];
foreach ($classNamesByPackage as $classNames) {
foreach ($classNames as $className) {
if (in_array(substr($className, 0, 15), $this->blacklistedSubPackages)) {
continue;
}
if ($this->reflectionService->isClassAnnotatedWith($className, Flow\Aspect::class)) {
continue;
}
$proxyableClasses[] = $className;
}
}
return $proxyableClasses;
} | php | protected function getProxyableClasses(array $classNamesByPackage): array
{
$proxyableClasses = [];
foreach ($classNamesByPackage as $classNames) {
foreach ($classNames as $className) {
if (in_array(substr($className, 0, 15), $this->blacklistedSubPackages)) {
continue;
}
if ($this->reflectionService->isClassAnnotatedWith($className, Flow\Aspect::class)) {
continue;
}
$proxyableClasses[] = $className;
}
}
return $proxyableClasses;
} | [
"protected",
"function",
"getProxyableClasses",
"(",
"array",
"$",
"classNamesByPackage",
")",
":",
"array",
"{",
"$",
"proxyableClasses",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"classNamesByPackage",
"as",
"$",
"classNames",
")",
"{",
"foreach",
"(",
"$",
... | Determines which of the given classes are potentially proxyable
and returns their names in an array.
@param array $classNamesByPackage Names of the classes to check
@return array Names of classes which can be proxied | [
"Determines",
"which",
"of",
"the",
"given",
"classes",
"are",
"potentially",
"proxyable",
"and",
"returns",
"their",
"names",
"in",
"an",
"array",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Aop/Builder/ProxyClassBuilder.php#L272-L287 |
neos/flow-development-collection | Neos.Flow/Classes/Aop/Builder/ProxyClassBuilder.php | ProxyClassBuilder.buildAspectContainers | protected function buildAspectContainers(array &$classNames): array
{
$aspectContainers = [];
foreach ($classNames as $aspectClassName) {
$aspectContainers[$aspectClassName] = $this->buildAspectContainer($aspectClassName);
}
return $aspectContainers;
} | php | protected function buildAspectContainers(array &$classNames): array
{
$aspectContainers = [];
foreach ($classNames as $aspectClassName) {
$aspectContainers[$aspectClassName] = $this->buildAspectContainer($aspectClassName);
}
return $aspectContainers;
} | [
"protected",
"function",
"buildAspectContainers",
"(",
"array",
"&",
"$",
"classNames",
")",
":",
"array",
"{",
"$",
"aspectContainers",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"classNames",
"as",
"$",
"aspectClassName",
")",
"{",
"$",
"aspectContainers",
"... | Checks the annotations of the specified classes for aspect tags
and creates an aspect with advisors accordingly.
@param array &$classNames Classes to check for aspect tags.
@return array An array of Aop\AspectContainer for all aspects which were found. | [
"Checks",
"the",
"annotations",
"of",
"the",
"specified",
"classes",
"for",
"aspect",
"tags",
"and",
"creates",
"an",
"aspect",
"with",
"advisors",
"accordingly",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Aop/Builder/ProxyClassBuilder.php#L296-L303 |
neos/flow-development-collection | Neos.Flow/Classes/Aop/Builder/ProxyClassBuilder.php | ProxyClassBuilder.buildAspectContainer | protected function buildAspectContainer(string $aspectClassName): AspectContainer
{
$aspectContainer = new AspectContainer($aspectClassName);
$methodNames = get_class_methods($aspectClassName);
foreach ($methodNames as $methodName) {
foreach ($this->reflectionService->getMethodAnnotations($aspectClassName, $methodName) as $annotation) {
$annotationClass = get_class($annotation);
switch ($annotationClass) {
case Flow\Around::class:
$pointcutFilterComposite = $this->pointcutExpressionParser->parse($annotation->pointcutExpression, $this->renderSourceHint($aspectClassName, $methodName, $annotationClass));
$advice = new Aop\Advice\AroundAdvice($aspectClassName, $methodName);
$pointcut = new Aop\Pointcut\Pointcut($annotation->pointcutExpression, $pointcutFilterComposite, $aspectClassName);
$advisor = new Aop\Advisor($advice, $pointcut);
$aspectContainer->addAdvisor($advisor);
break;
case Flow\Before::class:
$pointcutFilterComposite = $this->pointcutExpressionParser->parse($annotation->pointcutExpression, $this->renderSourceHint($aspectClassName, $methodName, $annotationClass));
$advice = new Aop\Advice\BeforeAdvice($aspectClassName, $methodName);
$pointcut = new Aop\Pointcut\Pointcut($annotation->pointcutExpression, $pointcutFilterComposite, $aspectClassName);
$advisor = new Aop\Advisor($advice, $pointcut);
$aspectContainer->addAdvisor($advisor);
break;
case Flow\AfterReturning::class:
$pointcutFilterComposite = $this->pointcutExpressionParser->parse($annotation->pointcutExpression, $this->renderSourceHint($aspectClassName, $methodName, $annotationClass));
$advice = new Aop\Advice\AfterReturningAdvice($aspectClassName, $methodName);
$pointcut = new Aop\Pointcut\Pointcut($annotation->pointcutExpression, $pointcutFilterComposite, $aspectClassName);
$advisor = new Aop\Advisor($advice, $pointcut);
$aspectContainer->addAdvisor($advisor);
break;
case Flow\AfterThrowing::class:
$pointcutFilterComposite = $this->pointcutExpressionParser->parse($annotation->pointcutExpression, $this->renderSourceHint($aspectClassName, $methodName, $annotationClass));
$advice = new Aop\Advice\AfterThrowingAdvice($aspectClassName, $methodName);
$pointcut = new Aop\Pointcut\Pointcut($annotation->pointcutExpression, $pointcutFilterComposite, $aspectClassName);
$advisor = new Aop\Advisor($advice, $pointcut);
$aspectContainer->addAdvisor($advisor);
break;
case Flow\After::class:
$pointcutFilterComposite = $this->pointcutExpressionParser->parse($annotation->pointcutExpression, $this->renderSourceHint($aspectClassName, $methodName, $annotationClass));
$advice = new Aop\Advice\AfterAdvice($aspectClassName, $methodName);
$pointcut = new Aop\Pointcut\Pointcut($annotation->pointcutExpression, $pointcutFilterComposite, $aspectClassName);
$advisor = new Aop\Advisor($advice, $pointcut);
$aspectContainer->addAdvisor($advisor);
break;
case Flow\Pointcut::class:
$pointcutFilterComposite = $this->pointcutExpressionParser->parse($annotation->expression, $this->renderSourceHint($aspectClassName, $methodName, $annotationClass));
$pointcut = new Aop\Pointcut\Pointcut($annotation->expression, $pointcutFilterComposite, $aspectClassName, $methodName);
$aspectContainer->addPointcut($pointcut);
break;
}
}
}
$introduceAnnotation = $this->reflectionService->getClassAnnotation($aspectClassName, Flow\Introduce::class);
if ($introduceAnnotation !== null) {
if ($introduceAnnotation->interfaceName === null && $introduceAnnotation->traitName === null) {
throw new Aop\Exception('The introduction in class "' . $aspectClassName . '" does neither contain an interface name nor a trait name, at least one is required.', 1172694761);
}
$pointcutFilterComposite = $this->pointcutExpressionParser->parse($introduceAnnotation->pointcutExpression, $this->renderSourceHint($aspectClassName, (string)$introduceAnnotation->interfaceName, Flow\Introduce::class));
$pointcut = new Aop\Pointcut\Pointcut($introduceAnnotation->pointcutExpression, $pointcutFilterComposite, $aspectClassName);
if ($introduceAnnotation->interfaceName !== null) {
$introduction = new Aop\InterfaceIntroduction($aspectClassName, $introduceAnnotation->interfaceName, $pointcut);
$aspectContainer->addInterfaceIntroduction($introduction);
}
if ($introduceAnnotation->traitName !== null) {
$introduction = new TraitIntroduction($aspectClassName, $introduceAnnotation->traitName, $pointcut);
$aspectContainer->addTraitIntroduction($introduction);
}
}
foreach ($this->reflectionService->getClassPropertyNames($aspectClassName) as $propertyName) {
$introduceAnnotation = $this->reflectionService->getPropertyAnnotation($aspectClassName, $propertyName, Flow\Introduce::class);
if ($introduceAnnotation !== null) {
$pointcutFilterComposite = $this->pointcutExpressionParser->parse($introduceAnnotation->pointcutExpression, $this->renderSourceHint($aspectClassName, $propertyName, Flow\Introduce::class));
$pointcut = new Aop\Pointcut\Pointcut($introduceAnnotation->pointcutExpression, $pointcutFilterComposite, $aspectClassName);
$introduction = new PropertyIntroduction($aspectClassName, $propertyName, $pointcut);
$aspectContainer->addPropertyIntroduction($introduction);
}
}
if (count($aspectContainer->getAdvisors()) < 1 &&
count($aspectContainer->getPointcuts()) < 1 &&
count($aspectContainer->getInterfaceIntroductions()) < 1 &&
count($aspectContainer->getTraitIntroductions()) < 1 &&
count($aspectContainer->getPropertyIntroductions()) < 1) {
throw new Aop\Exception('The class "' . $aspectClassName . '" is tagged to be an aspect but doesn\'t contain advices nor pointcut or introduction declarations.', 1169124534);
}
return $aspectContainer;
} | php | protected function buildAspectContainer(string $aspectClassName): AspectContainer
{
$aspectContainer = new AspectContainer($aspectClassName);
$methodNames = get_class_methods($aspectClassName);
foreach ($methodNames as $methodName) {
foreach ($this->reflectionService->getMethodAnnotations($aspectClassName, $methodName) as $annotation) {
$annotationClass = get_class($annotation);
switch ($annotationClass) {
case Flow\Around::class:
$pointcutFilterComposite = $this->pointcutExpressionParser->parse($annotation->pointcutExpression, $this->renderSourceHint($aspectClassName, $methodName, $annotationClass));
$advice = new Aop\Advice\AroundAdvice($aspectClassName, $methodName);
$pointcut = new Aop\Pointcut\Pointcut($annotation->pointcutExpression, $pointcutFilterComposite, $aspectClassName);
$advisor = new Aop\Advisor($advice, $pointcut);
$aspectContainer->addAdvisor($advisor);
break;
case Flow\Before::class:
$pointcutFilterComposite = $this->pointcutExpressionParser->parse($annotation->pointcutExpression, $this->renderSourceHint($aspectClassName, $methodName, $annotationClass));
$advice = new Aop\Advice\BeforeAdvice($aspectClassName, $methodName);
$pointcut = new Aop\Pointcut\Pointcut($annotation->pointcutExpression, $pointcutFilterComposite, $aspectClassName);
$advisor = new Aop\Advisor($advice, $pointcut);
$aspectContainer->addAdvisor($advisor);
break;
case Flow\AfterReturning::class:
$pointcutFilterComposite = $this->pointcutExpressionParser->parse($annotation->pointcutExpression, $this->renderSourceHint($aspectClassName, $methodName, $annotationClass));
$advice = new Aop\Advice\AfterReturningAdvice($aspectClassName, $methodName);
$pointcut = new Aop\Pointcut\Pointcut($annotation->pointcutExpression, $pointcutFilterComposite, $aspectClassName);
$advisor = new Aop\Advisor($advice, $pointcut);
$aspectContainer->addAdvisor($advisor);
break;
case Flow\AfterThrowing::class:
$pointcutFilterComposite = $this->pointcutExpressionParser->parse($annotation->pointcutExpression, $this->renderSourceHint($aspectClassName, $methodName, $annotationClass));
$advice = new Aop\Advice\AfterThrowingAdvice($aspectClassName, $methodName);
$pointcut = new Aop\Pointcut\Pointcut($annotation->pointcutExpression, $pointcutFilterComposite, $aspectClassName);
$advisor = new Aop\Advisor($advice, $pointcut);
$aspectContainer->addAdvisor($advisor);
break;
case Flow\After::class:
$pointcutFilterComposite = $this->pointcutExpressionParser->parse($annotation->pointcutExpression, $this->renderSourceHint($aspectClassName, $methodName, $annotationClass));
$advice = new Aop\Advice\AfterAdvice($aspectClassName, $methodName);
$pointcut = new Aop\Pointcut\Pointcut($annotation->pointcutExpression, $pointcutFilterComposite, $aspectClassName);
$advisor = new Aop\Advisor($advice, $pointcut);
$aspectContainer->addAdvisor($advisor);
break;
case Flow\Pointcut::class:
$pointcutFilterComposite = $this->pointcutExpressionParser->parse($annotation->expression, $this->renderSourceHint($aspectClassName, $methodName, $annotationClass));
$pointcut = new Aop\Pointcut\Pointcut($annotation->expression, $pointcutFilterComposite, $aspectClassName, $methodName);
$aspectContainer->addPointcut($pointcut);
break;
}
}
}
$introduceAnnotation = $this->reflectionService->getClassAnnotation($aspectClassName, Flow\Introduce::class);
if ($introduceAnnotation !== null) {
if ($introduceAnnotation->interfaceName === null && $introduceAnnotation->traitName === null) {
throw new Aop\Exception('The introduction in class "' . $aspectClassName . '" does neither contain an interface name nor a trait name, at least one is required.', 1172694761);
}
$pointcutFilterComposite = $this->pointcutExpressionParser->parse($introduceAnnotation->pointcutExpression, $this->renderSourceHint($aspectClassName, (string)$introduceAnnotation->interfaceName, Flow\Introduce::class));
$pointcut = new Aop\Pointcut\Pointcut($introduceAnnotation->pointcutExpression, $pointcutFilterComposite, $aspectClassName);
if ($introduceAnnotation->interfaceName !== null) {
$introduction = new Aop\InterfaceIntroduction($aspectClassName, $introduceAnnotation->interfaceName, $pointcut);
$aspectContainer->addInterfaceIntroduction($introduction);
}
if ($introduceAnnotation->traitName !== null) {
$introduction = new TraitIntroduction($aspectClassName, $introduceAnnotation->traitName, $pointcut);
$aspectContainer->addTraitIntroduction($introduction);
}
}
foreach ($this->reflectionService->getClassPropertyNames($aspectClassName) as $propertyName) {
$introduceAnnotation = $this->reflectionService->getPropertyAnnotation($aspectClassName, $propertyName, Flow\Introduce::class);
if ($introduceAnnotation !== null) {
$pointcutFilterComposite = $this->pointcutExpressionParser->parse($introduceAnnotation->pointcutExpression, $this->renderSourceHint($aspectClassName, $propertyName, Flow\Introduce::class));
$pointcut = new Aop\Pointcut\Pointcut($introduceAnnotation->pointcutExpression, $pointcutFilterComposite, $aspectClassName);
$introduction = new PropertyIntroduction($aspectClassName, $propertyName, $pointcut);
$aspectContainer->addPropertyIntroduction($introduction);
}
}
if (count($aspectContainer->getAdvisors()) < 1 &&
count($aspectContainer->getPointcuts()) < 1 &&
count($aspectContainer->getInterfaceIntroductions()) < 1 &&
count($aspectContainer->getTraitIntroductions()) < 1 &&
count($aspectContainer->getPropertyIntroductions()) < 1) {
throw new Aop\Exception('The class "' . $aspectClassName . '" is tagged to be an aspect but doesn\'t contain advices nor pointcut or introduction declarations.', 1169124534);
}
return $aspectContainer;
} | [
"protected",
"function",
"buildAspectContainer",
"(",
"string",
"$",
"aspectClassName",
")",
":",
"AspectContainer",
"{",
"$",
"aspectContainer",
"=",
"new",
"AspectContainer",
"(",
"$",
"aspectClassName",
")",
";",
"$",
"methodNames",
"=",
"get_class_methods",
"(",... | Creates and returns an aspect from the annotations found in a class which
is tagged as an aspect. The object acting as an advice will already be
fetched (and therefore instantiated if necessary).
@param string $aspectClassName Name of the class which forms the aspect, contains advices etc.
@return AspectContainer The aspect container containing one or more advisors
@throws Aop\Exception if no container could be built | [
"Creates",
"and",
"returns",
"an",
"aspect",
"from",
"the",
"annotations",
"found",
"in",
"a",
"class",
"which",
"is",
"tagged",
"as",
"an",
"aspect",
".",
"The",
"object",
"acting",
"as",
"an",
"advice",
"will",
"already",
"be",
"fetched",
"(",
"and",
"... | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Aop/Builder/ProxyClassBuilder.php#L314-L402 |
neos/flow-development-collection | Neos.Flow/Classes/Aop/Builder/ProxyClassBuilder.php | ProxyClassBuilder.buildProxyClass | public function buildProxyClass(string $targetClassName, array &$aspectContainers): bool
{
$interfaceIntroductions = $this->getMatchingInterfaceIntroductions($aspectContainers, $targetClassName);
$introducedInterfaces = $this->getInterfaceNamesFromIntroductions($interfaceIntroductions);
$introducedTraits = $this->getMatchingTraitNamesFromIntroductions($aspectContainers, $targetClassName);
$propertyIntroductions = $this->getMatchingPropertyIntroductions($aspectContainers, $targetClassName);
$methodsFromTargetClass = $this->getMethodsFromTargetClass($targetClassName);
$methodsFromIntroducedInterfaces = $this->getIntroducedMethodsFromInterfaceIntroductions($interfaceIntroductions);
$interceptedMethods = [];
$this->addAdvicedMethodsToInterceptedMethods($interceptedMethods, array_merge($methodsFromTargetClass, $methodsFromIntroducedInterfaces), $targetClassName, $aspectContainers);
$this->addIntroducedMethodsToInterceptedMethods($interceptedMethods, $methodsFromIntroducedInterfaces);
if (count($interceptedMethods) < 1 && count($introducedInterfaces) < 1 && count($introducedTraits) < 1 && count($propertyIntroductions) < 1) {
return false;
}
$proxyClass = $this->compiler->getProxyClass($targetClassName);
if ($proxyClass === false) {
return false;
}
$proxyClass->addInterfaces($introducedInterfaces);
$proxyClass->addTraits($introducedTraits);
/** @var $propertyIntroduction PropertyIntroduction */
foreach ($propertyIntroductions as $propertyIntroduction) {
$propertyName = $propertyIntroduction->getPropertyName();
$declaringAspectClassName = $propertyIntroduction->getDeclaringAspectClassName();
$possiblePropertyTypes = $this->reflectionService->getPropertyTagValues($declaringAspectClassName, $propertyName, 'var');
if (count($possiblePropertyTypes) > 0 && !$this->reflectionService->isPropertyAnnotatedWith($declaringAspectClassName, $propertyName, Flow\Transient::class)) {
$classSchema = $this->reflectionService->getClassSchema($targetClassName);
if ($classSchema !== null) {
$classSchema->addProperty($propertyName, $possiblePropertyTypes[0]);
}
}
$propertyReflection = new PropertyReflection($declaringAspectClassName, $propertyName);
$propertyReflection->setIsAopIntroduced(true);
$this->reflectionService->reflectClassProperty($targetClassName, $propertyReflection);
$proxyClass->addProperty($propertyName, var_export($propertyIntroduction->getInitialValue(), true), $propertyIntroduction->getPropertyVisibility(), $propertyIntroduction->getPropertyDocComment());
}
$proxyClass->getMethod('Flow_Aop_Proxy_buildMethodsAndAdvicesArray')->addPreParentCallCode(" if (method_exists(get_parent_class(), 'Flow_Aop_Proxy_buildMethodsAndAdvicesArray') && is_callable('parent::Flow_Aop_Proxy_buildMethodsAndAdvicesArray')) parent::Flow_Aop_Proxy_buildMethodsAndAdvicesArray();\n");
$proxyClass->getMethod('Flow_Aop_Proxy_buildMethodsAndAdvicesArray')->addPreParentCallCode($this->buildMethodsAndAdvicesArrayCode($interceptedMethods));
$proxyClass->getMethod('Flow_Aop_Proxy_buildMethodsAndAdvicesArray')->overrideMethodVisibility('protected');
$callBuildMethodsAndAdvicesArrayCode = "\n \$this->Flow_Aop_Proxy_buildMethodsAndAdvicesArray();\n";
$proxyClass->getConstructor()->addPreParentCallCode($callBuildMethodsAndAdvicesArrayCode);
$proxyClass->getMethod('__wakeup')->addPreParentCallCode($callBuildMethodsAndAdvicesArrayCode);
$proxyClass->getMethod('__clone')->addPreParentCallCode($callBuildMethodsAndAdvicesArrayCode);
if (!$this->reflectionService->hasMethod($targetClassName, '__wakeup')) {
$proxyClass->getMethod('__wakeup')->addPostParentCallCode(" if (method_exists(get_parent_class(), '__wakeup') && is_callable('parent::__wakeup')) parent::__wakeup();\n");
}
$proxyClass->addTraits(['\\' . AdvicesTrait::class]);
$this->buildMethodsInterceptorCode($targetClassName, $interceptedMethods);
$proxyClass->addProperty('Flow_Aop_Proxy_targetMethodsAndGroupedAdvices', 'array()');
$proxyClass->addProperty('Flow_Aop_Proxy_groupedAdviceChains', 'array()');
$proxyClass->addProperty('Flow_Aop_Proxy_methodIsInAdviceMode', 'array()');
return true;
} | php | public function buildProxyClass(string $targetClassName, array &$aspectContainers): bool
{
$interfaceIntroductions = $this->getMatchingInterfaceIntroductions($aspectContainers, $targetClassName);
$introducedInterfaces = $this->getInterfaceNamesFromIntroductions($interfaceIntroductions);
$introducedTraits = $this->getMatchingTraitNamesFromIntroductions($aspectContainers, $targetClassName);
$propertyIntroductions = $this->getMatchingPropertyIntroductions($aspectContainers, $targetClassName);
$methodsFromTargetClass = $this->getMethodsFromTargetClass($targetClassName);
$methodsFromIntroducedInterfaces = $this->getIntroducedMethodsFromInterfaceIntroductions($interfaceIntroductions);
$interceptedMethods = [];
$this->addAdvicedMethodsToInterceptedMethods($interceptedMethods, array_merge($methodsFromTargetClass, $methodsFromIntroducedInterfaces), $targetClassName, $aspectContainers);
$this->addIntroducedMethodsToInterceptedMethods($interceptedMethods, $methodsFromIntroducedInterfaces);
if (count($interceptedMethods) < 1 && count($introducedInterfaces) < 1 && count($introducedTraits) < 1 && count($propertyIntroductions) < 1) {
return false;
}
$proxyClass = $this->compiler->getProxyClass($targetClassName);
if ($proxyClass === false) {
return false;
}
$proxyClass->addInterfaces($introducedInterfaces);
$proxyClass->addTraits($introducedTraits);
/** @var $propertyIntroduction PropertyIntroduction */
foreach ($propertyIntroductions as $propertyIntroduction) {
$propertyName = $propertyIntroduction->getPropertyName();
$declaringAspectClassName = $propertyIntroduction->getDeclaringAspectClassName();
$possiblePropertyTypes = $this->reflectionService->getPropertyTagValues($declaringAspectClassName, $propertyName, 'var');
if (count($possiblePropertyTypes) > 0 && !$this->reflectionService->isPropertyAnnotatedWith($declaringAspectClassName, $propertyName, Flow\Transient::class)) {
$classSchema = $this->reflectionService->getClassSchema($targetClassName);
if ($classSchema !== null) {
$classSchema->addProperty($propertyName, $possiblePropertyTypes[0]);
}
}
$propertyReflection = new PropertyReflection($declaringAspectClassName, $propertyName);
$propertyReflection->setIsAopIntroduced(true);
$this->reflectionService->reflectClassProperty($targetClassName, $propertyReflection);
$proxyClass->addProperty($propertyName, var_export($propertyIntroduction->getInitialValue(), true), $propertyIntroduction->getPropertyVisibility(), $propertyIntroduction->getPropertyDocComment());
}
$proxyClass->getMethod('Flow_Aop_Proxy_buildMethodsAndAdvicesArray')->addPreParentCallCode(" if (method_exists(get_parent_class(), 'Flow_Aop_Proxy_buildMethodsAndAdvicesArray') && is_callable('parent::Flow_Aop_Proxy_buildMethodsAndAdvicesArray')) parent::Flow_Aop_Proxy_buildMethodsAndAdvicesArray();\n");
$proxyClass->getMethod('Flow_Aop_Proxy_buildMethodsAndAdvicesArray')->addPreParentCallCode($this->buildMethodsAndAdvicesArrayCode($interceptedMethods));
$proxyClass->getMethod('Flow_Aop_Proxy_buildMethodsAndAdvicesArray')->overrideMethodVisibility('protected');
$callBuildMethodsAndAdvicesArrayCode = "\n \$this->Flow_Aop_Proxy_buildMethodsAndAdvicesArray();\n";
$proxyClass->getConstructor()->addPreParentCallCode($callBuildMethodsAndAdvicesArrayCode);
$proxyClass->getMethod('__wakeup')->addPreParentCallCode($callBuildMethodsAndAdvicesArrayCode);
$proxyClass->getMethod('__clone')->addPreParentCallCode($callBuildMethodsAndAdvicesArrayCode);
if (!$this->reflectionService->hasMethod($targetClassName, '__wakeup')) {
$proxyClass->getMethod('__wakeup')->addPostParentCallCode(" if (method_exists(get_parent_class(), '__wakeup') && is_callable('parent::__wakeup')) parent::__wakeup();\n");
}
$proxyClass->addTraits(['\\' . AdvicesTrait::class]);
$this->buildMethodsInterceptorCode($targetClassName, $interceptedMethods);
$proxyClass->addProperty('Flow_Aop_Proxy_targetMethodsAndGroupedAdvices', 'array()');
$proxyClass->addProperty('Flow_Aop_Proxy_groupedAdviceChains', 'array()');
$proxyClass->addProperty('Flow_Aop_Proxy_methodIsInAdviceMode', 'array()');
return true;
} | [
"public",
"function",
"buildProxyClass",
"(",
"string",
"$",
"targetClassName",
",",
"array",
"&",
"$",
"aspectContainers",
")",
":",
"bool",
"{",
"$",
"interfaceIntroductions",
"=",
"$",
"this",
"->",
"getMatchingInterfaceIntroductions",
"(",
"$",
"aspectContainers... | Builds methods for a single AOP proxy class for the specified class.
@param string $targetClassName Name of the class to create a proxy class file for
@param array &$aspectContainers The array of aspect containers from the AOP Framework
@return boolean true if the proxy class could be built, false otherwise. | [
"Builds",
"methods",
"for",
"a",
"single",
"AOP",
"proxy",
"class",
"for",
"the",
"specified",
"class",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Aop/Builder/ProxyClassBuilder.php#L411-L478 |
neos/flow-development-collection | Neos.Flow/Classes/Aop/Builder/ProxyClassBuilder.php | ProxyClassBuilder.proxySubClassesOfClassToEnsureAdvices | protected function proxySubClassesOfClassToEnsureAdvices(string $className, ClassNameIndex $targetClassNameCandidates, ClassNameIndex $treatedSubClasses): ClassNameIndex
{
if ($this->reflectionService->isClassReflected($className) === false) {
return $treatedSubClasses;
}
if (trait_exists($className)) {
return $treatedSubClasses;
}
if (interface_exists($className)) {
return $treatedSubClasses;
}
$subClassNames = $this->reflectionService->getAllSubClassNamesForClass($className);
foreach ($subClassNames as $subClassName) {
if ($targetClassNameCandidates->hasClassName($subClassName)) {
continue;
}
$treatedSubClasses = $this->addBuildMethodsAndAdvicesCodeToClass($subClassName, $treatedSubClasses);
}
return $treatedSubClasses;
} | php | protected function proxySubClassesOfClassToEnsureAdvices(string $className, ClassNameIndex $targetClassNameCandidates, ClassNameIndex $treatedSubClasses): ClassNameIndex
{
if ($this->reflectionService->isClassReflected($className) === false) {
return $treatedSubClasses;
}
if (trait_exists($className)) {
return $treatedSubClasses;
}
if (interface_exists($className)) {
return $treatedSubClasses;
}
$subClassNames = $this->reflectionService->getAllSubClassNamesForClass($className);
foreach ($subClassNames as $subClassName) {
if ($targetClassNameCandidates->hasClassName($subClassName)) {
continue;
}
$treatedSubClasses = $this->addBuildMethodsAndAdvicesCodeToClass($subClassName, $treatedSubClasses);
}
return $treatedSubClasses;
} | [
"protected",
"function",
"proxySubClassesOfClassToEnsureAdvices",
"(",
"string",
"$",
"className",
",",
"ClassNameIndex",
"$",
"targetClassNameCandidates",
",",
"ClassNameIndex",
"$",
"treatedSubClasses",
")",
":",
"ClassNameIndex",
"{",
"if",
"(",
"$",
"this",
"->",
... | Makes sure that any sub classes of an adviced class also build the advices array on construction.
@param string $className The adviced class name
@param ClassNameIndex $targetClassNameCandidates target class names for advices
@param ClassNameIndex $treatedSubClasses Already treated (sub) classes to avoid duplication
@return ClassNameIndex The new collection of already treated classes | [
"Makes",
"sure",
"that",
"any",
"sub",
"classes",
"of",
"an",
"adviced",
"class",
"also",
"build",
"the",
"advices",
"array",
"on",
"construction",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Aop/Builder/ProxyClassBuilder.php#L488-L510 |
neos/flow-development-collection | Neos.Flow/Classes/Aop/Builder/ProxyClassBuilder.php | ProxyClassBuilder.addBuildMethodsAndAdvicesCodeToClass | protected function addBuildMethodsAndAdvicesCodeToClass(string $className, ClassNameIndex $treatedSubClasses): ClassNameIndex
{
if ($treatedSubClasses->hasClassName($className)) {
return $treatedSubClasses;
}
$treatedSubClasses = $treatedSubClasses->union(new ClassNameIndex([$className]));
if ($this->reflectionService->isClassReflected($className) === false) {
return $treatedSubClasses;
}
$proxyClass = $this->compiler->getProxyClass($className);
if ($proxyClass === false) {
return $treatedSubClasses;
}
$callBuildMethodsAndAdvicesArrayCode = " if (method_exists(get_parent_class(), 'Flow_Aop_Proxy_buildMethodsAndAdvicesArray') && is_callable('parent::Flow_Aop_Proxy_buildMethodsAndAdvicesArray')) parent::Flow_Aop_Proxy_buildMethodsAndAdvicesArray();\n";
$proxyClass->getConstructor()->addPreParentCallCode($callBuildMethodsAndAdvicesArrayCode);
$proxyClass->getMethod('__wakeup')->addPreParentCallCode($callBuildMethodsAndAdvicesArrayCode);
return $treatedSubClasses;
} | php | protected function addBuildMethodsAndAdvicesCodeToClass(string $className, ClassNameIndex $treatedSubClasses): ClassNameIndex
{
if ($treatedSubClasses->hasClassName($className)) {
return $treatedSubClasses;
}
$treatedSubClasses = $treatedSubClasses->union(new ClassNameIndex([$className]));
if ($this->reflectionService->isClassReflected($className) === false) {
return $treatedSubClasses;
}
$proxyClass = $this->compiler->getProxyClass($className);
if ($proxyClass === false) {
return $treatedSubClasses;
}
$callBuildMethodsAndAdvicesArrayCode = " if (method_exists(get_parent_class(), 'Flow_Aop_Proxy_buildMethodsAndAdvicesArray') && is_callable('parent::Flow_Aop_Proxy_buildMethodsAndAdvicesArray')) parent::Flow_Aop_Proxy_buildMethodsAndAdvicesArray();\n";
$proxyClass->getConstructor()->addPreParentCallCode($callBuildMethodsAndAdvicesArrayCode);
$proxyClass->getMethod('__wakeup')->addPreParentCallCode($callBuildMethodsAndAdvicesArrayCode);
return $treatedSubClasses;
} | [
"protected",
"function",
"addBuildMethodsAndAdvicesCodeToClass",
"(",
"string",
"$",
"className",
",",
"ClassNameIndex",
"$",
"treatedSubClasses",
")",
":",
"ClassNameIndex",
"{",
"if",
"(",
"$",
"treatedSubClasses",
"->",
"hasClassName",
"(",
"$",
"className",
")",
... | Adds code to build the methods and advices array in case the parent class has some.
@param string $className
@param ClassNameIndex $treatedSubClasses
@return ClassNameIndex | [
"Adds",
"code",
"to",
"build",
"the",
"methods",
"and",
"advices",
"array",
"in",
"case",
"the",
"parent",
"class",
"has",
"some",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Aop/Builder/ProxyClassBuilder.php#L519-L540 |
neos/flow-development-collection | Neos.Flow/Classes/Aop/Builder/ProxyClassBuilder.php | ProxyClassBuilder.getMethodsFromTargetClass | protected function getMethodsFromTargetClass(string $targetClassName): array
{
$methods = [];
$class = new \ReflectionClass($targetClassName);
foreach (['__construct', '__clone'] as $builtInMethodName) {
if (!$class->hasMethod($builtInMethodName)) {
$methods[] = [$targetClassName, $builtInMethodName];
}
}
foreach ($class->getMethods() as $method) {
$methods[] = [$targetClassName, $method->getName()];
}
return $methods;
} | php | protected function getMethodsFromTargetClass(string $targetClassName): array
{
$methods = [];
$class = new \ReflectionClass($targetClassName);
foreach (['__construct', '__clone'] as $builtInMethodName) {
if (!$class->hasMethod($builtInMethodName)) {
$methods[] = [$targetClassName, $builtInMethodName];
}
}
foreach ($class->getMethods() as $method) {
$methods[] = [$targetClassName, $method->getName()];
}
return $methods;
} | [
"protected",
"function",
"getMethodsFromTargetClass",
"(",
"string",
"$",
"targetClassName",
")",
":",
"array",
"{",
"$",
"methods",
"=",
"[",
"]",
";",
"$",
"class",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"targetClassName",
")",
";",
"foreach",
"(",... | Returns the methods of the target class.
@param string $targetClassName Name of the target class
@return array Method information with declaring class and method name pairs | [
"Returns",
"the",
"methods",
"of",
"the",
"target",
"class",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Aop/Builder/ProxyClassBuilder.php#L548-L564 |
neos/flow-development-collection | Neos.Flow/Classes/Aop/Builder/ProxyClassBuilder.php | ProxyClassBuilder.buildMethodsAndAdvicesArrayCode | protected function buildMethodsAndAdvicesArrayCode(array $methodsAndGroupedAdvices): string
{
if (count($methodsAndGroupedAdvices) < 1) {
return '';
}
$methodsAndAdvicesArrayCode = "\n \$objectManager = \\Neos\\Flow\\Core\\Bootstrap::\$staticObjectManager;\n";
$methodsAndAdvicesArrayCode .= " \$this->Flow_Aop_Proxy_targetMethodsAndGroupedAdvices = array(\n";
foreach ($methodsAndGroupedAdvices as $methodName => $advicesAndDeclaringClass) {
$methodsAndAdvicesArrayCode .= " '" . $methodName . "' => array(\n";
foreach ($advicesAndDeclaringClass['groupedAdvices'] as $adviceType => $adviceConfigurations) {
$methodsAndAdvicesArrayCode .= " '" . $adviceType . "' => array(\n";
foreach ($adviceConfigurations as $adviceConfiguration) {
$advice = $adviceConfiguration['advice'];
$methodsAndAdvicesArrayCode .= " new \\" . get_class($advice) . "('" . $advice->getAspectObjectName() . "', '" . $advice->getAdviceMethodName() . "', \$objectManager, " . $adviceConfiguration['runtimeEvaluationsClosureCode'] . "),\n";
}
$methodsAndAdvicesArrayCode .= " ),\n";
}
$methodsAndAdvicesArrayCode .= " ),\n";
}
$methodsAndAdvicesArrayCode .= " );\n";
return $methodsAndAdvicesArrayCode;
} | php | protected function buildMethodsAndAdvicesArrayCode(array $methodsAndGroupedAdvices): string
{
if (count($methodsAndGroupedAdvices) < 1) {
return '';
}
$methodsAndAdvicesArrayCode = "\n \$objectManager = \\Neos\\Flow\\Core\\Bootstrap::\$staticObjectManager;\n";
$methodsAndAdvicesArrayCode .= " \$this->Flow_Aop_Proxy_targetMethodsAndGroupedAdvices = array(\n";
foreach ($methodsAndGroupedAdvices as $methodName => $advicesAndDeclaringClass) {
$methodsAndAdvicesArrayCode .= " '" . $methodName . "' => array(\n";
foreach ($advicesAndDeclaringClass['groupedAdvices'] as $adviceType => $adviceConfigurations) {
$methodsAndAdvicesArrayCode .= " '" . $adviceType . "' => array(\n";
foreach ($adviceConfigurations as $adviceConfiguration) {
$advice = $adviceConfiguration['advice'];
$methodsAndAdvicesArrayCode .= " new \\" . get_class($advice) . "('" . $advice->getAspectObjectName() . "', '" . $advice->getAdviceMethodName() . "', \$objectManager, " . $adviceConfiguration['runtimeEvaluationsClosureCode'] . "),\n";
}
$methodsAndAdvicesArrayCode .= " ),\n";
}
$methodsAndAdvicesArrayCode .= " ),\n";
}
$methodsAndAdvicesArrayCode .= " );\n";
return $methodsAndAdvicesArrayCode;
} | [
"protected",
"function",
"buildMethodsAndAdvicesArrayCode",
"(",
"array",
"$",
"methodsAndGroupedAdvices",
")",
":",
"string",
"{",
"if",
"(",
"count",
"(",
"$",
"methodsAndGroupedAdvices",
")",
"<",
"1",
")",
"{",
"return",
"''",
";",
"}",
"$",
"methodsAndAdvic... | Creates code for an array of target methods and their advices.
Example:
$this->Flow_Aop_Proxy_targetMethodsAndGroupedAdvices = array(
'getSomeProperty' => array(
\Neos\Flow\Aop\Advice\AroundAdvice::class => array(
new \Neos\Flow\Aop\Advice\AroundAdvice(\Neos\Foo\SomeAspect::class, 'aroundAdvice', \Neos\Flow\Core\Bootstrap::$staticObjectManager, function() { ... }),
),
),
);
@param array $methodsAndGroupedAdvices An array of method names and grouped advice objects
@return string PHP code for the content of an array of target method names and advice objects
@see buildProxyClass() | [
"Creates",
"code",
"for",
"an",
"array",
"of",
"target",
"methods",
"and",
"their",
"advices",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Aop/Builder/ProxyClassBuilder.php#L584-L606 |
neos/flow-development-collection | Neos.Flow/Classes/Aop/Builder/ProxyClassBuilder.php | ProxyClassBuilder.buildMethodsInterceptorCode | protected function buildMethodsInterceptorCode(string $targetClassName, array $interceptedMethods): void
{
foreach ($interceptedMethods as $methodName => $methodMetaInformation) {
if (count($methodMetaInformation['groupedAdvices']) === 0) {
throw new Aop\Exception\VoidImplementationException(sprintf('Refuse to introduce method %s into target class %s because it has no implementation code. You might want to create an around advice which implements this method.', $methodName, $targetClassName), 1303224472);
}
$builderType = 'Adviced' . ($methodName === '__construct' ? 'Constructor' : 'Method');
$this->methodInterceptorBuilders[$builderType]->build($methodName, $interceptedMethods, $targetClassName);
}
} | php | protected function buildMethodsInterceptorCode(string $targetClassName, array $interceptedMethods): void
{
foreach ($interceptedMethods as $methodName => $methodMetaInformation) {
if (count($methodMetaInformation['groupedAdvices']) === 0) {
throw new Aop\Exception\VoidImplementationException(sprintf('Refuse to introduce method %s into target class %s because it has no implementation code. You might want to create an around advice which implements this method.', $methodName, $targetClassName), 1303224472);
}
$builderType = 'Adviced' . ($methodName === '__construct' ? 'Constructor' : 'Method');
$this->methodInterceptorBuilders[$builderType]->build($methodName, $interceptedMethods, $targetClassName);
}
} | [
"protected",
"function",
"buildMethodsInterceptorCode",
"(",
"string",
"$",
"targetClassName",
",",
"array",
"$",
"interceptedMethods",
")",
":",
"void",
"{",
"foreach",
"(",
"$",
"interceptedMethods",
"as",
"$",
"methodName",
"=>",
"$",
"methodMetaInformation",
")"... | Traverses all intercepted methods and their advices and builds PHP code to intercept
methods if necessary.
The generated code is added directly to the proxy class by calling the respective
methods of the Compiler API.
@param string $targetClassName The target class the pointcut should match with
@param array $interceptedMethods An array of method names which need to be intercepted
@return void
@throws Aop\Exception\VoidImplementationException | [
"Traverses",
"all",
"intercepted",
"methods",
"and",
"their",
"advices",
"and",
"builds",
"PHP",
"code",
"to",
"intercept",
"methods",
"if",
"necessary",
"."
] | train | https://github.com/neos/flow-development-collection/blob/a4484ef2a57e050dc9bd87c8481eeb250c7a36fa/Neos.Flow/Classes/Aop/Builder/ProxyClassBuilder.php#L620-L629 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.