Skip to content

Commit 4c9af3b

Browse files
committed
Fix execution order in ActionsBuilder
1 parent 778d6dc commit 4c9af3b

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

Builder/Admin/ActionsBuilder.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ public function getYamlKey(): string
1919

2020
public function getVariables(): array
2121
{
22+
// Return empty array if the variables have not yet been set,
23+
// to prevent calling getObjectActions or getBatchActions without reading the configuration
24+
if (empty($this->variables)) {
25+
return [];
26+
}
27+
2228
// If credentials are not globally defined,
2329
// check if an action have credentials
2430
if (null === $this->getVariable('credentials')) {
@@ -49,13 +55,13 @@ public function getBatchActions(): array
4955

5056
protected function setUserBatchActionConfiguration(Action $action)
5157
{
52-
$batchActions = $this->getVariable('batch_actions', array());
58+
$batchActions = $this->getVariable('batch_actions', []);
5359
$builderOptions = is_array($batchActions) && array_key_exists($action->getName(), $batchActions)
5460
? $batchActions[$action->getName()]
55-
: array();
61+
: [];
5662

5763
$globalOptions = $this->getGenerator()->getFromYaml(
58-
'params.batch_actions.'.$action->getName(), array()
64+
'params.batch_actions.'.$action->getName(), []
5965
);
6066

6167
if (null !== $builderOptions) {
@@ -76,7 +82,7 @@ protected function addBatchAction(Action $action)
7682

7783
protected function findBatchActions()
7884
{
79-
$batchActions = $this->getVariable('batch_actions', array());
85+
$batchActions = $this->getVariable('batch_actions', []);
8086

8187
foreach ($batchActions as $actionName => $actionParams) {
8288
$action = $this->findBatchAction($actionName);

Generator/Action/Object/DeleteAction.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ public function __construct($name, BaseBuilder $builder)
2424

2525
$this->setRoute($builder->getObjectActionsRoute());
2626

27-
$this->setParams(array(
27+
$this->setParams([
2828
'pk' => '{{ '.$builder->getModelClass().'.'.$builder->getModelPrimaryKeyName().' }}',
2929
'action' => 'delete'
30-
));
30+
]);
3131

3232
}
3333
}

0 commit comments

Comments
 (0)