You are here

function tft_taxonomy_term_create_access in Taxonomy File Tree 8

Same name and namespace in other branches
  1. 3.x tft.module \tft_taxonomy_term_create_access()

Implements hook_ENTITY_TYPE_create_access().

File

./tft.module, line 569
Contains tft.module.

Code

function tft_taxonomy_term_create_access(AccountInterface $account, array $context, $entity_bundle) {
  if ($account
    ->hasPermission(TFT_ADD_TERMS)) {

    // Allow platform-level content managers to create folders.
    return AccessResult::allowed();
  }
  $parent = \Drupal::request()->query
    ->get('parent');
  if (isset($parent) && _tft_term_access($parent)) {
    $gid = _tft_get_group_gid($parent);
    $group = Group::load($gid);
    if (isset($group) && $group
      ->hasPermission(TFT_ADD_TERMS, $account)) {

      // Allow group-level content managers to create folders in groups.
      return AccessResult::allowed();
    }
  }
  return AccessResult::neutral();
}