本文整理汇总了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);
}
示例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();
}
示例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);
}
}
示例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;
}
示例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;
}
示例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();
}
示例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);
}
}
示例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;
}
示例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);
}
示例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;
}