‪TYPO3CMS  10.4
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 
26 
32 {
38  public function ‪initializeArguments()
39  {
40  parent::initializeArguments();
41  $this->registerArgument('extension', 'array', '', true);
42  }
43 
49  public function ‪render()
50  {
51  $extension = $this->arguments['extension'];
52  $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
53  if (‪ExtensionManagementUtility::isLoaded($extension['key'])) {
54  return '<span class="btn btn-default disabled">' . $iconFactory->getIcon('empty-empty', ‪Icon::SIZE_SMALL)->render() . '</span>';
55  }
56  if (
57  !in_array($extension['type'], ‪Extension::returnAllowedInstallTypes()) ||
58  $extension['type'] === 'System'
59  ) {
60  return '<span class="btn btn-default disabled">' . $iconFactory->getIcon('empty-empty', ‪Icon::SIZE_SMALL)->render() . '</span>';
61  }
63  $uriBuilder = $this->renderingContext->getControllerContext()->getUriBuilder();
64  $action = 'removeExtension';
65  $uriBuilder->reset();
66  $uriBuilder->setFormat('json');
67  $uri = $uriBuilder->uriFor($action, [
68  'extension' => $extension['key']
69  ], 'Action');
70  $this->tag->addAttribute('href', $uri);
71  $cssClass = 'removeExtension btn btn-default';
72  $this->tag->addAttribute('class', $cssClass);
73  $this->tag->addAttribute('title', ‪LocalizationUtility::translate('extensionList.remove', 'extensionmanager'));
74  $this->tag->setContent($iconFactory->getIcon('actions-edit-delete', ‪Icon::SIZE_SMALL)->render());
75  return $this->tag->render();
76  }
77 }
‪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:29
‪TYPO3\CMS\Core\Imaging\Icon
Definition: Icon.php:26
‪TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder
Definition: UriBuilder.php:39
‪TYPO3\CMS\Core\Imaging\IconFactory
Definition: IconFactory.php:33
‪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:38
‪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\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪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:476
‪TYPO3\CMS\Extensionmanager\ViewHelpers\RemoveExtensionViewHelper\render
‪string render()
Definition: RemoveExtensionViewHelper.php:49