/** * 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; }
/** * Tests Jam::model_name(). * * @dataProvider provider_model_name */ public function test_model_name($model, $expected) { $this->assertSame($expected, Jam::model_name($model)); }
/** * Returns a string representation of the collection. * * @return string */ public function __toString() { return get_class($this) . ': ' . Jam::model_name($this->_model) . ' (' . $this->count() . ')'; }