1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* File containing the eZ\Publish\API\Repository\Values\Content\Content class. |
5
|
|
|
* |
6
|
|
|
* @copyright Copyright (C) eZ Systems AS. All rights reserved. |
7
|
|
|
* @license For full copyright and license information view LICENSE file distributed with this source code. |
8
|
|
|
*/ |
9
|
|
|
namespace eZ\Publish\API\Repository\Values\Content; |
10
|
|
|
|
11
|
|
|
use eZ\Publish\API\Repository\Values\ValueObject; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* this class represents a content object in a specific version. |
15
|
|
|
* |
16
|
|
|
* @property-read \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo convenience getter for getVersionInfo()->getContentInfo() |
17
|
|
|
* @property-read mixed $id convenience getter for retrieving the contentId: $versionInfo->contentInfo->id |
18
|
|
|
* @property-read \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo calls getVersionInfo() |
19
|
|
|
* @property-read \eZ\Publish\API\Repository\Values\Content\Field[] $fields access fields, calls getFields() |
20
|
|
|
*/ |
21
|
|
|
abstract class Content extends ValueObject |
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* Returns the VersionInfo for this version. |
25
|
|
|
* |
26
|
|
|
* @return \eZ\Publish\API\Repository\Values\Content\VersionInfo |
27
|
|
|
*/ |
28
|
|
|
abstract public function getVersionInfo(); |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Shorthand method for getVersionInfo()->getName(). |
32
|
|
|
* |
33
|
|
|
* @see \eZ\Publish\API\Repository\Values\Content\VersionInfo::getName() |
34
|
|
|
* |
35
|
|
|
* @param string|null $languageCode |
36
|
|
|
* |
37
|
|
|
* @return string|null The name for a given language, or null if $languageCode is not set |
38
|
|
|
* or does not exist. |
39
|
|
|
*/ |
40
|
|
|
public function getName($languageCode = null) |
41
|
|
|
{ |
42
|
|
|
return $this->getVersionInfo()->getName($languageCode); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Returns a field value for the given value. |
47
|
|
|
* |
48
|
|
|
* - If $languageCode is defined, |
49
|
|
|
* return if available, otherwise null |
50
|
|
|
* - If not pick using the following languages codes when applicable: |
51
|
|
|
* 1. Prioritized languages (if provided to api on object retrieval) |
52
|
|
|
* 2. Main language |
53
|
|
|
* |
54
|
|
|
* On non translatable fields this method ignores the languageCode parameter, and return main language field value. |
55
|
|
|
* |
56
|
|
|
* @param string $fieldDefIdentifier |
57
|
|
|
* @param string $languageCode |
58
|
|
|
* |
59
|
|
|
* @return \eZ\Publish\SPI\FieldType\Value|null a primitive type or a field type Value object depending on the field type. |
60
|
|
|
*/ |
61
|
|
|
abstract public function getFieldValue($fieldDefIdentifier, $languageCode = null); |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* This method returns the complete fields collection. |
65
|
|
|
* |
66
|
|
|
* @return \eZ\Publish\API\Repository\Values\Content\Field[] An array of {@link Field} |
67
|
|
|
*/ |
68
|
|
|
abstract public function getFields(); |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* This method returns the fields for a given language and non translatable fields. |
72
|
|
|
* |
73
|
|
|
* - If $languageCode is defined, return if available |
74
|
|
|
* - If not pick using prioritized languages (if provided to api on object retrieval) |
75
|
|
|
* - Otherwise return in main language |
76
|
|
|
* |
77
|
|
|
* @param string $languageCode |
78
|
|
|
* |
79
|
|
|
* @return \eZ\Publish\API\Repository\Values\Content\Field[] An array of {@link Field} with field identifier as keys |
80
|
|
|
*/ |
81
|
|
|
abstract public function getFieldsByLanguage($languageCode = null); |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* This method returns the field for a given field definition identifier and language. |
85
|
|
|
* |
86
|
|
|
* - If $languageCode is defined, |
87
|
|
|
* return if available, otherwise null |
88
|
|
|
* - If not pick using the following languages codes when applicable: |
89
|
|
|
* 1. Prioritized languages (if provided to api on object retrieval) |
90
|
|
|
* 2. Main language |
91
|
|
|
* |
92
|
|
|
* On non translatable fields this method ignores the languageCode parameter, and return main language field. |
93
|
|
|
* |
94
|
|
|
* @param string $fieldDefIdentifier |
95
|
|
|
* @param string|null $languageCode |
96
|
|
|
* |
97
|
|
|
* @return \eZ\Publish\API\Repository\Values\Content\Field|null A {@link Field} or null if nothing is found |
98
|
|
|
*/ |
99
|
|
|
abstract public function getField($fieldDefIdentifier, $languageCode = null); |
100
|
|
|
} |
101
|
|
|
|