You are here

trait CalculatedGroupPermissionsTrait in Group 8

Same name and namespace in other branches
  1. 2.0.x src/Access/CalculatedGroupPermissionsTrait.php \Drupal\group\Access\CalculatedGroupPermissionsTrait

Trait for \Drupal\group\Access\CalculatedGroupPermissionsInterface.

Hierarchy

File

src/Access/CalculatedGroupPermissionsTrait.php, line 8

Namespace

Drupal\group\Access
View source
trait CalculatedGroupPermissionsTrait {

  /**
   * A list of calculated group permission items, keyed by scope and identifier.
   *
   * @var array
   */
  protected $items = [];

  /**
   * {@inheritdoc}
   */
  public function getItem($scope, $identifier) {
    return isset($this->items[$scope][$identifier]) ? $this->items[$scope][$identifier] : FALSE;
  }

  /**
   * {@inheritdoc}
   */
  public function getItems() {
    $items = [];
    foreach ($this->items as $scope_items) {
      foreach ($scope_items as $item) {
        $items[] = $item;
      }
    }
    return $items;
  }

  /**
   * {@inheritdoc}
   */
  public function getItemsByScope($scope) {
    return isset($this->items[$scope]) ? array_values($this->items[$scope]) : [];
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CalculatedGroupPermissionsTrait::$items protected property A list of calculated group permission items, keyed by scope and identifier.
CalculatedGroupPermissionsTrait::getItem public function
CalculatedGroupPermissionsTrait::getItems public function
CalculatedGroupPermissionsTrait::getItemsByScope public function