‪TYPO3CMS  ‪main
OrderedProviderList.php
Go to the documentation of this file.
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 
19 
24 
32 {
36  protected ‪$providerList = [];
37 
45  public function ‪compile(array $result): array
46  {
47  $orderingService = GeneralUtility::makeInstance(DependencyOrderingService::class);
48  $orderedDataProvider = $orderingService->orderByDependencies($this->providerList, 'before', 'depends');
49 
50  foreach ($orderedDataProvider as $providerClassName => $providerConfig) {
51  if (isset($providerConfig['disabled']) && $providerConfig['disabled'] === true) {
52  // Skip this data provider if disabled by configuration
53  continue;
54  }
55 
56  if (!class_exists($providerClassName)) {
57  throw new \InvalidArgumentException(
58  'Implementation class for data provider ' . $providerClassName . ' does not exist',
59  1685542507
60  );
61  }
62 
64  $provider = GeneralUtility::makeInstance($providerClassName);
65 
66  if (!$provider instanceof ‪FormDataProviderInterface) {
67  throw new \UnexpectedValueException(
68  'Data provider ' . $providerClassName . ' must implement FormDataProviderInterface',
69  1485299408
70  );
71  }
72 
73  $result = $provider->addData($result);
74  }
75 
76  return $result;
77  }
78 
92  public function ‪setProviderList(array $list)
93  {
94  $this->providerList = $list;
95  }
96 }
‪TYPO3\CMS\Backend\Form\FormDataGroup
Definition: FlexFormSegment.php:16
‪TYPO3\CMS\Backend\Form\FormDataGroup\OrderedProviderList\$providerList
‪FormDataProviderInterface[] $providerList
Definition: OrderedProviderList.php:35
‪TYPO3\CMS\Backend\Form\FormDataGroup\OrderedProviderList\compile
‪array compile(array $result)
Definition: OrderedProviderList.php:44
‪TYPO3\CMS\Backend\Form\FormDataGroup\OrderedProviderList
Definition: OrderedProviderList.php:32
‪TYPO3\CMS\Backend\Form\FormDataGroup\OrderedProviderList\setProviderList
‪setProviderList(array $list)
Definition: OrderedProviderList.php:91
‪TYPO3\CMS\Core\Service\DependencyOrderingService
Definition: DependencyOrderingService.php:32
‪TYPO3\CMS\Backend\Form\FormDataGroupInterface
Definition: FormDataGroupInterface.php:23
‪TYPO3\CMS\Backend\Form\FormDataProviderInterface
Definition: FormDataProviderInterface.php:23
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52