vendor/symfony/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/RouterCacheWarmer.php
equal
deleted
inserted
replaced
|
1 <?php |
|
2 |
|
3 /* |
|
4 * This file is part of the Symfony package. |
|
5 * |
|
6 * (c) Fabien Potencier <fabien@symfony.com> |
|
7 * |
|
8 * For the full copyright and license information, please view the LICENSE |
|
9 * file that was distributed with this source code. |
|
10 */ |
|
11 |
|
12 namespace Symfony\Bundle\FrameworkBundle\CacheWarmer; |
|
13 |
|
14 use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface; |
|
15 use Symfony\Component\Routing\Router; |
|
16 |
|
17 /** |
|
18 * Generates the router matcher and generator classes. |
|
19 * |
|
20 * @author Fabien Potencier <fabien@symfony.com> |
|
21 */ |
|
22 class RouterCacheWarmer implements CacheWarmerInterface |
|
23 { |
|
24 protected $router; |
|
25 |
|
26 /** |
|
27 * Constructor. |
|
28 * |
|
29 * @param Router $router A Router instance |
|
30 */ |
|
31 public function __construct(Router $router) |
|
32 { |
|
33 $this->router = $router; |
|
34 } |
|
35 |
|
36 /** |
|
37 * Warms up the cache. |
|
38 * |
|
39 * @param string $cacheDir The cache directory |
|
40 */ |
|
41 public function warmUp($cacheDir) |
|
42 { |
|
43 $currentDir = $this->router->getOption('cache_dir'); |
|
44 |
|
45 // force cache generation |
|
46 $this->router->setOption('cache_dir', $cacheDir); |
|
47 $this->router->getMatcher(); |
|
48 $this->router->getGenerator(); |
|
49 |
|
50 $this->router->setOption('cache_dir', $currentDir); |
|
51 } |
|
52 |
|
53 /** |
|
54 * Checks whether this warmer is optional or not. |
|
55 * |
|
56 * @return Boolean always true |
|
57 */ |
|
58 public function isOptional() |
|
59 { |
|
60 return true; |
|
61 } |
|
62 } |