[TASK] CGL fixes after upgrade to php-cs-fixer 1.4
[Packages/TYPO3.CMS.git] / typo3 / sysext / form / Classes / Domain / Configuration / ConfigurationService.php
1 <?php
2 declare(strict_types=1);
3 namespace TYPO3\CMS\Form\Domain\Configuration;
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 use TYPO3\CMS\Core\Utility\GeneralUtility;
19 use TYPO3\CMS\Extbase\Object\ObjectManager;
20 use TYPO3\CMS\Form\Domain\Configuration\Exception\PrototypeNotFoundException;
21 use TYPO3\CMS\Form\Mvc\Configuration\ConfigurationManagerInterface;
22
23 /**
24 * Helper for configuration settings
25 *
26 * Scope: frontend / backend
27 */
28 class ConfigurationService
29 {
30
31 /**
32 * @var array
33 */
34 protected $formSettings;
35
36 /**
37 * @internal
38 */
39 public function initializeObject()
40 {
41 $this->formSettings = GeneralUtility::makeInstance(ObjectManager::class)
42 ->get(ConfigurationManagerInterface::class)
43 ->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_YAML_SETTINGS, 'form');
44 }
45
46 /**
47 * Get the prototype configuration
48 *
49 * @param string $prototypeName name of the prototype to get the configuration for
50 * @return array the prototype configuration
51 * @throws PrototypeNotFoundException if prototype with the name $prototypeName was not found
52 * @api
53 */
54 public function getPrototypeConfiguration(string $prototypeName): array
55 {
56 if (!isset($this->formSettings['prototypes'][$prototypeName])) {
57 throw new PrototypeNotFoundException(sprintf('The Prototype "%s" was not found.', $prototypeName), 1475924277);
58 }
59 return $this->formSettings['prototypes'][$prototypeName];
60 }
61 }