Add hook registration helper methods to registry

[MAILPOET-4515]
This commit is contained in:
Jan Jakes 2022-07-28 16:14:28 +02:00 committed by Veljko V
parent da58a5c416
commit 15e4635fe3

View File

@ -20,6 +20,15 @@ class Registry {
/** @var array<string, Action> */
private $actions = [];
/** @var WordPress */
private $wordPress;
public function __construct(
WordPress $wordPress
) {
$this->wordPress = $wordPress;
}
public function addSubject(Subject $subject): void {
$key = $subject->getKey();
if (isset($this->subjects[$key])) {
@ -91,4 +100,12 @@ class Registry {
public function getActions(): array {
return $this->actions;
}
public function onBeforeWorkflowSave(callable $callback, int $priority = 10): void {
$this->wordPress->addAction(Hooks::WORKFLOW_BEFORE_SAVE, $callback, $priority);
}
public function onBeforeWorkflowStepSave(callable $callback, int $priority = 10): void {
$this->wordPress->addAction(Hooks::WORKFLOW_STEP_BEFORE_SAVE, $callback, $priority);
}
}