| @@ -2,9 +2,8 @@ | ||
| 2 | 2 | |
| 3 | 3 | namespace Code_Snippets\REST_API; |
| 4 | 4 | |
| 5 | 5 | use WP_REST_Request; |
| 6 | -use function Code_Snippets\code_snippets; | |
| 7 | 6 | use const Code_Snippets\REST_API_NAMESPACE; |
| 8 | 7 | |
| 9 | 8 | /** |
| 10 | 9 | * Base class for REST API controllers. |
| @@ -9,8 +8,9 @@ | ||
| 9 | 8 | /** |
| 10 | 9 | * Base class for REST API controllers. |
| 11 | 10 | */ |
| 12 | 11 | abstract class REST_Controller { |
| 12 | + | |
| 13 | 13 | /** |
| 14 | 14 | * The version of the REST API this controller belongs to. |
| 15 | 15 | * |
| 16 | 16 | * @var string |
| @@ -34,10 +34,10 @@ | ||
| 34 | 34 | /** |
| 35 | 35 | * Class constructor. |
| 36 | 36 | */ |
| 37 | 37 | public function __construct() { |
| 38 | - assert( static::VERSION > 0, get_class( $this ) . '::VERSION must be set' ); | |
| 39 | - assert( static::BASE_ROUTE, get_class( $this ) . '::BASE_ROUTE must be set' ); | |
| 38 | + assert( ! empty( static::VERSION ), get_class( $this ) . '::VERSION must be set' ); | |
| 39 | + assert( ! empty( static::BASE_ROUTE ), get_class( $this ) . '::BASE_ROUTE must be set' ); | |
| 40 | 40 | |
| 41 | 41 | $this->namespace = REST_API_NAMESPACE . static::VERSION; |
| 42 | 42 | add_action( 'rest_api_init', [ $this, 'register_routes' ] ); |
| 43 | 43 | } |
| @@ -61,11 +61,7 @@ | ||
| 61 | 61 | * |
| 62 | 62 | * @param WP_REST_Request $request Full data about the request. |
| 63 | 63 | * |
| 64 | 64 | * @return bool |
| 65 | - * | |
| 66 | - * phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.Found | |
| 67 | 65 | */ |
| 68 | - public function permission_callback( WP_REST_Request $request ): bool { | |
| 69 | - return code_snippets()->current_user_can(); | |
| 70 | - } | |
| 66 | + abstract public function permission_callback( WP_REST_Request $request ): bool; | |
| 71 | 67 | } |