示例#1
0
 /**
  * Creates and returns a new SWLPropertyChange instance from a serialization.
  *
  * @param string|null $oldValue
  * @param string|null $newValue
  *
  * @return SWLPropertyChange
  */
 public static function newFromSerialization(SMWDIProperty $property, $oldValue, $newValue)
 {
     $diType = SMWDataValueFactory::getDataItemId($property->findPropertyTypeID());
     //var_dump($property);
     //if($diType!=7) {throw new Exception();exit;}
     return new self(is_null($oldValue) ? null : SMWDataItem::newFromSerialization($diType, $oldValue), is_null($newValue) ? null : SMWDataItem::newFromSerialization($diType, $newValue));
 }
	/**
	 * Creates and returns a new SWLPropertyChange instance from a serialization.
	 *
	 * @param string|null $oldValue
	 * @param string|null $newValue
	 *
	 * @return SWLPropertyChange
	 */
	public static function newFromSerialization( SMWDIProperty $property, $oldValue, $newValue ) {
		$diType = SMWDataValueFactory::getDataItemId( $property->findPropertyTypeID() );

		return new self(
			is_null( $oldValue ) ? null : SMWDataItem::newFromSerialization( $diType, $oldValue ),
			is_null( $newValue ) ? null : SMWDataItem::newFromSerialization( $diType, $newValue )
		);
	}
 /**
  * @see ExpElement::newFromSerialization
  */
 protected static function deserialize($serialization)
 {
     $dataItem = null;
     if (!array_key_exists('dataitem', $serialization)) {
         throw new RuntimeException("The serialization format is missing a dataitem element");
     }
     // If it is null, isset will ignore it
     if (isset($serialization['dataitem'])) {
         $dataItem = DataItem::newFromSerialization($serialization['dataitem']['type'], $serialization['dataitem']['item']);
     }
     return $dataItem;
 }
 /**
  * @return DataItem
  */
 protected function unserializeDataItem($property, $data, $value, $semanticData)
 {
     $dataItem = null;
     $type = $this->getDataItemId($property);
     // Verify that the current property type definition and the type of the
     // property during serialization do match, throw an error value to avoid any
     // exception during unserialization caused by the DataItem object due to a
     // mismatch of type definitions
     if ($type === $value['type']) {
         $dataItem = DataItem::newFromSerialization($value['type'], $value['item']);
     } else {
         $dataItem = $property->getDiWikiPage();
         $property = new DIProperty(DIProperty::TYPE_ERROR);
         $semanticData->addError(array(new ErrorValue($type, 'type mismatch', $property->getLabel())));
     }
     // Check whether the current dataItem has a subobject reference
     if ($dataItem->getDIType() === DataItem::TYPE_WIKIPAGE && $dataItem->getSubobjectName() !== '') {
         $dataItem = $this->unserializeSubobject($data, $value['item'], new SMWContainerSemanticData($dataItem));
     }
     // Ensure that errors are collected from a subobject level as well and
     // made available at the top
     if ($dataItem instanceof DIContainer) {
         $semanticData->addError($dataItem->getSemanticData()->getErrors());
     }
     if ($property !== null && $dataItem !== null) {
         $semanticData->addPropertyObjectValue($property, $dataItem);
     }
 }
 /**
  * @since 2.2
  *
  * @return DataItem[]
  */
 public function getExpectedDataItems()
 {
     $dataItems = array();
     if (!isset($this->contents['queryresult']['dataitems'])) {
         return $dataItems;
     }
     foreach ($this->contents['queryresult']['dataitems'] as $dataitem) {
         $dataItems[] = DataItem::newFromSerialization(DataTypeRegistry::getInstance()->getDataItemId($dataitem['type']), $dataitem['value']);
     }
     return $dataItems;
 }