Changeset View
Changeset View
Standalone View
Standalone View
src/app/Jobs/CommonJob.php
Show All 24 Lines | abstract class CommonJob implements ShouldQueue | ||||
/** | /** | ||||
* The failure message. | * The failure message. | ||||
* | * | ||||
* @var string | * @var string | ||||
*/ | */ | ||||
public $failureMessage; | public $failureMessage; | ||||
/** | /** | ||||
* The job deleted state. | |||||
* | |||||
* @var bool | |||||
*/ | |||||
protected $isDeleted = false; | |||||
/** | |||||
* The job released state. | * The job released state. | ||||
* | * | ||||
* @var bool | * @var bool | ||||
*/ | */ | ||||
protected $isReleased = false; | protected $isReleased = false; | ||||
/** | /** | ||||
* The number of tries for this Job. | * The number of tries for this Job. | ||||
* | * | ||||
* @var int | * @var int | ||||
*/ | */ | ||||
public $tries = 5; | public $tries = 5; | ||||
/** | /** | ||||
* Execute the job. | * Execute the job. | ||||
* | * | ||||
* @return void | * @return void | ||||
*/ | */ | ||||
abstract public function handle(); | abstract public function handle(); | ||||
/** | /** | ||||
* Delete the job from the queue. | |||||
* | |||||
* @return void | |||||
*/ | |||||
public function delete() | |||||
{ | |||||
// We need this for testing purposes | |||||
$this->isDeleted = true; | |||||
// @phpstan-ignore-next-line | |||||
if ($this->job) { | |||||
$this->job->delete(); | |||||
} | |||||
} | |||||
/** | |||||
* Delete the job, call the "failed" method, and raise the failed job event. | * Delete the job, call the "failed" method, and raise the failed job event. | ||||
* | * | ||||
* @param \Throwable|null $e An Exception | * @param \Throwable|null $e An Exception | ||||
* | * | ||||
* @return void | * @return void | ||||
*/ | */ | ||||
public function fail($e = null) | public function fail($e = null) | ||||
{ | { | ||||
Show All 29 Lines | public function release($delay = 0) | ||||
// @phpstan-ignore-next-line | // @phpstan-ignore-next-line | ||||
if ($this->job) { | if ($this->job) { | ||||
$this->job->release($delay); | $this->job->release($delay); | ||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* Determine if the job has been deleted. | |||||
* | |||||
* @return bool | |||||
*/ | |||||
public function isDeleted(): bool | |||||
{ | |||||
return $this->isDeleted; | |||||
} | |||||
/** | |||||
* Check if the job was released | * Check if the job was released | ||||
* | * | ||||
* @return bool | * @return bool | ||||
*/ | */ | ||||
public function isReleased(): bool | public function isReleased(): bool | ||||
{ | { | ||||
return $this->isReleased; | return $this->isReleased; | ||||
} | } | ||||
} | } |