|
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\Repository\Service; |
|
11
|
|
|
|
|
12
|
|
|
use PolderKnowledge\EntityService\Exception\InvalidServiceException; |
|
13
|
|
|
use PolderKnowledge\EntityService\Repository\Feature\DeletableInterface; |
|
14
|
|
|
use PolderKnowledge\EntityService\Repository\Feature\FlushableInterface; |
|
15
|
|
|
use PolderKnowledge\EntityService\Repository\Feature\ReadableInterface; |
|
16
|
|
|
use PolderKnowledge\EntityService\Repository\Feature\WritableInterface; |
|
17
|
|
|
use Zend\ServiceManager\AbstractPluginManager; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* Plugin manager for entity repositories used by entity services |
|
21
|
|
|
*/ |
|
22
|
|
|
class EntityRepositoryManager extends AbstractPluginManager |
|
23
|
|
|
{ |
|
24
|
|
|
/** |
|
25
|
|
|
* {@inheritDoc} |
|
26
|
|
|
*/ |
|
27
|
24 |
|
public function __construct($configInstanceOrParentLocator = null, array $config = []) |
|
28
|
|
|
{ |
|
29
|
24 |
|
parent::__construct($configInstanceOrParentLocator, $config); |
|
30
|
|
|
|
|
31
|
24 |
|
$this->autoAddInvokableClass = false; |
|
32
|
24 |
|
} |
|
33
|
|
|
|
|
34
|
|
|
|
|
35
|
|
|
// @codeCoverageIgnoreStart |
|
36
|
|
|
public function validatePlugin($plugin) |
|
|
|
|
|
|
37
|
|
|
{ |
|
38
|
|
|
} |
|
39
|
|
|
// @codeCoverageIgnoreEnd |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* {@inheritDoc} |
|
43
|
|
|
*/ |
|
44
|
15 |
|
public function validate($instance) |
|
45
|
|
|
{ |
|
46
|
15 |
|
if ($instance instanceof DeletableInterface || |
|
47
|
12 |
|
$instance instanceof FlushableInterface || |
|
48
|
9 |
|
$instance instanceof ReadableInterface || |
|
49
|
15 |
|
$instance instanceof WritableInterface) { |
|
50
|
12 |
|
return; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
3 |
|
throw new InvalidServiceException(sprintf( |
|
54
|
3 |
|
'Plugin manager "%s" expected a type of %s, %s, %s or %s but received "%s"', |
|
55
|
3 |
|
__CLASS__, |
|
56
|
3 |
|
DeletableInterface::class, |
|
57
|
3 |
|
FlushableInterface::class, |
|
58
|
3 |
|
ReadableInterface::class, |
|
59
|
3 |
|
WritableInterface::class, |
|
60
|
3 |
|
is_object($instance) ? get_class($instance) : gettype($instance) |
|
61
|
3 |
|
)); |
|
62
|
|
|
} |
|
63
|
|
|
} |
|
64
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.