TYPO3 CMS  TYPO3_8-7
DistributionController.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  */
20 
25 {
29  protected $packageManager;
30 
34  public function injectPackageManager(\TYPO3\CMS\Core\Package\PackageManager $packageManager)
35  {
36  $this->packageManager = $packageManager;
37  }
38 
44  protected function initializeView(ViewInterface $view)
45  {
46  if ($view instanceof BackendTemplateView) {
48  parent::initializeView($view);
49  $this->generateMenu();
50  $this->registerDocheaderButtons();
51  }
52  }
53 
59  public function showAction(\TYPO3\CMS\Extensionmanager\Domain\Model\Extension $extension)
60  {
61  $extensionKey = $extension->getExtensionKey();
62  // Check if extension/package is installed
63  $active = $this->packageManager->isPackageActive($extensionKey);
64 
65  // Create link for extension configuration
66  if ($active && file_exists(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($extensionKey) . 'ext_conf_template.txt')) {
67  $uriBuilder = $this->controllerContext->getUriBuilder();
68  $action = 'showConfigurationForm';
69  $configurationLink = $uriBuilder->reset()->uriFor(
70  $action,
71  ['extension' => ['key' => $extensionKey]],
72  'Configuration'
73  );
74  } else {
75  $configurationLink = false;
76  }
77  $this->view->assign('distributionActive', $active);
78  $this->view->assign('configurationLink', $configurationLink);
79  $this->view->assign('extension', $extension);
80  }
81 
87  protected function registerDocheaderButtons()
88  {
90  $buttonBar = $this->view->getModuleTemplate()->getDocHeaderComponent()->getButtonBar();
91 
92  $uriBuilder = $this->controllerContext->getUriBuilder();
93 
94  $uri = $uriBuilder->reset()->uriFor('distributions', [], 'List');
95  $title = $this->translate('extConfTemplate.backToList');
96  $icon = $this->view->getModuleTemplate()->getIconFactory()->getIcon('actions-view-go-back', Icon::SIZE_SMALL);
97  $button = $buttonBar->makeLinkButton()
98  ->setHref($uri)
99  ->setTitle($title)
100  ->setIcon($icon);
101  $buttonBar->addButton($button, ButtonBar::BUTTON_POSITION_LEFT);
102  }
103 }
showAction(\TYPO3\CMS\Extensionmanager\Domain\Model\Extension $extension)
injectPackageManager(\TYPO3\CMS\Core\Package\PackageManager $packageManager)