| 1234567891011121314151617181920212223242526272829303132 |
- <?php
- namespace cx_newsletter;
- use \register_rest_route;
- class rest_register
- implements rest_register_interface {
- public function __construct(string $namespace) {
- $this->namespace = $namespace;
- }
- public function register(rest_endpoint $endpoint) : self {
- $parameters = [
- 'methods' => $endpoint->get_method(),
- 'callback' => [$endpoint, 'action']
- ];
- register_rest_route(
- $this->get_namespace(),
- $endpoint->get_route(),
- $parameters
- );
- return $this;
- }
- public function get_namespace() : string {
- return $this->namespace;
- }
- private string $namespace;
- }
|