AsseticBundle\Service::createAssetFactory PHP Method

createAssetFactory() public method

public createAssetFactory ( array $configuration ) : Assetic\Factory\AssetFactory
$configuration array
return Assetic\Factory\AssetFactory
    public function createAssetFactory(array $configuration)
    {
        $factory = new Factory\AssetFactory($configuration['root_path']);
        $factory->setAssetManager($this->getAssetManager());
        $factory->setFilterManager($this->getFilterManager());
        $worker = $this->getCacheBusterStrategy();
        if ($worker instanceof WorkerInterface) {
            $factory->addWorker($worker);
        }
        $factory->setDebug($this->configuration->isDebug());
        return $factory;
    }

Usage Example

Example #1
0
 public function testCacheBusterStrategyWorker()
 {
     $factory = $this->object->createAssetFactory($this->configuration->getModule('test_application'));
     // no workers by default:
     $this->assertAttributeEquals(array(), 'workers', $factory);
     $cacheBusterStrategy = $this->getMock('AsseticBundle\\CacheBuster\\LastModifiedStrategy');
     $this->object->setCacheBusterStrategy($cacheBusterStrategy);
     $factory = $this->object->createAssetFactory($this->configuration->getModule('test_application'));
     // cache buster strategy is added to workers list:
     $this->assertAttributeEquals(array($cacheBusterStrategy), 'workers', $factory);
 }