_init(\Magento\Cms\Model\ResourceModel\Page::class); } /** * Load object data * * @param int|null $id * @param string $field * @return $this */ public function load($id, $field = null) { if ($id === null) { return $this->noRoutePage(); } return parent::load($id, $field); } /** * Load No-Route Page * * @return \Magento\Cms\Model\Page */ public function noRoutePage() { return $this->load(self::NOROUTE_PAGE_ID, $this->getIdFieldName()); } /** * Receive page store ids * * @return int[] */ public function getStores() { return $this->hasData('stores') ? $this->getData('stores') : (array)$this->getData('store_id'); } /** * Check if page identifier exist for specific store * return page id if page exists * * @param string $identifier * @param int $storeId * @return int */ public function checkIdentifier($identifier, $storeId) { return $this->_getResource()->checkIdentifier($identifier, $storeId); } /** * Prepare page's statuses. * Available event cms_page_get_available_statuses to customize statuses. * * @return array */ public function getAvailableStatuses() { return [self::STATUS_ENABLED => __('Enabled'), self::STATUS_DISABLED => __('Disabled')]; } /** * Get identities * * @return array */ public function getIdentities() { return [self::CACHE_TAG . '_' . $this->getId()]; } /** * Get ID * * @return int */ public function getId() { return parent::getData(self::PAGE_ID); } /** * Get identifier * * @return string */ public function getIdentifier() { return $this->getData(self::IDENTIFIER); } /** * Get title * * @return string */ public function getTitle() { return $this->getData(self::TITLE); } /** * Get page layout * * @return string */ public function getPageLayout() { return $this->getData(self::PAGE_LAYOUT); } /** * Get meta title * * @return string|null * @since 101.0.0 */ public function getMetaTitle() { return $this->getData(self::META_TITLE); } /** * Get meta keywords * * @return string */ public function getMetaKeywords() { return $this->getData(self::META_KEYWORDS); } /** * Get meta description * * @return string */ public function getMetaDescription() { return $this->getData(self::META_DESCRIPTION); } /** * Get content heading * * @return string */ public function getContentHeading() { return $this->getData(self::CONTENT_HEADING); } /** * Get content * * @return string */ public function getContent() { return $this->getData(self::CONTENT); } /** * Get creation time * * @return string */ public function getCreationTime() { return $this->getData(self::CREATION_TIME); } /** * Get update time * * @return string */ public function getUpdateTime() { return $this->getData(self::UPDATE_TIME); } /** * Get sort order * * @return string */ public function getSortOrder() { return $this->getData(self::SORT_ORDER); } /** * Get layout update xml * * @return string */ public function getLayoutUpdateXml() { return $this->getData(self::LAYOUT_UPDATE_XML); } /** * Get custom theme * * @return string */ public function getCustomTheme() { return $this->getData(self::CUSTOM_THEME); } /** * Get custom root template * * @return string */ public function getCustomRootTemplate() { return $this->getData(self::CUSTOM_ROOT_TEMPLATE); } /** * Get custom layout update xml * * @return string */ public function getCustomLayoutUpdateXml() { return $this->getData(self::CUSTOM_LAYOUT_UPDATE_XML); } /** * Get custom theme from * * @return string */ public function getCustomThemeFrom() { return $this->getData(self::CUSTOM_THEME_FROM); } /** * Get custom theme to * * @return string */ public function getCustomThemeTo() { return $this->getData(self::CUSTOM_THEME_TO); } /** * Is active * * @return bool */ public function isActive() { return (bool)$this->getData(self::IS_ACTIVE); } /** * Set ID * * @param int $id * @return \Magento\Cms\Api\Data\PageInterface */ public function setId($id) { return $this->setData(self::PAGE_ID, $id); } /** * Set identifier * * @param string $identifier * @return \Magento\Cms\Api\Data\PageInterface */ public function setIdentifier($identifier) { return $this->setData(self::IDENTIFIER, $identifier); } /** * Set title * * @param string $title * @return \Magento\Cms\Api\Data\PageInterface */ public function setTitle($title) { return $this->setData(self::TITLE, $title); } /** * Set page layout * * @param string $pageLayout * @return \Magento\Cms\Api\Data\PageInterface */ public function setPageLayout($pageLayout) { return $this->setData(self::PAGE_LAYOUT, $pageLayout); } /** * Set meta title * * @param string $metaTitle * @return \Magento\Cms\Api\Data\PageInterface * @since 101.0.0 */ public function setMetaTitle($metaTitle) { return $this->setData(self::META_TITLE, $metaTitle); } /** * Set meta keywords * * @param string $metaKeywords * @return \Magento\Cms\Api\Data\PageInterface */ public function setMetaKeywords($metaKeywords) { return $this->setData(self::META_KEYWORDS, $metaKeywords); } /** * Set meta description * * @param string $metaDescription * @return \Magento\Cms\Api\Data\PageInterface */ public function setMetaDescription($metaDescription) { return $this->setData(self::META_DESCRIPTION, $metaDescription); } /** * Set content heading * * @param string $contentHeading * @return \Magento\Cms\Api\Data\PageInterface */ public function setContentHeading($contentHeading) { return $this->setData(self::CONTENT_HEADING, $contentHeading); } /** * Set content * * @param string $content * @return \Magento\Cms\Api\Data\PageInterface */ public function setContent($content) { return $this->setData(self::CONTENT, $content); } /** * Set creation time * * @param string $creationTime * @return \Magento\Cms\Api\Data\PageInterface */ public function setCreationTime($creationTime) { return $this->setData(self::CREATION_TIME, $creationTime); } /** * Set update time * * @param string $updateTime * @return \Magento\Cms\Api\Data\PageInterface */ public function setUpdateTime($updateTime) { return $this->setData(self::UPDATE_TIME, $updateTime); } /** * Set sort order * * @param string $sortOrder * @return \Magento\Cms\Api\Data\PageInterface */ public function setSortOrder($sortOrder) { return $this->setData(self::SORT_ORDER, $sortOrder); } /** * Set layout update xml * * @param string $layoutUpdateXml * @return \Magento\Cms\Api\Data\PageInterface */ public function setLayoutUpdateXml($layoutUpdateXml) { return $this->setData(self::LAYOUT_UPDATE_XML, $layoutUpdateXml); } /** * Set custom theme * * @param string $customTheme * @return \Magento\Cms\Api\Data\PageInterface */ public function setCustomTheme($customTheme) { return $this->setData(self::CUSTOM_THEME, $customTheme); } /** * Set custom root template * * @param string $customRootTemplate * @return \Magento\Cms\Api\Data\PageInterface */ public function setCustomRootTemplate($customRootTemplate) { return $this->setData(self::CUSTOM_ROOT_TEMPLATE, $customRootTemplate); } /** * Set custom layout update xml * * @param string $customLayoutUpdateXml * @return \Magento\Cms\Api\Data\PageInterface */ public function setCustomLayoutUpdateXml($customLayoutUpdateXml) { return $this->setData(self::CUSTOM_LAYOUT_UPDATE_XML, $customLayoutUpdateXml); } /** * Set custom theme from * * @param string $customThemeFrom * @return \Magento\Cms\Api\Data\PageInterface */ public function setCustomThemeFrom($customThemeFrom) { return $this->setData(self::CUSTOM_THEME_FROM, $customThemeFrom); } /** * Set custom theme to * * @param string $customThemeTo * @return \Magento\Cms\Api\Data\PageInterface */ public function setCustomThemeTo($customThemeTo) { return $this->setData(self::CUSTOM_THEME_TO, $customThemeTo); } /** * Set is active * * @param int|bool $isActive * @return \Magento\Cms\Api\Data\PageInterface */ public function setIsActive($isActive) { return $this->setData(self::IS_ACTIVE, $isActive); } /** * {@inheritdoc} * @since 101.0.0 */ public function beforeSave() { $originalIdentifier = $this->getOrigData('identifier'); $currentIdentifier = $this->getIdentifier(); if ($this->hasDataChanges()) { $this->setUpdateTime(null); } if (!$this->getId() || $originalIdentifier === $currentIdentifier) { return parent::beforeSave(); } switch ($originalIdentifier) { case $this->getScopeConfig()->getValue(PageHelper::XML_PATH_NO_ROUTE_PAGE): throw new LocalizedException( __('This identifier is reserved for "CMS No Route Page" in configuration.') ); case $this->getScopeConfig()->getValue(PageHelper::XML_PATH_HOME_PAGE): throw new LocalizedException(__('This identifier is reserved for "CMS Home Page" in configuration.')); case $this->getScopeConfig()->getValue(PageHelper::XML_PATH_NO_COOKIES_PAGE): throw new LocalizedException( __('This identifier is reserved for "CMS No Cookies Page" in configuration.') ); } return parent::beforeSave(); } /** * @return ScopeConfigInterface */ private function getScopeConfig() { if (null === $this->scopeConfig) { $this->scopeConfig = \Magento\Framework\App\ObjectManager::getInstance()->get(ScopeConfigInterface::class); } return $this->scopeConfig; } }