TYPO3  7.6
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  protected $tagName = 'a';
36 
40  public function injectObjectManager(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface $objectManager)
41  {
42  $this->objectManager = $objectManager;
43  }
44 
51  public function render($extensionKey)
52  {
53  $tag = '';
54 
55  // If the "class.ext_update.php" file exists, build link to the update script screen
57  $updateScriptUtility = $this->objectManager->get(\TYPO3\CMS\Extensionmanager\Utility\UpdateScriptUtility::class);
59  $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
60  if ($updateScriptUtility->checkUpdateScriptExists($extensionKey)) {
61  $uriBuilder = $this->controllerContext->getUriBuilder();
62  $action = 'show';
63  $uri = $uriBuilder->reset()->uriFor(
64  $action,
65  array('extensionKey' => $extensionKey),
66  'UpdateScript'
67  );
68  $this->tag->addAttribute('href', $uri);
69  $this->tag->addAttribute('title', \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('extensionList.update.script', 'extensionmanager'));
70  $this->tag->setContent($iconFactory->getIcon('extensions-extensionmanager-update-script', Icon::SIZE_SMALL)->render());
71  $tag = $this->tag->render();
72  } else {
73  return '<span class="btn btn-default disabled">' . $iconFactory->getIcon('empty-empty', Icon::SIZE_SMALL)->render() . '</span>';
74  }
75  return $tag;
76  }
77 }