07188b0d69120a1d680472a998d6bf7077043659
[Packages/TYPO3.CMS.git] / typo3 / sysext / form / Classes / Domain / Finishers / ConfirmationFinisher.php
1 <?php
2 declare(strict_types=1);
3 namespace TYPO3\CMS\Form\Domain\Finishers;
4
5 /*
6 * This file is part of the TYPO3 CMS project.
7 *
8 * It originated from the Neos.Form package (www.neos.io)
9 *
10 * It is free software; you can redistribute it and/or modify it under
11 * the terms of the GNU General Public License, either version 2
12 * of the License, or any later version.
13 *
14 * For the full copyright and license information, please read the
15 * LICENSE.txt file that was distributed with this source code.
16 *
17 * The TYPO3 project - inspiring people to share!
18 */
19
20 use TYPO3\CMS\Form\Domain\Finishers\Exception\FinisherException;
21
22 /**
23 * A simple finisher that outputs a given text
24 *
25 * Options:
26 *
27 * - message: A hard-coded message to be rendered
28 *
29 * Usage:
30 * //...
31 * $confirmationFinisher = $this->objectManager->get(ConfirmationFinisher::class);
32 * $confirmationFinisher->setOptions(
33 * [
34 * 'message' => 'foo',
35 * ]
36 * );
37 * $formDefinition->addFinisher($confirmationFinisher);
38 * // ...
39 *
40 * Scope: frontend
41 */
42 class ConfirmationFinisher extends AbstractFinisher
43 {
44
45 /**
46 * @var array
47 */
48 protected $defaultOptions = [
49 'message' => 'The form has been submitted.',
50 ];
51
52 /**
53 * Executes this finisher
54 * @see AbstractFinisher::execute()
55 *
56 * @throws FinisherException
57 */
58 protected function executeInternal()
59 {
60 $formRuntime = $this->finisherContext->getFormRuntime();
61 $message = $this->parseOption('message');
62 $formRuntime->getResponse()->setContent($message);
63 }
64 }