[TASK] Introduced getter for $GLOBALS in backend/Classes/ContextMenu 44/37444/3
authorMichael Oehlhof <typo3@oehlhof.de>
Sun, 1 Mar 2015 23:36:39 +0000 (00:36 +0100)
committerWouter Wolters <typo3@wouterwolters.nl>
Mon, 2 Mar 2015 10:45:27 +0000 (11:45 +0100)
- add getter for LanguageService
- add getter for BackendUser

Resolves: #65445
Releases: master
Change-Id: I985f9b0aa619ea7f90f35fe169122c26850a73df
Reviewed-on: http://review.typo3.org/37444
Reviewed-by: Markus Klein <klein.t3@reelworx.at>
Tested-by: Markus Klein <klein.t3@reelworx.at>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
typo3/sysext/backend/Classes/ContextMenu/AbstractContextMenuDataProvider.php
typo3/sysext/backend/Classes/ContextMenu/Pagetree/ContextMenuDataProvider.php

index 8d01111..7968267 100644 (file)
@@ -70,7 +70,7 @@ abstract class AbstractContextMenuDataProvider {
         * @return array
         */
        protected function getConfiguration() {
-               $contextMenuActions = $GLOBALS['BE_USER']->getTSConfig('options.contextMenu.' . $this->contextMenuType . '.items');
+               $contextMenuActions = $this->getBackendUser()->getTSConfig('options.contextMenu.' . $this->contextMenuType . '.items');
                return $contextMenuActions['properties'];
        }
 
@@ -176,7 +176,7 @@ abstract class AbstractContextMenuDataProvider {
                                        unset($action);
                                        continue;
                                }
-                               $label = $GLOBALS['LANG']->sL($actionConfiguration['label'], TRUE);
+                               $label = $this->getLanguageService()->sL($actionConfiguration['label'], TRUE);
                                if ($type === 'SUBMENU') {
                                        $action->setType('submenu');
                                        $action->setChildActions($this->getNextContextMenuLevel($actionConfiguration, $node, $level + 1));
@@ -220,4 +220,22 @@ abstract class AbstractContextMenuDataProvider {
                return $contentUrl;
        }
 
+       /**
+        * Returns LanguageService
+        *
+        * @return \TYPO3\CMS\Lang\LanguageService
+        */
+       protected function getLanguageService() {
+               return $GLOBALS['LANG'];
+       }
+
+       /**
+        * Returns the current BE user.
+        *
+        * @return \TYPO3\CMS\Core\Authentication\BackendUserAuthentication
+        */
+       protected function getBackendUser() {
+               return $GLOBALS['BE_USER'];
+       }
+
 }
index f252cc6..2883a4e 100644 (file)
@@ -42,12 +42,12 @@ class ContextMenuDataProvider extends \TYPO3\CMS\Backend\ContextMenu\AbstractCon
         * @return array
         */
        protected function getDisableActions() {
-               $tsConfig = $GLOBALS['BE_USER']->getTSConfig('options.contextMenu.' . $this->getContextMenuType() . '.disableItems');
+               $tsConfig = $this->getBackendUser()->getTSConfig('options.contextMenu.' . $this->getContextMenuType() . '.disableItems');
                $disableItems = array();
                if (trim($tsConfig['value']) !== '') {
                        $disableItems = GeneralUtility::trimExplode(',', $tsConfig['value']);
                }
-               $tsConfig = $GLOBALS['BE_USER']->getTSConfig('options.contextMenu.pageTree.disableItems');
+               $tsConfig = $this->getBackendUser()->getTSConfig('options.contextMenu.pageTree.disableItems');
                $oldDisableItems = array();
                if (trim($tsConfig['value']) !== '') {
                        $oldDisableItems = GeneralUtility::trimExplode(',', $tsConfig['value']);
@@ -84,4 +84,13 @@ class ContextMenuDataProvider extends \TYPO3\CMS\Backend\ContextMenu\AbstractCon
                return $contextMenuActions;
        }
 
+       /**
+        * Returns the current BE user.
+        *
+        * @return \TYPO3\CMS\Core\Authentication\BackendUserAuthentication
+        */
+       protected function getBackendUser() {
+               return $GLOBALS['BE_USER'];
+       }
+
 }