/** * 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); }
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()); }
/** * 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(); }
private function getSerialized(Reference $reference) { return array('hash' => $reference->getHash(), 'snaks' => $this->snaksSerializer->serialize($reference->getSnaks()), 'snaks-order' => $this->buildSnakListOrderList($reference->getSnaks())); }