Open Source Content Management System

midgard_replicator method unserialize

  1. Examples

Unserializes xml content.

array unserialize(string xml, [bool force]);

Minimum version: 1.8.1 ( second optional parameter has been added in Midgard 1.8.2 )

This method takes two parameters:

  • xml , valid xml content from which an object instance should be created.
  • force , optional boolean value

Returns new array with objects if xml content has been succesfuly read and parsed , empty array otherwise.

This method "translates" object's properties ( of integer type if defined as links ) to particular object's guids. Such "translation" is not made when second optional force parameter is set to TRUE. In such case ,object's property is reset to default 0 value.

Properties which hold guid values ( like metadata.creator ) are not changed and no validation is done for such properties. It means that object is imported as is with such properties and application is responsible ( if needed ) to create logic of missed dependencies.

This method also unserializes purged objects. In such case object has three properties set:

  • guid ,object identifier
  • action set as "purged"
  • metadata.revised set with datetime when object has been purged

You should use:

Examples

$xml = $POST['xml_content'];

$objects = midgard_replicator::unserialize($xml);

foreach( $objects as $object )
{
     if($object->action == 'purged') 
     {
         echo "Object identified by $object->guid is purged!";
         echo "Do you want to import it?"; 
     }
}

PHP midgard_replicator

Designed by Nemein, hosted by Anykey