$notes = $this->_getNoteModel()->getLatestNotes($maxNotes);
$noteModel = $this->_getNoteModel() ;
$notes = $noteModel->getLatestNotes();
Without looking at the code, in all likelihood it is only the action of loading the model that is cached ($this->_getNoteModel). There is no evidence to suggest anything else is cached, but I know that typically whenever a model is loaded it is loaded from the Model cache. If the Model cache for that particular Model (e.g. Notes, Notices, Threads or whatever) is empty at the time then it will be loaded into the cache so it isn't necessary to load the model again.Is that cached, too?PHP:$notes = $this->_getNoteModel()->getLatestNotes($maxNotes);
Typically there is a separate model for each controller.And I wonder why there is always a new $.....Model variable introduced in each controller.
$threadModel = $this->_getThreadModel();
$postModel = $this->_getPostModel();
protected function _getForumModel()
{
return $this->getModelFromCache('XenForo_Model_Forum');
}
protected function _getThreadModel()
{
return $this->getModelFromCache('XenForo_Model_Thread');
}
$threads = $this->_getThreadModel()->getAllThreads();
$threadModel = $this->_getThreadModel();
$threads = $threadModel->getAllThreads();
$threadModel = XenForo_Model::create('XenForo_Model_Thread');
I now understood how the Xenforo_Model::getModelFromCache function works. So there is no technical reason for using $threadModel->getAllThreads(); instead of $this->_getThreadModel()->getAllThreads(); ? Coming to my original question, is it more elegant to user the former method?
/** @var XenForo_Model_User */
$userModel = $this->getModelFromCache('XenForo_Model_User');
We use essential cookies to make this site work, and optional cookies to enhance your experience.