[TASK] Clean up install tool module 23/23823/3
authorHelmut Hummel <helmut.hummel@typo3.org>
Fri, 13 Sep 2013 21:21:00 +0000 (23:21 +0200)
committerHelmut Hummel <helmut.hummel@typo3.org>
Fri, 13 Sep 2013 21:52:58 +0000 (23:52 +0200)
Resolves: #51996
Releases: 6.2
Change-Id: I5afca17c80931f3f9946fa5f33dc29fd1f572644
Reviewed-on: https://review.typo3.org/23823
Reviewed-by: Helmut Hummel
Tested-by: Helmut Hummel
typo3/sysext/install/Classes/Controller/BackendModuleController.php

index 6b11382..5684c2d 100644 (file)
@@ -39,19 +39,35 @@ namespace TYPO3\CMS\Install\Controller;
 class BackendModuleController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController {
 
        /**
+        * @var \TYPO3\CMS\Install\Service\EnableFileService
+        * @inject
+        */
+       protected $enableFileService;
+
+       /**
+        * @var \TYPO3\CMS\Core\FormProtection\AbstractFormProtection
+        */
+       protected $formProtection;
+
+       /**
+        * Set formprotection property
+        */
+       public function initializeAction() {
+               $this->formProtection = \TYPO3\CMS\Core\FormProtection\FormProtectionFactory::get();
+       }
+
+       /**
         * Index action shows install tool / step installer or redirect to action to enable install tool
         *
         * @return void
         */
        public function indexAction() {
-               /** @var $enableFileService \TYPO3\CMS\Install\Service\EnableFileService */
-               $enableFileService = $this->objectManager->get('TYPO3\\CMS\\Install\\Service\\EnableFileService');
-               if ($enableFileService->checkInstallToolEnableFile()) {
+               if ($this->enableFileService->checkInstallToolEnableFile()) {
                        // Install Tool is already enabled
-                       $enableFileService->extendInstallToolEnableFileLifetime();
-                       \TYPO3\CMS\Core\Utility\HttpUtility::redirect('sysext/install/Start/Install.php?install[context]=backend');
+                       $this->enableFileService->extendInstallToolEnableFileLifetime();
+                       $this->redirect('sysext/install/Start/Install.php?install[context]=backend');
                } else {
-                       $this->redirect('showEnableInstallToolButton');
+                       $this->forward('showEnableInstallToolButton');
                }
        }
 
@@ -61,28 +77,31 @@ class BackendModuleController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionCo
         * @return void
         */
        public function showEnableInstallToolButtonAction() {
-               $formProtection = \TYPO3\CMS\Core\FormProtection\FormProtectionFactory::get();
-               $token = $formProtection->generateToken('installTool');
+               $token = $this->formProtection->generateToken('installTool');
                $this->view->assign('installToolEnableToken', $token);
        }
 
        /**
         * Enable the install tool
         *
+        * @param string $installToolEnableToken
         * @throws \RuntimeException
         */
-       public function enableInstallToolAction() {
-               $token = $GLOBALS['_POST']['tx_install_system_installinstall']['installToolEnableToken'];
-               if (\TYPO3\CMS\Core\FormProtection\FormProtectionFactory::get()->validateToken($token, 'installTool')) {
-                       $installToolService = $this->objectManager->get('TYPO3\\CMS\\Install\\Service\\EnableFileService');
-                       $installToolService->createInstallToolEnableFile();
-                       $this->redirect('index');
-               } else {
-                       throw new \RuntimeException(
-                               'Given form token was not valid',
-                               1369161225
-                       );
+       public function enableInstallToolAction($installToolEnableToken) {
+               if (!$this->formProtection->validateToken($installToolEnableToken, 'installTool')) {
+                       throw new \RuntimeException('Given form token was not valid', 1369161225);
                }
+               $this->enableFileService->createInstallToolEnableFile();
+               $this->forward('index');
+       }
+
+       /**
+        * Redirect to specified URI
+        *
+        * @param string $uri
+        */
+       protected function redirect($uri) {
+               \TYPO3\CMS\Core\Utility\HttpUtility::redirect($uri);
        }
 }