本文整理匯總了PHP中JModelList::setState方法的典型用法代碼示例。如果您正苦於以下問題:PHP JModelList::setState方法的具體用法?PHP JModelList::setState怎麽用?PHP JModelList::setState使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類JModelList
的用法示例。
在下文中一共展示了JModelList::setState方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testListInfoIsAppendedToFormData
/**
* Tests the loadFormData method.
*
* @since 3.4
*
* @return void
*
* @testdox loadFormData() returns correct data from currently set states
*/
public function testListInfoIsAppendedToFormData()
{
$method = new ReflectionMethod('JModelList', 'loadFormData');
$method->setAccessible(true);
$applicationMock = $this->getMockCmsApp();
$applicationMock->expects($this->once())->method('getUserState')->with($this->equalTo('com_j.list'), $this->equalTo(new stdClass()))->will($this->returnValue((object) array("foo" => "bar")));
JFactory::$application = $applicationMock;
$this->object->setState('list.direction', 'ASC');
$this->object->setState('list.limit', 30);
$this->object->setState('list.ordering', 'enabled');
$this->object->setState('list.start', 0);
$expected = (object) array("foo" => "bar", "list" => array('direction' => 'ASC', 'limit' => 30, 'ordering' => 'enabled', 'start' => 0));
$this->assertEquals($expected, $method->invoke($this->object));
}
示例2: setState
/**
* Method to set model state variables. Update local vars.
*
* @access public
* @param string $property The name of the property.
* @param mixed $value The value of the property to set or null.
*
* @return mixed The previous value of the property or null if not set.
*
* @since 11.1
*/
public function setState($property, $value = null)
{
if ($property == 'context') {
$this->context = $value;
}
return parent::setState($property, $value);
}