use zend router
[GitHub/Stricted/Domain-Control-Panel.git] / vendor / Zend / Mvc / Service / DiAbstractServiceFactoryFactory.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\Mvc\Exception;
14 use Zend\ServiceManager\Di\DiAbstractServiceFactory;
15 use Zend\ServiceManager\FactoryInterface;
16 use Zend\ServiceManager\ServiceLocatorInterface;
17 use Zend\ServiceManager\ServiceManager;
18
19 /**
20 * @deprecated Since 2.7.9. The factory is now defined in zend-servicemanager-di,
21 * and removed in 3.0.0. Use Zend\ServiceManager\Di\DiAbstractServiceFactoryFactory
22 * from zend-servicemanager-di if you are using zend-servicemanager v3, and/or when
23 * ready to migrate to zend-mvc 3.0.
24 */
25 class DiAbstractServiceFactoryFactory implements FactoryInterface
26 {
27 /**
28 * Class responsible for instantiating a DiAbstractServiceFactory
29 *
30 * @param ContainerInterface $container
31 * @param string $name
32 * @param null|array $options
33 * @return DiAbstractServiceFactory
34 * @throws Exception\RuntimeException if zend-servicemanager v3 is in use.
35 */
36 public function __invoke(ContainerInterface $container, $name, array $options = null)
37 {
38 if (! class_exists(DiAbstractServiceFactory::class)) {
39 throw new Exception\RuntimeException(sprintf(
40 "%s is not compatible with zend-servicemanager v3, which you are currently using. \n"
41 . "Please run 'composer require zendframework/zend-servicemanager-di', and then update\n"
42 . "your configuration to use Zend\ServiceManager\Di\DiAbstractServiceFactoryFactory instead.",
43 __CLASS__
44 ));
45 }
46
47 $factory = new DiAbstractServiceFactory($container->get('Di'), DiAbstractServiceFactory::USE_SL_BEFORE_DI);
48
49 if ($container instanceof ServiceManager) {
50 $container->addAbstractFactory($factory, false);
51 }
52
53 return $factory;
54 }
55
56 /**
57 * Create and return DiAbstractServiceFactory instance
58 *
59 * For use with zend-servicemanager v2; proxies to __invoke().
60 *
61 * @param ServiceLocatorInterface $container
62 * @return DiAbstractServiceFactory
63 */
64 public function createService(ServiceLocatorInterface $container)
65 {
66 return $this($container, DiAbstractServiceFactory::class);
67 }
68 }