1
|
|
|
<?php namespace Arcanedev\Notify; |
2
|
|
|
|
3
|
|
|
use Illuminate\Support\Manager; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Class StoreManager |
7
|
|
|
* |
8
|
|
|
* @package Arcanedev\Notify |
9
|
|
|
* @author ARCANEDEV <[email protected]> |
10
|
|
|
*/ |
11
|
|
|
class StoreManager extends Manager |
12
|
|
|
{ |
13
|
|
|
/* ----------------------------------------------------------------- |
14
|
|
|
| Main Methods |
15
|
|
|
| ----------------------------------------------------------------- |
16
|
|
|
*/ |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Get the default driver name. |
20
|
|
|
* |
21
|
|
|
* @return string |
22
|
|
|
*/ |
23
|
48 |
|
public function getDefaultDriver() |
24
|
|
|
{ |
25
|
48 |
|
return $this->config()->get('notify.default', 'session'); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Load the stores. |
30
|
|
|
* |
31
|
|
|
* @return void |
32
|
|
|
*/ |
33
|
48 |
|
public function loadStores(): void |
34
|
|
|
{ |
35
|
48 |
|
foreach ($this->config()->get('notify.stores', []) as $driver => $store) { |
36
|
48 |
|
$this->loadStore($driver, $store); |
37
|
|
|
} |
38
|
48 |
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Load/Register a store. |
42
|
|
|
* |
43
|
|
|
* @param string $driver |
44
|
|
|
* @param array $store |
45
|
|
|
* |
46
|
|
|
* @return void |
47
|
|
|
*/ |
48
|
48 |
|
protected function loadStore(string $driver, array $store) |
49
|
|
|
{ |
50
|
48 |
|
$class = $store['class']; |
51
|
|
|
|
52
|
|
|
$this->extend($driver, function () use ($class) { |
53
|
48 |
|
return $this->app->make($class); |
54
|
48 |
|
}); |
55
|
|
|
|
56
|
|
|
$this->app->when($class)->needs('$options')->give(function () use ($store) { |
57
|
48 |
|
return $store['options'] ?? []; |
58
|
48 |
|
}); |
59
|
48 |
|
} |
60
|
|
|
|
61
|
|
|
/* ----------------------------------------------------------------- |
62
|
|
|
| Other Methods |
63
|
|
|
| ----------------------------------------------------------------- |
64
|
|
|
*/ |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* Get the config repository. |
68
|
|
|
* |
69
|
|
|
* @return \Illuminate\Contracts\Config\Repository |
70
|
|
|
*/ |
71
|
48 |
|
protected function config() |
72
|
|
|
{ |
73
|
48 |
|
return $this->app['config']; |
74
|
|
|
} |
75
|
|
|
} |
76
|
|
|
|