Drupal\helper\CurrentEntity
Provides helper for working with current entities.
Methods
Name | Description |
---|---|
__construct | CurrentEntity constructor. |
fromRouteMatch | Gets the entity from a route match. |
CurrentEntity::__construct
Description
public __construct (\Drupal\Core\Extension\ModuleHandlerInterface $module_handler, \Drupal\Core\Routing\RouteMatchInterface $route_match)
CurrentEntity constructor.
Parameters
(\Drupal\Core\Extension\ModuleHandlerInterface) $module_handler
: The module handler.(\Drupal\Core\Routing\RouteMatchInterface) $route_match
: Route match.
Return Values
void
CurrentEntity::fromRouteMatch
Description
public fromRouteMatch (\Drupal\Core\Routing\RouteMatchInterface|null $route_match)
Gets the entity from a route match.
Parameters
(\Drupal\Core\Routing\RouteMatchInterface|null) $route_match
: The route match to use, otherwise uses the current route match.
Return Values
\Drupal\Core\Entity\EntityInterface|null
The current page entity, or NULL if this is not an entity route.