| 1 |
<?php |
| 2 |
|
| 3 |
namespace EssentialBlocks\API; |
| 4 |
|
| 5 |
use EssentialBlocks\Traits\HasSingletone; |
| 6 |
|
| 7 |
class Server { |
| 8 |
use HasSingletone; |
| 9 |
|
| 10 |
public function __construct() { |
| 11 |
add_action( 'rest_api_init', array( $this, 'register_routes' ) ); |
| 12 |
} |
| 13 |
|
| 14 |
public function register_routes() { |
| 15 |
$routes = $this->routes(); |
| 16 |
|
| 17 |
foreach ( $routes as $route ) { |
| 18 |
$route->register(); |
| 19 |
} |
| 20 |
} |
| 21 |
|
| 22 |
public function routes() { |
| 23 |
return array( |
| 24 |
'product' => Product::get_instance(), |
| 25 |
'post-blocks' => PostBlock::get_instance(), |
| 26 |
'common' => Common::get_instance(), |
| 27 |
); |
| 28 |
} |
| 29 |
} |
| 30 |
|