TYPO3 CMS  TYPO3_8-7
UpdateFromTerController.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  */
18 
23 {
27  protected $repositoryHelper;
28 
33 
37  protected $listUtility;
38 
43 
47  protected $defaultViewObjectName = JsonView::class;
48 
52  public function injectRepositoryHelper(\TYPO3\CMS\Extensionmanager\Utility\Repository\Helper $repositoryHelper)
53  {
54  $this->repositoryHelper = $repositoryHelper;
55  }
56 
60  public function injectRepositoryRepository(\TYPO3\CMS\Extensionmanager\Domain\Repository\RepositoryRepository $repositoryRepository)
61  {
62  $this->repositoryRepository = $repositoryRepository;
63  }
64 
68  public function injectListUtility(\TYPO3\CMS\Extensionmanager\Utility\ListUtility $listUtility)
69  {
70  $this->listUtility = $listUtility;
71  }
72 
76  public function injectExtensionRepository(\TYPO3\CMS\Extensionmanager\Domain\Repository\ExtensionRepository $extensionRepository)
77  {
78  $this->extensionRepository = $extensionRepository;
79  }
80 
86  public function updateExtensionListFromTerAction($forceUpdateCheck = false)
87  {
88  $updated = false;
89  $errorMessage = '';
90 
91  if ($this->extensionRepository->countAll() === 0 || $forceUpdateCheck) {
92  try {
93  $updated = $this->repositoryHelper->updateExtList();
94  } catch (\TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException $e) {
95  $errorMessage = $e->getMessage();
96  }
97  }
99  $repository = $this->repositoryRepository->findByUid((int)$this->settings['repositoryUid']);
100 
101  $timeFormat = $this->getLanguageService()->sL('LLL:EXT:extensionmanager/Resources/Private/Language/locallang.xlf:extensionList.updateFromTer.lastUpdate.fullTimeFormat');
102  $lastUpdateTime = $repository ? $repository->getLastUpdate() : null;
103  if (null === $lastUpdateTime) {
104  $lastUpdatedSince = $this->getLanguageService()->sL('LLL:EXT:extensionmanager/Resources/Private/Language/locallang.xlf:extensionList.updateFromTer.never');
105  $lastUpdateTime = date($timeFormat);
106  } else {
108  time() - $lastUpdateTime->format('U'),
109  $this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.minutesHoursDaysYears')
110  );
111  $lastUpdateTime = $lastUpdateTime->format($timeFormat);
112  }
113  $this->view->assign('value', [
114  'updated' => $updated,
115  'lastUpdateTime' => $lastUpdateTime,
116  'timeSinceLastUpdate' => $lastUpdatedSince,
117  'errorMessage' => $errorMessage
118  ]);
119  }
120 
124  protected function getLanguageService()
125  {
126  return $GLOBALS['LANG'];
127  }
128 }
static calcAge($seconds, $labels='min|hrs|days|yrs|min|hour|day|year')
injectRepositoryHelper(\TYPO3\CMS\Extensionmanager\Utility\Repository\Helper $repositoryHelper)
injectExtensionRepository(\TYPO3\CMS\Extensionmanager\Domain\Repository\ExtensionRepository $extensionRepository)
injectListUtility(\TYPO3\CMS\Extensionmanager\Utility\ListUtility $listUtility)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']
injectRepositoryRepository(\TYPO3\CMS\Extensionmanager\Domain\Repository\RepositoryRepository $repositoryRepository)