| 1 |
<?php |
| 2 |
/** |
| 3 |
* OpenStation App Framework — Auth contract. |
| 4 |
* |
| 5 |
* Who is asking. The WordPress adapter answers from the current user; |
| 6 |
* the standalone adapter answers from whatever the host injected. |
| 7 |
* |
| 8 |
* @package OpenStation |
| 9 |
*/ |
| 10 |
|
| 11 |
namespace OpenStation\App\Contracts; |
| 12 |
|
| 13 |
// Direct access, unless a standalone host is booting on bare PHP. |
| 14 |
if ( ! defined( 'ABSPATH' ) ) { |
| 15 |
defined( 'OPENSTATION_STANDALONE' ) || exit; |
| 16 |
} |
| 17 |
|
| 18 |
interface Auth { |
| 19 |
|
| 20 |
/** |
| 21 |
* Numeric id of the acting user, 0 when anonymous. |
| 22 |
* |
| 23 |
* @return int |
| 24 |
*/ |
| 25 |
public function user_id(); |
| 26 |
|
| 27 |
/** |
| 28 |
* Whether the acting user is authenticated at all. |
| 29 |
* |
| 30 |
* @return bool |
| 31 |
*/ |
| 32 |
public function is_logged_in(); |
| 33 |
|
| 34 |
/** |
| 35 |
* Whether the acting user holds a capability. |
| 36 |
* |
| 37 |
* Extra arguments address a meta-capability's object — the id in |
| 38 |
* `can( 'delete_post', $post_id )`. The WordPress adapter forwards |
| 39 |
* them to `current_user_can()`; the standalone adapter answers |
| 40 |
* from the capability name alone. |
| 41 |
* |
| 42 |
* @param string $capability Capability slug, e.g. `manage_options`. |
| 43 |
* @param mixed ...$args Object the capability is asked against. |
| 44 |
* @return bool |
| 45 |
*/ |
| 46 |
public function can( $capability, ...$args ); |
| 47 |
} |
| 48 |
|