11
11
namespace Magento \Sitemap \Block \Adminhtml \Grid \Renderer ;
12
12
13
13
use Magento \Framework \App \Filesystem \DirectoryList ;
14
+ use Magento \Config \Model \Config \Reader \Source \Deployed \DocumentRoot ;
15
+ use Magento \Framework \App \ObjectManager ;
14
16
15
17
class Link extends \Magento \Backend \Block \Widget \Grid \Column \Renderer \AbstractRenderer
16
18
{
@@ -24,6 +26,11 @@ class Link extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRe
24
26
*/
25
27
protected $ _sitemapFactory ;
26
28
29
+ /**
30
+ * @var \Magento\Config\Model\Config\Reader\Source\Deployed\DocumentRoot
31
+ */
32
+ protected $ documentRoot ;
33
+
27
34
/**
28
35
* @param \Magento\Backend\Block\Context $context
29
36
* @param \Magento\Sitemap\Model\SitemapFactory $sitemapFactory
@@ -34,10 +41,13 @@ public function __construct(
34
41
\Magento \Backend \Block \Context $ context ,
35
42
\Magento \Sitemap \Model \SitemapFactory $ sitemapFactory ,
36
43
\Magento \Framework \Filesystem $ filesystem ,
44
+ \Magento \Config \Model \Config \Reader \Source \Deployed \DocumentRoot $ documentRoot = null ,
37
45
array $ data = []
38
46
) {
39
47
$ this ->_sitemapFactory = $ sitemapFactory ;
40
48
$ this ->_filesystem = $ filesystem ;
49
+ $ this ->documentRoot = $ documentRoot ?: ObjectManager::getInstance ()->get (DocumentRoot::class);
50
+
41
51
parent ::__construct ($ context , $ data );
42
52
}
43
53
@@ -54,7 +64,8 @@ public function render(\Magento\Framework\DataObject $row)
54
64
$ url = $ this ->escapeHtml ($ sitemap ->getSitemapUrl ($ row ->getSitemapPath (), $ row ->getSitemapFilename ()));
55
65
56
66
$ 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 );
58
69
if ($ directory ->isFile ($ fileName )) {
59
70
return sprintf ('<a href="%1$s">%1$s</a> ' , $ url );
60
71
}
0 commit comments