Skip to content

Commit 26315d8

Browse files
authored
[5.4] Change backend views to exceptions instead of legacy error handling (#44828)
1 parent 989dae9 commit 26315d8

File tree

82 files changed

+268
-862
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+268
-862
lines changed

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use Joomla\CMS\Factory;
1515
use Joomla\CMS\Form\Form;
1616
use Joomla\CMS\Language\Text;
17-
use Joomla\CMS\MVC\View\GenericDataException;
1817
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
1918
use Joomla\CMS\Pagination\Pagination;
2019
use Joomla\CMS\Router\Route;
@@ -223,11 +222,7 @@ public function display($tpl = null): void
223222
{
224223
/** @var AssociationModel $model */
225224
$model = $this->getModel();
226-
227-
// Check for errors.
228-
if (\count($errors = $model->getErrors())) {
229-
throw new GenericDataException(implode("\n", $errors), 500);
230-
}
225+
$model->setUseExceptions(true);
231226

232227
$this->app = Factory::getApplication();
233228
$this->form = $model->getForm();

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ public function display($tpl = null)
129129
{
130130
/** @var AssociationsModel $model */
131131
$model = $this->getModel();
132+
$model->setUseExceptions(true);
132133

133134
$this->state = $model->getState();
134135
$this->filterForm = $model->getFilterForm();
@@ -227,11 +228,6 @@ public function display($tpl = null)
227228
}
228229
}
229230

230-
// Check for errors.
231-
if (\count($errors = $model->getErrors())) {
232-
throw new \Exception(implode("\n", $errors), 500);
233-
}
234-
235231
$this->addToolbar();
236232

237233
parent::display($tpl);

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use Joomla\CMS\Helper\ContentHelper;
1515
use Joomla\CMS\Language\Multilanguage;
1616
use Joomla\CMS\Language\Text;
17-
use Joomla\CMS\MVC\View\GenericDataException;
1817
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
1918
use Joomla\CMS\Pagination\Pagination;
2019
use Joomla\CMS\Toolbar\Button\DropdownButton;
@@ -102,7 +101,9 @@ class HtmlView extends BaseHtmlView
102101
public function display($tpl = null): void
103102
{
104103
/** @var BannersModel $model */
105-
$model = $this->getModel();
104+
$model = $this->getModel();
105+
$model->setUseExceptions(true);
106+
106107
$this->categories = $model->getCategoryOrders();
107108
$this->items = $model->getItems();
108109
$this->pagination = $model->getPagination();
@@ -114,11 +115,6 @@ public function display($tpl = null): void
114115
$this->setLayout('emptystate');
115116
}
116117

117-
// Check for errors.
118-
if (\count($errors = $model->getErrors())) {
119-
throw new GenericDataException(implode("\n", $errors), 500);
120-
}
121-
122118
$this->addToolbar();
123119

124120
// We do not need to filter by language when multilingual is disabled

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
use Joomla\CMS\Form\Form;
1414
use Joomla\CMS\Helper\ContentHelper;
1515
use Joomla\CMS\Language\Text;
16-
use Joomla\CMS\MVC\View\GenericDataException;
1716
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
1817
use Joomla\CMS\Pagination\Pagination;
1918
use Joomla\CMS\Toolbar\ToolbarHelper;
@@ -92,7 +91,9 @@ class HtmlView extends BaseHtmlView
9291
public function display($tpl = null): void
9392
{
9493
/** @var ClientsModel $model */
95-
$model = $this->getModel();
94+
$model = $this->getModel();
95+
$model->setUseExceptions(true);
96+
9697
$this->items = $model->getItems();
9798
$this->pagination = $model->getPagination();
9899
$this->state = $model->getState();
@@ -103,11 +104,6 @@ public function display($tpl = null): void
103104
$this->setLayout('emptystate');
104105
}
105106

106-
// Check for errors.
107-
if (\count($errors = $model->getErrors())) {
108-
throw new GenericDataException(implode("\n", $errors), 500);
109-
}
110-
111107
$this->addToolbar();
112108

113109
parent::display($tpl);

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
namespace Joomla\Component\Banners\Administrator\View\Download;
1212

1313
use Joomla\CMS\Form\Form;
14-
use Joomla\CMS\MVC\View\GenericDataException;
1514
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
1615
use Joomla\Component\Banners\Administrator\Model\DownloadModel;
1716

@@ -48,13 +47,10 @@ class HtmlView extends BaseHtmlView
4847
public function display($tpl = null): void
4948
{
5049
/** @var DownloadModel $model */
51-
$model = $this->getModel();
52-
$this->form = $model->getForm();
50+
$model = $this->getModel();
51+
$model->setUseExceptions(true);
5352

54-
// Check for errors.
55-
if (\count($errors = $model->getErrors())) {
56-
throw new GenericDataException(implode("\n", $errors), 500);
57-
}
53+
$this->form = $model->getForm();
5854

5955
parent::display($tpl);
6056
}

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
use Joomla\CMS\Form\Form;
1414
use Joomla\CMS\Helper\ContentHelper;
1515
use Joomla\CMS\Language\Text;
16-
use Joomla\CMS\MVC\View\GenericDataException;
1716
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
1817
use Joomla\CMS\Pagination\Pagination;
1918
use Joomla\CMS\Router\Route;
@@ -92,7 +91,9 @@ class HtmlView extends BaseHtmlView
9291
public function display($tpl = null): void
9392
{
9493
/** @var TracksModel $model */
95-
$model = $this->getModel();
94+
$model = $this->getModel();
95+
$model->setUseExceptions(true);
96+
9697
$this->items = $model->getItems();
9798
$this->pagination = $model->getPagination();
9899
$this->state = $model->getState();
@@ -103,11 +104,6 @@ public function display($tpl = null): void
103104
$this->setLayout('emptystate');
104105
}
105106

106-
// Check for errors.
107-
if (\count($errors = $model->getErrors())) {
108-
throw new GenericDataException(implode("\n", $errors), 500);
109-
}
110-
111107
$this->addToolbar();
112108

113109
parent::display($tpl);

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,18 +92,15 @@ public function display($tpl = null): void
9292
{
9393
/** @var CacheModel $model */
9494
$model = $this->getModel();
95+
$model->setUseExceptions(true);
96+
9597
$this->data = $model->getData();
9698
$this->pagination = $model->getPagination();
9799
$this->total = $model->getTotal();
98100
$this->state = $model->getState();
99101
$this->filterForm = $model->getFilterForm();
100102
$this->activeFilters = $model->getActiveFilters();
101103

102-
// Check for errors.
103-
if (\count($errors = $model->getErrors())) {
104-
throw new GenericDataException(implode("\n", $errors), 500);
105-
}
106-
107104
if (!\count($this->data) && ($this->state->get('filter.search') === null || $this->state->get('filter.search') === '')) {
108105
$this->setLayout('emptystate');
109106
}

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ public function display($tpl = null)
105105
{
106106
/** @var CategoriesModel $model */
107107
$model = $this->getModel();
108+
$model->setUseExceptions(true);
108109

109110
$this->state = $model->getState();
110111
$this->items = $model->getItems();
@@ -118,11 +119,6 @@ public function display($tpl = null)
118119
$this->setLayout('emptystate');
119120
}
120121

121-
// Check for errors.
122-
if (\count($errors = $model->getErrors())) {
123-
throw new GenericDataException(implode("\n", $errors), 500);
124-
}
125-
126122
// Preprocess the list of items to find ordering divisions.
127123
foreach ($this->items as &$item) {
128124
$this->ordering[$item->parent_id][] = $item->id;

administrator/components/com_checkin/src/View/Checkin/HtmlView.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
namespace Joomla\Component\Checkin\Administrator\View\Checkin;
1212

1313
use Joomla\CMS\Language\Text;
14-
use Joomla\CMS\MVC\View\GenericDataException;
1514
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
1615
use Joomla\CMS\Toolbar\ToolbarHelper;
1716
use Joomla\Component\Checkin\Administrator\Model\CheckinModel;
@@ -93,6 +92,7 @@ public function display($tpl = null)
9392
{
9493
/** @var CheckinModel $model */
9594
$model = $this->getModel();
95+
$model->setUseExceptions(true);
9696

9797
$this->items = $model->getItems();
9898
$this->pagination = $model->getPagination();
@@ -106,11 +106,6 @@ public function display($tpl = null)
106106
$this->setLayout('emptystate');
107107
}
108108

109-
// Check for errors.
110-
if (\count($errors = $model->getErrors())) {
111-
throw new GenericDataException(implode("\n", $errors), 500);
112-
}
113-
114109
$this->addToolbar();
115110

116111
parent::display($tpl);

administrator/components/com_contact/src/View/Contacts/HtmlView.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use Joomla\CMS\Helper\ContentHelper;
1515
use Joomla\CMS\Language\Multilanguage;
1616
use Joomla\CMS\Language\Text;
17-
use Joomla\CMS\MVC\View\GenericDataException;
1817
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
1918
use Joomla\CMS\Toolbar\Button\DropdownButton;
2019
use Joomla\CMS\Toolbar\ToolbarHelper;
@@ -86,6 +85,7 @@ public function display($tpl = null)
8685
{
8786
/** @var ContactsModel $model */
8887
$model = $this->getModel();
88+
$model->setUseExceptions(true);
8989

9090
$this->items = $model->getItems();
9191
$this->pagination = $model->getPagination();
@@ -97,11 +97,6 @@ public function display($tpl = null)
9797
$this->setLayout('emptystate');
9898
}
9999

100-
// Check for errors.
101-
if (\count($errors = $model->getErrors())) {
102-
throw new GenericDataException(implode("\n", $errors), 500);
103-
}
104-
105100
// We don't need toolbar in the modal window.
106101
if ($this->getLayout() !== 'modal') {
107102
$this->addToolbar();

0 commit comments

Comments
 (0)