You are here

class Access in Forum Access 8

Access checks for forum.

Hierarchy

  • class \Drupal\forum_access\ForumAccess\Access

Expanded class hierarchy of Access

File

src/ForumAccess/Access.php, line 13

Namespace

Drupal\forum_access\ForumAccess
View source
class Access {

  /**
   * {@inheritdoc}
   */
  public function __construct() {
    module_load_include('inc', 'forum_access', 'includes/forum_access.common');
  }

  /**
   * Access check for forum index page.
   */
  public function forumIndex(AccountInterface $account) {
    $view_access = forum_access_forum_check_view($account);
    if (!empty($view_access)) {
      return AccessResult::allowed();
    }
    return AccessResult::forbidden();
  }

  /**
   * Access check for specific forum page.
   */
  public function forumPage(AccountInterface $account, TermInterface $taxonomy_term) {
    $view_access = forum_access_forum_check_view($account, $taxonomy_term
      ->id());
    if (!empty($view_access)) {
      return AccessResult::allowed();
    }
    return AccessResult::forbidden();
  }

  /**
   * Access for comment reply according to the taxonomy term of forum.
   */
  public function commentReply(EntityInterface $entity, $field_name, $pid = NULL) {
    if ($entity
      ->bundle() != 'forum') {
      return AccessResult::allowed();
    }

    // Forbid if user has no access to reply.
    if (!forum_access_entity_access_by_tid('create', $entity)) {
      return AccessResult::forbidden();
    }
    return AccessResult::allowed();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Access::commentReply public function Access for comment reply according to the taxonomy term of forum.
Access::forumIndex public function Access check for forum index page.
Access::forumPage public function Access check for specific forum page.
Access::__construct public function