function content_access_entity_operation in Content Access 8
Implements hook_entity_operation().
File
- ./
content_access.module, line 156 - Content access module file.
Code
function content_access_entity_operation(EntityInterface $entity) {
$operations = [];
$info = $entity
->getEntityType();
if ($info
->getBundleOf() == 'node') {
$account = \Drupal::currentUser();
if ($account
->hasPermission('bypass node access') && $account
->hasPermission('administer content types')) {
$operations['access-control'] = [
'title' => t('Access control'),
'weight' => 25,
'url' => Url::fromRoute('entity.node_type.content_access_form', [
'node_type' => $entity
->id(),
]),
];
}
}
return $operations;
}