@@ -58,6 +58,9 @@ |
||
| 58 | 58 | |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | + /** |
|
| 62 | + * @return \Doctrine\ORM\EntityManagerInterface |
|
| 63 | + */ |
|
| 61 | 64 | public function getEntityManager() { |
| 62 | 65 | |
| 63 | 66 | if ( $this->entity_manager === null ) { |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | false |
| 85 | 85 | ]; |
| 86 | 86 | |
| 87 | - switch (strtoupper($metadata_mode)) { |
|
| 87 | + switch ( strtoupper($metadata_mode) ) { |
|
| 88 | 88 | |
| 89 | 89 | case 'YAML': |
| 90 | 90 | $db_config = Setup::createYAMLMetadataConfiguration(...$config_args); |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | $repos = $configuration->get('database-repositories'); |
| 179 | 179 | |
| 180 | 180 | return array_map(function($repo) use ($base_folder) { |
| 181 | - return substr($repo, 0, 1 ) === "/" ? $repo : "$base_folder/$repo"; |
|
| 181 | + return substr($repo, 0, 1) === "/" ? $repo : "$base_folder/$repo"; |
|
| 182 | 182 | }, $repos); |
| 183 | 183 | |
| 184 | 184 | } |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | $base_folder = $configuration->get('base-path'); |
| 189 | 189 | $folder = $configuration->get('database-proxies'); |
| 190 | 190 | |
| 191 | - return substr($folder, 0, 1 ) === "/" ? $folder : "$base_folder/$folder"; |
|
| 191 | + return substr($folder, 0, 1) === "/" ? $folder : "$base_folder/$folder"; |
|
| 192 | 192 | |
| 193 | 193 | } |
| 194 | 194 | |
@@ -41,7 +41,6 @@ |
||
| 41 | 41 | * |
| 42 | 42 | * @param Configuration $configuration |
| 43 | 43 | * @param LoggerInterface $logger |
| 44 | - * @param TasksTable $tasks |
|
| 45 | 44 | * @param EventsManager $events |
| 46 | 45 | * @param EntityManager $em |
| 47 | 46 | */ |
@@ -79,11 +79,11 @@ discard block |
||
| 79 | 79 | |
| 80 | 80 | public function flush(array $queue) { |
| 81 | 81 | |
| 82 | - $this->getEvents()->emit( new QueueEvent('flush', null, $queue) ); |
|
| 82 | + $this->getEvents()->emit(new QueueEvent('flush', null, $queue)); |
|
| 83 | 83 | |
| 84 | 84 | $em = $this->getEntityManager(); |
| 85 | 85 | |
| 86 | - foreach ($queue as $record) { |
|
| 86 | + foreach ( $queue as $record ) { |
|
| 87 | 87 | $em->remove($record); |
| 88 | 88 | } |
| 89 | 89 | |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | |
| 110 | 110 | $records = []; |
| 111 | 111 | |
| 112 | - foreach ($queue as $name => $request) { |
|
| 112 | + foreach ( $queue as $name => $request ) { |
|
| 113 | 113 | $records[] = $request instanceof Request ? $this->doAddRequest($request, $em) : false; |
| 114 | 114 | } |
| 115 | 115 | |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | |
| 122 | 122 | protected function doAddRequest(Request $request, EntityManager $em) { |
| 123 | 123 | |
| 124 | - $this->getEvents()->emit( new QueueEvent('add', $request) ); |
|
| 124 | + $this->getEvents()->emit(new QueueEvent('add', $request)); |
|
| 125 | 125 | |
| 126 | 126 | $record = new Queue(); |
| 127 | 127 | $record->setName($request->getName())->setRequest($request); |
@@ -75,12 +75,10 @@ discard block |
||
| 75 | 75 | /** |
| 76 | 76 | * Class constructor |
| 77 | 77 | * |
| 78 | - * @param string $manager_name |
|
| 79 | 78 | * @param Configuration $configuration |
| 80 | 79 | * @param LoggerInterface $logger |
| 81 | 80 | * @param TasksTable $tasks |
| 82 | 81 | * @param EventsManager $events |
| 83 | - * @param EntityManager $em |
|
| 84 | 82 | */ |
| 85 | 83 | public function __construct( |
| 86 | 84 | Locker $locker, |
@@ -413,6 +411,9 @@ discard block |
||
| 413 | 411 | |
| 414 | 412 | } |
| 415 | 413 | |
| 414 | + /** |
|
| 415 | + * @param string $message |
|
| 416 | + */ |
|
| 416 | 417 | private function generateSyntheticResult($uid, $message, $jid = null, $success = true) { |
| 417 | 418 | |
| 418 | 419 | return new Result([ |
@@ -437,6 +438,9 @@ discard block |
||
| 437 | 438 | |
| 438 | 439 | } |
| 439 | 440 | |
| 441 | + /** |
|
| 442 | + * @param null|integer $pid |
|
| 443 | + */ |
|
| 440 | 444 | private function updateTrackerSetRunning($uid, $pid) { |
| 441 | 445 | |
| 442 | 446 | $this->tracker->setRunning($uid, $pid); |
@@ -466,6 +470,9 @@ discard block |
||
| 466 | 470 | |
| 467 | 471 | } |
| 468 | 472 | |
| 473 | + /** |
|
| 474 | + * @param Result $result |
|
| 475 | + */ |
|
| 469 | 476 | private function updateTrackerSetAborted($uid, $result) { |
| 470 | 477 | |
| 471 | 478 | $this->tracker->setAborted($uid, $result); |
@@ -128,9 +128,9 @@ discard block |
||
| 128 | 128 | |
| 129 | 129 | public function addBulk(array $requests) { |
| 130 | 130 | |
| 131 | - foreach ($requests as $id => $request) { |
|
| 131 | + foreach ( $requests as $id => $request ) { |
|
| 132 | 132 | |
| 133 | - if ($request instanceof \Comodojo\Extender\Task\Request) { |
|
| 133 | + if ( $request instanceof \Comodojo\Extender\Task\Request ) { |
|
| 134 | 134 | $this->add($request); |
| 135 | 135 | } else { |
| 136 | 136 | $this->logger->error("Skipping invalid request with local id $id: class mismatch"); |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | |
| 164 | 164 | $this->installErrorHandler(); |
| 165 | 165 | |
| 166 | - foreach ($this->tracker->getQueued() as $uid => $request) { |
|
| 166 | + foreach ( $this->tracker->getQueued() as $uid => $request ) { |
|
| 167 | 167 | |
| 168 | 168 | if ( $this->multithread === false ) { |
| 169 | 169 | |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | |
| 192 | 192 | if ( $this->max_childs > 0 && $this->tracker->countRunning() >= $this->max_childs ) { |
| 193 | 193 | |
| 194 | - while( $this->tracker->countRunning() >= $this->max_childs ) { |
|
| 194 | + while ( $this->tracker->countRunning() >= $this->max_childs ) { |
|
| 195 | 195 | |
| 196 | 196 | $this->catcher(); |
| 197 | 197 | |
@@ -190,6 +190,15 @@ discard block |
||
| 190 | 190 | |
| 191 | 191 | } |
| 192 | 192 | |
| 193 | + /** |
|
| 194 | + * @param integer $uid |
|
| 195 | + * @param integer $puid |
|
| 196 | + * @param string $name |
|
| 197 | + * @param integer $jid |
|
| 198 | + * @param string $task |
|
| 199 | + * @param TaskParameters $parameters |
|
| 200 | + * @param \DateTime $start |
|
| 201 | + */ |
|
| 193 | 202 | protected function openWorklog( |
| 194 | 203 | $uid, |
| 195 | 204 | $puid, |
@@ -221,6 +230,9 @@ discard block |
||
| 221 | 230 | |
| 222 | 231 | } |
| 223 | 232 | |
| 233 | + /** |
|
| 234 | + * @param \DateTime $end |
|
| 235 | + */ |
|
| 224 | 236 | protected function closeWorklog( |
| 225 | 237 | $status, |
| 226 | 238 | $result, |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | |
| 90 | 90 | $thetask = $this->table->get($task)->getInstance($name, $parameters); |
| 91 | 91 | |
| 92 | - $this->events->emit( new TaskEvent('start', $thetask) ); |
|
| 92 | + $this->events->emit(new TaskEvent('start', $thetask)); |
|
| 93 | 93 | |
| 94 | 94 | $pid = $thetask->getPid(); |
| 95 | 95 | |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | |
| 113 | 113 | $status = Worklog::STATUS_COMPLETE; |
| 114 | 114 | |
| 115 | - $this->events->emit( new TaskEvent('complete', $thetask) ); |
|
| 115 | + $this->events->emit(new TaskEvent('complete', $thetask)); |
|
| 116 | 116 | |
| 117 | 117 | } catch (TaskException $te) { |
| 118 | 118 | |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | |
| 121 | 121 | $result = $te->getMessage(); |
| 122 | 122 | |
| 123 | - $this->events->emit( new TaskEvent('abort', $thetask) ); |
|
| 123 | + $this->events->emit(new TaskEvent('abort', $thetask)); |
|
| 124 | 124 | |
| 125 | 125 | } catch (Exception $e) { |
| 126 | 126 | |
@@ -128,13 +128,13 @@ discard block |
||
| 128 | 128 | |
| 129 | 129 | $result = $e->getMessage(); |
| 130 | 130 | |
| 131 | - $this->events->emit( new TaskEvent('error', $thetask) ); |
|
| 131 | + $this->events->emit(new TaskEvent('error', $thetask)); |
|
| 132 | 132 | |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | $this->restoreErrorHandler(); |
| 136 | 136 | |
| 137 | - $this->events->emit( new TaskEvent('stop', $thetask) ); |
|
| 137 | + $this->events->emit(new TaskEvent('stop', $thetask)); |
|
| 138 | 138 | |
| 139 | 139 | $this->stopwatch->stop(); |
| 140 | 140 | |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | |
| 169 | 169 | ob_end_clean(); |
| 170 | 170 | |
| 171 | - $this->events->emit( new TaskEvent(self::statusToEvent($status), $thetask, $result) ); |
|
| 171 | + $this->events->emit(new TaskEvent(self::statusToEvent($status), $thetask, $result)); |
|
| 172 | 172 | |
| 173 | 173 | return $result; |
| 174 | 174 | |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | $worklog->setJid($schedule); |
| 228 | 228 | } |
| 229 | 229 | |
| 230 | - $this->events->emit( new WorklogEvent('open', $worklog) ); |
|
| 230 | + $this->events->emit(new WorklogEvent('open', $worklog)); |
|
| 231 | 231 | |
| 232 | 232 | $em->persist($worklog); |
| 233 | 233 | $em->flush(); |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | $worklog->setJid($schedule); |
| 267 | 267 | } |
| 268 | 268 | |
| 269 | - $this->events->emit( new WorklogEvent('close', $worklog) ); |
|
| 269 | + $this->events->emit(new WorklogEvent('close', $worklog)); |
|
| 270 | 270 | |
| 271 | 271 | $em->persist($worklog); |
| 272 | 272 | $em->flush(); |
@@ -281,7 +281,7 @@ discard block |
||
| 281 | 281 | |
| 282 | 282 | protected function statusToEvent($status) { |
| 283 | 283 | |
| 284 | - switch ($status) { |
|
| 284 | + switch ( $status ) { |
|
| 285 | 285 | case Worklog::STATUS_COMPLETE: |
| 286 | 286 | return 'complete'; |
| 287 | 287 | break; |
@@ -44,7 +44,6 @@ |
||
| 44 | 44 | /** |
| 45 | 45 | * Tracker constructor |
| 46 | 46 | * |
| 47 | - * @param string $name |
|
| 48 | 47 | * @param Configuration $configuration |
| 49 | 48 | * @param LoggerInterface $logger |
| 50 | 49 | */ |
@@ -41,7 +41,6 @@ |
||
| 41 | 41 | * |
| 42 | 42 | * @param Configuration $configuration |
| 43 | 43 | * @param LoggerInterface $logger |
| 44 | - * @param TasksTable $tasks |
|
| 45 | 44 | * @param EventsManager $events |
| 46 | 45 | * @param EntityManager $em |
| 47 | 46 | */ |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | |
| 130 | 130 | $schedule->setFirstrun($schedule->getNextPlannedRun($time)); |
| 131 | 131 | |
| 132 | - $this->getEvents()->emit( new ScheduleEvent('add', $schedule) ); |
|
| 132 | + $this->getEvents()->emit(new ScheduleEvent('add', $schedule)); |
|
| 133 | 133 | |
| 134 | 134 | $em = $this->getEntityManager(); |
| 135 | 135 | |
@@ -147,13 +147,13 @@ discard block |
||
| 147 | 147 | $records = []; |
| 148 | 148 | $em = $this->getEntityManager(); |
| 149 | 149 | |
| 150 | - foreach ($schedules as $key => $schedule) { |
|
| 150 | + foreach ( $schedules as $key => $schedule ) { |
|
| 151 | 151 | |
| 152 | 152 | try { |
| 153 | 153 | |
| 154 | 154 | $schedule->setFirstrun($schedule->getNextPlannedRun($time)); |
| 155 | 155 | |
| 156 | - $this->getEvents()->emit( new ScheduleEvent('add', $schedule) ); |
|
| 156 | + $this->getEvents()->emit(new ScheduleEvent('add', $schedule)); |
|
| 157 | 157 | |
| 158 | 158 | $em->persist($schedule); |
| 159 | 159 | |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | |
| 188 | 188 | if ( empty($old_schedule) ) throw new Exception("Cannot find schedule with id $id"); |
| 189 | 189 | |
| 190 | - $this->getEvents()->emit( new ScheduleEvent('edit', $schedule, $old_schedule) ); |
|
| 190 | + $this->getEvents()->emit(new ScheduleEvent('edit', $schedule, $old_schedule)); |
|
| 191 | 191 | |
| 192 | 192 | $old_schedule->merge($schedule); |
| 193 | 193 | |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | |
| 208 | 208 | if ( is_null($schedule) ) throw new Exception("Cannot find scheule $id"); |
| 209 | 209 | |
| 210 | - $this->getEvents()->emit( new ScheduleEvent('remove', $schedule) ); |
|
| 210 | + $this->getEvents()->emit(new ScheduleEvent('remove', $schedule)); |
|
| 211 | 211 | |
| 212 | 212 | $em->remove($schedule); |
| 213 | 213 | |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | |
| 226 | 226 | if ( is_null($schedule) ) throw new Exception("Cannot find scheule $name"); |
| 227 | 227 | |
| 228 | - $this->getEvents()->emit( new ScheduleEvent('remove', $schedule) ); |
|
| 228 | + $this->getEvents()->emit(new ScheduleEvent('remove', $schedule)); |
|
| 229 | 229 | |
| 230 | 230 | $em->remove($schedule); |
| 231 | 231 | |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | |
| 244 | 244 | if ( is_null($schedule) ) throw new Exception("Cannot find scheule $id"); |
| 245 | 245 | |
| 246 | - $this->getEvents()->emit( new ScheduleEvent('enable', $schedule) ); |
|
| 246 | + $this->getEvents()->emit(new ScheduleEvent('enable', $schedule)); |
|
| 247 | 247 | |
| 248 | 248 | $schedule->setEnabled(true); |
| 249 | 249 | |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | |
| 264 | 264 | if ( is_null($schedule) ) throw new Exception("Cannot find scheule $name"); |
| 265 | 265 | |
| 266 | - $this->getEvents()->emit( new ScheduleEvent('enable', $schedule) ); |
|
| 266 | + $this->getEvents()->emit(new ScheduleEvent('enable', $schedule)); |
|
| 267 | 267 | |
| 268 | 268 | $schedule->setEnabled(true); |
| 269 | 269 | |
@@ -283,7 +283,7 @@ discard block |
||
| 283 | 283 | |
| 284 | 284 | if ( is_null($schedule) ) throw new Exception("Cannot find scheule $id"); |
| 285 | 285 | |
| 286 | - $this->getEvents()->emit( new ScheduleEvent('disable', $schedule) ); |
|
| 286 | + $this->getEvents()->emit(new ScheduleEvent('disable', $schedule)); |
|
| 287 | 287 | |
| 288 | 288 | $schedule->setEnabled(false); |
| 289 | 289 | |
@@ -303,7 +303,7 @@ discard block |
||
| 303 | 303 | |
| 304 | 304 | if ( is_null($schedule) ) throw new Exception("Cannot find scheule $name"); |
| 305 | 305 | |
| 306 | - $this->getEvents()->emit( new ScheduleEvent('disable', $schedule) ); |
|
| 306 | + $this->getEvents()->emit(new ScheduleEvent('disable', $schedule)); |
|
| 307 | 307 | |
| 308 | 308 | $schedule->setEnabled(false); |
| 309 | 309 | |
@@ -38,9 +38,7 @@ |
||
| 38 | 38 | * |
| 39 | 39 | * @param Configuration $configuration |
| 40 | 40 | * @param LoggerInterface $logger |
| 41 | - * @param TasksTable $tasks |
|
| 42 | 41 | * @param EventsManager $events |
| 43 | - * @param EntityManager $em |
|
| 44 | 42 | */ |
| 45 | 43 | public function __construct( |
| 46 | 44 | Configuration $configuration, |
@@ -34,14 +34,14 @@ |
||
| 34 | 34 | use EventsTrait; |
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | - * Class constructor |
|
| 38 | - * |
|
| 39 | - * @param Configuration $configuration |
|
| 40 | - * @param LoggerInterface $logger |
|
| 41 | - * @param TasksTable $tasks |
|
| 42 | - * @param EventsManager $events |
|
| 43 | - * @param EntityManager $em |
|
| 44 | - */ |
|
| 37 | + * Class constructor |
|
| 38 | + * |
|
| 39 | + * @param Configuration $configuration |
|
| 40 | + * @param LoggerInterface $logger |
|
| 41 | + * @param TasksTable $tasks |
|
| 42 | + * @param EventsManager $events |
|
| 43 | + * @param EntityManager $em |
|
| 44 | + */ |
|
| 45 | 45 | public function __construct( |
| 46 | 46 | Configuration $configuration, |
| 47 | 47 | LoggerInterface $logger, |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | |
| 59 | 59 | $em = Database::init($this->getConfiguration())->getEntityManager(); |
| 60 | 60 | |
| 61 | - foreach ($results as $result) { |
|
| 61 | + foreach ( $results as $result ) { |
|
| 62 | 62 | |
| 63 | 63 | $id = $result->jid; |
| 64 | 64 | |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | $date = new DateTime(); |
| 94 | 94 | $timestamps = []; |
| 95 | 95 | |
| 96 | - foreach ($items as $schedule) { |
|
| 96 | + foreach ( $items as $schedule ) { |
|
| 97 | 97 | |
| 98 | 98 | $timestamps[] = $schedule->getNextPlannedRun($date)->getTimestamp(); |
| 99 | 99 | |
@@ -139,7 +139,7 @@ |
||
| 139 | 139 | |
| 140 | 140 | $result = []; |
| 141 | 141 | |
| 142 | - foreach($tasks as $name => $task) { |
|
| 142 | + foreach ( $tasks as $name => $task ) { |
|
| 143 | 143 | |
| 144 | 144 | if ( empty($task['class']) ) { |
| 145 | 145 | |
@@ -66,7 +66,7 @@ |
||
| 66 | 66 | |
| 67 | 67 | if ( !empty($queue) ) { |
| 68 | 68 | |
| 69 | - $events->emit( new QueueEvent('process', null, $queue) ); |
|
| 69 | + $events->emit(new QueueEvent('process', null, $queue)); |
|
| 70 | 70 | |
| 71 | 71 | $requests = $this->jobsToRequests($queue); |
| 72 | 72 | |