(string $hook)
| 35 | } |
| 36 | |
| 37 | public function run_hook(string $hook): void { |
| 38 | // filter by hook |
| 39 | $filter = fn(Action $action) => $action->hook === $hook; |
| 40 | // order by priority |
| 41 | $sort = fn($a, $b) => $a->priority <=> $b->priority; |
| 42 | $actions_to_run = array_filter($this->_actions, $filter); |
| 43 | usort($actions_to_run, $sort); |
| 44 | |
| 45 | foreach ($actions_to_run as $action) { |
| 46 | ($action->action)(); |
| 47 | } |
| 48 | |
| 49 | } |
| 50 | |
| 51 | } |
| 52 |