NEW Add getter and setter for removeRelation in GridFieldDeleteAction

This allows users to modify the property value in the component without having to
remove it and add a new one when they want to change it.
This commit is contained in:
Robbie Averill 2018-01-12 14:23:00 +13:00
parent 844a4c96e4
commit 9fddb5de99

View File

@ -41,7 +41,7 @@ class GridFieldDeleteAction implements GridField_ColumnProvider, GridField_Actio
*/
public function __construct($removeRelation = false)
{
$this->removeRelation = $removeRelation;
$this->setRemoveRelation($removeRelation);
}
/**
@ -115,7 +115,7 @@ class GridFieldDeleteAction implements GridField_ColumnProvider, GridField_Actio
*/
public function getColumnContent($gridField, $record, $columnName)
{
if ($this->removeRelation) {
if ($this->getRemoveRelation()) {
if (!$record->canEdit()) {
return null;
}
@ -187,4 +187,25 @@ class GridFieldDeleteAction implements GridField_ColumnProvider, GridField_Actio
}
}
}
/**
* Get whether to remove or delete the relation
*
* @return bool
*/
public function getRemoveRelation()
{
return $this->removeRelation;
}
/**
* Set whether to remove or delete the relation
* @param bool $removeRelation
* @return $this
*/
public function setRemoveRelation($removeRelation)
{
$this->removeRelation = (bool) $removeRelation;
return $this;
}
}