TASK: Added code migration for Validation.yaml structure
This commit is contained in:
parent
9a055a2f77
commit
4534099d3a
4 changed files with 82 additions and 5 deletions
|
@ -1,16 +1,27 @@
|
|||
<?php
|
||||
namespace DigiComp\SettingValidator;
|
||||
|
||||
use Neos\Flow\Annotations as Flow;
|
||||
/*
|
||||
* This file is part of the DigiComp.SettingValidator package.
|
||||
*
|
||||
* (c) digital competence
|
||||
*
|
||||
* This package is Open Source Software. For the full copyright and license
|
||||
* information, please view the LICENSE file which was distributed with this
|
||||
* source code.
|
||||
*/
|
||||
|
||||
use Neos\Flow\Configuration\ConfigurationManager;
|
||||
use Neos\Flow\Core\Bootstrap;
|
||||
use Neos\Flow\Package\Package as BasePackage;
|
||||
|
||||
/**
|
||||
* @Flow\Scope("prototype")
|
||||
* Package base class of the DigiComp.SettingValidator package.
|
||||
*/
|
||||
class Package extends BasePackage
|
||||
{
|
||||
const CONFIGURATION_TYPE_VALIDATION = 'Validation';
|
||||
|
||||
/**
|
||||
* @param Bootstrap $bootstrap
|
||||
*/
|
||||
|
@ -23,7 +34,7 @@ class Package extends BasePackage
|
|||
function ($configurationManager) {
|
||||
/** @var ConfigurationManager $configurationManager */
|
||||
$configurationManager->registerConfigurationType(
|
||||
'Validation',
|
||||
static::CONFIGURATION_TYPE_VALIDATION,
|
||||
ConfigurationManager::CONFIGURATION_PROCESSING_TYPE_DEFAULT,
|
||||
true
|
||||
);
|
||||
|
|
|
@ -1,6 +1,16 @@
|
|||
<?php
|
||||
namespace DigiComp\SettingValidator\Validation\Validator;
|
||||
|
||||
/*
|
||||
* This file is part of the DigiComp.SettingValidator package.
|
||||
*
|
||||
* (c) digital competence
|
||||
*
|
||||
* This package is Open Source Software. For the full copyright and license
|
||||
* information, please view the LICENSE file which was distributed with this
|
||||
* source code.
|
||||
*/
|
||||
|
||||
use Neos\Flow\Annotations as Flow;
|
||||
use Neos\Flow\Configuration\ConfigurationManager;
|
||||
use Neos\Flow\Reflection\ReflectionService;
|
||||
|
|
55
Migrations/Code/Version20170603120900.php
Normal file
55
Migrations/Code/Version20170603120900.php
Normal file
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
namespace Neos\Flow\Core\Migrations;
|
||||
|
||||
/*
|
||||
* This file is part of the DigiComp.SettingValidator package.
|
||||
*
|
||||
* (c) digital competence
|
||||
*
|
||||
* This package is Open Source Software. For the full copyright and license
|
||||
* information, please view the LICENSE file which was distributed with this
|
||||
* source code.
|
||||
*/
|
||||
|
||||
use DigiComp\SettingValidator\Package;
|
||||
|
||||
/**
|
||||
* Restructures Validation.yamls to new format
|
||||
*/
|
||||
class Version20170603120900 extends AbstractMigration
|
||||
{
|
||||
public function getIdentifier()
|
||||
{
|
||||
return 'DigiComp.SettingValidator-20170603120900';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
$this->processConfiguration(Package::CONFIGURATION_TYPE_VALIDATION,
|
||||
function (&$configuration) {
|
||||
foreach ($configuration as $validatorName => &$validators) {
|
||||
$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 be migrated.');
|
||||
continue;
|
||||
}
|
||||
if (isset($validator['property'])) {
|
||||
$newConfiguration['properties'][$validator['property']][$validator['validator']]
|
||||
= $validator['options'];
|
||||
} else {
|
||||
$newConfiguration['self'][$validator['validator']] = $validator['options'];
|
||||
}
|
||||
}
|
||||
$validators = $newConfiguration;
|
||||
}
|
||||
},
|
||||
true
|
||||
);
|
||||
}
|
||||
}
|
|
@ -65,7 +65,8 @@
|
|||
"TYPO3.FluidAdaptor-20161130112935",
|
||||
"Neos.Media-20161219094126",
|
||||
"Neos.Flow-20170125103800",
|
||||
"Neos.Flow-20170127183102"
|
||||
"Neos.Flow-20170127183102",
|
||||
"DigiComp.SettingValidator-20170603120900"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue