Add check that API endpoint class is a registered service in DI

[PREMIUM-99]
This commit is contained in:
Rostislav Wolny
2018-12-10 15:13:21 +01:00
parent fc61377fd8
commit 525fb5289b

View File

@@ -108,7 +108,7 @@ class API {
$namespace,
ucfirst($this->_request_endpoint)
);
if(class_exists($endpoint_class)) {
if($this->container->has($endpoint_class)) {
$this->_request_endpoint_class = $endpoint_class;
break;
}
@@ -138,7 +138,9 @@ class API {
function processRoute() {
try {
if(empty($this->_request_endpoint_class)) {
if(empty($this->_request_endpoint_class) ||
!$this->container->has($this->_request_endpoint_class)
) {
throw new \Exception(__('Invalid API endpoint.', 'mailpoet'));
}