Chris@0
|
1 <?php
|
Chris@0
|
2
|
Chris@0
|
3 namespace Drupal\Core\Access;
|
Chris@0
|
4
|
Chris@0
|
5 use Symfony\Component\Routing\RouteCollection;
|
Chris@0
|
6
|
Chris@0
|
7 /**
|
Chris@0
|
8 * Provides the available access checkers by service IDs.
|
Chris@0
|
9 *
|
Chris@0
|
10 * Access checker services are added by ::addCheckService calls and are loaded
|
Chris@0
|
11 * by ::loadCheck.
|
Chris@0
|
12 *
|
Chris@0
|
13 * The checker provider service and the actual checking is separated in order
|
Chris@0
|
14 * to not require the full access manager on route build time.
|
Chris@0
|
15 */
|
Chris@0
|
16 interface CheckProviderInterface {
|
Chris@0
|
17
|
Chris@0
|
18
|
Chris@0
|
19 /**
|
Chris@0
|
20 * For each route, saves a list of applicable access checks to the route.
|
Chris@0
|
21 *
|
Chris@0
|
22 * @param \Symfony\Component\Routing\RouteCollection $routes
|
Chris@0
|
23 * A collection of routes to apply checks to.
|
Chris@0
|
24 */
|
Chris@0
|
25 public function setChecks(RouteCollection $routes);
|
Chris@0
|
26
|
Chris@0
|
27 /**
|
Chris@0
|
28 * Registers a new AccessCheck by service ID.
|
Chris@0
|
29 *
|
Chris@0
|
30 * @param string $service_id
|
Chris@0
|
31 * The ID of the service in the Container that provides a check.
|
Chris@0
|
32 * @param string $service_method
|
Chris@0
|
33 * The method to invoke on the service object for performing the check.
|
Chris@0
|
34 * @param array $applies_checks
|
Chris@0
|
35 * (optional) An array of route requirement keys the checker service applies
|
Chris@0
|
36 * to.
|
Chris@0
|
37 * @param bool $needs_incoming_request
|
Chris@0
|
38 * (optional) True if access-check method only acts on an incoming request.
|
Chris@0
|
39 */
|
Chris@0
|
40 public function addCheckService($service_id, $service_method, array $applies_checks = [], $needs_incoming_request = FALSE);
|
Chris@0
|
41
|
Chris@0
|
42 /**
|
Chris@0
|
43 * Lazy-loads access check services.
|
Chris@0
|
44 *
|
Chris@0
|
45 * @param string $service_id
|
Chris@0
|
46 * The service id of the access check service to load.
|
Chris@0
|
47 *
|
Chris@0
|
48 * @return callable
|
Chris@0
|
49 * A callable access check.
|
Chris@0
|
50 *
|
Chris@0
|
51 * @throws \InvalidArgumentException
|
Chris@0
|
52 * Thrown when the service hasn't been registered in addCheckService().
|
Chris@0
|
53 * @throws \Drupal\Core\Access\AccessException
|
Chris@0
|
54 * Thrown when the service doesn't implement the required interface.
|
Chris@0
|
55 */
|
Chris@0
|
56 public function loadCheck($service_id);
|
Chris@0
|
57
|
Chris@0
|
58 /**
|
Chris@0
|
59 * A list of checks that needs the request.
|
Chris@0
|
60 *
|
Chris@0
|
61 * @return array
|
Chris@0
|
62 */
|
Chris@0
|
63 public function getChecksNeedRequest();
|
Chris@0
|
64
|
Chris@0
|
65 }
|