‪TYPO3CMS  9.5
ListController.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 
30 
36 {
40  protected ‪$extensionRepository;
41 
45  protected ‪$listUtility;
46 
50  protected ‪$pageRenderer;
51 
55  protected ‪$dependencyUtility;
56 
60  public function ‪injectExtensionRepository(\‪TYPO3\CMS\Extensionmanager\Domain\Repository\ExtensionRepository ‪$extensionRepository)
61  {
62  $this->extensionRepository = ‪$extensionRepository;
63  }
64 
68  public function ‪injectListUtility(\‪TYPO3\CMS\Extensionmanager\Utility\ListUtility ‪$listUtility)
69  {
70  $this->listUtility = ‪$listUtility;
71  }
72 
76  public function ‪injectPageRenderer(\‪TYPO3\CMS\Core\Page\PageRenderer ‪$pageRenderer)
77  {
78  $this->pageRenderer = ‪$pageRenderer;
79  }
80 
84  public function ‪injectDependencyUtility(\‪TYPO3\CMS\Extensionmanager\Utility\DependencyUtility ‪$dependencyUtility)
85  {
86  $this->dependencyUtility = ‪$dependencyUtility;
87  }
88 
92  public function ‪initializeAction()
93  {
94  $this->pageRenderer->addInlineLanguageLabelFile('EXT:extensionmanager/Resources/Private/Language/locallang.xlf');
95  $isAutomaticInstallationEnabled = (bool)GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('extensionmanager', 'offlineMode');
96  if ($isAutomaticInstallationEnabled) {
97  $this->settings['offlineMode'] = true;
98  }
99  }
100 
106  protected function ‪initializeView(‪ViewInterface ‪$view)
107  {
108  if (‪$view instanceof ‪BackendTemplateView) {
110  parent::initializeView(‪$view);
111  $this->‪generateMenu();
113  }
114  }
115 
119  protected function ‪addComposerModeNotification()
120  {
122  $this->‪addFlashMessage(
124  'composerMode.message',
125  'extensionmanager'
126  ),
128  'composerMode.title',
129  'extensionmanager'
130  ),
132  );
133  }
134  }
135 
139  public function ‪indexAction()
140  {
142  $availableAndInstalledExtensions = $this->listUtility->getAvailableAndInstalledExtensionsWithAdditionalInformation();
143  ksort($availableAndInstalledExtensions);
144  $this->view->assignMultiple(
145  [
146  'extensions' => $availableAndInstalledExtensions,
147  'isComposerMode' => ‪Environment::isComposerMode(),
148  ]
149  );
150  $this->‪handleTriggerArguments();
151  }
152 
159  public function ‪unresolvedDependenciesAction($extensionKey)
160  {
161  $availableExtensions = $this->listUtility->getAvailableExtensions();
162  if (isset($availableExtensions[$extensionKey])) {
163  $extensionArray = $this->listUtility->enrichExtensionsWithEmConfAndTerInformation(
164  [
165  $extensionKey => $availableExtensions[$extensionKey]
166  ]
167  );
169  $extensionModelUtility = $this->objectManager->get(ExtensionModelUtility::class);
170  $extension = $extensionModelUtility->mapExtensionArrayToModel($extensionArray[$extensionKey]);
171  } else {
172  throw new ExtensionManagerException('Extension ' . $extensionKey . ' is not available', 1402421007);
173  }
174  $this->dependencyUtility->checkDependencies($extension);
175  $this->view->assign('extension', $extension);
176  $this->view->assign('unresolvedDependencies', $this->dependencyUtility->getDependencyErrors());
177  }
178 
185  public function ‪terAction($search = '')
186  {
188  $search = trim($search);
189  if (!empty($search)) {
190  $extensions = $this->extensionRepository->findByTitleOrAuthorNameOrExtensionKey($search);
191  } else {
192  $extensions = $this->extensionRepository->findAll();
193  }
194  $availableAndInstalledExtensions = $this->listUtility->getAvailableAndInstalledExtensions($this->listUtility->getAvailableExtensions());
195  $this->view->assign('extensions', $extensions)
196  ->assign('search', $search)
197  ->assign('availableAndInstalled', $availableAndInstalledExtensions);
198  }
199 
205  public function ‪distributionsAction($showUnsuitableDistributions = false)
206  {
208  $importExportInstalled = ‪ExtensionManagementUtility::isLoaded('impexp');
209  if ($importExportInstalled) {
210  try {
212  $repositoryHelper = $this->objectManager->get(Helper::class);
213  // Check if a TER update has been done at all, if not, fetch it directly
214  // Repository needs an update, but not because of the extension hash has changed
215  $isExtListUpdateNecessary = $repositoryHelper->isExtListUpdateNecessary();
216  if ($isExtListUpdateNecessary > 0 && ($isExtListUpdateNecessary & $repositoryHelper::PROBLEM_EXTENSION_HASH_CHANGED) === 0) {
217  $repositoryHelper->updateExtList();
218  }
219  } catch (ExtensionManagerException $e) {
220  $this->‪addFlashMessage($e->getMessage(), $e->getCode(), ‪FlashMessage::ERROR);
221  }
222 
223  $officialDistributions = $this->extensionRepository->findAllOfficialDistributions();
224  $communityDistributions = $this->extensionRepository->findAllCommunityDistributions();
225 
226  $officialDistributions = $this->dependencyUtility->filterYoungestVersionOfExtensionList($officialDistributions->toArray(), $showUnsuitableDistributions);
227  $communityDistributions = $this->dependencyUtility->filterYoungestVersionOfExtensionList($communityDistributions->toArray(), $showUnsuitableDistributions);
228 
229  $this->view->assign('officialDistributions', $officialDistributions);
230  $this->view->assign('communityDistributions', $communityDistributions);
231  }
232  $this->view->assign('enableDistributionsView', $importExportInstalled);
233  $this->view->assign('showUnsuitableDistributions', $showUnsuitableDistributions);
234  }
235 
241  public function ‪showAllVersionsAction($extensionKey)
242  {
243  $currentVersion = $this->extensionRepository->findOneByCurrentVersionByExtensionKey($extensionKey);
244  $extensions = $this->extensionRepository->findByExtensionKeyOrderedByVersion($extensionKey);
245 
246  $this->view->assignMultiple(
247  [
248  'extensionKey' => $extensionKey,
249  'currentVersion' => $currentVersion,
250  'extensions' => $extensions
251  ]
252  );
253  }
254 
260  protected function ‪registerDocheaderButtons()
261  {
263  return;
264  }
265 
266  if (!in_array($this->actionMethodName, ['indexAction', 'terAction', 'showAllVersionsAction'], true)) {
267  return;
268  }
269 
271  $buttonBar = $this->view->getModuleTemplate()->getDocHeaderComponent()->getButtonBar();
272  ‪$uriBuilder = $this->controllerContext->getUriBuilder();
273 
274  if ($this->actionMethodName === 'showAllVersionsAction') {
275  $uri = ‪$uriBuilder->reset()->uriFor('ter', [], 'List');
276  $title = $this->‪translate('extConfTemplate.backToList');
277  $icon = $this->view->getModuleTemplate()->getIconFactory()->getIcon('actions-view-go-back', ‪Icon::SIZE_SMALL);
278  $classes = '';
279  } else {
280  $uri = ‪$uriBuilder->reset()->uriFor('form', [], 'UploadExtensionFile');
281  $title = $this->‪translate('extensionList.uploadExtension');
282  $icon = $this->view->getModuleTemplate()->getIconFactory()->getIcon('actions-edit-upload', ‪Icon::SIZE_SMALL);
283  $classes = 't3js-upload';
284  }
285  $button = $buttonBar->makeLinkButton()
286  ->setHref($uri)
287  ->setTitle($title)
288  ->setClasses($classes)
289  ->setIcon($icon);
290  $buttonBar->addButton($button, ‪ButtonBar::BUTTON_POSITION_LEFT);
291  }
292 }
‪TYPO3\CMS\Core\Imaging\Icon\SIZE_SMALL
‪const SIZE_SMALL
Definition: Icon.php:29
‪TYPO3\CMS\Extensionmanager\Controller\ListController\injectListUtility
‪injectListUtility(\TYPO3\CMS\Extensionmanager\Utility\ListUtility $listUtility)
Definition: ListController.php:64
‪TYPO3\CMS\Extensionmanager\Controller\ListController\$listUtility
‪TYPO3 CMS Extensionmanager Utility ListUtility $listUtility
Definition: ListController.php:43
‪TYPO3\CMS\Extensionmanager\Controller\ListController\indexAction
‪indexAction()
Definition: ListController.php:135
‪TYPO3\CMS\Backend\Template\Components\ButtonBar\BUTTON_POSITION_LEFT
‪const BUTTON_POSITION_LEFT
Definition: ButtonBar.php:35
‪TYPO3\CMS\Extensionmanager\Controller\AbstractController\translate
‪string null translate($key, $arguments=null)
Definition: AbstractController.php:41
‪TYPO3\CMS\Backend\Template\Components\ButtonBar
Definition: ButtonBar.php:31
‪TYPO3\CMS\Extensionmanager\Controller\ListController\injectDependencyUtility
‪injectDependencyUtility(\TYPO3\CMS\Extensionmanager\Utility\DependencyUtility $dependencyUtility)
Definition: ListController.php:80
‪TYPO3\CMS\Extbase\Utility\LocalizationUtility
Definition: LocalizationUtility.php:29
‪TYPO3\CMS\Extensionmanager\Controller\AbstractModuleController
Definition: AbstractModuleController.php:25
‪TYPO3\CMS\Core\Configuration\ExtensionConfiguration
Definition: ExtensionConfiguration.php:42
‪TYPO3\CMS\Extbase\Mvc\Controller\AbstractController\$uriBuilder
‪TYPO3 CMS Extbase Mvc Web Routing UriBuilder $uriBuilder
Definition: AbstractController.php:37
‪TYPO3\CMS\Core\Imaging\Icon
Definition: Icon.php:25
‪TYPO3\CMS\Extensionmanager\Controller\ListController\addComposerModeNotification
‪addComposerModeNotification()
Definition: ListController.php:115
‪TYPO3
‪TYPO3\CMS\Extensionmanager\Utility\ExtensionModelUtility
Definition: ExtensionModelUtility.php:22
‪TYPO3\CMS\Extensionmanager\Controller\AbstractModuleController\generateMenu
‪generateMenu()
Definition: AbstractModuleController.php:58
‪TYPO3\CMS\Extensionmanager\Controller\ListController\$extensionRepository
‪TYPO3 CMS Extensionmanager Domain Repository ExtensionRepository $extensionRepository
Definition: ListController.php:39
‪TYPO3\CMS\Extensionmanager\Controller
Definition: AbstractController.php:2
‪TYPO3\CMS\Extensionmanager\Controller\ListController\initializeAction
‪initializeAction()
Definition: ListController.php:88
‪TYPO3\CMS\Core\Utility\ExtensionManagementUtility
Definition: ExtensionManagementUtility.php:36
‪TYPO3\CMS\Extensionmanager\Controller\ListController\$dependencyUtility
‪TYPO3 CMS Extensionmanager Utility DependencyUtility $dependencyUtility
Definition: ListController.php:51
‪TYPO3\CMS\Extbase\Utility\LocalizationUtility\translate
‪static string null translate($key, $extensionName=null, $arguments=null, string $languageKey=null, array $alternativeLanguageKeys=null)
Definition: LocalizationUtility.php:63
‪TYPO3\CMS\Core\Utility\ExtensionManagementUtility\isLoaded
‪static bool isLoaded($key, $exitOnError=null)
Definition: ExtensionManagementUtility.php:115
‪TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException
Definition: ExtensionManagerException.php:23
‪TYPO3\CMS\Extbase\Mvc\View\ViewInterface
Definition: ViewInterface.php:21
‪TYPO3\CMS\Extensionmanager\Controller\ListController\unresolvedDependenciesAction
‪unresolvedDependenciesAction($extensionKey)
Definition: ListController.php:155
‪TYPO3\CMS\Extensionmanager\Controller\ListController\registerDocheaderButtons
‪registerDocheaderButtons()
Definition: ListController.php:256
‪TYPO3\CMS\Backend\View\BackendTemplateView
Definition: BackendTemplateView.php:27
‪TYPO3\CMS\Core\Core\Environment\isComposerMode
‪static bool isComposerMode()
Definition: Environment.php:117
‪TYPO3\CMS\Core\Messaging\AbstractMessage\INFO
‪const INFO
Definition: AbstractMessage.php:26
‪TYPO3\CMS\Extensionmanager\Controller\ListController\distributionsAction
‪distributionsAction($showUnsuitableDistributions=false)
Definition: ListController.php:201
‪TYPO3\CMS\Core\Messaging\FlashMessage
Definition: FlashMessage.php:22
‪TYPO3\CMS\Extensionmanager\Controller\ListController\initializeView
‪initializeView(ViewInterface $view)
Definition: ListController.php:102
‪TYPO3\CMS\Extensionmanager\Controller\ListController\showAllVersionsAction
‪showAllVersionsAction($extensionKey)
Definition: ListController.php:237
‪TYPO3\CMS\Core\Core\Environment
Definition: Environment.php:39
‪TYPO3\CMS\Extensionmanager\Controller\ListController
Definition: ListController.php:36
‪TYPO3\CMS\Extensionmanager\Controller\ListController\injectPageRenderer
‪injectPageRenderer(\TYPO3\CMS\Core\Page\PageRenderer $pageRenderer)
Definition: ListController.php:72
‪TYPO3\CMS\Extensionmanager\Utility\Repository\Helper
Definition: Helper.php:34
‪TYPO3\CMS\Extensionmanager\Controller\ListController\$pageRenderer
‪TYPO3 CMS Core Page PageRenderer $pageRenderer
Definition: ListController.php:47
‪TYPO3\CMS\Extensionmanager\Controller\AbstractController\handleTriggerArguments
‪handleTriggerArguments()
Definition: AbstractController.php:51
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Extensionmanager\Controller\ListController\terAction
‪terAction($search='')
Definition: ListController.php:181
‪TYPO3\CMS\Extensionmanager\Controller\ListController\injectExtensionRepository
‪injectExtensionRepository(\TYPO3\CMS\Extensionmanager\Domain\Repository\ExtensionRepository $extensionRepository)
Definition: ListController.php:56
‪TYPO3\CMS\Extensionmanager\Controller\AbstractModuleController\$view
‪BackendTemplateView $view
Definition: AbstractModuleController.php:30
‪TYPO3\CMS\Extbase\Mvc\Controller\AbstractController\addFlashMessage
‪addFlashMessage($messageBody, $messageTitle='', $severity=\TYPO3\CMS\Core\Messaging\AbstractMessage::OK, $storeInSession=true)
Definition: AbstractController.php:154
‪TYPO3\CMS\Core\Messaging\AbstractMessage\ERROR
‪const ERROR
Definition: AbstractMessage.php:29