TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
UpdateScriptViewHelper.php
Go to the documentation of this file.
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 
20 
26 {
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  $tag = '';
58 
59  // If the "class.ext_update.php" file exists, build link to the update script screen
61  $updateScriptUtility = $this->objectManager->get(\TYPO3\CMS\Extensionmanager\Utility\UpdateScriptUtility::class);
63  $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
64  if ($updateScriptUtility->checkUpdateScriptExists($extensionKey)) {
65  $uriBuilder = $this->controllerContext->getUriBuilder();
66  $action = 'show';
67  $uri = $uriBuilder->reset()->uriFor(
68  $action,
69  ['extensionKey' => $extensionKey],
70  'UpdateScript'
71  );
72  $this->tag->addAttribute('href', $uri);
73  $this->tag->addAttribute('title', \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('extensionList.update.script', 'extensionmanager'));
74  $this->tag->setContent($iconFactory->getIcon('extensions-extensionmanager-update-script', Icon::SIZE_SMALL)->render());
75  $tag = $this->tag->render();
76  } else {
77  return '<span class="btn btn-default disabled">' . $iconFactory->getIcon('empty-empty', Icon::SIZE_SMALL)->render() . '</span>';
78  }
79  return $tag;
80  }
81 }
static translate($key, $extensionName, $arguments=null)
static makeInstance($className,...$constructorArguments)
injectObjectManager(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface $objectManager)