コード例 #1
0
ファイル: Io.php プロジェクト: IlyaGluschenko/test001
 /**
  * @param string $fileName
  * @param string $content
  * @throws FileSystemException
  * @return bool
  */
 public function writeResultFile($fileName, $content)
 {
     /**
      * Rename is atomic on *nix systems, while file_put_contents is not. Writing to a
      * temporary file whose name is process-unique and renaming to the real location helps
      * avoid race conditions. Race condition can occur if the compiler has not been run, when
      * multiple processes are attempting to access the generated file simultaneously.
      */
     $content = "<?php\n" . $content;
     $tmpFile = $fileName . "." . getmypid();
     $this->filesystemDriver->filePutContents($tmpFile, $content);
     try {
         $success = $this->filesystemDriver->rename($tmpFile, $fileName);
     } catch (FileSystemException $e) {
         if (!$this->fileExists($fileName)) {
             throw $e;
         } else {
             /**
              * Due to race conditions, file may have already been written, causing rename to fail. As long as
              * the file exists, everything is okay.
              */
             $success = true;
         }
     }
     return $success;
 }
コード例 #2
0
ファイル: FileManager.php プロジェクト: Doability/magento2dev
 /**
  * @param string $content
  * @return void
  */
 public function updateTranslationFileContent($content)
 {
     $translationDir = $this->directoryList->getPath(DirectoryList::STATIC_VIEW) . \DIRECTORY_SEPARATOR . $this->assetRepo->getStaticViewFileContext()->getPath();
     if (!$this->driverFile->isExists($this->getTranslationFileFullPath())) {
         $this->driverFile->createDirectory($translationDir);
     }
     $this->driverFile->filePutContents($this->getTranslationFileFullPath(), $content);
 }
コード例 #3
0
 /**
  * @param string $content
  * @return void
  */
 public function updateTranslationFileContent($content)
 {
     $translationDir = $this->directoryList->getPath(DirectoryList::STATIC_VIEW) . \DIRECTORY_SEPARATOR . $this->assetRepo->getStaticViewFileContext()->getPath();
     if (!$this->driverFile->isExists($this->getTranslationFileFullPath())) {
         $this->driverFile->createDirectory($translationDir, \Magento\Framework\Filesystem\Driver\File::WRITEABLE_DIRECTORY_MODE);
     }
     $this->driverFile->filePutContents($this->getTranslationFileFullPath(), $content);
 }
コード例 #4
0
 /**
  * {@inheritdoc}
  */
 public function handle(array $record)
 {
     if (!$this->isHandling($record)) {
         return false;
     }
     $logFile = $this->config->getOption('log_file');
     $record['formatted'] = $this->getFormatter()->format($record);
     if ($logFile) {
         $filePath = $this->getFilePath($logFile);
         $this->file->filePutContents($filePath, $record['formatted'] . PHP_EOL, FILE_APPEND);
     }
     return false === $this->bubble;
 }
コード例 #5
0
 /**
  * @param string $fileName
  * @param string $content
  * @return bool
  */
 public function writeResultFile($fileName, $content)
 {
     $content = "<?php\n" . $content;
     return $this->filesystemDriver->filePutContents($fileName, $content);
 }