97 \
Magento\Framework\View\DesignInterface $design,
98 \
Magento\Cms\Model\PageFactory $pageFactory,
100 \
Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate,
101 \
Magento\Framework\Escaper $escaper,
105 $this->_page =
$page;
106 $this->_design = $design;
107 $this->_pageFactory = $pageFactory;
109 $this->_localeDate = $localeDate;
110 $this->_escaper = $escaper;
112 parent::__construct($context);
122 public function prepareResultPage(
Action $action, $pageId =
null)
124 if ($pageId !==
null && $pageId !== $this->_page->getId()) {
125 $delimiterPosition = strrpos($pageId,
'|');
126 if ($delimiterPosition) {
127 $pageId = substr($pageId, 0, $delimiterPosition);
130 $this->_page->setStoreId($this->_storeManager->getStore()->getId());
131 if (!$this->_page->load($pageId)) {
136 if (!$this->_page->getId()) {
140 $inRange = $this->_localeDate->isScopeDateInInterval(
142 $this->_page->getCustomThemeFrom(),
143 $this->_page->getCustomThemeTo()
146 if ($this->_page->getCustomTheme()) {
148 $this->_design->setDesignTheme($this->_page->getCustomTheme());
152 $resultPage = $this->resultPageFactory->create();
154 $resultPage->addHandle(
'cms_page_view');
155 $resultPage->addPageLayoutHandles([
'id' => str_replace(
'/',
'_', $this->_page->getIdentifier())]);
157 $this->_eventManager->dispatch(
159 [
'page' => $this->_page,
'controller_action' => $action,
'request' => $this->
_getRequest()]
162 if ($this->_page->getCustomLayoutUpdateXml() && $inRange) {
163 $layoutUpdate = $this->_page->getCustomLayoutUpdateXml();
165 $layoutUpdate = $this->_page->getLayoutUpdateXml();
167 if (!empty($layoutUpdate)) {
168 $resultPage->getLayout()->getUpdate()->addUpdate($layoutUpdate);
171 $contentHeadingBlock = $resultPage->getLayout()->getBlock(
'page_content_heading');
172 if ($contentHeadingBlock) {
173 $contentHeading = $this->_escaper->escapeHtml($this->_page->getContentHeading());
174 $contentHeadingBlock->setContentHeading($contentHeading);
186 public function getPageUrl($pageId =
null)
189 $page = $this->_pageFactory->create();
190 if ($pageId !==
null && $pageId !==
$page->getId()) {
191 $page->setStoreId($this->_storeManager->getStore()->getId());
192 $page->load($pageId);
195 if (!
$page->getId()) {
199 return $this->_urlBuilder->getUrl(
null, [
'_direct' =>
$page->getIdentifier()]);
211 if ($this->_page->getPageLayout()) {
212 if ($this->_page->getCustomPageLayout()
213 && $this->_page->getCustomPageLayout() !=
'empty' 216 $handle = $this->_page->getCustomPageLayout();
218 $handle = $this->_page->getPageLayout();
220 $resultPage->getConfig()->setPageLayout(
$handle);
const XML_PATH_NO_ROUTE_PAGE
setLayoutType($inRange, $resultPage)
__construct(\Magento\Framework\App\Helper\Context $context, \Magento\Framework\Message\ManagerInterface $messageManager, \Magento\Cms\Model\Page $page, \Magento\Framework\View\DesignInterface $design, \Magento\Cms\Model\PageFactory $pageFactory, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Framework\Escaper $escaper, \Magento\Framework\View\Result\PageFactory $resultPageFactory)
const XML_PATH_NO_COOKIES_PAGE