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 PolderKnowledge\EntityService\EntityService; |
14
|
|
|
use Zend\ServiceManager\AbstractFactoryInterface; |
15
|
|
|
use Zend\ServiceManager\ServiceLocatorInterface; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Abstract service factory to create a DefaultEntityService |
19
|
|
|
*/ |
20
|
|
|
class EntityServiceAbstractServiceFactory implements AbstractFactoryInterface |
|
|
|
|
21
|
|
|
{ |
22
|
|
|
const REPOSITORY_SERVICE_KEY = 'EntityRepositoryManager'; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* {@inheritdoc} |
26
|
|
|
*/ |
27
|
9 |
|
public function canCreate(ContainerInterface $container, $requestedName) |
28
|
|
|
{ |
29
|
9 |
|
return class_exists($requestedName); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* {@inheritdoc} |
34
|
|
|
*/ |
35
|
3 |
|
public function __invoke(ContainerInterface $container, $requestedName, array $options = null) |
36
|
|
|
{ |
37
|
3 |
|
$entityRepositoryManager = $container->get(self::REPOSITORY_SERVICE_KEY, $options); |
|
|
|
|
38
|
|
|
|
39
|
3 |
|
return new EntityService($entityRepositoryManager->get($requestedName), $requestedName); |
40
|
|
|
} |
41
|
|
|
|
42
|
3 |
|
public function canCreateServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName) |
43
|
|
|
{ |
44
|
3 |
|
return $this->canCreate($serviceLocator, $requestedName); |
45
|
|
|
} |
46
|
|
|
|
47
|
3 |
|
public function createServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName) |
48
|
|
|
{ |
49
|
|
|
// @codeCoverageIgnoreStart |
50
|
|
|
if (method_exists($serviceLocator, 'getServiceLocator')) { |
51
|
|
|
$serviceLocator = $serviceLocator->getServiceLocator(); |
52
|
|
|
} |
53
|
|
|
// @codeCoverageIgnoreEnd |
54
|
|
|
|
55
|
3 |
|
return $this($serviceLocator, $requestedName); |
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.