forked from magento/magento2
/
Page.php
165 lines (154 loc) · 4.81 KB
/
Page.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@magentocommerce.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
*
* @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
namespace Magento\Cms\Model;
/**
* Cms Page Model
*
* @method \Magento\Cms\Model\Resource\Page _getResource()
* @method \Magento\Cms\Model\Resource\Page getResource()
* @method string getTitle()
* @method \Magento\Cms\Model\Page setTitle(string $value)
* @method string getPageLayout()
* @method \Magento\Cms\Model\Page setPageLayout(string $value)
* @method string getMetaKeywords()
* @method \Magento\Cms\Model\Page setMetaKeywords(string $value)
* @method string getMetaDescription()
* @method \Magento\Cms\Model\Page setMetaDescription(string $value)
* @method string getIdentifier()
* @method \Magento\Cms\Model\Page setIdentifier(string $value)
* @method string getContentHeading()
* @method \Magento\Cms\Model\Page setContentHeading(string $value)
* @method string getContent()
* @method \Magento\Cms\Model\Page setContent(string $value)
* @method string getCreationTime()
* @method \Magento\Cms\Model\Page setCreationTime(string $value)
* @method string getUpdateTime()
* @method \Magento\Cms\Model\Page setUpdateTime(string $value)
* @method int getIsActive()
* @method \Magento\Cms\Model\Page setIsActive(int $value)
* @method int getSortOrder()
* @method \Magento\Cms\Model\Page setSortOrder(int $value)
* @method string getLayoutUpdateXml()
* @method \Magento\Cms\Model\Page setLayoutUpdateXml(string $value)
* @method string getCustomTheme()
* @method \Magento\Cms\Model\Page setCustomTheme(string $value)
* @method string getCustomPageLayout()
* @method \Magento\Cms\Model\Page setCustomPageLayout(string $value)
* @method string getCustomLayoutUpdateXml()
* @method \Magento\Cms\Model\Page setCustomLayoutUpdateXml(string $value)
* @method string getCustomThemeFrom()
* @method \Magento\Cms\Model\Page setCustomThemeFrom(string $value)
* @method string getCustomThemeTo()
* @method \Magento\Cms\Model\Page setCustomThemeTo(string $value)
*/
class Page extends \Magento\Framework\Model\AbstractModel implements \Magento\Framework\Object\IdentityInterface
{
/**
* No route page id
*/
const NOROUTE_PAGE_ID = 'no-route';
/**#@+
* Page's Statuses
*/
const STATUS_ENABLED = 1;
const STATUS_DISABLED = 0;
/**#@-*/
/**
* CMS page cache tag
*/
const CACHE_TAG = 'cms_page';
/**
* @var string
*/
protected $_cacheTag = 'cms_page';
/**
* Prefix of model events names
*
* @var string
*/
protected $_eventPrefix = 'cms_page';
/**
* Initialize resource model
*
* @return void
*/
protected function _construct()
{
$this->_init('Magento\Cms\Model\Resource\Page');
}
/**
* Load object data
*
* @param int|null $id
* @param string $field
* @return $this
*/
public function load($id, $field = null)
{
if (is_null($id)) {
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());
}
/**
* 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 array(self::STATUS_ENABLED => __('Enabled'), self::STATUS_DISABLED => __('Disabled'));
}
/**
* Get identities
*
* @return array
*/
public function getIdentities()
{
return array(self::CACHE_TAG . '_' . $this->getId());
}
}