TYPO3 CMS  TYPO3_6-2
AbstractAction.php
Go to the documentation of this file.
1 <?php
3 
18 
22 abstract class AbstractAction implements ActionInterface {
23 
27  protected $objectManager = NULL;
28 
34  public function injectObjectManager(\TYPO3\CMS\Extbase\Object\ObjectManager $objectManager) {
35  $this->objectManager = $objectManager;
36  }
37 
41  protected $view = NULL;
42 
48  public function injectView(\TYPO3\CMS\Install\View\FailsafeView $view) {
49  $this->view = $view;
50  }
51 
55  protected $controller = '';
56 
60  protected $action = '';
61 
65  protected $token = '';
66 
70  protected $postValues = array();
71 
75  protected $lastError = array();
76 
80  protected $messages = array();
81 
87  public function handle() {
88  $this->initializeHandle();
89  return $this->executeAction();
90  }
91 
97  protected function initializeHandle() {
98  // Context service distinguishes between standalone and backend context
99  $contextService = $this->objectManager->get('TYPO3\\CMS\\Install\\Service\\ContextService');
100 
101  $viewRootPath = GeneralUtility::getFileAbsFileName('EXT:install/Resources/Private/');
102  $controllerActionDirectoryName = ucfirst($this->controller);
103  $mainTemplate = ucfirst($this->action);
104  $this->view->setTemplatePathAndFilename($viewRootPath . 'Templates/Action/' . $controllerActionDirectoryName . '/' . $mainTemplate . '.html');
105  $this->view->setLayoutRootPath($viewRootPath . 'Layouts/');
106  $this->view->setPartialRootPath($viewRootPath . 'Partials/');
107  $this->view
108  // time is used in js and css as parameter to force loading of resources
109  ->assign('time', time())
110  ->assign('action', $this->action)
111  ->assign('controller', $this->controller)
112  ->assign('token', $this->token)
113  ->assign('context', $contextService->getContextString())
114  ->assign('contextService', $contextService)
115  ->assign('lastError', $this->lastError)
116  ->assign('messages', $this->messages)
117  ->assign('typo3Version', TYPO3_version)
118  ->assign('siteName', $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']);
119  }
120 
126  abstract protected function executeAction();
127 
134  public function setToken($token) {
135  $this->token = $token;
136  }
137 
144  public function setController($controller) {
145  $this->controller = $controller;
146  }
147 
155  public function setAction($action) {
156  $this->action = $action;
157  }
158 
165  public function setPostValues(array $postValues) {
166  $this->postValues = $postValues;
167  }
168 
174  public function setLastError(array $lastError) {
175  $this->lastError = $lastError;
176  }
177 
183  public function setMessages(array $messages = array()) {
184  $this->messages = $messages;
185  }
186 
192  protected function isDbalEnabled() {
193  if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('adodb')
194  && \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('dbal')
195  ) {
196  return TRUE;
197  }
198  return FALSE;
199  }
200 
206  protected function getContext() {
207  $context = 'standalone';
208  $formValues = GeneralUtility::_GP('install');
209  if (isset($formValues['context'])) {
210  $context = $formValues['context'] === 'backend' ? 'backend' : 'standalone';
211  }
212  return $context;
213  }
214 
221  protected function getDatabaseConnection() {
222  static $database;
223  if (!is_object($database)) {
225  $database = $this->objectManager->get('TYPO3\\CMS\\Core\\Database\\DatabaseConnection');
226  $database->setDatabaseUsername($GLOBALS['TYPO3_CONF_VARS']['DB']['username']);
227  $database->setDatabasePassword($GLOBALS['TYPO3_CONF_VARS']['DB']['password']);
228  $database->setDatabaseHost($GLOBALS['TYPO3_CONF_VARS']['DB']['host']);
229  $database->setDatabasePort($GLOBALS['TYPO3_CONF_VARS']['DB']['port']);
230  $database->setDatabaseSocket($GLOBALS['TYPO3_CONF_VARS']['DB']['socket']);
231  $database->setDatabaseName($GLOBALS['TYPO3_CONF_VARS']['DB']['database']);
232  $database->initialize();
233  $database->connectDB();
234  }
235  return $database;
236  }
237 
249  ->loadTypo3LoadedExtAndExtLocalconf(FALSE)
250  ->applyAdditionalConfigurationSettings()
251  ->initializeTypo3DbGlobal()
252  ->loadExtensionTables(FALSE);
253  }
254 
261  protected function getHashedPassword($password) {
263  return $saltFactory->getHashedPassword($password);
264  }
265 }
static getSaltingInstance($saltedHash='', $mode=TYPO3_MODE)
Definition: SaltFactory.php:83
injectObjectManager(\TYPO3\CMS\Extbase\Object\ObjectManager $objectManager)
$database
Definition: server.php:38
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]
static getFileAbsFileName($filename, $onlyRelative=TRUE, $relToTYPO3_mainDir=FALSE)
injectView(\TYPO3\CMS\Install\View\FailsafeView $view)