You are here

public function AmazonSesController::statistics in Amazon SES 2.0.x

Outputs a page of statistics.

Return value

array A render array to build the page.

1 string reference to 'AmazonSesController::statistics'
amazon_ses.routing.yml in ./amazon_ses.routing.yml
amazon_ses.routing.yml

File

src/Controller/AmazonSesController.php, line 31

Class

AmazonSesController
Controller for Amazon SES routes.

Namespace

Drupal\amazon_ses\Controller

Code

public function statistics() {
  $quota = $this->handler
    ->getSendQuota();
  $statistics = $this->handler
    ->getSendStatistics();
  return [
    'quota' => [
      '#type' => 'details',
      '#title' => $this
        ->t('Daily sending limits'),
      '#open' => TRUE,
      'sending_quota' => [
        '#markup' => $this
          ->t('<strong>Quota:</strong> @max_send', [
          '@max_send' => $quota['Max24HourSend'],
        ]) . '<br />',
      ],
      'sent_mail' => [
        '#markup' => $this
          ->t('<strong>Sent:</strong> @sent_last', [
          '@sent_last' => $quota['SentLast24Hours'],
        ]) . '<br />',
      ],
      'send_rate' => [
        '#markup' => $this
          ->t('<strong>Maximum Send Rate:</strong> @send_rate
            emails/second', [
          '@send_rate' => $quota['MaxSendRate'],
        ]),
      ],
    ],
    'statistics' => [
      '#type' => 'details',
      '#title' => $this
        ->t('Sending statistics'),
      '#open' => TRUE,
      'sent' => [
        '#markup' => $this
          ->t('<strong>Sent:</strong> @sent', [
          '@sent' => $statistics['DeliveryAttempts'],
        ]) . '<br />',
      ],
      'bounces' => [
        '#markup' => $this
          ->t('<strong>Bounces:</strong> @bounces', [
          '@bounces' => $statistics['Bounces'],
        ]) . '<br />',
      ],
      'complaints' => [
        '#markup' => $this
          ->t('<strong>Complaints:</strong> @complaints', [
          '@complaints' => $statistics['Complaints'],
        ]) . '<br />',
      ],
      'rejected' => [
        '#markup' => $this
          ->t('<strong>Rejected:</strong> @rejected', [
          '@rejected' => $statistics['Rejects'],
        ]),
      ],
      'description' => [
        '#markup' => '<p>' . $this
          ->t('Sending statistics are compiled
            over the previous two weeks.') . '</p>',
      ],
    ],
  ];
}