本文整理汇总了PHP中JViewLegacy::setModel方法的典型用法代码示例。如果您正苦于以下问题:PHP JViewLegacy::setModel方法的具体用法?PHP JViewLegacy::setModel怎么用?PHP JViewLegacy::setModel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JViewLegacy
的用法示例。
在下文中一共展示了JViewLegacy::setModel方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSetModel
/**
* Test JViewLegacy::setModel()
*
* @since 11.3
*
* @return void
*/
public function testSetModel()
{
// Prepare variable to compare against and a bunch of models
$models = array();
$model1 = new ModelMockupJView();
$model2 = new ModelMockupJView();
$model2->name = 'test';
$model3 = new ModelMockupJView();
$model3->name = 'defaulttest';
// Assert that initial state is empty
$this->assertAttributeEquals($models, '_models', $this->class);
// Assert that setModel() returns the model handed over
$this->assertThat($this->class->setModel($model1), $this->equalTo($model1));
$models['model'] = $model1;
// Assert that model was correctly added to array
$this->assertAttributeEquals($models, '_models', $this->class);
// Assert that having more than one model works
$this->class->setModel($model2);
$models['test'] = $model2;
$this->assertAttributeEquals($models, '_models', $this->class);
// Assert that default model works correctly
$this->assertAttributeEquals('', '_defaultModel', $this->class);
$this->class->setModel($model3, true);
$models['defaulttest'] = $model3;
$this->assertAttributeEquals($models, '_models', $this->class);
$this->assertAttributeEquals('defaulttest', '_defaultModel', $this->class);
}
示例2: assignExtrasView
protected function assignExtrasView()
{
// Create the View
$view = new JViewLegacy(array('name' => 'extras', 'base_path' => JPATH_SITE . '/components/com_rsmembership'));
// Create the Model
$model = JModelLegacy::getInstance('Extras', 'RSMembershipModel');
// Assign the Model to the View and set it as default.
$view->setModel($model, true);
$view->model =& $model;
$view->item = $this->membership;
$view->extras = $model->getItems();
$view->show_subscribe_btn = false;
$this->extrasview = $view->loadTemplate();
}