Continued with indexes/stacks:
[core.git] / inc / classes / main / factories / index / class_FileStackIndexFactory.php
index ca1fb7c..df10a1c 100644 (file)
@@ -38,9 +38,18 @@ class FileStackIndexFactory extends ObjectFactory {
         * @param       $stackName                      Name of the stack's file
         * @return      $indexInstance          An instance of a IndexableStack class
         */
-       public static final function createFileStackIndexInstance ($fileName) {
-               // Call parent factory
-               $indexInstance self::createObjectByConfiguredName('file_stack_index_class', array($fileName));
+       public static final function createFileStackIndexInstance ($fileName, $type) {
+               // If there is no handler?
+               if (Registry::getRegistry()->instanceExists($type . '_index')) {
+                       // Get handler from registry
+                       $indexInstance = Registry::getRegistry()->getInstance($type . '_index');
+               } else {
+                       // Get the handler instance
+                       $indexInstance = self::createObjectByConfiguredName('file_stack_' . $type . '_index_class', array($fileName));
+
+                       // Add it to the registry
+                       Registry::getRegistry()->addInstance($type . '_index', $indexInstance);
+               }
 
                // Return the instance
                return $indexInstance;