DigiComp.SettingValidator/Migrations/Code/Version20170603120900.php
Robin Krahnen 0ad084f734
All checks were successful
ci/woodpecker/push/code-style Pipeline was successful
ci/woodpecker/push/test Pipeline was successful
add "declare(strict_types=1);"
2022-05-02 09:56:09 +02:00

56 lines
1.9 KiB
PHP

<?php
declare(strict_types=1);
namespace Neos\Flow\Core\Migrations;
/**
* Restructures all Validation.yaml to new format
*/
class Version20170603120900 extends AbstractMigration
{
/**
* @return string
*/
public function getIdentifier(): string
{
return 'DigiComp.SettingValidator-20170603120900';
}
/**
* @inheritDoc
*/
public function up(): void
{
$this->processConfiguration(
'Validation',
function (array &$configuration): void {
foreach ($configuration as $validatorName => &$validators) {
// guard that protects configuration, which has already the new format:
if (isset($validators['properties']) || isset($validators['self'])) {
continue;
}
$newConfiguration = ['properties' => [], 'self' => []];
foreach ($validators as $key => $validator) {
if (!isset($validator['validator']) || !isset($validator['options'])) {
$this->showWarning(
'The Validation.yaml files contained no validator or options for validation: '
. '"' . $validatorName . '.' . $key . '". It was not migrated.'
);
continue;
}
if (isset($validator['property'])) {
$newConfiguration['properties'][$validator['property']][$validator['validator']] =
$validator['options'];
} else {
$newConfiguration['self'][$validator['validator']] = $validator['options'];
}
}
$validators = $newConfiguration;
}
},
true
);
}
}