Cache the vfs in the factory
authorMichael J. Rubinsky <mrubinsk@horde.org>
Mon, 24 May 2010 18:42:13 +0000 (14:42 -0400)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Mon, 24 May 2010 18:42:13 +0000 (14:42 -0400)
framework/Core/lib/Horde/Core/Factory/Vfs.php

index 134c59b..382ac0e 100644 (file)
 class Horde_Core_Factory_Vfs
 {
     /**
+     * Instances.
+     *
+     * @var array
+     */
+    private $_instances = array();
+
+    /**
      * The injector.
      *
      * @var Horde_Injector
@@ -47,8 +54,12 @@ class Horde_Core_Factory_Vfs
      */
     public function getVfs($scope)
     {
-        $params = Horde::getVFSConfig($scope);
-        return VFS::singleton($params['type'], $params['params']);
+        if (empty($this->_instances[$scope])) {
+            $params = Horde::getVFSConfig($scope);
+            $this->_instances[$scope] = VFS::singleton($params['type'], $params['params']);
+        }
+
+        return $this->_instances[$scope];
     }
 
 }
\ No newline at end of file