-
Notifications
You must be signed in to change notification settings - Fork 611
/
ElementTrait.php
255 lines (211 loc) · 6.42 KB
/
ElementTrait.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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
<?php
/**
* @link https://craftcms.com/
* @copyright Copyright (c) Pixel & Tonic, Inc.
* @license https://craftcms.github.io/license/
*/
namespace craft\base;
use craft\elements\db\EagerLoadInfo;
use DateTime;
/**
* ElementTrait implements the common methods and properties for element classes.
*
* @author Pixel & Tonic, Inc. <support@pixelandtonic.com>
* @since 3.0.0
*/
trait ElementTrait
{
/**
* @var ElementInterface[]|null All elements that the element was queried with.
* @since 5.0.0
*/
public ?array $elementQueryResult = null;
/**
* @var EagerLoadInfo|null Info about the eager loading setup used to query this element.
* @since 5.0.0
*/
public ?EagerLoadInfo $eagerLoadInfo = null;
/**
* @var int|null The element’s ID
*/
public ?int $id = null;
/**
* @var string|null The element’s temporary ID (only used if the element’s URI format contains {id})
*/
public ?string $tempId = null;
/**
* @var int|null The ID of the draft’s row in the `drafts` table
* @since 3.2.0
*/
public ?int $draftId = null;
/**
* @var int|null The ID of the revision’s row in the `revisions` table
* @since 3.2.0
*/
public ?int $revisionId = null;
/**
* @var bool Whether this is a provisional draft.
* @since 3.7.0
*/
public bool $isProvisionalDraft = false;
/**
* @var string|null The element’s UID
*/
public ?string $uid = null;
/**
* @var int|null The ID of the element’s record in the `elements_sites` table
* @since 3.5.2
*/
public ?int $siteSettingsId = null;
/**
* @var int|null The element’s field layout ID
*/
public ?int $fieldLayoutId = null;
/**
* @var int|null The element’s structure ID
*/
public ?int $structureId = null;
/**
* @var bool Whether the element is enabled
*/
public bool $enabled = true;
/**
* @var bool Whether the element is archived
*/
public bool $archived = false;
/**
* @var int|null The site ID the element is associated with
*/
public ?int $siteId = null;
/**
* @var string|null The element’s title
*/
public ?string $title = null;
/**
* @var string|null The element’s slug
*/
public ?string $slug = null;
/**
* @var string|null The element’s URI
*/
public ?string $uri = null;
/**
* @var DateTime|null The date that the element was created
*/
public ?DateTime $dateCreated = null;
/**
* @var DateTime|null The date that the element was last updated
*/
public ?DateTime $dateUpdated = null;
/**
* @var DateTime|null The date that the canonical element was last merged into this one
* @since 3.7.0
*/
public ?DateTime $dateLastMerged = null;
/**
* @var DateTime|null The date that the element was trashed
* @since 3.2.0
*/
public ?DateTime $dateDeleted = null;
/**
* @var bool|null Whether the element was deleted along with its owner
* @since 5.0.0
*/
public ?bool $deletedWithOwner = null;
/**
* @var int|null The element’s structure’s root ID
*/
public ?int $root = null;
/**
* @var int|null The element’s left position within its structure
*/
public ?int $lft = null;
/**
* @var int|null The element’s right position within its structure
*/
public ?int $rgt = null;
/**
* @var int|null The element’s level within its structure
*/
public ?int $level = null;
/**
* @var int|null The element’s search score, if the [[\craft\elements\db\ElementQuery::search]] parameter was used when querying for the element
*/
public ?int $searchScore = null;
/**
* @var bool Whether the element has been soft-deleted.
*/
public bool $trashed = false;
/**
* @var bool Whether the element is still awaiting its custom field values
*/
public bool $awaitingFieldValues = false;
/**
* @var bool Whether the element is being saved in the context of propagating another site's version of the element.
*/
public bool $propagating = false;
/**
* @var ElementInterface|null The element that this element is being propagated from.
* @since 5.0.0
*/
public ?ElementInterface $propagatingFrom = null;
/**
* @var bool Whether all element attributes should be propagated across all its supported sites, even if that means
* overwriting existing site-specific values.
* @since 3.2.0
*/
public bool $propagateAll = false;
/**
* @var int[] The site IDs that the element was just propagated to for the first time.
* @since 3.2.9
*/
public array $newSiteIds = [];
/**
* @var bool Whether the element is being saved to the current site for the first time.
* @since 3.7.15
*/
public bool $isNewForSite = false;
/**
* @var bool Whether the element is being resaved by a ResaveElement job or a `resave` console command.
* @since 3.1.22
*/
public bool $resaving = false;
/**
* @var ElementInterface|null The element that this element is being duplicated by.
*/
public ?ElementInterface $duplicateOf = null;
/**
* @var bool Whether the element is being saved for the first time in a normal state (not as a draft or revision).
* @since 3.7.5
*/
public bool $firstSave = false;
/**
* @var bool Whether recent changes to the canonical element are being merged into this element.
* @since 3.7.0
*/
public bool $mergingCanonicalChanges = false;
/**
* @var bool Whether the element is being updated from a derivative element, such as a draft or revision.
*
* If this is true, the derivative element can be accessed via [[duplicateOf]].
*
* @since 3.7.0
*/
public bool $updatingFromDerivative = false;
/**
* @var bool Whether the element is currently being previewed.
* @since 3.2.0
*/
public bool $previewing = false;
/**
* @var bool Whether the element should definitely be saved, if it’s a nested element being considered
* for saving by [[NestedElementManager]].
* @since 5.0.0
*/
public bool $forceSave = false;
/**
* @var bool Whether the element is being hard-deleted.
* @since 3.2.0
*/
public bool $hardDelete = false;
}