1 | <?php |
||
28 | abstract class AccessControlledListener implements EventSubscriberInterface |
||
29 | { |
||
30 | /** |
||
31 | * @var RequestMatcher |
||
32 | */ |
||
33 | private $clientMatcher; |
||
34 | |||
35 | /** |
||
36 | * When creating this event listener, you can configure a number of options. |
||
37 | * |
||
38 | * - client_matcher: RequestMatcherInterface to identify clients that are allowed to send request. |
||
39 | * - client_ips: IP or array of IPs of clients that are allowed to send requests. |
||
40 | * |
||
41 | * Only one of request matcher or IPs may be a non-null value. If you use a |
||
42 | * RequestMatcher, configure your IPs into it. |
||
43 | * |
||
44 | * If neither parameter is set, the filter is IP 127.0.0.1 |
||
45 | * |
||
46 | * @param array $options Options to overwrite the default options |
||
47 | * |
||
48 | * @throws \InvalidArgumentException if both client_matcher and client_ips are set or unknown keys are found in $options |
||
49 | */ |
||
50 | 14 | public function __construct(array $options = []) |
|
64 | |||
65 | /** |
||
66 | * Get the options resolver for the constructor arguments. |
||
67 | * |
||
68 | * @return OptionsResolver |
||
69 | */ |
||
70 | 14 | protected function getOptionsResolver() |
|
82 | |||
83 | /** |
||
84 | * Check whether the request is allowed. |
||
85 | * |
||
86 | * @param Request $request The request to check |
||
87 | * |
||
88 | * @return bool Whether access is granted |
||
89 | */ |
||
90 | protected function isRequestAllowed(Request $request) |
||
94 | } |
||
95 |