本文整理汇总了PHP中Magento\Framework\Filesystem\Directory\Write::renameFile方法的典型用法代码示例。如果您正苦于以下问题:PHP Write::renameFile方法的具体用法?PHP Write::renameFile怎么用?PHP Write::renameFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Filesystem\Directory\Write
的用法示例。
在下文中一共展示了Write::renameFile方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generateXml
/**
* Generate XML file
*
* @see http://www.sitemaps.org/protocol.html
*
* @return $this
*/
public function generateXml()
{
$this->_initSitemapItems();
/** @var $sitemapItem \Magento\Framework\Object */
foreach ($this->_sitemapItems as $sitemapItem) {
$changefreq = $sitemapItem->getChangefreq();
$priority = $sitemapItem->getPriority();
foreach ($sitemapItem->getCollection() as $item) {
$xml = $this->_getSitemapRow($item->getUrl(), $item->getUpdatedAt(), $changefreq, $priority, $item->getImages());
if ($this->_isSplitRequired($xml) && $this->_sitemapIncrement > 0) {
$this->_finalizeSitemap();
}
if (!$this->_fileSize) {
$this->_createSitemap();
}
$this->_writeSitemapRow($xml);
// Increase counters
$this->_lineCount++;
$this->_fileSize += strlen($xml);
}
}
$this->_finalizeSitemap();
if ($this->_sitemapIncrement == 1) {
// In case when only one increment file was created use it as default sitemap
$path = rtrim($this->getSitemapPath(), '/') . '/' . $this->_getCurrentSitemapFilename($this->_sitemapIncrement);
$destination = rtrim($this->getSitemapPath(), '/') . '/' . $this->getSitemapFilename();
$this->_directory->renameFile($path, $destination);
} else {
// Otherwise create index file with list of generated sitemaps
$this->_createSitemapIndex();
}
// Push sitemap to robots.txt
if ($this->_isEnabledSubmissionRobots()) {
$this->_addSitemapToRobotsTxt($this->getSitemapFilename());
}
$this->setSitemapTime($this->_dateModel->gmtDate('Y-m-d H:i:s'));
$this->save();
return $this;
}