Subversion-Projekte lars-tiefland.laravel_shop

Revision

Zur aktuellen Revision | Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
 
3
namespace Illuminate\Queue;
4
 
5
use Illuminate\Contracts\Queue\Job as JobContract;
6
use InvalidArgumentException;
7
use Throwable;
8
 
9
trait InteractsWithQueue
10
{
11
    /**
12
     * The underlying queue job instance.
13
     *
14
     * @var \Illuminate\Contracts\Queue\Job|null
15
     */
16
    public $job;
17
 
18
    /**
19
     * Get the number of times the job has been attempted.
20
     *
21
     * @return int
22
     */
23
    public function attempts()
24
    {
25
        return $this->job ? $this->job->attempts() : 1;
26
    }
27
 
28
    /**
29
     * Delete the job from the queue.
30
     *
31
     * @return void
32
     */
33
    public function delete()
34
    {
35
        if ($this->job) {
36
            return $this->job->delete();
37
        }
38
    }
39
 
40
    /**
41
     * Fail the job from the queue.
42
     *
43
     * @param  \Throwable|null  $exception
44
     * @return void
45
     */
46
    public function fail($exception = null)
47
    {
48
        if ($exception instanceof Throwable || is_null($exception)) {
49
            if ($this->job) {
50
                return $this->job->fail($exception);
51
            }
52
        } else {
53
            throw new InvalidArgumentException('The fail method requires an instance of Throwable.');
54
        }
55
    }
56
 
57
    /**
58
     * Release the job back into the queue after (n) seconds.
59
     *
60
     * @param  int  $delay
61
     * @return void
62
     */
63
    public function release($delay = 0)
64
    {
65
        if ($this->job) {
66
            return $this->job->release($delay);
67
        }
68
    }
69
 
70
    /**
71
     * Set the base queue job instance.
72
     *
73
     * @param  \Illuminate\Contracts\Queue\Job  $job
74
     * @return $this
75
     */
76
    public function setJob(JobContract $job)
77
    {
78
        $this->job = $job;
79
 
80
        return $this;
81
    }
82
}