<?php
/**
 * REST API bootstrap.
 *
 * @package JOCBM
 */

namespace JOCBM\Rest;

defined( 'ABSPATH' ) || exit;

/**
 * Class RestApi
 */
final class RestApi {

	public const NAMESPACE = 'joc-blockora-morph/v1';

	/**
	 * Register controllers.
	 */
	public function register(): void {
		add_action( 'rest_api_init', array( $this, 'register_routes' ) );
	}

	/**
	 * Register all routes.
	 */
	public function register_routes(): void {
		( new CategoriesController() )->register_routes();
		( new SystemBlocksController() )->register_routes();
		( new UserBlocksController() )->register_routes();
		( new UserContentsController() )->register_routes();
		( new ThemeConfigController() )->register_routes();
		( new AppController() )->register_routes();
		( new PostTypesController() )->register_routes();
		( new FrontEditController() )->register_routes();
		( new FieldCatalogController() )->register_routes();

		/**
		 * Fires after core REST controllers are registered.
		 *
		 * @param string $namespace REST namespace (`joc-blockora-morph/v1`).
		 */
		do_action( 'jocbm_rest_register', self::NAMESPACE );
	}
}
