Completed
Pull Request — master (#4)
by
unknown
01:53
created

AssetFactory::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 3
nc 1
nop 5
1
<?php
2
3
namespace Hshn\AngularBundle\Factory;
4
5
use Symfony\Component\DependencyInjection\ContainerInterface;
6
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
7
use Symfony\Component\HttpKernel\KernelInterface;
8
use Symfony\Bundle\AsseticBundle\Factory\AssetFactory as BaseAssetFactory;
9
use Assetic\Asset\AssetInterface;
10
11
class AssetFactory extends BaseAssetFactory
12
{
13
    private $container;
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
14
15
    /**
16
     * @inheritdoc
17
     */
18
    public function __construct(KernelInterface $kernel, ContainerInterface $container, ParameterBagInterface $parameterBag, $baseDir, $debug = false)
19
    {
20
        parent::__construct($kernel, $container, $parameterBag, $baseDir, $debug);
21
22
        $this->container = $container;
23
    }
24
25
    /**
26
     * @inheritdoc
27
     */
28
    protected function parseInput($input, array $options = array())
29
    {
30
        if (0 === strpos($input, '@ng_template_cache_')) {
31
            return $this->createTemplateCacheAsset(str_replace('@ng_template_cache_', '', $input));
32
        }
33
34
        return parent::parseInput($input, $options);
35
    }
36
37
    /**
38
     * @param $name
39
     * @return object
40
     */
41
    protected function createTemplateCacheAsset($name)
42
    {
43
        return $this->container->get(sprintf('hshn_angular.asset.template_cache.%s', $name));
44
    }
45
}
46