Passed
Push — master ( 6c7aff...ce6d49 )
by
unknown
46:49 queued 20:16
created

FormYamlProvider   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
eloc 15
dl 0
loc 41
rs 10
c 1
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getLabel() 0 4 1
A __invoke() 0 4 1
A getConfiguration() 0 8 1
A getIdentifier() 0 3 1
A getLanguageService() 0 3 1
A __construct() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the TYPO3 CMS project.
7
 *
8
 * It is free software; you can redistribute it and/or modify it under
9
 * the terms of the GNU General Public License, either version 2
10
 * of the License, or any later version.
11
 *
12
 * For the full copyright and license information, please read the
13
 * LICENSE.txt file that was distributed with this source code.
14
 *
15
 * The TYPO3 project - inspiring people to share!
16
 */
17
18
namespace TYPO3\CMS\Form\ConfigurationModuleProvider;
19
20
use TYPO3\CMS\Core\Localization\LanguageService;
21
use TYPO3\CMS\Core\Utility\ArrayUtility;
22
use TYPO3\CMS\Form\Mvc\Configuration\ConfigurationManager;
23
use TYPO3\CMS\Form\Mvc\Configuration\ConfigurationManagerInterface;
24
use TYPO3\CMS\Lowlevel\ConfigurationModuleProvider\ProviderInterface;
25
26
class FormYamlProvider implements ProviderInterface
27
{
28
    protected string $identifier;
29
    protected ConfigurationManager $configurationManager;
30
31
    public function __construct(ConfigurationManager $configurationManager)
32
    {
33
        $this->configurationManager = $configurationManager;
34
    }
35
36
    public function __invoke(array $attributes): self
37
    {
38
        $this->identifier = $attributes['identifier'];
39
        return $this;
40
    }
41
42
    public function getIdentifier(): string
43
    {
44
        return $this->identifier;
45
    }
46
47
    public function getLabel(): string
48
    {
49
        return $this->getLanguageService()->sL(
50
            'LLL:EXT:form/Resources/Private/Language/locallang.xlf:form.configuration.module.provider'
51
        );
52
    }
53
54
    public function getConfiguration(): array
55
    {
56
        $configuration = $this->configurationManager->getConfiguration(
57
            ConfigurationManagerInterface::CONFIGURATION_TYPE_YAML_SETTINGS,
58
            'form'
59
        );
60
        ArrayUtility::naturalKeySortRecursive($configuration);
61
        return $configuration;
62
    }
63
64
    protected function getLanguageService(): LanguageService
65
    {
66
        return $GLOBALS['LANG'];
67
    }
68
}
69