You are here

public function RouteGroupResolver::resolve in Organic groups 8

Resolves groups within the plugin's domain.

Parameters

\Drupal\og\OgResolvedGroupCollectionInterface $collection: A collection of groups that were resolved by previous plugins. If the plugin discovers new groups, it may add these to this collection. A plugin may also remove groups from the collection that were previously discovered by other plugins, if it finds out that certain groups are incompatible with the current state in the plugin's domain.

Overrides OgGroupResolverInterface::resolve

File

src/Plugin/OgGroupResolver/RouteGroupResolver.php, line 27

Class

RouteGroupResolver
Resolves the group from the route.

Namespace

Drupal\og\Plugin\OgGroupResolver

Code

public function resolve(OgResolvedGroupCollectionInterface $collection) {
  $entity = $this
    ->getContentEntity();
  if ($entity && $this->groupTypeManager
    ->isGroup($entity
    ->getEntityTypeId(), $entity
    ->bundle())) {
    $collection
      ->addGroup($entity, [
      'route',
    ]);

    // We are on a route that matches an entity path for a group entity. We
    // can conclude with 100% certainty that this group is relevant for the
    // current context. There's no need to keep searching.
    $this
      ->stopPropagation();
  }
}