TYPO3 CMS  TYPO3_7-6
AbstractCoreUpdate.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 abstract class AbstractCoreUpdate extends AbstractAjaxAction
22 {
26  protected $view = null;
27 
31  protected $coreUpdateService;
32 
36  protected $statusUtility;
37 
42 
46  public function injectView(\TYPO3\CMS\Install\View\FailsafeView $view)
47  {
48  // dummy method to stop setting view to failsafeView while keeping
49  // compatibility with parent declaration (and thus errors on PHP7)
50  // while allowing dependency injection to inject correct view by
51  // using method below.
52  }
53 
57  public function injectJsonView(\TYPO3\CMS\Install\View\JsonView $view)
58  {
59  $this->view = $view;
60  }
61 
65  public function injectCoreUpdateService(\TYPO3\CMS\Install\Service\CoreUpdateService $coreUpdateService)
66  {
67  $this->coreUpdateService = $coreUpdateService;
68  }
69 
73  public function injectStatusUtility(\TYPO3\CMS\Install\Status\StatusUtility $statusUtility)
74  {
75  $this->statusUtility = $statusUtility;
76  }
77 
81  public function injectCoreVersionService(\TYPO3\CMS\Install\Service\CoreVersionService $coreVersionService)
82  {
83  $this->coreVersionService = $coreVersionService;
84  }
85 
92  protected function initializeHandle()
93  {
94  if (!$this->coreUpdateService->isCoreUpdateEnabled()) {
95  throw new \TYPO3\CMS\Install\Controller\Exception(
96  'Core Update disabled in this environment',
97  1381609294
98  );
99  }
101  }
102 
110  protected function getVersionToHandle()
111  {
112  $getVars = \TYPO3\CMS\Core\Utility\GeneralUtility::_GET('install');
113  if (!isset($getVars['type'])) {
114  throw new \TYPO3\CMS\Install\Controller\Exception(
115  'Type must be set to either "regular" or "development"',
116  1380975303
117  );
118  }
119  $type = $getVars['type'];
120  if ($type === 'development') {
121  $versionToHandle = $this->coreVersionService->getYoungestPatchDevelopmentRelease();
122  } else {
123  $versionToHandle = $this->coreVersionService->getYoungestPatchRelease();
124  }
125  return $versionToHandle;
126  }
127 }
injectStatusUtility(\TYPO3\CMS\Install\Status\StatusUtility $statusUtility)
injectJsonView(\TYPO3\CMS\Install\View\JsonView $view)
injectCoreVersionService(\TYPO3\CMS\Install\Service\CoreVersionService $coreVersionService)
injectCoreUpdateService(\TYPO3\CMS\Install\Service\CoreUpdateService $coreUpdateService)
injectView(\TYPO3\CMS\Install\View\FailsafeView $view)