60d92cd3c00cb92784d39a4476fe025c04f57d15
[Packages/TYPO3.CMS.git] / typo3 / sysext / form / Classes / Controller / WizardController.php
1 <?php
2 namespace TYPO3\CMS\Form\Controller;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
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.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use TYPO3\CMS\Core\Utility\GeneralUtility;
18
19 /**
20 * The form wizard controller
21 */
22 class WizardController
23 {
24 /**
25 * Dispatch on action
26 *
27 * Calls the requested action
28 *
29 * @return void
30 */
31 public function dispatch()
32 {
33 switch (GeneralUtility::_GP('action')) {
34 case 'save':
35 $this->saveAction();
36 break;
37 case 'load':
38 $this->loadAction();
39 break;
40 default:
41 $this->indexAction();
42 }
43 }
44
45 /**
46 * The index action
47 *
48 * The action which should be taken when the wizard is loaded
49 *
50 * @return void
51 */
52 protected function indexAction()
53 {
54 /** @var $view \TYPO3\CMS\Form\View\Wizard\WizardView */
55 $view = GeneralUtility::makeInstance(\TYPO3\CMS\Form\View\Wizard\WizardView::class, $this->getRepository());
56 $view->render();
57 }
58
59 /**
60 * The save action
61 *
62 * The action which should be taken when the form in the wizard is saved
63 *
64 * @return void
65 */
66 protected function saveAction()
67 {
68 /** @var $view \TYPO3\CMS\Form\View\Wizard\SaveWizardView */
69 $view = GeneralUtility::makeInstance(\TYPO3\CMS\Form\View\Wizard\SaveWizardView::class, $this->getRepository());
70 $view->render();
71 }
72
73 /**
74 * The load action
75 *
76 * The action which should be taken when the form in the wizard is loaded
77 *
78 * @return void
79 */
80 protected function loadAction()
81 {
82 /** @var $view \TYPO3\CMS\Form\View\Wizard\LoadWizardView */
83 $view = GeneralUtility::makeInstance(\TYPO3\CMS\Form\View\Wizard\LoadWizardView::class, $this->getRepository());
84 $view->render();
85 }
86
87 /**
88 * Gets the repository object.
89 *
90 * @return \TYPO3\CMS\Form\Domain\Repository\ContentRepository
91 */
92 protected function getRepository()
93 {
94 return GeneralUtility::makeInstance(\TYPO3\CMS\Form\Domain\Repository\ContentRepository::class);
95 }
96 }