99use Magento \Framework ;
1010use Magento \Framework \App \Response \HttpInterface as HttpResponseInterface ;
1111use Magento \Framework \View ;
12+ use Magento \Framework \View \Element \Template \Context ;
13+ use Magento \Framework \View \LayoutFactory ;
14+ use Magento \Framework \View \Layout \ReaderPool ;
15+ use Magento \Framework \Translate \InlineInterface ;
16+ use Magento \Framework \View \Layout \BuilderFactory ;
17+ use Magento \Framework \View \Layout \GeneratorPool ;
18+ use Magento \Framework \View \Page \Config \RendererInterface as PageConfigRendererInterface ;
19+ use Magento \Framework \View \Page \Config \RendererFactory as PageConfigRendererFactory ;
20+ use Magento \Framework \View \Page \Layout \Reader as PageLayoutReader ;
21+ use Magento \Framework \App \RequestInterface as AppRequestInterface ;
22+ use Magento \Framework \View \Asset \Repository as AssetRepository ;
23+ use Psr \Log \LoggerInterface ;
24+ use Magento \Framework \UrlInterface ;
25+ use Magento \Framework \View \Page \Config as PageConfig ;
26+ use Magento \Framework \View \FileSystem as ViewFileSystem ;
27+ use Magento \Framework \App \ObjectManager ;
28+ use Magento \Framework \View \EntitySpecificHandlesList ;
1229
1330/**
14- * A "page" result that encapsulates page type, page configuration
15- * and imposes certain layout handles.
31+ * Class Page represents a "page" result that encapsulates page type, page configuration, and imposes certain layout handles.
1632 *
1733 * The framework convention is that there will be loaded a guaranteed handle for "all pages",
1834 * then guaranteed handle that corresponds to page type
@@ -35,27 +51,27 @@ class Page extends Layout
3551 protected $ pageLayout ;
3652
3753 /**
38- * @var \Magento\Framework\View\Page\Config
54+ * @var PageConfig
3955 */
4056 protected $ pageConfig ;
4157
4258 /**
43- * @var \Magento\Framework\View\Page\Config\RendererInterface
59+ * @var PageConfigRendererInterface
4460 */
4561 protected $ pageConfigRenderer ;
4662
4763 /**
48- * @var \Magento\Framework\View\Page\Config\RendererFactory
64+ * @var PageConfigRendererFactory
4965 */
5066 protected $ pageConfigRendererFactory ;
5167
5268 /**
53- * @var \Magento\Framework\View\Page\Layout\Reader
69+ * @var PageLayoutReader
5470 */
5571 protected $ pageLayoutReader ;
5672
5773 /**
58- * @var \Magento\Framework\View\FileSystem
74+ * @var ViewFileSystem
5975 */
6076 protected $ viewFileSystem ;
6177
@@ -70,61 +86,59 @@ class Page extends Layout
7086 protected $ template ;
7187
7288 /**
73- * @var Framework\App\RequestInterface
89+ * @var AppRequestInterface
7490 */
7591 protected $ request ;
7692
7793 /**
78- * Asset service
79- *
80- * @var \Magento\Framework\View\Asset\Repository
94+ * @var AssetRepository
8195 */
8296 protected $ assetRepo ;
8397
8498 /**
85- * @var \Psr\Log\ LoggerInterface
99+ * @var LoggerInterface
86100 */
87101 protected $ logger ;
88102
89103 /**
90- * @var Framework\ UrlInterface
104+ * @var UrlInterface
91105 */
92106 protected $ urlBuilder ;
93107
94108 /**
95- * @var View\ EntitySpecificHandlesList
109+ * @var EntitySpecificHandlesList
96110 */
97111 private $ entitySpecificHandlesList ;
98112
99113 /**
100114 * Constructor
101115 *
102- * @param View\Element\Template\ Context $context
103- * @param View\ LayoutFactory $layoutFactory
104- * @param View\Layout\ ReaderPool $layoutReaderPool
105- * @param Framework\Translate\ InlineInterface $translateInline
106- * @param View\Layout\ BuilderFactory $layoutBuilderFactory
107- * @param View\Layout\ GeneratorPool $generatorPool
108- * @param View\Page\Config\RendererFactory $pageConfigRendererFactory
109- * @param View\Page\Layout\Reader $pageLayoutReader
116+ * @param Context $context
117+ * @param LayoutFactory $layoutFactory
118+ * @param ReaderPool $layoutReaderPool
119+ * @param InlineInterface $translateInline
120+ * @param BuilderFactory $layoutBuilderFactory
121+ * @param GeneratorPool $generatorPool
122+ * @param PageConfigRendererFactory $pageConfigRendererFactory
123+ * @param PageLayoutReader $pageLayoutReader
110124 * @param string $template
111125 * @param bool $isIsolated
112- * @param View\ EntitySpecificHandlesList $entitySpecificHandlesList
113- *
126+ * @param EntitySpecificHandlesList|null $entitySpecificHandlesList
127+ *
114128 * @SuppressWarnings(PHPMD.ExcessiveParameterList)
115129 */
116130 public function __construct (
117- View \ Element \ Template \ Context $ context ,
118- View \ LayoutFactory $ layoutFactory ,
119- View \ Layout \ ReaderPool $ layoutReaderPool ,
120- Framework \ Translate \ InlineInterface $ translateInline ,
121- View \ Layout \ BuilderFactory $ layoutBuilderFactory ,
122- View \ Layout \ GeneratorPool $ generatorPool ,
123- View \ Page \ Config \ RendererFactory $ pageConfigRendererFactory ,
124- View \ Page \ Layout \ Reader $ pageLayoutReader ,
125- $ template ,
126- $ isIsolated = false ,
127- View \ EntitySpecificHandlesList $ entitySpecificHandlesList = null
131+ Context $ context ,
132+ LayoutFactory $ layoutFactory ,
133+ ReaderPool $ layoutReaderPool ,
134+ InlineInterface $ translateInline ,
135+ BuilderFactory $ layoutBuilderFactory ,
136+ GeneratorPool $ generatorPool ,
137+ PageConfigRendererFactory $ pageConfigRendererFactory ,
138+ PageLayoutReader $ pageLayoutReader ,
139+ string $ template ,
140+ bool $ isIsolated = false ,
141+ ? EntitySpecificHandlesList $ entitySpecificHandlesList = null
128142 ) {
129143 $ this ->request = $ context ->getRequest ();
130144 $ this ->assetRepo = $ context ->getAssetRepository ();
@@ -136,7 +150,7 @@ public function __construct(
136150 $ this ->pageConfigRendererFactory = $ pageConfigRendererFactory ;
137151 $ this ->template = $ template ;
138152 $ this ->entitySpecificHandlesList = $ entitySpecificHandlesList
139- ?: \ Magento \ Framework \ App \ ObjectManager::getInstance ()->get (View \ EntitySpecificHandlesList::class);
153+ ?: ObjectManager::getInstance ()->get (EntitySpecificHandlesList::class);
140154 parent ::__construct (
141155 $ context ,
142156 $ layoutFactory ,
@@ -203,7 +217,7 @@ public function addDefaultHandle()
203217 /**
204218 * Return page configuration
205219 *
206- * @return \Magento\Framework\View\Page\Config
220+ * @return PageConfig
207221 */
208222 public function getConfig ()
209223 {
@@ -220,7 +234,7 @@ public function getConfig()
220234 */
221235 public function addPageLayoutHandles (array $ parameters = [], $ defaultHandle = null , $ entitySpecific = true )
222236 {
223- $ handle = $ defaultHandle ? $ defaultHandle : $ this ->getDefaultLayoutHandle ();
237+ $ handle = $ defaultHandle ?: $ this ->getDefaultLayoutHandle ();
224238 $ pageHandles = [$ handle ];
225239 foreach ($ parameters as $ key => $ value ) {
226240 $ handle = $ value ['handle ' ] ?? $ handle ;
@@ -237,6 +251,8 @@ public function addPageLayoutHandles(array $parameters = [], $defaultHandle = nu
237251 }
238252
239253 /**
254+ * Render the page.
255+ *
240256 * {@inheritdoc}
241257 */
242258 protected function render (HttpResponseInterface $ response )
@@ -262,7 +278,7 @@ protected function render(HttpResponseInterface $response)
262278
263279 $ output = $ this ->getLayout ()->getOutput ();
264280 $ this ->assign ('layoutContent ' , $ output );
265- $ output = $ this ->renderPage ();
281+ $ output = $ this ->renderPage ($ output );
266282 $ this ->translateInline ->processResponseBody ($ output );
267283 $ response ->appendBody ($ output );
268284 } else {
@@ -287,7 +303,9 @@ protected function addDefaultBodyClasses()
287303 }
288304
289305 /**
290- * @return string
306+ * Get the page layout.
307+ *
308+ * @return string The page layout.
291309 */
292310 protected function getPageLayout ()
293311 {
@@ -297,9 +315,9 @@ protected function getPageLayout()
297315 /**
298316 * Assign variable
299317 *
300- * @param string|array $key
301- * @param mixed $value
302- * @return $this
318+ * @param string|array $key
319+ * @param mixed $value
320+ * @return $this
303321 */
304322 protected function assign ($ key , $ value = null )
305323 {
@@ -319,7 +337,7 @@ protected function assign($key, $value = null)
319337 * @return string
320338 * @throws \Exception
321339 */
322- protected function renderPage ()
340+ protected function renderPage ($ output )
323341 {
324342 $ fileName = $ this ->viewFileSystem ->getTemplateFileName ($ this ->template );
325343 if (!$ fileName ) {
@@ -345,7 +363,7 @@ protected function renderPage()
345363 * @param array $params
346364 * @return string
347365 */
348- protected function getViewFileUrl ($ fileId , array $ params = [])
366+ protected function getViewFileUrl (string $ fileId , array $ params = [])
349367 {
350368 try {
351369 $ params = array_merge (['_secure ' => $ this ->request ->isSecure ()], $ params );
0 commit comments