32
1
mirror of https://github.com/joomla-extensions/weblinks.git synced 2024-12-27 02:12:50 +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\CMS\Helper\ModuleHelper;
use Joomla\Module\Weblinks\Site\Helper\WeblinksHelper; use Joomla\Module\Weblinks\Site\Helper\WeblinksHelper;
$model = $app->bootComponent('com_weblinks')->getMVCFactory() $list = WeblinksHelper::getList($params, $app);
->createModel('Category', 'Site', ['ignore_request' => true]);
$list = WeblinksHelper::getList($params, $model, $app);
if (!count($list)) if (!count($list))
{ {

View File

@ -14,7 +14,6 @@ defined('_JEXEC') or die;
use Joomla\CMS\Application\CMSApplicationInterface; use Joomla\CMS\Application\CMSApplicationInterface;
use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Router\Route; use Joomla\CMS\Router\Route;
use Joomla\Component\Weblinks\Site\Model\CategoryModel;
use Joomla\Registry\Registry; use Joomla\Registry\Registry;
/** /**
@ -28,15 +27,18 @@ class WeblinksHelper
* Retrieve list of weblinks * Retrieve list of weblinks
* *
* @param Registry $params The module parameters * @param Registry $params The module parameters
* @param CategoryModel $model The model
* @param CMSApplicationInterface $app The application * @param CMSApplicationInterface $app The application
* *
* @return mixed Null if no weblinks based on input parameters else an array containing all the weblinks. * @return mixed Null if no weblinks based on input parameters else an array containing all the weblinks.
* *
* @since 1.5 * @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 // Set application parameters in model
$appParams = $app->getParams(); $appParams = $app->getParams();
$model->setState('params', $appParams); $model->setState('params', $appParams);