Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Member Functions | Protected Attributes
Page Class Reference
Inheritance diagram for Page:
AbstractBlock IdentityInterface DataObject BlockInterface

Public Member Functions

 __construct (\Magento\Framework\View\Element\Context $context, \Magento\Cms\Model\Page $page, \Magento\Cms\Model\Template\FilterProvider $filterProvider, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Cms\Model\PageFactory $pageFactory, \Magento\Framework\View\Page\Config $pageConfig, array $data=[])
 
 getIdentities ()
 
- Public Member Functions inherited from AbstractBlock
 __construct (\Magento\Framework\View\Element\Context $context, array $data=[])
 
 getJsLayout ()
 
 getRequest ()
 
 getParentBlock ()
 
 setLayout (\Magento\Framework\View\LayoutInterface $layout)
 
 getLayout ()
 
 setNameInLayout ($name)
 
 getChildNames ()
 
 setAttribute ($name, $value=null)
 
 setChild ($alias, $block)
 
 addChild ($alias, $block, $data=[])
 
 unsetChild ($alias)
 
 unsetCallChild ($alias, $callback, $result, $params)
 
 unsetChildren ()
 
 getChildBlock ($alias)
 
 getChildHtml ($alias='', $useCache=true)
 
 getChildChildHtml ($alias, $childChildAlias='', $useCache=true)
 
 getBlockHtml ($name)
 
 insert ($element, $siblingName=0, $after=true, $alias='')
 
 append ($element, $alias='')
 
 getGroupChildNames ($groupName)
 
 getChildData ($alias, $key='')
 
 getUiId ($arg1=null, $arg2=null, $arg3=null, $arg4=null, $arg5=null)
 
 getJsId ($arg1=null, $arg2=null, $arg3=null, $arg4=null, $arg5=null)
 
 getUrl ($route='', $params=[])
 
 getViewFileUrl ($fileId, array $params=[])
 
 formatDate ( $date=null, $format=\IntlDateFormatter::SHORT, $showTime=false, $timezone=null)
 
 formatTime ( $time=null, $format=\IntlDateFormatter::SHORT, $showDate=false)
 
 getModuleName ()
 
 escapeHtml ($data, $allowedTags=null)
 
 escapeJs ($string)
 
 escapeHtmlAttr ($string, $escapeSingleQuote=true)
 
 escapeCss ($string)
 
 stripTags ($data, $allowableTags=null, $allowHtmlEntities=false)
 
 escapeUrl ($string)
 
 escapeXssInUrl ($data)
 
 escapeQuote ($data, $addSlashes=false)
 
 escapeJsQuote ($data, $quote='\'')
 
 getNameInLayout ()
 
 getCacheKeyInfo ()
 
 getCacheKey ()
 
 getVar ($name, $module=null)
 
 isScopePrivate ()
 
- Public Member Functions inherited from DataObject
 __construct (array $data=[])
 
 addData (array $arr)
 
 setData ($key, $value=null)
 
 unsetData ($key=null)
 
 getData ($key='', $index=null)
 
 getDataByPath ($path)
 
 getDataByKey ($key)
 
 setDataUsingMethod ($key, $args=[])
 
 getDataUsingMethod ($key, $args=null)
 
 hasData ($key='')
 
 toArray (array $keys=[])
 
 convertToArray (array $keys=[])
 
 toXml (array $keys=[], $rootName='item', $addOpenTag=false, $addCdata=true)
 
 convertToXml (array $arrAttributes=[], $rootName='item', $addOpenTag=false, $addCdata=true)
 
 toJson (array $keys=[])
 
 convertToJson (array $keys=[])
 
 toString ($format='')
 
 __call ($method, $args)
 
 isEmpty ()
 
 serialize ($keys=[], $valueSeparator='=', $fieldSeparator=' ', $quote='"')
 
 debug ($data=null, &$objects=[])
 
 offsetSet ($offset, $value)
 
 offsetExists ($offset)
 
 offsetUnset ($offset)
 
 offsetGet ($offset)
 
- Public Member Functions inherited from BlockInterface
 toHtml ()
 

Protected Member Functions

 _prepareLayout ()
 
 _addBreadcrumbs (\Magento\Cms\Model\Page $page)
 
 _toHtml ()
 
- Protected Member Functions inherited from AbstractBlock
 _construct ()
 
 _prepareLayout ()
 
 _beforeToHtml ()
 
 _afterToHtml ($html)
 
 _toHtml ()
 
 _getNotFoundUrl ($route='', $params=['_direct'=> 'core/index/notFound'])
 
 getCacheTags ()
 
 getCacheLifetime ()
 
 _loadCache ()
 
 _saveCache ($data)
 
 _getSidPlaceholder ($cacheKey=null)
 
- Protected Member Functions inherited from DataObject
 _getData ($key)
 
 _underscore ($name)
 

Protected Attributes

 $_filterProvider
 
 $_page
 
 $_storeManager
 
 $_pageFactory
 
 $pageConfig
 
- Protected Attributes inherited from AbstractBlock
 $_design
 
 $_session
 
 $_sidResolver
 
 $_nameInLayout
 
 $_layout
 
 $jsLayout = []
 
 $_request
 
 $_urlBuilder
 
 $_eventManager
 
 $_frontController
 
 $_assetRepo
 
 $_viewConfig
 
 $_cacheState
 
 $_logger
 
 $_escaper
 
 $filterManager
 
 $_localeDate
 
 $inlineTranslation
 
 $_isScopePrivate = false
 
 $_scopeConfig
 
 $_cache
 
- Protected Attributes inherited from DataObject
 $_data = []
 

Additional Inherited Members

- Static Public Member Functions inherited from AbstractBlock
static extractModuleName ($className)
 
