Completed
Push — master ( 6cec30...bddb48 )
by nicolas
11s
created

ConfigFileCacheWarmer::warmUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Dekalee\AdbackAnalyticsBundle\CacheWarmer;
4
5
use Dekalee\AdbackAnalytics\Query\ScriptUrlQuery;
6
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface;
7
8
/**
9
 * Class ConfigFileCacheWarmer
10
 */
11
class ConfigFileCacheWarmer implements CacheWarmerInterface
12
{
13
    protected $query;
14
15
    /**
16
     * @param ScriptUrlQuery $query
17
     */
18
    public function __construct(ScriptUrlQuery $query)
19
    {
20
        $this->query = $query;
21
    }
22
23
    /**
24
     * Checks whether this warmer is optional or not.
25
     *
26
     * Optional warmers can be ignored on certain conditions.
27
     *
28
     * A warmer should return true if the cache can be
29
     * generated incrementally and on-demand.
30
     *
31
     * @return bool true if the warmer is optional, false otherwise
32
     */
33
    public function isOptional()
34
    {
35
        return false;
36
    }
37
38
    /**
39
     * Warms up the cache.
40
     *
41
     * @param string $cacheDir The cache directory
42
     */
43
    public function warmUp($cacheDir)
44
    {
45
        $this->query->execute();
46
    }
47
}
48