openrat-cms

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

ModelFactory.class.php (381B)


      1 <?php
      2 
      3 namespace cms\model;
      4 
      5 class ModelFactory
      6 {
      7     /**
      8      * @param $type
      9      * @param $id
     10      * @return ModelBase
     11      */
     12     public static function create($type, $id) {
     13 
     14         // 'aBc' => 'Abc'
     15         $className = '\\cms\\model\\'.ucfirst(strtolower($type));
     16 
     17         if   ( ! class_exists($className))
     18         	return null;
     19 
     20         return new $className( $id );
     21    }
     22 }