[TASK] Re-work/simplify copyright header in PHP files - Part 2
[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 * @inject
31 */
32 protected $enableFileService;
33
34 /**
35 * @var \TYPO3\CMS\Core\FormProtection\AbstractFormProtection
36 */
37 protected $formProtection;
38
39 /**
40 * Set formprotection property
41 */
42 public function initializeAction() {
43 $this->formProtection = \TYPO3\CMS\Core\FormProtection\FormProtectionFactory::get();
44 }
45
46 /**
47 * Index action shows install tool / step installer or redirect to action to enable install tool
48 *
49 * @return void
50 */
51 public function indexAction() {
52 if ($this->enableFileService->checkInstallToolEnableFile()) {
53 $this->redirect('sysext/install/Start/Install.php?install[context]=backend');
54 } else {
55 $this->forward('showEnableInstallToolButton');
56 }
57 }
58
59 /**
60 * Show enable install tool
61 *
62 * @return void
63 */
64 public function showEnableInstallToolButtonAction() {
65 $token = $this->formProtection->generateToken('installTool');
66 $this->view->assign('installToolEnableToken', $token);
67 }
68
69 /**
70 * Enable the install tool
71 *
72 * @param string $installToolEnableToken
73 * @throws \RuntimeException
74 */
75 public function enableInstallToolAction($installToolEnableToken) {
76 if (!$this->formProtection->validateToken($installToolEnableToken, 'installTool')) {
77 throw new \RuntimeException('Given form token was not valid', 1369161225);
78 }
79 $this->enableFileService->createInstallToolEnableFile();
80 $this->forward('index');
81 }
82
83 /**
84 * Redirect to specified URI
85 *
86 * @param string $uri
87 */
88 protected function redirect($uri) {
89 \TYPO3\CMS\Core\Utility\HttpUtility::redirect($uri);
90 }
91 }