function hook_domain_operations in Domain Access 8
Adds administrative operations for the domain overview form.
These operations are only available to users who can administer the domain. That access check happens prior to this hook being called. If your use-case requires additional permission checking, you should provide it before returning any values.
Parameters
\Drupal\domain\DomainInterface $domain: A domain record object.
\Drupal\Core\Session\AccountInterface $account: The user account performing the operation.
Return value
array An array of operations which uses a unique string key and requires the elements 'title' and 'url'; the 'query' value is optional, and used for link-actions with tokens
3 functions implement hook_domain_operations()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
- domain_alias_domain_operations in domain_alias/
domain_alias.module - Implements hook_domain_operations().
- domain_content_domain_operations in domain_content/
domain_content.module - Implements hook_domain_operations().
- domain_test_domain_operations in domain/
tests/ modules/ domain_test/ domain_test.module - Implements hook_domain_operations().
2 invocations of hook_domain_operations()
- DomainHookTest::testHookDomainOperations in domain/
tests/ src/ Kernel/ DomainHookTest.php - Tests domain operations hook.
- DomainListBuilder::getOperations in domain/
src/ DomainListBuilder.php - Provides an array of information to build a list of operation links.
File
- domain/
domain.api.php, line 67 - API documentation file for Domain module.
Code
function hook_domain_operations(\Drupal\domain\DomainInterface $domain, \Drupal\Core\Session\AccountInterface $account) {
$operations = [];
// Check permissions.
if ($account
->hasPermission('view domain aliases') || $account
->hasPermission('administer domain aliases')) {
// Add aliases to the list.
$id = $domain
->id();
$operations['domain_alias'] = [
'title' => t('Aliases'),
'url' => \Drupal\Core\Url::fromRoute('domain_alias.admin', [
'domain' => $id,
]),
'weight' => 60,
];
}
return $operations;
}