[!!!][TASK] Remove CMS base ViewHelper classes
[Packages/TYPO3.CMS.git] / typo3 / sysext / extensionmanager / Classes / ViewHelpers / UpdateScriptViewHelper.php
index 78f0c8a..1edb205 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 namespace TYPO3\CMS\Extensionmanager\ViewHelpers;
 
-/**
+/*
  * This file is part of the TYPO3 CMS project.
  *
  * It is free software; you can redistribute it and/or modify it under
@@ -13,55 +13,56 @@ namespace TYPO3\CMS\Extensionmanager\ViewHelpers;
  *
  * The TYPO3 project - inspiring people to share!
  */
-use TYPO3\CMS\Backend\Utility\IconUtility;
+
+use TYPO3\CMS\Core\Imaging\Icon;
+use TYPO3\CMS\Core\Imaging\IconFactory;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
 
 /**
  * View helper for update script link
- *
- * @author Francois Suter <francois.suter@typo3.org>
  * @internal
  */
-class UpdateScriptViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Link\ActionViewHelper {
-
-       /**
-        * @var \TYPO3\CMS\Extbase\Object\ObjectManagerInterface
-        * @inject
-        */
-       protected $objectManager;
-
-       /**
-        * @var string
-        */
-       protected $tagName = 'a';
-
-       /**
-        * Renders a link to the update script screen if the extension has one
-        *
-        * @param string $extensionKey Extension key
-        * @return string The rendered a tag
-        */
-       public function render($extensionKey) {
-               $tag = '';
+class UpdateScriptViewHelper extends Link\ActionViewHelper
+{
+    /**
+     * initialize arguments
+     */
+    public function initializeArguments()
+    {
+        parent::initializeArguments();
+        $this->registerArgument('extensionKey', 'string', 'Extension key', true);
+    }
 
-               // If the "class.ext_update.php" file exists, build link to the update script screen
-               /** @var $updateScriptUtility \TYPO3\CMS\Extensionmanager\Utility\UpdateScriptUtility */
-               $updateScriptUtility = $this->objectManager->get(\TYPO3\CMS\Extensionmanager\Utility\UpdateScriptUtility::class);
-               if ($updateScriptUtility->checkUpdateScriptExists($extensionKey)) {
-                       $uriBuilder = $this->controllerContext->getUriBuilder();
-                       $action = 'show';
-                       $uri = $uriBuilder->reset()->uriFor(
-                               $action,
-                               array('extensionKey' => $extensionKey),
-                               'UpdateScript'
-                       );
-                       $this->tag->addAttribute('href', $uri);
-                       $this->tag->addAttribute('title', \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('extensionList.update.script', 'extensionmanager'));
-                       $this->tag->setContent(\TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('extensions-extensionmanager-update-script'));
-                       $tag = $this->tag->render();
-               } else {
-                       return '<span class="btn disabled">' . IconUtility::getSpriteIcon('empty-empty') . '</span>';
-               }
-               return $tag;
-       }
+    /**
+     * Renders a link to the update script screen if the extension has one
+     *
+     * @return string The rendered a tag
+     */
+    public function render()
+    {
+        $extensionKey = $this->arguments['extensionKey'];
+        $tag = '';
 
+        // If the "class.ext_update.php" file exists, build link to the update script screen
+        /** @var $updateScriptUtility \TYPO3\CMS\Extensionmanager\Utility\UpdateScriptUtility */
+        $updateScriptUtility = $this->objectManager->get(\TYPO3\CMS\Extensionmanager\Utility\UpdateScriptUtility::class);
+        /** @var IconFactory $iconFactory */
+        $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
+        if ($updateScriptUtility->checkUpdateScriptExists($extensionKey)) {
+            $uriBuilder = $this->renderingContext->getControllerContext()->getUriBuilder();
+            $action = 'show';
+            $uri = $uriBuilder->reset()->uriFor(
+                $action,
+                ['extensionKey' => $extensionKey],
+                'UpdateScript'
+            );
+            $this->tag->addAttribute('href', $uri);
+            $this->tag->addAttribute('title', \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('extensionList.update.script', 'extensionmanager'));
+            $this->tag->setContent($iconFactory->getIcon('extensions-extensionmanager-update-script', Icon::SIZE_SMALL)->render());
+            $tag = $this->tag->render();
+        } else {
+            return '<span class="btn btn-default disabled">' . $iconFactory->getIcon('empty-empty', Icon::SIZE_SMALL)->render() . '</span>';
+        }
+        return $tag;
+    }
 }