本文整理汇总了PHP中Magento\Framework\Filesystem\Directory\Read::readFile方法的典型用法代码示例。如果您正苦于以下问题:PHP Read::readFile方法的具体用法?PHP Read::readFile怎么用?PHP Read::readFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Filesystem\Directory\Read
的用法示例。
在下文中一共展示了Read::readFile方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: minifyFile
/**
* 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);
}
}
示例2: testReadFile
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));
}
示例3: testReadFileCustomProtocol
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));
}
示例4: loadLocalPackage
/**
* 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;
}
示例5: getCountryParams
/**
* 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();
}
示例6: _loadMap
/**
* 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 '';
}
示例7: _getConfigModel
/**
* 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]);
}
示例8: _getConfigModel
/**
* 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)));
}