/** * @param EntityId $entityId * * @throws RedirectCreationException */ private function checkExistsNoRedirect(EntityId $entityId) { try { $redirect = $this->entityRedirectLookup->getRedirectForEntityId($entityId, 'for update'); } catch (EntityRedirectLookupException $ex) { throw new RedirectCreationException($ex->getMessage(), 'no-such-entity', $ex); } if ($redirect !== null) { throw new RedirectCreationException("Entity {$entityId} is a redirect", 'target-is-redirect'); } }
/** * Load the sitelink using a SiteLinkLookup. Resolves item redirects, if needed. * * @param string $site * @param ItemId $itemId * * @return array[] */ private function loadLinks($site, ItemId $itemId) { $links = $this->siteLinkLookup->getLinks(array($itemId->getNumericId()), array($site)); if (isset($links[0])) { return $links; } // Maybe the item is a redirect: Try to resolve the redirect and load // the links from there. $redirectTarget = $this->redirectLookup->getRedirectForEntityId($itemId); if ($redirectTarget instanceof ItemId) { return $this->siteLinkLookup->getLinks(array($redirectTarget->getNumericId()), array($site)); } return array(); }