You are here

class AmazonSesClientFactory in Amazon SES 2.0.x

Factory class for AWS SesClient instances.

Hierarchy

Expanded class hierarchy of AmazonSesClientFactory

1 string reference to 'AmazonSesClientFactory'
amazon_ses.services.yml in ./amazon_ses.services.yml
amazon_ses.services.yml
1 service uses AmazonSesClientFactory
amazon_ses.client_factory in ./amazon_ses.services.yml
Drupal\amazon_ses\AmazonSesClientFactory

File

src/AmazonSesClientFactory.php, line 11

Namespace

Drupal\amazon_ses
View source
class AmazonSesClientFactory {

  /**
   * Creates an AWS SesClient instance.
   *
   * @param array $options
   *   The default client options.
   * @param \Drupal\Core\Config\ConfigFactory $configFactory
   *   The config factory.
   *
   * @return \Aws\Ses\SesClient
   *   The client instance.
   */
  public static function createInstance(array $options, ConfigFactory $configFactory) {
    $settings = $configFactory
      ->get('aws_secrets_manager.settings');
    $options['region'] = $settings
      ->get('aws_region');
    $awsKey = $settings
      ->get('aws_key');
    $awsSecret = $settings
      ->get('aws_secret');
    if (!empty($awsKey) && !empty($awsSecret)) {
      $options['credentials'] = [
        'key' => $awsKey,
        'secret' => $awsSecret,
      ];
    }
    return new SesClient($options);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AmazonSesClientFactory::createInstance public static function Creates an AWS SesClient instance.