2017-06-03 12:56:14 +02:00
|
|
|
<?php
|
2020-03-16 15:44:36 +01:00
|
|
|
|
2017-06-03 12:56:14 +02:00
|
|
|
namespace Neos\Flow\Core\Migrations;
|
|
|
|
|
|
|
|
use DigiComp\SettingValidator\Package;
|
|
|
|
|
|
|
|
/**
|
2020-05-14 14:43:25 +02:00
|
|
|
* Restructures all Validation.yaml to new format
|
2017-06-03 12:56:14 +02:00
|
|
|
*/
|
|
|
|
class Version20170603120900 extends AbstractMigration
|
|
|
|
{
|
2020-03-16 15:41:30 +01:00
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
2017-06-03 12:56:14 +02:00
|
|
|
public function getIdentifier()
|
|
|
|
{
|
|
|
|
return 'DigiComp.SettingValidator-20170603120900';
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function up()
|
|
|
|
{
|
2019-01-28 11:37:18 +01:00
|
|
|
$this->processConfiguration(
|
|
|
|
Package::CONFIGURATION_TYPE_VALIDATION,
|
2017-06-03 12:56:14 +02:00
|
|
|
function (&$configuration) {
|
|
|
|
foreach ($configuration as $validatorName => &$validators) {
|
2019-01-28 11:37:18 +01:00
|
|
|
// guard that protects configuration, which has already the new format:
|
|
|
|
if (isset($validators['properties']) || isset($validators['self'])) {
|
|
|
|
continue;
|
|
|
|
}
|
2017-06-03 12:56:14 +02:00
|
|
|
$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(
|
|
|
|
'The Validation.yaml files contained no validator or options for validation: ' .
|
|
|
|
'"' . $validatorName . '.' . $key . '". It was not migrated.'
|
|
|
|
);
|
2017-06-03 12:56:14 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (isset($validator['property'])) {
|
|
|
|
$newConfiguration['properties'][$validator['property']][$validator['validator']]
|
|
|
|
= $validator['options'];
|
|
|
|
} else {
|
|
|
|
$newConfiguration['self'][$validator['validator']] = $validator['options'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$validators = $newConfiguration;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
true
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|