[TASK] Drop an always skipped unit test
[Packages/TYPO3.CMS.git] / typo3 / sysext / extensionmanager / Classes / Controller / DistributionController.php
1 <?php
2
3 /*
4 * This file is part of the TYPO3 CMS project.
5 *
6 * It is free software; you can redistribute it and/or modify it under
7 * the terms of the GNU General Public License, either version 2
8 * of the License, or any later version.
9 *
10 * For the full copyright and license information, please read the
11 * LICENSE.txt file that was distributed with this source code.
12 *
13 * The TYPO3 project - inspiring people to share!
14 */
15
16 namespace TYPO3\CMS\Extensionmanager\Controller;
17
18 use TYPO3\CMS\Backend\Template\Components\ButtonBar;
19 use TYPO3\CMS\Backend\View\BackendTemplateView;
20 use TYPO3\CMS\Core\Imaging\Icon;
21 use TYPO3\CMS\Core\Package\PackageManager;
22 use TYPO3\CMS\Extbase\Mvc\View\ViewInterface;
23 use TYPO3\CMS\Extensionmanager\Domain\Model\Extension;
24
25 /**
26 * Controller for distribution related actions
27 * @internal This class is a specific controller implementation and is not considered part of the Public TYPO3 API.
28 */
29 class DistributionController extends AbstractModuleController
30 {
31 /**
32 * @var PackageManager
33 */
34 protected $packageManager;
35
36 /**
37 * @param PackageManager $packageManager
38 */
39 public function injectPackageManager(PackageManager $packageManager)
40 {
41 $this->packageManager = $packageManager;
42 }
43
44 /**
45 * Set up the doc header properly here
46 *
47 * @param ViewInterface $view
48 */
49 protected function initializeView(ViewInterface $view)
50 {
51 if ($view instanceof BackendTemplateView) {
52 /** @var BackendTemplateView $view */
53 parent::initializeView($view);
54 $this->generateMenu();
55 $this->registerDocheaderButtons();
56 }
57 }
58
59 /**
60 * Shows information about the distribution
61 *
62 * @param Extension $extension
63 */
64 public function showAction(Extension $extension)
65 {
66 $extensionKey = $extension->getExtensionKey();
67 // Check if extension/package is installed
68 $active = $this->packageManager->isPackageActive($extensionKey);
69
70 $this->view->assign('distributionActive', $active);
71 $this->view->assign('extension', $extension);
72 }
73
74 /**
75 * Registers the Icons into the docheader
76 *
77 * @throws \InvalidArgumentException
78 */
79 protected function registerDocheaderButtons()
80 {
81 /** @var ButtonBar $buttonBar */
82 $buttonBar = $this->view->getModuleTemplate()->getDocHeaderComponent()->getButtonBar();
83
84 $uri = $this->uriBuilder->reset()->uriFor('distributions', [], 'List');
85 $title = $this->translate('extConfTemplate.backToList');
86 $icon = $this->view->getModuleTemplate()->getIconFactory()->getIcon('actions-view-go-back', Icon::SIZE_SMALL);
87 $button = $buttonBar->makeLinkButton()
88 ->setHref($uri)
89 ->setTitle($title)
90 ->setIcon($icon);
91 $buttonBar->addButton($button, ButtonBar::BUTTON_POSITION_LEFT);
92 }
93 }