use zend router
[GitHub/Stricted/Domain-Control-Panel.git] / vendor / Zend / Mvc / Service / DiFactory.php
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\Di\Config;
14 use Zend\Di\Di;
15 use Zend\ServiceManager\FactoryInterface;
16 use Zend\ServiceManager\ServiceLocatorInterface;
17
18 /**
19 * @deprecated Since 2.7.9. The factory is now defined in zend-servicemanager-di,
20 * and removed in 3.0.0. Use Zend\ServiceManager\Di\DiFactory from
21 * from zend-servicemanager-di if you are using zend-servicemanager v3, and/or when
22 * ready to migrate to zend-mvc 3.0.
23 */
24 class DiFactory implements FactoryInterface
25 {
26 /**
27 * Create and return abstract factory seeded by dependency injector
28 *
29 * Creates and returns an abstract factory seeded by the dependency
30 * injector. If the "di" key of the configuration service is set, that
31 * sub-array is passed to a DiConfig object and used to configure
32 * the DI instance. The DI instance is then used to seed the
33 * DiAbstractServiceFactory, which is then registered with the service
34 * manager.
35 *
36 * @param ContainerInterface $container
37 * @param string $name
38 * @param null|array $options
39 * @return Di
40 */
41 public function __invoke(ContainerInterface $container, $name, array $options = null)
42 {
43 $di = new Di();
44 $config = $container->has('config') ? $container->get('config') : [];
45
46 if (isset($config['di'])) {
47 (new Config($config['di']))->configure($di);
48 }
49
50 return $di;
51 }
52
53 /**
54 * Create and return Di instance
55 *
56 * For use with zend-servicemanager v2; proxies to __invoke().
57 *
58 * @param ServiceLocatorInterface $container
59 * @return Di
60 */
61 public function createService(ServiceLocatorInterface $container)
62 {
63 return $this($container, Di::class);
64 }
65 }