TYPO3 CMS  TYPO3_7-6
ContentDataProcessor.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
19 
24 {
34  public function process(ContentObjectRenderer $cObject, array $configuration, array $variables)
35  {
36  if (
37  !empty($configuration['dataProcessing.'])
38  && is_array($configuration['dataProcessing.'])
39  ) {
40  $processors = $configuration['dataProcessing.'];
41  $processorKeys = TemplateService::sortedKeyList($processors);
42 
43  foreach ($processorKeys as $key) {
44  $className = $processors[$key];
45  if (!class_exists($className)) {
46  throw new \UnexpectedValueException('Processor class name "' . $className . '" does not exist!', 1427455378);
47  }
48 
49  if (!in_array(DataProcessorInterface::class, class_implements($className), true)) {
50  throw new \UnexpectedValueException(
51  'Processor with class name "' . $className . '" ' .
52  'must implement interface "' . DataProcessorInterface::class . '"',
53  1427455377
54  );
55  }
56 
57  $processorConfiguration = isset($processors[$key . '.']) ? $processors[$key . '.'] : [];
58 
59  $variables = GeneralUtility::makeInstance($className)->process(
60  $cObject,
61  $configuration,
62  $processorConfiguration,
63  $variables
64  );
65  }
66  }
67 
68  return $variables;
69  }
70 }
static sortedKeyList($setupArr, $acceptOnlyProperties=false)
process(ContentObjectRenderer $cObject, array $configuration, array $variables)