| @@ 17-57 (lines=41) @@ | ||
| 14 | use Zend\ServiceManager\FactoryInterface; |
|
| 15 | use Zend\ServiceManager\ServiceLocatorInterface; |
|
| 16 | ||
| 17 | class EntityRepositoryManagerFactory implements FactoryInterface |
|
| 18 | { |
|
| 19 | public function __invoke(ContainerInterface $container, $requestedName, array $options = null) |
|
| 20 | { |
|
| 21 | $options = $options ?: []; |
|
| 22 | ||
| 23 | $pluginManager = new EntityRepositoryManager($container, $options); |
|
| 24 | ||
| 25 | // If this is in a zend-mvc application, the ServiceListener will inject |
|
| 26 | // merged configuration during bootstrap. |
|
| 27 | if ($container->has('ServiceListener')) { |
|
| 28 | return $pluginManager; |
|
| 29 | } |
|
| 30 | ||
| 31 | // If we do not have a config service, nothing more to do |
|
| 32 | if (!$container->has('config')) { |
|
| 33 | return $pluginManager; |
|
| 34 | } |
|
| 35 | ||
| 36 | $config = $container->get('config'); |
|
| 37 | // If we do not have log_filters configuration, nothing more to do |
|
| 38 | if (!isset($config['entity_repository_manager']) || !is_array($config['entity_repository_manager'])) { |
|
| 39 | return $pluginManager; |
|
| 40 | } |
|
| 41 | // Wire service configuration for log_filters |
|
| 42 | (new Config($config['entity_repository_manager']))->configureServiceManager($pluginManager); |
|
| 43 | ||
| 44 | return $pluginManager; |
|
| 45 | } |
|
| 46 | ||
| 47 | public function createService(ServiceLocatorInterface $serviceLocator) |
|
| 48 | { |
|
| 49 | // @codeCoverageIgnoreStart |
|
| 50 | if (method_exists($serviceLocator, 'getServiceLocator')) { |
|
| 51 | $serviceLocator = $serviceLocator->getServiceLocator(); |
|
| 52 | } |
|
| 53 | // @codeCoverageIgnoreEnd |
|
| 54 | ||
| 55 | return $this($serviceLocator, ''); |
|
| 56 | } |
|
| 57 | } |
|
| 58 | ||
| @@ 17-57 (lines=41) @@ | ||
| 14 | use Zend\ServiceManager\FactoryInterface; |
|
| 15 | use Zend\ServiceManager\ServiceLocatorInterface; |
|
| 16 | ||
| 17 | class EntityServiceManagerFactory implements FactoryInterface |
|
| 18 | { |
|
| 19 | public function __invoke(ContainerInterface $container, $requestedName, array $options = null) |
|
| 20 | { |
|
| 21 | $options = $options ?: []; |
|
| 22 | ||
| 23 | $pluginManager = new EntityServiceManager($container, $options); |
|
| 24 | ||
| 25 | // If this is in a zend-mvc application, the ServiceListener will inject |
|
| 26 | // merged configuration during bootstrap. |
|
| 27 | if ($container->has('ServiceListener')) { |
|
| 28 | return $pluginManager; |
|
| 29 | } |
|
| 30 | ||
| 31 | // If we do not have a config service, nothing more to do |
|
| 32 | if (!$container->has('config')) { |
|
| 33 | return $pluginManager; |
|
| 34 | } |
|
| 35 | ||
| 36 | $config = $container->get('config'); |
|
| 37 | // If we do not have log_filters configuration, nothing more to do |
|
| 38 | if (!isset($config['entity_service_manager']) || !is_array($config['entity_service_manager'])) { |
|
| 39 | return $pluginManager; |
|
| 40 | } |
|
| 41 | // Wire service configuration for log_filters |
|
| 42 | (new Config($config['entity_service_manager']))->configureServiceManager($pluginManager); |
|
| 43 | ||
| 44 | return $pluginManager; |
|
| 45 | } |
|
| 46 | ||
| 47 | public function createService(ServiceLocatorInterface $serviceLocator) |
|
| 48 | { |
|
| 49 | // @codeCoverageIgnoreStart |
|
| 50 | if (method_exists($serviceLocator, 'getServiceLocator')) { |
|
| 51 | $serviceLocator = $serviceLocator->getServiceLocator(); |
|
| 52 | } |
|
| 53 | // @codeCoverageIgnoreEnd |
|
| 54 | ||
| 55 | return $this($serviceLocator, ''); |
|
| 56 | } |
|
| 57 | } |
|
| 58 | ||