TYPO3 CMS  TYPO3_8-7
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 
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  }
75  return $this->identifier;
76  }
77 
83  public function setTitle($title)
84  {
85  $this->title = $title;
86  }
87 
93  public function getIdentifier()
94  {
95  return $this->identifier;
96  }
97 
103  public function setIdentifier($identifier)
104  {
105  $this->identifier = $identifier;
106  }
107 
116  public function shouldRenderWizard()
117  {
118  $explanation = '';
119  $result = $this->checkForUpdate($explanation);
120  return (bool)$result === true;
121  }
122 
131  public function shouldRenderNextButton()
132  {
133  $showUpdate = 0;
134  $explanation = '';
135  $result = $this->checkForUpdate($explanation, $showUpdate);
136  return $showUpdate != 2 || $result;
137  }
138 
145  public function checkIfTableExists($table)
146  {
147  $tableExists = GeneralUtility::makeInstance(ConnectionPool::class)
148  ->getConnectionForTable($table)
149  ->getSchemaManager()
150  ->tablesExist([$table]);
151 
152  return $tableExists;
153  }
154 
161  abstract public function checkForUpdate(&$description);
162 
170  abstract public function performUpdate(array &$dbQueries, &$customMessage);
171 
178  protected function installExtensions(array $extensionKeys)
179  {
181  $installUtility = GeneralUtility::makeInstance(
182  \TYPO3\CMS\Extensionmanager\Utility\InstallUtility::class
183  );
184  $installUtility->install($extensionKeys);
185  }
186 
194  protected function markWizardAsDone($confValue = 1)
195  {
196  GeneralUtility::makeInstance(Registry::class)->set('installUpdate', get_class($this), $confValue);
197  }
198 
204  protected function isWizardDone()
205  {
206  $wizardClassName = get_class($this);
207  $done = GeneralUtility::makeInstance(Registry::class)->get('installUpdate', $wizardClassName, false);
208 
209  // Fall back in case the wizard for migration of "wizard done" flags to system registry was not run yet
210  if (!$done) {
211  try {
212  GeneralUtility::makeInstance(ConfigurationManager::class)
213  ->getLocalConfigurationValueByPath('INSTALL/wizardDone/' . $wizardClassName);
214  $done = true;
215  } catch (\RuntimeException $e) {
216  }
217  }
218 
219  return $done;
220  }
221 }
performUpdate(array &$dbQueries, &$customMessage)
static makeInstance($className,... $constructorArguments)