| 1 |
<?php |
| 2 |
/** |
| 3 |
* Provider for REST Functionality. |
| 4 |
* |
| 5 |
* @since 2.5.0 |
| 6 |
* |
| 7 |
* @package Bookit\REST |
| 8 |
*/ |
| 9 |
|
| 10 |
namespace Bookit\REST; |
| 11 |
|
| 12 |
use Bookit\Contracts\Service_Provider; |
| 13 |
use Bookit\REST\V1\Documentation\OpenAPI_Documentation; |
| 14 |
|
| 15 |
/** |
| 16 |
* Class Provider |
| 17 |
* |
| 18 |
* Provides the functionality for REST API. |
| 19 |
* |
| 20 |
* @since 2.5.0 |
| 21 |
* |
| 22 |
* @package Bookit\REST |
| 23 |
*/ |
| 24 |
class Provider extends Service_Provider { |
| 25 |
|
| 26 |
/** |
| 27 |
* Binds and sets up implementations. |
| 28 |
* |
| 29 |
* @since 2.5.0 |
| 30 |
*/ |
| 31 |
public function register() { |
| 32 |
// Register the SP on the container. |
| 33 |
$this->container->singleton( 'bookit.rests.provider', $this ); |
| 34 |
$this->container->singleton( OpenAPI_Documentation::class, OpenAPI_Documentation::class ); |
| 35 |
|
| 36 |
$this->add_actions(); |
| 37 |
$this->add_filters(); |
| 38 |
} |
| 39 |
|
| 40 |
/** |
| 41 |
* Adds required actions for REST API. |
| 42 |
* |
| 43 |
* @since 2.5.0 |
| 44 |
*/ |
| 45 |
protected function add_actions() { |
| 46 |
add_action( 'rest_api_init', [ $this, 'register_endpoints' ] ); |
| 47 |
} |
| 48 |
|
| 49 |
/** |
| 50 |
* Registers the REST API endpoints for ESM. |
| 51 |
* |
| 52 |
* @since 2.5.0 |
| 53 |
*/ |
| 54 |
public function register_endpoints() { |
| 55 |
$this->container->make( OpenAPI_Documentation::class )->register(); |
| 56 |
} |
| 57 |
|
| 58 |
/** |
| 59 |
* Adds required filters for REST API. |
| 60 |
* |
| 61 |
* @since 2.5.0 |
| 62 |
*/ |
| 63 |
protected function add_filters() {} |
| 64 |
} |
| 65 |
|