Files
piratepoet/lib/API/API.php
Rostislav Wolny de5385ed03 Get rid of static instantiation of JSON API
[MAILPOET-1689]
2018-12-17 15:02:42 +01:00

20 lines
500 B
PHP

<?php
namespace MailPoet\API;
use MailPoet\DI\ContainerWrapper;
use MailPoetVendor\Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
if(!defined('ABSPATH')) exit;
class API {
static function MP($version) {
$api_class = sprintf('%s\MP\%s\API', __NAMESPACE__, $version);
try {
return ContainerWrapper::getInstance()->get($api_class);
} catch (ServiceNotFoundException $e) {
throw new \Exception(__('Invalid API version.', 'mailpoet'));
}
}
}