Skip to content
This repository has been archived by the owner on Oct 10, 2019. It is now read-only.

Commit

Permalink
Module's name is retrieving from controller class name
Browse files Browse the repository at this point in the history
  • Loading branch information
neilime committed Oct 10, 2013
1 parent c265de0 commit 6db54bf
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,19 @@ public function onBootstrap(\Zend\EventManager\EventInterface $oEvent){
* @param \Zend\Mvc\MvcEvent $oEvent
*/
public function renderAssets(\Zend\Mvc\MvcEvent $oEvent){
$oAssetsBundleService = $oEvent->getApplication()->getServiceManager()->get('AssetsBundleService');
$oAssetsBundleService->getOptions()->setRenderer($oEvent->getApplication()->getServiceManager()->get('ViewRenderer'));
$oServiceManager = $oEvent->getApplication()->getServiceManager();
$oAssetsBundleService = $oServiceManager->get('AssetsBundleService');
$oAssetsBundleService->getOptions()->setRenderer($oServiceManager->get('ViewRenderer'));

/* @var $oRouter \Zend\Mvc\Router\RouteMatch */
$oRouter = $oEvent->getRouteMatch();
if($oRouter instanceof \Zend\Mvc\Router\RouteMatch){
if($sControllerName = $oRouter->getParam('controller'))$sModuleName = current(explode('\\',ltrim($sControllerName,'\\')));

//Retrieve controller
if(
($sControllerName = $oRouter->getParam('controller'))
&& ($sControllerClass = get_class($oServiceManager->get('ControllerLoader')->get($sControllerName)))
)$sModuleName = substr($sControllerClass, 0, strpos($sControllerClass, '\\'));
$sActionName = $oRouter->getParam('action');
$oOptions = $oAssetsBundleService->getOptions()
->setControllerName($sControllerName);
Expand Down

0 comments on commit 6db54bf

Please sign in to comment.