Ejemplo n.º 1
0
	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);
		}
		
	}
Ejemplo n.º 2
0
Archivo: App.php Proyecto: ricobl/frix
	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;
		
	}
Ejemplo n.º 3
0
	static public function meta() {
		return ModelMeta::meta(get_class());
	}
Ejemplo n.º 4
0
	function get_meta () {
		if (!$this->meta) {
			$this->meta = ModelMeta::meta($this->model_name);
		}
		return $this->meta;
	}
Ejemplo n.º 5
0
    private function set_up () {
        if (!is_a($this->model_name, 'Model')) {
            $this->related_model = ModelMeta::meta($this->model_name);
        }
	}