Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 4 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| RestApi | |
0.00% |
0 / 4 |
|
0.00% |
0 / 2 |
12 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| register_routes | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace NewfoldLabs\WP\Module\Installer\RestApi; |
| 4 | |
| 5 | /** |
| 6 | * Instantiate controllers and register routes. |
| 7 | */ |
| 8 | final class RestApi { |
| 9 | |
| 10 | /** |
| 11 | * List of controllers to register. |
| 12 | * |
| 13 | * @var array |
| 14 | */ |
| 15 | protected $controllers = array( |
| 16 | 'NewfoldLabs\\WP\\Module\\Installer\\RestApi\\PluginsController', |
| 17 | 'NewfoldLabs\\WP\\Module\\Installer\\RestApi\\ThemeInstallerController', |
| 18 | ); |
| 19 | |
| 20 | /** |
| 21 | * The constructor that registers all the controllers. |
| 22 | */ |
| 23 | public function __construct() { |
| 24 | add_action( 'rest_api_init', array( $this, 'register_routes' ) ); |
| 25 | } |
| 26 | |
| 27 | /** |
| 28 | * Helper to register all the controller. |
| 29 | * |
| 30 | * @return void |
| 31 | */ |
| 32 | public function register_routes() { |
| 33 | foreach ( $this->controllers as $controller ) { |
| 34 | /** |
| 35 | * Get an instance of the WP_REST_Controller. |
| 36 | * |
| 37 | * @var $instance WP_REST_Controller |
| 38 | */ |
| 39 | $instance = new $controller(); |
| 40 | $instance->register_routes(); |
| 41 | } |
| 42 | } |
| 43 | } |