1 | <?php |
||
8 | class HashidServiceProvider extends ServiceProvider |
||
9 | { |
||
10 | /** |
||
11 | * Register the service provider. |
||
12 | * |
||
13 | * @return void |
||
14 | */ |
||
15 | 6 | public function register() |
|
22 | |||
23 | /** |
||
24 | * Setup package assets. |
||
25 | * |
||
26 | * @return void |
||
27 | */ |
||
28 | 6 | protected function setupAssets() |
|
40 | |||
41 | /** |
||
42 | * Register service bindings. |
||
43 | * |
||
44 | * @return void |
||
45 | */ |
||
46 | protected function registerServices() |
||
47 | { |
||
48 | 6 | $this->app->singleton('hashid', function ($app) { |
|
49 | 4 | return new HashidManager($app); |
|
50 | 6 | }); |
|
51 | 6 | $this->app->alias('hashid', HashidManager::class); |
|
52 | |||
53 | foreach ([ |
||
54 | 6 | Base64Driver::class, |
|
55 | 6 | Base64IntegerDriver::class, |
|
56 | 6 | HexDriver::class, |
|
57 | 6 | HexIntegerDriver::class, |
|
58 | 6 | ] as $class) { |
|
59 | 6 | $key = $this->getBindingKeyForDriver($class); |
|
60 | |||
61 | 6 | $this->app->singleton($key, $class); |
|
62 | 6 | $this->app->alias($key, $class); |
|
63 | 6 | } |
|
64 | |||
65 | 6 | foreach ([ |
|
66 | 6 | Base62Driver::class, |
|
67 | 6 | Base62IntegerDriver::class, |
|
68 | 6 | HashidsDriver::class, |
|
69 | 6 | HashidsHexDriver::class, |
|
70 | 6 | HashidsIntegerDriver::class, |
|
71 | 6 | HashidsStringDriver::class, |
|
72 | 6 | OptimusDriver::class, |
|
73 | 6 | ] as $class) { |
|
74 | 6 | $this->app->bind($this->getBindingKeyForDriver($class), $class); |
|
75 | 6 | } |
|
76 | 6 | } |
|
77 | |||
78 | /** |
||
79 | * Get the binding key for the driver class. |
||
80 | * |
||
81 | * @param string $class |
||
82 | * @return string |
||
83 | */ |
||
84 | 6 | protected function getBindingKeyForDriver($class) |
|
90 | |||
91 | /** |
||
92 | * Register console commands. |
||
93 | * |
||
94 | * @return void |
||
95 | */ |
||
96 | 6 | protected function registerCommands() |
|
105 | } |
||
106 |