1 | <?php |
||
24 | class AllowedMethodsRouterLoader implements AllowedMethodsLoaderInterface, CacheWarmerInterface |
||
25 | { |
||
26 | private $router; |
||
27 | private $cache; |
||
28 | |||
29 | /** |
||
30 | * Constructor. |
||
31 | * |
||
32 | * @param RouterInterface $router |
||
33 | * @param string $cacheDir |
||
34 | * @param bool $isDebug Kernel debug flag |
||
35 | */ |
||
36 | 3 | public function __construct(RouterInterface $router, $cacheDir, $isDebug) |
|
37 | { |
||
38 | 3 | $this->router = $router; |
|
39 | 3 | $this->cache = new ConfigCache(sprintf('%s/allowed_methods.cache.php', $cacheDir), $isDebug); |
|
40 | 3 | } |
|
41 | |||
42 | /** |
||
43 | * {@inheritdoc} |
||
44 | */ |
||
45 | 2 | public function getAllowedMethods() |
|
46 | { |
||
47 | 2 | if (!$this->cache->isFresh()) { |
|
48 | 2 | $this->warmUp(null); |
|
49 | 2 | } |
|
50 | |||
51 | 2 | return require $this->cache->getPath(); |
|
52 | } |
||
53 | |||
54 | /** |
||
55 | * {@inheritdoc} |
||
56 | */ |
||
57 | 2 | public function isOptional() |
|
61 | |||
62 | /** |
||
63 | * {@inheritdoc} |
||
64 | */ |
||
65 | 2 | public function warmUp($cacheDir) |
|
101 | } |
||
102 |