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