| 1 | <?php |
||
| 14 | class EntityApiLookup implements EntityLookup { |
||
| 15 | |||
| 16 | private RevisionGetter $revisionGetter; |
||
|
|
|||
| 17 | |||
| 18 | /** |
||
| 19 | * @param RevisionGetter $revisionGetter |
||
| 20 | */ |
||
| 21 | public function __construct( RevisionGetter $revisionGetter ) { |
||
| 22 | $this->revisionGetter = $revisionGetter; |
||
| 23 | } |
||
| 24 | |||
| 25 | /** |
||
| 26 | * @see EntityLookup::getEntity |
||
| 27 | * @return null|mixed |
||
| 28 | */ |
||
| 29 | public function getEntity( EntityId $entityId ) { |
||
| 30 | $revision = $this->revisionGetter->getFromId( $entityId ); |
||
| 31 | |||
| 32 | if ( !$revision ) { |
||
| 33 | return null; |
||
| 34 | } |
||
| 35 | |||
| 36 | return $revision->getContent()->getData(); |
||
| 37 | } |
||
| 38 | |||
| 39 | /** |
||
| 40 | * @see EntityLookup::hasEntity |
||
| 41 | * @return bool |
||
| 42 | */ |
||
| 43 | public function hasEntity( EntityId $entityId ) { |
||
| 44 | $revision = $this->revisionGetter->getFromId( $entityId ); |
||
| 45 | return (bool)$revision; |
||
| 46 | } |
||
| 47 | } |
||
| 48 |