DOCS Update PSR-12 compliance in GridField_ActionProvider docs code examples

[ci skip]
This commit is contained in:
Robbie Averill 2019-09-13 18:09:10 -07:00
parent ed47f43133
commit b8e81983b9

View File

@ -51,7 +51,7 @@ class GridFieldCustomAction implements GridField_ColumnProvider, GridField_Actio
public function getColumnMetadata($gridField, $columnName) public function getColumnMetadata($gridField, $columnName)
{ {
if($columnName == 'Actions') { if ($columnName === 'Actions') {
return ['title' => '']; return ['title' => ''];
} }
} }
@ -63,7 +63,9 @@ class GridFieldCustomAction implements GridField_ColumnProvider, GridField_Actio
public function getColumnContent($gridField, $record, $columnName) public function getColumnContent($gridField, $record, $columnName)
{ {
if(!$record->canEdit()) return; if (!$record->canEdit()) {
return;
}
$field = GridField_FormAction::create( $field = GridField_FormAction::create(
$gridField, $gridField,
@ -83,7 +85,9 @@ class GridFieldCustomAction implements GridField_ColumnProvider, GridField_Actio
public function handleAction(GridField $gridField, $actionName, $arguments, $data) public function handleAction(GridField $gridField, $actionName, $arguments, $data)
{ {
if($actionName == 'docustomaction') { if ($actionName !== 'docustomaction') {
return;
}
// perform your action here // perform your action here
// output a success message to the user // output a success message to the user
@ -93,7 +97,6 @@ class GridFieldCustomAction implements GridField_ColumnProvider, GridField_Actio
); );
} }
} }
}
``` ```
## Add the GridFieldCustomAction to the current `GridFieldConfig` ## Add the GridFieldCustomAction to the current `GridFieldConfig`
@ -186,7 +189,9 @@ class GridFieldCustomAction implements GridField_ColumnProvider, GridField_Actio
public function getCustomAction($gridField, $record) public function getCustomAction($gridField, $record)
{ {
if(!$record->canEdit()) return; if (!$record->canEdit()) {
return;
}
return GridField_FormAction::create( return GridField_FormAction::create(
$gridField, $gridField,
@ -227,7 +232,7 @@ class GridFieldCustomAction implements GridField_ColumnProvider, GridField_Actio
public function getColumnMetadata($gridField, $columnName) public function getColumnMetadata($gridField, $columnName)
{ {
if($columnName == 'Actions') { if ($columnName === 'Actions') {
return ['title' => '']; return ['title' => ''];
} }
} }
@ -255,7 +260,9 @@ class GridFieldCustomAction implements GridField_ColumnProvider, GridField_Actio
public function handleAction(GridField $gridField, $actionName, $arguments, $data) public function handleAction(GridField $gridField, $actionName, $arguments, $data)
{ {
if($actionName == 'docustomaction') { if ($actionName !== 'docustomaction') {
return;
}
// perform your action here // perform your action here
// output a success message to the user // output a success message to the user
@ -265,7 +272,6 @@ class GridFieldCustomAction implements GridField_ColumnProvider, GridField_Actio
); );
} }
} }
}
``` ```
## Related ## Related