# solid-performance/1.2.0/src/Performance/API/Provider.php

Solid Performance – Your No-Code Caching, Performance, &amp; Page Speed Solution, version 1.2.0. 92 lines.

- Page: https://pluginprobe.com/plugins/solid-performance/1.2.0/code/src/Performance/API/Provider.php
- Raw: https://pluginprobe.com/plugins/solid-performance/1.2.0/raw/src/Performance/API/Provider.php
- Modified: 2024-09-03T15:51:20+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/solid-performance/1.2.0/code/src/Performance/API/Provider.php#L10-L20`.

```php
<?php
/**
 * The provider responsible for registering API classes with the container & WordPress.
 *
 * @since 0.1.0
 *
 * @package SolidWP\Performance
 */

namespace SolidWP\Performance\API;

use SolidWP\Performance\API\Routes\Page_Cache\Clear;
use SolidWP\Performance\API\Routes\Page_Cache\Debug;
use SolidWP\Performance\API\Routes\Page_Cache\Off;
use SolidWP\Performance\API\Routes\Page_Cache\On;
use SolidWP\Performance\API\Routes\Page_Cache\Status;
use SolidWP\Performance\API\Routes\Page_Cache\Regenerate;
use SolidWP\Performance\Contracts\Service_Provider;

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * The provider responsible for registering API classes with the container & WordPress.
 *
 * @since 0.1.0
 *
 * @package SolidWP\Performance
 */
class Provider extends Service_Provider {

	/**
	 * The namespace of the plugin's REST API routes.
	 *
	 * @since 0.1.0
	 *
	 * @var string
	 */
	private string $namespace = 'solid-performance/v1';

	/**
	 * All the endpoints that should be registered with the REST API.
	 *
	 * @since 0.1.0
	 *
	 * @var array<int,string>
	 */
	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' ],
				],
			);
		}
	}
}

```
