TYPO3 CMS  TYPO3_6-2
PostProcessor.php
Go to the documentation of this file.
1 <?php
3 
23 
27  protected $form;
28 
32  protected $typoscriptFactory;
33 
40  public function __construct(\TYPO3\CMS\Form\Domain\Model\Form $form, array $typoScript) {
41  $this->form = $form;
42  $this->typoscriptFactory = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Form\\Domain\\Factory\\TypoScriptFactory');
43  $this->typoScript = $typoScript;
44  }
45 
54  public function process() {
55  $html = '';
56  if (is_array($this->typoScript)) {
58 
59  foreach ($keys as $key) {
60  if (!(int)$key || strpos($key, '.') !== FALSE) {
61  continue;
62  }
63  $className = FALSE;
64  $processorName = $this->typoScript[$key];
65  $processorArguments = array();
66  if (isset($this->typoScript[$key . '.'])) {
67  $processorArguments = $this->typoScript[$key . '.'];
68  }
69 
70  if (isset($processorArguments['layout.'])) {
71  $layoutHandler = $this->typoscriptFactory->setLayoutHandler($processorArguments);
72  } else {
73  $layoutHandler = $this->typoscriptFactory->setLayoutHandler($this->typoScript);
74  }
75 
76  if (class_exists($processorName, TRUE)) {
77  $className = $processorName;
78  } else {
79  $classNameExpanded = 'TYPO3\\CMS\\Form\\PostProcess\\' . ucfirst(strtolower($processorName)) . 'PostProcessor';
80  if (class_exists($classNameExpanded, TRUE)) {
81  $className = $classNameExpanded;
82  }
83  }
84  if ($className !== FALSE) {
85  $layout = $this->typoscriptFactory->getLayoutFromTypoScript($this->typoScript[$processorName . '.']);
86  $layoutHandler->setLayout($layout);
87 
88  $processor = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance($className, $this->form, $processorArguments);
89  if ($processor instanceof PostProcessorInterface) {
90  $html .= $processor->process();
91  }
92  }
93  }
94  }
95  return $html;
96  }
97 
105  public function sortTypoScriptKeyList() {
106  return \TYPO3\CMS\Core\TypoScript\TemplateService::sortedKeyList($this->typoScript);
107  }
108 
109 }
$typoscriptFactory
__construct(\TYPO3\CMS\Form\Domain\Model\Form $form, array $typoScript)
sortTypoScriptKeyList()
$form
process()
static sortedKeyList($setupArr, $acceptOnlyProperties=FALSE)