Conditions | 1 |
Paths | 1 |
Total Lines | 183 |
Code Lines | 144 |
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 |
||
38 | protected function __construct($timezone) |
||
39 | { |
||
40 | $this->singular_item = esc_html__('Ticket', 'event_espresso'); |
||
41 | $this->plural_item = esc_html__('Tickets', 'event_espresso'); |
||
42 | $this->_tables = array( |
||
43 | 'Ticket' => new EE_Primary_Table('esp_ticket', 'TKT_ID'), |
||
44 | ); |
||
45 | $this->_fields = array( |
||
46 | 'Ticket' => array( |
||
47 | 'TKT_ID' => new EE_Primary_Key_Int_Field( |
||
48 | 'TKT_ID', |
||
49 | esc_html__('Ticket ID', 'event_espresso') |
||
50 | ), |
||
51 | 'TTM_ID' => new EE_Foreign_Key_Int_Field( |
||
52 | 'TTM_ID', |
||
53 | esc_html__('Ticket Template ID', 'event_espresso'), |
||
54 | false, |
||
55 | 0, |
||
56 | 'Ticket_Template' |
||
57 | ), |
||
58 | 'TKT_name' => new EE_Plain_Text_Field( |
||
59 | 'TKT_name', |
||
60 | esc_html__('Ticket Name', 'event_espresso'), |
||
61 | false, |
||
62 | '' |
||
63 | ), |
||
64 | 'TKT_description' => new EE_Post_Content_Field( |
||
65 | 'TKT_description', |
||
66 | esc_html__('Description of Ticket', 'event_espresso'), |
||
67 | false, |
||
68 | '' |
||
69 | ), |
||
70 | 'TKT_start_date' => new EE_Datetime_Field( |
||
71 | 'TKT_start_date', |
||
72 | esc_html__('Start time/date of Ticket', 'event_espresso'), |
||
73 | false, |
||
74 | EE_Datetime_Field::now, |
||
75 | $timezone |
||
76 | ), |
||
77 | 'TKT_end_date' => new EE_Datetime_Field( |
||
78 | 'TKT_end_date', |
||
79 | esc_html__('End time/date of Ticket', 'event_espresso'), |
||
80 | false, |
||
81 | EE_Datetime_Field::now, |
||
82 | $timezone |
||
83 | ), |
||
84 | 'TKT_min' => new EE_Integer_Field( |
||
85 | 'TKT_min', |
||
86 | esc_html__('Minimum quantity of this ticket that must be purchased', 'event_espresso'), |
||
87 | false, |
||
88 | 0 |
||
89 | ), |
||
90 | 'TKT_max' => new EE_Infinite_Integer_Field( |
||
91 | 'TKT_max', |
||
92 | esc_html__( |
||
93 | 'Maximum quantity of this ticket that can be purchased in one transaction', |
||
94 | 'event_espresso' |
||
95 | ), |
||
96 | false, |
||
97 | EE_INF |
||
98 | ), |
||
99 | 'TKT_price' => new EE_Money_Field( |
||
100 | 'TKT_price', |
||
101 | esc_html__('Final calculated price for ticket', 'event_espresso'), |
||
102 | false, |
||
103 | 0 |
||
104 | ), |
||
105 | 'TKT_sold' => new EE_Integer_Field( |
||
106 | 'TKT_sold', |
||
107 | esc_html__('Number of this ticket sold', 'event_espresso'), |
||
108 | false, |
||
109 | 0 |
||
110 | ), |
||
111 | 'TKT_qty' => new EE_Infinite_Integer_Field( |
||
112 | 'TKT_qty', |
||
113 | esc_html__('Quantity of this ticket that is available', 'event_espresso'), |
||
114 | false, |
||
115 | EE_INF |
||
116 | ), |
||
117 | 'TKT_reserved' => new EE_Integer_Field( |
||
118 | 'TKT_reserved', |
||
119 | esc_html__( |
||
120 | 'Quantity of this ticket that is reserved, but not yet fully purchased', |
||
121 | 'event_espresso' |
||
122 | ), |
||
123 | false, |
||
124 | 0 |
||
125 | ), |
||
126 | 'TKT_uses' => new EE_Infinite_Integer_Field( |
||
127 | 'TKT_uses', |
||
128 | esc_html__('Number of datetimes this ticket can be used at', 'event_espresso'), |
||
129 | false, |
||
130 | EE_INF |
||
131 | ), |
||
132 | 'TKT_required' => new EE_Boolean_Field( |
||
133 | 'TKT_required', |
||
134 | esc_html__( |
||
135 | 'Flag indicating whether this ticket must be purchased with a transaction', |
||
136 | 'event_espresso' |
||
137 | ), |
||
138 | false, |
||
139 | false |
||
140 | ), |
||
141 | 'TKT_taxable' => new EE_Boolean_Field( |
||
142 | 'TKT_taxable', |
||
143 | esc_html__( |
||
144 | 'Flag indicating whether there is tax applied on this ticket', |
||
145 | 'event_espresso' |
||
146 | ), |
||
147 | false, |
||
148 | false |
||
149 | ), |
||
150 | 'TKT_is_default' => new EE_Boolean_Field( |
||
151 | 'TKT_is_default', |
||
152 | esc_html__('Flag indicating that this ticket is a default ticket', 'event_espresso'), |
||
153 | false, |
||
154 | false |
||
155 | ), |
||
156 | 'TKT_order' => new EE_Integer_Field( |
||
157 | 'TKT_order', |
||
158 | esc_html__( |
||
159 | 'The order in which the Ticket is displayed in the editor (used for autosaves when the form doesn\'t have the ticket ID yet)', |
||
160 | 'event_espresso' |
||
161 | ), |
||
162 | false, |
||
163 | 0 |
||
164 | ), |
||
165 | 'TKT_row' => new EE_Integer_Field( |
||
166 | 'TKT_row', |
||
167 | esc_html__('How tickets are displayed in the ui', 'event_espresso'), |
||
168 | false, |
||
169 | 0 |
||
170 | ), |
||
171 | 'TKT_deleted' => new EE_Trashed_Flag_Field( |
||
172 | 'TKT_deleted', |
||
173 | esc_html__('Flag indicating if this has been archived or not', 'event_espresso'), |
||
174 | false, |
||
175 | false |
||
176 | ), |
||
177 | 'TKT_wp_user' => new EE_WP_User_Field( |
||
178 | 'TKT_wp_user', |
||
179 | esc_html__('Ticket Creator ID', 'event_espresso'), |
||
180 | false |
||
181 | ), |
||
182 | 'TKT_parent' => new EE_Integer_Field( |
||
183 | 'TKT_parent', |
||
184 | esc_html__( |
||
185 | 'Indicates what TKT_ID is the parent of this TKT_ID (used in autosaves/revisions)', |
||
186 | 'event_espresso' |
||
187 | ), |
||
188 | true, |
||
189 | 0 |
||
190 | ), |
||
191 | ), |
||
192 | ); |
||
193 | $this->_model_relations = array( |
||
194 | 'Datetime' => new EE_HABTM_Relation('Datetime_Ticket'), |
||
195 | 'Datetime_Ticket' => new EE_Has_Many_Relation(), |
||
196 | 'Price' => new EE_HABTM_Relation('Ticket_Price'), |
||
197 | 'Ticket_Template' => new EE_Belongs_To_Relation(), |
||
198 | 'Registration' => new EE_Has_Many_Relation(), |
||
199 | 'WP_User' => new EE_Belongs_To_Relation(), |
||
200 | ); |
||
201 | //this model is generally available for reading |
||
202 | $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Default_Public( |
||
203 | 'TKT_is_default', |
||
204 | 'Datetime.Event' |
||
205 | ); |
||
206 | //account for default tickets in the caps |
||
207 | $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Default_Protected( |
||
208 | 'TKT_is_default', |
||
209 | 'Datetime.Event' |
||
210 | ); |
||
211 | $this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Default_Protected( |
||
212 | 'TKT_is_default', |
||
213 | 'Datetime.Event' |
||
214 | ); |
||
215 | $this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Default_Protected( |
||
216 | 'TKT_is_default', |
||
217 | 'Datetime.Event' |
||
218 | ); |
||
219 | parent::__construct($timezone); |
||
220 | } |
||
221 | |||
341 |