You are here

function domain_alias_domain_operations in Domain Access 8

Implements hook_domain_operations().

File

domain_alias/domain_alias.module, line 67
Maps multiple host requests to a single domain record.

Code

function domain_alias_domain_operations(DomainInterface $domain, AccountInterface $account) {
  $operations = [];

  // Check permissions. The user must be a super-admin or assigned to the
  // domain.
  $is_domain_admin = $domain
    ->access('update', $account);
  if ($account
    ->hasPermission('administer domain aliases') || $is_domain_admin && $account
    ->hasPermission('view domain aliases')) {

    // Add aliases to the list of operations.
    $operations['domain_alias'] = [
      'title' => t('Aliases'),
      'url' => Url::fromRoute('domain_alias.admin', [
        'domain' => $domain
          ->id(),
      ]),
      'weight' => 60,
    ];
  }
  return $operations;
}