3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
10 namespace Zend\Mvc\Service
;
12 use Zend\Mvc\Controller\ControllerManager
;
13 use Zend\ServiceManager\FactoryInterface
;
14 use Zend\ServiceManager\ServiceLocatorInterface
;
17 * @see \Zend\Mvc\Service\ControllerManagerFactory
18 * @deprecated please use Zend\Mvc\Service\ControllerManagerFactory instead;
19 * this class will be removed in release 3.0
21 class ControllerLoaderFactory
implements FactoryInterface
24 * Create the controller loader service
26 * Creates and returns an instance of ControllerManager. The
27 * only controllers this manager will allow are those defined in the
28 * application configuration's "controllers" array. If a controller is
29 * matched, the scoped manager will attempt to load the controller.
30 * Finally, it will attempt to inject the controller plugin manager
31 * if the controller implements a setPluginManager() method.
33 * This plugin manager is _not_ peered against DI, and as such, will
34 * not load unknown classes.
36 * @param ServiceLocatorInterface $serviceLocator
37 * @return ControllerManager
39 public function createService(ServiceLocatorInterface
$serviceLocator)
41 trigger_error(sprintf(
42 '%s is deprecated; please use %s instead',
44 ControllerManagerFactory
::class
45 ), E_USER_DEPRECATED
);
47 $controllerLoader = new ControllerManager($serviceLocator);
48 $controllerLoader->addPeeringServiceManager($serviceLocator);
50 $config = $serviceLocator->get('Config');
52 if (isset($config['di']) && isset($config['di']['allowed_controllers']) && $serviceLocator->has('Di')) {
53 $controllerLoader->addAbstractFactory($serviceLocator->get('DiStrictAbstractServiceFactory'));
56 return $controllerLoader;