UpdateScriptController.php 2.7 KB
Newer Older
1
<?php
2

3
/*
4
 * This file is part of the TYPO3 CMS project.
5
 *
6
7
8
 * It is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License, either version 2
 * of the License, or any later version.
9
 *
10
11
 * For the full copyright and license information, please read the
 * LICENSE.txt file that was distributed with this source code.
12
 *
13
14
 * The TYPO3 project - inspiring people to share!
 */
15

16
17
namespace TYPO3\CMS\Extensionmanager\Controller;

18
19
20
use TYPO3\CMS\Backend\Template\Components\ButtonBar;
use TYPO3\CMS\Backend\View\BackendTemplateView;
use TYPO3\CMS\Core\Imaging\Icon;
21
use TYPO3\CMS\Core\Utility\GeneralUtility;
22
use TYPO3\CMS\Extbase\Mvc\View\ViewInterface;
23
use TYPO3\CMS\Extensionmanager\Utility\UpdateScriptUtility;
24
25
26

/**
 * Controller for configuration related actions.
27
 * @internal This class is a specific controller implementation and is not considered part of the Public TYPO3 API.
28
 */
29
class UpdateScriptController extends AbstractModuleController
30
{
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
    /**
     * Set up the doc header properly here
     *
     * @param ViewInterface $view
     */
    protected function initializeView(ViewInterface $view)
    {
        if ($view instanceof BackendTemplateView) {
            /** @var BackendTemplateView $view */
            parent::initializeView($view);
            $this->generateMenu();
            $this->registerDocheaderButtons();
        }
    }

46
47
48
49
50
51
52
53
    /**
     * Show the content of the update script (if any).
     *
     * @param string $extensionKey Extension key
     * @throws \TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException
     */
    public function showAction($extensionKey)
    {
54
        $updateScriptUtility = GeneralUtility::makeInstance(UpdateScriptUtility::class);
55
56
57
58
59
        $updateScriptResult = $updateScriptUtility->executeUpdateIfNeeded($extensionKey);
        $this->view
            ->assign('updateScriptResult', $updateScriptResult)
            ->assign('extensionKey', $extensionKey);
    }
60
61
62
63
64
65
66
67
68
69
70

    /**
     * Registers the Icons into the docheader
     *
     * @throws \InvalidArgumentException
     */
    protected function registerDocheaderButtons()
    {
        /** @var ButtonBar $buttonBar */
        $buttonBar = $this->view->getModuleTemplate()->getDocHeaderComponent()->getButtonBar();

71
        $uri = $this->uriBuilder->reset()->uriFor('index', [], 'List');
72
73
74
75
76
77
78
79
        $title = $this->translate('extConfTemplate.backToList');
        $icon = $this->view->getModuleTemplate()->getIconFactory()->getIcon('actions-view-go-back', Icon::SIZE_SMALL);
        $button = $buttonBar->makeLinkButton()
            ->setHref($uri)
            ->setTitle($title)
            ->setIcon($icon);
        $buttonBar->addButton($button, ButtonBar::BUTTON_POSITION_LEFT);
    }
80
}