mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-04 23:28:41 +02:00
Merge pull request #256 from halkyon/cleanup
GridFieldDeleteAction minor tidy up
This commit is contained in:
commit
5061c8c608
@ -1,11 +1,20 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* This class is an GridField Component that add Delete action for Objects in the GridField.
|
* This class is a {@link GridField} component that adds a delete action for objects.
|
||||||
* See {@link GridFieldRemoveButton} for detaching an item from the current relationship instead.
|
*
|
||||||
|
* This component also supports unlinking a relation instead of deleting the object.
|
||||||
|
* Use the {@link $removeRelation} property set in the constructor.
|
||||||
|
*
|
||||||
|
* <code>
|
||||||
|
* $action = new GridFieldDeleteAction(); // delete objects permanently
|
||||||
|
* $action = new GridFieldDeleteAction(true); // removes the relation to object, instead of deleting
|
||||||
|
* </code>
|
||||||
|
*
|
||||||
|
* @package sapphire
|
||||||
|
* @subpackage gridfield
|
||||||
*/
|
*/
|
||||||
class GridFieldDeleteAction implements GridField_ColumnProvider, GridField_ActionProvider {
|
class GridFieldDeleteAction implements GridField_ColumnProvider, GridField_ActionProvider {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If this is set to true, this actionprovider will remove the object from the list, instead of
|
* If this is set to true, this actionprovider will remove the object from the list, instead of
|
||||||
* deleting. In the case of a has one, has many or many many list it will uncouple the item from
|
* deleting. In the case of a has one, has many or many many list it will uncouple the item from
|
||||||
@ -17,10 +26,10 @@ class GridFieldDeleteAction implements GridField_ColumnProvider, GridField_Actio
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param boolean $unlinkRelation - true if removing the item from the list, but not deleting it
|
* @param boolean $removeRelation - true if removing the item from the list, but not deleting it
|
||||||
*/
|
*/
|
||||||
public function __construct($unlinkRelation = false) {
|
public function __construct($removeRelation = false) {
|
||||||
$this->removeRelation = $unlinkRelation;
|
$this->removeRelation = $removeRelation;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -30,9 +39,10 @@ class GridFieldDeleteAction implements GridField_ColumnProvider, GridField_Actio
|
|||||||
* @param array $columns
|
* @param array $columns
|
||||||
*/
|
*/
|
||||||
public function augmentColumns($gridField, &$columns) {
|
public function augmentColumns($gridField, &$columns) {
|
||||||
if(!in_array('Actions', $columns))
|
if(!in_array('Actions', $columns)) {
|
||||||
$columns[] = 'Actions';
|
$columns[] = 'Actions';
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return any special attributes that will be used for FormField::createTag()
|
* Return any special attributes that will be used for FormField::createTag()
|
||||||
|
Loading…
Reference in New Issue
Block a user