‪TYPO3CMS  9.5
UpdateScriptViewHelper.php
Go to the documentation of this file.
1 <?php
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 
21 
27 {
28 
30  protected ‪$objectManager;
31 
35  public function ‪injectObjectManager(\‪TYPO3\CMS\‪Extbase\Object\ObjectManagerInterface ‪$objectManager)
36  {
37  $this->objectManager = ‪$objectManager;
38  }
39 
43  public function ‪initializeArguments()
44  {
45  parent::initializeArguments();
46  $this->registerArgument('extensionKey', 'string', 'Extension key', true);
47  }
48 
54  public function ‪render()
55  {
56  $extensionKey = $this->arguments['extensionKey'];
57 
58  // If the "class.ext_update.php" file exists, build link to the update script screen
60  $updateScriptUtility = $this->objectManager->get(\‪TYPO3\CMS\Extensionmanager\Utility\UpdateScriptUtility::class);
62  $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
63  if ($updateScriptUtility->checkUpdateScriptExists($extensionKey)) {
64  $uriBuilder = $this->renderingContext->getControllerContext()->getUriBuilder();
65  $action = 'show';
66  $uri = $uriBuilder->reset()->uriFor(
67  $action,
68  ['extensionKey' => $extensionKey],
69  'UpdateScript'
70  );
71  $this->tag->addAttribute('href', $uri);
72  $this->tag->addAttribute('title', \‪TYPO3\CMS\‪Extbase\Utility\‪LocalizationUtility::translate('extensionList.update.script', 'extensionmanager'));
73  $this->tag->setContent($iconFactory->getIcon('actions-refresh', ‪Icon::SIZE_SMALL)->render());
74  $tag = $this->tag->render();
75  } else {
76  return '<span class="btn btn-default disabled">' . $iconFactory->getIcon('empty-empty', ‪Icon::SIZE_SMALL)->render() . '</span>';
77  }
78  return $tag;
79  }
80 }
‪TYPO3\CMS\Core\Imaging\Icon\SIZE_SMALL
‪const SIZE_SMALL
Definition: Icon.php:29
‪TYPO3\CMS\Extbase\Annotation
Definition: IgnoreValidation.php:4
‪TYPO3\CMS\Core\Imaging\Icon
Definition: Icon.php:25
‪TYPO3
‪TYPO3\CMS\Core\Imaging\IconFactory
Definition: IconFactory.php:31
‪TYPO3\CMS\Extensionmanager\ViewHelpers
‪TYPO3\CMS\Extbase\Utility\LocalizationUtility\translate
‪static string null translate($key, $extensionName=null, $arguments=null, string $languageKey=null, array $alternativeLanguageKeys=null)
Definition: LocalizationUtility.php:63
‪TYPO3\CMS\Extensionmanager\ViewHelpers\UpdateScriptViewHelper\injectObjectManager
‪injectObjectManager(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface $objectManager)
Definition: UpdateScriptViewHelper.php:34
‪TYPO3\CMS\Extensionmanager\ViewHelpers\UpdateScriptViewHelper
Definition: UpdateScriptViewHelper.php:27
‪TYPO3\CMS\Extensionmanager\ViewHelpers\UpdateScriptViewHelper\initializeArguments
‪initializeArguments()
Definition: UpdateScriptViewHelper.php:42
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Extensionmanager\ViewHelpers\UpdateScriptViewHelper\render
‪string render()
Definition: UpdateScriptViewHelper.php:53
‪TYPO3\CMS\Extensionmanager\ViewHelpers\UpdateScriptViewHelper\$objectManager
‪TYPO3 CMS Extbase Object ObjectManager $objectManager
Definition: UpdateScriptViewHelper.php:29