Completed
Push — middleware-wip ( 1bbe3a...71b03c )
by Romain
02:47
created

PresetMiddlewares::getList()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/*
3
 * 2017 Romain CANON <[email protected]>
4
 *
5
 * This file is part of the TYPO3 FormZ project.
6
 * It is free software; you can redistribute it and/or modify it
7
 * under the terms of the GNU General Public License, either
8
 * version 3 of the License, or any later version.
9
 *
10
 * For the full copyright and license information, see:
11
 * http://www.gnu.org/licenses/gpl-3.0.html
12
 */
13
14
namespace Romm\Formz\Configuration\Form\Middleware;
15
16
use Romm\ConfigurationObject\Service\Items\DataPreProcessor\DataPreProcessor;
17
use Romm\ConfigurationObject\Service\Items\DataPreProcessor\DataPreProcessorInterface;
18
use Romm\ConfigurationObject\Traits\ConfigurationObject\MagicMethodsTrait;
19
use Romm\Formz\Middleware\MiddlewareInterface;
20
21
class PresetMiddlewares implements DataPreProcessorInterface
22
{
23
    use MagicMethodsTrait;
24
25
    /**
26
     * @var \Romm\Formz\Middleware\Item\FormInjection\FormInjectionMiddleware
27
     */
28
    protected $formInjection;
29
30
    /**
31
     * @var \Romm\Formz\Middleware\Item\FormValidation\FormValidationMiddleware
32
     */
33
    protected $formValidation;
34
35
    /**
36
     * @var \Romm\Formz\Middleware\Item\Persistence\PersistenceMiddleware
37
     */
38
    protected $persistence;
39
40
    /**
41
     * @todo
42
     *
43
     * @return MiddlewareInterface[]
44
     */
45
    public function getList()
46
    {
47
        return get_object_vars($this);
48
    }
49
50
    /**
51
     * @todo
52
     *
53
     * @param DataPreProcessor $processor
54
     */
55
    public static function dataPreProcessor(DataPreProcessor $processor)
56
    {
57
        $data = $processor->getData();
58
59
        foreach (array_keys(get_class_vars(self::class)) as $middleware) {
60
            if (false === isset($data[$middleware])) {
61
                $data[$middleware] = [];
62
            }
63
        }
64
65
        $processor->setData($data);
66
    }
67
}
68