TYPO3  7.6
RemoveExtensionViewHelper.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  $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
41  if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded($extension['key'])) {
42  return '<span class="btn btn-default disabled">' . $iconFactory->getIcon('empty-empty', Icon::SIZE_SMALL)->render() . '</span>';
43  }
44  if (
45  !in_array($extension['type'], \TYPO3\CMS\Extensionmanager\Domain\Model\Extension::returnAllowedInstallTypes()) ||
46  $extension['type'] === 'System'
47  ) {
48  return '<span class="btn btn-default disabled">' . $iconFactory->getIcon('empty-empty', Icon::SIZE_SMALL)->render() . '</span>';
49  }
50  $uriBuilder = $this->controllerContext->getUriBuilder();
51  $action = 'removeExtension';
52  $uriBuilder->reset();
53  $uriBuilder->setFormat('json');
54  $uri = $uriBuilder->uriFor($action, array(
55  'extension' => $extension['key']
56  ), 'Action');
57  $this->tag->addAttribute('href', $uri);
58  $cssClass = 'removeExtension btn btn-default';
59  $this->tag->addAttribute('class', $cssClass);
60  $this->tag->addAttribute('title', \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('extensionList.remove', 'extensionmanager'));
61  $this->tag->setContent($iconFactory->getIcon('actions-edit-delete', Icon::SIZE_SMALL)->render());
62  return $this->tag->render();
63  }
64 }