Completed
Push — master ( afd09d...952c66 )
by Adam
05:47
created

DoctrineEnhancerCacheWarmer::__construct()   A

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
 * WellCommerce Open-Source E-Commerce Platform
4
 *
5
 * This file is part of the WellCommerce package.
6
 *
7
 * (c) Adam Piotrowski <[email protected]>
8
 *
9
 * For the full copyright and license information,
10
 * please view the LICENSE file that was distributed with this source code.
11
 */
12
13
namespace WellCommerce\Bundle\CoreBundle\CacheWarmer;
14
15
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface;
16
use WellCommerce\Component\DoctrineEnhancer\TraitGenerator\TraitGenerator;
17
use WellCommerce\Component\DoctrineEnhancer\TraitGenerator\TraitGeneratorEnhancerCollection;
18
19
/**
20
 * Class DoctrineEnhancerCacheWarmer
21
 *
22
 * @author  Adam Piotrowski <[email protected]e.org>
23
 */
24
class DoctrineEnhancerCacheWarmer implements CacheWarmerInterface
25
{
26
    private $collection;
27
    
28
    public function __construct(TraitGeneratorEnhancerCollection $collection)
29
    {
30
        $this->collection = $collection;
31
    }
32
    
33
    public function warmUp($cacheDir)
34
    {
35
        foreach ($this->collection as $traitClass => $enhancers) {
36
            $generator = new TraitGenerator($traitClass, $enhancers);
37
            $generator->generate();
38
        }
39
    }
40
    
41
    /**
42
     * Checks whether this warmer is optional or not.
43
     *
44
     * @return Boolean always true
45
     */
46
    public function isOptional()
47
    {
48
        return false;
49
    }
50
}
51