Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
 
3
namespace Illuminate\Broadcasting;
4
 
5
use Illuminate\Container\Container;
6
use Illuminate\Contracts\Cache\Repository;
7
use Illuminate\Contracts\Queue\ShouldBeUnique;
8
 
9
class UniqueBroadcastEvent extends BroadcastEvent implements ShouldBeUnique
10
{
11
    /**
12
     * The unique lock identifier.
13
     *
14
     * @var mixed
15
     */
16
    public $uniqueId;
17
 
18
    /**
19
     * The number of seconds the unique lock should be maintained.
20
     *
21
     * @var int
22
     */
23
    public $uniqueFor;
24
 
25
    /**
26
     * Create a new event instance.
27
     *
28
     * @param  mixed  $event
29
     * @return void
30
     */
31
    public function __construct($event)
32
    {
33
        $this->uniqueId = get_class($event);
34
 
35
        if (method_exists($event, 'uniqueId')) {
36
            $this->uniqueId .= $event->uniqueId();
37
        } elseif (property_exists($event, 'uniqueId')) {
38
            $this->uniqueId .= $event->uniqueId;
39
        }
40
 
41
        if (method_exists($event, 'uniqueFor')) {
42
            $this->uniqueFor = $event->uniqueFor();
43
        } elseif (property_exists($event, 'uniqueFor')) {
44
            $this->uniqueFor = $event->uniqueFor;
45
        }
46
 
47
        parent::__construct($event);
48
    }
49
 
50
    /**
51
     * Resolve the cache implementation that should manage the event's uniqueness.
52
     *
53
     * @return \Illuminate\Contracts\Cache\Repository
54
     */
55
    public function uniqueVia()
56
    {
57
        return method_exists($this->event, 'uniqueVia')
58
                ? $this->event->uniqueVia()
59
                : Container::getInstance()->make(Repository::class);
60
    }
61
}