Completed
Push — master ( f1eedc...1b618f )
by Adam
05:55
created

BundleCacheWarmer::__construct()   A

↳ Parent: BundleCacheWarmer

Complexity

Conditions 1
Paths 1

Duplication

Lines 0
Ratio 0 %

Size

Total Lines 4
Code Lines 2

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace WellCommerce\Bundle\CoreBundle\CacheWarmer;
4
5
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmer;
6
use Symfony\Component\HttpKernel\KernelInterface;
7
use WellCommerce\Bundle\CoreBundle\Locator\BundleLocator;
8
9
/**
10
 * Class BundleCacheWarmer
11
 *
12
 * @author  Adam Piotrowski <[email protected]>
13
 */
14
class BundleCacheWarmer extends CacheWarmer
15
{
16
    /**
17
     * @var KernelInterface
18
     */
19
    private $kernel;
20
    
21
    public function __construct(KernelInterface $kernel)
22
    {
23
        $this->kernel = $kernel;
24
    }
25
    
26
    public function warmUp($cacheDir)
27
    {
28
        $locator        = new BundleLocator($this->kernel);
29
        $bundlesClasses = $locator->getBundleClasses();
30
        $this->writeCacheFile($cacheDir . '/bundles.php', sprintf('<?php return %s;', var_export($bundlesClasses, true)));
31
    }
32
    
33
    public function isOptional()
34
    {
35
        return false;
36
    }
37
}
38