Brak opisu

API.php 608B

1234567891011121314151617181920212223242526
  1. <?php
  2. namespace MailPoet\API;
  3. if (!defined('ABSPATH')) exit;
  4. use MailPoet\DI\ContainerWrapper;
  5. use MailPoetVendor\Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
  6. class API {
  7. /**
  8. * @param string $version
  9. * @return \MailPoet\API\MP\v1\API
  10. * @throws \Exception
  11. */
  12. public static function MP($version) {
  13. $apiClass = sprintf('%s\MP\%s\API', __NAMESPACE__, $version);
  14. try {
  15. return ContainerWrapper::getInstance()->get($apiClass);
  16. } catch (ServiceNotFoundException $e) {
  17. throw new \Exception(__('Invalid API version.', 'mailpoet'));
  18. }
  19. }
  20. }