|
10 | 10 | /**
|
11 | 11 | * CMS Page Helper
|
12 | 12 | * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
|
| 13 | + * @SuppressWarnings(PHPMD.CyclomaticComplexity) |
| 14 | + * @SuppressWarnings(PHPMD.NPathComplexity) |
13 | 15 | */
|
14 | 16 | class Page extends \Magento\Framework\App\Helper\AbstractHelper
|
15 | 17 | {
|
@@ -165,19 +167,7 @@ public function prepareResultPage(Action $action, $pageId = null)
|
165 | 167 | $this->_design->setDesignTheme($this->_page->getCustomTheme());
|
166 | 168 | }
|
167 | 169 | }
|
168 |
| - /** @var \Magento\Framework\View\Result\Page $resultPage */ |
169 |
| - $resultPage = $this->resultPageFactory->create(); |
170 |
| - if ($this->_page->getPageLayout()) { |
171 |
| - if ($this->_page->getCustomPageLayout() |
172 |
| - && $this->_page->getCustomPageLayout() != 'empty' |
173 |
| - && $inRange |
174 |
| - ) { |
175 |
| - $handle = $this->_page->getCustomPageLayout(); |
176 |
| - } else { |
177 |
| - $handle = $this->_page->getPageLayout(); |
178 |
| - } |
179 |
| - $resultPage->getConfig()->setPageLayout($handle); |
180 |
| - } |
| 170 | + $resultPage = $this->_setLayoutType($inRange); |
181 | 171 | $resultPage->initLayout();
|
182 | 172 | $resultPage->addHandle('cms_page_view');
|
183 | 173 | $resultPage->addPageLayoutHandles(['id' => $this->_page->getIdentifier()]);
|
@@ -263,18 +253,7 @@ protected function _renderPage(Action $action, $pageId = null, $renderLayout = t
|
263 | 253 | $this->_design->setDesignTheme($this->_page->getCustomTheme());
|
264 | 254 | }
|
265 | 255 | }
|
266 |
| - $resultPage = $this->_view->getPage(); |
267 |
| - if ($this->_page->getPageLayout()) { |
268 |
| - if ($this->_page->getCustomPageLayout() |
269 |
| - && $this->_page->getCustomPageLayout() != 'empty' |
270 |
| - && $inRange |
271 |
| - ) { |
272 |
| - $handle = $this->_page->getCustomPageLayout(); |
273 |
| - } else { |
274 |
| - $handle = $this->_page->getPageLayout(); |
275 |
| - } |
276 |
| - $resultPage->getConfig()->setPageLayout($handle); |
277 |
| - } |
| 256 | + $resultPage = $this->_setLayoutType($inRange); |
278 | 257 | $resultPage->initLayout();
|
279 | 258 | $resultPage->addHandle('cms_page_view');
|
280 | 259 | $resultPage->addPageLayoutHandles(['id' => $this->_page->getIdentifier()]);
|
@@ -349,4 +328,29 @@ public function getPageUrl($pageId = null)
|
349 | 328 |
|
350 | 329 | return $this->_urlBuilder->getUrl(null, ['_direct' => $page->getIdentifier()]);
|
351 | 330 | }
|
| 331 | + |
| 332 | + /** |
| 333 | + * Set layout type |
| 334 | + * |
| 335 | + * @param bool $inRange |
| 336 | + * @return \Magento\Framework\View\Result\Page |
| 337 | + */ |
| 338 | + protected function _setLayoutType($inRange) |
| 339 | + { |
| 340 | + /** @var \Magento\Framework\View\Result\Page $resultPage */ |
| 341 | + $resultPage = $this->resultPageFactory->create(); |
| 342 | + if ($this->_page->getPageLayout()) { |
| 343 | + if ($this->_page->getCustomPageLayout() |
| 344 | + && $this->_page->getCustomPageLayout() != 'empty' |
| 345 | + && $inRange |
| 346 | + ) { |
| 347 | + $handle = $this->_page->getCustomPageLayout(); |
| 348 | + } else { |
| 349 | + $handle = $this->_page->getPageLayout(); |
| 350 | + } |
| 351 | + $resultPage->getConfig()->setPageLayout($handle); |
| 352 | + return $resultPage; |
| 353 | + } |
| 354 | + return $resultPage; |
| 355 | + } |
352 | 356 | }
|
0 commit comments