TYPO3 CMS  TYPO3_8-7
ConfirmationFinisher.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types = 1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
22 
44 {
45 
49  protected $defaultOptions = [
50  'message' => 'The form has been submitted.',
51  ];
52 
59  protected function executeInternal()
60  {
61  $message = $this->parseOption('message');
62 
63  $standaloneView = $this->initializeStandaloneView(
64  $this->finisherContext->getFormRuntime()
65  );
66 
67  $standaloneView->assign('message', $message);
68 
69  return $standaloneView->render();
70  }
71 
78  protected function initializeStandaloneView(FormRuntime $formRuntime): StandaloneView
79  {
80  $standaloneView = $this->objectManager->get(StandaloneView::class);
81 
82  if (!isset($this->options['templateName'])) {
83  throw new FinisherException('The option "templateName" must be set for the ConfirmationFinisher.', 1521573955);
84  }
85 
86  $standaloneView->setTemplate($this->options['templateName']);
87  $standaloneView->getTemplatePaths()->fillFromConfigurationArray($this->options);
88 
89  if (isset($this->options['variables']) && is_array($this->options['variables'])) {
90  $standaloneView->assignMultiple($this->options['variables']);
91  }
92 
93  $standaloneView->assign('form', $formRuntime);
94  $standaloneView->assign('finisherVariableProvider', $this->finisherContext->getFinisherVariableProvider());
95 
96  $standaloneView->getRenderingContext()
97  ->getViewHelperVariableContainer()
98  ->addOrUpdate(RenderRenderableViewHelper::class, 'formRuntime', $formRuntime);
99 
100  return $standaloneView;
101  }
102 }