-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathContentInfo.php
More file actions
200 lines (162 loc) · 5.82 KB
/
ContentInfo.php
File metadata and controls
200 lines (162 loc) · 5.82 KB
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
<?php
/**
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);
namespace Ibexa\Contracts\Core\Repository\Values\Content;
use DateTimeInterface;
use Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType;
use Ibexa\Contracts\Core\Repository\Values\User\User;
use Ibexa\Contracts\Core\Repository\Values\ValueObject;
/**
* This class provides all version independent information of the Content object.
*
* @property-read int $id @deprecated 4.6.7 accessing magic getter is deprecated and will be removed in 5.0.0. Use {@see ContentInfo::getId()} instead.
* @property-read int $contentTypeId The unique id of the content type item the Content object is an instance of
* @property-read string $name @deprecated 4.6.7 accessing magic getter is deprecated and will be removed in 5.0.0. Use {@see ContentInfo::getName()} instead.
* @property-read int $sectionId @deprecated 4.6.2 Use {@see ContentInfo::getSectionId} instead. The section to which the Content object is assigned
* @property-read int $currentVersionNo Current Version number is the version number of the published version or the version number of a newly created draft (which is 1).
* @property-read bool $published true if there exists a published version false otherwise
* @property-read int $ownerId the user id of the owner of the Content object
* @property-read \DateTime $modificationDate Content object modification date
* @property-read \DateTime $publishedDate date of the first publish
* @property-read bool $alwaysAvailable Indicates if the Content object is shown in the mainlanguage if its not present in an other requested language
* @property-read string $remoteId a global unique id of the Content object
* @property-read string $mainLanguageCode The main language code of the Content object. If the available flag is set to true the Content is shown in this language if the requested language does not exist.
* @property-read int|null $mainLocationId @deprecated Use {@see ContentInfo::getMainLocationId} instead
* @property-read int $status status of the Content object
* @property-read bool $isHidden @deprecated 4.6.7 accessing magic getter is deprecated and will be removed in 5.0.0. Use {@see ContentInfo::isHidden()} instead.
*/
class ContentInfo extends ValueObject
{
public const int STATUS_DRAFT = 0;
public const int STATUS_PUBLISHED = 1;
public const int STATUS_TRASHED = 2;
/**
* The unique id of the Content object.
*/
protected int $id;
/**
* The content type id of the Content object.
*/
protected int $contentTypeId;
/**
* The computed name (via name schema) in the main language of the Content object.
*
* For names in other languages then main see {@see \Ibexa\Contracts\Core\Repository\Values\Content\VersionInfo}
*/
protected string $name;
/**
* The section to which the Content object is assigned.
*/
protected int $sectionId;
/**
* Current Version number is the version number of the published version or the version number of
* a newly created draft (which is 1).
*/
protected int $currentVersionNo;
/**
* True if there exists a published version, false otherwise.
*/
protected bool $published;
/**
* The owner of the Content object.
*/
protected int $ownerId;
/**
* Content modification date.
*/
protected ?DateTimeInterface $modificationDate;
/**
* Content publication date.
*/
protected ?DateTimeInterface $publishedDate;
/**
* Indicates if the Content object is shown in the mainlanguage if its not present in an other requested language.
*/
protected bool $alwaysAvailable = false;
/**
* Remote identifier used as a custom identifier for the object.
*/
protected string $remoteId;
/**
* The main language code of the Content object.
*/
protected string $mainLanguageCode;
/**
* Identifier of the main location.
*
* If the Content object has multiple locations,
* $mainLocationId will point to the main one.
*/
protected ?int $mainLocationId = null;
/**
* Status of the content.
*
* Replaces deprecated API\ContentInfo::$published.
*/
protected int $status;
protected bool $isHidden;
protected ContentType $contentType;
protected Section $section;
protected Language $mainLanguage;
protected ?Location $mainLocation;
protected User $owner;
public function isDraft(): bool
{
return $this->status === self::STATUS_DRAFT;
}
public function isPublished(): bool
{
return $this->status === self::STATUS_PUBLISHED;
}
public function isTrashed(): bool
{
return $this->status === self::STATUS_TRASHED;
}
public function isHidden(): bool
{
return $this->isHidden;
}
public function getContentType(): ContentType
{
return $this->contentType;
}
public function getSection(): Section
{
return $this->section;
}
public function getSectionId(): int
{
return $this->sectionId;
}
public function getMainLanguage(): Language
{
return $this->mainLanguage;
}
public function getMainLanguageCode(): string
{
return $this->mainLanguageCode;
}
public function getMainLocation(): ?Location
{
return $this->mainLocation;
}
public function getOwner(): User
{
return $this->owner;
}
public function getMainLocationId(): ?int
{
return $this->mainLocationId;
}
public function getId(): int
{
return $this->id;
}
public function getName(): string
{
return $this->name;
}
}