Skip to content

Commit

Permalink
Move action lifecycle hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
zepfietje committed May 22, 2024
1 parent 81949c0 commit b367120
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 20 deletions.
10 changes: 6 additions & 4 deletions packages/actions/src/Concerns/InteractsWithActions.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,15 @@ public function callMountedAction(array $arguments = []): mixed
if ($this->mountedActionHasForm(mountedAction: $action)) {
$action->callBeforeFormValidated();

$action->formData($form->getState());
$action->formData(
$form->getState(afterValidate: function () use ($action) {
$action->callAfterFormValidated();

$action->callAfterFormValidated();
$action->callBefore();
}),
);
}

$action->callBefore();

$result = $action->call([
'form' => $form,
]);
Expand Down
10 changes: 6 additions & 4 deletions packages/forms/src/Concerns/HasFormComponentActions.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,15 @@ public function callMountedFormComponentAction(array $arguments = []): mixed
if ($this->mountedFormComponentActionHasForm(mountedAction: $action)) {
$action->callBeforeFormValidated();

$action->formData($form->getState());
$action->formData(
$form->getState(afterValidate: function () use ($action) {
$action->callAfterFormValidated();

$action->callAfterFormValidated();
$action->callBefore();
}),
);
}

$action->callBefore();

$result = $action->call([
'form' => $form,
]);
Expand Down
10 changes: 6 additions & 4 deletions packages/infolists/src/Concerns/InteractsWithInfolists.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,15 @@ public function callMountedInfolistAction(array $arguments = []): mixed
if ($this->mountedInfolistActionHasForm(mountedAction: $action)) {
$action->callBeforeFormValidated();

$action->formData($form->getState());
$action->formData(
$form->getState(afterValidate: function () use ($action) {
$action->callAfterFormValidated();

$action->callAfterFormValidated();
$action->callBefore();
}),
);
}

$action->callBefore();

$result = $action->call([
'form' => $form,
]);
Expand Down
10 changes: 6 additions & 4 deletions packages/tables/src/Concerns/HasActions.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,15 @@ public function callMountedTableAction(array $arguments = []): mixed
if ($this->mountedTableActionHasForm(mountedAction: $action)) {
$action->callBeforeFormValidated();

$action->formData($form->getState());
$action->formData(
$form->getState(afterValidate: function () use ($action) {
$action->callAfterFormValidated();

$action->callAfterFormValidated();
$action->callBefore();
}),
);
}

$action->callBefore();

$result = $action->call([
'form' => $form,
]);
Expand Down
10 changes: 6 additions & 4 deletions packages/tables/src/Concerns/HasBulkActions.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,15 @@ public function callMountedTableBulkAction(array $arguments = []): mixed
if ($this->mountedTableBulkActionHasForm(mountedBulkAction: $action)) {
$action->callBeforeFormValidated();

$action->formData($form->getState());
$action->formData(
$form->getState(afterValidate: function () use ($action) {
$action->callAfterFormValidated();

$action->callAfterFormValidated();
$action->callBefore();
}),
);
}

$action->callBefore();

$result = $action->call([
'form' => $form,
]);
Expand Down

0 comments on commit b367120

Please sign in to comment.