‪TYPO3CMS  9.5
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 
24 {
28  protected ‪$repositoryHelper;
29 
33  protected ‪$repositoryRepository;
34 
38  protected ‪$listUtility;
39 
44 
48  protected ‪$defaultViewObjectName = JsonView::class;
49 
53  public function ‪injectRepositoryHelper(\‪TYPO3\CMS\Extensionmanager\Utility\Repository\‪Helper ‪$repositoryHelper)
54  {
55  $this->repositoryHelper = ‪$repositoryHelper;
56  }
57 
61  public function ‪injectRepositoryRepository(\‪TYPO3\CMS\Extensionmanager\Domain\Repository\RepositoryRepository ‪$repositoryRepository)
62  {
63  $this->repositoryRepository = ‪$repositoryRepository;
64  }
65 
69  public function ‪injectListUtility(\‪TYPO3\CMS\Extensionmanager\Utility\ListUtility ‪$listUtility)
70  {
71  $this->listUtility = ‪$listUtility;
72  }
73 
77  public function ‪injectExtensionRepository(\‪TYPO3\CMS\Extensionmanager\Domain\Repository\ExtensionRepository ‪$extensionRepository)
78  {
79  $this->extensionRepository = ‪$extensionRepository;
80  }
81 
87  public function ‪updateExtensionListFromTerAction($forceUpdateCheck = false)
88  {
89  $updated = false;
90  $errorMessage = '';
91 
92  if ($this->extensionRepository->countAll() === 0 || $forceUpdateCheck) {
93  try {
94  $updated = $this->repositoryHelper->updateExtList();
95  } catch (\‪TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException $e) {
96  $errorMessage = $e->getMessage();
97  }
98  }
100  $repository = $this->repositoryRepository->findOneTypo3OrgRepository();
101 
102  $timeFormat = $this->‪getLanguageService()->‪sL('LLL:EXT:extensionmanager/Resources/Private/Language/locallang.xlf:extensionList.updateFromTer.lastUpdate.fullTimeFormat');
103  $lastUpdateTime = $repository ? $repository->getLastUpdate() : null;
104  if (null === $lastUpdateTime) {
105  $lastUpdatedSince = $this->‪getLanguageService()->‪sL('LLL:EXT:extensionmanager/Resources/Private/Language/locallang.xlf:extensionList.updateFromTer.never');
106  $lastUpdateTime = date($timeFormat);
107  } else {
109  time() - $lastUpdateTime->format('U'),
110  $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.minutesHoursDaysYears')
111  );
112  $lastUpdateTime = $lastUpdateTime->format($timeFormat);
113  }
114  $this->view->assign('value', [
115  'updated' => $updated,
116  'lastUpdateTime' => $lastUpdateTime,
117  'timeSinceLastUpdate' => $lastUpdatedSince,
118  'errorMessage' => $errorMessage
119  ]);
120  }
121 
125  protected function ‪getLanguageService()
126  {
127  return ‪$GLOBALS['LANG'];
128  }
129 }
‪TYPO3
‪TYPO3\CMS\Backend\Utility\BackendUtility\calcAge
‪static string calcAge($seconds, $labels='min|hrs|days|yrs|min|hour|day|year')
Definition: BackendUtility.php:1218
‪TYPO3\CMS\Extensionmanager\Controller\UpdateFromTerController\injectListUtility
‪injectListUtility(\TYPO3\CMS\Extensionmanager\Utility\ListUtility $listUtility)
Definition: UpdateFromTerController.php:64
‪TYPO3\CMS\Extensionmanager\Controller\UpdateFromTerController\$listUtility
‪TYPO3 CMS Extensionmanager Utility ListUtility $listUtility
Definition: UpdateFromTerController.php:35
‪TYPO3\CMS\Extensionmanager\Controller
Definition: AbstractController.php:2
‪TYPO3\CMS\Core\Localization\LanguageService\sL
‪string sL($input)
Definition: LanguageService.php:158
‪TYPO3\CMS\Extensionmanager\Controller\UpdateFromTerController\$defaultViewObjectName
‪JsonView $defaultViewObjectName
Definition: UpdateFromTerController.php:43
‪TYPO3\CMS\Extensionmanager\Controller\UpdateFromTerController\getLanguageService
‪LanguageService getLanguageService()
Definition: UpdateFromTerController.php:120
‪TYPO3\CMS\Extensionmanager\Controller\UpdateFromTerController\$repositoryHelper
‪TYPO3 CMS Extensionmanager Utility Repository Helper $repositoryHelper
Definition: UpdateFromTerController.php:27
‪TYPO3\CMS\Extensionmanager\Controller\UpdateFromTerController\$extensionRepository
‪TYPO3 CMS Extensionmanager Domain Repository ExtensionRepository $extensionRepository
Definition: UpdateFromTerController.php:39
‪TYPO3\CMS\Extensionmanager\Controller\UpdateFromTerController\updateExtensionListFromTerAction
‪updateExtensionListFromTerAction($forceUpdateCheck=false)
Definition: UpdateFromTerController.php:82
‪TYPO3\CMS\Extensionmanager\Controller\UpdateFromTerController\injectExtensionRepository
‪injectExtensionRepository(\TYPO3\CMS\Extensionmanager\Domain\Repository\ExtensionRepository $extensionRepository)
Definition: UpdateFromTerController.php:72
‪TYPO3\CMS\Extensionmanager\Exception
Definition: Exception.php:23
‪TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException
Definition: ExtensionManagerException.php:23
‪TYPO3\CMS\Extensionmanager\Controller\AbstractController
Definition: AbstractController.php:22
‪TYPO3\CMS\Extensionmanager\Controller\UpdateFromTerController\$repositoryRepository
‪TYPO3 CMS Extensionmanager Domain Repository RepositoryRepository $repositoryRepository
Definition: UpdateFromTerController.php:31
‪TYPO3\CMS\Extensionmanager\Controller\UpdateFromTerController
Definition: UpdateFromTerController.php:24
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Extensionmanager\Utility\Repository\Helper
Definition: Helper.php:34
‪TYPO3\CMS\Extensionmanager\Controller\UpdateFromTerController\injectRepositoryHelper
‪injectRepositoryHelper(\TYPO3\CMS\Extensionmanager\Utility\Repository\Helper $repositoryHelper)
Definition: UpdateFromTerController.php:48
‪TYPO3\CMS\Core\Localization\LanguageService
Definition: LanguageService.php:29
‪TYPO3\CMS\Extbase\Mvc\View\JsonView
Definition: JsonView.php:29
‪TYPO3\CMS\Extensionmanager\Controller\UpdateFromTerController\injectRepositoryRepository
‪injectRepositoryRepository(\TYPO3\CMS\Extensionmanager\Domain\Repository\RepositoryRepository $repositoryRepository)
Definition: UpdateFromTerController.php:56