protected function OgRouteGroupResolverBase::getContentEntity in Organic groups 8
Returns the content entity from the current route.
This will return the entity if the current route matches the entity paths ('link templates') that are defined in the entity definition.
Return value
\Drupal\Core\Entity\ContentEntityInterface|null The entity, or NULL if we are not on a content entity path.
2 calls to OgRouteGroupResolverBase::getContentEntity()
- RouteGroupContentResolver::resolve in src/
Plugin/ OgGroupResolver/ RouteGroupContentResolver.php - Resolves groups within the plugin's domain.
- RouteGroupResolver::resolve in src/
Plugin/ OgGroupResolver/ RouteGroupResolver.php - Resolves groups within the plugin's domain.
File
- src/
OgRouteGroupResolverBase.php, line 92
Class
- OgRouteGroupResolverBase
- Base class for OgGroupResolver plugins that inspect the route.
Namespace
Drupal\ogCode
protected function getContentEntity() {
$route = $this->routeMatch
->getRouteObject();
if (!$route) {
return NULL;
}
// Check if we are on a content entity path.
$path = $route
->getPath();
$paths = $this
->getContentEntityPaths();
if (array_key_exists($path, $paths)) {
// Return the entity.
return $this->routeMatch
->getParameter($paths[$path]);
}
return NULL;
}