You are here

public function GroupRoleListBuilder::__construct in Group 8

Same name and namespace in other branches
  1. 2.0.x src/Entity/Controller/GroupRoleListBuilder.php \Drupal\group\Entity\Controller\GroupRoleListBuilder::__construct()

Constructs a new EntityListBuilder object.

Parameters

\Drupal\Core\Entity\EntityTypeInterface $entity_type: The entity type definition.

\Drupal\Core\Entity\EntityStorageInterface $storage: The entity storage class.

Overrides DraggableListBuilder::__construct

File

src/Entity/Controller/GroupRoleListBuilder.php, line 31

Class

GroupRoleListBuilder
Defines a class to build a listing of group role entities.

Namespace

Drupal\group\Entity\Controller

Code

public function __construct(EntityTypeInterface $entity_type, EntityStorageInterface $storage, RouteMatchInterface $route_match) {
  parent::__construct($entity_type, $storage);

  // When on the default group role list route, we should have a group type.
  if ($route_match
    ->getRouteName() == 'entity.group_role.collection') {
    $parameters = $route_match
      ->getParameters();

    // Check if the route had a group type parameter.
    if ($parameters
      ->has('group_type') && ($group_type = $parameters
      ->get('group_type'))) {
      if ($group_type instanceof GroupTypeInterface) {
        $this->groupType = $group_type;
      }
    }
  }
}