1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Passbook package. |
5
|
|
|
* |
6
|
|
|
* (c) Eymen Gunay <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Passbook\Pass; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Pass Structure |
16
|
|
|
* |
17
|
|
|
* @author Eymen Gunay <[email protected]> |
18
|
|
|
*/ |
19
|
|
|
class Structure implements StructureInterface |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* Fields to be displayed in the header on the front of the pass. |
23
|
|
|
* @var array |
24
|
|
|
*/ |
25
|
|
|
public $headerFields = []; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Fields to be displayed prominently on the front of the pass. |
29
|
|
|
* @var array |
30
|
|
|
*/ |
31
|
|
|
public $primaryFields = []; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Fields to be displayed on the front of the pass. |
35
|
|
|
* @var array |
36
|
|
|
*/ |
37
|
|
|
public $secondaryFields = []; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Additional fields to be displayed on the front of the pass. |
41
|
|
|
* @var array |
42
|
|
|
*/ |
43
|
|
|
public $auxiliaryFields = []; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Fields to be on the back of the pass. |
47
|
|
|
* @var array |
48
|
|
|
*/ |
49
|
|
|
public $backFields = []; |
50
|
|
|
|
51
|
6 |
|
public function toArray() |
52
|
|
|
{ |
53
|
6 |
|
$array = []; |
54
|
|
|
|
55
|
6 |
|
foreach ($this->getHeaderFields() as $headerField) { |
56
|
2 |
|
$array['headerFields'][] = $headerField->toArray(); |
57
|
|
|
} |
58
|
|
|
|
59
|
6 |
|
foreach ($this->getPrimaryFields() as $primaryField) { |
60
|
4 |
|
$array['primaryFields'][] = $primaryField->toArray(); |
61
|
|
|
} |
62
|
|
|
|
63
|
6 |
|
foreach ($this->getSecondaryFields() as $secondaryField) { |
64
|
4 |
|
$array['secondaryFields'][] = $secondaryField->toArray(); |
65
|
|
|
} |
66
|
|
|
|
67
|
6 |
|
foreach ($this->getAuxiliaryFields() as $auxiliaryField) { |
68
|
4 |
|
$array['auxiliaryFields'][] = $auxiliaryField->toArray(); |
69
|
|
|
} |
70
|
|
|
|
71
|
6 |
|
foreach ($this->getBackFields() as $backField) { |
72
|
2 |
|
$array['backFields'][] = $backField->toArray(); |
73
|
|
|
} |
74
|
|
|
|
75
|
6 |
|
return empty($array) ? (object)null : $array; |
|
|
|
|
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* {@inheritdoc} |
80
|
|
|
*/ |
81
|
2 |
|
public function addHeaderField(FieldInterface $headerField) |
82
|
|
|
{ |
83
|
2 |
|
$this->headerFields[] = $headerField; |
84
|
|
|
|
85
|
2 |
|
return $this; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* {@inheritdoc} |
90
|
|
|
*/ |
91
|
6 |
|
public function getHeaderFields() |
92
|
|
|
{ |
93
|
6 |
|
return $this->headerFields; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* {@inheritdoc} |
98
|
|
|
*/ |
99
|
4 |
|
public function addPrimaryField(FieldInterface $primaryField) |
100
|
|
|
{ |
101
|
4 |
|
$this->primaryFields[] = $primaryField; |
102
|
|
|
|
103
|
4 |
|
return $this; |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* {@inheritdoc} |
108
|
|
|
*/ |
109
|
6 |
|
public function getPrimaryFields() |
110
|
|
|
{ |
111
|
6 |
|
return $this->primaryFields; |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* {@inheritdoc} |
116
|
|
|
*/ |
117
|
4 |
|
public function addSecondaryField(FieldInterface $secondaryField) |
118
|
|
|
{ |
119
|
4 |
|
$this->secondaryFields[] = $secondaryField; |
120
|
|
|
|
121
|
4 |
|
return $this; |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* {@inheritdoc} |
126
|
|
|
*/ |
127
|
6 |
|
public function getSecondaryFields() |
128
|
|
|
{ |
129
|
6 |
|
return $this->secondaryFields; |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
/** |
133
|
|
|
* {@inheritdoc} |
134
|
|
|
*/ |
135
|
4 |
|
public function addAuxiliaryField(FieldInterface $auxiliaryField) |
136
|
|
|
{ |
137
|
4 |
|
$this->auxiliaryFields[] = $auxiliaryField; |
138
|
|
|
|
139
|
4 |
|
return $this; |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
/** |
143
|
|
|
* {@inheritdoc} |
144
|
|
|
*/ |
145
|
6 |
|
public function getAuxiliaryFields() |
146
|
|
|
{ |
147
|
6 |
|
return $this->auxiliaryFields; |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
/** |
151
|
|
|
* {@inheritdoc} |
152
|
|
|
*/ |
153
|
2 |
|
public function addBackField(FieldInterface $backField) |
154
|
|
|
{ |
155
|
2 |
|
$this->backFields[] = $backField; |
156
|
|
|
|
157
|
2 |
|
return $this; |
158
|
|
|
} |
159
|
|
|
|
160
|
|
|
/** |
161
|
|
|
* {@inheritdoc} |
162
|
|
|
*/ |
163
|
6 |
|
public function getBackFields() |
164
|
|
|
{ |
165
|
6 |
|
return $this->backFields; |
166
|
|
|
} |
167
|
|
|
} |
168
|
|
|
|