1 | <?php |
||
8 | class OrderProcessQueue extends DataObject |
||
|
|||
9 | { |
||
10 | private static $db = array( |
||
11 | 'DeferTimeInSeconds' => 'Int', |
||
12 | 'InProcess' => 'Boolean' |
||
13 | ); |
||
14 | |||
15 | private static $has_one = array( |
||
16 | 'Order' => 'Order' |
||
17 | ); |
||
18 | |||
19 | private static $indexes = array( |
||
20 | 'OrderID' => array( |
||
21 | 'type' => 'unique', |
||
22 | 'value' => '"OrderID"' |
||
23 | ), |
||
24 | 'Created' => true, |
||
25 | 'DeferTimeInSeconds' => true |
||
26 | ); |
||
27 | |||
28 | private static $casting = array( |
||
29 | 'ToBeProcessedAt' => 'SS_Datetime' |
||
30 | ); |
||
31 | |||
32 | private static $default_sort = array( |
||
33 | 'Created' => 'DESC' |
||
34 | ); |
||
35 | |||
36 | /** |
||
37 | * standard SS variable. |
||
38 | * |
||
39 | * @var array |
||
40 | */ |
||
41 | private static $summary_fields = array( |
||
42 | 'Order.Title' => 'Order', |
||
43 | 'Order.Status.Title' => 'Current Step', |
||
44 | 'ToBeProcessedAt.Nice' => 'To be processed at', |
||
45 | 'ToBeProcessedAt.Ago' => 'That is ...', |
||
46 | 'InProcess.Nice' => 'Currently Running' |
||
47 | ); |
||
48 | |||
49 | /** |
||
50 | * standard SS variable. |
||
51 | * |
||
52 | * @var array |
||
53 | */ |
||
54 | private static $searchable_fields = array( |
||
55 | 'OrderID' => array( |
||
56 | 'field' => 'NumericField', |
||
57 | 'title' => 'Order Number', |
||
58 | ) |
||
59 | ); |
||
60 | |||
61 | |||
62 | /** |
||
63 | * Standard SS method. |
||
64 | * |
||
65 | * @param Member $member |
||
66 | * |
||
67 | * @return bool |
||
68 | */ |
||
69 | public function canCreate($member = null) |
||
73 | |||
74 | /** |
||
75 | * Standard SS method. |
||
76 | * |
||
77 | * @param Member $member |
||
78 | * |
||
79 | * @return bool |
||
80 | */ |
||
81 | public function canView($member = null) |
||
100 | |||
101 | /** |
||
102 | * Standard SS method. |
||
103 | * |
||
104 | * @param Member $member |
||
105 | * |
||
106 | * @return bool |
||
107 | */ |
||
108 | public function canEdit($member = null) |
||
112 | |||
113 | /** |
||
114 | * Standard SS method |
||
115 | * Queues can be deleted if needed. |
||
116 | * |
||
117 | * @param Member $member |
||
118 | * |
||
119 | * @return bool |
||
120 | */ |
||
121 | public function canDelete($member = null) |
||
125 | |||
126 | /** |
||
127 | * standard SS variable. |
||
128 | * |
||
129 | * @var string |
||
130 | */ |
||
131 | private static $singular_name = 'Order To Be Processed'; |
||
132 | public function i18n_singular_name() |
||
136 | |||
137 | /** |
||
138 | * standard SS variable. |
||
139 | * |
||
140 | * @var string |
||
141 | */ |
||
142 | private static $plural_name = 'Orders to be Processed'; |
||
143 | public function i18n_plural_name() |
||
147 | |||
148 | |||
149 | /** |
||
150 | * META METHOD: Add an order to the job list. |
||
151 | * If the order already exists, it will update the seconds and the creation time. |
||
152 | * |
||
153 | * @param Order $order [description] |
||
154 | * @param Int $deferInSeconds [description] |
||
155 | */ |
||
156 | public function AddOrderToQueue($order, $deferTimeInSeconds) |
||
173 | |||
174 | /** |
||
175 | * processes the order ... |
||
176 | * |
||
177 | * @param Order $order |
||
178 | */ |
||
179 | public function process($order) |
||
200 | |||
201 | /** |
||
202 | * META METHOD: returns the queue object if it exists |
||
203 | * |
||
204 | * @param Order $order |
||
205 | * |
||
206 | * @return null | OrderProcessQueue |
||
207 | */ |
||
208 | public function getQueueObject($order) |
||
214 | |||
215 | /** |
||
216 | * META METHOD: Once you are done, you can remove the item like this ... |
||
217 | * |
||
218 | * @param Order $order |
||
219 | */ |
||
220 | public function removeOrderFromQueue($order) |
||
228 | |||
229 | /** |
||
230 | * META METHOD: returns a list of orders to be processed |
||
231 | * @param int $id force this Order to be processed |
||
232 | * @param int $limit total number of orders that can be retrieved at any one time |
||
233 | * |
||
234 | * @return DataList (of orders) |
||
235 | */ |
||
236 | public function OrdersToBeProcessed($id = 0, $limit = 9999) |
||
261 | |||
262 | /** |
||
263 | * META METHOD: all orders with a queue object |
||
264 | * @param int $id force this Order to be processed |
||
265 | * @param int $limit total number of orders that can be retrieved at any one time |
||
266 | * |
||
267 | * @return DataList (of orders) |
||
268 | */ |
||
269 | public function AllOrdersInQueue($limit = 9999) |
||
277 | |||
278 | /** |
||
279 | * META METHOD: returns a list of orders NOT YET to be processed |
||
280 | * @param int $limit total number of orders that can be retrieved at any one time |
||
281 | * |
||
282 | * @return DataList (of orders) |
||
283 | */ |
||
284 | public function OrdersInQueueThatAreNotReady($limit = 9999) |
||
307 | |||
308 | /** |
||
309 | * non-database method of working out if an Order is ready to go. |
||
310 | * |
||
311 | * @return bool |
||
312 | */ |
||
313 | public function isReadyToGo() |
||
317 | |||
318 | /** |
||
319 | * |
||
320 | * casted variable |
||
321 | * @return SS_DateTime |
||
322 | */ |
||
323 | public function ToBeProcessedAt() |
||
327 | |||
328 | /** |
||
329 | * |
||
330 | * casted variable |
||
331 | * @return SS_DateTime |
||
332 | */ |
||
333 | public function getToBeProcessedAt() |
||
337 | |||
338 | |||
339 | /** |
||
340 | * CMS Fields |
||
341 | * @return FieldList |
||
342 | */ |
||
343 | public function getCMSFields() |
||
378 | } |
||
379 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.