[TASK] Remove unused ViewHelpers from extension manager
[Packages/TYPO3.CMS.git] / typo3 / sysext / extensionmanager / Classes / ViewHelpers / RemoveExtensionViewHelper.php
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
17 use TYPO3\CMS\Core\Imaging\Icon;
18 use TYPO3\CMS\Core\Imaging\IconFactory;
19 use TYPO3\CMS\Core\Utility\GeneralUtility;
20 use TYPO3\CMS\Fluid\ViewHelpers\Link\ActionViewHelper;
21
22 /**
23 * view helper for displaying a remove extension link
24 * @internal
25 */
26 class RemoveExtensionViewHelper extends ActionViewHelper
27 {
28 /**
29 * Initialize arguments
30 *
31 * @throws \TYPO3Fluid\Fluid\Core\ViewHelper\Exception
32 */
33 public function initializeArguments()
34 {
35 parent::initializeArguments();
36 $this->registerArgument('extension', 'array', '', true);
37 }
38
39 /**
40 * Renders an install link
41 *
42 * @return string the rendered a tag
43 */
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 }