1 | <?php |
||
34 | abstract class Location extends ValueObject |
||
35 | { |
||
36 | // @todo Rename these to better fit current naming, also reuse these in Persistence or copy the change over. |
||
37 | const SORT_FIELD_PATH = 1; |
||
38 | const SORT_FIELD_PUBLISHED = 2; |
||
39 | const SORT_FIELD_MODIFIED = 3; |
||
40 | const SORT_FIELD_SECTION = 4; |
||
41 | const SORT_FIELD_DEPTH = 5; |
||
42 | const SORT_FIELD_CLASS_IDENTIFIER = 6; |
||
43 | const SORT_FIELD_CLASS_NAME = 7; |
||
44 | const SORT_FIELD_PRIORITY = 8; |
||
45 | const SORT_FIELD_NAME = 9; |
||
46 | |||
47 | /** |
||
48 | * @deprecated |
||
49 | */ |
||
50 | const SORT_FIELD_MODIFIED_SUBNODE = 10; |
||
51 | |||
52 | const SORT_FIELD_NODE_ID = 11; |
||
53 | const SORT_FIELD_CONTENTOBJECT_ID = 12; |
||
54 | |||
55 | const SORT_ORDER_DESC = 0; |
||
56 | const SORT_ORDER_ASC = 1; |
||
57 | |||
58 | const STATUS_DRAFT = 0; |
||
59 | const STATUS_PUBLISHED = 1; |
||
60 | |||
61 | /** |
||
62 | * Map for Location sort fields to their respective SortClauses. |
||
63 | * |
||
64 | * Those not here (class name/identifier and modified subnode) are |
||
65 | * missing/deprecated and will most likely be removed in the future. |
||
66 | */ |
||
67 | const SORT_FIELD_MAP = [ |
||
68 | self::SORT_FIELD_PATH => SortClause\Location\Path::class, |
||
69 | self::SORT_FIELD_PUBLISHED => SortClause\DatePublished::class, |
||
70 | self::SORT_FIELD_MODIFIED => SortClause\DateModified::class, |
||
71 | self::SORT_FIELD_SECTION => SortClause\SectionIdentifier::class, |
||
72 | self::SORT_FIELD_DEPTH => SortClause\Location\Depth::class, |
||
73 | //self::SORT_FIELD_CLASS_IDENTIFIER => false, |
||
74 | //self::SORT_FIELD_CLASS_NAME => false, |
||
75 | self::SORT_FIELD_PRIORITY => SortClause\Location\Priority::class, |
||
76 | self::SORT_FIELD_NAME => SortClause\ContentName::class, |
||
77 | //self::SORT_FIELD_MODIFIED_SUBNODE => false, |
||
78 | self::SORT_FIELD_NODE_ID => SortClause\Location\Id::class, |
||
79 | self::SORT_FIELD_CONTENTOBJECT_ID => SortClause\ContentId::class, |
||
80 | ]; |
||
81 | |||
82 | /** |
||
83 | * Map for Location sort order to their respective Query SORT constants. |
||
84 | */ |
||
85 | const SORT_ORDER_MAP = [ |
||
86 | self::SORT_ORDER_DESC => Query::SORT_DESC, |
||
87 | self::SORT_ORDER_ASC => Query::SORT_ASC, |
||
88 | ]; |
||
89 | |||
90 | /** |
||
91 | * Location ID. |
||
92 | * |
||
93 | * @var mixed Location ID. |
||
94 | */ |
||
95 | protected $id; |
||
96 | |||
97 | /** |
||
98 | * the status of the location. |
||
99 | * |
||
100 | * a location gets the status DRAFT on newly created content which is not published. When content is published the |
||
101 | * location gets the status STATUS_PUBLISHED |
||
102 | * |
||
103 | * @var int |
||
104 | */ |
||
105 | public $status = self::STATUS_PUBLISHED; |
||
106 | |||
107 | /** |
||
108 | * Location priority. |
||
109 | * |
||
110 | * Position of the Location among its siblings when sorted using priority |
||
111 | * sort order. |
||
112 | * |
||
113 | * @var int |
||
114 | */ |
||
115 | protected $priority; |
||
116 | |||
117 | /** |
||
118 | * Indicates that the Location entity has been explicitly marked as hidden. |
||
119 | * |
||
120 | * @var bool |
||
121 | */ |
||
122 | protected $hidden; |
||
123 | |||
124 | /** |
||
125 | * Indicates that the Location is implicitly marked as hidden by a parent |
||
126 | * location. |
||
127 | * |
||
128 | * @var bool |
||
129 | */ |
||
130 | protected $invisible; |
||
131 | |||
132 | /** |
||
133 | * Remote ID. |
||
134 | * |
||
135 | * A universally unique identifier. |
||
136 | * |
||
137 | * @var mixed |
||
138 | */ |
||
139 | protected $remoteId; |
||
140 | |||
141 | /** |
||
142 | * Returns the content info of the content object of this location. |
||
143 | * |
||
144 | * @return \eZ\Publish\API\Repository\Values\Content\ContentInfo |
||
145 | */ |
||
146 | abstract public function getContentInfo(); |
||
147 | |||
148 | /** |
||
149 | * Returns true if current location is a draft. |
||
150 | * |
||
151 | * @return bool |
||
152 | */ |
||
153 | public function isDraft() |
||
157 | |||
158 | /** |
||
159 | * Parent ID. |
||
160 | * |
||
161 | * @var mixed Location ID. |
||
162 | */ |
||
163 | protected $parentLocationId; |
||
164 | |||
165 | /** |
||
166 | * The materialized path of the location entry, eg: /1/2/. |
||
167 | * |
||
168 | * @var string |
||
169 | */ |
||
170 | protected $pathString; |
||
171 | |||
172 | /** |
||
173 | * Depth location has in the location tree. |
||
174 | * |
||
175 | * @var int |
||
176 | */ |
||
177 | protected $depth; |
||
178 | |||
179 | /** |
||
180 | * Specifies which property the child locations should be sorted on. |
||
181 | * |
||
182 | * Valid values are found at {@link Location::SORT_FIELD_*} |
||
183 | * |
||
184 | * @var mixed |
||
185 | */ |
||
186 | protected $sortField; |
||
187 | |||
188 | /** |
||
189 | * Specifies whether the sort order should be ascending or descending. |
||
190 | * |
||
191 | * Valid values are {@link Location::SORT_ORDER_*} |
||
192 | * |
||
193 | * @var mixed |
||
194 | */ |
||
195 | protected $sortOrder; |
||
196 | |||
197 | /** |
||
198 | * Get SortClause objects built from Locations's sort options. |
||
199 | * |
||
200 | * @throws NotImplementedException If sort field has a deprecated/unsupported value which does not have a Sort Clause. |
||
201 | * |
||
202 | * @return \eZ\Publish\API\Repository\Values\Content\Query\SortClause[] |
||
203 | */ |
||
204 | public function getSortClauses() |
||
218 | } |
||
219 |