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