1 | <?php |
||
21 | class DispatchingEntityLookup implements EntityLookup { |
||
22 | |||
23 | /** |
||
24 | * @var EntityLookup[] |
||
25 | */ |
||
26 | private $lookups; |
||
27 | |||
28 | /** |
||
29 | * @since 3.7 |
||
30 | * |
||
31 | * @param EntityLookup[] $lookups associative array with repository names (strings) as keys |
||
32 | * and EntityLookup objects as values. |
||
33 | * |
||
34 | * @throws ParameterAssertionException |
||
35 | */ |
||
36 | public function __construct( array $lookups ) { |
||
37 | Assert::parameter( |
||
38 | !empty( $lookups ), |
||
39 | '$lookups', |
||
40 | 'must must not be empty' |
||
41 | ); |
||
42 | Assert::parameterElementType( EntityLookup::class, $lookups, '$lookups' ); |
||
43 | RepositoryNameAssert::assertParameterKeysAreValidRepositoryNames( $lookups, '$lookups' ); |
||
44 | $this->lookups = $lookups; |
||
45 | } |
||
46 | |||
47 | /** |
||
48 | * @see EntityLookup::getEntity |
||
49 | * |
||
50 | * @since 3.7 |
||
51 | * |
||
52 | * @param EntityId $entityId |
||
53 | * |
||
54 | * @return null|EntityDocument |
||
55 | * @throws EntityLookupException |
||
56 | * @throws UnknownForeignRepositoryException |
||
57 | */ |
||
58 | public function getEntity( EntityId $entityId ) { |
||
59 | $lookup = $this->getLookupForEntityId( $entityId ); |
||
60 | return $lookup->getEntity( $entityId ); |
||
61 | } |
||
62 | |||
63 | /** |
||
64 | * @see EntityLookup::hasEntity |
||
65 | * |
||
66 | * @since 3.7 |
||
67 | * |
||
68 | * @param EntityId $entityId |
||
69 | * |
||
70 | * @return bool |
||
71 | * @throws EntityLookupException |
||
72 | * @throws UnknownForeignRepositoryException |
||
73 | */ |
||
74 | public function hasEntity( EntityId $entityId ) { |
||
78 | |||
79 | /** |
||
80 | * @param EntityId $entityId |
||
81 | * |
||
82 | * @return EntityLookup |
||
83 | * @throws UnknownForeignRepositoryException |
||
84 | */ |
||
85 | private function getLookupForEntityId( EntityId $entityId ) { |
||
92 | |||
93 | } |
||
94 |