30
1
mirror of https://github.com/joomla-extensions/weblinks.git synced 2024-09-27 20:49:05 +00:00

Move model creation into getList method (same with core)

This commit is contained in:
Tuan Pham Ngoc 2021-07-30 12:34:21 +07:00
parent baddd59e16
commit ddb6bf3c91
2 changed files with 6 additions and 7 deletions

View File

@ -12,10 +12,7 @@ defined('_JEXEC') or die;
use Joomla\CMS\Helper\ModuleHelper;
use Joomla\Module\Weblinks\Site\Helper\WeblinksHelper;
$model = $app->bootComponent('com_weblinks')->getMVCFactory()
->createModel('Category', 'Site', ['ignore_request' => true]);
$list = WeblinksHelper::getList($params, $model, $app);
$list = WeblinksHelper::getList($params, $app);
if (!count($list))
{

View File

@ -14,7 +14,6 @@ defined('_JEXEC') or die;
use Joomla\CMS\Application\CMSApplicationInterface;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Router\Route;
use Joomla\Component\Weblinks\Site\Model\CategoryModel;
use Joomla\Registry\Registry;
/**
@ -28,15 +27,18 @@ class WeblinksHelper
* Retrieve list of weblinks
*
* @param Registry $params The module parameters
* @param CategoryModel $model The model
* @param CMSApplicationInterface $app The application
*
* @return mixed Null if no weblinks based on input parameters else an array containing all the weblinks.
*
* @since 1.5
**/
public static function getList($params, $model, $app)
public static function getList($params, $app)
{
/* @var \Joomla\Component\Weblinks\Site\Model\CategoryModel $model */
$model = $app->bootComponent('com_weblinks')->getMVCFactory()
->createModel('Category', 'Site', ['ignore_request' => true]);
// Set application parameters in model
$appParams = $app->getParams();
$model->setState('params', $appParams);