From: Michael J. Rubinsky Date: Wed, 19 Aug 2009 14:28:00 +0000 (-0400) Subject: Use a static member to hold the Kronolith_Driver object X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=f8288c29f868f731287609a2cb60b3e462dc28fa;p=horde.git Use a static member to hold the Kronolith_Driver object --- diff --git a/kronolith/lib/Resource.php b/kronolith/lib/Resource.php index 33e2ba4ee..bb2a0934f 100644 --- a/kronolith/lib/Resource.php +++ b/kronolith/lib/Resource.php @@ -18,14 +18,21 @@ */ class Kronolith_Resource { + static protected $_driver; + /** * * @return unknown_type */ - static public function listResources($params) + static public function listResources($params = array()) { // Query kronolith_resource table for all(?) available resources? // maybe by 'type' or 'name'? type would be arbitrary? + if (empty(self::$_driver)) { + self::$_driver = Kronolith::getDriver('Sql'); + } + + self::$_driver->listResources($params); } /** @@ -40,8 +47,11 @@ class Kronolith_Resource $calendar = hash('md5', microtime()); $resource->calendar_id = $calendar; - $driver = Kronolith::getDriver('Sql'); - return $driver->saveResource($resource); + if (empty(self::$_driver)) { + self::$_driver = Kronolith::getDriver('Sql'); + } + + return self::$_driver->saveResource($resource); } /** @@ -64,8 +74,10 @@ class Kronolith_Resource static public function isResourceCalendar($calendar) { - $driver = Kronolith::getDriver('Sql'); - $resource = $driver->getResourceIdByCalendar($calendar); + if (empty(self::$_driver)) { + self::$_driver = Kronolith::getDriver('Sql'); + } + $resource = self::$_driver->getResourceIdByCalendar($calendar); return $resource > 0; }