public function testGetDirectoryRead() { /** @var \Magento\Framework\Filesystem\Directory\ReadInterface $dirReadMock */ $dirReadMock = $this->getMock('Magento\\Framework\\Filesystem\\Directory\\ReadInterface'); $this->_dirReadFactoryMock->expects($this->once())->method('create')->will($this->returnValue($dirReadMock)); $this->assertEquals($dirReadMock, $this->_filesystem->getDirectoryRead(DirectoryList::ROOT)); }
public function setup() { $this->readFactoryMock = $this->getMock('Magento\\Framework\\Filesystem\\Directory\\ReadFactory', [], [], '', false); $this->readerMock = $this->getMockForAbstractClass('Magento\\Framework\\Filesystem\\Directory\\ReadInterface', [], '', false); $this->readFactoryMock->expects($this->once())->method('create')->willReturn($this->readerMock); $this->basePackageInfo = new BasePackageInfo($this->readFactoryMock); }
/** * @param \Magento\Backend\Block\Context $context * @param \Magento\Framework\Filesystem $filesystem * @param \Magento\Framework\Filesystem\Directory\ReadFactory $directoryRead * @param \Magento\Framework\Stdlib\DateTime\DateTime $coreDate * @param array $data */ public function __construct(\Magento\Backend\Block\Context $context, \Magento\Framework\Filesystem $filesystem, \Magento\Framework\Filesystem\Directory\ReadFactory $directoryRead, \Magento\Framework\Stdlib\DateTime\DateTime $coreDate, array $data = []) { parent::__construct($context, $data); $this->_ioRead = $filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem\DirectoryList::ROOT); $this->_coreDate = $coreDate; $this->_directoryRead = $directoryRead->create(""); }
public function __construct(\Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\Module\ModuleList $moduleList, \Magento\Framework\App\Config\MutableScopeConfigInterface $scopeConfig, \Magento\Framework\UrlInterface $urlBuilder, \Magento\Framework\Session\SessionManagerInterface $session, \Wyomind\Core\Helper\Data $coreHelper, \Magento\Framework\Filesystem\Directory\ReadFactory $directoryRead, \Magento\Framework\Filesystem\File\ReadFactory $fileRead, \Magento\Framework\App\Filesystem\DirectoryList $directoryList, \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = []) { parent::__construct($context, $registry, $resource, $resourceCollection, $data); $this->_magentoVersion = $coreHelper->getMagentoVersion(); $this->_moduleList = $moduleList; $this->_scopeConfig = $scopeConfig; $this->_urlBuilder = $urlBuilder; $this->_cacheManager = $context->getCacheManager(); $this->_session = $session; $this->_coreHelper = $coreHelper; $root = $directoryList->getPath(\Magento\Framework\App\Filesystem\DirectoryList::ROOT); if (file_exists($root . "/vendor/wyomind/")) { $this->_directoryRead = $directoryRead->create($root . "/vendor/wyomind/"); } else { $this->_directoryRead = $directoryRead->create($root . "/app/code/Wyomind/"); } $this->_httpRead = $fileRead; $this->_directoryList = $directoryList; $this->_version = $this->_moduleList->getOne("Wyomind_Core")['setup_version']; $this->_refreshCache = false; $this->getValues(); foreach ($this->_values as $ext) { $this->checkActivation($ext); } if ($this->_refreshCache) { $this->_cacheManager->clean(['config']); } }
/** * Get an array of URNs * * @param OutputInterface $output * @return array */ private function getUrnDictionary(OutputInterface $output) { $files = $this->filesUtility->getXmlCatalogFiles('*.xml'); $files = array_merge($files, $this->filesUtility->getXmlCatalogFiles('*.xsd')); $urns = []; foreach ($files as $file) { $fileDir = dirname($file[0]); $fileName = basename($file[0]); $read = $this->readFactory->create($fileDir); $content = $read->readFile($fileName); $matches = []; preg_match_all('/schemaLocation="(urn\\:magento\\:[^"]*)"/i', $content, $matches); if (isset($matches[1])) { $urns = array_merge($urns, $matches[1]); } } $urns = array_unique($urns); $paths = []; foreach ($urns as $urn) { try { $paths[$urn] = $this->urnResolver->getRealPath($urn); } catch (\Exception $e) { // don't add unsupported element to array if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) { $output->writeln($e->getMessage()); } } } return $paths; }
protected function setUp() { $this->componentRegistrar = $this->getMock('Magento\\Framework\\Component\\ComponentRegistrar', [], [], '', false); $this->dirRead = $this->getMock('Magento\\Framework\\Filesystem\\Directory\\Read', [], [], '', false); $this->dirReadFactory = $this->getMock('Magento\\Framework\\Filesystem\\Directory\\ReadFactory', [], [], '', false); $this->dirReadFactory->expects($this->any())->method('create')->willReturn($this->dirRead); $this->themePackageInfo = new ThemePackageInfo($this->componentRegistrar, $this->dirReadFactory); }
/** * Create an instance of directory with read permissions * * @param string $directoryCode * @param string $driverCode * @return \Magento\Framework\Filesystem\Directory\ReadInterface */ public function getDirectoryRead($directoryCode, $driverCode = DriverPool::FILE) { $code = $directoryCode . '_' . $driverCode; if (!array_key_exists($code, $this->readInstances)) { $this->readInstances[$code] = $this->readFactory->create($this->getDirPath($directoryCode), $driverCode); } return $this->readInstances[$code]; }
/** * Minify template file * * @param string $file * @return void */ public function minify($file) { $dir = dirname($file); $fileName = basename($file); $content = preg_replace('#(?<!]]>)\\s+</#', '</', preg_replace('#((?:<\\?php\\s+(?!echo|print|if|elseif|else)[^\\?]*)\\?>)\\s+#', '$1 ', preg_replace('#(?<!' . implode('|', $this->inlineHtmlTags) . ')\\> \\<#', '><', preg_replace('#(?ix)(?>[^\\S ]\\s*|\\s{2,})(?=(?:(?:[^<]++|<(?!/?(?:textarea|pre|script)\\b))*+)' . '(?:<(?>textarea|pre|script)\\b|\\z))#', ' ', preg_replace('#(?<!:|\\\\|\'|")//(?!\\s*\\<\\!\\[)(?!\\s*]]\\>)[^\\n\\r]*#', '', preg_replace('#(?<!:)//[^\\n\\r]*(\\s\\?\\>)#', '$1', $this->readFactory->create($dir)->readFile($fileName))))))); if (!$this->htmlDirectory->isExist()) { $this->htmlDirectory->create(); } $this->htmlDirectory->writeFile($this->getRelativeGeneratedPath($file), rtrim($content)); }
protected function setUp() { $this->entityFactory = $this->getMockBuilder('Magento\\Framework\\Data\\Collection\\EntityFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock(); $this->themeConfigFactory = $this->getMockBuilder('Magento\\Framework\\Config\\ThemeFactory')->setMethods(['create'])->disableOriginalConstructor()->getMock(); $this->directory = $this->getMockBuilder('Magento\\Framework\\Filesystem\\Directory\\ReadInterface')->disableOriginalConstructor()->getMock(); $this->themePackageList = $this->getMock('\\Magento\\Framework\\View\\Design\\Theme\\ThemePackageList', [], [], '', false); $this->readDirFactory = $this->getMock('Magento\\Framework\\Filesystem\\Directory\\ReadFactory', [], [], '', false); $this->readDirFactory->expects($this->any())->method('create')->will($this->returnValue($this->directory)); $this->model = new Collection($this->entityFactory, $this->themeConfigFactory, $this->themePackageList, $this->readDirFactory); }
protected function setUp() { $this->themeDirectory = $this->getMock('Magento\\Framework\\Filesystem\\Directory\\Read', ['getAbsolutePath', 'search'], [], '', false); $this->pathPatternHelperMock = $this->getMockBuilder('Magento\\Framework\\View\\Helper\\PathPattern')->disableOriginalConstructor()->getMock(); $this->fileFactory = $this->getMock('Magento\\Framework\\View\\File\\Factory', [], [], '', false); $this->readDirFactory = $this->getMock('Magento\\Framework\\Filesystem\\Directory\\ReadFactory', [], [], '', false); $this->readDirFactory->expects($this->any())->method('create')->will($this->returnValue($this->themeDirectory)); $this->componentRegistrar = $this->getMockForAbstractClass('Magento\\Framework\\Component\\ComponentRegistrarInterface'); $this->model = new \Magento\Framework\View\File\Collector\Override\Base($this->fileFactory, $this->readDirFactory, $this->componentRegistrar, $this->pathPatternHelperMock, 'override'); }
/** * Get path of file after using fallback rules * * @param RuleInterface $fallbackRule * @param string $file * @param array $params * @return string|bool */ protected function resolveFile(RuleInterface $fallbackRule, $file, array $params = []) { foreach ($fallbackRule->getPatternDirs($params) as $dir) { $path = "{$dir}/{$file}"; $dirRead = $this->readFactory->create($dir); if ($dirRead->isExist($file)) { return $path; } } return false; }
/** * Initialize testable object */ public function setUp() { $this->htmlDirectory = $this->getMockBuilder('Magento\\Framework\\Filesystem\\Directory\\WriteInterface')->getMock(); $this->appDirectory = $this->getMockBuilder('Magento\\Framework\\Filesystem\\Directory\\ReadInterface')->getMock(); $filesystem = $this->getMockBuilder('Magento\\Framework\\Filesystem')->disableOriginalConstructor()->getMock(); $filesystem->expects($this->once())->method('getDirectoryWrite')->with(DirectoryList::TEMPLATE_MINIFICATION_DIR)->willReturn($this->htmlDirectory); /** @var \Magento\Framework\Filesystem $filesystem */ $this->readFactory = $this->getMock('Magento\\Framework\\Filesystem\\Directory\\ReadFactory', [], [], '', false); $this->readFactory->expects($this->any())->method('create')->willReturn($this->appDirectory); $this->object = new Minifier($filesystem, $this->readFactory); }
public function setup() { $this->themeDirectoryMock = $this->getMockBuilder('Magento\\Framework\\Filesystem\\Directory\\ReadInterface')->getMock(); $this->fileFactoryMock = $this->getMockBuilder('Magento\\Framework\\View\\File\\Factory')->disableOriginalConstructor()->getMock(); $this->themeMock = $this->getMockBuilder('Magento\\Framework\\View\\Design\\ThemeInterface')->getMock(); $this->themeMock->expects($this->once())->method('getFullPath')->will($this->returnValue($this->themePath)); $this->readDirFactory = $this->getMock('Magento\\Framework\\Filesystem\\Directory\\ReadFactory', [], [], '', false); $this->readDirFactory->expects($this->any())->method('create')->will($this->returnValue($this->themeDirectoryMock)); $this->componentRegistrar = $this->getMockForAbstractClass('Magento\\Framework\\Component\\ComponentRegistrarInterface'); $this->themeFileCollector = new Theme($this->fileFactoryMock, $this->readDirFactory, $this->componentRegistrar); }
/** * @param $filePath Absolute file path to CSV file */ public function setFile($filePath) { if (!file_exists($filePath)) { throw new FileNotFoundException(); } // Hacky but quick fix for https://github.com/cedricblondeau/magento2-module-catalog-import-command/issues/1 $pathInfo = pathinfo($filePath); $validate = $this->importModel->validateSource($this->csvSourceFactory->create(['file' => $pathInfo['basename'], 'directory' => $this->readFactory->create($pathInfo['dirname'])])); if (!$validate) { throw new \InvalidArgumentException(); } }
/** * @param bool $check */ protected function getContentStep($check = true) { $resultPath = 'adminhtml/path/to/file.xml'; $includeXmlContent = '<config><item id="1"><test/></item><item id="2"></item></config>'; $modulesDirectoryMock = $this->getMockBuilder('Magento\\Framework\\Filesystem\\Directory\\ReadInterface')->getMockForAbstractClass(); $this->readFactoryMock->expects($this->once())->method('create')->willReturn($modulesDirectoryMock); $this->moduleReaderMock->expects($this->once())->method('getModuleDir')->with('etc', 'Module_Name')->willReturn('path/in/application/module'); $modulesDirectoryMock->expects($this->once())->method('isExist')->with($resultPath)->willReturn($check); if ($check) { $modulesDirectoryMock->expects($this->once())->method('isFile')->with($resultPath)->willReturn($check); $modulesDirectoryMock->expects($this->once())->method('readFile')->with($resultPath)->willReturn($includeXmlContent); } }
/** * Initialize package name to full theme path map * * @return void * @throws \Zend_Json_Exception */ private function initializeMap() { $themePaths = $this->componentRegistrar->getPaths(ComponentRegistrar::THEME); /** @var \Magento\Theme\Model\Theme $theme */ foreach ($themePaths as $fullThemePath => $themeDir) { $themeDirRead = $this->readDirFactory->create($themeDir); if ($themeDirRead->isExist('composer.json')) { $rawData = \Zend_Json::decode($themeDirRead->readFile('composer.json')); if (isset($rawData['name'])) { $this->packageNameToFullPathMap[$rawData['name']] = $fullThemePath; } } } }
/** * @inheritdoc */ public function install() { $this->eavConfig->clear(); $importModel = $this->importModel; $importModel->setData(['entity' => 'catalog_product', 'behavior' => 'append', 'import_images_file_dir' => 'pub/media/catalog/product', Import::FIELD_NAME_VALIDATION_STRATEGY => ProcessingErrorAggregatorInterface::VALIDATION_STRATEGY_SKIP_ERRORS]); $source = $this->csvSourceFactory->create(['file' => 'fixtures/products.csv', 'directory' => $this->readFactory->create($this->componentRegistrar->getPath(ComponentRegistrar::MODULE, 'Magento_ConfigurableSampleData'))]); $currentPath = getcwd(); chdir(BP); $importModel->validateSource($source); $importModel->importSource(); chdir($currentPath); $this->eavConfig->clear(); $this->reindex(); }
/** * Initialize testable object */ protected function setUp() { $this->htmlDirectoryMock = $this->getMockBuilder(Filesystem\Directory\WriteInterface::class)->getMockForAbstractClass(); $this->appDirectoryMock = $this->getMockBuilder(ReadInterface::class)->getMockForAbstractClass(); $this->rootDirectoryMock = $this->getMockBuilder(ReadInterface::class)->getMockForAbstractClass(); $this->filesystemMock = $this->getMockBuilder(Filesystem::class)->disableOriginalConstructor()->getMock(); $this->readFactoryMock = $this->getMockBuilder(Filesystem\Directory\ReadFactory::class)->disableOriginalConstructor()->getMock(); $this->filesystemMock->expects($this->once())->method('getDirectoryWrite')->with(DirectoryList::TEMPLATE_MINIFICATION_DIR)->willReturn($this->htmlDirectoryMock); $this->filesystemMock->expects($this->any())->method('getDirectoryRead')->with(DirectoryList::ROOT, DriverPool::FILE)->willReturn($this->rootDirectoryMock); $this->rootDirectoryMock->expects($this->any())->method('getRelativePath')->willReturnCallback(function ($value) { return ltrim($value, '/'); }); $this->readFactoryMock->expects($this->any())->method('create')->willReturn($this->appDirectoryMock); $this->object = (new ObjectManager($this))->getObject(Minifier::class, ['filesystem' => $this->filesystemMock, 'readFactory' => $this->readFactoryMock]); }
/** * @param \Magento\Backend\App\Action\Context $context * @param \Magento\Framework\Model\Context $contextModel * @param \Magento\Framework\Registry $coreRegistry * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory * @param \Wyomind\Core\Helper\Data $coreHelper * @param \Wyomind\SimpleGoogleShopping\Helper\Data $sgsHelper * @param \Wyomind\SimpleGoogleShopping\Model\Feeds $sgsModel * @param \Magento\Framework\Model\Context $context_ * @param \Magento\Backend\Model\View\Result\ForwardFactory $resultForwardFactory * @param \Magento\Framework\Controller\Result\RawFactory $resultRawFactory * @param \Magento\Framework\Filesystem\Directory\ReadFactory $directoryRead * @param \Wyomind\SimpleGoogleShopping\Helper\Parser $parserHelper * @param \Magento\Eav\Api\AttributeRepositoryInterface $attributeRepository */ public function __construct(\Magento\Backend\App\Action\Context $context, \Magento\Framework\Model\Context $contextModel, \Magento\Framework\Registry $coreRegistry, \Magento\Framework\View\Result\PageFactory $resultPageFactory, \Wyomind\Core\Helper\Data $coreHelper, \Wyomind\SimpleGoogleShopping\Helper\Data $sgsHelper, \Wyomind\SimpleGoogleShopping\Model\Feeds $sgsModel, \Magento\Backend\Model\View\Result\ForwardFactory $resultForwardFactory, \Magento\Framework\Controller\Result\RawFactory $resultRawFactory, \Magento\Framework\Filesystem\Directory\ReadFactory $directoryRead, \Wyomind\SimpleGoogleShopping\Helper\Parser $parserHelper, \Magento\Eav\Api\AttributeRepositoryInterface $attributeRepository) { $this->coreRegistry = $coreRegistry; $this->resultPageFactory = $resultPageFactory; $this->coreHelper = $coreHelper; $this->cacheManager = $contextModel->getCacheManager(); $this->sgsHelper = $sgsHelper; $this->sgsModel = $sgsModel; $this->resultForwardFactory = $resultForwardFactory; $this->resultRedirectFactory = $context->getResultRedirectFactory(); $this->resultRawFactory = $resultRawFactory; $this->parserHelper = $parserHelper; $this->attributeRepository = $attributeRepository; $this->directoryRead = $directoryRead->create("app/code/Wyomind/SimpleGoogleShopping"); parent::__construct($context); }
/** * Retrieve files * * @param ThemeInterface $theme * @param string $filePath * @return \Magento\Framework\View\File[] */ public function getFiles(ThemeInterface $theme, $filePath) { $namespace = $module = '*'; $themePath = $theme->getFullPath(); if (empty($themePath)) { return []; } $themeAbsolutePath = $this->componentRegistrar->getPath(ComponentRegistrar::THEME, $themePath); if (!$themeAbsolutePath) { return []; } $themeDir = $this->readDirFactory->create($themeAbsolutePath); $searchPattern = "{$namespace}_{$module}/{$this->subDir}{$filePath}"; $files = $themeDir->search($searchPattern); $result = []; $pattern = "#(?<moduleName>[^/]+)/{$this->subDir}" . $this->pathPatternHelper->translatePatternFromGlob($filePath) . "\$#i"; foreach ($files as $file) { $filename = $themeDir->getAbsolutePath($file); if (!preg_match($pattern, $filename, $matches)) { continue; } $result[] = $this->fileFactory->create($filename, $matches['moduleName']); } return $result; }
public function testResolveNonexistentFile() { $this->readFactoryMock->expects($this->any())->method('create')->willReturn($this->directoryMock); $this->ruleMock->expects($this->once())->method('getPatternDirs')->willReturn(['some/dir']); $this->directoryMock->expects($this->once())->method('isExist')->willReturn(false); $this->assertFalse($this->object->resolve('type', 'file.ext', 'frontend', $this->getMockForTheme('magento_theme'), 'en_US', 'Magento_Module')); }
/** * Collect files in components * If $withContext is true, returns array of file objects with component context * * @param string $componentType * @param string $pattern * @param bool|false $withContext * @return array */ private function collect($componentType, $pattern, $withContext) { $files = []; foreach ($this->registrar->getPaths($componentType) as $componentName => $path) { $directoryRead = $this->readFactory->create($path); $foundFiles = $directoryRead->search($pattern); foreach ($foundFiles as $foundFile) { $foundFile = $directoryRead->getAbsolutePath($foundFile); if ($withContext) { $files[] = new ComponentFile($componentType, $componentName, $foundFile); } else { $files[] = $foundFile; } } } return $files; }
/** * Retrieve files * * @param ThemeInterface $theme * @param string $filePath * @return \Magento\Framework\View\File[] */ public function getFiles(ThemeInterface $theme, $filePath) { $list = $this->fileListFactory->create('Magento\\Framework\\Css\\PreProcessor\\File\\FileList\\Collator'); $files = $this->libraryDirectory->search($filePath); $list->add($this->createFiles($this->libraryDirectory, $theme, $files)); foreach ($theme->getInheritedThemes() as $currentTheme) { $themeFullPath = $currentTheme->getFullPath(); $path = $this->componentRegistrar->getPath(ComponentRegistrar::THEME, $themeFullPath); if (empty($path)) { continue; } $directoryRead = $this->readFactory->create($path); $foundFiles = $directoryRead->search("web/{$filePath}"); $list->replace($this->createFiles($directoryRead, $theme, $foundFiles)); } return $list->getAll(); }
/** * Find all theme-based email templates for a given template ID * * @param string $templateId * @return array[] */ public function getThemeTemplates($templateId) { $templates = []; $area = $this->getTemplateArea($templateId); $module = $this->getTemplateModule($templateId); $filename = $this->_getInfo($templateId, 'file'); foreach ($this->themePackages->getThemes() as $theme) { if ($theme->getArea() == $area) { $themeDir = $this->readDirFactory->create($theme->getPath()); $file = "{$module}/email/{$filename}"; if ($themeDir->isExist($file)) { $templates[] = ['value' => sprintf('%s/%s/%s', $templateId, $theme->getVendor(), $theme->getName()), 'label' => sprintf('%s (%s/%s)', $this->getTemplateLabel($templateId), $theme->getVendor(), $theme->getName()), 'group' => $this->getTemplateModule($templateId)]; } } } return $templates; }
/** * Create an instance of directory with write permissions * * @param string $code * @return \Magento\Framework\Filesystem\Directory\ReadInterface */ public function getDirectoryRead($code) { if (!array_key_exists($code, $this->readInstances)) { $config = $this->directoryList->getConfig($code); $this->readInstances[$code] = $this->readFactory->create($config, $this->driverFactory); } return $this->readInstances[$code]; }
/** * Return generated varnish.vcl configuration file * * @param string $vclTemplatePath * @return string * @api */ public function getVclFile($vclTemplatePath) { $moduleEtcPath = $this->reader->getModuleDir(Dir::MODULE_ETC_DIR, 'Magento_PageCache'); $configFilePath = $moduleEtcPath . '/' . $this->_scopeConfig->getValue($vclTemplatePath); $directoryRead = $this->readFactory->create($moduleEtcPath); $configFilePath = $directoryRead->getRelativePath($configFilePath); $data = $directoryRead->readFile($configFilePath); return strtr($data, $this->_getReplacements()); }
/** * Collect files * * @param string|null $searchPattern * @return array * @throws \Exception */ public function collectFiles($searchPattern = null) { $result = []; if ($searchPattern === null) { $searchPattern = $this->searchPattern; } if ($searchPattern === null) { throw new \Exception('Search pattern cannot be empty.'); } $files = $this->collectorAggregated->getFiles($this->design->getDesignTheme(), $searchPattern); foreach ($files as $file) { $fullFileName = $file->getFileName(); $fileDir = dirname($fullFileName); $fileName = basename($fullFileName); $dirRead = $this->readFactory->create($fileDir); $result[$fullFileName] = $dirRead->readFile($fileName); } return $result; }
/** * Return configuration model for the theme * * @param ThemePackage $themePackage * @return \Magento\Framework\Config\Theme */ protected function _getConfigModel($themePackage) { $themeDir = $this->dirReadFactory->create($themePackage->getPath()); if ($themeDir->isExist('theme.xml')) { $configContent = $themeDir->readFile('theme.xml'); } else { $configContent = ''; } return $this->themeConfigFactory->create(['configContent' => $configContent]); }
/** * Get content of include file (in adminhtml area) * * @param string $includePath * @return string * @throws LocalizedException */ protected function getContent($includePath) { // <include path="Magento_Payment::my_payment.xml" /> list($moduleName, $filename) = explode('::', $includePath); $path = 'adminhtml/' . $filename; $directoryRead = $this->readFactory->create($this->moduleReader->getModuleDir(Dir::MODULE_ETC_DIR, $moduleName)); if ($directoryRead->isExist($path) && $directoryRead->isFile($path)) { return $directoryRead->readFile($path); } throw new LocalizedException(__('The file "%1" does not exist', $path)); }
/** * Creates a chain for pre-processing * * @param LocalInterface $asset * @param string|bool $dir * @param string|bool $path * @return PreProcessor\Chain */ private function createChain(LocalInterface $asset, $dir, $path) { if ($path) { $origContent = $this->readFactory->create($dir)->readFile($path); $origContentType = $this->getContentType($path); } else { $origContent = ''; $origContentType = $asset->getContentType(); } $chain = $this->chainFactory->create(['asset' => $asset, 'origContent' => $origContent, 'origContentType' => $origContentType, 'origAssetPath' => $dir . '/' . $path]); return $chain; }