Skip to content

Commit 6773730

Browse files
author
Evgeniy Miskov
committed
MAGETWO-33059: Refactor CMS module
1 parent 702d728 commit 6773730

File tree

1 file changed

+29
-25
lines changed

1 file changed

+29
-25
lines changed

app/code/Magento/Cms/Helper/Page.php

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
/**
1111
* CMS Page Helper
1212
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
13+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
14+
* @SuppressWarnings(PHPMD.NPathComplexity)
1315
*/
1416
class Page extends \Magento\Framework\App\Helper\AbstractHelper
1517
{
@@ -165,19 +167,7 @@ public function prepareResultPage(Action $action, $pageId = null)
165167
$this->_design->setDesignTheme($this->_page->getCustomTheme());
166168
}
167169
}
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);
181171
$resultPage->initLayout();
182172
$resultPage->addHandle('cms_page_view');
183173
$resultPage->addPageLayoutHandles(['id' => $this->_page->getIdentifier()]);
@@ -263,18 +253,7 @@ protected function _renderPage(Action $action, $pageId = null, $renderLayout = t
263253
$this->_design->setDesignTheme($this->_page->getCustomTheme());
264254
}
265255
}
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);
278257
$resultPage->initLayout();
279258
$resultPage->addHandle('cms_page_view');
280259
$resultPage->addPageLayoutHandles(['id' => $this->_page->getIdentifier()]);
@@ -349,4 +328,29 @@ public function getPageUrl($pageId = null)
349328

350329
return $this->_urlBuilder->getUrl(null, ['_direct' => $page->getIdentifier()]);
351330
}
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+
}
352356
}

0 commit comments

Comments
 (0)