Page MenuHomePhabricator
Paste P664

Example to fetch a statement from Wikibase
ActivePublic

Authored by Bene on May 20 2015, 7:18 PM.
Tags
None
Referenced Files
F167384: Example to fetch a statement from Wikibase
May 20 2015, 7:18 PM
Subscribers
None
$entityLookup = Wikibase\Client\WikibaseClient::getDefaultInstance()->getStore()->getEntityLookup();
/** @var Wikibase\DataModel\Entity\Item $item */
$item = $entityLookup->getEntity( new Wikibase\DataModel\Entity\ItemId( $prefixedId ) );
$statements = $item->getStatements()->getWithPropertyId( new Wikibase\DataModel\Entity\PropertyId( $bannerPropertyId ) )->getBestStatements();
if ( !$statements->isEmpty() ) {
$statements = $statements->toArray();
$snak = $statements[0]->getMainSnak();
if ( $snak instanceof Wikibase\DataModel\Snak\PropertyValueSnak ) {
$banner = $snak->getDataValue()->getValue();
}
}

Event Timeline

Bene changed the title of this paste from untitled to Example to fetch a statement from Wikibase.
Bene updated the paste's language from autodetect to php.