Horde_Kolab_Server_Object_Factory::loadClass PHP Method

loadClass() public static method

Attempts to load the concrete Horde_Kolab_Server_Object class based on $type.
public static loadClass ( mixed $type ) : true | PEAR_Error
$type mixed The type of the Horde_Kolab_Server_Object subclass.
return true | PEAR_Error True if successfull.
    public static function loadClass($type)
    {
        if (!class_exists($type)) {
            throw new Horde_Kolab_Server_Exception('Class definition of ' . $type . ' not found.');
        }
    }

Usage Example

Example #1
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);
 }
Horde_Kolab_Server_Object_Factory