- Data Fields inherited from AbstractBlock
const CACHE_GROUP = \Magento\Framework\App\Cache\Type\Block::TYPE_IDENTIFIER
 
const CACHE_KEY_PREFIX = 'BLOCK_'
 
- Static Protected Attributes inherited from DataObject
static $_underscoreCache = []
 

Detailed Description

Cms page content block

@api

Since
100.0.2

Definition at line 16 of file Page.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( \Magento\Framework\View\Element\Context  $context,
\Magento\Cms\Model\Page  $page,
\Magento\Cms\Model\Template\FilterProvider  $filterProvider,
\Magento\Store\Model\StoreManagerInterface  $storeManager,
\Magento\Cms\Model\PageFactory  $pageFactory,
\Magento\Framework\View\Page\Config  $pageConfig,
array  $data = [] 
)

Construct

Parameters
\Magento\Framework\View\Element\Context$context
\Magento\Cms\Model\Page$page
\Magento\Cms\Model\Template\FilterProvider$filterProvider
\Magento\Store\Model\StoreManagerInterface$storeManager
\Magento\Cms\Model\PageFactory$pageFactory
\Magento\Framework\View\Page\Config$pageConfig
array$data

Definition at line 59 of file Page.php.

67  {
68  parent::__construct($context, $data);
69  // used singleton (instead factory) because there exist dependencies on \Magento\Cms\Helper\Page
70  $this->_page = $page;
71  $this->_filterProvider = $filterProvider;
72  $this->_storeManager = $storeManager;
73  $this->_pageFactory = $pageFactory;
74  $this->pageConfig = $pageConfig;
75  }
$storeManager
$page
Definition: pages.php:8

Member Function Documentation

◆ _addBreadcrumbs()

_addBreadcrumbs ( \Magento\Cms\Model\Page  $page)
protected

Prepare breadcrumbs

Parameters
\Magento\Cms\Model\Page$page
Exceptions

Definition at line 128 of file Page.php.

129  {
130  $homePageIdentifier = $this->_scopeConfig->getValue(
131  'web/default/cms_home_page',
133  );
134  $homePageDelimiterPosition = strrpos($homePageIdentifier, '|');
135  if ($homePageDelimiterPosition) {
136  $homePageIdentifier = substr($homePageIdentifier, 0, $homePageDelimiterPosition);
137  }
138  $noRouteIdentifier = $this->_scopeConfig->getValue(
139  'web/default/cms_no_route',
141  );
142  $noRouteDelimiterPosition = strrpos($noRouteIdentifier, '|');
143  if ($noRouteDelimiterPosition) {
144  $noRouteIdentifier = substr($noRouteIdentifier, 0, $noRouteDelimiterPosition);
145  }
146  if ($this->_scopeConfig->getValue('web/default/show_cms_breadcrumbs', ScopeInterface::SCOPE_STORE)
147  && ($breadcrumbsBlock = $this->getLayout()->getBlock('breadcrumbs'))
148  && $page->getIdentifier() !== $homePageIdentifier
149  && $page->getIdentifier() !== $noRouteIdentifier
150  ) {
151  $breadcrumbsBlock->addCrumb(
152  'home',
153  [
154  'label' => __('Home'),
155  'title' => __('Go to Home Page'),
156  'link' => $this->_storeManager->getStore()->getBaseUrl()
157  ]
158  );
159  $breadcrumbsBlock->addCrumb('cms_page', ['label' => $page->getTitle(), 'title' => $page->getTitle()]);
160  }
161  }
__()
Definition: __.php:13
$page
Definition: pages.php:8

◆ _prepareLayout()

_prepareLayout ( )
protected

Prepare global layout

Returns
$this

Definition at line 102 of file Page.php.

103  {
104  $page = $this->getPage();
105  $this->_addBreadcrumbs($page);
106  $this->pageConfig->addBodyClass('cms-' . $page->getIdentifier());
107  $metaTitle = $page->getMetaTitle();
108  $this->pageConfig->getTitle()->set($metaTitle ? $metaTitle : $page->getTitle());
109  $this->pageConfig->setKeywords($page->getMetaKeywords());
110  $this->pageConfig->setDescription($page->getMetaDescription());
111 
112  $pageMainTitle = $this->getLayout()->getBlock('page.main.title');
113  if ($pageMainTitle) {
114  // Setting empty page title if content heading is absent
115  $cmsTitle = $page->getContentHeading() ?: ' ';
116  $pageMainTitle->setPageTitle($this->escapeHtml($cmsTitle));
117  }
118  return parent::_prepareLayout();
119  }
_addBreadcrumbs(\Magento\Cms\Model\Page $page)
Definition: Page.php:128
$page
Definition: pages.php:8

◆ _toHtml()

_toHtml ( )
protected

Prepare HTML content

Returns
string

Definition at line 168 of file Page.php.

169  {
170  $html = $this->_filterProvider->getPageFilter()->filter($this->getPage()->getContent());
171  return $html;
172  }

◆ getIdentities()

getIdentities ( )

Return identifiers for produced content

Returns
array

Implements IdentityInterface.

Definition at line 179 of file Page.php.

180  {
181  return [\Magento\Cms\Model\Page::CACHE_TAG . '_' . $this->getPage()->getId()];
182  }

Field Documentation

◆ $_filterProvider

$_filterProvider
protected

Definition at line 22 of file Page.php.

◆ $_page

$_page
protected

Definition at line 27 of file Page.php.

◆ $_pageFactory

$_pageFactory
protected

Definition at line 41 of file Page.php.

◆ $_storeManager

$_storeManager
protected

Definition at line 34 of file Page.php.

◆ $pageConfig

$pageConfig
protected

Definition at line 46 of file Page.php.


The documentation for this class was generated from the following file: