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