Esempio n. 1
0
 /**
  * Factory method that returns a Singleton instance of the ModelManager class
  * that is used for performing CRUD actions on Models of the type specified.
  *
  * @param string $modelName The name of the Model whose manager we want to retrieve
  * @return \Buan\ModelManager
  */
 public static final function create($modelName)
 {
     // Vars
     static $modelManagerInstances = [];
     // Return instance if already created
     if (isset($modelManagerInstances[$modelName])) {
         return $modelManagerInstances[$modelName];
     }
     // Create new instance and return
     $managerClassName = Inflector::modelName_modelManagerClass($modelName);
     try {
         $modelManagerInstances[$modelName] = new $managerClassName($modelName);
     } catch (Exception $e) {
         SystemLog::add($e->getMessage(), SystemLog::CORE);
         $modelManagerInstances[$modelName] = new ModelManager($modelName);
     }
     return $modelManagerInstances[$modelName];
 }