Horde_Kolab_Storage_Object::unserialize PHP Méthode

unserialize() public méthode

Unserialization.
public unserialize ( string $data )
$data string Serialized data.
    public function unserialize($data)
    {
        $data = @unserialize($data);
        if (!is_array($data)) {
            throw new Horde_Kolab_Storage_Object_Exception('Cache data invalid');
        }
        if (isset($data[self::SERIALIZATION_DATA])) {
            $this->_data = $data[self::SERIALIZATION_DATA];
        }
        if (isset($data[self::SERIALIZATION_ERRORS])) {
            $this->_errors = $data[self::SERIALIZATION_ERRORS];
        }
        if (isset($data[self::SERIALIZATION_TYPE])) {
            $this->_type = $data[self::SERIALIZATION_TYPE];
        }
        if (isset($data[self::SERIALIZATION_FOLDER])) {
            $this->_folder = $data[self::SERIALIZATION_FOLDER];
        }
        if (isset($data[self::SERIALIZATION_BACKENDID])) {
            $this->_backend_id = $data[self::SERIALIZATION_BACKENDID];
        }
        if (isset($data[self::SERIALIZATION_MIMEPARTID])) {
            $this->_mime_part_id = $data[self::SERIALIZATION_MIMEPARTID];
        }
    }

Usage Example

Exemple #1
0
 public function testSerializeUnserializeForgetsContent()
 {
     $data_string = "<?xml version=\"1.0\"?>\n<kolab><test/></kolab>";
     $content = fopen('php://temp', 'r+');
     fwrite($content, $data_string);
     $data = $this->getMock('Horde_Kolab_Storage_Object_Writer');
     $object = new Horde_Kolab_Storage_Object();
     $this->folder->expects($this->once())->method('getType')->will($this->returnValue('event'));
     $this->folder->expects($this->once())->method('getPath')->will($this->returnValue('INBOX/Calendar'));
     $this->driver->expects($this->exactly(2))->method('fetchBodypart')->with('INBOX/Calendar', '1', '2')->will($this->returnValue($content));
     $object->setDriver($this->driver);
     $object->load('1', $this->folder, $data, $this->getMultipartMimeMessage('application/x-vnd.kolab.event'));
     $new_object = new Horde_Kolab_Storage_Object();
     $new_object->unserialize($object->serialize());
     $new_object->setDriver($this->driver);
     $this->assertSame($content, $new_object->getContent());
 }