class CheckProvider implements CheckProviderInterface, ContainerAwareInterface (View source)

Loads access checkers from the container.

Traits

ContainerAwareTrait

Properties

protected array $checkIds

Array of registered access check service ids.

protected AccessInterface[] $checks

Array of access check objects keyed by service id.

protected array $checkMethods

Array of access check method names keyed by service ID.

protected $checksNeedsRequest

Array of access checks which only will be run on the incoming request.

protected array $staticRequirementMap

An array to map static requirement keys to service IDs.

protected array $dynamicRequirementMap

An array to map dynamic requirement keys to service IDs.

Methods

addCheckService(string $service_id, string $service_method, array $applies_checks = [], bool $needs_incoming_request = FALSE)

Registers a new AccessCheck by service ID.

array
getChecksNeedRequest()

A list of checks that needs the request.

setChecks(RouteCollection $routes)

For each route, saves a list of applicable access checks to the route.

callable
loadCheck(string $service_id)

Lazy-loads access check services.

array
applies(Route $route)

Determine which registered access checks apply to a route.

loadDynamicRequirementMap()

Compiles a mapping of requirement keys to access checker service IDs.

Details

addCheckService(string $service_id, string $service_method, array $applies_checks = [], bool $needs_incoming_request = FALSE)

Registers a new AccessCheck by service ID.

Parameters

string $service_id

The ID of the service in the Container that provides a check.

string $service_method

The method to invoke on the service object for performing the check.

array $applies_checks

(optional) An array of route requirement keys the checker service applies to.

bool $needs_incoming_request

(optional) True if access-check method only acts on an incoming request.

array getChecksNeedRequest()

A list of checks that needs the request.

Return Value

array

setChecks(RouteCollection $routes)

For each route, saves a list of applicable access checks to the route.

Parameters

RouteCollection $routes

A collection of routes to apply checks to.

callable loadCheck(string $service_id)

Lazy-loads access check services.

Parameters

string $service_id

The service id of the access check service to load.

Return Value

callable

A callable access check.

Exceptions

InvalidArgumentException
AccessException

protected array applies(Route $route)

Determine which registered access checks apply to a route.

Parameters

Route $route

The route to get list of access checks for.

Return Value

array

An array of service ids for the access checks that apply to passed route.

protected loadDynamicRequirementMap()

Compiles a mapping of requirement keys to access checker service IDs.