Skip to content

Commit b97281b

Browse files
fix sitemap link renderer
1 parent d570fcd commit b97281b

File tree

1 file changed

+12
-1
lines changed
  • app/code/Magento/Sitemap/Block/Adminhtml/Grid/Renderer

1 file changed

+12
-1
lines changed

app/code/Magento/Sitemap/Block/Adminhtml/Grid/Renderer/Link.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
namespace Magento\Sitemap\Block\Adminhtml\Grid\Renderer;
1212

1313
use Magento\Framework\App\Filesystem\DirectoryList;
14+
use Magento\Config\Model\Config\Reader\Source\Deployed\DocumentRoot;
15+
use Magento\Framework\App\ObjectManager;
1416

1517
class Link extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer
1618
{
@@ -24,6 +26,11 @@ class Link extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRe
2426
*/
2527
protected $_sitemapFactory;
2628

29+
/**
30+
* @var \Magento\Config\Model\Config\Reader\Source\Deployed\DocumentRoot
31+
*/
32+
protected $documentRoot;
33+
2734
/**
2835
* @param \Magento\Backend\Block\Context $context
2936
* @param \Magento\Sitemap\Model\SitemapFactory $sitemapFactory
@@ -34,10 +41,13 @@ public function __construct(
3441
\Magento\Backend\Block\Context $context,
3542
\Magento\Sitemap\Model\SitemapFactory $sitemapFactory,
3643
\Magento\Framework\Filesystem $filesystem,
44+
\Magento\Config\Model\Config\Reader\Source\Deployed\DocumentRoot $documentRoot = null,
3745
array $data = []
3846
) {
3947
$this->_sitemapFactory = $sitemapFactory;
4048
$this->_filesystem = $filesystem;
49+
$this->documentRoot = $documentRoot ?: ObjectManager::getInstance()->get(DocumentRoot::class);
50+
4151
parent::__construct($context, $data);
4252
}
4353

@@ -54,7 +64,8 @@ public function render(\Magento\Framework\DataObject $row)
5464
$url = $this->escapeHtml($sitemap->getSitemapUrl($row->getSitemapPath(), $row->getSitemapFilename()));
5565

5666
$fileName = preg_replace('/^\//', '', $row->getSitemapPath() . $row->getSitemapFilename());
57-
$directory = $this->_filesystem->getDirectoryRead(DirectoryList::ROOT);
67+
$documentRootPath = $this->documentRoot->getPath();
68+
$directory = $this->_filesystem->getDirectoryRead($documentRootPath);
5869
if ($directory->isFile($fileName)) {
5970
return sprintf('<a href="%1$s">%1$s</a>', $url);
6071
}

0 commit comments

Comments
 (0)