These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | /* |
||
4 | * This file is part of the FOSHttpCacheBundle package. |
||
5 | * |
||
6 | * (c) FriendsOfSymfony <http://friendsofsymfony.github.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 FOS\HttpCacheBundle\Command; |
||
13 | |||
14 | use FOS\HttpCacheBundle\CacheManager; |
||
15 | use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; |
||
16 | |||
17 | /** |
||
18 | * Base class for commands to trigger cache invalidation from the command line. |
||
19 | * |
||
20 | * @author David Buchmann <[email protected]> |
||
21 | */ |
||
22 | abstract class BaseInvalidateCommand extends ContainerAwareCommand |
||
23 | { |
||
24 | /** |
||
25 | * @var CacheManager |
||
26 | */ |
||
27 | private $cacheManager; |
||
28 | |||
29 | /** |
||
30 | * If no cache manager is specified explicitly, fos_http_cache.cache_manager |
||
31 | * is automatically loaded. |
||
32 | * |
||
33 | * @param CacheManager|null $cacheManager The cache manager to talk to |
||
34 | */ |
||
35 | 14 | public function __construct(CacheManager $cacheManager = null) |
|
36 | { |
||
37 | 14 | if (!$cacheManager) { |
|
38 | 1 | @trigger_error('Instantiating commands without the cache manager is deprecated and will be removed in version 3', E_USER_DEPRECATED); |
|
0 ignored issues
–
show
|
|||
39 | } |
||
40 | 14 | $this->cacheManager = $cacheManager; |
|
41 | 14 | parent::__construct(); |
|
42 | 14 | } |
|
43 | |||
44 | /** |
||
45 | * Get the configured cache manager, loading fos_http_cache.cache_manager |
||
46 | * from the container if none was specified. |
||
47 | * |
||
48 | * @return CacheManager |
||
49 | */ |
||
50 | 9 | protected function getCacheManager() |
|
51 | { |
||
52 | 9 | if (!$this->cacheManager) { |
|
53 | 1 | $this->cacheManager = $this->getContainer()->get('fos_http_cache.cache_manager'); |
|
54 | } |
||
55 | |||
56 | 9 | return $this->cacheManager; |
|
57 | } |
||
58 | } |
||
59 |
If you suppress an error, we recommend checking for the error condition explicitly: