Skip to content

Commit cd42246

Browse files
laoneojoomla-bot
andauthored
Get ordering from model in module controller (#37635)
* Get ordering from model in module controller * imports * Phase 1 convert BRANCH to PSR-12 * Phase 2 convert BRANCH to PSR-12 --------- Co-authored-by: Joomla! Bot <[email protected]>
1 parent 4a67d25 commit cd42246

File tree

1 file changed

+5
-15
lines changed

1 file changed

+5
-15
lines changed

administrator/components/com_modules/src/Controller/ModuleController.php

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
namespace Joomla\Component\Modules\Administrator\Controller;
1212

13-
use Joomla\CMS\Factory;
1413
use Joomla\CMS\Form\Form;
1514
use Joomla\CMS\Language\Text;
1615
use Joomla\CMS\MVC\Controller\FormController;
@@ -19,7 +18,6 @@
1918
use Joomla\CMS\Router\Route;
2019
use Joomla\CMS\Session\Session;
2120
use Joomla\CMS\Uri\Uri;
22-
use Joomla\Database\ParameterType;
2321

2422
// phpcs:disable PSR1.Files.SideEffects
2523
\defined('_JEXEC') or die;
@@ -279,21 +277,13 @@ public function orderPosition()
279277
$app->close();
280278
}
281279

282-
$db = Factory::getDbo();
283-
$clientId = (int) $clientId;
284-
$query = $db->getQuery(true)
285-
->select($db->quoteName(['position', 'ordering', 'title']))
286-
->from($db->quoteName('#__modules'))
287-
->where($db->quoteName('client_id') . ' = :clientid')
288-
->where($db->quoteName('position') . ' = :position')
289-
->order($db->quoteName('ordering'))
290-
->bind(':clientid', $clientId, ParameterType::INTEGER)
291-
->bind(':position', $position);
292-
293-
$db->setQuery($query);
280+
$model = $this->getModel('Modules', 'Administrator', ['ignore_request' => true]);
281+
$model->setState('client_id', $clientId);
282+
$model->setState('filter.position', $position);
283+
$model->setState('list.ordering', 'a.ordering');
294284

295285
try {
296-
$orders = $db->loadObjectList();
286+
$orders = $model->getItems();
297287
} catch (\RuntimeException $e) {
298288
$app->enqueueMessage($e->getMessage(), 'error');
299289

0 commit comments

Comments
 (0)