本文整理汇总了PHP中JModelLegacy::getName方法的典型用法代码示例。如果您正苦于以下问题:PHP JModelLegacy::getName方法的具体用法?PHP JModelLegacy::getName怎么用?PHP JModelLegacy::getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JModelLegacy
的用法示例。
在下文中一共展示了JModelLegacy::getName方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postSaveHook
/**
* Update the ordered items in post save hook
*/
protected function postSaveHook(JModelLegacy $model, $validData = array())
{
$order_id = $model->getState($model->getName() . '.id');
$data = JFactory::getApplication()->input->post->getArray(array('jform' => array('ordered' => 'array', 'deleted' => 'array')));
// We add order items right on order edit view
foreach ($data['jform']['ordered'] as $item) {
$item['order_id'] = $order_id;
$model = JModelLegacy::getInstance('OrderItem', 'DZProductModel');
$form = $model->getForm($item, false);
if (!$form) {
continue;
}
$validItem = $model->validate($form, $item);
if ($validItem === false) {
continue;
}
if (!$model->save($validItem)) {
continue;
}
}
// Make sure the submitted deleted ids are all integer
JArrayHelper::toInteger($data['jform']['deleted']);
// Remove items
$model = JModelLegacy::getInstance('OrderItem', 'DZProductModel');
$model->delete($data['jform']['deleted']);
}
示例2: testGetName
/**
* Tests the getName method.
*
* @expectedException Exception
* @expectedExceptionCode 500
*
* @since 12.3
*
* @return void
*/
public function testGetName()
{
// Test default fixture
$this->assertEquals('lead', $this->fixture->getName());
$this->assertEquals('com_test', TestReflection::getValue($this->fixture, 'option'));
// Test creating fixture with model in class name
$this->fixture = JModelLegacy::getInstance('Room', 'RemodelModel');
$this->assertEquals('room', $this->fixture->getName());
$this->assertEquals('com_remodel', TestReflection::getValue($this->fixture, 'option'));
// Ensure that $name can be set properly, and doesn't change $option
TestReflection::setValue($this->fixture, 'name', 'foo');
$this->assertEquals('foo', $this->fixture->getName());
$this->assertEquals('com_remodel', TestReflection::getValue($this->fixture, 'option'));
// Test creating a non-existant class.
$this->assertFalse(JModelLegacy::getInstance('Does', 'NotExist'));
// Test creating class that does exist, but does not contain 'Model' (uppercase)
$this->fixture = JModelLegacy::getInstance('NomodelInName');
$this->fixture->getName();
}
示例3: setModel
/**
* Method to add a model to the view. We support a multiple model single
* view system by which models are referenced by classname. A caveat to the
* classname referencing is that any classname prepended by JModel will be
* referenced by the name without JModel, eg. JModelCategory is just
* Category.
*
* @param JModelLegacy $model The model to add to the view.
* @param boolean $default Is this the default model?
*
* @return object The added model.
*
* @since 12.2
*/
public function setModel($model, $default = false)
{
$name = strtolower($model->getName());
$this->_models[$name] = $model;
if ($default) {
$this->_defaultModel = $name;
}
return $model;
}
示例4: setModel
/**
* Method to add a model to the create object.
*
* @param JModelLegacy $model The model to add.
*
* @return object The added model.
*/
protected function setModel($model)
{
$name = strtolower($model->getName());
$this->_models[$name] = $model;
return $this->_models[$name];
}
示例5: testNameOfExistingClassThatDoesNotContainModel
/**
* Test getting the name of a class that does exist, but does not contain 'Model' (upper- or lowercase)
*
* @expectedException Exception
* @expectedExceptionCode 500
*
* @since 12.3
*
* @return void
*
* @testdox getName() throws exception if class has no 'model' in classname
*/
public function testNameOfExistingClassThatDoesNotContainModel()
{
$this->fixture = new NokeywordInName();
$this->fixture->getName();
}