‪TYPO3CMS  ‪main
ProcessAvailableActionsViewHelper.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use Psr\EventDispatcher\EventDispatcherInterface;
22 use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper;
23 
29 final class ‪ProcessAvailableActionsViewHelper extends AbstractTagBasedViewHelper
30 {
31  protected EventDispatcherInterface ‪$eventDispatcher;
32 
33  public function ‪injectEventDispatcher(EventDispatcherInterface ‪$eventDispatcher): void
34  {
35  $this->eventDispatcher = ‪$eventDispatcher;
36  }
37 
38  public function ‪initializeArguments(): void
39  {
40  parent::initializeArguments();
41  $this->registerArgument('extension', 'array', '', true);
42  }
43 
44  public function ‪render(): string
45  {
46  $html = $this->renderChildren();
47  $actions = preg_split('#\\n\\s*#s', trim($html));
48  $actions = is_array($actions) ? $actions : [];
49  $event = new ‪AvailableActionsForExtensionEvent($this->arguments['extension']['key'], $this->arguments['extension'], $actions);
50  $this->eventDispatcher->dispatch($event);
51  return implode(' ', $event->getActions());
52  }
53 }
‪TYPO3\CMS\Extensionmanager\ViewHelpers\ProcessAvailableActionsViewHelper
Definition: ProcessAvailableActionsViewHelper.php:30
‪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\render
‪render()
Definition: ProcessAvailableActionsViewHelper.php:44
‪TYPO3\CMS\Extensionmanager\ViewHelpers\ProcessAvailableActionsViewHelper\initializeArguments
‪initializeArguments()
Definition: ProcessAvailableActionsViewHelper.php:38
‪TYPO3\CMS\Extensionmanager\ViewHelpers\ProcessAvailableActionsViewHelper\$eventDispatcher
‪EventDispatcherInterface $eventDispatcher
Definition: ProcessAvailableActionsViewHelper.php:31