Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@Mischosch
Created September 17, 2011 19:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mischosch/9f226c2ce591c0dbf3e1 to your computer and use it in GitHub Desktop.
Save Mischosch/9f226c2ce591c0dbf3e1 to your computer and use it in GitHub Desktop.
Module based dispatch approach
protected function dispatch($routeMatch)
{
$events = $this->events();
$params = compact('routeMatch');
$result = $events->triggerUntil('dispatch.pre', $this, $params, function($result) {
return ($result instanceof Response);
});
if ($result->stopped()) {
return $result->last();
}
$moduleName = $routeMatch->getParam('module', null);
$controllerName = $routeMatch->getParam('controller', 'not-found');
$locator = $this->getLocator();
try {
if (!empty($moduleName)) {
$controller = $locator->get($moduleName . '_' . $controllerName);
} else {
$controller = $locator->get($controllerName);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment