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 * For each route, saves a list of applicable access checks to the route.
|
Chris@0
|
20 *
|
Chris@0
|
21 * @param \Symfony\Component\Routing\RouteCollection $routes
|
Chris@0
|
22 * A collection of routes to apply checks to.
|
Chris@0
|
23 */
|
Chris@0
|
24 public function setChecks(RouteCollection $routes);
|
Chris@0
|
25
|
Chris@0
|
26 /**
|
Chris@0
|
27 * Registers a new AccessCheck by service ID.
|
Chris@0
|
28 *
|
Chris@0
|
29 * @param string $service_id
|
Chris@0
|
30 * The ID of the service in the Container that provides a check.
|
Chris@0
|
31 * @param string $service_method
|
Chris@0
|
32 * The method to invoke on the service object for performing the check.
|
Chris@0
|
33 * @param array $applies_checks
|
Chris@0
|
34 * (optional) An array of route requirement keys the checker service applies
|
Chris@0
|
35 * to.
|
Chris@0
|
36 * @param bool $needs_incoming_request
|
Chris@0
|
37 * (optional) True if access-check method only acts on an incoming request.
|
Chris@0
|
38 */
|
Chris@0
|
39 public function addCheckService($service_id, $service_method, array $applies_checks = [], $needs_incoming_request = FALSE);
|
Chris@0
|
40
|
Chris@0
|
41 /**
|
Chris@0
|
42 * Lazy-loads access check services.
|
Chris@0
|
43 *
|
Chris@0
|
44 * @param string $service_id
|
Chris@0
|
45 * The service id of the access check service to load.
|
Chris@0
|
46 *
|
Chris@0
|
47 * @return callable
|
Chris@0
|
48 * A callable access check.
|
Chris@0
|
49 *
|
Chris@0
|
50 * @throws \InvalidArgumentException
|
Chris@0
|
51 * Thrown when the service hasn't been registered in addCheckService().
|
Chris@0
|
52 * @throws \Drupal\Core\Access\AccessException
|
Chris@0
|
53 * Thrown when the service doesn't implement the required interface.
|
Chris@0
|
54 */
|
Chris@0
|
55 public function loadCheck($service_id);
|
Chris@0
|
56
|
Chris@0
|
57 /**
|
Chris@0
|
58 * A list of checks that needs the request.
|
Chris@0
|
59 *
|
Chris@0
|
60 * @return array
|
Chris@0
|
61 */
|
Chris@0
|
62 public function getChecksNeedRequest();
|
Chris@0
|
63
|
Chris@0
|
64 }
|