Skip to content

Commit

Permalink
Callback Action extended with pre/post/normal
Browse files Browse the repository at this point in the history
  • Loading branch information
dergel committed Oct 17, 2023
1 parent 691342e commit f0f885b
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions lib/yform/action/callback.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,32 @@
class rex_yform_action_callback extends rex_yform_action_abstract
{
public function executeAction(): void
{
$this->action_callback();
}

public function preAction(): void
{
$this->action_callback('pre');
}

public function postAction(): void
{
$this->action_callback('post');
}

public function action_callback($currentFunction = 'normal')
{
if (!$this->getElement(2)) {
return;
}
call_user_func($this->getElement(2), $this);
if ($currentFunction == $this->getElement(3)) {
call_user_func($this->getElement(2), $this);
}
}

public function getDescription(): string
{
return 'action|callback|mycallback / myclass::mycallback';
return 'action|callback|mycallback / myclass::mycallback|pre/post/[normal]';
}
}

0 comments on commit f0f885b

Please sign in to comment.