9e18683aa93293725f120b0820369347d43d61a2
[Packages/TYPO3.CMS.git] / typo3 / sysext / extensionmanager / Classes / Controller / AbstractController.php
1 <?php
2 namespace TYPO3\CMS\Extensionmanager\Controller;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2012-2013 Susanne Moog, <typo3@susannemoog.de>
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 * Abstract action controller.
31 *
32 * @author Susanne Moog <typo3@susannemoog.de>
33 */
34 class AbstractController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController {
35
36 const TRIGGER_RefreshModuleMenu = 'refreshModuleMenu';
37
38 /**
39 * @var array
40 */
41 protected $triggerArguments = array(
42 self::TRIGGER_RefreshModuleMenu,
43 );
44
45 /**
46 * Resolve view and initialize the general view-variables extensionName,
47 * controllerName and actionName based on the request object
48 *
49 * @return \TYPO3\CMS\Fluid\View\TemplateView
50 */
51 protected function resolveView() {
52 $view = parent::resolveView();
53 $view->assignMultiple(array(
54 'extensionName' => $this->request->getControllerExtensionName(),
55 'controllerName' => $this->request->getControllerName(),
56 'actionName' => $this->request->getControllerActionName()
57 ));
58 return $view;
59 }
60
61 /**
62 * Translation shortcut
63 *
64 * @param $key
65 * @param NULL|array $arguments
66 * @return NULL|string
67 */
68 protected function translate($key, $arguments = NULL) {
69 return \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate($key, 'extensionmanager', $arguments);
70 }
71
72 /**
73 * Handles trigger arguments, e.g. refreshing the module menu
74 * widget if an extension with backend modules has been enabled
75 * or disabled.
76 *
77 * @return void
78 */
79 protected function handleTriggerArguments() {
80 $triggers = array();
81
82 foreach ($this->triggerArguments as $triggerArgument) {
83 if ($this->request->hasArgument($triggerArgument)) {
84 $triggers[$triggerArgument] = $this->request->getArgument($triggerArgument);
85 }
86 }
87
88 $this->view->assign('triggers', $triggers);
89 }
90 }