1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace POData\ObjectModel; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Class ODataLink represents an OData Navigation Link. |
7
|
|
|
*/ |
8
|
|
|
class ODataLink |
9
|
|
|
{ |
10
|
|
|
/** |
11
|
|
|
* Name of the link. This becomes last segment of rel attribute value. |
12
|
|
|
* |
13
|
|
|
* @var string |
14
|
|
|
*/ |
15
|
|
|
public $name; |
16
|
|
|
/** |
17
|
|
|
* Title of the link. This become value of title attribute. |
18
|
|
|
* |
19
|
|
|
* @var string |
20
|
|
|
*/ |
21
|
|
|
public $title; |
22
|
|
|
/** |
23
|
|
|
* Type of link. |
24
|
|
|
* |
25
|
|
|
* @var string |
26
|
|
|
*/ |
27
|
|
|
public $type; |
28
|
|
|
/** |
29
|
|
|
* Url to the navigation property. This become value of href attribute. |
30
|
|
|
* |
31
|
|
|
* @var string |
32
|
|
|
*/ |
33
|
|
|
public $url; |
34
|
|
|
/** |
35
|
|
|
* Checks is Expand result contains single entity or collection of |
36
|
|
|
* entities i.e. feed. |
37
|
|
|
* |
38
|
|
|
* @var bool |
39
|
|
|
*/ |
40
|
|
|
public $isCollection; |
41
|
|
|
/** |
42
|
|
|
* The expanded result. This becomes the inline content of the link. |
43
|
|
|
* |
44
|
|
|
* @var ODataEntry|ODataFeed |
45
|
|
|
*/ |
46
|
|
|
public $expandedResult; |
47
|
|
|
/** |
48
|
|
|
* True if Link is Expanded, False if not. |
49
|
|
|
* |
50
|
|
|
* @var bool |
51
|
|
|
*/ |
52
|
|
|
public $isExpanded; |
53
|
|
|
/** |
54
|
|
|
* @var null |
55
|
|
|
*/ |
56
|
|
|
public $expandResult; |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @return null|\POData\ObjectModel\ODataExpandedResult |
60
|
|
|
*/ |
61
|
|
|
public function getExpandResult() |
62
|
|
|
{ |
63
|
|
|
if (!$this->isExpanded) { |
64
|
|
|
return null; |
65
|
|
|
} |
66
|
|
|
if ($this->isCollection) { |
67
|
|
|
assert($this->expandedResult instanceof ODataFeed); |
68
|
|
|
return new ODataExpandedResult(null, $this->expandedResult); |
69
|
|
|
} |
70
|
|
|
assert($this->expandedResult instanceof ODataEntry); |
71
|
|
|
return new ODataExpandedResult($this->expandedResult); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @param \POData\ObjectModel\ODataExpandedResult $eResult |
76
|
|
|
*/ |
77
|
|
|
public function setExpandResult(ODataExpandedResult $eResult) |
78
|
|
|
{ |
79
|
|
View Code Duplication |
if (null !== $eResult->feed) { |
80
|
|
|
$this->isExpanded = true; |
81
|
|
|
$this->isCollection = true; |
82
|
|
|
$this->expandedResult = $eResult->feed; |
83
|
|
|
} |
84
|
|
View Code Duplication |
if (null !== $eResult->entry) { |
85
|
|
|
$this->isExpanded = true; |
86
|
|
|
$this->isCollection = false; |
87
|
|
|
$this->expandedResult = $eResult->entry; |
88
|
|
|
} |
89
|
|
|
} |
90
|
|
|
} |
91
|
|
|
|