当前位置: 首页>>代码示例>>PHP>>正文


PHP WriteInterface::readFile方法代码示例

本文整理汇总了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);
     }
 }
开发者ID:IlyaGluschenko,项目名称:test001,代码行数:11,代码来源:File.php

示例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;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:18,代码来源:LockerProcess.php

示例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 [];
     }
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:14,代码来源:MaintenanceMode.php

示例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;
 }
开发者ID:nja78,项目名称:magento2,代码行数:23,代码来源:Download.php

示例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;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:18,代码来源:FileGenerator.php

示例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;
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:24,代码来源:Status.php

示例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;
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:46,代码来源:Settlement.php

示例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']);
 }
开发者ID:nja78,项目名称:magento2,代码行数:10,代码来源:Extended.php

示例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());
 }
开发者ID:nja78,项目名称:magento2,代码行数:12,代码来源:Config.php

示例10: get

 /**
  * Gets contents of the log
  *
  * @return array
  */
 public function get()
 {
     $fileContents = explode(PHP_EOL, $this->directory->readFile($this->logFile));
     return $fileContents;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:10,代码来源:WebLogger.php

示例11: getReportOutput

 /**
  * Get report file output
  *
  * @param string $filename
  * @return string
  */
 public function getReportOutput($filename)
 {
     return $this->varDirectory->readFile($this->getFilePath($filename));
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:10,代码来源:Report.php

示例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());
 }
开发者ID:aiesh,项目名称:magento2,代码行数:10,代码来源:Config.php


注:本文中的Magento\Framework\Filesystem\Directory\WriteInterface::readFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。