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


PHP Write::writeFile方法代码示例

本文整理汇总了PHP中Magento\Framework\Filesystem\Directory\Write::writeFile方法的典型用法代码示例。如果您正苦于以下问题:PHP Write::writeFile方法的具体用法?PHP Write::writeFile怎么用?PHP Write::writeFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Magento\Framework\Filesystem\Directory\Write的用法示例。


在下文中一共展示了Write::writeFile方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: execute

 /**
  * @param \Magento\Framework\Event\Observer $observer
  */
 public function execute(Observer $observer)
 {
     $value = $this->_helper->getRobotsConfig('content');
     $this->_directory->writeFile($this->_fileRobot, $value);
     $value = $this->_helper->getHtaccessConfig('content');
     $this->_directory->writeFile($this->_fileHtaccess, $value);
 }
开发者ID:mageplaza,项目名称:magento-2-seo-extension,代码行数:10,代码来源:SeoObserver.php

示例2: afterSave

 /**
  * Check and process robots file
  *
  * @return $this
  */
 public function afterSave()
 {
     if ($this->getValue()) {
         $this->_directory->writeFile($this->_file, $this->getValue());
     }
     return parent::afterSave();
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:12,代码来源:Robots.php

示例3: 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);
     }
 }
开发者ID:Mohitsahu123,项目名称:mtf,代码行数:15,代码来源:Lite.php

示例4: _saveFatalErrorReport

 /**
  * Log information about fatal error.
  *
  * @param string $reportData
  * @return string
  */
 protected function _saveFatalErrorReport($reportData)
 {
     $this->directoryWrite->create('report/api');
     $reportId = abs(intval(microtime(true) * rand(100, 1000)));
     $this->directoryWrite->writeFile('report/api/' . $reportId, serialize($reportData));
     return $reportId;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:13,代码来源:ErrorProcessor.php

示例5: replaceTmpEncryptKey

 /**
  * @param string $key
  * @return $this
  */
 public function replaceTmpEncryptKey($key)
 {
     $localXml = $this->_configDirectory->readFile($this->_localConfigFile);
     $localXml = str_replace(self::TMP_ENCRYPT_KEY_VALUE, $key, $localXml);
     $this->_configDirectory->writeFile($this->_localConfigFile, $localXml);
     return $this;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:11,代码来源:Config.php

示例6: _afterSave

 /**
  * Check and process robots file
  *
  * @return $this
  */
 protected function _afterSave()
 {
     if ($this->getValue()) {
         $this->_directory->writeFile($this->_file, $this->getValue());
     }
     return parent::_afterSave();
 }
开发者ID:aiesh,项目名称:magento2,代码行数:12,代码来源:Robots.php

示例7: handleEnable

 /**
  * @param \Magento\Framework\Filesystem\Directory\Write $flagDir
  * @param OutputInterface $output
  * @param null $onOption
  */
 protected function handleEnable(\Magento\Framework\Filesystem\Directory\Write $flagDir, OutputInterface $output, $onOption = null)
 {
     $flagDir->touch(MaintenanceMode::FLAG_FILENAME);
     $output->writeln(self::ENABLED_MESSAGE);
     if (!is_null($onOption)) {
         // Write IPs to exclusion file
         $flagDir->writeFile(MaintenanceMode::IP_FILENAME, $onOption);
         $output->writeln(self::WROTE_IP_MESSAGE);
     }
 }
开发者ID:brentwpeterson,项目名称:n98-magerun2,代码行数:15,代码来源:MaintenanceCommand.php

示例8: savePackagesForUpdateToCache

 /**
  * Save composer packages available for update to cache
  *
  * @param array $availableVersions
  * @return bool|string
  */
 private function savePackagesForUpdateToCache($availableVersions)
 {
     $syncInfo = [];
     $syncInfo['lastSyncDate'] = $this->getDateTime()->gmtTimestamp();
     $syncInfo['packages'] = $availableVersions;
     $data = json_encode($syncInfo, JSON_UNESCAPED_SLASHES);
     try {
         $this->directory->writeFile($this->pathToCacheFile, $data);
     } catch (\Magento\Framework\Exception\FileSystemException $e) {
         return false;
     }
     return $data;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:19,代码来源:UpdatePackagesCache.php

示例9: _addSitemapToRobotsTxt

 /**
  * Add sitemap file to robots.txt
  *
  * @param string $sitemapFileName
  * @return void
  */
 protected function _addSitemapToRobotsTxt($sitemapFileName)
 {
     $robotsSitemapLine = 'Sitemap: ' . $this->getSitemapUrl($this->getSitemapPath(), $sitemapFileName);
     $filename = 'robots.txt';
     $content = '';
     if ($this->_directory->isExist($filename)) {
         $content = $this->_directory->readFile($filename);
     }
     if (strpos($content, $robotsSitemapLine) === false) {
         if (!empty($content)) {
             $content .= $this->_findNewLinesDelimiter($content);
         }
         $content .= $robotsSitemapLine;
     }
     $this->_directory->writeFile($filename, $content);
 }
开发者ID:nja78,项目名称:magento2,代码行数:22,代码来源:Sitemap.php

示例10: savePackage

 /**
  * Save package file to var/connect.
  *
  * @return boolean
  */
 public function savePackage()
 {
     if ($this->getData('file_name') != '') {
         $fileName = $this->getData('file_name');
         $this->unsetData('file_name');
     } else {
         $fileName = $this->getName();
     }
     if (!preg_match('/^[a-z0-9]+[a-z0-9\\-\\_\\.]*([\\/\\\\]{1}[a-z0-9]+[a-z0-9\\-\\_\\.]*)*$/i', $fileName)) {
         return false;
     }
     if (!$this->getPackageXml()) {
         $this->generatePackageXml();
     }
     if (!$this->getPackageXml()) {
         return false;
     }
     try {
         //            $path = $this->writeDirectory->getAbsolutePath();
         $this->writeDirectory->writeFile(sprintf('connect/%s', 'package.xml'), $this->getPackageXml());
         $this->unsPackageXml();
         $this->unsTargets();
         $xml = $this->_convertArray->assocToXml($this->getData());
         $xml = new \Magento\Framework\Simplexml\Element($xml->asXML());
         // prepare dir to save
         $parts = explode('/', $fileName);
         array_pop($parts);
         $directoryPath = implode('/', $parts);
         if (!empty($directoryPath)) {
             $this->writeDirectory->create(sprintf('connect/%s', $directoryPath));
         }
         $this->writeDirectory->writeFile(sprintf('connect/%s.xml', $fileName), $xml->asNiceXml());
     } catch (\Magento\Framework\Filesystem\FilesystemException $e) {
         $this->logger->addStreamLog(\Magento\Framework\Logger::LOGGER_EXCEPTION);
         $this->logger->log($e->getMessage());
         return false;
     }
     return true;
 }
开发者ID:Atlis,项目名称:docker-magento2,代码行数:44,代码来源:Extension.php


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