1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* This file is part of the reva2/jsonapi. |
4
|
|
|
* |
5
|
|
|
* (c) Sergey Revenko <[email protected]> |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
8
|
|
|
* file that was distributed with this source code. |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
|
12
|
|
|
namespace Reva2\JsonApi\Decoders\Mapping; |
13
|
|
|
|
14
|
|
|
use Reva2\JsonApi\Contracts\Decoders\Mapping\DocumentMetadataInterface; |
15
|
|
|
use Reva2\JsonApi\Contracts\Decoders\Mapping\PropertyMetadataInterface; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* JSON API document metadata |
19
|
|
|
* |
20
|
|
|
* @package Reva2\JsonApi\Decoders\Mapping |
21
|
|
|
* @author Sergey Revenko <[email protected]> |
22
|
|
|
*/ |
23
|
|
|
class DocumentMetadata extends GenericMetadata implements DocumentMetadataInterface |
24
|
|
|
{ |
25
|
|
|
/** |
26
|
|
|
* @var PropertyMetadataInterface |
27
|
|
|
* @internal |
28
|
|
|
*/ |
29
|
|
|
public $content; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @var PropertyMetadataInterface |
33
|
|
|
* @internal |
34
|
|
|
*/ |
35
|
|
|
public $metadata; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @var bool |
39
|
|
|
* @internal |
40
|
|
|
*/ |
41
|
|
|
public $allowEmpty = false; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @inheritdoc |
45
|
|
|
*/ |
46
|
4 |
|
public function getContentMetadata() |
47
|
|
|
{ |
48
|
4 |
|
return $this->content; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Sets metadata for document content |
53
|
|
|
* |
54
|
|
|
* @param PropertyMetadataInterface $metadata |
55
|
|
|
* @return $this |
56
|
|
|
*/ |
57
|
4 |
|
public function setContentMetadata(PropertyMetadataInterface $metadata) |
58
|
|
|
{ |
59
|
4 |
|
$this->content = $metadata; |
60
|
|
|
|
61
|
4 |
|
return $this; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @return PropertyMetadataInterface |
66
|
|
|
*/ |
67
|
3 |
|
public function getMetadata() |
68
|
|
|
{ |
69
|
3 |
|
return $this->metadata; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @param PropertyMetadataInterface $metadata |
74
|
|
|
* @return DocumentMetadata |
75
|
|
|
*/ |
76
|
3 |
|
public function setMetadata($metadata) |
77
|
|
|
{ |
78
|
3 |
|
$this->metadata = $metadata; |
79
|
|
|
|
80
|
3 |
|
return $this; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @inheritdoc |
85
|
|
|
*/ |
86
|
1 |
|
public function isAllowEmpty() |
87
|
|
|
{ |
88
|
1 |
|
return $this->allowEmpty; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* Sets value of flag which show that document can be empty |
93
|
|
|
* |
94
|
|
|
* @param bool $allow |
95
|
|
|
* @return $this |
96
|
|
|
*/ |
97
|
4 |
|
public function setAllowEmpty($allow) |
98
|
|
|
{ |
99
|
4 |
|
$this->allowEmpty = $allow; |
100
|
|
|
|
101
|
4 |
|
return $this; |
102
|
|
|
} |
103
|
|
|
} |
104
|
|
|
|