| 1 |
<?php |
| 2 |
/** |
| 3 |
* OpenStation App Framework — Hooks contract. |
| 4 |
* |
| 5 |
* The extensibility bus. Apps expose their seams through it exactly |
| 6 |
* as WordPress code does — `filter()` to let others reshape a value, |
| 7 |
* `action()` to announce that something happened — and the host |
| 8 |
* decides what those calls mean. |
| 9 |
* |
| 10 |
* @package OpenStation |
| 11 |
*/ |
| 12 |
|
| 13 |
namespace OpenStation\App\Contracts; |
| 14 |
|
| 15 |
// Direct access, unless a standalone host is booting on bare PHP. |
| 16 |
if ( ! defined( 'ABSPATH' ) ) { |
| 17 |
defined( 'OPENSTATION_STANDALONE' ) || exit; |
| 18 |
} |
| 19 |
|
| 20 |
interface Hooks { |
| 21 |
|
| 22 |
/** |
| 23 |
* Run a value through every registered filter callback. |
| 24 |
* |
| 25 |
* @param string $hook Hook name. |
| 26 |
* @param mixed $value Value to filter. |
| 27 |
* @param mixed ...$args Extra arguments handed to the callbacks. |
| 28 |
* @return mixed Filtered value. |
| 29 |
*/ |
| 30 |
public function filter( $hook, $value, ...$args ); |
| 31 |
|
| 32 |
/** |
| 33 |
* Fire an action. |
| 34 |
* |
| 35 |
* @param string $hook Hook name. |
| 36 |
* @param mixed ...$args Arguments handed to the callbacks. |
| 37 |
* @return void |
| 38 |
*/ |
| 39 |
public function action( $hook, ...$args ); |
| 40 |
} |
| 41 |
|