TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
AbstractUpdate.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Install\Updates;
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 
22 
27 abstract class AbstractUpdate
28 {
34  protected $title;
35 
41  protected $identifier;
42 
48  public $pObj;
49 
55  public $userInput;
56 
64 
70  public function getTitle()
71  {
72  if ($this->title) {
73  return $this->title;
74  } else {
75  return $this->identifier;
76  }
77  }
78 
85  public function setTitle($title)
86  {
87  $this->title = $title;
88  }
89 
95  public function getIdentifier()
96  {
97  return $this->identifier;
98  }
99 
106  public function setIdentifier($identifier)
107  {
108  $this->identifier = $identifier;
109  }
110 
119  public function shouldRenderWizard()
120  {
121  $showUpdate = 0;
122  $explanation = '';
123  $result = $this->checkForUpdate($explanation, $showUpdate);
124  return $showUpdate > 0 || $result == true;
125  }
126 
135  public function shouldRenderNextButton()
136  {
137  $showUpdate = 0;
138  $explanation = '';
139  $result = $this->checkForUpdate($explanation, $showUpdate);
140  return $showUpdate != 2 || $result;
141  }
142 
149  public function checkIfTableExists($table)
150  {
151  $tableExists = GeneralUtility::makeInstance(ConnectionPool::class)
152  ->getConnectionForTable($table)
153  ->getSchemaManager()
154  ->tablesExist([$table]);
155 
156  return $tableExists;
157  }
158 
165  abstract public function checkForUpdate(&$description);
166 
174  abstract public function performUpdate(array &$dbQueries, &$customMessages);
175 
183  protected function installExtensions(array $extensionKeys)
184  {
186  $installUtility = GeneralUtility::makeInstance(
187  \TYPO3\CMS\Extensionmanager\Utility\InstallUtility::class
188  );
189  foreach ($extensionKeys as $extension) {
190  $installUtility->install($extension);
191  }
192  }
193 
202  protected function markWizardAsDone($confValue = 1)
203  {
204  GeneralUtility::makeInstance(Registry::class)->set('installUpdate', get_class($this), $confValue);
205  }
206 
212  protected function isWizardDone()
213  {
214  $wizardClassName = get_class($this);
215  $done = GeneralUtility::makeInstance(Registry::class)->get('installUpdate', $wizardClassName, false);
216 
217  // Fall back in case the wizard for migration of "wizard done" flags to system registry was not run yet
218  if (!$done) {
219  try {
220  GeneralUtility::makeInstance(ConfigurationManager::class)
221  ->getLocalConfigurationValueByPath('INSTALL/wizardDone/' . $wizardClassName);
222  $done = true;
223  } catch (\RuntimeException $e) {
224  }
225  }
226 
227  return $done;
228  }
229 }
performUpdate(array &$dbQueries, &$customMessages)
static makeInstance($className,...$constructorArguments)