TYPO3 CMS  TYPO3_8-7
BackendModuleController.php
Go to the documentation of this file.
1 <?php
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 
25 
37 {
45  public function index(ServerRequestInterface $request, ResponseInterface $response)
46  {
48  $enableFileService = GeneralUtility::makeInstance(EnableFileService::class);
50  $formProtection = FormProtectionFactory::get();
51 
52  if ($enableFileService->checkInstallToolEnableFile()) {
53  // Install tool is open and valid, redirect to it
54  $response = $response->withStatus(303)->withHeader('Location', 'install.php?install[context]=backend');
55  } elseif ($request->getMethod() === 'POST' && $request->getParsedBody()['action'] === 'enableInstallTool') {
56  // Request to open the install tool
57  $installToolEnableToken = $request->getParsedBody()['installToolEnableToken'];
58  if (!$formProtection->validateToken($installToolEnableToken, 'installTool')) {
59  throw new \RuntimeException('Given form token was not valid', 1369161225);
60  }
61  $enableFileService->createInstallToolEnableFile();
62  // Install tool is open and valid, redirect to it
63  $response = $response->withStatus(303)->withHeader('Location', 'install.php?install[context]=backend');
64  } else {
65  // Show the "create enable install tool" button
67  $view = GeneralUtility::makeInstance(StandaloneView::class);
68  $view->setTemplatePathAndFilename(
70  'EXT:install/Resources/Private/Templates/BackendModule/ShowEnableInstallToolButton.html'
71  )
72  );
73  $token = $formProtection->generateToken('installTool');
74  $view->assign('installToolEnableToken', $token);
76  $moduleTemplate = GeneralUtility::makeInstance(ModuleTemplate::class);
77  $moduleTemplate->setContent($view->render());
78  $response->getBody()->write($moduleTemplate->renderContent());
79  }
80  return $response;
81  }
82 }
static getFileAbsFileName($filename, $_=null, $_2=null)
static makeInstance($className,... $constructorArguments)
static get($classNameOrType='default',... $constructorArguments)