From d0a92c3ce529f33f9b6cdfd5cc197aba76b818ac Mon Sep 17 00:00:00 2001 From: Gunnar Wrobel Date: Mon, 3 Jan 2011 13:46:15 +0100 Subject: [PATCH] Create list queries in the factory. --- .../lib/Horde/Kolab/Storage/Factory.php | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Factory.php b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Factory.php index 596c00ec3..67e17ce76 100644 --- a/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Factory.php +++ b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Factory.php @@ -195,6 +195,33 @@ class Horde_Kolab_Storage_Factory } /** + * Create the specified list query type. + * + * @param string $name The query name. + * @param Horde_Kolab_Storage_List $list The list that should be queried. + * + * @return Horde_Kolab_Storage_Query A query handler. + * + * @throws Horde_Kolab_Storage_Exception In case the requested query is not supported. + */ + public function createListQuery($name, Horde_Kolab_Storage_List $list) + { + if (class_exists($name)) { + $query = new $name($list); + } else if (strpos($name, 'Horde_Kolab_Storage_List_Query_') === false) { + $query = $this->createListQuery( + 'Horde_Kolab_Storage_List_Query_' . $name, $list + ); + } else { + throw new Horde_Kolab_Storage_Exception(sprintf('No such query "%s"!', $name)); + } + if (method_exists($query, 'setFactory')) { + $query->setFactory($this); + } + return $query; + } + + /** * Create a namespace handler. * * @param string $type The namespace type. -- 2.11.0