9
9
use Magento \Framework ;
10
10
use Magento \Framework \App \Response \HttpInterface as HttpResponseInterface ;
11
11
use 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 ;
12
29
13
30
/**
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.
16
32
*
17
33
* The framework convention is that there will be loaded a guaranteed handle for "all pages",
18
34
* then guaranteed handle that corresponds to page type
@@ -35,27 +51,27 @@ class Page extends Layout
35
51
protected $ pageLayout ;
36
52
37
53
/**
38
- * @var \Magento\Framework\View\Page\Config
54
+ * @var PageConfig
39
55
*/
40
56
protected $ pageConfig ;
41
57
42
58
/**
43
- * @var \Magento\Framework\View\Page\Config\RendererInterface
59
+ * @var PageConfigRendererInterface
44
60
*/
45
61
protected $ pageConfigRenderer ;
46
62
47
63
/**
48
- * @var \Magento\Framework\View\Page\Config\RendererFactory
64
+ * @var PageConfigRendererFactory
49
65
*/
50
66
protected $ pageConfigRendererFactory ;
51
67
52
68
/**
53
- * @var \Magento\Framework\View\Page\Layout\Reader
69
+ * @var PageLayoutReader
54
70
*/
55
71
protected $ pageLayoutReader ;
56
72
57
73
/**
58
- * @var \Magento\Framework\View\FileSystem
74
+ * @var ViewFileSystem
59
75
*/
60
76
protected $ viewFileSystem ;
61
77
@@ -70,61 +86,59 @@ class Page extends Layout
70
86
protected $ template ;
71
87
72
88
/**
73
- * @var Framework\App\RequestInterface
89
+ * @var AppRequestInterface
74
90
*/
75
91
protected $ request ;
76
92
77
93
/**
78
- * Asset service
79
- *
80
- * @var \Magento\Framework\View\Asset\Repository
94
+ * @var AssetRepository
81
95
*/
82
96
protected $ assetRepo ;
83
97
84
98
/**
85
- * @var \Psr\Log\ LoggerInterface
99
+ * @var LoggerInterface
86
100
*/
87
101
protected $ logger ;
88
102
89
103
/**
90
- * @var Framework\ UrlInterface
104
+ * @var UrlInterface
91
105
*/
92
106
protected $ urlBuilder ;
93
107
94
108
/**
95
- * @var View\ EntitySpecificHandlesList
109
+ * @var EntitySpecificHandlesList
96
110
*/
97
111
private $ entitySpecificHandlesList ;
98
112
99
113
/**
100
114
* Constructor
101
115
*
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
110
124
* @param string $template
111
125
* @param bool $isIsolated
112
- * @param View\ EntitySpecificHandlesList $entitySpecificHandlesList
113
- *
126
+ * @param EntitySpecificHandlesList|null $entitySpecificHandlesList
127
+ *
114
128
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
115
129
*/
116
130
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
128
142
) {
129
143
$ this ->request = $ context ->getRequest ();
130
144
$ this ->assetRepo = $ context ->getAssetRepository ();
@@ -136,7 +150,7 @@ public function __construct(
136
150
$ this ->pageConfigRendererFactory = $ pageConfigRendererFactory ;
137
151
$ this ->template = $ template ;
138
152
$ this ->entitySpecificHandlesList = $ entitySpecificHandlesList
139
- ?: \ Magento \ Framework \ App \ ObjectManager::getInstance ()->get (View \ EntitySpecificHandlesList::class);
153
+ ?: ObjectManager::getInstance ()->get (EntitySpecificHandlesList::class);
140
154
parent ::__construct (
141
155
$ context ,
142
156
$ layoutFactory ,
@@ -203,7 +217,7 @@ public function addDefaultHandle()
203
217
/**
204
218
* Return page configuration
205
219
*
206
- * @return \Magento\Framework\View\Page\Config
220
+ * @return PageConfig
207
221
*/
208
222
public function getConfig ()
209
223
{
@@ -220,7 +234,7 @@ public function getConfig()
220
234
*/
221
235
public function addPageLayoutHandles (array $ parameters = [], $ defaultHandle = null , $ entitySpecific = true )
222
236
{
223
- $ handle = $ defaultHandle ? $ defaultHandle : $ this ->getDefaultLayoutHandle ();
237
+ $ handle = $ defaultHandle ?: $ this ->getDefaultLayoutHandle ();
224
238
$ pageHandles = [$ handle ];
225
239
foreach ($ parameters as $ key => $ value ) {
226
240
$ handle = $ value ['handle ' ] ?? $ handle ;
@@ -237,6 +251,8 @@ public function addPageLayoutHandles(array $parameters = [], $defaultHandle = nu
237
251
}
238
252
239
253
/**
254
+ * Render the page.
255
+ *
240
256
* {@inheritdoc}
241
257
*/
242
258
protected function render (HttpResponseInterface $ response )
@@ -262,7 +278,7 @@ protected function render(HttpResponseInterface $response)
262
278
263
279
$ output = $ this ->getLayout ()->getOutput ();
264
280
$ this ->assign ('layoutContent ' , $ output );
265
- $ output = $ this ->renderPage ();
281
+ $ output = $ this ->renderPage ($ output );
266
282
$ this ->translateInline ->processResponseBody ($ output );
267
283
$ response ->appendBody ($ output );
268
284
} else {
@@ -287,7 +303,9 @@ protected function addDefaultBodyClasses()
287
303
}
288
304
289
305
/**
290
- * @return string
306
+ * Get the page layout.
307
+ *
308
+ * @return string The page layout.
291
309
*/
292
310
protected function getPageLayout ()
293
311
{
@@ -297,9 +315,9 @@ protected function getPageLayout()
297
315
/**
298
316
* Assign variable
299
317
*
300
- * @param string|array $key
301
- * @param mixed $value
302
- * @return $this
318
+ * @param string|array $key
319
+ * @param mixed $value
320
+ * @return $this
303
321
*/
304
322
protected function assign ($ key , $ value = null )
305
323
{
@@ -319,7 +337,7 @@ protected function assign($key, $value = null)
319
337
* @return string
320
338
* @throws \Exception
321
339
*/
322
- protected function renderPage ()
340
+ protected function renderPage ($ output )
323
341
{
324
342
$ fileName = $ this ->viewFileSystem ->getTemplateFileName ($ this ->template );
325
343
if (!$ fileName ) {
@@ -345,7 +363,7 @@ protected function renderPage()
345
363
* @param array $params
346
364
* @return string
347
365
*/
348
- protected function getViewFileUrl ($ fileId , array $ params = [])
366
+ protected function getViewFileUrl (string $ fileId , array $ params = [])
349
367
{
350
368
try {
351
369
$ params = array_merge (['_secure ' => $ this ->request ->isSecure ()], $ params );
0 commit comments