| @@ 8-50 (lines=43) @@ | ||
| 5 | use dmank\gearman\JobInterface; |
|
| 6 | use Symfony\Component\EventDispatcher\Event; |
|
| 7 | ||
| 8 | class FunctionEvent extends Event |
|
| 9 | { |
|
| 10 | const FUNCTION_BEFORE_EXECUTE = 'worker.function.before_execute'; |
|
| 11 | const FUNCTION_AFTER_EXECUTE = 'worker.function.after_execute'; |
|
| 12 | ||
| 13 | private $jobHandler; |
|
| 14 | private $job; |
|
| 15 | /** |
|
| 16 | * @var array |
|
| 17 | */ |
|
| 18 | private $result; |
|
| 19 | ||
| 20 | public function __construct(JobHandlerInterface $jobHandler, JobInterface $job, $result = []) |
|
| 21 | { |
|
| 22 | $this->jobHandler = $jobHandler; |
|
| 23 | $this->job = $job; |
|
| 24 | $this->result = $result; |
|
| 25 | } |
|
| 26 | ||
| 27 | /** |
|
| 28 | * @return array |
|
| 29 | */ |
|
| 30 | public function getResult() |
|
| 31 | { |
|
| 32 | return $this->result; |
|
| 33 | } |
|
| 34 | ||
| 35 | /** |
|
| 36 | * @return JobHandlerInterface |
|
| 37 | */ |
|
| 38 | public function getJobHandler() |
|
| 39 | { |
|
| 40 | return $this->jobHandler; |
|
| 41 | } |
|
| 42 | ||
| 43 | /** |
|
| 44 | * @return JobInterface |
|
| 45 | */ |
|
| 46 | public function getJob() |
|
| 47 | { |
|
| 48 | return $this->job; |
|
| 49 | } |
|
| 50 | } |
|
| 51 | ||
| @@ 8-57 (lines=50) @@ | ||
| 5 | use dmank\gearman\JobInterface; |
|
| 6 | use Symfony\Component\EventDispatcher\Event; |
|
| 7 | ||
| 8 | class FunctionFailureEvent extends Event |
|
| 9 | { |
|
| 10 | const FUNCTION_ON_FAILURE = 'worker.function.on_failure'; |
|
| 11 | ||
| 12 | /** |
|
| 13 | * @var JobHandlerInterface |
|
| 14 | */ |
|
| 15 | private $jobHandler; |
|
| 16 | ||
| 17 | /** |
|
| 18 | * @var JobInterface|null |
|
| 19 | */ |
|
| 20 | private $job; |
|
| 21 | ||
| 22 | /** |
|
| 23 | * @var \Exception |
|
| 24 | */ |
|
| 25 | private $exception; |
|
| 26 | ||
| 27 | public function __construct(JobHandlerInterface $jobHandler, \Exception $exception, JobInterface $job = null) |
|
| 28 | { |
|
| 29 | $this->jobHandler = $jobHandler; |
|
| 30 | $this->exception = $exception; |
|
| 31 | $this->job = $job; |
|
| 32 | } |
|
| 33 | ||
| 34 | /** |
|
| 35 | * @return JobHandlerInterface |
|
| 36 | */ |
|
| 37 | public function getJobHandler() |
|
| 38 | { |
|
| 39 | return $this->jobHandler; |
|
| 40 | } |
|
| 41 | ||
| 42 | /** |
|
| 43 | * @return JobInterface |
|
| 44 | */ |
|
| 45 | public function getJob() |
|
| 46 | { |
|
| 47 | return $this->job; |
|
| 48 | } |
|
| 49 | ||
| 50 | /** |
|
| 51 | * @return \Exception |
|
| 52 | */ |
|
| 53 | public function getException() |
|
| 54 | { |
|
| 55 | return $this->exception; |
|
| 56 | } |
|
| 57 | } |
|
| 58 | ||