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

BundleCacheWarmer   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 24
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A warmUp() 0 6 1
A isOptional() 0 4 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