Skip to content

Commit 6682213

Browse files
authored
[5.3] Refactoring views to directly call models (com_actionlogs to com_finder) (joomla#44149)
* Refactoring views to directly call models (com_actionlogs to com_finder) * Missed a few * One more fix
1 parent cb1d4a0 commit 6682213

File tree

35 files changed

+261
-159
lines changed

35 files changed

+261
-159
lines changed

administrator/components/com_associations/src/View/Associations/HtmlView.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Joomla\CMS\Router\Route;
1818
use Joomla\CMS\Toolbar\ToolbarHelper;
1919
use Joomla\Component\Associations\Administrator\Helper\AssociationsHelper;
20+
use Joomla\Component\Associations\Administrator\Model\AssociationsModel;
2021

2122
// phpcs:disable PSR1.Files.SideEffects
2223
\defined('_JEXEC') or die;
@@ -126,9 +127,12 @@ class HtmlView extends BaseHtmlView
126127
*/
127128
public function display($tpl = null)
128129
{
129-
$this->state = $this->get('State');
130-
$this->filterForm = $this->get('FilterForm');
131-
$this->activeFilters = $this->get('ActiveFilters');
130+
/** @var AssociationsModel $model */
131+
$model = $this->getModel();
132+
133+
$this->state = $model->getState();
134+
$this->filterForm = $model->getFilterForm();
135+
$this->activeFilters = $model->getActiveFilters();
132136

133137
if (!Associations::isEnabled()) {
134138
$link = Route::_('index.php?option=com_plugins&task=plugin.edit&extension_id=' . AssociationsHelper::getLanguagefilterPluginId());
@@ -211,8 +215,8 @@ public function display($tpl = null)
211215
}
212216
}
213217

214-
$this->items = $this->get('Items');
215-
$this->pagination = $this->get('Pagination');
218+
$this->items = $model->getItems();
219+
$this->pagination = $model->getPagination();
216220

217221
$linkParameters = [
218222
'layout' => 'edit',
@@ -225,7 +229,7 @@ public function display($tpl = null)
225229
}
226230

227231
// Check for errors.
228-
if (\count($errors = $this->get('Errors'))) {
232+
if (\count($errors = $model->getErrors())) {
229233
throw new \Exception(implode("\n", $errors), 500);
230234
}
231235

administrator/components/com_banners/src/View/Banner/HtmlView.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function display($tpl = null): void
7676
$this->state = $model->getState();
7777

7878
// Check for errors.
79-
if (\count($errors = $this->get('Errors'))) {
79+
if (\count($errors = $model->getErrors())) {
8080
throw new GenericDataException(implode("\n", $errors), 500);
8181
}
8282

administrator/components/com_banners/src/View/Banners/HtmlView.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,12 @@ public function display($tpl = null): void
110110
$this->filterForm = $model->getFilterForm();
111111
$this->activeFilters = $model->getActiveFilters();
112112

113-
if (!\count($this->items) && $this->isEmptyState = $this->get('IsEmptyState')) {
113+
if (!\count($this->items) && $this->isEmptyState = $model->getIsEmptyState()) {
114114
$this->setLayout('emptystate');
115115
}
116116

117117
// Check for errors.
118-
if (\count($errors = $this->get('Errors'))) {
118+
if (\count($errors = $model->getErrors())) {
119119
throw new GenericDataException(implode("\n", $errors), 500);
120120
}
121121

administrator/components/com_banners/src/View/Client/HtmlView.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public function display($tpl = null): void
8585
$this->canDo = ContentHelper::getActions('com_banners');
8686

8787
// Check for errors.
88-
if (\count($errors = $this->get('Errors'))) {
88+
if (\count($errors = $model->getErrors())) {
8989
throw new GenericDataException(implode("\n", $errors), 500);
9090
}
9191

administrator/components/com_banners/src/View/Clients/HtmlView.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,12 @@ public function display($tpl = null): void
9999
$this->filterForm = $model->getFilterForm();
100100
$this->activeFilters = $model->getActiveFilters();
101101

102-
if (!\count($this->items) && $this->isEmptyState = $this->get('IsEmptyState')) {
102+
if (!\count($this->items) && $this->isEmptyState = $model->getIsEmptyState()) {
103103
$this->setLayout('emptystate');
104104
}
105105

106106
// Check for errors.
107-
if (\count($errors = $this->get('Errors'))) {
107+
if (\count($errors = $model->getErrors())) {
108108
throw new GenericDataException(implode("\n", $errors), 500);
109109
}
110110

administrator/components/com_banners/src/View/Download/HtmlView.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function display($tpl = null): void
5252
$this->form = $model->getForm();
5353

5454
// Check for errors.
55-
if (\count($errors = $this->get('Errors'))) {
55+
if (\count($errors = $model->getErrors())) {
5656
throw new GenericDataException(implode("\n", $errors), 500);
5757
}
5858

administrator/components/com_banners/src/View/Tracks/HtmlView.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,12 @@ public function display($tpl = null): void
9999
$this->filterForm = $model->getFilterForm();
100100
$this->activeFilters = $model->getActiveFilters();
101101

102-
if (!\count($this->items) && $this->isEmptyState = $this->get('IsEmptyState')) {
102+
if (!\count($this->items) && $this->isEmptyState = $model->getIsEmptyState()) {
103103
$this->setLayout('emptystate');
104104
}
105105

106106
// Check for errors.
107-
if (\count($errors = $this->get('Errors'))) {
107+
if (\count($errors = $model->getErrors())) {
108108
throw new GenericDataException(implode("\n", $errors), 500);
109109
}
110110

administrator/components/com_banners/src/View/Tracks/RawView.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function display($tpl = null): void
4848
$content = $model->getContent();
4949

5050
// Check for errors.
51-
if (\count($errors = $this->get('Errors'))) {
51+
if (\count($errors = $model->getErrors())) {
5252
throw new GenericDataException(implode("\n", $errors), 500);
5353
}
5454

administrator/components/com_cache/src/View/Cache/HtmlView.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public function display($tpl = null): void
100100
$this->activeFilters = $model->getActiveFilters();
101101

102102
// Check for errors.
103-
if (\count($errors = $this->get('Errors'))) {
103+
if (\count($errors = $model->getErrors())) {
104104
throw new GenericDataException(implode("\n", $errors), 500);
105105
}
106106

administrator/components/com_categories/src/View/Categories/HtmlView.php

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use Joomla\CMS\Pagination\Pagination;
2121
use Joomla\CMS\Toolbar\Button\DropdownButton;
2222
use Joomla\CMS\Toolbar\ToolbarHelper;
23+
use Joomla\Component\Categories\Administrator\Model\CategoriesModel;
2324
use Joomla\Filesystem\Path;
2425

2526
// phpcs:disable PSR1.Files.SideEffects
@@ -102,20 +103,23 @@ class HtmlView extends BaseHtmlView
102103
*/
103104
public function display($tpl = null)
104105
{
105-
$this->state = $this->get('State');
106-
$this->items = $this->get('Items');
107-
$this->pagination = $this->get('Pagination');
108-
$this->assoc = $this->get('Assoc');
109-
$this->filterForm = $this->get('FilterForm');
110-
$this->activeFilters = $this->get('ActiveFilters');
106+
/** @var CategoriesModel $model */
107+
$model = $this->getModel();
108+
109+
$this->state = $model->getState();
110+
$this->items = $model->getItems();
111+
$this->pagination = $model->getPagination();
112+
$this->assoc = $model->getAssoc();
113+
$this->filterForm = $model->getFilterForm();
114+
$this->activeFilters = $model->getActiveFilters();
111115

112116
// Written this way because we only want to call IsEmptyState if no items, to prevent always calling it when not needed.
113-
if (!\count($this->items) && $this->isEmptyState = $this->get('IsEmptyState')) {
117+
if (!\count($this->items) && $this->isEmptyState = $model->getIsEmptyState()) {
114118
$this->setLayout('emptystate');
115119
}
116120

117121
// Check for errors.
118-
if (\count($errors = $this->get('Errors'))) {
122+
if (\count($errors = $model->getErrors())) {
119123
throw new GenericDataException(implode("\n", $errors), 500);
120124
}
121125

0 commit comments

Comments
 (0)