From: Gunnar Wrobel
Date: Thu, 29 Oct 2009 15:55:37 +0000 (+0100) Subject: Fix the search handler. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=d9117d90819ef79a5056ea62c0854e0c6149b24b;p=horde.git Fix the search handler. --- diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Search/Base.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Search/Base.php index f49121f83..0d4a70661 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Search/Base.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Search/Base.php @@ -1,6 +1,7 @@ _composite = $composite; - $this->_searches = $this->getSearchOperations(); + $this->_searches = $this->_getSearchOperations(); } - /*__construct - /** Initialize the search operations supported by this server. * - */ - /** * Returns the set of search operations supported by this server type. * * @return array An array of supported search operations. */ - public function getSearchOperations() + private function _getSearchOperations() { $server_searches = array(); foreach ($this->_composite->structure->getSupportedObjects() as $sobj) { - if (in_array('getSearchOperations', get_class_methods($sobj))) { + $methods = get_class_methods($sobj); + if (in_array('getSearchOperations', $methods)) { $searches = call_user_func(array($sobj, 'getSearchOperations')); foreach ($searches as $search) { - $server_searches[$search] = array('class' => $sobj); + if (in_array($search, $methods)) { + $server_searches[$search] = array('class' => $sobj); + } else { + sprintf( + "Class \"%s\" does not support method \"%s\"!", + $sobj, + $search + ); + } } } } @@ -78,6 +86,16 @@ class Horde_Kolab_Server_Search_Base implements Horde_Kolab_Server_Search } /** + * Returns the set of search operations supported by this server type. + * + * @return array An array of supported search operations. + */ + public function getSearchOperations() + { + return $this->_searches; + } + + /** * Capture undefined calls and assume they refer to a search operation. * * @param string $method The name of the called method. @@ -89,16 +107,19 @@ class Horde_Kolab_Server_Search_Base implements Horde_Kolab_Server_Search */ public function __call($method, $args) { - if (in_array($method, array_keys($this->searches))) { - array_unshift($args, $this); - if (isset($this->searches[$method])) { - return call_user_func_array(array($this->searches[$method]['class'], - $method), $args); - } + if (in_array($method, array_keys($this->_searches))) { + array_unshift($args, $this->_composite); + return call_user_func_array( + array( + $this->_searches[$method]['class'], $method + ), + $args + ); } throw new Horde_Kolab_Server_Exception( sprintf( - "The server type \"%s\" with structure \"%s\" does not support method \"%s\"!", + "The server type \"%s\" with structure \"%s\" does not support" + . " method \"%s\"!", get_class($this->_composite->server), get_class($this->_composite->structure), $method