[Flow] Using Layout from other package
Qbus | Axel Wüstemann
awu at qbus.de
Wed Jul 31 09:59:49 CEST 2013
This was developed by Robert Lemke within a workshop he holded in our
company:
The key is, to let all controller derive from a master controller, wich
defines a layoutRootPath und a partialRootPath.
Furher, each module may define a function 'getModuleLabel' and
'getModuleCssClass' in order to generate a dynamic and plugable menu.
abstract class AbstractModuleController extends ActionController {
/**
* @Flow\Inject
* @var \TYPO3\Flow\Reflection\ReflectionService
*/
protected $reflectionService;
/**
* @Flow\Inject
* @var \TYPO3\Flow\Object\ObjectManagerInterface
*/
protected $objectManager;
/**
*
*
* @param ViewInterface $view
*/
protected function initializeView(ViewInterface $view) {
parent::initializeView($view);
/** @var \TYPO3\Fluid\View\TemplateView $view */
$view->setLayoutPathAndFilename('resource://LALLF.Intranet/Private/Layouts/Default.html');
$view->setPartialRootPath('resource://LALLF.Intranet/Private/Partials/');
$view->assign('modules', $this->buildMenu());
}
/**
* @return string
*/
static public function getModuleCssClass() {
return '';
}
/**
* @return array
*/
protected function buildMenu() {
$moduleClassNames =
$this->reflectionService->getAllImplementationClassNamesForInterface('LALLF\Intranet\Controller\ModuleControllerInterface');
$modules = array();
foreach ($moduleClassNames as $moduleClassName) {
$objectName =
$this->objectManager->getObjectNameByClassName($moduleClassName);
$packageKey = $this->objectManager->getPackageKeyByObjectName($objectName);
$modules[$moduleClassName] = array(
'label' => call_user_func(array($moduleClassName, 'getModuleLabel')),
'package' => $packageKey,
'controller' => substr($moduleClassName, strpos($moduleClassName,
'\\Controller\\') + 12, -10),
'icon' => call_user_func(array($moduleClassName, 'getModuleCssClass')),
'active' => (get_class($this) === $moduleClassName)
);
}
return $modules;
}
}
More information about the Flow
mailing list