Guest User

Untitled

a guest
Aug 7th, 2013
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.46 KB | None | 0 0
  1. <?php
  2.  
  3. namespace VKF\Admin\Controller;
  4.  
  5. /* *
  6.  * This script belongs to the TYPO3 Flow package "VKF.Admin".             *
  7.  *                                                                        *
  8.  *                                                                        */
  9.  
  10. use TYPO3\Flow\Annotations as Flow;
  11. use TYPO3\Flow\Mvc\Controller\ActionController;
  12.  
  13. abstract class AbstractAdminController extends ActionController implements AdminControllerInterface {
  14.  
  15.     /**
  16.      * @Flow\Inject
  17.      * @var TYPO3\Flow\I18n\Translator
  18.      */
  19.     protected $translator;
  20.    
  21.     /**
  22.      *
  23.      * @param ViewInterface $view
  24.      */
  25.     protected function initializeView(\TYPO3\Flow\Mvc\View\ViewInterface $view) {
  26.         parent::initializeView($view);
  27.         /** @var \TYPO3\Fluid\View\TemplateView $view */
  28.         $view->setLayoutRootPath('resource://VKF.Admin/Private/Layouts');
  29.         $view->assign('modules', $this->getAllModules());
  30.     }
  31.  
  32.     /**
  33.      * @return array
  34.      */
  35.     protected function getAllModules() {
  36.         $moduleClassNames =
  37.                 $this->reflectionService->getAllImplementationClassNamesForInterface("VKF\Admin\Controller\AdminControllerInterface");
  38.         \TYPO3\Flow\var_dump($this->translator);
  39.         $modules = array();
  40.         foreach ($moduleClassNames as $moduleClassName) {
  41.             $objectName = $this->objectManager->getObjectNameByClassName($moduleClassName);
  42.             $packageKey = $this->objectManager->getPackageKeyByObjectName($objectName);
  43.            
  44.             $translationIdentifier = $packageKey . '.' . substr($moduleClassName, strpos($moduleClassName, '\\Controller\\') + 12, -10);
  45.             //\TYPO3\Flow\var_dump($this->translator->translateById($translationIdentifier));
  46.             $moduleCategory = call_user_func(array($moduleClassName, 'getModuleCategory'));
  47.  
  48.             if (!isset($modules[$moduleCategory]))
  49.                 $modules[$moduleCategory] = array();
  50.  
  51.             $modules[$moduleCategory][$moduleClassName] = array(
  52.                 'label' => call_user_func(array($moduleClassName, 'getModuleLabel')),
  53.                 'package' => $packageKey,
  54.                 'controller' => substr($moduleClassName, strpos($moduleClassName, '\\Controller\\') + 12, -10),
  55.                 'active' => (get_class($this) === $moduleClassName)
  56.             );
  57.  
  58.             sort($modules[$moduleCategory]);
  59.         }
  60.         ksort($modules);
  61.  
  62.         return $modules;
  63.     }
  64.  
  65. }
  66.  
  67. ?>
Advertisement
Add Comment
Please, Sign In to add comment