‪TYPO3CMS  10.4
ProcessAvailableActionsViewHelper.php
Go to the documentation of this file.
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 
17 
18 use Psr\EventDispatcher\EventDispatcherInterface;
20 use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper;
21 
27 class ‪ProcessAvailableActionsViewHelper extends AbstractTagBasedViewHelper
28 {
32  protected ‪$eventDispatcher;
33 
34  public function ‪injectEventDispatcher(EventDispatcherInterface ‪$eventDispatcher)
35  {
36  $this->eventDispatcher = ‪$eventDispatcher;
37  }
38 
39  public function ‪initializeArguments()
40  {
41  parent::initializeArguments();
42  $this->registerArgument('extension', 'array', '', true);
43  }
44 
50  public function ‪render()
51  {
52  $html = $this->renderChildren();
53  $actions = preg_split('#\\n\\s*#s', trim($html));
54  $actions = is_array($actions) ? $actions : [];
55 
56  $event = new ‪AvailableActionsForExtensionEvent($this->arguments['extension']['key'], $this->arguments['extension'], $actions);
57  $this->eventDispatcher->dispatch($event);
58  return implode(' ', $event->getActions());
59  }
60 }
‪TYPO3\CMS\Extensionmanager\ViewHelpers\ProcessAvailableActionsViewHelper\render
‪string render()
Definition: ProcessAvailableActionsViewHelper.php:49
‪TYPO3\CMS\Extensionmanager\ViewHelpers\ProcessAvailableActionsViewHelper
Definition: ProcessAvailableActionsViewHelper.php:28
‪TYPO3\CMS\Extensionmanager\ViewHelpers\ProcessAvailableActionsViewHelper\injectEventDispatcher
‪injectEventDispatcher(EventDispatcherInterface $eventDispatcher)
Definition: ProcessAvailableActionsViewHelper.php:33
‪TYPO3\CMS\Extensionmanager\ViewHelpers
‪TYPO3\CMS\Extensionmanager\Event\AvailableActionsForExtensionEvent
Definition: AvailableActionsForExtensionEvent.php:24
‪TYPO3\CMS\Extensionmanager\ViewHelpers\ProcessAvailableActionsViewHelper\initializeArguments
‪initializeArguments()
Definition: ProcessAvailableActionsViewHelper.php:38
‪TYPO3\CMS\Extensionmanager\ViewHelpers\ProcessAvailableActionsViewHelper\$eventDispatcher
‪EventDispatcherInterface $eventDispatcher
Definition: ProcessAvailableActionsViewHelper.php:31