[TASK] Get rid of ObjectManager in install tool
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / Classes / Controller / Action / Ajax / AbstractCoreUpdate.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 use TYPO3\CMS\Core\Utility\GeneralUtility;
18 use TYPO3\CMS\Install\Service\CoreUpdateService;
19 use TYPO3\CMS\Install\Service\CoreVersionService;
20 use TYPO3\CMS\Install\Status\StatusUtility;
21 use TYPO3\CMS\Install\View\JsonView;
22
23 /**
24 * Abstract core update class contains general core update
25 * related methods
26 */
27 abstract class AbstractCoreUpdate extends AbstractAjaxAction
28 {
29 /**
30 * @var \TYPO3\CMS\Install\View\JsonView
31 */
32 protected $view;
33
34 /**
35 * @var \TYPO3\CMS\Install\Service\CoreUpdateService
36 */
37 protected $coreUpdateService;
38
39 /**
40 * @var \TYPO3\CMS\Install\Status\StatusUtility
41 */
42 protected $statusUtility;
43
44 /**
45 * @var \TYPO3\CMS\Install\Service\CoreVersionService
46 */
47 protected $coreVersionService;
48
49 /**
50 * @param JsonView $view
51 * @param CoreUpdateService $coreUpdateService
52 * @param \TYPO3\CMS\Install\Status\StatusUtility $statusUtility
53 * @param \TYPO3\CMS\Install\Service\CoreVersionService $coreVersionService
54 */
55 public function __construct(
56 JsonView $view = null,
57 CoreUpdateService $coreUpdateService = null,
58 StatusUtility $statusUtility = null,
59 CoreVersionService $coreVersionService = null)
60 {
61 $this->view = $view ?: GeneralUtility::makeInstance(JsonView::class);
62 $this->coreUpdateService = $coreUpdateService ?: GeneralUtility::makeInstance(CoreUpdateService::class);
63 $this->statusUtility = $statusUtility ?: GeneralUtility::makeInstance(StatusUtility::class);
64 $this->coreVersionService = $coreVersionService ?: GeneralUtility::makeInstance(CoreVersionService::class);
65 }
66
67 /**
68 * Initialize the handle action, sets up fluid stuff and assigns default variables.
69 *
70 * @return void
71 * @throws \TYPO3\CMS\Install\Controller\Exception
72 */
73 protected function initializeHandle()
74 {
75 if (!$this->coreUpdateService->isCoreUpdateEnabled()) {
76 throw new \TYPO3\CMS\Install\Controller\Exception(
77 'Core Update disabled in this environment',
78 1381609294
79 );
80 }
81 $this->loadExtLocalconfDatabaseAndExtTables();
82 }
83
84 /**
85 * Find out which version upgrade should be handled. This may
86 * be different depending on whether development or regular release.
87 *
88 * @throws \TYPO3\CMS\Install\Controller\Exception
89 * @return string Version to handle, eg. 6.2.2
90 */
91 protected function getVersionToHandle()
92 {
93 $getVars = \TYPO3\CMS\Core\Utility\GeneralUtility::_GET('install');
94 if (!isset($getVars['type'])) {
95 throw new \TYPO3\CMS\Install\Controller\Exception(
96 'Type must be set to either "regular" or "development"',
97 1380975303
98 );
99 }
100 $type = $getVars['type'];
101 if ($type === 'development') {
102 $versionToHandle = $this->coreVersionService->getYoungestPatchDevelopmentRelease();
103 } else {
104 $versionToHandle = $this->coreVersionService->getYoungestPatchRelease();
105 }
106 return $versionToHandle;
107 }
108 }