3
3
* Copyright © Magento, Inc. All rights reserved.
4
4
* See COPYING.txt for license details.
5
5
*/
6
+ declare (strict_types=1 );
6
7
7
8
namespace Magento \Framework \App ;
8
9
9
10
use Magento \Framework \App \Filesystem \DirectoryList ;
11
+ use Magento \Framework \Filesystem ;
10
12
use Magento \Framework \Filesystem \Directory \ReadFactory ;
11
13
12
14
/**
@@ -20,18 +22,26 @@ class DocRootLocator
20
22
private $ request ;
21
23
22
24
/**
25
+ * @deprecated
23
26
* @var ReadFactory
24
27
*/
25
28
private $ readFactory ;
26
29
30
+ /**
31
+ * @var Filesystem
32
+ */
33
+ private $ filesystem ;
34
+
27
35
/**
28
36
* @param RequestInterface $request
29
37
* @param ReadFactory $readFactory
38
+ * @param Filesystem|null $filesystem
30
39
*/
31
- public function __construct (RequestInterface $ request , ReadFactory $ readFactory )
40
+ public function __construct (RequestInterface $ request , ReadFactory $ readFactory, Filesystem $ filesystem = null )
32
41
{
33
42
$ this ->request = $ request ;
34
43
$ this ->readFactory = $ readFactory ;
44
+ $ this ->filesystem = $ filesystem ?: ObjectManager::getInstance ()->get (Filesystem::class);
35
45
}
36
46
37
47
/**
@@ -42,7 +52,8 @@ public function __construct(RequestInterface $request, ReadFactory $readFactory)
42
52
public function isPub ()
43
53
{
44
54
$ rootBasePath = $ this ->request ->getServer ('DOCUMENT_ROOT ' );
45
- $ readDirectory = $ this ->readFactory ->create (DirectoryList::ROOT );
46
- return (substr ($ rootBasePath , -strlen ('/pub ' )) === '/pub ' ) && !$ readDirectory ->isExist ($ rootBasePath . 'setup ' );
55
+ $ readDirectory = $ this ->filesystem ->getDirectoryRead (DirectoryList::ROOT );
56
+
57
+ return (substr ($ rootBasePath , -\strlen ('/pub ' )) === '/pub ' ) && ! $ readDirectory ->isExist ('setup ' );
47
58
}
48
59
}
0 commit comments