Introduce ContainerWrapper

Container wrapper wraps both premium and free containers and adds ability for free plugin to use premium plugin services directly.
[PREMIUM-99]
This commit is contained in:
Rostislav Wolny
2018-12-04 14:46:14 +01:00
parent 884cabb51f
commit 26472d8b9a
5 changed files with 154 additions and 14 deletions

View File

@@ -3,7 +3,6 @@ namespace MailPoet\API\JSON;
use MailPoet\Config\AccessControl;
use MailPoetVendor\Psr\Container\ContainerInterface;
use MailPoetVendor\Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
use MailPoet\Models\Setting;
use MailPoet\Util\Helpers;
use MailPoet\Util\Security;
@@ -143,13 +142,7 @@ class API {
throw new \Exception(__('Invalid API endpoint.', 'mailpoet'));
}
try {
$endpoint = $this->container->get($this->_request_endpoint_class);
} catch (ServiceNotFoundException $e) {
// Hotfix for Premium plugin which adds endpoints which are not registered in DI container
$endpoint = new $this->_request_endpoint_class();
}
$endpoint = $this->container->get($this->_request_endpoint_class);
if(!method_exists($endpoint, $this->_request_method)) {
throw new \Exception(__('Invalid API endpoint method.', 'mailpoet'));
}