/** * @param AssetInterface $asset */ protected function write(AssetInterface $asset) { $umask = $this->configuration->getUmask(); if (null !== $umask) { $umask = umask($umask); } if ($this->configuration->isDebug() && !$this->configuration->isCombine() && $asset instanceof AssetCollection) { foreach ($asset as $item) { $this->writeAsset($item); } } else { $this->getAssetWriter()->writeAsset($asset); } if (null !== $umask) { umask($umask); } }
public function initLoadedModules(array $loadedModules) { $moduleConfiguration = $this->configuration->getModules(); foreach ($loadedModules as $moduleName => $module) { $moduleName = strtolower($moduleName); if (!isset($moduleConfiguration[$moduleName])) { continue; } $conf = (array) $moduleConfiguration[$moduleName]; $factory = new Factory\AssetFactory($conf['root_path']); $factory->setAssetManager($this->getAssetManager()); $factory->setFilterManager($this->getFilterManager()); $factory->setDebug($this->configuration->isDebug()); $collections = (array) $conf['collections']; foreach ($collections as $name => $options) { $assets = isset($options['assets']) ? $options['assets'] : array(); $filters = isset($options['filters']) ? $options['filters'] : array(); $options = isset($options['options']) ? $options['options'] : array(); $options['output'] = isset($options['output']) ? $options['output'] : $name; $filters = $this->initFilters($filters); /** @var $asset \Assetic\Asset\AssetCollection */ $asset = $factory->createAsset($assets, $filters, $options); # allow to move all files 1:1 to new directory # its particulary usefull when this assets are images. if (isset($options['move_raw']) && $options['move_raw']) { foreach ($asset as $key => $value) { $name = md5($value->getSourceRoot() . $value->getSourcePath()); $value->setTargetPath($value->getSourcePath()); $value = $this->cache($value); $this->assetManager->set($name, $value); } } else { $asset = $this->cache($asset); $this->assetManager->set($name, $asset); } } $writer = new AssetWriter($this->configuration->getWebPath()); $writer->writeManagerAssets($this->assetManager); } }
public function testSetDebug() { $expected = true; $this->assertNull($this->object->setDebug($expected)); $this->assertEquals($expected, $this->object->isDebug()); }