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\Contracts\Events\Dispatcher;
6
 
7
class PendingBroadcast
8
{
9
    /**
10
     * The event dispatcher implementation.
11
     *
12
     * @var \Illuminate\Contracts\Events\Dispatcher
13
     */
14
    protected $events;
15
 
16
    /**
17
     * The event instance.
18
     *
19
     * @var mixed
20
     */
21
    protected $event;
22
 
23
    /**
24
     * Create a new pending broadcast instance.
25
     *
26
     * @param  \Illuminate\Contracts\Events\Dispatcher  $events
27
     * @param  mixed  $event
28
     * @return void
29
     */
30
    public function __construct(Dispatcher $events, $event)
31
    {
32
        $this->event = $event;
33
        $this->events = $events;
34
    }
35
 
36
    /**
37
     * Broadcast the event using a specific broadcaster.
38
     *
39
     * @param  string|null  $connection
40
     * @return $this
41
     */
42
    public function via($connection = null)
43
    {
44
        if (method_exists($this->event, 'broadcastVia')) {
45
            $this->event->broadcastVia($connection);
46
        }
47
 
48
        return $this;
49
    }
50
 
51
    /**
52
     * Broadcast the event to everyone except the current user.
53
     *
54
     * @return $this
55
     */
56
    public function toOthers()
57
    {
58
        if (method_exists($this->event, 'dontBroadcastToCurrentUser')) {
59
            $this->event->dontBroadcastToCurrentUser();
60
        }
61
 
62
        return $this;
63
    }
64
 
65
    /**
66
     * Handle the object's destruction.
67
     *
68
     * @return void
69
     */
70
    public function __destruct()
71
    {
72
        $this->events->dispatch($this->event);
73
    }
74
}