33 * Copyright © Magento, Inc. All rights reserved.
44 * See COPYING.txt for license details.
55 */
6+ declare(strict_types=1);
67
78namespace Magento\Framework\App;
89
910use Magento\Framework\App\Filesystem\DirectoryList;
11+ use Magento\Framework\Filesystem;
1012use Magento\Framework\Filesystem\Directory\ReadFactory;
1113
1214/**
@@ -20,18 +22,26 @@ class DocRootLocator
2022 private $request;
2123
2224 /**
25+ * @deprecated
2326 * @var ReadFactory
2427 */
2528 private $readFactory;
2629
30+ /**
31+ * @var Filesystem
32+ */
33+ private $filesystem;
34+
2735 /**
2836 * @param RequestInterface $request
2937 * @param ReadFactory $readFactory
38+ * @param Filesystem|null $filesystem
3039 */
31- public function __construct (RequestInterface $ request , ReadFactory $ readFactory )
40+ public function __construct(RequestInterface $request, ReadFactory $readFactory, Filesystem $filesystem = null )
3241 {
3342 $this->request = $request;
3443 $this->readFactory = $readFactory;
44+ $this->filesystem = $filesystem ?: ObjectManager::getInstance()->get(Filesystem::class);
3545 }
3646
3747 /**
@@ -42,7 +52,8 @@ public function __construct(RequestInterface $request, ReadFactory $readFactory)
4252 public function isPub()
4353 {
4454 $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');
4758 }
4859}
0 commit comments