TYPO3 CMS  TYPO3_8-7
ToggleExtensionInstallationStateViewHelper.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 
22 
28 {
32  protected $tagName = 'a';
33 
37  public function initializeArguments()
38  {
39  parent::initializeArguments();
40  $this->registerArgument('extension', 'array', '', true);
41  }
42 
48  public function render()
49  {
50  $extension = $this->arguments['extension'];
51  // Early return if package is protected or is a runtime activated package and can not be unloaded
53  $packageManager = $this->objectManager->get(PackageManager::class);
54  $package = $packageManager->getPackage($extension['key']);
55  if ($package->isProtected() || in_array($extension['key'], $GLOBALS['TYPO3_CONF_VARS']['EXT']['runtimeActivatedPackages'])) {
56  return '';
57  }
58 
59  $uriBuilder = $this->controllerContext->getUriBuilder();
60  $action = 'toggleExtensionInstallationState';
61  $uri = $uriBuilder->reset()->uriFor($action, [
62  'extensionKey' => $extension['key']
63  ], 'Action');
64  $this->tag->addAttribute('href', $uri);
65  $label = $extension['installed'] ? 'deactivate' : 'activate';
66  $this->tag->addAttribute('title', LocalizationUtility::translate('extensionList.' . $label, 'extensionmanager'));
67  $icon = $extension['installed'] ? 'uninstall' : 'install';
68  $this->tag->addAttribute('class', 'onClickMaskExtensionManager btn btn-default');
69 
71  $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
72  $this->tag->setContent($iconFactory->getIcon('actions-system-extension-' . $icon, Icon::SIZE_SMALL)->render());
73  return $this->tag->render();
74  }
75 }
static translate($key, $extensionName=null, $arguments=null)
static makeInstance($className,... $constructorArguments)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']