1 | <?php |
||
9 | class HashidServiceProvider extends ServiceProvider |
||
10 | { |
||
11 | /** |
||
12 | * Register the service provider. |
||
13 | * |
||
14 | * @return void |
||
15 | */ |
||
16 | 6 | public function register() |
|
23 | |||
24 | /** |
||
25 | * Setup package assets. |
||
26 | * |
||
27 | * @return void |
||
28 | */ |
||
29 | 6 | protected function setupAssets() |
|
41 | |||
42 | /** |
||
43 | * Register service bindings. |
||
44 | * |
||
45 | * @return void |
||
46 | */ |
||
47 | 6 | protected function registerServices() |
|
48 | { |
||
49 | $this->app->singleton('hashid', function ($app) { |
||
50 | 4 | return new HashidManager($app); |
|
51 | 6 | }); |
|
52 | 6 | $this->app->alias('hashid', HashidManager::class); |
|
53 | |||
54 | 6 | foreach ($this->getSingletonDrivers() as $class) { |
|
55 | 6 | $this->app->singleton( |
|
56 | 6 | $key = $this->getBindingKeyForDriver($class), |
|
57 | 1 | function () use ($class) { |
|
58 | 1 | return new $class; |
|
59 | } |
||
60 | 6 | ); |
|
61 | 6 | $this->app->alias($key, $class); |
|
62 | 6 | } |
|
63 | |||
64 | 6 | foreach ($this->getNonSingletonDrivers() as $class) { |
|
65 | 6 | $this->app->bind($this->getBindingKeyForDriver($class), $class); |
|
66 | 6 | } |
|
67 | 6 | } |
|
68 | |||
69 | /** |
||
70 | * Get singleton drivers classes. |
||
71 | * |
||
72 | * @return array |
||
73 | */ |
||
74 | 6 | protected function getSingletonDrivers() |
|
83 | |||
84 | /** |
||
85 | * Get non-singleton drivers classes. |
||
86 | * |
||
87 | * @return array |
||
88 | */ |
||
89 | 6 | protected function getNonSingletonDrivers() |
|
101 | |||
102 | /** |
||
103 | * Get the binding key for the driver class. |
||
104 | * |
||
105 | * @param string $class |
||
106 | * @return string |
||
107 | */ |
||
108 | 6 | protected function getBindingKeyForDriver($class) |
|
114 | |||
115 | /** |
||
116 | * Register console commands. |
||
117 | * |
||
118 | * @return void |
||
119 | */ |
||
120 | 6 | protected function registerCommands() |
|
129 | } |
||
130 |