[FEATURE] Signal to process actions in Extension Manager
[Packages/TYPO3.CMS.git] / typo3 / sysext / extensionmanager / Classes / ViewHelpers / ProcessAvailableActionsViewHelper.php
1 <?php
2 namespace TYPO3\CMS\Extensionmanager\ViewHelpers;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2014 Xavier Perseguers <xavier@typo3.org>
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 * A copy is found in the text file GPL.txt and important notices to the license
19 * from the author is found in LICENSE.txt distributed with these scripts.
20 *
21 *
22 * This script is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * This copyright notice MUST APPEAR in all copies of the script!
28 ***************************************************************/
29
30 /**
31 * View helper to let 3rd-party extensions process the list of available
32 * actions for a given extension.
33 *
34 * @author Xavier Perseguers <xavier@typo3.org>
35 */
36 class ProcessAvailableActionsViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Link\ActionViewHelper {
37
38 const SIGNAL_ProcessActions = 'processActions';
39
40 /**
41 * @var \TYPO3\CMS\Extbase\SignalSlot\Dispatcher
42 * @inject
43 */
44 protected $signalSlotDispatcher;
45
46 /**
47 * Processes the list of actions.
48 *
49 * @param string $extension
50 * @return string the rendered list of actions
51 */
52 public function render($extension) {
53 $html = $this->renderChildren();
54 $actions = preg_split('#\\n\\s*#s', trim($html));
55
56 $this->signalSlotDispatcher->dispatch(
57 __CLASS__,
58 static::SIGNAL_ProcessActions,
59 array(
60 'extension' => $extension,
61 'actions' => &$actions,
62 )
63 );
64
65 return implode(' ', $actions);
66 }
67
68 }