[BUGFIX] Wrong overloading of AbstractController::redirect()
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / Classes / Controller / BackendModuleController.php
1 <?php
2 namespace TYPO3\CMS\Install\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 /**
18 * Backend module controller
19 *
20 * Embeds in backend an only shows the 'enable install tool button' or redirects
21 * to step installer if install tool is enabled.
22 *
23 * This is a classic extbase module that does not interfere with the other code
24 * within the install tool.
25 */
26 class BackendModuleController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController
27 {
28 /**
29 * @var \TYPO3\CMS\Install\Service\EnableFileService
30 */
31 protected $enableFileService;
32
33 /**
34 * @var \TYPO3\CMS\Core\FormProtection\AbstractFormProtection
35 */
36 protected $formProtection;
37
38 /**
39 * @param \TYPO3\CMS\Install\Service\EnableFileService $enableFileService
40 */
41 public function injectEnableFileService(\TYPO3\CMS\Install\Service\EnableFileService $enableFileService)
42 {
43 $this->enableFileService = $enableFileService;
44 }
45
46 /**
47 * Set formprotection property
48 */
49 public function initializeAction()
50 {
51 $this->formProtection = \TYPO3\CMS\Core\FormProtection\FormProtectionFactory::get();
52 }
53
54 /**
55 * Index action shows install tool / step installer or redirect to action to enable install tool
56 *
57 * @return void
58 */
59 public function indexAction()
60 {
61 if ($this->enableFileService->checkInstallToolEnableFile()) {
62 \TYPO3\CMS\Core\Utility\HttpUtility::redirect('sysext/install/Start/Install.php?install[context]=backend');
63 } else {
64 $this->forward('showEnableInstallToolButton');
65 }
66 }
67
68 /**
69 * Show enable install tool
70 *
71 * @return void
72 */
73 public function showEnableInstallToolButtonAction()
74 {
75 $token = $this->formProtection->generateToken('installTool');
76 $this->view->assign('installToolEnableToken', $token);
77 }
78
79 /**
80 * Enable the install tool
81 *
82 * @param string $installToolEnableToken
83 * @throws \RuntimeException
84 */
85 public function enableInstallToolAction($installToolEnableToken)
86 {
87 if (!$this->formProtection->validateToken($installToolEnableToken, 'installTool')) {
88 throw new \RuntimeException('Given form token was not valid', 1369161225);
89 }
90 $this->enableFileService->createInstallToolEnableFile();
91 $this->forward('index');
92 }
93
94 /**
95 * Redirect to specified URI
96 *
97 * @param string $uri
98 * @todo: deprecate this method in CMS8, it overload the method of AbstractController in wrong way.
99 * @todo: to late to deprecate in CMS7
100 */
101 protected function redirect($uri)
102 {
103 \TYPO3\CMS\Core\Utility\HttpUtility::redirect($uri);
104 }
105 }