1 | <?php |
||
10 | class ElfinderServiceProvider extends ServiceProvider |
||
11 | { |
||
12 | /** |
||
13 | * namespace. |
||
14 | * |
||
15 | * @var string |
||
16 | */ |
||
17 | protected $namespace = 'Recca0120\Elfinder\Http\Controllers'; |
||
18 | |||
19 | /** |
||
20 | * handle routes. |
||
21 | * |
||
22 | * @param \Illuminate\Routing\Router $router |
||
23 | */ |
||
24 | public function boot(Router $router) |
||
25 | { |
||
26 | $config = $this->app['config']['elfinder']; |
||
27 | $this->handleRoutes($router, $config); |
||
28 | $this->loadViewsFrom(__DIR__.'/../resources/views', 'elfinder'); |
||
29 | |||
30 | if ($this->app->runningInConsole() === true) { |
||
31 | $this->handlePublishes(); |
||
32 | } |
||
33 | } |
||
34 | |||
35 | /** |
||
36 | * Register any application services. |
||
37 | */ |
||
38 | public function register() |
||
39 | { |
||
40 | $this->mergeConfigFrom(__DIR__.'/../config/elfinder.php', 'elfinder'); |
||
41 | |||
42 | $this->app->singleton('elfinder.options', function ($app) { |
||
43 | return new Options( |
||
44 | $app['request'], |
||
45 | $app['files'], |
||
46 | $app['url'], |
||
47 | new LaravelSession($app['session']), |
||
48 | $app['config']['elfinder'] |
||
49 | ); |
||
50 | }); |
||
51 | |||
52 | $this->app->singleton('elfinder', function ($app) { |
||
53 | return new elFinder((array) $app['elfinder.options']); |
||
54 | }); |
||
55 | |||
56 | $this->app->singleton(Connector::class, function ($app) { |
||
57 | return new Connector($app['elfinder']); |
||
58 | }); |
||
59 | } |
||
60 | |||
61 | /** |
||
62 | * register routes. |
||
63 | * |
||
64 | * @param \Illuminate\Routing\Router $router |
||
65 | * @param array $config |
||
66 | */ |
||
67 | protected function handleRoutes(Router $router, $config) |
||
68 | { |
||
69 | if ($this->app->routesAreCached() === false) { |
||
70 | $router->group(array_merge([ |
||
71 | 'namespace' => $this->namespace, |
||
72 | ], Arr::get($config, 'route', [])), function () { |
||
73 | require __DIR__.'/Http/routes.php'; |
||
74 | }); |
||
75 | } |
||
76 | } |
||
77 | |||
78 | /** |
||
79 | * handle publishes. |
||
80 | * |
||
81 | * @return void |
||
82 | */ |
||
83 | protected function handlePublishes() |
||
97 | } |
||
98 |