1 | <?php |
||
28 | class PurgeSubscriber extends AccessControlledSubscriber |
||
29 | { |
||
30 | const DEFAULT_PURGE_METHOD = 'PURGE'; |
||
31 | |||
32 | /** |
||
33 | * The options configured in the constructor argument or default values. |
||
34 | * |
||
35 | * @var array |
||
36 | */ |
||
37 | private $options = []; |
||
38 | |||
39 | /** |
||
40 | * When creating this subscriber, you can configure a number of options. |
||
41 | * |
||
42 | * - purge_method: HTTP method that identifies purge requests. |
||
43 | * - purge_client_matcher: RequestMatcher to identify valid purge clients. |
||
44 | * - purge_client_ips: IP or array of IPs that are allowed to purge. |
||
45 | * |
||
46 | * Only set one of purge_client_ips and purge_client_matcher. |
||
47 | * |
||
48 | * @param array $options Options to overwrite the default options |
||
49 | * |
||
50 | * @throws \InvalidArgumentException if unknown keys are found in $options |
||
51 | */ |
||
52 | 6 | public function __construct(array $options = []) |
|
53 | { |
||
54 | 6 | $resolver = new OptionsResolver(); |
|
55 | 6 | if (method_exists($resolver, 'setDefined')) { |
|
56 | // this was only added in symfony 2.6 |
||
57 | $resolver->setDefined(['purge_client_matcher', 'purge_client_ips', 'purge_method']); |
||
58 | } else { |
||
59 | 6 | $resolver->setOptional(['purge_client_matcher', 'purge_client_ips', 'purge_method']); |
|
|
|||
60 | } |
||
61 | 6 | $resolver->setDefaults([ |
|
62 | 6 | 'purge_client_matcher' => null, |
|
63 | 6 | 'purge_client_ips' => null, |
|
64 | 6 | 'purge_method' => static::DEFAULT_PURGE_METHOD, |
|
65 | 6 | ]); |
|
66 | |||
67 | 6 | $this->options = $resolver->resolve($options); |
|
68 | |||
69 | 5 | parent::__construct($this->options['purge_client_matcher'], $this->options['purge_client_ips']); |
|
70 | 5 | } |
|
71 | |||
72 | /** |
||
73 | * {@inheritdoc} |
||
74 | */ |
||
75 | public static function getSubscribedEvents() |
||
81 | |||
82 | /** |
||
83 | * Look at unsafe requests and handle purge requests. |
||
84 | * |
||
85 | * Prevents access when the request comes from a non-authorized client. |
||
86 | * |
||
87 | * @param CacheEvent $event |
||
88 | */ |
||
89 | 5 | public function handlePurge(CacheEvent $event) |
|
110 | } |
||
111 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.