TYPO3 CMS  TYPO3_7-6
AbstractUpdate.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 
24 abstract class AbstractUpdate
25 {
31  protected $title;
32 
38  protected $identifier;
39 
45  public $pObj;
46 
52  public $userInput;
53 
61 
67  public function getTitle()
68  {
69  if ($this->title) {
70  return $this->title;
71  } else {
72  return $this->identifier;
73  }
74  }
75 
82  public function setTitle($title)
83  {
84  $this->title = $title;
85  }
86 
92  public function getIdentifier()
93  {
94  return $this->identifier;
95  }
96 
103  public function setIdentifier($identifier)
104  {
105  $this->identifier = $identifier;
106  }
107 
116  public function shouldRenderWizard()
117  {
118  $showUpdate = 0;
119  $explanation = '';
120  $result = $this->checkForUpdate($explanation, $showUpdate);
121  return $showUpdate > 0 || $result == true;
122  }
123 
132  public function shouldRenderNextButton()
133  {
134  $showUpdate = 0;
135  $explanation = '';
136  $result = $this->checkForUpdate($explanation, $showUpdate);
137  return $showUpdate != 2 || $result;
138  }
139 
146  public function checkIfTableExists($table)
147  {
148  $databaseTables = $this->getDatabaseConnection()->admin_get_tables();
149  if (array_key_exists($table, $databaseTables)) {
150  return true;
151  }
152  return false;
153  }
154 
161  abstract public function checkForUpdate(&$description);
162 
170  abstract public function performUpdate(array &$dbQueries, &$customMessages);
171 
179  protected function installExtensions(array $extensionKeys)
180  {
182  $installUtility = GeneralUtility::makeInstance(
183  \TYPO3\CMS\Extensionmanager\Utility\InstallUtility::class
184  );
185  foreach ($extensionKeys as $extension) {
186  $installUtility->install($extension);
187  }
188  }
189 
198  protected function markWizardAsDone($confValue = 1)
199  {
200  GeneralUtility::makeInstance(\TYPO3\CMS\Core\Configuration\ConfigurationManager::class)
201  ->setLocalConfigurationValueByPath('INSTALL/wizardDone/' . get_class($this), $confValue);
202  }
203 
209  protected function isWizardDone()
210  {
211  $wizardClassName = get_class($this);
212  $done = false;
213  if (
214  isset($GLOBALS['TYPO3_CONF_VARS']['INSTALL']['wizardDone'][$wizardClassName])
215  && $GLOBALS['TYPO3_CONF_VARS']['INSTALL']['wizardDone'][$wizardClassName]
216  ) {
217  $done = true;
218  }
219  return $done;
220  }
221 
225  protected function getDatabaseConnection()
226  {
227  return $GLOBALS['TYPO3_DB'];
228  }
229 }
performUpdate(array &$dbQueries, &$customMessages)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']