| 1 | <?php |
||
| 2 | |||
| 3 | namespace Wikibase\DataModel\Services\Lookup; |
||
| 4 | |||
| 5 | use Wikibase\DataModel\Entity\Property; |
||
| 6 | use Wikibase\DataModel\Entity\PropertyId; |
||
| 7 | |||
| 8 | /** |
||
| 9 | * PropertyLookup implementation providing a migration path away from |
||
| 10 | * the EntityLookup interface. |
||
| 11 | * |
||
| 12 | * @license GPL-2.0-or-later |
||
| 13 | * @author Jeroen De Dauw < [email protected] > |
||
| 14 | */ |
||
| 15 | class LegacyAdapterPropertyLookup implements PropertyLookup { |
||
| 16 | |||
| 17 | private EntityLookup $lookup; |
||
| 18 | |||
| 19 | public function __construct( EntityLookup $lookup ) { |
||
| 20 | $this->lookup = $lookup; |
||
| 21 | } |
||
| 22 | |||
| 23 | /** |
||
| 24 | * @param PropertyId $propertyId |
||
| 25 | * |
||
| 26 | * @return Property|null |
||
| 27 | * @throws PropertyLookupException |
||
| 28 | */ |
||
| 29 | public function getPropertyForId( PropertyId $propertyId ) { |
||
| 30 | try { |
||
| 31 | return $this->lookup->getEntity( $propertyId ); |
||
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||
| 32 | } catch ( EntityLookupException $ex ) { |
||
| 33 | throw new PropertyLookupException( $propertyId, $ex->getMessage(), $ex ); |
||
| 34 | } |
||
| 35 | } |
||
| 36 | |||
| 37 | } |
||
| 38 |