Overview

Packages

  • Jonah
  • None

Classes

  • Jonah
  • Jonah_Api
  • Jonah_Block_Latest
  • Jonah_Driver
  • Jonah_Driver_Sql
  • Jonah_Exception
  • Jonah_Factory_Driver
  • Jonah_Form_Feed
  • Jonah_Form_Story
  • Jonah_Test
  • Jonah_View_ChannelDelete
  • Jonah_View_ChannelEdit
  • Jonah_View_ChannelList
  • Jonah_View_StoryDelete
  • Jonah_View_StoryEdit
  • Jonah_View_StoryList
  • Jonah_View_StoryPdf
  • Jonah_View_StoryView
  • Jonah_View_TagSearchList
  • Overview
  • Package
  • Class
  • Tree
 1: <?php
 2: /**
 3:  * Jonah_Driver factory.
 4:  *
 5:  * Copyright 2010-2012 Horde LLC (http://www.horde.org/)
 6:  *
 7:  * See the enclosed file LICENSE for license information (BSD). If you did not
 8:  * did not receive this file, see http://cvs.horde.org/co.php/jonah/LICENSE.
 9:  *
10:  * @author Michael J. Rubinsky <mrubinsk@horde.org>
11:  * @author Ben Klang <ben@alkaloid.net>
12:  * @package Jonah
13:  */
14: class Jonah_Factory_Driver extends Horde_Core_Factory_Injector
15: {
16:     /**
17:      * Instances.
18:      *
19:      * @var array
20:      */
21:     private $_instances = array();
22: 
23:     /**
24:      * Return the driver instance.
25:      *
26:      * @param string $driver  The concrete driver to return
27:      * @param array $params   An array of additional driver parameters.
28:      *
29:      * @return Jonah_Driver
30:      * @throws Jonah_Exception
31:      */
32:     public function create(Horde_Injector $injector)
33:     {
34:         $driver = Horde_String::ucfirst($GLOBALS['conf']['news']['storage']['driver']);
35:         $driver = basename($driver);
36:         $params = Horde::getDriverConfig(array('news', 'storage'), $driver);
37: 
38:         $sig = md5($driver . serialize($params));
39:         if (isset($this->_instances[$sig])) {
40:             return $this->_instances[$sig];
41:         }
42: 
43:         $class = 'Jonah_Driver_' . $driver;
44:         if (class_exists($class)) {
45:             $object = new $class($params);
46:             $this->_instances[$sig] = $object;
47:         } else {
48:             throw new Jonah_Exception(sprintf(_("No such backend \"%s\" found"), $driver));
49:         }
50: 
51:         return $this->_instances[$sig];
52:     }
53: }
54: 
API documentation generated by ApiGen