1 <?php
2
3 namespace Skimia\Assets\Providers;
4
5 use Skimia\Assets\Console\Commands\FlushPipelineCommand;
6 use Skimia\Assets\Manager as Assets;
7 use Illuminate\Foundation\AliasLoader;
8 use Stolz\Assets\Laravel\ServiceProvider as StolzProvider;
9
10 class StolzAssetsServiceProvider extends StolzProvider
11 {
12 13 14 15 16
17 public function boot()
18 {
19
20 AliasLoader::getInstance()->alias('Assets', 'Stolz\Assets\Laravel\Facade');
21
22 $this->commands('stolz.assets.command.flush');
23 }
24
25 26 27 28 29
30 public function register()
31 {
32
33 $this->app->bind('stolz.assets.command.flush', function ($app) {
34 return new FlushPipelineCommand();
35 });
36
37
38 $config = $this->app['config']->get('assets.groups', []);
39
40
41 if (! isset($config['default'])) {
42 return $this->registerAssetsManagerInstance('default', $config);
43 }
44
45 foreach ($config as $groupName => $groupConfig) {
46 $this->registerAssetsManagerInstance($groupName, (array) $groupConfig);
47 }
48 }
49
50 51 52 53 54 55 56 57
58 protected function registerAssetsManagerInstance($name, array $config)
59 {
60 $this->app->singleton("stolz.assets.group.$name", function ($app) use ($config) {
61 if (! isset($config['public_dir'])) {
62 $config['public_dir'] = public_path();
63 }
64
65 $config['collections_dir'] = $this->app['config']->get('assets.collections_dir', 'collections');
66
67 return new Assets($config);
68 });
69 }
70 }
71