Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2571865
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/src/app/Jobs/CommonJob.php b/src/app/Jobs/CommonJob.php
index ce931614..334f3cfe 100644
--- a/src/app/Jobs/CommonJob.php
+++ b/src/app/Jobs/CommonJob.php
@@ -1,144 +1,141 @@
<?php
namespace App\Jobs;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
/**
* The abstract \App\Jobs\DomainJob implements the logic needed for all dispatchable Jobs related to
* \App\Domain objects.
*
* ```php
* $job = new \App\Jobs\Domain\CreateJob($domainId);
* $job->handle();
* ```
*/
abstract class CommonJob implements ShouldQueue
{
use Dispatchable;
use InteractsWithQueue;
use Queueable;
/**
* The failure message.
*
* @var string
*/
public $failureMessage;
/**
* The job deleted state.
*
* @var bool
*/
protected $isDeleted = false;
/**
* The job released state.
*
* @var bool
*/
protected $isReleased = false;
/**
* The number of tries for this Job.
*
* @var int
*/
public $tries = 5;
/**
* Execute the job.
*
* @return void
*/
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.
*
* @param \Throwable|null $e An Exception
*
* @return void
*/
public function fail($e = null)
{
// Save the message, for testing purposes
$this->failureMessage = $e->getMessage();
- // @phpstan-ignore-next-line
if ($this->job) {
$this->job->fail($e);
}
}
/**
* Check if the job has failed
*
* @return bool
*/
public function hasFailed(): bool
{
return $this->failureMessage !== null;
}
/**
* Release the job back into the queue.
*
* @param int $delay Time in seconds
* @return void
*/
public function release($delay = 0)
{
// We need this for testing purposes
$this->isReleased = true;
- // @phpstan-ignore-next-line
if ($this->job) {
$this->job->release($delay);
} else {
// $this->job is only set when the job is dispatched, not if manually executed by calling handle().
// When manually executed, release() does nothing, and we thus throw an exception.
throw new \Exception("Attempted to release a manually executed job");
}
}
/**
* Determine if the job has been deleted.
*
* @return bool
*/
public function isDeleted(): bool
{
return $this->isDeleted;
}
/**
* Check if the job was released
*
* @return bool
*/
public function isReleased(): bool
{
return $this->isReleased;
}
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Thu, Mar 19, 9:07 AM (1 d, 3 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
458026
Default Alt Text
(3 KB)
Attached To
Mode
R2 kolab
Attached
Detach File
Event Timeline
Log In to Comment