-
Notifications
You must be signed in to change notification settings - Fork 0
/
membership_entity.inc
182 lines (158 loc) · 3.3 KB
/
membership_entity.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
<?php
/**
* @file
* Contains the MembershipEntity class.
*/
/**
* Defines a membership entity.
*/
class MembershipEntity extends Entity {
/**
* The primary identifier for a membership.
*
* @var int
*/
public $mid;
/**
* A user enterable unique member id.
*
* @var int
*/
public $member_id; // @codingStandardsIgnoreLine
/**
* The type (bundle) of membership.
*
* @var string
*/
public $type;
/**
* The primary member.
*
* @var int
*/
public $uid;
/**
* An array of secondary members.
*
* @var array
*/
public $secondary_members; // @codingStandardsIgnoreLine
/**
* Integer code indicating the membership status.
*
* @var int
*
* @see membership_entity_get_status_list().
*/
public $status;
/**
* The Unix timestamp when the membership was created.
*
* @var int
*/
public $created;
/**
* The Unix timestamp when the membership was most recently saved.
*
* @var int
*/
public $changed;
/**
* Build a new membership entity.
*/
public function __construct($values = array()) {
return parent::__construct($values);
}
/**
* Returns the entity identifier (the entity's machine name or numeric ID).
*
* @return
* The identifier of the entity, or NULL if the entity does not yet have
* an identifier.
*/
public function id() {
}
/**
* Returns the type of the entity.
*
* @return
* The type of the entity.
*/
public function entityType() {
return 'membership_entity';
}
/**
* Returns the bundle of the entity.
*
* @return
* The bundle of the entity. Defaults to the entity type if the entity type
* does not make use of different bundles.
*/
public function bundle() {
return $this->type ?? $this->entityType();
}
/**
* Returns the label of the entity.
*
* @return
* The label of the entity, or NULL if there is no label defined.
*/
public function label() {
return $this->label;
}
/**
* Returns the URI elements of the entity.
*
* @return
* An array containing the 'path' and 'options' keys used to build the URI
* of the entity, and matching the signature of url(). NULL if the entity
* has no URI of its own.
*/
public function uri() {
}
/**
* Returns the primary member.
*/
public function primaryMember() {
return user_load($this->uid);
}
/**
* Set the primary member for the membership.
*
* @param object|int $account
* The loaded account object or member uid.
*/
public function setPrimaryMember($account) {
$this->uid = is_object($account) ? $account->uid : $account;
}
/**
* Returns the full url to the membership.
*/
public function url() {
$uri = $this->uri();
return url($uri['path'], $uri);
}
/**
* Returns the Backdrop path to the membership.
*/
public function path() {
$uri = $this->uri();
return $uri['path'];
}
/**
* Overrides Entity::defaultUri().
*/
public function defaultUri() {
return array('path' => 'membership/' . $this->mid);
}
/**
* Overrides Entity::save().
*/
public function save() {
if (empty($this->created)) {
$this->created = REQUEST_TIME;
}
$this->changed = REQUEST_TIME;
return parent::save();
}
}