66namespace Magento \Framework \View \Page ;
77
88use Magento \Framework \App ;
9+ use Magento \Framework \App \ObjectManager ;
910use Magento \Framework \Event ;
1011use Magento \Framework \View ;
12+ use Magento \Framework \View \Model \PageLayout \Config \BuilderInterface ;
1113
1214/**
1315 * Class Builder
@@ -24,24 +26,32 @@ class Builder extends View\Layout\Builder
2426 */
2527 protected $ pageLayoutReader ;
2628
29+ /**
30+ * @var BuilderInterface|mixed
31+ */
32+ private $ pageLayoutBuilder ;
33+
2734 /**
2835 * @param View\LayoutInterface $layout
2936 * @param App\Request\Http $request
3037 * @param Event\ManagerInterface $eventManager
3138 * @param Config $pageConfig
3239 * @param Layout\Reader $pageLayoutReader
40+ * @param BuilderInterface|null $pageLayoutBuilder
3341 */
3442 public function __construct (
3543 View \LayoutInterface $ layout ,
3644 App \Request \Http $ request ,
3745 Event \ManagerInterface $ eventManager ,
3846 Config $ pageConfig ,
39- Layout \Reader $ pageLayoutReader
47+ Layout \Reader $ pageLayoutReader ,
48+ ?BuilderInterface $ pageLayoutBuilder = null
4049 ) {
4150 parent ::__construct ($ layout , $ request , $ eventManager );
4251 $ this ->pageConfig = $ pageConfig ;
4352 $ this ->pageLayoutReader = $ pageLayoutReader ;
4453 $ this ->pageConfig ->setBuilder ($ this );
54+ $ this ->pageLayoutBuilder = $ pageLayoutBuilder ?? ObjectManager::getInstance ()->get (BuilderInterface::class);
4555 }
4656
4757 /**
@@ -73,6 +83,10 @@ protected function readPageLayout()
7383 */
7484 protected function getPageLayout ()
7585 {
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 ();
7791 }
7892}
0 commit comments