public static function RouteSubscriber::isViewing in Lightning Core 8.5
Same name and namespace in other branches
- 8 src/Routing/RouteSubscriber.php \Drupal\lightning_core\Routing\RouteSubscriber::isViewing()
- 8.2 src/Routing/RouteSubscriber.php \Drupal\lightning_core\Routing\RouteSubscriber::isViewing()
- 8.3 src/Routing/RouteSubscriber.php \Drupal\lightning_core\Routing\RouteSubscriber::isViewing()
- 8.4 src/Routing/RouteSubscriber.php \Drupal\lightning_core\Routing\RouteSubscriber::isViewing()
Checks if we are currently viewing an entity at its canonical route.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The entity.
\Drupal\Core\Routing\RouteMatchInterface $route_match: (optional) The current route match.
Return value
bool TRUE if we are at the entity's canonical route, FALSE otherwise.
File
- src/
Routing/ RouteSubscriber.php, line 94
Class
- RouteSubscriber
- Dynamically alters various routes.
Namespace
Drupal\lightning_core\RoutingCode
public static function isViewing(EntityInterface $entity, RouteMatchInterface $route_match = NULL) {
$route_match = $route_match ?: \Drupal::routeMatch();
$entity_type = $entity
->getEntityTypeId();
return $route_match
->getRouteName() == "entity.{$entity_type}.canonical" && $route_match
->getRawParameter($entity_type) == $entity
->id();
}