/** * Publish the asset * * @param Asset\LocalInterface $asset * @return bool */ private function publishAsset(Asset\LocalInterface $asset) { $targetDir = $this->filesystem->getDirectoryWrite(DirectoryList::STATIC_VIEW); $rootDir = $this->filesystem->getDirectoryWrite(DirectoryList::ROOT); $source = $rootDir->getRelativePath($asset->getSourceFile()); $destination = $asset->getPath(); $strategy = $this->materializationStrategyFactory->create($asset); return $strategy->publishFile($rootDir, $targetDir, $source, $destination); }
/** * Publish the asset * * @param Asset\LocalInterface $asset * @return bool */ private function publishAsset(Asset\LocalInterface $asset) { $targetDir = $this->filesystem->getDirectoryWrite(DirectoryList::STATIC_VIEW); $fullSource = $asset->getSourceFile(); $source = basename($fullSource); $sourceDir = $this->writeFactory->create(dirname($fullSource)); $destination = $asset->getPath(); $strategy = $this->materializationStrategyFactory->create($asset); return $strategy->publishFile($sourceDir, $targetDir, $source, $destination); }
public function testCreateException() { $asset = $this->getAsset(); $copyStrategy = $this->getMockBuilder('Magento\\Framework\\App\\View\\Asset\\MaterializationStrategy\\Copy')->setMethods([])->getMock(); $copyStrategy->expects($this->once())->method('isSupported')->with($asset)->willReturn(false); $this->objectManager->expects($this->once())->method('get')->with(Factory::DEFAULT_STRATEGY)->willReturn($copyStrategy); $factory = new Factory($this->objectManager, []); $this->setExpectedException('LogicException', 'No materialization strategy is supported'); $factory->create($asset); }