function __construct ($obj) { // Figure out what kind of object we're using // ModelMeta: use it if (is_a($obj, 'ModelMeta')) { $this->meta = $obj; } // Model: use it's meta and keep the instance elseif (is_a($obj, 'Model')) { $this->meta = $obj->meta(); $this->instance = $obj; } // Other (string?): get the ModelMeta based on Model name else { $this->meta = ModelMeta::meta($obj); } }
public function load_model ($name) { /* if (!array_key_exists($name, $this->models) { return false; // TODO: maybe throw an exception here... // throw new Exception(sprintf('Model "%s" not available.', $name)); } */ $ok = import(join_path(array($this->models_path, $name . '.php'))); // Make a shortcut for the app on the model ModelMeta::meta($name)->app = $this; return $ok; }
static public function meta() { return ModelMeta::meta(get_class()); }
function get_meta () { if (!$this->meta) { $this->meta = ModelMeta::meta($this->model_name); } return $this->meta; }
private function set_up () { if (!is_a($this->model_name, 'Model')) { $this->related_model = ModelMeta::meta($this->model_name); } }