*/ private array $endpoints = [ Clear::class, Debug::class, Off::class, On::class, Regenerate::class, Status::class, ]; /** * {@inheritdoc} */ public function register(): void { add_action( 'rest_api_init', [ $this, 'register_all_endpoints' ] ); } /** * Registers all endpoints of the REST API. * * @since 0.1.0 * * @return void */ public function register_all_endpoints(): void { foreach ( $this->endpoints as $class ) { /** @var Route */ $endpoint = $this->container->get( $class ); register_rest_route( $this->namespace, $endpoint->get_path(), [ [ 'methods' => $endpoint->get_methods(), 'callback' => [ $endpoint, 'callback' ], 'args' => $endpoint->get_arguments(), 'permission_callback' => [ $endpoint, 'permission_callback' ], ], 'schema' => [ $endpoint, 'schema_callback' ], ], ); } } }