You are here

public function MandrillConfigurationAccessCheck::access in Mandrill 8

Access check for Mandrill module configuration.

Ensures a Mandrill API key has been provided.

Parameters

\Drupal\Core\Session\AccountInterface $account: Run access checks for this account.

Return value

\Drupal\Core\Access\AccessResultInterface The access result.

File

src/Access/MandrillConfigurationAccessCheck.php, line 25

Class

MandrillConfigurationAccessCheck
Checks access for displaying configuration page.

Namespace

Drupal\mandrill\Access

Code

public function access(AccountInterface $account) {
  $config = \Drupal::configFactory()
    ->get('mandrill.settings');
  $api_key = $config
    ->get('mandrill_api_key');
  return AccessResult::allowedIf(!empty($api_key));
}