[TASK] Re-work/simplify copyright header in PHP files - Part 2
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / Classes / Controller / Action / Ajax / CoreUpdateIsUpdateAvailable.php
1 <?php
2 namespace TYPO3\CMS\Install\Controller\Action\Ajax;
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
17 /**
18 * Check if a younger version is available
19 */
20 class CoreUpdateIsUpdateAvailable extends AbstractCoreUpdate {
21
22 /**
23 * Executes the action
24 *
25 * @return array Rendered content
26 */
27 protected function executeAction() {
28 $status = array();
29 if ($this->coreVersionService->isInstalledVersionAReleasedVersion()) {
30 $isDevelopmentUpdateAvailable = $this->coreVersionService->isYoungerPatchDevelopmentReleaseAvailable();
31 $isUpdateAvailable = $this->coreVersionService->isYoungerPatchReleaseAvailable();
32 $isUpdateSecurityRelevant = $this->coreVersionService->isUpdateSecurityRelevant();
33
34 if (!$isUpdateAvailable && !$isDevelopmentUpdateAvailable) {
35 $status = $this->getMessage('notice', 'No regular update available');
36 } elseif ($isUpdateAvailable) {
37 $newVersion = $this->coreVersionService->getYoungestPatchRelease();
38 if ($isUpdateSecurityRelevant) {
39 $status = $this->getMessage('warning', 'Update to security relevant released version ' . $newVersion . ' is available!');
40 $action = $this->getAction('Update now', 'updateRegular');
41 } else {
42 $status = $this->getMessage('info', 'Update to regular released version ' . $newVersion . ' is available!');
43 $action = $this->getAction('Update now', 'updateRegular');
44 }
45 } elseif ($isDevelopmentUpdateAvailable) {
46 $newVersion = $this->coreVersionService->getYoungestPatchDevelopmentRelease();
47 $status = $this->getMessage('info', 'Update to development release ' . $newVersion . ' is available!');
48 $action = $this->getAction('Update now', 'updateDevelopment');
49 }
50 } else {
51 $status = $this->getMessage('warning', 'Current version is a development version and can not be updated');
52 }
53
54 $this->view->assign('success', TRUE);
55 $this->view->assign('status', array($status));
56 if (isset($action)) {
57 $this->view->assign('action', $action);
58 }
59
60 return $this->view->render();
61 }
62
63 /**
64 * @param string $severity
65 * @param string $title
66 * @param string $message
67 * @return \TYPO3\CMS\Install\Status\StatusInterface
68 */
69 protected function getMessage($severity, $title, $message = '') {
70 /** @var $statusMessage \TYPO3\CMS\Install\Status\StatusInterface */
71 $statusMessage = $this->objectManager->get('TYPO3\\CMS\\Install\\Status\\' . ucfirst($severity) . 'Status');
72 $statusMessage->setTitle($title);
73 $statusMessage->setMessage($message);
74
75 return $statusMessage;
76 }
77
78 /**
79 * @param string $title
80 * @param string $action
81 * @return array
82 */
83 protected function getAction($title, $action) {
84 return array(
85 'title' => $title,
86 'action' => $action,
87 );
88 }
89 }