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