Completed
Push — master ( 471d20...bd01a5 )
by
unknown
16:06 queued 43s
created

UpdateScriptViewHelper::initializeArguments()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
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
16
namespace TYPO3\CMS\Extensionmanager\ViewHelpers;
17
18
use TYPO3\CMS\Core\Imaging\Icon;
19
use TYPO3\CMS\Core\Imaging\IconFactory;
20
use TYPO3\CMS\Core\Utility\GeneralUtility;
21
use TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder;
22
use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
23
use TYPO3\CMS\Extensionmanager\Utility\UpdateScriptUtility;
24
use TYPO3\CMS\Fluid\ViewHelpers\Link\ActionViewHelper;
25
26
/**
27
 * ViewHelper for update script link
28
 * @internal
29
 */
30
class UpdateScriptViewHelper extends ActionViewHelper
31
{
32
    /**
33
     * initialize arguments
34
     */
35
    public function initializeArguments()
36
    {
37
        parent::initializeArguments();
38
        $this->registerArgument('extensionKey', 'string', 'Extension key', true);
39
    }
40
41
    /**
42
     * Renders a link to the update script screen if the extension has one
43
     *
44
     * @return string The rendered a tag
45
     */
46
    public function render()
47
    {
48
        $extensionKey = $this->arguments['extensionKey'];
49
50
        // If the "class.ext_update.php" file exists, build link to the update script screen
51
        $updateScriptUtility = GeneralUtility::makeInstance(UpdateScriptUtility::class);
52
        $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
53
        if ($updateScriptUtility->checkUpdateScriptExists($extensionKey)) {
54
            /** @var UriBuilder $uriBuilder */
55
            $uriBuilder = $this->renderingContext->getControllerContext()->getUriBuilder();
0 ignored issues
show
Bug introduced by
The method getControllerContext() does not exist on TYPO3Fluid\Fluid\Core\Re...nderingContextInterface. Did you maybe mean getControllerAction()? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

55
            $uriBuilder = $this->renderingContext->/** @scrutinizer ignore-call */ getControllerContext()->getUriBuilder();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
56
            $action = 'show';
57
            $uri = $uriBuilder->reset()->uriFor(
58
                $action,
59
                ['extensionKey' => $extensionKey],
60
                'UpdateScript'
61
            );
62
            $this->tag->addAttribute('href', $uri);
63
            $this->tag->addAttribute('title', LocalizationUtility::translate('extensionList.update.script', 'extensionmanager'));
64
            $this->tag->setContent($iconFactory->getIcon('actions-refresh', Icon::SIZE_SMALL)->render());
65
            $tag = $this->tag->render();
66
        } else {
67
            return '<span class="btn btn-default disabled">' . $iconFactory->getIcon('empty-empty', Icon::SIZE_SMALL)->render() . '</span>';
68
        }
69
        return $tag;
70
    }
71
}
72