2 namespace TYPO3\CMS\Form\PostProcess
;
5 * This file is part of the TYPO3 CMS project.
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.
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
14 * The TYPO3 project - inspiring people to share!
17 use TYPO3\CMS\Core\Utility\GeneralUtility
;
18 use TYPO3\CMS\Form\ObjectFactory
;
26 * @var \TYPO3\CMS\Form\View\Form\FormView
31 * @var \TYPO3\CMS\Form\Domain\Factory\TypoScriptFactory
33 protected $typoscriptFactory;
38 * @param \TYPO3\CMS\Form\Domain\Model\Form $form Form domain model
39 * @param array $typoScript Post processor TypoScript settings
41 public function __construct(\TYPO3\CMS\Form\Domain\Model\Form
$form, array $typoScript) {
43 $this->typoscriptFactory
= GeneralUtility
::makeInstance(\TYPO3\CMS\Form\Domain\Factory\TypoScriptFactory
::class);
44 $this->typoScript
= $typoScript;
48 * The main method called by the controller
50 * Iterates over the configured post processors and calls them with their
53 * @return string HTML messages from the called processors
55 public function process() {
57 if (is_array($this->typoScript
)) {
58 $keys = \TYPO3\CMS\Core\TypoScript\TemplateService
::sortedKeyList($this->typoScript
);
60 foreach ($keys as $key) {
61 if (!(int)$key ||
strpos($key, '.') !== FALSE) {
65 $processorName = $this->typoScript
[$key];
66 $processorArguments = array();
67 if (isset($this->typoScript
[$key . '.'])) {
68 $processorArguments = $this->typoScript
[$key . '.'];
71 if (isset($processorArguments['layout.'])) {
72 $layoutHandler = $this->typoscriptFactory
->setLayoutHandler($processorArguments);
74 $layoutHandler = $this->typoscriptFactory
->setLayoutHandler($this->typoScript
);
77 if (class_exists($processorName, TRUE)) {
78 $className = $processorName;
80 $classNameExpanded = 'TYPO3\\CMS\\Form\\PostProcess\\' . ucfirst(strtolower($processorName)) . 'PostProcessor';
81 if (class_exists($classNameExpanded, TRUE)) {
82 $className = $classNameExpanded;
85 if ($className !== FALSE) {
86 $layout = $this->typoscriptFactory
->getLayoutFromTypoScript($this->typoScript
[$processorName . '.']);
87 $layoutHandler->setLayout($layout);
89 $processor = ObjectFactory
::createFormObject($className, $this->form
, $processorArguments);
90 if ($processor instanceof PostProcessorInterface
) {
91 $html .= $processor->process();