/**
  * Generates the HTML for a Reference object.
  *
  * @param Reference $reference
  *
  * @return string HTML
  */
 private function getHtmlForReference(Reference $reference)
 {
     $snaks = $reference->getSnaks();
     $referenceSnaksByProperty = new ByPropertyIdGrouper($snaks);
     $snaklistviewsHtml = '';
     foreach ($referenceSnaksByProperty->getPropertyIds() as $propertyId) {
         $snaklistviewsHtml .= $this->getSnaklistviewHtml($referenceSnaksByProperty->getByPropertyId($propertyId));
     }
     return $this->templateFactory->render('wikibase-referenceview', 'wikibase-referenceview-' . $reference->getHash(), $snaklistviewsHtml);
 }
예제 #2
0
 public function testCanConstructWithSnakArray()
 {
     $snaks = array(new PropertyNoValueSnak(1), new PropertyNoValueSnak(3), new PropertyNoValueSnak(2));
     $reference = new Reference($snaks);
     $this->assertEquals(new SnakList($snaks), $reference->getSnaks());
 }
예제 #3
0
 /**
  * Validate a list of references.
  * This is done by validating all snaks in all of the references.
  *
  * @param Reference $reference
  *
  * @return Result
  */
 public function validateReference(Reference $reference)
 {
     foreach ($reference->getSnaks() as $snak) {
         $result = $this->validate($snak);
         if (!$result->isValid()) {
             return $result;
         }
     }
     return Result::newSuccess();
 }
예제 #4
0
 private function getSerialized(Reference $reference)
 {
     return array('hash' => $reference->getHash(), 'snaks' => $this->snaksSerializer->serialize($reference->getSnaks()), 'snaks-order' => $this->buildSnakListOrderList($reference->getSnaks()));
 }