Conditions | 9 |
Paths | 28 |
Total Lines | 23 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
32 | public function run($request) |
||
33 | { |
||
34 | if (!Director::is_cli()) echo '<pre>'; |
||
35 | echo "Start migrating the order min and max\n\n"; |
||
36 | |||
37 | /** @var \CalendarEvent|TicketExtension $event */ |
||
38 | foreach (\CalendarEvent::get() as $event) { |
||
39 | if (($tickets = $event->Tickets()) && $tickets->exists()) { |
||
40 | $max = $event->OrderMax; |
||
41 | $min = $event->OrderMin; |
||
42 | /** @var Ticket $ticket */ |
||
43 | foreach ($tickets as $ticket) { |
||
44 | if (empty($ticket->OrderMax)) $ticket->OrderMax = $max; |
||
45 | if (empty($ticket->OrderMin)) $ticket->OrderMin = $min; |
||
46 | $ticket->write(); |
||
47 | echo "[$event->Title] Set order min on ticket {$ticket->Title} to [$min] and max to [$max] \n"; |
||
48 | } |
||
49 | } |
||
50 | } |
||
51 | |||
52 | echo "\n\nDone migration"; |
||
53 | if (!Director::is_cli()) echo '</pre>'; |
||
54 | } |
||
55 | } |
||
56 |