You are here

protected function GroupRoleController::doGetEntity in Group 2.0.x

Same name and namespace in other branches
  1. 8 src/Entity/Controller/GroupRoleController.php \Drupal\group\Entity\Controller\GroupRoleController::doGetEntity()

Determines the entity.

Parameters

\Drupal\Core\Routing\RouteMatchInterface $route_match: The route match.

\Drupal\Core\Entity\EntityInterface $_entity: (optional) The entity, set in \Drupal\Core\Entity\Enhancer\EntityRouteEnhancer.

Return value

\Drupal\Core\Entity\EntityInterface|null The entity, if it is passed in directly or if the first parameter of the active route is an entity; otherwise, NULL.

Overrides EntityController::doGetEntity

File

src/Entity/Controller/GroupRoleController.php, line 17

Class

GroupRoleController
Returns responses for GroupRole routes.

Namespace

Drupal\group\Entity\Controller

Code

protected function doGetEntity(RouteMatchInterface $route_match, EntityInterface $_entity = NULL) {
  if ($_entity) {
    $entity = $_entity;
  }
  elseif ($route_match
    ->getRawParameter('group_role') !== NULL) {
    $entity = $route_match
      ->getParameter('group_role');
  }
  if (isset($entity)) {
    return $this->entityRepository
      ->getTranslationFromContext($entity);
  }
}