Kronolith::getDriver PHP Méthode

getDriver() public static méthode

This singleton method automatically retrieves all parameters required for the specified driver.
public static getDriver ( string $driver = null, string $calendar = null ) : Kronolith_Driver
$driver string The type of concrete Kronolith_Driver subclass to return.
$calendar string The calendar name. The format depends on the driver being used.
Résultat Kronolith_Driver The newly created concrete Kronolith_Driver instance.
    public static function getDriver($driver = null, $calendar = null)
    {
        $instance = $GLOBALS['injector']->getInstance('Kronolith_Factory_Driver')->create($driver);
        if (!is_null($calendar)) {
            $instance->open($calendar);
            /* Remote calendar parameters are per calendar. */
            if ($instance instanceof Kronolith_Driver_Ical) {
                $instance->setParams(self::getRemoteParams($calendar));
            }
        }
        return $instance;
    }

Usage Example

Exemple #1
0
 /**
  * Adds a new resource to storage
  *
  * @param Kronolith_Resource_Base $resource
  *
  * @return unknown_type
  */
 public static function addResource(Kronolith_Resource_Base $resource)
 {
     // Create a new calendar id.
     $calendar = uniqid(mt_rand());
     $resource->set('calendar', $calendar);
     $driver = Kronolith::getDriver('Resource');
     return $driver->save($resource);
 }
All Usage Examples Of Kronolith::getDriver