コード例 #1
0
ファイル: Jam.php プロジェクト: Konro1/pms
 /**
  * Automatically loads a model, if it exists,
  * into the meta table.
  *
  * Models are not required to register
  * themselves; it happens automatically.
  *
  * @param   string  $model
  * @return  boolean
  */
 public static function register($model)
 {
     $class = Jam::class_name($model);
     $model = Jam::model_name($model);
     // Don't re-initialize!
     if (isset(Jam::$_models[$model])) {
         return TRUE;
     }
     // Can we find the class?
     if (class_exists($class)) {
         // Prevent accidentally trying to load ORM or Sprig models
         if (!is_subclass_of($class, 'Jam_Validated')) {
             return FALSE;
         }
     } else {
         return FALSE;
     }
     // Load it into the registry
     Jam::$_models[$model] = $meta = new Jam_Meta($model);
     // Let the intialize() method override defaults.
     call_user_func(array($class, 'initialize'), $meta);
     // Finalize the changes
     $meta->finalize($model);
     return TRUE;
 }
コード例 #2
0
ファイル: CoreTest.php プロジェクト: Konro1/pms
 /**
  * Tests Jam::model_name().
  *
  * @dataProvider provider_model_name
  */
 public function test_model_name($model, $expected)
 {
     $this->assertSame($expected, Jam::model_name($model));
 }
コード例 #3
0
ファイル: Attributes.php プロジェクト: Konro1/pms
 /**
  * Returns a string representation of the collection.
  *
  * @return  string
  */
 public function __toString()
 {
     return get_class($this) . ': ' . Jam::model_name($this->_model) . ' (' . $this->count() . ')';
 }