1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Polder Knowledge / entityservice-module (https://polderknowledge.com) |
4
|
|
|
* |
5
|
|
|
* @link https://github.com/polderknowledge/entityservice-module for the canonical source repository |
6
|
|
|
* @copyright Copyright (c) 2016 Polder Knowledge (https://polderknowledge.com) |
7
|
|
|
* @license https://github.com/polderknowledge/entityservice-module/blob/master/LICENSE.md MIT |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace PolderKnowledge\EntityService\Service; |
11
|
|
|
|
12
|
|
|
use Interop\Container\ContainerInterface; |
13
|
|
|
use Zend\ServiceManager\Config; |
14
|
|
|
use Zend\ServiceManager\FactoryInterface; |
15
|
|
|
use Zend\ServiceManager\ServiceLocatorInterface; |
16
|
|
|
|
17
|
|
View Code Duplication |
class EntityServiceManagerFactory implements FactoryInterface |
|
|
|
|
18
|
|
|
{ |
19
|
12 |
|
public function __invoke(ContainerInterface $container, $requestedName, array $options = null) |
20
|
|
|
{ |
21
|
12 |
|
$options = $options ?: []; |
22
|
|
|
|
23
|
12 |
|
$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
|
12 |
|
if ($container->has('ServiceListener')) { |
28
|
3 |
|
return $pluginManager; |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
// If we do not have a config service, nothing more to do |
32
|
9 |
|
if (!$container->has('config')) { |
33
|
6 |
|
return $pluginManager; |
34
|
|
|
} |
35
|
|
|
|
36
|
3 |
|
$config = $container->get('config'); |
37
|
|
|
// If we do not have log_filters configuration, nothing more to do |
38
|
3 |
|
if (!isset($config['entity_service_manager']) || !is_array($config['entity_service_manager'])) { |
39
|
|
|
return $pluginManager; |
40
|
|
|
} |
41
|
|
|
// Wire service configuration for log_filters |
42
|
3 |
|
(new Config($config['entity_service_manager']))->configureServiceManager($pluginManager); |
43
|
|
|
|
44
|
3 |
|
return $pluginManager; |
45
|
|
|
} |
46
|
|
|
|
47
|
3 |
|
public function createService(ServiceLocatorInterface $serviceLocator) |
48
|
|
|
{ |
49
|
|
|
// @codeCoverageIgnoreStart |
50
|
|
|
if (method_exists($serviceLocator, 'getServiceLocator')) { |
51
|
|
|
$serviceLocator = $serviceLocator->getServiceLocator(); |
52
|
|
|
} |
53
|
|
|
// @codeCoverageIgnoreEnd |
54
|
|
|
|
55
|
3 |
|
return $this($serviceLocator, ''); |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
|
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.