本文整理汇总了PHP中AbstractObject::setModel方法的典型用法代码示例。如果您正苦于以下问题:PHP AbstractObject::setModel方法的具体用法?PHP AbstractObject::setModel怎么用?PHP AbstractObject::setModel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AbstractObject
的用法示例。
在下文中一共展示了AbstractObject::setModel方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setModel
/** Associate view with a model. Different models may behave differently. */
function setModel($model, $actual_fields = undefined)
{
parent::setModel($model);
// Some models will want default controller to be associated
if ($this->model->default_controller) {
$this->controller = $this->model->setController($this->model->default_controller);
}
// Use our default controller if present
if ($this->default_controller) {
$this->controller = $this->setController($this->default_controller);
}
if ($this->controller) {
if ($this->controller->hasMethod('setActualFields')) {
$this->controller->setActualFields($actual_fields);
}
if ($this->controller->hasMethod('_bindView')) {
$this->controller->_bindView();
}
}
if ($this->model instanceof Model_Table) {
$this->dq = $this->model->_dsql();
}
// compatibility
return $this->model;
}
示例2: setModel
/**
* Set model
*
* @param Model|string $model
* @param string|bool $display_field
*
* @return Model|$this
*/
public function setModel($model, $display_field = null)
{
if ($model instanceof Model) {
return AbstractObject::setModel($model);
}
$this->model_name = is_string($model) ? $model : get_class($model);
$this->model_name = (string) $this->app->normalizeClassName($this->model_name, 'Model');
if ($display_field) {
$this->display_field = (string) $display_field;
}
if ($display_field !== false) {
$this->owner->addExpression($this->getDereferenced())->set(array($this, 'calculateSubQuery'))->caption((string) $this->caption());
}
$this->system(true);
$this->editable(true);
$this->visible(false);
return $this;
}