fisharebest /
laravel-assets
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * laravel-assets: asset management for Laravel 5 |
||
| 4 | * |
||
| 5 | * Copyright (c) 2021 Greg Roach |
||
| 6 | * |
||
| 7 | * This program is free software: you can redistribute it and/or modify |
||
| 8 | * it under the terms of the GNU General Public License as published by |
||
| 9 | * the Free Software Foundation, either version 3 of the License, or |
||
| 10 | * (at your option) any later version. |
||
| 11 | * |
||
| 12 | * This program is distributed in the hope that it will be useful, |
||
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
| 15 | * GNU General Public License for more details. |
||
| 16 | * |
||
| 17 | * You should have received a copy of the GNU General Public License |
||
| 18 | * along with this program. If not, see <https://www.gnu.org/licenses/>. |
||
| 19 | */ |
||
| 20 | |||
| 21 | namespace Fisharebest\LaravelAssets; |
||
| 22 | |||
| 23 | use Fisharebest\LaravelAssets\Commands\Purge; |
||
| 24 | use Illuminate\Contracts\Foundation\Application; |
||
| 25 | use Illuminate\Support\ServiceProvider; |
||
| 26 | use League\Flysystem\Adapter\Local; |
||
| 27 | use League\Flysystem\AdapterInterface; |
||
| 28 | use League\Flysystem\Filesystem; |
||
| 29 | |||
| 30 | class AssetsServiceProvider extends ServiceProvider |
||
| 31 | { |
||
| 32 | /** |
||
| 33 | * Perform post-registration booting of services. |
||
| 34 | */ |
||
| 35 | public function boot() |
||
| 36 | { |
||
| 37 | // Allow artisan to publish our config file using the "vendor:publish" command. |
||
| 38 | $this->publishes([ |
||
| 39 | __DIR__ . '/../config/assets.php' => config_path('assets.php'), |
||
| 40 | ]); |
||
| 41 | } |
||
| 42 | |||
| 43 | /** |
||
| 44 | * Register bindings in the container. |
||
| 45 | */ |
||
| 46 | public function register() |
||
| 47 | { |
||
| 48 | // Merge our default configuration. |
||
| 49 | $this->mergeConfigFrom(__DIR__ . '/../config/assets.php', 'assets'); |
||
| 50 | |||
| 51 | // Bind our component into the IoC container. |
||
| 52 | $this->app->singleton('assets', function ($app) { |
||
| 53 | $config = [ |
||
| 54 | 'visibility' => AdapterInterface::VISIBILITY_PUBLIC, |
||
| 55 | ]; |
||
| 56 | |||
| 57 | $filesystem = new Filesystem(new Local(public_path()), $config); |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 58 | |||
| 59 | return new Assets($app['config']['assets'], $filesystem); |
||
| 60 | }); |
||
| 61 | |||
| 62 | // Command-line functions |
||
| 63 | // Don't use array access here - it is hard to mock / unit-test. Use bind() and make() instead. |
||
| 64 | $this->app->bind('command.assets.purge', function (Application $app) { |
||
| 65 | return new Purge($app->make('assets')); |
||
| 66 | }); |
||
| 67 | |||
| 68 | $this->commands(['command.assets.purge']); |
||
| 69 | } |
||
| 70 | } |
||
| 71 |