‪TYPO3CMS  9.5
RemoveExtensionViewHelper.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 
21 
27 {
33  public function ‪initializeArguments()
34  {
35  parent::initializeArguments();
36  $this->registerArgument('extension', 'array', '', true);
37  }
38 
44  public function ‪render()
45  {
46  $extension = $this->arguments['extension'];
47  $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
48  if (\‪TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded($extension['key'])) {
49  return '<span class="btn btn-default disabled">' . $iconFactory->getIcon('empty-empty', ‪Icon::SIZE_SMALL)->render() . '</span>';
50  }
51  if (
52  !in_array($extension['type'], \‪TYPO3\CMS\Extensionmanager\Domain\Model\‪Extension::returnAllowedInstallTypes()) ||
53  $extension['type'] === 'System'
54  ) {
55  return '<span class="btn btn-default disabled">' . $iconFactory->getIcon('empty-empty', ‪Icon::SIZE_SMALL)->render() . '</span>';
56  }
57  $uriBuilder = $this->renderingContext->getControllerContext()->getUriBuilder();
58  $action = 'removeExtension';
59  $uriBuilder->reset();
60  $uriBuilder->setFormat('json');
61  $uri = $uriBuilder->uriFor($action, [
62  'extension' => $extension['key']
63  ], 'Action');
64  $this->tag->addAttribute('href', $uri);
65  $cssClass = 'removeExtension btn btn-default';
66  $this->tag->addAttribute('class', $cssClass);
67  $this->tag->addAttribute('title', \‪TYPO3\CMS\‪Extbase\Utility\‪LocalizationUtility::translate('extensionList.remove', 'extensionmanager'));
68  $this->tag->setContent($iconFactory->getIcon('actions-edit-delete', ‪Icon::SIZE_SMALL)->render());
69  return $this->tag->render();
70  }
71 }
‪TYPO3\CMS\Core\Imaging\Icon\SIZE_SMALL
‪const SIZE_SMALL
Definition: Icon.php:29
‪TYPO3\CMS\Extbase\Annotation
Definition: IgnoreValidation.php:4
‪TYPO3\CMS\Core\Imaging\Icon
Definition: Icon.php:25
‪TYPO3
‪TYPO3\CMS\Core\Imaging\IconFactory
Definition: IconFactory.php:31
‪TYPO3\CMS\Extensionmanager\ViewHelpers
‪TYPO3\CMS\Extensionmanager\ViewHelpers\RemoveExtensionViewHelper
Definition: RemoveExtensionViewHelper.php:27
‪TYPO3\CMS\Extensionmanager\ViewHelpers\RemoveExtensionViewHelper\initializeArguments
‪initializeArguments()
Definition: RemoveExtensionViewHelper.php:33
‪TYPO3\CMS\Extbase\Utility\LocalizationUtility\translate
‪static string null translate($key, $extensionName=null, $arguments=null, string $languageKey=null, array $alternativeLanguageKeys=null)
Definition: LocalizationUtility.php:63
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\returnAllowedInstallTypes
‪static array returnAllowedInstallTypes()
Definition: Extension.php:467
‪TYPO3\CMS\Extensionmanager\ViewHelpers\RemoveExtensionViewHelper\render
‪string render()
Definition: RemoveExtensionViewHelper.php:44