@@ -30,7 +30,7 @@ |
||
| 30 | 30 | |
| 31 | 31 | use DataAccessTrait; |
| 32 | 32 | |
| 33 | - public function __construct($name, $id, $task, $class, $parameters=array()) { |
|
| 33 | + public function __construct($name, $id, $task, $class, $parameters = array()) { |
|
| 34 | 34 | |
| 35 | 35 | $this->name = $name; |
| 36 | 36 | $this->id = $id; |
@@ -32,10 +32,7 @@ |
||
| 32 | 32 | * |
| 33 | 33 | * @param array $parameters Array of parameters (if any) |
| 34 | 34 | * @param \Monolog\Logger $logger |
| 35 | - * @param int $pid Task PID (if any) |
|
| 36 | 35 | * @param string $name Task Name |
| 37 | - * @param int $timestamp Start timestamp (if null will be retrieved directly) |
|
| 38 | - * @param bool $multithread Multithread switch |
|
| 39 | 36 | * |
| 40 | 37 | * @return Object $this |
| 41 | 38 | */ |
@@ -27,6 +27,7 @@ |
||
| 27 | 27 | /** |
| 28 | 28 | * Return the value at index |
| 29 | 29 | * |
| 30 | + * @param string $index |
|
| 30 | 31 | * @return string $index The offset |
| 31 | 32 | */ |
| 32 | 33 | public function offsetGet($index) { |
@@ -29,45 +29,45 @@ |
||
| 29 | 29 | * |
| 30 | 30 | * @return string $index The offset |
| 31 | 31 | */ |
| 32 | - public function offsetGet($index) { |
|
| 32 | + public function offsetGet($index) { |
|
| 33 | 33 | |
| 34 | - return $this->data[$index]; |
|
| 34 | + return $this->data[$index]; |
|
| 35 | 35 | |
| 36 | - } |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * Assigns a value to index offset |
|
| 40 | - * |
|
| 41 | - * @param string $index The offset to assign the value to |
|
| 42 | - * @param mixed $value The value to set |
|
| 43 | - */ |
|
| 44 | - public function offsetSet($index, $value) { |
|
| 38 | + /** |
|
| 39 | + * Assigns a value to index offset |
|
| 40 | + * |
|
| 41 | + * @param string $index The offset to assign the value to |
|
| 42 | + * @param mixed $value The value to set |
|
| 43 | + */ |
|
| 44 | + public function offsetSet($index, $value) { |
|
| 45 | 45 | |
| 46 | - $this->data[$index] = $value; |
|
| 46 | + $this->data[$index] = $value; |
|
| 47 | 47 | |
| 48 | - } |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * Unsets an index |
|
| 52 | - * |
|
| 53 | - * @param string $index The offset to unset |
|
| 54 | - */ |
|
| 55 | - public function offsetUnset($index) { |
|
| 50 | + /** |
|
| 51 | + * Unsets an index |
|
| 52 | + * |
|
| 53 | + * @param string $index The offset to unset |
|
| 54 | + */ |
|
| 55 | + public function offsetUnset($index) { |
|
| 56 | 56 | |
| 57 | - unset($this->data[$index]); |
|
| 57 | + unset($this->data[$index]); |
|
| 58 | 58 | |
| 59 | - } |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * Check if an index exists |
|
| 63 | - * |
|
| 64 | - * @param string $index Offset |
|
| 65 | - * @return boolean |
|
| 66 | - */ |
|
| 67 | - public function offsetExists($index) { |
|
| 61 | + /** |
|
| 62 | + * Check if an index exists |
|
| 63 | + * |
|
| 64 | + * @param string $index Offset |
|
| 65 | + * @return boolean |
|
| 66 | + */ |
|
| 67 | + public function offsetExists($index) { |
|
| 68 | 68 | |
| 69 | - return $this->offsetGet($index) !== null; |
|
| 69 | + return $this->offsetGet($index) !== null; |
|
| 70 | 70 | |
| 71 | - } |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | 73 | } |
@@ -32,10 +32,7 @@ |
||
| 32 | 32 | * |
| 33 | 33 | * @param array $parameters Array of parameters (if any) |
| 34 | 34 | * @param \Monolog\Logger $logger |
| 35 | - * @param int $pid Task PID (if any) |
|
| 36 | 35 | * @param string $name Task Name |
| 37 | - * @param int $timestamp Start timestamp (if null will be retrieved directly) |
|
| 38 | - * @param bool $multithread Multithread switch |
|
| 39 | 36 | * |
| 40 | 37 | * @return Object $this |
| 41 | 38 | */ |
@@ -95,7 +95,7 @@ |
||
| 95 | 95 | |
| 96 | 96 | $result = array(); |
| 97 | 97 | |
| 98 | - foreach($tasks as $task) { |
|
| 98 | + foreach ( $tasks as $task ) { |
|
| 99 | 99 | |
| 100 | 100 | if ( empty($task['name']) || empty($task['class']) ) { |
| 101 | 101 | |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | LoggerInterface $logger, |
| 45 | 45 | Emitter $events, |
| 46 | 46 | $niceness = null |
| 47 | - ){ |
|
| 47 | + ) { |
|
| 48 | 48 | |
| 49 | 49 | // Setup parent Model |
| 50 | 50 | parent::_construct($configuration, $logger); |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | |
| 123 | 123 | $this->logger->info("Received TERM signal, shutting down process gracefully"); |
| 124 | 124 | |
| 125 | - $this->events->emit( new SignalEvent($signal, $this) ); |
|
| 125 | + $this->events->emit(new SignalEvent($signal, $this)); |
|
| 126 | 126 | |
| 127 | 127 | $this->end(0); |
| 128 | 128 | |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | |
| 142 | 142 | $this->logger->info("Received TERM signal, shutting down process"); |
| 143 | 143 | |
| 144 | - $this->events->emit( new SignalEvent($signal, $this) ); |
|
| 144 | + $this->events->emit(new SignalEvent($signal, $this)); |
|
| 145 | 145 | |
| 146 | 146 | $this->end(1); |
| 147 | 147 | |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | |
| 161 | 161 | $this->logger->info("Received $signal signal, firing associated event(s)"); |
| 162 | 162 | |
| 163 | - $this->events->emit( new SignalEvent($signal, $this) ); |
|
| 163 | + $this->events->emit(new SignalEvent($signal, $this)); |
|
| 164 | 164 | |
| 165 | 165 | } |
| 166 | 166 | |
@@ -44,7 +44,7 @@ |
||
| 44 | 44 | LoggerInterface $logger, |
| 45 | 45 | Emitter $events, |
| 46 | 46 | $niceness = null |
| 47 | - ){ |
|
| 47 | + ) { |
|
| 48 | 48 | |
| 49 | 49 | // Setup parent Model |
| 50 | 50 | parent::_construct($configuration, $logger); |
@@ -30,6 +30,9 @@ |
||
| 30 | 30 | |
| 31 | 31 | private $task; |
| 32 | 32 | |
| 33 | + /** |
|
| 34 | + * @param string $status |
|
| 35 | + */ |
|
| 33 | 36 | public function __construct($status, TaskInterface $task) { |
| 34 | 37 | |
| 35 | 38 | $name = $task->name; |
@@ -47,21 +47,21 @@ |
||
| 47 | 47 | ->createQueryBuilder() |
| 48 | 48 | ->insert($this->table) |
| 49 | 49 | ->values(array ( |
| 50 | - 'id' => 0, |
|
| 50 | + 'id' => 0, |
|
| 51 | 51 | 'status' => '?', |
| 52 | 52 | 'pid' => '?', |
| 53 | 53 | 'name' => '?', |
| 54 | 54 | 'jid' => '?', |
| 55 | 55 | 'task' => '?', |
| 56 | - 'parameters' => '?', |
|
| 56 | + 'parameters' => '?', |
|
| 57 | 57 | 'start' => '?' |
| 58 | 58 | )) |
| 59 | 59 | ->setParameter(0, 'RUNNING') |
| 60 | - ->setParameter(1, $pid) |
|
| 60 | + ->setParameter(1, $pid) |
|
| 61 | 61 | ->setParameter(2, $name) |
| 62 | 62 | ->setParameter(3, $jobid) |
| 63 | 63 | ->setParameter(4, $task) |
| 64 | - ->setParameter(5, serialize($parameters)) |
|
| 64 | + ->setParameter(5, serialize($parameters)) |
|
| 65 | 65 | ->setParameter(6, $start) |
| 66 | 66 | ->execute(); |
| 67 | 67 | |
@@ -46,7 +46,7 @@ |
||
| 46 | 46 | $this->dbh |
| 47 | 47 | ->createQueryBuilder() |
| 48 | 48 | ->insert($this->table) |
| 49 | - ->values(array ( |
|
| 49 | + ->values(array( |
|
| 50 | 50 | 'id' => 0, |
| 51 | 51 | 'status' => '?', |
| 52 | 52 | 'pid' => '?', |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | |
| 80 | 80 | $thetask = $this->createTask($name, $task, $parameters); |
| 81 | 81 | |
| 82 | - $this->events->emit( new TaskEvent('start', $thetask) ); |
|
| 82 | + $this->events->emit(new TaskEvent('start', $thetask)); |
|
| 83 | 83 | |
| 84 | 84 | $pid = $thetask->pid; |
| 85 | 85 | |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | |
| 88 | 88 | $status = true; |
| 89 | 89 | |
| 90 | - $this->events->emit( new TaskStatusEvent('start', $thetask) ); |
|
| 90 | + $this->events->emit(new TaskStatusEvent('start', $thetask)); |
|
| 91 | 91 | |
| 92 | 92 | try { |
| 93 | 93 | |
@@ -108,11 +108,11 @@ discard block |
||
| 108 | 108 | |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | - $this->events->emit( new TaskStatusEvent($status ? 'success' : 'error', $thetask) ); |
|
| 111 | + $this->events->emit(new TaskStatusEvent($status ? 'success' : 'error', $thetask)); |
|
| 112 | 112 | |
| 113 | - $this->events->emit( new TaskStatusEvent('stop', $thetask) ); |
|
| 113 | + $this->events->emit(new TaskStatusEvent('stop', $thetask)); |
|
| 114 | 114 | |
| 115 | - $this->events->emit( new TaskEvent('stop', $thetask) ); |
|
| 115 | + $this->events->emit(new TaskEvent('stop', $thetask)); |
|
| 116 | 116 | |
| 117 | 117 | $end = microtime(true); |
| 118 | 118 | |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | return new Result( |
| 130 | - array ( |
|
| 130 | + array( |
|
| 131 | 131 | $pid, |
| 132 | 132 | $name, |
| 133 | 133 | $status, |