[BUGFIX] FollowUp: Fix signal returns for associated signal arguments
[Packages/TYPO3.CMS.git] / typo3 / sysext / extensionmanager / Classes / ViewHelpers / ProcessAvailableActionsViewHelper.php
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
17 /**
18 * View helper to let 3rd-party extensions process the list of available
19 * actions for a given extension.
20 *
21 * @author Xavier Perseguers <xavier@typo3.org>
22 */
23 class ProcessAvailableActionsViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Link\ActionViewHelper {
24
25 const SIGNAL_ProcessActions = 'processActions';
26
27 /**
28 * @var \TYPO3\CMS\Extbase\SignalSlot\Dispatcher
29 * @inject
30 */
31 protected $signalSlotDispatcher;
32
33 /**
34 * Processes the list of actions.
35 *
36 * @param string $extension
37 * @return string the rendered list of actions
38 */
39 public function render($extension) {
40 $html = $this->renderChildren();
41 $actions = preg_split('#\\n\\s*#s', trim($html));
42
43 $actions = $this->emitProcessActionsSignal($extension, $actions);
44
45 return implode(' ', $actions);
46 }
47
48 /**
49 * Emits a signal after the list of actions is processed
50 *
51 * @param string $extension
52 * @param array $actions
53 * @return array Modified action array
54 */
55 protected function emitProcessActionsSignal($extension, array $actions) {
56 $this->signalSlotDispatcher->dispatch(
57 __CLASS__,
58 static::SIGNAL_ProcessActions,
59 array(
60 $extension,
61 &$actions,
62 )
63 );
64 return $actions;
65 }
66
67 }