/** * Get path to minified file for specified original file * * @param string $originalFile path to original file relative to pub/view_cache * @param string $targetFile path relative to pub/view_cache * @return void */ public function minifyFile($originalFile, $targetFile) { if ($this->_isUpdateNeeded($targetFile)) { $content = $this->rootDirectory->readFile($originalFile); $content = $this->adapter->minify($content); $this->pubViewCacheDir->writeFile($targetFile, $content); } }
public function testReadFile() { $path = 'filepath'; $flag = 'flag'; $context = 'context'; $contents = 'contents'; $this->driver->expects($this->once())->method('getAbsolutePath')->with($this->path, $path)->will($this->returnValue($path)); $this->driver->expects($this->once())->method('fileGetContents')->with($path, $flag, $context)->will($this->returnValue($contents)); $this->assertEquals($contents, $this->read->readFile($path, $flag, $context)); }
public function testReadFileCustomProtocol() { $path = 'filepath'; $flag = 'flag'; $context = 'context'; $protocol = 'ftp'; $contents = 'contents'; $fileMock = $this->getMock('Magento\\Framework\\Filesystem\\File\\Read', [], [], '', false); $fileMock->expects($this->once())->method('readAll')->with($flag, $context)->will($this->returnValue($contents)); $this->driver->expects($this->once())->method('getAbsolutePath')->with($this->path, $path, $protocol)->will($this->returnValue($path)); $this->driver->expects($this->never())->method('fileGetContents'); $this->fileFactory->expects($this->once())->method('create')->with($path, $protocol, $this->driver)->will($this->returnValue($fileMock)); $this->assertEquals($contents, $this->read->readFile($path, $flag, $context, $protocol)); }
/** * Load local package data array * * @param string $packageName without extension * @return array|boolean */ public function loadLocalPackage($packageName) { $xmlFile = sprintf('connect/%.xml', $packageName); $serFile = sprintf('connect/%.ser', $packageName); if ($this->readDirectory->isFile($xmlFile) && $this->readDirectory->isReadable($xmlFile)) { $xml = simplexml_load_string($this->readDirectory->readFile($xmlFile)); $data = $this->_xmlConverter->xmlToAssoc($xml); if (!empty($data)) { return $data; } } if ($this->readDirectory->isFile($serFile) && $this->readDirectory->isReadable($xmlFile)) { $data = unserialize($this->readDirectory->readFile($serFile)); if (!empty($data)) { return $data; } } return false; }
/** * Get Country Params by Country Code * * @param string $countryCode * @return \Magento\Framework\Object * * @see $countryCode ISO 3166 Codes (Countries) A2 */ protected function getCountryParams($countryCode) { if (empty($this->_countryParams)) { $etcPath = $this->_configReader->getModuleDir('etc', 'Magento_Dhl'); $countriesXmlPath = $this->modulesDirectory->getRelativePath($etcPath . '/countries.xml'); $countriesXml = $this->modulesDirectory->readFile($countriesXmlPath); $this->_countryParams = $this->_xmlElFactory->create(array('data' => $countriesXml)); } if (isset($this->_countryParams->{$countryCode})) { $countryParams = new \Magento\Framework\Object($this->_countryParams->{$countryCode}->asArray()); } return isset($countryParams) ? $countryParams : new \Magento\Framework\Object(); }
/** * Load aliases to classes map from file * * @param string $pathToMapFile * @return string */ protected function _loadMap($pathToMapFile) { if ($this->_directory->isFile($pathToMapFile)) { return $this->_directory->readFile($pathToMapFile); } return ''; }
/** * Return configuration model for themes * * @param string $configPath * @return \Magento\Framework\Config\Theme */ protected function _getConfigModel($configPath) { $relativeConfigPath = $this->_directory->getRelativePath($configPath); $configContent = $this->_directory->isExist($relativeConfigPath) ? $this->_directory->readFile($relativeConfigPath) : null; return $this->themeConfigFactory->create(['configContent' => $configContent]); }
/** * Return configuration model for themes * * @param string $configPath * @return \Magento\Framework\Config\Theme */ protected function _getConfigModel($configPath) { return new \Magento\Framework\Config\Theme($this->_directory->readFile($this->_directory->getRelativePath($configPath))); }