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\Notifications;
4
 
5
use Illuminate\Contracts\Bus\Dispatcher as Bus;
6
use Illuminate\Contracts\Events\Dispatcher;
7
use Illuminate\Contracts\Notifications\Dispatcher as DispatcherContract;
8
use Illuminate\Contracts\Notifications\Factory as FactoryContract;
9
use Illuminate\Support\Manager;
10
use InvalidArgumentException;
11
 
12
class ChannelManager extends Manager implements DispatcherContract, FactoryContract
13
{
14
    /**
15
     * The default channel used to deliver messages.
16
     *
17
     * @var string
18
     */
19
    protected $defaultChannel = 'mail';
20
 
21
    /**
22
     * The locale used when sending notifications.
23
     *
24
     * @var string|null
25
     */
26
    protected $locale;
27
 
28
    /**
29
     * Send the given notification to the given notifiable entities.
30
     *
31
     * @param  \Illuminate\Support\Collection|array|mixed  $notifiables
32
     * @param  mixed  $notification
33
     * @return void
34
     */
35
    public function send($notifiables, $notification)
36
    {
37
        (new NotificationSender(
38
            $this, $this->container->make(Bus::class), $this->container->make(Dispatcher::class), $this->locale)
39
        )->send($notifiables, $notification);
40
    }
41
 
42
    /**
43
     * Send the given notification immediately.
44
     *
45
     * @param  \Illuminate\Support\Collection|array|mixed  $notifiables
46
     * @param  mixed  $notification
47
     * @param  array|null  $channels
48
     * @return void
49
     */
50
    public function sendNow($notifiables, $notification, array $channels = null)
51
    {
52
        (new NotificationSender(
53
            $this, $this->container->make(Bus::class), $this->container->make(Dispatcher::class), $this->locale)
54
        )->sendNow($notifiables, $notification, $channels);
55
    }
56
 
57
    /**
58
     * Get a channel instance.
59
     *
60
     * @param  string|null  $name
61
     * @return mixed
62
     */
63
    public function channel($name = null)
64
    {
65
        return $this->driver($name);
66
    }
67
 
68
    /**
69
     * Create an instance of the database driver.
70
     *
71
     * @return \Illuminate\Notifications\Channels\DatabaseChannel
72
     */
73
    protected function createDatabaseDriver()
74
    {
75
        return $this->container->make(Channels\DatabaseChannel::class);
76
    }
77
 
78
    /**
79
     * Create an instance of the broadcast driver.
80
     *
81
     * @return \Illuminate\Notifications\Channels\BroadcastChannel
82
     */
83
    protected function createBroadcastDriver()
84
    {
85
        return $this->container->make(Channels\BroadcastChannel::class);
86
    }
87
 
88
    /**
89
     * Create an instance of the mail driver.
90
     *
91
     * @return \Illuminate\Notifications\Channels\MailChannel
92
     */
93
    protected function createMailDriver()
94
    {
95
        return $this->container->make(Channels\MailChannel::class);
96
    }
97
 
98
    /**
99
     * Create a new driver instance.
100
     *
101
     * @param  string  $driver
102
     * @return mixed
103
     *
104
     * @throws \InvalidArgumentException
105
     */
106
    protected function createDriver($driver)
107
    {
108
        try {
109
            return parent::createDriver($driver);
110
        } catch (InvalidArgumentException $e) {
111
            if (class_exists($driver)) {
112
                return $this->container->make($driver);
113
            }
114
 
115
            throw $e;
116
        }
117
    }
118
 
119
    /**
120
     * Get the default channel driver name.
121
     *
122
     * @return string
123
     */
124
    public function getDefaultDriver()
125
    {
126
        return $this->defaultChannel;
127
    }
128
 
129
    /**
130
     * Get the default channel driver name.
131
     *
132
     * @return string
133
     */
134
    public function deliversVia()
135
    {
136
        return $this->getDefaultDriver();
137
    }
138
 
139
    /**
140
     * Set the default channel driver name.
141
     *
142
     * @param  string  $channel
143
     * @return void
144
     */
145
    public function deliverVia($channel)
146
    {
147
        $this->defaultChannel = $channel;
148
    }
149
 
150
    /**
151
     * Set the locale of notifications.
152
     *
153
     * @param  string  $locale
154
     * @return $this
155
     */
156
    public function locale($locale)
157
    {
158
        $this->locale = $locale;
159
 
160
        return $this;
161
    }
162
}