6
6
namespace Magento \Framework \View \Page ;
7
7
8
8
use Magento \Framework \App ;
9
+ use Magento \Framework \App \ObjectManager ;
9
10
use Magento \Framework \Event ;
10
11
use Magento \Framework \View ;
12
+ use Magento \Framework \View \Model \PageLayout \Config \BuilderInterface ;
11
13
12
14
/**
13
15
* Class Builder
@@ -24,24 +26,32 @@ class Builder extends View\Layout\Builder
24
26
*/
25
27
protected $ pageLayoutReader ;
26
28
29
+ /**
30
+ * @var BuilderInterface|mixed
31
+ */
32
+ private $ pageLayoutBuilder ;
33
+
27
34
/**
28
35
* @param View\LayoutInterface $layout
29
36
* @param App\Request\Http $request
30
37
* @param Event\ManagerInterface $eventManager
31
38
* @param Config $pageConfig
32
39
* @param Layout\Reader $pageLayoutReader
40
+ * @param BuilderInterface|null $pageLayoutBuilder
33
41
*/
34
42
public function __construct (
35
43
View \LayoutInterface $ layout ,
36
44
App \Request \Http $ request ,
37
45
Event \ManagerInterface $ eventManager ,
38
46
Config $ pageConfig ,
39
- Layout \Reader $ pageLayoutReader
47
+ Layout \Reader $ pageLayoutReader ,
48
+ ?BuilderInterface $ pageLayoutBuilder = null
40
49
) {
41
50
parent ::__construct ($ layout , $ request , $ eventManager );
42
51
$ this ->pageConfig = $ pageConfig ;
43
52
$ this ->pageLayoutReader = $ pageLayoutReader ;
44
53
$ this ->pageConfig ->setBuilder ($ this );
54
+ $ this ->pageLayoutBuilder = $ pageLayoutBuilder ?? ObjectManager::getInstance ()->get (BuilderInterface::class);
45
55
}
46
56
47
57
/**
@@ -73,6 +83,10 @@ protected function readPageLayout()
73
83
*/
74
84
protected function getPageLayout ()
75
85
{
76
- return $ this ->pageConfig ->getPageLayout () ?: $ this ->layout ->getUpdate ()->getPageLayout ();
86
+ $ pageLayout = $ this ->pageConfig ->getPageLayout ();
87
+
88
+ return ($ pageLayout && $ this ->pageLayoutBuilder ->getPageLayoutsConfig ()->hasPageLayout ($ pageLayout ))
89
+ ? $ pageLayout
90
+ : $ this ->layout ->getUpdate ()->getPageLayout ();
77
91
}
78
92
}
0 commit comments