forked from MichaelYick/mailpoet
Add hook registration helper methods to registry
[MAILPOET-4515]
This commit is contained in:
parent
da58a5c416
commit
15e4635fe3
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user