DigiComp.SettingValidator/Migrations/Code/Version20170603120900.php

57 lines
1.9 KiB
PHP
Raw Normal View History

<?php
2022-05-02 09:56:09 +02:00
declare(strict_types=1);
namespace Neos\Flow\Core\Migrations;
/**
2020-05-14 14:43:25 +02:00
* Restructures all Validation.yaml to new format
*/
class Version20170603120900 extends AbstractMigration
{
2020-03-16 15:41:30 +01:00
/**
* @return string
*/
2020-07-22 17:22:46 +02:00
public function getIdentifier(): string
{
return 'DigiComp.SettingValidator-20170603120900';
}
2022-04-04 22:29:30 +02:00
/**
* @inheritDoc
*/
2020-07-22 17:22:46 +02:00
public function up(): void
{
$this->processConfiguration(
2020-07-22 17:22:46 +02:00
'Validation',
2021-09-23 09:52:07 +02:00
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' => []];
2020-05-14 14:43:25 +02:00
foreach ($validators as $key => $validator) {
2020-05-04 22:26:58 +02:00
if (!isset($validator['validator']) || !isset($validator['options'])) {
$this->showWarning(
2021-04-13 08:51:04 +02:00
'The Validation.yaml files contained no validator or options for validation: '
. '"' . $validatorName . '.' . $key . '". It was not migrated.'
2020-05-04 22:26:58 +02:00
);
continue;
}
if (isset($validator['property'])) {
2021-04-13 08:51:04 +02:00
$newConfiguration['properties'][$validator['property']][$validator['validator']] =
$validator['options'];
} else {
$newConfiguration['self'][$validator['validator']] = $validator['options'];
}
}
$validators = $newConfiguration;
}
},
true
);
}
}