You are here

class MailgunFactory in Mailgun 8

Defines the mailgun factory.

Hierarchy

Expanded class hierarchy of MailgunFactory

1 file declares its use of MailgunFactory
MailgunFactoryTest.php in tests/src/Kernel/MailgunFactoryTest.php
1 string reference to 'MailgunFactory'
mailgun.services.yml in ./mailgun.services.yml
mailgun.services.yml
1 service uses MailgunFactory
mailgun.mailgun_client_factory in ./mailgun.services.yml
Drupal\mailgun\MailgunFactory

File

src/MailgunFactory.php, line 11

Namespace

Drupal\mailgun
View source
class MailgunFactory {

  /**
   * Configuration object.
   *
   * @var \Drupal\Core\Config\ImmutableConfig
   */
  protected $mailgunConfig;

  /**
   * Constructs MailgunFactory object.
   *
   * @param \Drupal\Core\Config\ConfigFactoryInterface $configFactory
   *   The config factory.
   */
  public function __construct(ConfigFactoryInterface $configFactory) {
    $this->mailgunConfig = $configFactory
      ->get(MailgunHandlerInterface::CONFIG_NAME);
  }

  /**
   * Create Mailgun client.
   *
   * @return \Mailgun\Mailgun
   *   Mailgun PHP SDK Client.
   */
  public function create() {
    if ($endpoint = $this->mailgunConfig
      ->get('api_endpoint')) {
      return Mailgun::create($this->mailgunConfig
        ->get('api_key'), $endpoint);
    }
    else {
      return Mailgun::create($this->mailgunConfig
        ->get('api_key'));
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
MailgunFactory::$mailgunConfig protected property Configuration object.
MailgunFactory::create public function Create Mailgun client.
MailgunFactory::__construct public function Constructs MailgunFactory object.