/** * Executes the current command. * * @param InputInterface $input An InputInterface instance * @param OutputInterface $output An OutputInterface instance * * @return null|int null or 0 if everything went fine, or an error code */ protected function execute(InputInterface $input, OutputInterface $output) { $config = $this->assetic->getConfiguration(); $config->setBuildOnRequest(true); $this->assetic->build(); $this->assetic->getAssetWriter()->writeManagerAssets($this->assetic->getAssetManager()); }
/** * @param string $collectionName * @param array $options * * @return string * * @throws \AsseticBundle\Exception\InvalidArgumentException */ public function __invoke($collectionName, array $options = []) { if (!$this->service->getAssetManager()->has($collectionName)) { throw new Exception\InvalidArgumentException('Collection "' . $collectionName . '" does not exist.'); } $asset = $this->service->getAssetManager()->get($collectionName); return $this->setupAsset($asset, $options); }
public function buildAction() { $config = $this->assetic->getConfiguration(); $config->setBuildOnRequest(true); $this->assetic->build(); $manager = $this->assetic->getAssetManager(); $writer = $this->assetic->getAssetWriter(); $writer->writeManagerAssets($manager); }
public function testWriteAssetIfNotUpdated() { $this->configuration->setBuildOnRequest(true); $this->configuration->setWriteIfChanged(true); $this->object->build(); $manager = $this->object->getAssetManager(); $assets = $manager->get('base_css')->all(); /** @var \Assetic\Asset\AssetInterface $asset */ $asset = $assets[0]; $asset->setTargetPath($manager->get('base_css')->getTargetPath()); $targetFile = $this->configuration->getWebPath($asset->getTargetPath()); if (is_file($targetFile)) { unlink($targetFile); } $this->assertFileNotExists($targetFile); $this->object->writeAsset($asset); $this->assertFileExists($targetFile); $sourceFile = $asset->getSourceRoot() . '/' . $asset->getSourcePath(); $targetMTime = filemtime($targetFile); sleep(2); $modifiedAsset = new FileAsset($sourceFile); $modifiedAsset->setTargetPath($targetFile); $this->object->writeAsset($modifiedAsset); clearstatcache(true, $targetFile); $targetMTimeNotModified = filemtime($targetFile); $this->assertLessThanOrEqual($targetMTime, $targetMTimeNotModified); }