You are here

class BBBMeetingModeratorAccessCheck in BigBlueButton 8

Class BBBMeetingModeratorAccessCheck.

@package Drupal\bbb\Access

Hierarchy

Expanded class hierarchy of BBBMeetingModeratorAccessCheck

1 string reference to 'BBBMeetingModeratorAccessCheck'
bbb_node.services.yml in modules/bbb_node/bbb_node.services.yml
modules/bbb_node/bbb_node.services.yml
1 service uses BBBMeetingModeratorAccessCheck
bbb_node.meeting.moderator_access_check in modules/bbb_node/bbb_node.services.yml
Drupal\bbb_node\Access\BBBMeetingModeratorAccessCheck

File

modules/bbb_node/src/Access/BBBMeetingModeratorAccessCheck.php, line 18

Namespace

Drupal\bbb_node\Access
View source
class BBBMeetingModeratorAccessCheck implements AccessInterface {

  /**
   * Node based Meeting API.
   *
   * @var \Drupal\bbb_node\Service\NodeMeeting
   */
  protected $nodeMeeting;

  /**
   * Node storage.
   *
   * @var \Drupal\Core\Entity\EntityStorageInterface
   */
  protected $nodeStorage;

  /**
   * Constructs a BBBMeetingModeratorAccessCheck object.
   *
   * @param \Drupal\bbb_node\Service\NodeMeeting $node_meeting
   *   Node based Meeting API.
   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
   *   Entity type manager.
   */
  public function __construct(NodeMeeting $node_meeting, EntityTypeManagerInterface $entity_type_manager) {
    $this->nodeMeeting = $node_meeting;
    $this->nodeStorage = $entity_type_manager
      ->getStorage('node');
  }

  /**
   * {@inheritdoc}
   */
  public function access(RouteMatchInterface $route_match, AccountInterface $account) {
    $node = $route_match
      ->getParameter('node');
    if (!$node instanceof NodeInterface) {
      $node = $this->nodeStorage
        ->load($node);
    }
    if (!$this->nodeMeeting
      ->isTypeOf($node)) {
      return AccessResult::forbidden();
    }

    // Check for access to attend meetings.
    if ($account
      ->hasPermission('bbb_node moderate meetings') || $account
      ->hasPermission('administer big blue button') || $account
      ->id() === $node
      ->getOwnerId() && $account
      ->hasPermission('bbb_node moderate own meetings')) {
      return AccessResult::allowed();
    }
    return AccessResult::neutral();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
BBBMeetingModeratorAccessCheck::$nodeMeeting protected property Node based Meeting API.
BBBMeetingModeratorAccessCheck::$nodeStorage protected property Node storage.
BBBMeetingModeratorAccessCheck::access public function
BBBMeetingModeratorAccessCheck::__construct public function Constructs a BBBMeetingModeratorAccessCheck object.