TYPO3 CMS  TYPO3_8-7
AbstractAction.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 
19 
23 abstract class AbstractAction implements ActionInterface
24 {
28  protected $view = null;
29 
33  protected $controller = '';
34 
38  protected $action = '';
39 
43  protected $token = '';
44 
48  protected $postValues = [];
49 
53  protected $lastError = [];
54 
58  protected $messages = [];
59 
65  public function handle()
66  {
67  $this->initializeHandle();
68  return $this->executeAction();
69  }
70 
74  protected function initializeHandle()
75  {
76  // Context service distinguishes between standalone and backend context
77  $contextService = GeneralUtility::makeInstance(\TYPO3\CMS\Install\Service\ContextService::class);
78 
79  $viewRootPath = GeneralUtility::getFileAbsFileName('EXT:install/Resources/Private/');
80  $controllerActionDirectoryName = ucfirst($this->controller);
81  $mainTemplate = ucfirst($this->action);
82  $this->view = GeneralUtility::makeInstance(StandaloneView::class);
83  $this->view->getRequest()->setControllerExtensionName('Install');
84  $this->view->setTemplatePathAndFilename($viewRootPath . 'Templates/Action/' . $controllerActionDirectoryName . '/' . $mainTemplate . '.html');
85  $this->view->setLayoutRootPaths([$viewRootPath . 'Layouts/']);
86  $this->view->setPartialRootPaths([$viewRootPath . 'Partials/']);
87  $this->view
88  // time is used in js and css as parameter to force loading of resources
89  ->assign('time', time())
90  ->assign('action', $this->action)
91  ->assign('controller', $this->controller)
92  ->assign('token', $this->token)
93  ->assign('context', $contextService->getContextString())
94  ->assign('contextService', $contextService)
95  ->assign('lastError', $this->lastError)
96  ->assign('messages', $this->messages)
97  ->assign('typo3Version', TYPO3_version)
98  ->assign('siteName', $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']);
99  }
100 
106  abstract protected function executeAction();
107 
113  public function setToken($token)
114  {
115  $this->token = $token;
116  }
117 
123  public function setController($controller)
124  {
125  $this->controller = $controller;
126  }
127 
134  public function setAction($action)
135  {
136  $this->action = $action;
137  }
138 
144  public function setPostValues(array $postValues)
145  {
146  $this->postValues = $postValues;
147  }
148 
154  public function setLastError(array $lastError)
155  {
156  $this->lastError = $lastError;
157  }
158 
164  public function setMessages(array $messages = [])
165  {
166  $this->messages = $messages;
167  }
168 
174  protected function getContext()
175  {
176  $context = 'standalone';
177  $formValues = GeneralUtility::_GP('install');
178  if (isset($formValues['context'])) {
179  $context = $formValues['context'] === 'backend' ? 'backend' : 'standalone';
180  }
181  return $context;
182  }
183 
192  {
194  ->ensureClassLoadingInformationExists()
195  ->loadTypo3LoadedExtAndExtLocalconf(false)
196  ->defineLoggingAndExceptionConstants()
197  ->unsetReservedGlobalVariables()
198  ->initializeTypo3DbGlobal()
199  ->loadBaseTca(false)
200  ->loadExtTables(false);
201  }
202 
209  protected function getHashedPassword($password)
210  {
212  return $saltFactory->getHashedPassword($password);
213  }
214 
220  protected function getExtensionCompatibilityTesterMessages()
221  {
222  $extensionCompatibilityTesterMessages = [];
223 
225  $message = GeneralUtility::makeInstance(\TYPO3\CMS\Install\Status\LoadingStatus::class);
226  $message->setTitle('Loading...');
227  $extensionCompatibilityTesterMessages[] = $message;
228 
229  $message = GeneralUtility::makeInstance(\TYPO3\CMS\Install\Status\ErrorStatus::class);
230  $message->setTitle('Incompatible extension found!');
231  $message->setMessage('Something went wrong and no protocol was written.');
232  $extensionCompatibilityTesterMessages[] = $message;
233 
234  $message = GeneralUtility::makeInstance(\TYPO3\CMS\Install\Status\OkStatus::class);
235  $message->setTitle('All local extensions can be loaded!');
236  $extensionCompatibilityTesterMessages[] = $message;
237 
238  return $extensionCompatibilityTesterMessages;
239  }
240 }
static getSaltingInstance($saltedHash='', $mode=TYPO3_MODE)
Definition: SaltFactory.php:83
static getFileAbsFileName($filename, $_=null, $_2=null)
static makeInstance($className,... $constructorArguments)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']