You are here

function groupmenu_entity_create_access in Group Menu 8

Implements hook_entity_create_access().

When trying to create a menu it suffices to have the right to do so in only one group the menu belongs to.

File

./groupmenu.module, line 28
Gives the ability to create and manage menus for groups.

Code

function groupmenu_entity_create_access(AccountInterface $account, array $context, $entity_bundle) {
  $plugin_id = 'group_menu:menu';
  $group_content_types = GroupContentType::loadByContentPluginId($plugin_id);
  if (isset($group_content_types[$entity_bundle])) {
    if ($context['group']
      ->hasPermission("create {$plugin_id} entity", $account)) {
      return AccessResult::allowed();
    }
  }
  return AccessResult::neutral();
}