-
Notifications
You must be signed in to change notification settings - Fork 127
/
Content.php
85 lines (81 loc) · 2.15 KB
/
Content.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
/**
* Generates the core Kolab content.
*
* PHP version 5
*
* @category Kolab
* @package Kolab_Storage
* @author Gunnar Wrobel <wrobel@pardus.de>
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @link http://pear.horde.org/index.php?package=Kolab_Storage
*/
/**
* Generates the core Kolab content.
*
* Copyright 2011-2012 Horde LLC (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
*
* @category Kolab
* @package Kolab_Storage
* @author Gunnar Wrobel <wrobel@pardus.de>
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @link http://pear.horde.org/index.php?package=Kolab_Storage
*/
class Horde_Kolab_Storage_Data_Object_Content
{
/**
* Kolab format handler.
*
* @var Horde_Kolab_Format
*/
private $_format;
/**
* Constructor.
*
* @param Horde_Kolab_Format $format The Kolab format handler.
*/
public function __construct(Horde_Kolab_Format $format)
{
$this->_format = $format;
}
/**
* Create the Kolab content as a string.
*
* @param array $object The object data.
*
* @return string The Kolab content.
*/
public function create(array $object)
{
try {
return $this->_format->save($object);
} catch (Horde_Kolab_Format_Exception $e) {
throw new Horde_Kolab_Storage_Data_Exception(
'Failed saving Kolab object!', 0, $e
);
}
}
/**
* Modify a previous Kolab object.
*
* @param array $object The new object data.
* @param string $previous The previous data.
*
* @return string The new Kolab content.
*/
public function modify(array $object, $previous)
{
try {
return $this->_format->save(
$object, array('previous' => $previous)
);
} catch (Horde_Kolab_Format_Exception $e) {
throw new Horde_Kolab_Storage_Data_Exception(
'Failed saving Kolab object!', 0, $e
);
}
}
}