1: <?php
2: /**
3: * The cached variant for the Kolab storage handler [the default].
4: *
5: * PHP version 5
6: *
7: * @category Kolab
8: * @package Kolab_Storage
9: * @author Gunnar Wrobel <wrobel@pardus.de>
10: * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
11: * @link http://pear.horde.org/index.php?package=Kolab_Storage
12: */
13:
14: /**
15: * The cached variant for the Kolab storage handler [the default].
16: *
17: * Copyright 2004-2012 Horde LLC (http://www.horde.org/)
18: *
19: * See the enclosed file COPYING for license information (LGPL). If you
20: * did not receive this file, see http://www.horde.org/licenses/lgpl21.
21: *
22: * @category Kolab
23: * @package Kolab_Storage
24: * @author Gunnar Wrobel <wrobel@pardus.de>
25: * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
26: * @link http://pear.horde.org/index.php?package=Kolab_Storage
27: */
28: class Horde_Kolab_Storage_Cached
29: extends Horde_Kolab_Storage_Base
30: {
31: /**
32: * The cache.
33: *
34: * @var Horde_Kolab_Storage_Cache
35: */
36: private $_cache;
37:
38: /**
39: * Constructor.
40: *
41: * @param Horde_Kolab_Storage_Driver $master The primary connection
42: * driver.
43: * @param Horde_Kolab_Storage_QuerySet $query_set The query handler.
44: * @param Horde_Kolab_Storage_Factory $factory The factory.
45: * @param Horde_Kolab_Storage_Cache $cache The cache.
46: * @param array $params Additional parameters.
47: */
48: public function __construct(Horde_Kolab_Storage_Driver $master,
49: Horde_Kolab_Storage_QuerySet $query_set,
50: Horde_Kolab_Storage_Factory $factory,
51: Horde_Kolab_Storage_Cache $cache,
52: array $params = array())
53: {
54: parent::__construct($master, $query_set, $factory, $params);
55: $this->_cache = $cache;
56: }
57:
58: /**
59: * Create the folder list object.
60: *
61: * @param Horde_Kolab_Storage_Driver $master The primary connection driver.
62: * @param Horde_Kolab_Storage_Factory $factory The factory.
63: *
64: * @return Horde_Kolab_Storage_List The handler for the list of folders
65: * present in the Kolab backend.
66: */
67: protected function _createList(Horde_Kolab_Storage_Driver $master,
68: Horde_Kolab_Storage_Factory $factory)
69: {
70: $decorated_list = new Horde_Kolab_Storage_List_Base($master, $factory);
71: $list_cache = $this->_cache->getListCache(
72: $decorated_list->getIdParameters()
73: );
74: $list = new Horde_Kolab_Storage_List_Decorator_Cache(
75: $decorated_list,
76: $list_cache
77: );
78: return $list;
79: }
80:
81: /**
82: * Return a data handler for accessing data in the specified
83: * folder.
84: *
85: * @param mixed $folder The name of the folder or
86: * an instance representing
87: * the folder.
88: * @param Horde_Kolab_Storage_Driver $master The primary connection
89: * driver.
90: * @param Horde_Kolab_Storage_Factory $factory The factory.
91: * @param string $object_type The type of data we want
92: * to access in the folder.
93: * @param int $data_version Format version of the
94: * object data.
95: *
96: * @return Horde_Kolab_Data The data object.
97: */
98: protected function _createData($folder,
99: Horde_Kolab_Storage_Driver $master,
100: Horde_Kolab_Storage_Factory $factory,
101: $object_type = null,
102: $data_version = 1)
103: {
104: return new Horde_Kolab_Storage_Data_Cached(
105: $folder,
106: $master,
107: $factory,
108: $this->_cache,
109: $object_type,
110: $data_version
111: );
112: }
113: }