/** * 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 ServiceLocatorInterface $serviceLocator */ public function __construct(ServiceLocatorInterface $serviceLocator) { $serviceFactory = new ServiceFactory(); $this->service = $serviceFactory->createService($serviceLocator); $this->service->build(); $this->baseUrl = $this->service->getConfiguration()->getBaseUrl(); $this->basePath = $this->service->getConfiguration()->getBasePath(); }
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); }
/** * @inheritdoc */ public function build() { if ($this->built) { return; } $key = 'assets-manager'; if ($this->cacheAdapter->hasItem($key)) { $data = $this->cacheAdapter->getItem($key); $assetManager = unserialize($data); if ($assetManager instanceof AssetManager) { $this->setAssetManager($assetManager); return; } } parent::build(); $this->cacheAdapter->setItem($key, serialize($this->getAssetManager())); $this->built = true; }