Code merge from latest Ship-Simu code
[mailer.git] / inc / classes / main / factories / objects / class_ObjectFactory.php
index 5dda5fb904b8e177b3f7a70286a2d693ee1dee04..3f8ac7fa61b116b5dd93c4d5b9735f8bec1fc0de 100644 (file)
@@ -25,7 +25,6 @@ class ObjectFactory extends BaseFactory {
        /**
         * Protected constructor
         *
-        * @param       $class  Name of the real class (not BaseFactory)
         * @return      void
         */
        protected function __construct () {
@@ -34,6 +33,9 @@ class ObjectFactory extends BaseFactory {
 
                // Set object description
                $this->setObjectDescription("Simple generic object factory");
+
+               // Create unique ID number
+               $this->createUniqueID();
        }
 
        /**
@@ -56,7 +58,7 @@ class ObjectFactory extends BaseFactory {
                        throw new EmptyVariableException(array($factoryInstance, 'className'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
                } elseif (!class_exists($className)) {
                        // Then throw an exception
-                       throw new ClassNotFoundException($className, self::EXCEPTION_CLASS_NOT_FOUND);
+                       throw new ClassNotFoundException(array($factoryInstance, $className), self::EXCEPTION_CLASS_NOT_FOUND);
                }
 
                // Then Prepare the eval() command
@@ -71,6 +73,23 @@ class ObjectFactory extends BaseFactory {
                // Return the prepared instance
                return $objectInstance;
        }
+
+       /**
+        * Creates an object by it's configured name
+        *
+        * @param       $configEnttry                   Configuration entry to read
+        * @return      $objectInstance                 An instance of the requested object
+        */
+       public final static function createObjectByConfiguredName ($configEntry) {
+               // Read the configuration entry
+               $className = FrameworkConfiguration::getInstance()->readConfig($configEntry);
+
+               // Send this to the other factory...
+               $objectInstance = self::createObjectByName($className);
+
+               // Return the instance
+               return $objectInstance;
+       }
 }
 
 // [EOF]