class CustomAccessCheck implements AccessInterface (View source)

Defines an access checker that allows specifying a custom method for access.

You should only use it when you are sure that the access callback will not be reused. Good examples in core are Edit or Toolbar module.

The method is called on another instance of the controller class, so you cannot reuse any stored property of your actual controller instance used to generate the output.

Properties

protected ControllerResolverInterface $controllerResolver

The controller resolver.

protected AccessArgumentsResolverFactoryInterface $argumentsResolverFactory

The arguments resolver.

Methods

__construct(ControllerResolverInterface $controller_resolver, AccessArgumentsResolverFactoryInterface $arguments_resolver_factory)

Constructs a CustomAccessCheck instance.

access(Route $route, RouteMatchInterface $route_match, AccountInterface $account)

Checks access for the account and route using the custom access checker.

Details

__construct(ControllerResolverInterface $controller_resolver, AccessArgumentsResolverFactoryInterface $arguments_resolver_factory)

Constructs a CustomAccessCheck instance.

Parameters

ControllerResolverInterface $controller_resolver

The controller resolver.

AccessArgumentsResolverFactoryInterface $arguments_resolver_factory

The arguments resolver factory.

AccessResultInterface access(Route $route, RouteMatchInterface $route_match, AccountInterface $account)

Checks access for the account and route using the custom access checker.

Parameters

Route $route

The route.

RouteMatchInterface $route_match

The route match object to be checked.

AccountInterface $account

The account being checked.

Return Value

AccessResultInterface

The access result.