class ViewModeAccessCheck implements AccessInterface (View source)

Defines an access check for entity view mode routes.

Properties

protected EntityTypeManagerInterface $entityTypeManager

The entity type manager.

Methods

__construct(EntityTypeManagerInterface $entity_type_manager)

Creates a new ViewModeAccessCheck.

access(Route $route, RouteMatchInterface $route_match, AccountInterface $account, string $view_mode_name = 'default', string $bundle = NULL)

Checks access to the view mode.

Details

__construct(EntityTypeManagerInterface $entity_type_manager)

Creates a new ViewModeAccessCheck.

Parameters

EntityTypeManagerInterface $entity_type_manager

The entity type manager.

AccessResultInterface access(Route $route, RouteMatchInterface $route_match, AccountInterface $account, string $view_mode_name = 'default', string $bundle = NULL)

Checks access to the view mode.

Parameters

Route $route

The route to check against.

RouteMatchInterface $route_match

The parametrized route.

AccountInterface $account

The currently logged in account.

string $view_mode_name

(optional) The view mode. Defaults to 'default'.

string $bundle

(optional) The bundle. Different entity types can have different names for their bundle key, so if not specified on the route via a {bundle} parameter, the access checker determines the appropriate key name, and gets the value from the corresponding request attribute. For example, for nodes, the bundle key is "node_type", so the value would be available via the {node_type} parameter rather than a {bundle} parameter.

Return Value

AccessResultInterface

The access result.