Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Commit

Permalink
[#4962] Updated code to use ControllerManager
Browse files Browse the repository at this point in the history
- Original commit adds the alias for ControllerManager; this commit updates code
  to use that alias. Some tests needed to be updated as well.
  • Loading branch information
weierophinney committed Oct 23, 2013
1 parent e0e5aa6 commit 7ab9530
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 9 deletions.
8 changes: 4 additions & 4 deletions library/Zend/Mvc/Controller/Plugin/Service/ForwardFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class ForwardFactory implements FactoryInterface
* {@inheritDoc}
*
* @return Forward
* @throws ServiceNotCreatedException if ControllerLoader service is not found in application service locator
* @throws ServiceNotCreatedException if Controllermanager service is not found in application service locator
*/
public function createService(ServiceLocatorInterface $plugins)
{
Expand All @@ -32,14 +32,14 @@ public function createService(ServiceLocatorInterface $plugins)
));
}

if (!$services->has('ControllerLoader')) {
if (!$services->has('ControllerManager')) {
throw new ServiceNotCreatedException(sprintf(
'%s requires that the application service manager contains a "%s" service; none found',
__CLASS__,
'ControllerLoader'
'ControllerManager'
));
}
$controllers = $services->get('ControllerLoader');
$controllers = $services->get('ControllerManager');

return new Forward($controllers);
}
Expand Down
4 changes: 2 additions & 2 deletions library/Zend/Mvc/DispatchListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
/**
* Default dispatch listener
*
* Pulls controllers from the service manager's "ControllerLoader" service.
* Pulls controllers from the service manager's "ControllerManager" service.
*
* If the controller cannot be found a "404" result is set up. Otherwise it
* will continue to try to load the controller.
Expand Down Expand Up @@ -86,7 +86,7 @@ public function onDispatch(MvcEvent $e)
$controllerName = $routeMatch->getParam('controller', 'not-found');
$application = $e->getApplication();
$events = $application->getEventManager();
$controllerLoader = $application->getServiceManager()->get('ControllerLoader');
$controllerLoader = $application->getServiceManager()->get('ControllerManager');

if (!$controllerLoader->has($controllerName)) {
$return = $this->marshalControllerNotFoundEvent($application::ERROR_CONTROLLER_NOT_FOUND, $controllerName, $e, $application);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ protected function getControllerFullClassName()
{
$routeMatch = $this->getApplication()->getMvcEvent()->getRouteMatch();
$controllerIdentifier = $routeMatch->getParam('controller');
$controllerManager = $this->getApplicationServiceLocator()->get('ControllerLoader');
$controllerManager = $this->getApplicationServiceLocator()->get('ControllerManager');
$controllerClass = $controllerManager->get($controllerIdentifier);
return get_class($controllerClass);
}
Expand Down
1 change: 1 addition & 0 deletions tests/ZendTest/Mvc/ApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public function setUp()
'aliases' => array(
'Router' => 'HttpRouter',
'Configuration' => 'Config',
'ControllerManager' => 'ControllerLoader',
),
))
);
Expand Down
6 changes: 4 additions & 2 deletions tests/ZendTest/Mvc/Controller/Plugin/ForwardTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,11 @@ public function setUp()
return $controller;
});
$controllers->setServiceLocator($services);
$services->add('ControllerLoader', function () use ($controllers) {
$controllerLoader = function () use ($controllers) {
return $controllers;
});
};
$services->add('ControllerLoader', $controllerLoader);
$services->add('ControllerManager', $controllerLoader);
$services->add('ControllerPluginManager', function () use ($plugins) {
return $plugins;
});
Expand Down
1 change: 1 addition & 0 deletions tests/ZendTest/Mvc/DispatchListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public function setUp()
'aliases' => array(
'Router' => 'HttpRouter',
'Configuration' => 'Config',
'ControllerManager' => 'ControllerLoader',
),
))
);
Expand Down

0 comments on commit 7ab9530

Please sign in to comment.