[BUGFIX] ext:install Better error handling in first folder step
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / Classes / Controller / BackendModuleController.php
1 <?php
2 namespace TYPO3\CMS\Install\Controller;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2013 Christian Kuhn <lolli@schwarzbu.ch>
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 * A copy is found in the textfile GPL.txt and important notices to the license
19 * from the author is found in LICENSE.txt distributed with these scripts.
20 *
21 *
22 * This script is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * This copyright notice MUST APPEAR in all copies of the script!
28 ***************************************************************/
29
30 /**
31 * Backend module controller
32 *
33 * Embeds in backend an only shows the 'enable install tool button' or redirects
34 * to step installer if install tool is enabled.
35 *
36 * This is a classic extbase module that does not interfere with the other code
37 * within the install tool.
38 */
39 class BackendModuleController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController {
40
41 /**
42 * @var \TYPO3\CMS\Install\Service\EnableFileService
43 * @inject
44 */
45 protected $enableFileService;
46
47 /**
48 * @var \TYPO3\CMS\Core\FormProtection\AbstractFormProtection
49 */
50 protected $formProtection;
51
52 /**
53 * Set formprotection property
54 */
55 public function initializeAction() {
56 $this->formProtection = \TYPO3\CMS\Core\FormProtection\FormProtectionFactory::get();
57 }
58
59 /**
60 * Index action shows install tool / step installer or redirect to action to enable install tool
61 *
62 * @return void
63 */
64 public function indexAction() {
65 if ($this->enableFileService->checkInstallToolEnableFile()) {
66 // Install Tool is already enabled
67 $this->enableFileService->extendInstallToolEnableFileLifetime();
68 $this->redirect('sysext/install/Start/Install.php?install[context]=backend');
69 } else {
70 $this->forward('showEnableInstallToolButton');
71 }
72 }
73
74 /**
75 * Show enable install tool
76 *
77 * @return void
78 */
79 public function showEnableInstallToolButtonAction() {
80 $token = $this->formProtection->generateToken('installTool');
81 $this->view->assign('installToolEnableToken', $token);
82 }
83
84 /**
85 * Enable the install tool
86 *
87 * @param string $installToolEnableToken
88 * @throws \RuntimeException
89 */
90 public function enableInstallToolAction($installToolEnableToken) {
91 if (!$this->formProtection->validateToken($installToolEnableToken, 'installTool')) {
92 throw new \RuntimeException('Given form token was not valid', 1369161225);
93 }
94 $this->enableFileService->createInstallToolEnableFile();
95 $this->forward('index');
96 }
97
98 /**
99 * Redirect to specified URI
100 *
101 * @param string $uri
102 */
103 protected function redirect($uri) {
104 \TYPO3\CMS\Core\Utility\HttpUtility::redirect($uri);
105 }
106 }
107
108 ?>