Copyright 2008-2016 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.
Author: Gunnar Wrobel (wrobel@pardus.de)
Example #1
0
 /**
  * Fetch a Kolab object.
  *
  * This method will not retrieve any data from the server
  * immediately. Instead it will simply generate a new instance for the
  * desired object.
  *
  * The server data will only be accessed once you start reading the object
  * data.
  *
  * This method can also be used in order to fetch non-existing objects that
  * will be saved later. This is however not recommended and you should
  * rather use the add($info) method for that.
  *
  * If you do not provide the object type the server will try to determine it
  * automatically based on the uid. As this requires reading data from the
  * server it is recommended to specify the object type whenever it is known.
  *
  * If you do not specify a uid the object corresponding to the user bound to
  * the server will be returned.
  *
  * @param string $guid The GUID of the object to fetch.
  * @param string $type The type of the object to fetch.
  *
  * @return Kolab_Object The corresponding Kolab object.
  *
  * @throws Horde_Kolab_Server_Exception
  */
 public function fetch($guid = null, $type = null)
 {
     if (!isset($guid)) {
         $guid = $this->_composite->server->getGuid();
     }
     if (empty($type)) {
         $type = $this->_composite->structure->determineType($guid);
     }
     $object = Horde_Kolab_Server_Object_Factory::factory($type, $guid, $this->_composite);
     return $object;
 }
Example #2
0
 /**
  * Determine the type of an object by its tree position and other
  * parameters.
  *
  * @param string $guid The GUID of the object to examine.
  * @param array  $ocs  The object classes of the object to examine.
  *
  * @return string The class name of the corresponding object type.
  *
  * @throws Horde_Kolab_Server_Exception If the object type is unknown.
  */
 protected function _determineType($guid, array $ocs)
 {
     $ocs = array_reverse($ocs);
     foreach ($ocs as $oc) {
         try {
             $class_name = 'Horde_Kolab_Server_Object_' . ucfirst(strtolower($oc));
             Horde_Kolab_Server_Object_Factory::loadClass($class_name);
             return $class_name;
         } catch (Horde_Kolab_Server_Exception $e) {
         }
     }
     throw new Horde_Kolab_Server_Exception(sprintf("Unknown object type for GUID %s.", $guid), Horde_Kolab_Server_Exception::SYSTEM);
 }