CMSMain - Linting changes + Added Docblock

+ Made the linting changes requested by @GuySartorelli
+ Added method documentation for BatchActionParameters()
This commit is contained in:
Benjamin Blake 2022-07-05 20:11:20 -06:00
parent 81593057de
commit 654fa5a681

View File

@ -2112,13 +2112,22 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
return new CMSBatchActionHandler($this, 'batchactions'); return new CMSBatchActionHandler($this, 'batchactions');
} }
/**
* Returns a LiteralField containing parameter field HTML
* for batch actions
*
* Used by {@link LeftAndMain} to render batch actions in
* the BatchActionsForm
*
* @return LiteralField
*/
public function BatchActionParameters() public function BatchActionParameters()
{ {
$batchActions = $this->batchactions()->registeredActions(); $batchActions = $this->batchactions()->registeredActions();
$forms = []; $forms = [];
foreach ($batchActions as $urlSegment => $batchAction) { foreach ($batchActions as $urlSegment => $batchAction) {
$SNG_action = singleton($batchAction["class"]); $SNG_action = singleton($batchAction['class']);
if ($SNG_action->canView() && $fieldList = $SNG_action->getParameterFields()) { if ($SNG_action->canView() && $fieldList = $SNG_action->getParameterFields()) {
$formHtml = ''; $formHtml = '';
/** @var FormField $field */ /** @var FormField $field */
@ -2130,10 +2139,11 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
} }
$pageHtml = ''; $pageHtml = '';
foreach ($forms as $urlSegment => $html) { foreach ($forms as $urlSegment => $html) {
$pageHtml .= "<div class=\"params\" id=\"BatchActionParameters_$urlSegment\" style=\"display:none\">$html</div>\n\n"; $pageHtml .= '<div class="params" id="BatchActionParameters_' . $urlSegment . '" style="display:none">' . $html . '</div>';
} }
return new LiteralField("BatchActionParameters", '<div id="BatchActionParameters" style="display:none">'.$pageHtml.'</div>'); return new LiteralField('BatchActionParameters', '<div id="BatchActionParameters" style="display:none">' . $pageHtml . '</div>');
} }
/** /**
* Returns a list of batch actions * Returns a list of batch actions
*/ */