示例#1
0
 protected function addToOutput(Entity $entity, Status $status, $oldRevId = null)
 {
     $this->getResultBuilder()->addBasicEntityInformation($entity->getId(), 'entity');
     $this->getResultBuilder()->addRevisionIdFromStatusToResult($status, 'entity', $oldRevId);
     $params = $this->extractRequestParams();
     if (isset($params['site']) && isset($params['title'])) {
         $normTitle = $this->stringNormalizer->trimToNFC($params['title']);
         if ($normTitle !== $params['title']) {
             $this->getResultBuilder()->addNormalizedTitle($params['title'], $normTitle, 'normalized');
         }
     }
     $this->getResultBuilder()->markSuccess(1);
 }
 /**
  * Tries to find item id for given siteId and title combination
  *
  * @param string $siteId
  * @param string $title
  * @param bool $normalize
  *
  * @return ItemId|null
  */
 private function getItemId($siteId, $title, $normalize)
 {
     // FIXME: This code is duplicated in SpecialItemByTitle::execute!
     $title = $this->stringNormalizer->trimToNFC($title);
     $id = $this->siteLinkLookup->getItemIdForLink($siteId, $title);
     // Try harder by requesting normalization on the external site.
     if ($id === null && $normalize === true) {
         $siteObj = $this->siteStore->getSite($siteId);
         //XXX: this passes the normalized title back into $title by reference...
         $this->normalizeTitle($title, $siteObj);
         $id = $this->siteLinkLookup->getItemIdForLink($siteObj->getGlobalId(), $title);
     }
     return $id;
 }
 /**
  * Trims leading and trailing whitespace and performs unicode normalization
  * by calling Wikibase\StringNormalizer::trimToNFC().
  *
  * @see StringNormalizer::normalize()
  * @see Wikibase\StringNormalizer::trimToNFC()
  *
  * @param string $value the value to normalize
  *
  * @throws InvalidArgumentException if $value is not a string
  * @return string the normalized value
  */
 public function normalize($value)
 {
     return $this->normalizer->trimToNFC($value);
 }