‪TYPO3CMS  10.4
ClassesConfiguration.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 {
28  private ‪$configuration;
29 
33  public function ‪__construct(array ‪$configuration)
34  {
35  $this->configuration = ‪$configuration;
36  }
37 
42  public function ‪hasClass(string $className): bool
43  {
44  return array_key_exists($className, $this->configuration);
45  }
46 
51  public function ‪getConfigurationFor(string $className): ?array
52  {
53  return $this->configuration[$className] ?? null;
54  }
55 
63  public function ‪getSubClasses(string $className): array
64  {
65  return $this->‪resolveSubClassesRecursive($className);
66  }
67 
73  private function ‪resolveSubClassesRecursive(string $className, array $subClasses = []): array
74  {
75  foreach ($this->configuration[$className]['subclasses'] ?? [] as $subclass) {
76  if (in_array($subclass, $subClasses, true)) {
77  continue;
78  }
79 
80  $subClasses[] = $subclass;
81  $subClasses = $this->‪resolveSubClassesRecursive($subclass, $subClasses);
82  }
83 
84  return $subClasses;
85  }
86 }
‪TYPO3\CMS\Extbase\Persistence\ClassesConfiguration\getConfigurationFor
‪array null getConfigurationFor(string $className)
Definition: ClassesConfiguration.php:50
‪TYPO3\CMS\Extbase\Persistence\ClassesConfiguration\getSubClasses
‪array getSubClasses(string $className)
Definition: ClassesConfiguration.php:62
‪TYPO3\CMS\Extbase\Persistence
Definition: ClassesConfiguration.php:18
‪TYPO3\CMS\Extbase\Persistence\ClassesConfiguration\$configuration
‪array $configuration
Definition: ClassesConfiguration.php:27
‪TYPO3\CMS\Extbase\Persistence\ClassesConfiguration\hasClass
‪bool hasClass(string $className)
Definition: ClassesConfiguration.php:41
‪TYPO3\CMS\Extbase\Persistence\ClassesConfiguration
Definition: ClassesConfiguration.php:24
‪TYPO3\CMS\Extbase\Persistence\ClassesConfiguration\__construct
‪__construct(array $configuration)
Definition: ClassesConfiguration.php:32
‪TYPO3\CMS\Extbase\Persistence\ClassesConfiguration\resolveSubClassesRecursive
‪array resolveSubClassesRecursive(string $className, array $subClasses=[])
Definition: ClassesConfiguration.php:72