[CLEANUP] Use comments not PHPDoc style comments in copyright block
[Packages/TYPO3.CMS.git] / typo3 / sysext / extensionmanager / Classes / ViewHelpers / UpdateScriptViewHelper.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 use TYPO3\CMS\Backend\Utility\IconUtility;
17
18 /**
19 * View helper for update script link
20 *
21 * @author Francois Suter <francois.suter@typo3.org>
22 * @internal
23 */
24 class UpdateScriptViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Link\ActionViewHelper {
25
26 /**
27 * @var \TYPO3\CMS\Extbase\Object\ObjectManagerInterface
28 * @inject
29 */
30 protected $objectManager;
31
32 /**
33 * @var string
34 */
35 protected $tagName = 'a';
36
37 /**
38 * Renders a link to the update script screen if the extension has one
39 *
40 * @param string $extensionKey Extension key
41 * @return string The rendered a tag
42 */
43 public function render($extensionKey) {
44 $tag = '';
45
46 // If the "class.ext_update.php" file exists, build link to the update script screen
47 /** @var $updateScriptUtility \TYPO3\CMS\Extensionmanager\Utility\UpdateScriptUtility */
48 $updateScriptUtility = $this->objectManager->get(\TYPO3\CMS\Extensionmanager\Utility\UpdateScriptUtility::class);
49 if ($updateScriptUtility->checkUpdateScriptExists($extensionKey)) {
50 $uriBuilder = $this->controllerContext->getUriBuilder();
51 $action = 'show';
52 $uri = $uriBuilder->reset()->uriFor(
53 $action,
54 array('extensionKey' => $extensionKey),
55 'UpdateScript'
56 );
57 $this->tag->addAttribute('href', $uri);
58 $this->tag->addAttribute('title', \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('extensionList.update.script', 'extensionmanager'));
59 $this->tag->setContent(\TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('extensions-extensionmanager-update-script'));
60 $tag = $this->tag->render();
61 } else {
62 return '<span class="btn disabled">' . IconUtility::getSpriteIcon('empty-empty') . '</span>';
63 }
64 return $tag;
65 }
66
67 }