/** * @see EntityHolder::getEntityId * * This implements lazy initialization of the entity: when called for the first time, * this method will call getEntity() on the EntityHolder passed to the constructor, * and then deep clone the entity returned. The resulting copy is returned. * Subsequent calls will return the same entity. * * @param string $expectedClass The class with which the result is expected to be compatible. * Defaults to EntityDocument. * * @throws RuntimeException If the entity held by this EntityHolder is not compatible with $expectedClass. * @return EntityDocument */ public function getEntity($expectedClass = 'Wikibase\\DataModel\\Entity\\EntityDocument') { if (!$this->entity) { $entity = $this->entityHolder->getEntity($expectedClass); $this->entity = unserialize(serialize($entity)); } return $this->entity; }
/** * Returns the Item that makes up this ItemContent. * * @throws MWException when it's a redirect (targets will never be resolved) * @throws LogicException * @return Item */ public function getItem() { $redirect = $this->getRedirectTarget(); if ($redirect) { throw new MWException('Unresolved redirect to [[' . $redirect->getFullText() . ']]'); } if (!$this->itemHolder) { throw new LogicException('Neither redirect nor item found in ItemContent!'); } return $this->itemHolder->getEntity('Wikibase\\DataModel\\Entity\\Item'); }
/** * Gets the property that makes up this property content. * * @return Property */ public function getProperty() { return $this->propertyHolder->getEntity('Wikibase\\DataModel\\Entity\\Property'); }
/** * @return MediaInfo */ public function getMedium() { return $this->mediumHolder->getEntity('WikibaseMedia\\DataModel\\Medium'); }