function forum_access_node_insert in Forum Access 8
Same name and namespace in other branches
- 7 forum_access.module \forum_access_node_insert()
Implements hook_ENTITY_TYPE_insert() for node entities.
@inheritdoc
1 call to forum_access_node_insert()
- forum_access_node_update in ./
forum_access.module - Implements hook_ENTITY_TYPE_update() for node entities.
File
- ./
forum_access.module, line 214 - Contains forum_access.module.
Code
function forum_access_node_insert(EntityInterface $entity) {
if ($entity
->bundle() != 'forum') {
return;
}
module_load_include('inc', 'forum_access', 'includes/forum_access.common');
module_load_include('inc', 'forum_access', 'includes/forum_access.acl');
if ($tid = forum_access_get_tid($entity)) {
$acl_id = forum_access_get_acl($tid, 'moderate');
acl_node_add_acl($entity
->id(), $acl_id, 1, 1, 1);
}
$node = Node::load($entity
->id());
// To preserve database integrity, only write grants if the node
// loads successfully.
if (!empty($node)) {
\Drupal::entityTypeManager()
->getAccessControlHandler('node')
->writeGrants($node);
}
}