‪TYPO3CMS  11.5
RemoveExtensionViewHelper.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
25 use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper;
26 
31 class ‪RemoveExtensionViewHelper extends AbstractTagBasedViewHelper
32 {
36  protected ‪$tagName = 'a';
37 
38  public function ‪initializeArguments()
39  {
40  parent::initializeArguments();
41  $this->registerUniversalTagAttributes();
42  $this->registerArgument('extension', 'array', '', true);
43  }
44 
50  public function ‪render()
51  {
52  $extension = $this->arguments['extension'];
53  $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
54  if (‪ExtensionManagementUtility::isLoaded($extension['key'])) {
55  return '<span class="btn btn-default disabled">' . $iconFactory->getIcon('empty-empty', ‪Icon::SIZE_SMALL)->render() . '</span>';
56  }
57  if (
58  !in_array($extension['type'], ‪Extension::returnAllowedInstallTypes()) ||
59  $extension['type'] === 'System'
60  ) {
61  return '<span class="btn btn-default disabled">' . $iconFactory->getIcon('empty-empty', ‪Icon::SIZE_SMALL)->render() . '</span>';
62  }
63  $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
64  $uriBuilder->setRequest($this->renderingContext->getRequest());
65  $uriBuilder->reset();
66  $uriBuilder->setFormat('json');
67  $uri = $uriBuilder->uriFor(
68  'removeExtension',
69  ['extension' => $extension['key']],
70  'Action'
71  );
72  $this->tag->addAttribute('href', $uri);
73  $this->tag->addAttribute('class', $this->arguments['class']);
74  $this->tag->addAttribute('title', ‪LocalizationUtility::translate('extensionList.remove', 'extensionmanager'));
75  $this->tag->setContent($iconFactory->getIcon('actions-edit-delete', ‪Icon::SIZE_SMALL)->render());
76  return $this->tag->render();
77  }
78 }
‪TYPO3\CMS\Core\Imaging\Icon\SIZE_SMALL
‪const SIZE_SMALL
Definition: Icon.php:30
‪TYPO3\CMS\Extbase\Utility\LocalizationUtility
Definition: LocalizationUtility.php:33
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension
Definition: Extension.php:28
‪TYPO3\CMS\Core\Imaging\Icon
Definition: Icon.php:26
‪TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder
Definition: UriBuilder.php:41
‪TYPO3\CMS\Core\Imaging\IconFactory
Definition: IconFactory.php:34
‪TYPO3\CMS\Extensionmanager\ViewHelpers
‪TYPO3\CMS\Core\Utility\ExtensionManagementUtility
Definition: ExtensionManagementUtility.php:43
‪TYPO3\CMS\Extensionmanager\ViewHelpers\RemoveExtensionViewHelper
Definition: RemoveExtensionViewHelper.php:32
‪TYPO3\CMS\Extensionmanager\ViewHelpers\RemoveExtensionViewHelper\initializeArguments
‪initializeArguments()
Definition: RemoveExtensionViewHelper.php:37
‪TYPO3\CMS\Extbase\Utility\LocalizationUtility\translate
‪static string null translate(string $key, ?string $extensionName=null, array $arguments=null, string $languageKey=null, array $alternativeLanguageKeys=null)
Definition: LocalizationUtility.php:67
‪TYPO3\CMS\Extensionmanager\ViewHelpers\RemoveExtensionViewHelper\$tagName
‪string $tagName
Definition: RemoveExtensionViewHelper.php:35
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:50
‪TYPO3\CMS\Core\Utility\ExtensionManagementUtility\isLoaded
‪static bool isLoaded($key)
Definition: ExtensionManagementUtility.php:114
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\returnAllowedInstallTypes
‪static array returnAllowedInstallTypes()
Definition: Extension.php:475
‪TYPO3\CMS\Extensionmanager\ViewHelpers\RemoveExtensionViewHelper\render
‪string render()
Definition: RemoveExtensionViewHelper.php:49