/** * Use the Jam::build_template() to return the model for the row in the results * @param array $value * @return Jam_Model */ protected function _load_model($value) { if (!$value) { return NULL; } $model = clone Jam::build_template($this->meta()->model(), $value); $model = $model->load_fields($value); return $model; }
public function test_build_template() { $model = Jam::build_template('test_author'); $this->assertInstanceOf('Model_Test_Author', $model); $this->assertFalse($model->loaded()); $model2 = Jam::build_template('test_author'); $this->assertSame($model, $model2); $model = Jam::build_template('test_position'); $this->assertInstanceOf('Model_Test_Position', $model); $model = Jam::build_template('test_position', array('model' => 'test_position_big')); $this->assertInstanceOf('Model_Test_Position_Big', $model); }
/** * Build a new Jam Model, add it to the collection and return the newly built model * @param array $values set values on the new model * @return Jam_Model */ public function build(array $values = NULL) { $item = clone Jam::build_template($this->model(), $values); if ($values) { $item->set($values); } $this->add($item); return $item; }