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 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
;
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.
25 class DiAbstractServiceFactoryFactory
implements FactoryInterface
28 * Class responsible for instantiating a DiAbstractServiceFactory
30 * @param ContainerInterface $container
32 * @param null|array $options
33 * @return DiAbstractServiceFactory
34 * @throws Exception\RuntimeException if zend-servicemanager v3 is in use.
36 public function __invoke(ContainerInterface
$container, $name, array $options = null)
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.",
47 $factory = new DiAbstractServiceFactory($container->get('Di'), DiAbstractServiceFactory
::USE_SL_BEFORE_DI
);
49 if ($container instanceof ServiceManager
) {
50 $container->addAbstractFactory($factory, false);
57 * Create and return DiAbstractServiceFactory instance
59 * For use with zend-servicemanager v2; proxies to __invoke().
61 * @param ServiceLocatorInterface $container
62 * @return DiAbstractServiceFactory
64 public function createService(ServiceLocatorInterface
$container)
66 return $this($container, DiAbstractServiceFactory
::class);