Rename endpoint "factory" to a more exact "container"

[MAILPOET-4207]
This commit is contained in:
Jan Jakes
2022-04-12 14:42:22 +02:00
committed by Veljko V
parent 36a3f34db8
commit 679f2200bd
4 changed files with 12 additions and 12 deletions

View File

@ -13,17 +13,17 @@ class API {
private const PREFIX = 'mailpoet/v1/automation';
private const WP_REST_API_INIT_ACTION = 'rest_api_init';
/** @var EndpointFactory */
private $endpointFactory;
/** @var EndpointContainer */
private $endpointContainer;
/** @var WordPress */
private $wordPress;
public function __construct(
EndpointFactory $endpointFactory,
EndpointContainer $endpointContainer,
WordPress $wordPress
) {
$this->endpointFactory = $endpointFactory;
$this->endpointContainer = $endpointContainer;
$this->wordPress = $wordPress;
}
@ -62,7 +62,7 @@ class API {
'methods' => $method,
'callback' => function (WP_REST_Request $wpRequest) use ($endpointClass) {
try {
$endpoint = $this->endpointFactory->createEndpoint($endpointClass);
$endpoint = $this->endpointContainer->get($endpointClass);
$request = new Request($wpRequest);
return $endpoint->handle($request);
} catch (Throwable $e) {
@ -70,7 +70,7 @@ class API {
}
},
'permission_callback' => function () use ($endpointClass) {
$endpoint = $this->endpointFactory->createEndpoint($endpointClass);
$endpoint = $this->endpointContainer->get($endpointClass);
return $endpoint->checkPermissions();
},
'args' => $schema,