File tree Expand file tree Collapse file tree 3 files changed +98
-0
lines changed
lib/internal/Magento/Framework/App Expand file tree Collapse file tree 3 files changed +98
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * Copyright © 2016 Magento. All rights reserved.
4
+ * See COPYING.txt for license details.
5
+ */
6
+ namespace Magento \Backend \Model \Setup ;
7
+
8
+ use Magento \Backend \Model \Menu ;
9
+ use Magento \Backend \Model \Menu \Builder ;
10
+ use Magento \Framework \App \DocRoot ;
11
+
12
+ /**
13
+ * Plugin class to remove web setup wizard from menu if application root is pub/ and no setup url variable is specified.
14
+ */
15
+ class MenuBuilder
16
+ {
17
+
18
+ /**
19
+ * @var DocRoot
20
+ */
21
+ protected $ docRoot ;
22
+
23
+ /**
24
+ * MenuBuilder constructor.
25
+ *
26
+ * @param DocRoot $docRoot
27
+ */
28
+ public function __construct (DocRoot $ docRoot )
29
+ {
30
+ $ this ->docRoot = $ docRoot ;
31
+ }
32
+
33
+ /**
34
+ * Removes 'Web Setup Wizard' from the menu if doc root is pub and no setup url variable is specified.
35
+ *
36
+ * @param Builder $subject
37
+ * @param Menu $menu
38
+ * @return Menu
39
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
40
+ */
41
+ public function afterGetResult (Builder $ subject , Menu $ menu )
42
+ {
43
+ if ($ this ->docRoot ->hasThisSubDir ('pub ' , 'setup ' )) {
44
+ $ menu ->remove ('Magento_Backend::setup_wizard ' );
45
+ }
46
+ return $ menu ;
47
+ }
48
+ }
Original file line number Diff line number Diff line change 214
214
</argument >
215
215
</arguments >
216
216
</type >
217
+ <type name =" Magento\Backend\Model\Menu\Builder" >
218
+ <plugin name =" SetupMenuBuilder" type =" Magento\Backend\Model\Setup\MenuBuilder" />
219
+ </type >
217
220
</config >
Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * Copyright © 2016 Magento. All rights reserved.
4
+ * See COPYING.txt for license details.
5
+ */
6
+
7
+ namespace Magento \Framework \App ;
8
+
9
+ use Magento \Framework \App \Filesystem \DirectoryList ;
10
+ use Magento \Framework \Filesystem \Directory \ReadFactory ;
11
+
12
+ /**
13
+ * This class calculates if document root is set to pub
14
+ */
15
+ class DocRoot
16
+ {
17
+ /**
18
+ * @var RequestInterface
19
+ */
20
+ private $ request ;
21
+
22
+ /**
23
+ * @var ReadFactory
24
+ */
25
+ private $ readFactory ;
26
+
27
+ /**
28
+ * @param RequestInterface $request
29
+ * @param ReadFactory $readFactory
30
+ */
31
+ public function __construct (RequestInterface $ request , ReadFactory $ readFactory ) {
32
+ $ this ->request = $ request ;
33
+ $ this ->readFactory = $ readFactory ;
34
+ }
35
+
36
+ /**
37
+ * Returns true if doc root is pub/ and not BP
38
+ *
39
+ * @return string
40
+ */
41
+ public function hasThisSubDir ($ dirToCheck , $ missingDir )
42
+ {
43
+ $ rootBasePath = $ this ->request ->getServer ('DOCUMENT_ROOT ' );
44
+ $ readDirectory = $ this ->readFactory ->create (DirectoryList::ROOT );
45
+ return strpos ($ rootBasePath , $ dirToCheck ) && !$ readDirectory ->isExist ($ rootBasePath + $ missingDir );
46
+ }
47
+ }
You can’t perform that action at this time.
0 commit comments