Commit | Line | Data |
---|---|---|
44d399bc S |
1 | <?php |
2 | /** | |
3 | * Zend Framework (http://framework.zend.com/) | |
4 | * | |
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 | |
8 | */ | |
9 | ||
10 | namespace Zend\Mvc\Service; | |
11 | ||
12 | use Interop\Container\ContainerInterface; | |
13 | use Zend\Mvc\Controller\ControllerManager; | |
14 | use Zend\ServiceManager\FactoryInterface; | |
15 | use Zend\ServiceManager\ServiceLocatorInterface; | |
16 | ||
17 | class ControllerManagerFactory implements FactoryInterface | |
18 | { | |
19 | /** | |
20 | * Create the controller manager service | |
21 | * | |
22 | * Creates and returns an instance of ControllerManager. The | |
23 | * only controllers this manager will allow are those defined in the | |
24 | * application configuration's "controllers" array. If a controller is | |
25 | * matched, the scoped manager will attempt to load the controller. | |
26 | * Finally, it will attempt to inject the controller plugin manager | |
27 | * if the controller implements a setPluginManager() method. | |
28 | * | |
29 | * @param ContainerInterface $container | |
30 | * @param string $Name | |
31 | * @param null|array $options | |
32 | * @return ControllerManager | |
33 | */ | |
34 | public function __invoke(ContainerInterface $container, $name, array $options = null) | |
35 | { | |
36 | if ($options) { | |
37 | return new ControllerManager($container, $options); | |
38 | } | |
39 | return new ControllerManager($container); | |
40 | } | |
41 | ||
42 | /** | |
43 | * Create and return ControllerManager instance | |
44 | * | |
45 | * For use with zend-servicemanager v2; proxies to __invoke(). | |
46 | * | |
47 | * @param ServiceLocatorInterface $container | |
48 | * @return ControllerManager | |
49 | */ | |
50 | public function createService(ServiceLocatorInterface $container) | |
51 | { | |
52 | return $this($container, ControllerManager::class); | |
53 | } | |
54 | } |