Esempio n. 1
0
 /**
  * @param Fingerprint $fingerprint
  * @param EntityDiff $patch
  *
  * @throws InvalidArgumentException
  */
 public function patchFingerprint(Fingerprint $fingerprint, EntityDiff $patch)
 {
     $labels = $this->patcher->patch($fingerprint->getLabels()->toTextArray(), $patch->getLabelsDiff());
     $fingerprint->setLabels($this->newTermListFromArray($labels));
     $descriptions = $this->patcher->patch($fingerprint->getDescriptions()->toTextArray(), $patch->getDescriptionsDiff());
     $fingerprint->setDescriptions($this->newTermListFromArray($descriptions));
     $this->patchAliases($fingerprint, $patch->getAliasesDiff());
 }
 /**
  * Generates and returns an HTML visualization of the provided EntityDiff.
  *
  * @since 0.4
  *
  * @param EntityDiff $diff
  *
  * @return string
  */
 protected function visualizeEntityDiff(EntityDiff $diff)
 {
     if ($diff->isEmpty()) {
         return '';
     }
     $html = '';
     $termDiffVisualizer = new DiffView(array(), new Diff(array($this->context->getLanguage()->getMessage('wikibase-diffview-label') => $diff->getLabelsDiff(), $this->context->getLanguage()->getMessage('wikibase-diffview-alias') => $diff->getAliasesDiff(), $this->context->getLanguage()->getMessage('wikibase-diffview-description') => $diff->getDescriptionsDiff()), true), $this->siteStore, $this->entityIdFormatter, $this->context);
     $html .= $termDiffVisualizer->getHtml();
     foreach ($diff->getClaimsDiff() as $claimDiffOp) {
         $html .= $this->getClaimDiffHtml($claimDiffOp);
     }
     // FIXME: this does not belong here as it is specific to items
     if ($diff instanceof ItemDiff) {
         $linkDiffVisualizer = new DiffView(array(), new Diff(array($this->context->getLanguage()->getMessage('wikibase-diffview-link') => $diff->getSiteLinkDiff()), true), $this->siteStore, $this->entityIdFormatter, $this->context);
         $html .= $linkDiffVisualizer->getHtml();
     }
     return $html;
 }
Esempio n. 3
0
 /**
  * @dataProvider diffProvider
  */
 public function testGetLabelsDiff(EntityDiff $entityDiff)
 {
     $diff = $entityDiff->getLabelsDiff();
     $this->assertInstanceOf('Diff\\Diff', $diff);
     $this->assertTrue($diff->isAssociative());
 }