8
8
9
9
namespace Magento \PageBuilder \Controller \Adminhtml \Template ;
10
10
11
- use Magento \Framework \App \Action \ HttpGetActionInterface ;
11
+ use Magento \Backend \App \Action ;
12
12
use Magento \Backend \App \Action \Context ;
13
+ use Magento \Framework \App \Action \HttpGetActionInterface ;
13
14
use Magento \Framework \View \Result \PageFactory ;
14
- use Magento \Backend \App \Action ;
15
+ use Magento \PageBuilder \Model \Config ;
16
+ use Magento \Framework \Controller \Result \ForwardFactory ;
15
17
16
18
/**
17
19
* Display template grid
@@ -25,16 +27,32 @@ class Index extends Action implements HttpGetActionInterface
25
27
*/
26
28
private $ resultPageFactory ;
27
29
30
+ /**
31
+ * @var Config
32
+ */
33
+ private $ config ;
34
+
35
+ /**
36
+ * @var ForwardFactory
37
+ */
38
+ private $ forwardFactory ;
39
+
28
40
/**
29
41
* @param Context $context
30
42
* @param PageFactory $resultPageFactory
43
+ * @param Config $config
44
+ * @param ForwardFactory $forwardFactory
31
45
*/
32
46
public function __construct (
33
47
Context $ context ,
34
- PageFactory $ resultPageFactory
48
+ PageFactory $ resultPageFactory ,
49
+ Config $ config ,
50
+ ForwardFactory $ forwardFactory
35
51
) {
36
52
parent ::__construct ($ context );
37
53
$ this ->resultPageFactory = $ resultPageFactory ;
54
+ $ this ->config = $ config ;
55
+ $ this ->forwardFactory = $ forwardFactory ;
38
56
}
39
57
40
58
/**
@@ -44,6 +62,10 @@ public function __construct(
44
62
*/
45
63
public function execute ()
46
64
{
65
+ if (!$ this ->config ->isEnabled ()) {
66
+ return $ this ->forwardFactory ->create ()->forward ('noroute ' );
67
+ }
68
+
47
69
/** @var \Magento\Backend\Model\View\Result\Page $resultPage */
48
70
$ resultPage = $ this ->resultPageFactory ->create ();
49
71
$ resultPage ->setActiveMenu ('Magento_PageBuilder::templates ' );
0 commit comments