|
16 | 16 | use Symfony\Component\HttpFoundation\RequestMatcher; |
17 | 17 | use Symfony\Component\HttpFoundation\Response; |
18 | 18 | use Symfony\Component\HttpKernel\HttpKernelInterface; |
| 19 | +use Symfony\Component\OptionsResolver\OptionsResolver; |
19 | 20 |
|
20 | 21 | /** |
21 | 22 | * Purge handler for the symfony built-in HttpCache. |
@@ -48,20 +49,17 @@ class PurgeSubscriber extends AccessControlledSubscriber |
48 | 49 | */ |
49 | 50 | public function __construct(array $options = array()) |
50 | 51 | { |
51 | | - $extra = array_diff(array_keys($options), array('purge_client_matcher', 'purge_client_ips', 'purge_method')); |
52 | | - if (count($extra)) { |
53 | | - throw new \InvalidArgumentException(sprintf( |
54 | | - 'Unsupported purge configuration option(s) "%s"', |
55 | | - implode(', ', $extra) |
56 | | - )); |
57 | | - } |
| 52 | + $resolver = new OptionsResolver(); |
| 53 | + $resolver->setDefined(array('purge_client_matcher', 'purge_client_ips', 'purge_method')); |
| 54 | + $resolver->setDefaults(array( |
| 55 | + 'purge_client_matcher' => null, |
| 56 | + 'purge_client_ips' => null, |
| 57 | + 'purge_method' => 'PURGE', |
| 58 | + )); |
58 | 59 |
|
59 | | - parent::__construct( |
60 | | - isset($options['purge_client_matcher']) ? $options['purge_client_matcher'] : null, |
61 | | - isset($options['purge_client_ips']) ? $options['purge_client_ips'] : null |
62 | | - ); |
| 60 | + $this->options = $resolver->resolve($options); |
63 | 61 |
|
64 | | - $this->options['purge_method'] = isset($options['purge_method']) ? $options['purge_method'] : 'PURGE'; |
| 62 | + parent::__construct($this->options['purge_client_matcher'], $this->options['purge_client_ips']); |
65 | 63 | } |
66 | 64 |
|
67 | 65 | /** |
|
0 commit comments