コード例 #1
0
 /**
  * @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);
 }
コード例 #2
0
ファイル: Robots.php プロジェクト: shabbirvividads/magento2
 /**
  * Check and process robots file
  *
  * @return $this
  */
 public function afterSave()
 {
     if ($this->getValue()) {
         $this->_directory->writeFile($this->_file, $this->getValue());
     }
     return parent::afterSave();
 }
コード例 #3
0
ファイル: Lite.php プロジェクト: Mohitsahu123/mtf
 /**
  * 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);
     }
 }
コード例 #4
0
 /**
  * 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;
 }
コード例 #5
0
ファイル: Config.php プロジェクト: aiesh/magento2
 /**
  * @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;
 }
コード例 #6
0
ファイル: Robots.php プロジェクト: aiesh/magento2
 /**
  * Check and process robots file
  *
  * @return $this
  */
 protected function _afterSave()
 {
     if ($this->getValue()) {
         $this->_directory->writeFile($this->_file, $this->getValue());
     }
     return parent::_afterSave();
 }
コード例 #7
0
 /**
  * @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);
     }
 }
コード例 #8
0
 /**
  * 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;
 }
コード例 #9
0
ファイル: Sitemap.php プロジェクト: nja78/magento2
 /**
  * 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);
 }
コード例 #10
0
ファイル: Extension.php プロジェクト: Atlis/docker-magento2
 /**
  * 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;
 }