当前位置: 首页>>代码示例>>PHP>>正文


PHP JViewLegacy::setModel方法代码示例

本文整理汇总了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);
 }
开发者ID:n9iels,项目名称:joomla-cms,代码行数:34,代码来源:JViewLegacyTest.php

示例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();
 }
开发者ID:JozefAB,项目名称:qk,代码行数:14,代码来源:view.html.php


注:本文中的JViewLegacy::setModel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。