Extract automation API to MailPoet REST API
[MAILPOET-4523]
This commit is contained in:
committed by
John Oleksowicz
parent
1b5d6bd974
commit
ba35ddf6e6
25
mailpoet/lib/API/REST/EndpointContainer.php
Normal file
25
mailpoet/lib/API/REST/EndpointContainer.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php declare(strict_types = 1);
|
||||
|
||||
namespace MailPoet\API\REST;
|
||||
|
||||
use MailPoet\InvalidStateException;
|
||||
use MailPoetVendor\Psr\Container\ContainerInterface;
|
||||
|
||||
class EndpointContainer {
|
||||
/** @var ContainerInterface */
|
||||
private $container;
|
||||
|
||||
public function __construct(
|
||||
ContainerInterface $container
|
||||
) {
|
||||
$this->container = $container;
|
||||
}
|
||||
|
||||
public function get(string $class): Endpoint {
|
||||
$endpoint = $this->container->get($class);
|
||||
if (!$endpoint instanceof Endpoint) {
|
||||
throw new InvalidStateException(sprintf("Class '%s' doesn't implement '%s'", $class, Endpoint::class));
|
||||
}
|
||||
return $endpoint;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user