Add check that API endpoint class is a registered service in DI
[PREMIUM-99]
This commit is contained in:
@@ -108,7 +108,7 @@ class API {
|
|||||||
$namespace,
|
$namespace,
|
||||||
ucfirst($this->_request_endpoint)
|
ucfirst($this->_request_endpoint)
|
||||||
);
|
);
|
||||||
if(class_exists($endpoint_class)) {
|
if($this->container->has($endpoint_class)) {
|
||||||
$this->_request_endpoint_class = $endpoint_class;
|
$this->_request_endpoint_class = $endpoint_class;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -138,7 +138,9 @@ class API {
|
|||||||
|
|
||||||
function processRoute() {
|
function processRoute() {
|
||||||
try {
|
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'));
|
throw new \Exception(__('Invalid API endpoint.', 'mailpoet'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user