TYPO3  7.6
PostProcessor.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Form\PostProcess;
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 
18 
23 {
27  protected $objectManager;
28 
33 
37  protected $form;
38 
43  public function injectObjectManager(\TYPO3\CMS\Extbase\Object\ObjectManager $objectManager)
44  {
45  $this->objectManager = $objectManager;
46  }
47 
54  public function __construct(\TYPO3\CMS\Form\Domain\Model\Element $form, array $postProcessorTypoScript)
55  {
56  $this->form = $form;
57  $this->postProcessorTypoScript = $postProcessorTypoScript;
58  }
59 
68  public function process()
69  {
70  $html = '';
71 
72  if (is_array($this->postProcessorTypoScript)) {
73  $keys = TemplateService::sortedKeyList($this->postProcessorTypoScript);
74 
75  foreach ($keys as $key) {
76  if (!(int)$key || strpos($key, '.') !== false) {
77  continue;
78  }
79  $className = false;
80  $processorName = $this->postProcessorTypoScript[$key];
81  $processorArguments = array();
82  if (isset($this->postProcessorTypoScript[$key . '.'])) {
83  $processorArguments = $this->postProcessorTypoScript[$key . '.'];
84  }
85 
86  if (class_exists($processorName, true)) {
87  $className = $processorName;
88  } else {
89  $classNameExpanded = 'TYPO3\\CMS\\Form\\PostProcess\\' . ucfirst(strtolower($processorName)) . 'PostProcessor';
90  if (class_exists($classNameExpanded, true)) {
91  $className = $classNameExpanded;
92  }
93  }
94  if ($className !== false) {
95  $processor = $this->objectManager->get($className, $this->form, $processorArguments);
96  if ($processor instanceof PostProcessorInterface) {
97  $processor->setControllerContext($this->controllerContext);
98  $html .= $processor->process();
99  }
100  }
101  }
102  }
103 
104  return $html;
105  }
106 }