Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F117748737
CommonJob.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None
CommonJob.php
View Options
<?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
;
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
();
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
;
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-php
Expires
Sat, Apr 4, 1:10 AM (2 w, 8 h ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
5a/64/e8a0825be0765ca021cf41265568
Default Alt Text
CommonJob.php (2 KB)
Attached To
Mode
rK kolab
Attached
Detach File
Event Timeline