Files
piratepoet/lib/API/API.php
Pavel Dohnal 3c8dd21701 Add doc for api
[MAILPOET-2041]
2019-05-30 13:03:33 -04:00

26 lines
603 B
PHP

<?php
namespace MailPoet\API;
use MailPoet\DI\ContainerWrapper;
use MailPoetVendor\Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
if (!defined('ABSPATH')) exit;
class API {
/**
* @param string $version
* @return \MailPoet\API\MP\v1\API
* @throws \Exception
*/
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'));
}
}
}