Passed
Push — master ( 9fba3d...a339bf )
by Romain
03:49
created

GracefulProcessorRunner   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 21
rs 10
c 0
b 0
f 0
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A processData() 0 13 4
1
<?php
2
3
/*
4
 * Copyright (C) 2018
5
 * Nathan Boiron <[email protected]>
6
 * Romain Canon <[email protected]>
7
 *
8
 * This file is part of the TYPO3 NotiZ project.
9
 * It is free software; you can redistribute it and/or modify it
10
 * under the terms of the GNU General Public License, either
11
 * version 3 of the License, or any later version.
12
 *
13
 * For the full copyright and license information, see:
14
 * http://www.gnu.org/licenses/gpl-3.0.html
15
 */
16
17
namespace CuyZ\Notiz\Core\Notification\TCA\Processor;
18
19
use CuyZ\Notiz\Core\Notification\TCA\EntityTcaWriter;
20
use TYPO3\CMS\Core\Database\TableConfigurationPostProcessingHookInterface;
21
use TYPO3\CMS\Core\SingletonInterface;
22
use TYPO3\CMS\Core\Utility\GeneralUtility;
23
24
class GracefulProcessorRunner implements SingletonInterface, TableConfigurationPostProcessingHookInterface
25
{
26
    /**
27
     * This method runs just after the TCA was registered.
28
     *
29
     * It instantiates and runs a list of "graceful processors" that modify some
30
     * TCA that requires more complex logic (which can fail for any reason).
31
     */
32
    public function processData()
33
    {
34
        foreach ($GLOBALS['TCA'] as $tableName => $configuration) {
35
            // @PHP7
36
            if (!isset($configuration['ctrl'][EntityTcaWriter::NOTIFICATION_ENTITY]['processor'])) {
37
                continue;
38
            }
39
40
            foreach ($configuration['ctrl'][EntityTcaWriter::NOTIFICATION_ENTITY]['processor'] as $processorClassName) {
41
                /** @var GracefulProcessor $processor */
42
                $processor = GeneralUtility::makeInstance($processorClassName);
43
44
                $processor->process($tableName);
45
            }
46
        }
47
    }
48
}
49