TYPO3 CMS  TYPO3_8-7
CoreUpdateIsUpdateAvailable.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 
18 
23 {
29  protected function executeAction()
30  {
31  $status = [];
32  if ($this->coreVersionService->isInstalledVersionAReleasedVersion()) {
33  $isDevelopmentUpdateAvailable = $this->coreVersionService->isYoungerPatchDevelopmentReleaseAvailable();
34  $isUpdateAvailable = $this->coreVersionService->isYoungerPatchReleaseAvailable();
35  $isUpdateSecurityRelevant = $this->coreVersionService->isUpdateSecurityRelevant();
36 
37  if (!$isUpdateAvailable && !$isDevelopmentUpdateAvailable) {
38  $status = $this->getMessage('notice', 'No regular update available');
39  } elseif ($isUpdateAvailable) {
40  $newVersion = $this->coreVersionService->getYoungestPatchRelease();
41  if ($isUpdateSecurityRelevant) {
42  $status = $this->getMessage('warning', 'Update to security relevant released version ' . $newVersion . ' is available!');
43  $action = $this->getAction('Update now', 'updateRegular');
44  } else {
45  $status = $this->getMessage('info', 'Update to regular released version ' . $newVersion . ' is available!');
46  $action = $this->getAction('Update now', 'updateRegular');
47  }
48  } elseif ($isDevelopmentUpdateAvailable) {
49  $newVersion = $this->coreVersionService->getYoungestPatchDevelopmentRelease();
50  $status = $this->getMessage('info', 'Update to development release ' . $newVersion . ' is available!');
51  $action = $this->getAction('Update now', 'updateDevelopment');
52  }
53  } else {
54  $status = $this->getMessage('warning', 'Current version is a development version and can not be updated');
55  }
56 
57  $this->view->assign('success', true);
58  $this->view->assign('status', [$status]);
59  if (isset($action)) {
60  $this->view->assign('action', $action);
61  }
62 
63  return $this->view->render();
64  }
65 
72  protected function getMessage($severity, $title, $message = '')
73  {
75  $statusMessage = GeneralUtility::makeInstance('TYPO3\\CMS\\Install\\Status\\' . ucfirst($severity) . 'Status');
76  $statusMessage->setTitle($title);
77  $statusMessage->setMessage($message);
78 
79  return $statusMessage;
80  }
81 
87  protected function getAction($title, $action)
88  {
89  return [
90  'title' => $title,
91  'action' => $action,
92  ];
93  }
94 }
static makeInstance($className,... $constructorArguments)