You are here

ForumAccessCheck.php in Opigno forum 8

Same filename and directory in other branches
  1. 3.x src/Access/ForumAccessCheck.php

File

src/Access/ForumAccessCheck.php
View source
<?php

namespace Drupal\opigno_forum\Access;

use Drupal\Core\Access\AccessResult;
use Drupal\Core\Routing\Access\AccessInterface;
use Drupal\Core\Routing\RouteMatch;
use Drupal\Core\Session\AccountInterface;

/**
 * Checks access for displaying forum page.
 */
class ForumAccessCheck implements AccessInterface {

  /**
   * Returns forum access.
   */
  public function access(RouteMatch $route_match, AccountInterface $account) {
    $forum = $route_match
      ->getParameter('taxonomy_term');
    if ($forum !== NULL) {
      if (!_opigno_forum_access($forum
        ->id(), $account)) {
        return AccessResult::forbidden();
      }
    }
    return AccessResult::allowed();
  }

}

Classes

Namesort descending Description
ForumAccessCheck Checks access for displaying forum page.