1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Hateoas\Tests\Fixtures; |
4
|
|
|
|
5
|
|
|
use Hateoas\Configuration\Relation; |
6
|
|
|
use JMS\Serializer\Annotation as Serializer; |
7
|
|
|
use Hateoas\Configuration\Annotation as Hateoas; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* @Hateoas\Relation( |
11
|
|
|
* "self", |
12
|
|
|
* href = "http://adrienbrault.fr", |
13
|
|
|
* exclusion = @Hateoas\Exclusion( |
14
|
|
|
* groups = {"Default", "simple"}, |
15
|
|
|
* excludeIf = "expr(object.firstName !== 'Adrien' || object.lastName !== 'Brault')" |
16
|
|
|
* ) |
17
|
|
|
* ) |
18
|
|
|
* @Hateoas\Relation( |
19
|
|
|
* "computer", |
20
|
|
|
* href = "http://www.apple.com/macbook-pro/", |
21
|
|
|
* exclusion = @Hateoas\Exclusion(groups = {"Default", "simple"}), |
22
|
|
|
* embedded = @Hateoas\Embedded( |
23
|
|
|
* "expr(object.getMacbookPro())", |
24
|
|
|
* exclusion = @Hateoas\Exclusion(groups = {"Default"}) |
25
|
|
|
* ) |
26
|
|
|
* ) |
27
|
|
|
* @Hateoas\Relation( |
28
|
|
|
* "broken-computer", |
29
|
|
|
* embedded = "expr(object.getWindowsComputer())" |
30
|
|
|
* ) |
31
|
|
|
* @Hateoas\Relation( |
32
|
|
|
* "smartphone", |
33
|
|
|
* embedded = "expr(object.getiOSSmartphone())" |
34
|
|
|
* ) |
35
|
|
|
* @Hateoas\Relation( |
36
|
|
|
* "smartphone", |
37
|
|
|
* embedded = "expr(object.getAndroidSmartphone())" |
38
|
|
|
* ) |
39
|
|
|
* |
40
|
|
|
* @Hateoas\RelationProvider("getRelations") |
41
|
|
|
*/ |
42
|
|
|
class AdrienBrault |
43
|
|
|
{ |
44
|
|
|
/** |
45
|
|
|
* @Serializer\Groups({"Default", "simple"}) |
46
|
|
|
*/ |
47
|
|
|
public $firstName = 'Adrien'; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @Serializer\Groups({"Default", "simple"}) |
51
|
|
|
*/ |
52
|
|
|
public $lastName = 'Brault'; |
53
|
|
|
|
54
|
|
|
public function getMacbookPro() |
55
|
|
|
{ |
56
|
|
|
return new Computer('MacBook Pro'); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
public function getWindowsComputer() |
60
|
|
|
{ |
61
|
|
|
return new Computer('Windows Computer'); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
public function getiOSSmartphone() |
65
|
|
|
{ |
66
|
|
|
return new Smartphone('iPhone 6'); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
public function getAndroidSmartphone() |
70
|
|
|
{ |
71
|
|
|
return new Smartphone('Nexus 5'); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
public function getRelations() |
75
|
|
|
{ |
76
|
|
|
return array( |
77
|
|
|
new Relation('dynamic-relation', 'awesome!!!', array('wowowow')), |
78
|
|
|
); |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
|