Exemplo n.º 1
0
 /**
  * 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);
     }
 }
Exemplo n.º 2
0
 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));
 }
Exemplo n.º 3
0
 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));
 }
Exemplo n.º 4
0
 /**
  * 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;
 }
Exemplo n.º 5
0
 /**
  * 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();
 }
Exemplo n.º 6
0
 /**
  * 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 '';
 }
Exemplo n.º 7
0
 /**
  * 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]);
 }
Exemplo n.º 8
0
 /**
  * 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)));
 }