Ejemplo n.º 1
0
 /**
  * @test
  */
 public function processUsesLocalLayoutIfSet()
 {
     $processorConfig = array('layout.' => array('label' => '<div class="local"><labelvalue /></div>'), 'recipientEmail' => '*****@*****.**', 'senderEmail' => '*****@*****.**');
     $typoScript = array('layout.' => array('label' => '<div class="global"><labelvalue /></div>'), '1' => 'foo', '1.' => $processorConfig);
     $subject = new PostProcessor($this->formProphecy->reveal(), $typoScript);
     $this->typoScriptFactoryProphecy->setLayoutHandler($processorConfig)->willReturn($this->typoScriptLayoutProphecy->reveal());
     $this->assertEquals('', $subject->process());
 }
Ejemplo n.º 2
0
 /**
  * The main method called by the controller
  *
  * Iterates over the configured post processors and calls them with their
  * own settings
  *
  * @return string HTML messages from the called processors
  */
 public function process()
 {
     $html = '';
     if (is_array($this->typoScript)) {
         $keys = \TYPO3\CMS\Core\TypoScript\TemplateService::sortedKeyList($this->typoScript);
         foreach ($keys as $key) {
             if (!(int) $key || strpos($key, '.') !== FALSE) {
                 continue;
             }
             $className = FALSE;
             $processorName = $this->typoScript[$key];
             $processorArguments = array();
             if (isset($this->typoScript[$key . '.'])) {
                 $processorArguments = $this->typoScript[$key . '.'];
             }
             if (isset($processorArguments['layout.'])) {
                 $layoutHandler = $this->typoscriptFactory->setLayoutHandler($processorArguments);
             } else {
                 $layoutHandler = $this->typoscriptFactory->setLayoutHandler($this->typoScript);
             }
             if (class_exists($processorName, TRUE)) {
                 $className = $processorName;
             } else {
                 $classNameExpanded = 'TYPO3\\CMS\\Form\\PostProcess\\' . ucfirst(strtolower($processorName)) . 'PostProcessor';
                 if (class_exists($classNameExpanded, TRUE)) {
                     $className = $classNameExpanded;
                 }
             }
             if ($className !== FALSE) {
                 $layout = $this->typoscriptFactory->getLayoutFromTypoScript($this->typoScript[$processorName . '.']);
                 $layoutHandler->setLayout($layout);
                 $processor = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance($className, $this->form, $processorArguments);
                 if ($processor instanceof PostProcessorInterface) {
                     $html .= $processor->process();
                 }
             }
         }
     }
     return $html;
 }