/**
  * Try to map an ExpElement to a representative DataItem which may return null
  * if the attempt fails.
  *
  * @since 2.4
  *
  * @param ExpElement $expElement
  *
  * @return DataItem|null
  */
 public function tryToFindDataItemForExpElement(ExpElement $expElement)
 {
     $dataItem = null;
     if (!$expElement instanceof ExpResource) {
         return $dataItem;
     }
     $uri = $expElement->getUri();
     if (strpos($uri, $this->wikiNamespace) !== false) {
         $dataItem = $this->tryToMatchDataItemForWikiNamespaceUri($uri);
     } else {
         // Not in wikiNamespace therefore most likely an imported URI
         $dataItem = $this->tryToMatchDataItemForUnmatchedWikiNamespaceUri($uri);
     }
     return $dataItem;
 }
 private function doDeserializeChild($serialization)
 {
     if (!isset($serialization['subject'])) {
         return ExpElement::newFromSerialization($serialization);
     }
     $element = $this->newExpData($serialization['subject']);
     $this->doDeserialize($serialization, $element);
     return $element;
 }
 /**
  * @dataProvider serializationMissingElementProvider
  */
 public function testDeserializiationForMissingElementThrowsException($serialization)
 {
     $this->setExpectedException('RuntimeException');
     ExpElement::newFromSerialization($serialization);
 }
 /**
  * @since  2.2
  *
  * @return array
  */
 public function getSerialization()
 {
     $serialization = array('type' => self::TYPE_LITERAL, 'lexical' => $this->lexicalForm, 'datatype' => $this->datatype, 'lang' => $this->lang);
     return $serialization + parent::getSerialization();
 }
Esempio n. 5
0
 /**
  * @since  2.2
  *
  * @return array
  */
 public function getSerialization()
 {
     $serialization = array('type' => self::TYPE_RESOURCE, 'uri' => $this->getUri());
     return $serialization + parent::getSerialization();
 }
 /**
  * @dataProvider instanceProvider
  */
 public function testSerielization(ExpElement $element)
 {
     $serialization = ExpElement::newFromSerialization($element->getSerialization());
     $this->assertEquals($element->getDataItem(), $serialization->getDataItem());
 }