GracefulProcessorRunner::processData()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

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