‪TYPO3CMS  10.4
ValueFromReferenceArrayProcessor.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
24 {
30  public function ‪canProcess(string $placeholder, array $referenceArray): bool
31  {
32  return strpos($placeholder, '(') === false;
33  }
34 
43  public function ‪process(string $value, array $referenceArray)
44  {
45  $parts = explode('.', $value);
46  $referenceData = $referenceArray;
47  foreach ($parts as $part) {
48  if (isset($referenceData[$part])) {
49  $referenceData = $referenceData[$part];
50  } else {
51  // return unsubstituted placeholder
52  throw new \UnexpectedValueException('Value not found', 1581501216);
53  }
54  }
55  return $referenceData;
56  }
57 }
‪TYPO3\CMS\Core\Configuration\Processor\Placeholder\ValueFromReferenceArrayProcessor
Definition: ValueFromReferenceArrayProcessor.php:24
‪TYPO3\CMS\Core\Configuration\Processor\Placeholder
Definition: EnvVariableProcessor.php:16
‪TYPO3\CMS\Core\Configuration\Processor\Placeholder\PlaceholderProcessorInterface
Definition: PlaceholderProcessorInterface.php:19
‪TYPO3\CMS\Core\Configuration\Processor\Placeholder\ValueFromReferenceArrayProcessor\canProcess
‪bool canProcess(string $placeholder, array $referenceArray)
Definition: ValueFromReferenceArrayProcessor.php:30
‪TYPO3\CMS\Core\Configuration\Processor\Placeholder\ValueFromReferenceArrayProcessor\process
‪array mixed string process(string $value, array $referenceArray)
Definition: ValueFromReferenceArrayProcessor.php:43