Skip to content

Commit 744a665

Browse files
authored
[5.3] Refactoring views to directly call models (com_plugins to com_workflow) (joomla#44167)
* Refactoring views to directly call models (com_plugins to com_workflow) * Missed a few
1 parent 6682213 commit 744a665

File tree

37 files changed

+328
-199
lines changed

37 files changed

+328
-199
lines changed

administrator/components/com_plugins/src/View/Plugin/HtmlView.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Joomla\CMS\MVC\View\GenericDataException;
1717
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
1818
use Joomla\CMS\Toolbar\ToolbarHelper;
19+
use Joomla\Component\Plugins\Administrator\Model\PluginModel;
1920

2021
// phpcs:disable PSR1.Files.SideEffects
2122
\defined('_JEXEC') or die;
@@ -67,9 +68,12 @@ class HtmlView extends BaseHtmlView
6768
*/
6869
public function display($tpl = null)
6970
{
70-
$this->state = $this->get('State');
71-
$this->item = $this->get('Item');
72-
$this->form = $this->get('Form');
71+
/** @var PluginModel $model */
72+
$model = $this->getModel();
73+
74+
$this->state = $model->getState();
75+
$this->item = $model->getItem();
76+
$this->form = $model->getForm();
7377

7478
if ($this->getLayout() === 'modalreturn') {
7579
parent::display($tpl);
@@ -78,7 +82,7 @@ public function display($tpl = null)
7882
}
7983

8084
// Check for errors.
81-
if (\count($errors = $this->get('Errors'))) {
85+
if (\count($errors = $model->getErrors())) {
8286
throw new GenericDataException(implode("\n", $errors), 500);
8387
}
8488

@@ -120,7 +124,9 @@ protected function addToolbar()
120124
// Get the help information for the plugin item.
121125
$lang = $this->getLanguage();
122126

123-
$help = $this->get('Help');
127+
/** @var PluginModel $model */
128+
$model = $this->getModel();
129+
$help = $model->getHelp();
124130

125131
if ($help->url && $lang->hasKey($help->url)) {
126132
$debug = $lang->setDebug(false);

administrator/components/com_plugins/src/View/Plugins/HtmlView.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Joomla\CMS\MVC\View\GenericDataException;
1616
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
1717
use Joomla\CMS\Toolbar\ToolbarHelper;
18+
use Joomla\Component\Plugins\Administrator\Model\PluginsModel;
1819

1920
// phpcs:disable PSR1.Files.SideEffects
2021
\defined('_JEXEC') or die;
@@ -73,14 +74,17 @@ class HtmlView extends BaseHtmlView
7374
*/
7475
public function display($tpl = null)
7576
{
76-
$this->items = $this->get('Items');
77-
$this->pagination = $this->get('Pagination');
78-
$this->state = $this->get('State');
79-
$this->filterForm = $this->get('FilterForm');
80-
$this->activeFilters = $this->get('ActiveFilters');
77+
/** @var PluginsModel $model */
78+
$model = $this->getModel();
79+
80+
$this->items = $model->getItems();
81+
$this->pagination = $model->getPagination();
82+
$this->state = $model->getState();
83+
$this->filterForm = $model->getFilterForm();
84+
$this->activeFilters = $model->getActiveFilters();
8185

8286
// Check for errors.
83-
if (\count($errors = $this->get('Errors'))) {
87+
if (\count($errors = $model->getErrors())) {
8488
throw new GenericDataException(implode("\n", $errors), 500);
8589
}
8690

administrator/components/com_privacy/src/View/Capabilities/HtmlView.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Joomla\CMS\MVC\View\GenericDataException;
1515
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
1616
use Joomla\CMS\Toolbar\ToolbarHelper;
17+
use Joomla\Component\Privacy\Administrator\Model\CapabilitiesModel;
1718

1819
// phpcs:disable PSR1.Files.SideEffects
1920
\defined('_JEXEC') or die;
@@ -55,12 +56,15 @@ class HtmlView extends BaseHtmlView
5556
*/
5657
public function display($tpl = null)
5758
{
59+
/** @var CapabilitiesModel $model */
60+
$model = $this->getModel();
61+
5862
// Initialise variables
59-
$this->capabilities = $this->get('Capabilities');
60-
$this->state = $this->get('State');
63+
$this->capabilities = $model->getCapabilities();
64+
$this->state = $model->getState();
6165

6266
// Check for errors.
63-
if (\count($errors = $this->get('Errors'))) {
67+
if (\count($errors = $model->getErrors())) {
6468
throw new Genericdataexception(implode("\n", $errors), 500);
6569
}
6670

administrator/components/com_privacy/src/View/Consents/HtmlView.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,19 +93,20 @@ class HtmlView extends BaseHtmlView
9393
public function display($tpl = null)
9494
{
9595
/** @var ConsentsModel $model */
96-
$model = $this->getModel();
96+
$model = $this->getModel();
97+
9798
$this->items = $model->getItems();
9899
$this->pagination = $model->getPagination();
99100
$this->state = $model->getState();
100101
$this->filterForm = $model->getFilterForm();
101102
$this->activeFilters = $model->getActiveFilters();
102103

103-
if (!\count($this->items) && $this->isEmptyState = $this->get('IsEmptyState')) {
104+
if (!\count($this->items) && $this->isEmptyState = $model->getIsEmptyState()) {
104105
$this->setLayout('emptystate');
105106
}
106107

107108
// Check for errors.
108-
if (\count($errors = $this->get('Errors'))) {
109+
if (\count($errors = $model->getErrors())) {
109110
throw new Genericdataexception(implode("\n", $errors), 500);
110111
}
111112

administrator/components/com_privacy/src/View/Export/XmlView.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function display($tpl = null)
4646
$exportData = $model->collectDataForExportRequest();
4747

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

administrator/components/com_privacy/src/View/Request/HtmlView.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,11 @@ public function display($tpl = null)
9696

9797
// Variables only required for the edit layout
9898
if ($this->getLayout() === 'edit') {
99-
$this->form = $this->get('Form');
99+
$this->form = $model->getForm();
100100
}
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_privacy/src/View/Requests/HtmlView.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,12 @@ public function display($tpl = null)
112112
$this->urgentRequestAge = (int) ComponentHelper::getParams('com_privacy')->get('notify', 14);
113113
$this->sendMailEnabled = (bool) Factory::getApplication()->get('mailonline', 1);
114114

115-
if (!\count($this->items) && $this->get('IsEmptyState')) {
115+
if (!\count($this->items) && $model->getIsEmptyState()) {
116116
$this->setLayout('emptystate');
117117
}
118118

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

administrator/components/com_redirect/src/View/Link/HtmlView.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
1818
use Joomla\CMS\Toolbar\Toolbar;
1919
use Joomla\CMS\Toolbar\ToolbarHelper;
20+
use Joomla\Component\Redirect\Administrator\Model\LinkModel;
2021

2122
// phpcs:disable PSR1.Files.SideEffects
2223
\defined('_JEXEC') or die;
@@ -61,12 +62,15 @@ class HtmlView extends BaseHtmlView
6162
*/
6263
public function display($tpl = null)
6364
{
64-
$this->form = $this->get('Form');
65-
$this->item = $this->get('Item');
66-
$this->state = $this->get('State');
65+
/** @var LinkModel $model */
66+
$model = $this->getModel();
67+
68+
$this->form = $model->getForm();
69+
$this->item = $model->getItem();
70+
$this->state = $model->getState();
6771

6872
// Check for errors.
69-
if (\count($errors = $this->get('Errors'))) {
73+
if (\count($errors = $model->getErrors())) {
7074
throw new GenericDataException(implode("\n", $errors), 500);
7175
}
7276

administrator/components/com_redirect/src/View/Links/HtmlView.php

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Joomla\CMS\Toolbar\Button\DropdownButton;
2020
use Joomla\CMS\Toolbar\ToolbarHelper;
2121
use Joomla\Component\Redirect\Administrator\Helper\RedirectHelper;
22+
use Joomla\Component\Redirect\Administrator\Model\LinksModel;
2223

2324
// phpcs:disable PSR1.Files.SideEffects
2425
\defined('_JEXEC') or die;
@@ -118,20 +119,23 @@ class HtmlView extends BaseHtmlView
118119
*/
119120
public function display($tpl = null)
120121
{
122+
/** @var LinksModel $model */
123+
$model = $this->getModel();
124+
121125
// Set variables
122-
$this->items = $this->get('Items');
123-
$this->pagination = $this->get('Pagination');
124-
$this->state = $this->get('State');
125-
$this->filterForm = $this->get('FilterForm');
126-
$this->activeFilters = $this->get('ActiveFilters');
126+
$this->items = $model->getItems();
127+
$this->pagination = $model->getPagination();
128+
$this->state = $model->getState();
129+
$this->filterForm = $model->getFilterForm();
130+
$this->activeFilters = $model->getActiveFilters();
127131
$this->params = ComponentHelper::getParams('com_redirect');
128132

129-
if (!\count($this->items) && $this->isEmptyState = $this->get('IsEmptyState')) {
133+
if (!\count($this->items) && $this->isEmptyState = $model->getIsEmptyState()) {
130134
$this->setLayout('emptystate');
131135
}
132136

133137
// Check for errors.
134-
if (\count($errors = $this->get('Errors'))) {
138+
if (\count($errors = $model->getErrors())) {
135139
throw new GenericDataException(implode("\n", $errors), 500);
136140
}
137141

@@ -153,7 +157,7 @@ public function display($tpl = null)
153157
*/
154158
protected function addToolbar()
155159
{
156-
$state = $this->get('State');
160+
$state = $this->state;
157161
$canDo = ContentHelper::getActions('com_redirect');
158162
$toolbar = $this->getDocument()->getToolbar();
159163

administrator/components/com_scheduler/src/View/Select/HtmlView.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Joomla\CMS\MVC\View\GenericDataException;
1717
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
1818
use Joomla\CMS\Toolbar\ToolbarHelper;
19+
use Joomla\Component\Scheduler\Administrator\Model\SelectModel;
1920
use Joomla\Component\Scheduler\Administrator\Task\TaskOption;
2021

2122
// phpcs:disable PSR1.Files.SideEffects
@@ -85,11 +86,14 @@ public function __construct($config = [])
8586
*/
8687
public function display($tpl = null): void
8788
{
88-
$this->state = $this->get('State');
89-
$this->items = $this->get('Items');
89+
/** @var SelectModel $model */
90+
$model = $this->getModel();
91+
92+
$this->state = $model->getState();
93+
$this->items = $model->getItems();
9094

9195
// Check for errors.
92-
if (\count($errors = $this->get('Errors'))) {
96+
if (\count($errors = $model->getErrors())) {
9397
throw new GenericDataException(implode("\n", $errors), 500);
9498
}
9599

0 commit comments

Comments
 (0)