Conditions | 1 |
Paths | 1 |
Total Lines | 140 |
Code Lines | 109 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
140 | protected function __construct($timezone = null, ModelFieldFactory $model_field_factory) |
||
141 | { |
||
142 | $this->singular_item = esc_html__('Attendee', 'event_espresso'); |
||
143 | $this->plural_item = esc_html__('Attendees', 'event_espresso'); |
||
144 | $this->_tables = array( |
||
145 | 'Attendee_CPT' => new EE_Primary_Table('posts', 'ID'), |
||
146 | 'Attendee_Meta' => new EE_Secondary_Table( |
||
147 | 'esp_attendee_meta', |
||
148 | 'ATTM_ID', |
||
149 | 'ATT_ID' |
||
150 | ), |
||
151 | ); |
||
152 | $this->_fields = array( |
||
153 | 'Attendee_CPT' => array( |
||
154 | 'ATT_ID' => $model_field_factory->createPrimaryKeyIntField( |
||
155 | 'ID', |
||
156 | esc_html__('Attendee ID', 'event_espresso') |
||
157 | ), |
||
158 | 'ATT_full_name' => $model_field_factory->createPlainTextField( |
||
159 | 'post_title', |
||
160 | esc_html__('Attendee Full Name', 'event_espresso'), |
||
161 | false, |
||
162 | esc_html__('Unknown', 'event_espresso') |
||
163 | ), |
||
164 | 'ATT_bio' => $model_field_factory->createPostContentField( |
||
165 | 'post_content', |
||
166 | esc_html__('Attendee Biography', 'event_espresso'), |
||
167 | false, |
||
168 | esc_html__('No Biography Provided', 'event_espresso') |
||
169 | ), |
||
170 | 'ATT_slug' => $model_field_factory->createSlugField( |
||
171 | 'post_name', |
||
172 | esc_html__('Attendee URL Slug', 'event_espresso') |
||
173 | ), |
||
174 | 'ATT_created' => $model_field_factory->createDatetimeField( |
||
175 | 'post_date', |
||
176 | esc_html__('Time Attendee Created', 'event_espresso') |
||
177 | ), |
||
178 | 'ATT_short_bio' => $model_field_factory->createSimpleHtmlField( |
||
179 | 'post_excerpt', |
||
180 | esc_html__('Attendee Short Biography', 'event_espresso'), |
||
181 | true, |
||
182 | esc_html__('No Biography Provided', 'event_espresso') |
||
183 | ), |
||
184 | 'ATT_modified' => $model_field_factory->createDatetimeField( |
||
185 | 'post_modified', |
||
186 | esc_html__('Time Attendee Last Modified', 'event_espresso') |
||
187 | ), |
||
188 | 'ATT_author' => $model_field_factory->createWpUserField( |
||
189 | 'post_author', |
||
190 | esc_html__('Creator ID of the first Event attended', 'event_espresso'), |
||
191 | false |
||
192 | ), |
||
193 | 'ATT_parent' => $model_field_factory->createDbOnlyIntField( |
||
194 | 'post_parent', |
||
195 | esc_html__('Parent Attendee (unused)', 'event_espresso'), |
||
196 | false, |
||
197 | 0 |
||
198 | ), |
||
199 | 'post_type' => $model_field_factory->createWpPostTypeField('espresso_attendees'), |
||
200 | 'status' => $model_field_factory->createWpPostStatusField( |
||
201 | 'post_status', |
||
202 | esc_html__('Attendee Status', 'event_espresso'), |
||
203 | false, |
||
204 | 'publish' |
||
205 | ), |
||
206 | ), |
||
207 | 'Attendee_Meta' => array( |
||
208 | 'ATTM_ID' => $model_field_factory->createDbOnlyIntField( |
||
209 | 'ATTM_ID', |
||
210 | esc_html__('Attendee Meta Row ID', 'event_espresso'), |
||
211 | false |
||
212 | ), |
||
213 | 'ATT_ID_fk' => $model_field_factory->createDbOnlyIntField( |
||
214 | 'ATT_ID', |
||
215 | esc_html__('Foreign Key to Attendee in Post Table', 'event_espresso'), |
||
216 | false |
||
217 | ), |
||
218 | 'ATT_fname' => $model_field_factory->createPlainTextField( |
||
219 | 'ATT_fname', |
||
220 | esc_html__('First Name', 'event_espresso') |
||
221 | ), |
||
222 | 'ATT_lname' => $model_field_factory->createPlainTextField( |
||
223 | 'ATT_lname', |
||
224 | esc_html__('Last Name', 'event_espresso') |
||
225 | ), |
||
226 | 'ATT_address' => $model_field_factory->createPlainTextField( |
||
227 | 'ATT_address', |
||
228 | esc_html__('Address Part 1', 'event_espresso') |
||
229 | ), |
||
230 | 'ATT_address2' => $model_field_factory->createPlainTextField( |
||
231 | 'ATT_address2', |
||
232 | esc_html__('Address Part 2', 'event_espresso') |
||
233 | ), |
||
234 | 'ATT_city' => $model_field_factory->createPlainTextField( |
||
235 | 'ATT_city', |
||
236 | esc_html__('City', 'event_espresso') |
||
237 | ), |
||
238 | 'STA_ID' => $model_field_factory->createForeignKeyIntField( |
||
239 | 'STA_ID', |
||
240 | esc_html__('State', 'event_espresso'), |
||
241 | true, |
||
242 | 0, |
||
243 | 'State' |
||
244 | ), |
||
245 | 'CNT_ISO' => $model_field_factory->createForeignKeyStringField( |
||
246 | 'CNT_ISO', |
||
247 | esc_html__('Country', 'event_espresso'), |
||
248 | true, |
||
249 | '', |
||
250 | 'Country' |
||
251 | ), |
||
252 | 'ATT_zip' => $model_field_factory->createPlainTextField( |
||
253 | 'ATT_zip', |
||
254 | esc_html__('ZIP/Postal Code', 'event_espresso') |
||
255 | ), |
||
256 | 'ATT_email' => $model_field_factory->createEmailField( |
||
257 | 'ATT_email', |
||
258 | esc_html__('Email Address', 'event_espresso') |
||
259 | ), |
||
260 | 'ATT_phone' => $model_field_factory->createPlainTextField( |
||
261 | 'ATT_phone', |
||
262 | esc_html__('Phone', 'event_espresso') |
||
263 | ), |
||
264 | ), |
||
265 | ); |
||
266 | $this->_model_relations = array( |
||
267 | 'Registration' => new EE_Has_Many_Relation(), |
||
268 | 'State' => new EE_Belongs_To_Relation(), |
||
269 | 'Country' => new EE_Belongs_To_Relation(), |
||
270 | 'Event' => new EE_HABTM_Relation('Registration', false), |
||
271 | 'WP_User' => new EE_Belongs_To_Relation(), |
||
272 | 'Message' => new EE_Has_Many_Any_Relation(false), |
||
273 | //allow deletion of attendees even if they have messages in the queue for them. |
||
274 | 'Term_Relationship' => new EE_Has_Many_Relation(), |
||
275 | 'Term_Taxonomy' => new EE_HABTM_Relation('Term_Relationship'), |
||
276 | ); |
||
277 | $this->_caps_slug = 'contacts'; |
||
278 | parent::__construct($timezone); |
||
279 | } |
||
280 | |||
432 |