DEP Deprecate configurable silent failures in GridField components

This commit is contained in:
Guy Sartorelli 2023-11-13 12:12:03 +13:00
parent cfd8f05a04
commit bc47d65cc5
No known key found for this signature in database
GPG Key ID: F313E3B9504D496A
6 changed files with 42 additions and 9 deletions

View File

@ -2,6 +2,8 @@
namespace SilverStripe\Forms\GridField;
use SilverStripe\Dev\Deprecation;
/**
* A simple readonly, paginated view of records, with sortable and searchable
* headers.
@ -23,9 +25,11 @@ class GridFieldConfig_Base extends GridFieldConfig
$this->addComponent(GridFieldPageCount::create('toolbar-header-right'));
$this->addComponent($pagination = GridFieldPaginator::create($itemsPerPage));
$sort->setThrowExceptionOnBadDataType(false);
$filter->setThrowExceptionOnBadDataType(false);
$pagination->setThrowExceptionOnBadDataType(false);
Deprecation::withNoReplacement(function () use ($sort, $filter, $pagination) {
$sort->setThrowExceptionOnBadDataType(false);
$filter->setThrowExceptionOnBadDataType(false);
$pagination->setThrowExceptionOnBadDataType(false);
});
$this->extend('updateConfig');
}

View File

@ -1,6 +1,8 @@
<?php
namespace SilverStripe\Forms\GridField;
use SilverStripe\Dev\Deprecation;
/**
* Allows editing of records contained within the GridField, instead of only allowing the ability to view records in
* the GridField.
@ -30,9 +32,11 @@ class GridFieldConfig_RecordEditor extends GridFieldConfig
$this->addComponent($pagination = GridFieldPaginator::create($itemsPerPage));
$this->addComponent(GridFieldDetailForm::create(null, $showPagination, $showAdd));
$sort->setThrowExceptionOnBadDataType(false);
$filter->setThrowExceptionOnBadDataType(false);
$pagination->setThrowExceptionOnBadDataType(false);
Deprecation::withNoReplacement(function () use ($sort, $filter, $pagination) {
$sort->setThrowExceptionOnBadDataType(false);
$filter->setThrowExceptionOnBadDataType(false);
$pagination->setThrowExceptionOnBadDataType(false);
});
$this->extend('updateConfig');
}

View File

@ -2,6 +2,8 @@
namespace SilverStripe\Forms\GridField;
use SilverStripe\Dev\Deprecation;
/**
* Similar to {@link GridFieldConfig_RecordEditor}, but adds features to work
* on has-many or many-many relationships.
@ -43,9 +45,11 @@ class GridFieldConfig_RelationEditor extends GridFieldConfig
$this->addComponent($pagination = GridFieldPaginator::create($itemsPerPage));
$this->addComponent(GridFieldDetailForm::create());
$sort->setThrowExceptionOnBadDataType(false);
$filter->setThrowExceptionOnBadDataType(false);
$pagination->setThrowExceptionOnBadDataType(false);
Deprecation::withNoReplacement(function () use ($sort, $filter, $pagination) {
$sort->setThrowExceptionOnBadDataType(false);
$filter->setThrowExceptionOnBadDataType(false);
$pagination->setThrowExceptionOnBadDataType(false);
});
$this->extend('updateConfig');
}

View File

@ -7,6 +7,7 @@ use SilverStripe\Admin\LeftAndMain;
use SilverStripe\Control\Controller;
use SilverStripe\Control\HTTPResponse;
use SilverStripe\Core\ClassInfo;
use SilverStripe\Dev\Deprecation;
use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\Form;
use SilverStripe\Forms\Schema\FormSchema;
@ -27,6 +28,7 @@ class GridFieldFilterHeader extends AbstractGridFieldComponent implements GridFi
* See {@link setThrowExceptionOnBadDataType()}
*
* @var bool
* @deprecated 5.2.0 Will be removed without equivalent functionality
*/
protected $throwExceptionOnBadDataType = true;
@ -66,17 +68,21 @@ class GridFieldFilterHeader extends AbstractGridFieldComponent implements GridFi
* {@link GridFieldConfig} subclasses set this to false for flexibility.
*
* @param bool $throwExceptionOnBadDataType
* @deprecated 5.2.0 Will be removed without equivalent functionality
*/
public function setThrowExceptionOnBadDataType($throwExceptionOnBadDataType)
{
Deprecation::notice('5.2.0', 'Will be removed without equivalent functionality');
$this->throwExceptionOnBadDataType = $throwExceptionOnBadDataType;
}
/**
* See {@link setThrowExceptionOnBadDataType()}
* @deprecated 5.2.0 Will be removed without equivalent functionality
*/
public function getThrowExceptionOnBadDataType()
{
Deprecation::notice('5.2.0', 'Will be removed without equivalent functionality');
return $this->throwExceptionOnBadDataType;
}
@ -103,6 +109,7 @@ class GridFieldFilterHeader extends AbstractGridFieldComponent implements GridFi
if ($dataList instanceof Filterable) {
return true;
} else {
// This will be changed to always throw an exception in a future major release.
if ($this->throwExceptionOnBadDataType) {
throw new LogicException(
static::class . " expects an SS_Filterable list to be passed to the GridField."

View File

@ -9,6 +9,7 @@ use SilverStripe\ORM\UnsavedRelationList;
use SilverStripe\View\ArrayData;
use SilverStripe\View\SSViewer;
use LogicException;
use SilverStripe\Dev\Deprecation;
/**
* GridFieldPaginator paginates the {@link GridField} list and adds controls
@ -33,6 +34,7 @@ class GridFieldPaginator extends AbstractGridFieldComponent implements GridField
/**
* See {@link setThrowExceptionOnBadDataType()}
* @deprecated 5.2.0 Will be removed without equivalent functionality
*/
protected $throwExceptionOnBadDataType = true;
@ -57,9 +59,11 @@ class GridFieldPaginator extends AbstractGridFieldComponent implements GridField
*
* @param bool $throwExceptionOnBadDataType
* @return $this
* @deprecated 5.2.0 Will be removed without equivalent functionality
*/
public function setThrowExceptionOnBadDataType($throwExceptionOnBadDataType)
{
Deprecation::notice('5.2.0', 'Will be removed without equivalent functionality');
$this->throwExceptionOnBadDataType = $throwExceptionOnBadDataType;
return $this;
}
@ -68,9 +72,11 @@ class GridFieldPaginator extends AbstractGridFieldComponent implements GridField
* See {@link setThrowExceptionOnBadDataType()}
*
* @return bool
* @deprecated 5.2.0 Will be removed without equivalent functionality
*/
public function getThrowExceptionOnBadDataType()
{
Deprecation::notice('5.2.0', 'Will be removed without equivalent functionality');
return $this->throwExceptionOnBadDataType;
}
@ -86,6 +92,7 @@ class GridFieldPaginator extends AbstractGridFieldComponent implements GridField
if ($dataList instanceof Limitable) {
return true;
} else {
// This will be changed to always throw an exception in a future major release.
if ($this->throwExceptionOnBadDataType) {
throw new LogicException(
static::class . " expects an SS_Limitable list to be passed to the GridField."

View File

@ -12,6 +12,7 @@ use SilverStripe\View\ArrayData;
use SilverStripe\View\SSViewer;
use LogicException;
use SilverStripe\Core\Injector\Injector;
use SilverStripe\Dev\Deprecation;
/**
* GridFieldSortableHeader adds column headers to a {@link GridField} that can
@ -26,6 +27,7 @@ class GridFieldSortableHeader extends AbstractGridFieldComponent implements Grid
* See {@link setThrowExceptionOnBadDataType()}
*
* @var bool
* @deprecated 5.2.0 Will be removed without equivalent functionality
*/
protected $throwExceptionOnBadDataType = true;
@ -45,9 +47,11 @@ class GridFieldSortableHeader extends AbstractGridFieldComponent implements Grid
*
* @param bool $throwExceptionOnBadDataType
* @return $this
* @deprecated 5.2.0 Will be removed without equivalent functionality
*/
public function setThrowExceptionOnBadDataType($throwExceptionOnBadDataType)
{
Deprecation::notice('5.2.0', 'Will be removed without equivalent functionality');
$this->throwExceptionOnBadDataType = $throwExceptionOnBadDataType;
return $this;
}
@ -56,9 +60,11 @@ class GridFieldSortableHeader extends AbstractGridFieldComponent implements Grid
* See {@link setThrowExceptionOnBadDataType()}
*
* @return bool
* @deprecated 5.2.0 Will be removed without equivalent functionality
*/
public function getThrowExceptionOnBadDataType()
{
Deprecation::notice('5.2.0', 'Will be removed without equivalent functionality');
return $this->throwExceptionOnBadDataType;
}
@ -74,6 +80,7 @@ class GridFieldSortableHeader extends AbstractGridFieldComponent implements Grid
if ($dataList instanceof Sortable) {
return true;
} else {
// This will be changed to always throw an exception in a future major release.
if ($this->throwExceptionOnBadDataType) {
throw new LogicException(
static::class . " expects an SS_Sortable list to be passed to the GridField."