1 | <?php |
||
11 | class RealTimeActionScheduler |
||
12 | { |
||
13 | /** @var Container **/ |
||
14 | protected $container; |
||
15 | /** @var TaskManager **/ |
||
16 | protected $taskManager; |
||
17 | /** @var LoadBalancer **/ |
||
18 | protected $loadBalancer; |
||
19 | /** @var ProcessGateway **/ |
||
20 | protected $processGateway; |
||
21 | /** @var array **/ |
||
22 | protected $queue = []; |
||
23 | |||
24 | /** |
||
25 | * @param Container $container |
||
26 | */ |
||
27 | public function __construct(Container $container) |
||
34 | |||
35 | public function init() |
||
36 | { |
||
37 | $this->container->get('ares.commander_manager')->scheduleMovements(); |
||
38 | $this->container->get('athena.building_queue_manager')->scheduleActions(); |
||
39 | $this->container->get('athena.commercial_shipping_manager')->scheduleShippings(); |
||
40 | $this->container->get('athena.recycling_mission_manager')->scheduleMissions(); |
||
41 | $this->container->get('athena.ship_queue_manager')->scheduleActions(); |
||
42 | $this->container->get('promethee.technology_queue_manager')->scheduleQueues(); |
||
43 | $factionManager = $this->container->get('demeter.color_manager'); |
||
44 | $factionManager->scheduleSenateUpdate(); |
||
45 | $factionManager->scheduleCampaigns(); |
||
46 | $factionManager->scheduleElections(); |
||
47 | $factionManager->scheduleBallot(); |
||
48 | $this->execute(); |
||
49 | } |
||
50 | |||
51 | /** |
||
52 | * This method is meant to register a new action to schedule |
||
53 | * The action is put in the queue to be executed |
||
54 | * |
||
55 | * @param string $manager |
||
56 | * @param string $method |
||
57 | * @param array $object |
||
58 | * @param string $date |
||
59 | * @param array $context |
||
60 | */ |
||
61 | public function schedule($manager, $method, $object, $date, $context = null) |
||
87 | |||
88 | /** |
||
89 | * @param string $manager |
||
90 | * @param string $method |
||
91 | * @param string $objectClass |
||
92 | * @param int $objectId |
||
93 | * @param string $date |
||
94 | * @param array $context |
||
95 | */ |
||
96 | public function scheduleFromProcess($manager, $method, $objectClass, $objectId, $date, $context = null) |
||
102 | |||
103 | /** |
||
104 | * This method is meant to executed the scheduled data if their date is passed |
||
105 | * In case of cyclic actions, the scheduler will check the current hour and compare it to the last executed hour |
||
106 | */ |
||
107 | public function execute() |
||
123 | |||
124 | /** |
||
125 | * @param object $object |
||
126 | * @param string $date |
||
127 | * @param string $oldDate |
||
128 | */ |
||
129 | public function reschedule($object, $date, $oldDate) { |
||
134 | |||
135 | /** |
||
136 | * @param object $object |
||
137 | * @param string $date |
||
138 | */ |
||
139 | public function cancel($object, $date) |
||
157 | |||
158 | /** |
||
159 | * @param string $class |
||
160 | * @param int $id |
||
161 | * @param string $date |
||
162 | */ |
||
163 | public function cancelFromProcess($class, $id, $date) |
||
171 | |||
172 | /** |
||
173 | * @return array |
||
174 | */ |
||
175 | public function getQueue() |
||
179 | } |