public function OgContext::getGroup in Organic groups 8
Returns the group which is relevant in the current context, if any.
Return value
\Drupal\Core\Entity\ContentEntityInterface|null The group which is relevant in the current context, or NULL if no group was found.
Overrides OgContextInterface::getGroup
File
- src/
ContextProvider/ OgContext.php, line 171
Class
- OgContext
- Provides the group that best matches the current context.
Namespace
Drupal\og\ContextProviderCode
public function getGroup() {
$contexts = $this
->getRuntimeContexts([
'og',
]);
if (!empty($contexts['og']) && ($group = $contexts['og']
->getContextValue())) {
if ($group instanceof ContentEntityInterface) {
return $group;
}
}
}