| 1 |
<?php declare(strict_types = 1); |
| 2 |
|
| 3 |
namespace MailPoet\Automation\Engine\API; |
| 4 |
|
| 5 |
if (!defined('ABSPATH')) exit; |
| 6 |
|
| 7 |
|
| 8 |
use MailPoet\API\REST\API as MailPoetApi; |
| 9 |
use MailPoet\Automation\Engine\Hooks; |
| 10 |
use MailPoet\Automation\Engine\WordPress; |
| 11 |
|
| 12 |
class API extends MailPoetApi { |
| 13 |
/** @var MailPoetApi */ |
| 14 |
private $api; |
| 15 |
|
| 16 |
/** @var WordPress */ |
| 17 |
private $wordPress; |
| 18 |
|
| 19 |
public function __construct( |
| 20 |
MailPoetApi $api, |
| 21 |
WordPress $wordPress |
| 22 |
) { |
| 23 |
$this->api = $api; |
| 24 |
$this->wordPress = $wordPress; |
| 25 |
} |
| 26 |
|
| 27 |
public function initialize(): void { |
| 28 |
$this->wordPress->addAction(MailPoetApi::REST_API_INIT_ACTION, function () { |
| 29 |
$this->wordPress->doAction(Hooks::API_INITIALIZE, [$this]); |
| 30 |
}); |
| 31 |
} |
| 32 |
|
| 33 |
public function registerGetRoute(string $route, string $endpoint): void { |
| 34 |
$this->api->registerGetRoute($route, $endpoint); |
| 35 |
} |
| 36 |
|
| 37 |
public function registerPostRoute(string $route, string $endpoint): void { |
| 38 |
$this->api->registerPostRoute($route, $endpoint); |
| 39 |
} |
| 40 |
|
| 41 |
public function registerPutRoute(string $route, string $endpoint): void { |
| 42 |
$this->api->registerPutRoute($route, $endpoint); |
| 43 |
} |
| 44 |
|
| 45 |
public function registerPatchRoute(string $route, string $endpoint): void { |
| 46 |
$this->api->registerPatchRoute($route, $endpoint); |
| 47 |
} |
| 48 |
|
| 49 |
public function registerDeleteRoute(string $route, string $endpoint): void { |
| 50 |
$this->api->registerDeleteRoute($route, $endpoint); |
| 51 |
} |
| 52 |
} |
| 53 |
|