本文整理汇总了PHP中Magento\Framework\Filesystem\Directory\WriteInterface::readFile方法的典型用法代码示例。如果您正苦于以下问题:PHP WriteInterface::readFile方法的具体用法?PHP WriteInterface::readFile怎么用?PHP WriteInterface::readFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Filesystem\Directory\WriteInterface
的用法示例。
在下文中一共展示了WriteInterface::readFile方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: load
/**
* {@inheritdoc}
*/
public function load()
{
try {
return $this->directory->readFile($this->fileName);
} catch (\Magento\Framework\Exception\FileSystemException $e) {
throw new \UnexpectedValueException('Unable to retrieve deployment version of static files from the file system.', 0, $e);
}
}
示例2: isProcessLocked
/**
* Check whether generation process has already locked
*
* @return bool
* @throws FileSystemException
*/
private function isProcessLocked()
{
if ($this->tmpDirectory->isExist($this->lockFilePath)) {
$lockTime = (int) $this->tmpDirectory->readFile($this->lockFilePath);
if (time() - $lockTime >= self::MAX_LOCK_TIME) {
$this->tmpDirectory->delete($this->lockFilePath);
return false;
}
return true;
}
return false;
}
示例3: getAddressInfo
/**
* Get list of IP addresses effective for maintenance mode
*
* @return string[]
*/
public function getAddressInfo()
{
if ($this->flagDir->isExist(self::IP_FILENAME)) {
$temp = $this->flagDir->readFile(self::IP_FILENAME);
return explode(',', trim($temp));
} else {
return [];
}
}
示例4: execute
/**
* Download sample file action
*
* @return \Magento\Framework\Controller\Result\Raw
*/
public function execute()
{
$fileName = $this->getRequest()->getParam('filename') . '.csv';
$filePath = self::SAMPLE_FILES_DIRECTORY . $fileName;
if (!$this->fileDirectory->isFile($filePath)) {
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
$this->messageManager->addError(__('There is no sample file for this entity.'));
$resultRedirect = $this->resultRedirectFactory->create();
$resultRedirect->setPath('*/import');
return $resultRedirect;
}
$fileSize = isset($this->fileDirectory->stat($filePath)['size']) ? $this->fileDirectory->stat($filePath)['size'] : null;
$this->fileFactory->create($fileName, null, DirectoryList::VAR_DIR, 'application/octet-stream', $fileSize);
/** @var \Magento\Framework\Controller\Result\Raw $resultRaw */
$resultRaw = $this->resultRawFactory->create();
$resultRaw->setContents($this->fileDirectory->readFile($filePath));
return $resultRaw;
}
示例5: isProcessLocked
/**
* Check whether generation process has already locked
*
* @return bool
*/
protected function isProcessLocked()
{
$lockFilePath = $this->config->getLessMaterializationRelativePath() . '/' . self::LOCK_FILE;
if ($this->tmpDirectory->isExist($lockFilePath)) {
$lockTime = time() - (int) $this->tmpDirectory->readFile($lockFilePath);
if ($lockTime >= self::MAX_LOCK_TIME) {
$this->tmpDirectory->delete($lockFilePath);
return false;
}
return true;
}
return false;
}
示例6: writeMessageToFile
/**
* Write status information to the file.
*
* @param string $text
* @param string $filePath
* @return $this
* @throws \RuntimeException
*/
protected function writeMessageToFile($text, $filePath)
{
$isNewFile = !$this->varReaderWriter->isExist($filePath);
if (!$isNewFile && $this->varReaderWriter->readFile($filePath)) {
$text = "\n{$text}";
}
try {
$this->varReaderWriter->writeFile($filePath, $text, 'a+');
} catch (FileSystemException $e) {
throw new \RuntimeException(sprintf('Cannot add status information to "%s"', $filePath));
}
if ($isNewFile) {
chmod($filePath, 0777);
}
return $this;
}
示例7: fetchAndSave
/**
* Goes to specified host/path and fetches reports from there.
* Save reports to database.
*
* @param \Magento\Framework\Filesystem\Io\Sftp $connection
* @return int Number of report rows that were fetched and saved successfully
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function fetchAndSave(\Magento\Framework\Filesystem\Io\Sftp $connection)
{
$fetched = 0;
$listing = $this->_filterReportsList($connection->rawls());
foreach ($listing as $filename => $attributes) {
$localCsv = 'PayPal_STL_' . uniqid(\Magento\Framework\Math\Random::getRandomNumber()) . time() . '.csv';
if ($connection->read($filename, $this->_tmpDirectory->getAbsolutePath($localCsv))) {
if (!$this->_tmpDirectory->isWritable($localCsv)) {
throw new \Magento\Framework\Exception\LocalizedException(__('We cannot create a target file for reading reports.'));
}
$encoded = $this->_tmpDirectory->readFile($localCsv);
$csvFormat = 'new';
$fileEncoding = mb_detect_encoding($encoded);
if (self::FILES_OUT_CHARSET != $fileEncoding) {
$decoded = @iconv($fileEncoding, self::FILES_OUT_CHARSET . '//IGNORE', $encoded);
$this->_tmpDirectory->writeFile($localCsv, $decoded);
$csvFormat = 'old';
}
// Set last modified date, this value will be overwritten during parsing
if (isset($attributes['mtime'])) {
$date = new \DateTime();
$lastModified = $date->setTimestamp($attributes['mtime']);
$this->setReportLastModified($lastModified->format('Y-m-d H:i:s'));
}
$this->setReportDate($this->_fileNameToDate($filename))->setFilename($filename)->parseCsv($localCsv, $csvFormat);
if ($this->getAccountId()) {
$this->save();
}
if ($this->_dataSaveAllowed) {
$fetched += count($this->_rows);
}
// clean object and remove parsed file
$this->unsetData();
$this->_tmpDirectory->delete($localCsv);
}
}
return $fetched;
}
示例8: _getFileContainerContent
/**
* Retrieve file content from file container array
*
* @param array $fileData
* @return string
*/
protected function _getFileContainerContent(array $fileData)
{
return $this->_directory->readFile('export/' . $fileData['value']);
}
示例9: getVclFile
/**
* Return generated varnish.vcl configuration file
*
* @param string $vclTemplatePath
* @return string
* @api
*/
public function getVclFile($vclTemplatePath)
{
$data = $this->_modulesDirectory->readFile($this->_scopeConfig->getValue($vclTemplatePath));
return strtr($data, $this->_getReplacements());
}
示例10: get
/**
* Gets contents of the log
*
* @return array
*/
public function get()
{
$fileContents = explode(PHP_EOL, $this->directory->readFile($this->logFile));
return $fileContents;
}
示例11: getReportOutput
/**
* Get report file output
*
* @param string $filename
* @return string
*/
public function getReportOutput($filename)
{
return $this->varDirectory->readFile($this->getFilePath($filename));
}
示例12: getVclFile
/**
* Return generated varnish.vcl configuration file
*
* @return string
*/
public function getVclFile()
{
$data = $this->_modulesDirectory->readFile($this->_scopeConfig->getValue(self::VARNISH_CONFIGURATION_PATH));
return strtr($data, $this->_getReplacements());
}