1: <?php
2: /**
3: * Factory for Ansel_Storage.
4: *
5: * Copyright 2010-2012 Horde LLC (http://www.horde.org/)
6: *
7: * @author Michael J. Rubinsky <mrubinsk@horde.org>
8: * @category Horde
9: * @license http://www.horde.org/licenses/gpl GPL
10: * @package Ansel
11: */
12: class Ansel_Factory_Storage extends Horde_Core_Factory_Injector
13: {
14: /**
15: * Array of already instantiated instances
16: *
17: * @var array
18: */
19: private $_instances = array();
20:
21: /**
22: * Return an Ansel_Storage instance scoped for the current Ansel scope.
23: * Scope is determined by the current value of Ansel_Config::scope
24: *
25: * @return Ansel_Storage
26: */
27: public function create(Horde_Injector $injector)
28: {
29: $scope = $injector->getInstance('Ansel_Config')->get('scope');
30: if (empty($this->_instances[$scope])) {
31: $this->_instances[$scope] = new Ansel_Storage($injector->getInstance('Horde_Core_Factory_Share')->create($scope));
32: $this->_instances[$scope]->setStorage($injector->getInstance('Horde_Db_Adapter'));
33: }
34:
35: return $this->_instances[$scope];
36: }
37:
38: }
39: