‪TYPO3CMS  ‪main
AbstractFieldGenerator.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 
22 
29 {
33  protected ‪$kauderwelschService;
34 
38  protected ‪$matchArray = [];
39 
43  public function ‪__construct()
44  {
45  $this->kauderwelschService = GeneralUtility::makeInstance(KauderwelschService::class);
46  }
47 
55  public function ‪match(array $data): bool
56  {
57  return $this->‪checkMatchArray($data, $this->matchArray);
58  }
59 
67  protected function ‪checkMatchArray(array $data, array ‪$matchArray): bool
68  {
69  $result = true;
70  foreach (‪$matchArray as $name => $value) {
71  if (isset($data[$name])) {
72  if (is_array($value)) {
73  $result = $this->‪checkMatchArray($data[$name], $value);
74  if ($result === false) {
75  return false;
76  }
77  } elseif ($data[$name] === $value) {
78  $result = (bool)($result & true);
79  } else {
80  return false;
81  }
82  } else {
83  return false;
84  }
85  }
86  return $result;
87  }
88 }
‪TYPO3\CMS\Styleguide\TcaDataGenerator\FieldGenerator\AbstractFieldGenerator\$matchArray
‪array $matchArray
Definition: AbstractFieldGenerator.php:36
‪TYPO3\CMS\Styleguide\TcaDataGenerator\FieldGenerator\AbstractFieldGenerator\__construct
‪__construct()
Definition: AbstractFieldGenerator.php:41
‪TYPO3\CMS\Styleguide\Service\KauderwelschService
Definition: KauderwelschService.php:26
‪TYPO3\CMS\Styleguide\TcaDataGenerator\FieldGenerator\AbstractFieldGenerator
Definition: AbstractFieldGenerator.php:29
‪TYPO3\CMS\Styleguide\TcaDataGenerator\FieldGenerator\AbstractFieldGenerator\checkMatchArray
‪bool checkMatchArray(array $data, array $matchArray)
Definition: AbstractFieldGenerator.php:65
‪TYPO3\CMS\Styleguide\TcaDataGenerator\FieldGenerator
Definition: AbstractFieldGenerator.php:18
‪TYPO3\CMS\Styleguide\TcaDataGenerator\FieldGenerator\AbstractFieldGenerator\$kauderwelschService
‪KauderwelschService $kauderwelschService
Definition: AbstractFieldGenerator.php:32
‪TYPO3\CMS\Styleguide\TcaDataGenerator\FieldGenerator\AbstractFieldGenerator\match
‪bool match(array $data)
Definition: AbstractFieldGenerator.php:53
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52