Skip to content

Commit

Permalink
Fix execution order in ActionsBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
tobias-93 committed Feb 16, 2023
1 parent 778d6dc commit 4c9af3b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
14 changes: 10 additions & 4 deletions Builder/Admin/ActionsBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ public function getYamlKey(): string

public function getVariables(): array
{
// Return empty array if the variables have not yet been set,
// to prevent calling getObjectActions or getBatchActions without reading the configuration
if (empty($this->variables)) {
return [];
}

// If credentials are not globally defined,
// check if an action have credentials
if (null === $this->getVariable('credentials')) {
Expand Down Expand Up @@ -49,13 +55,13 @@ public function getBatchActions(): array

protected function setUserBatchActionConfiguration(Action $action)
{
$batchActions = $this->getVariable('batch_actions', array());
$batchActions = $this->getVariable('batch_actions', []);
$builderOptions = is_array($batchActions) && array_key_exists($action->getName(), $batchActions)
? $batchActions[$action->getName()]
: array();
: [];

$globalOptions = $this->getGenerator()->getFromYaml(
'params.batch_actions.'.$action->getName(), array()
'params.batch_actions.'.$action->getName(), []
);

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

protected function findBatchActions()
{
$batchActions = $this->getVariable('batch_actions', array());
$batchActions = $this->getVariable('batch_actions', []);

foreach ($batchActions as $actionName => $actionParams) {
$action = $this->findBatchAction($actionName);
Expand Down
4 changes: 2 additions & 2 deletions Generator/Action/Object/DeleteAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ public function __construct($name, BaseBuilder $builder)

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

$this->setParams(array(
$this->setParams([
'pk' => '{{ '.$builder->getModelClass().'.'.$builder->getModelPrimaryKeyName().' }}',
'action' => 'delete'
));
]);

}
}

0 comments on commit 4c9af3b

Please sign in to comment.