TYPO3  7.6
ToggleExtensionInstallationStateViewHelper.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Extensionmanager\ViewHelpers;
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 
20 
26 {
30  protected $tagName = 'a';
31 
38  public function render($extension)
39  {
40  // Early return if package is protected or is a runtime actived package and can not be unloaded
42  $packageManager = $this->objectManager->get(\TYPO3\CMS\Core\Package\PackageManager::class);
43  $package = $packageManager->getPackage($extension['key']);
44  if ($package->isProtected() || in_array($extension['key'], $GLOBALS['TYPO3_CONF_VARS']['EXT']['runtimeActivatedPackages'])) {
45  return '';
46  }
47 
48  $uriBuilder = $this->controllerContext->getUriBuilder();
49  $action = 'toggleExtensionInstallationState';
50  $uri = $uriBuilder->reset()->uriFor($action, array(
51  'extensionKey' => $extension['key']
52  ), 'Action');
53  $this->tag->addAttribute('href', $uri);
54  $label = $extension['installed'] ? 'deactivate' : 'activate';
55  $this->tag->addAttribute('title', \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('extensionList.' . $label, 'extensionmanager'));
56  $icon = $extension['installed'] ? 'uninstall' : 'install';
57  $this->tag->addAttribute('class', 'onClickMaskExtensionManager btn btn-default');
58 
60  $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
61  $this->tag->setContent($iconFactory->getIcon('actions-system-extension-' . $icon, Icon::SIZE_SMALL)->render());
62  return $this->tag->render();
63  }
64 }