MediaServiceProvider::syncFilesystemConfig()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 3
nc 2
nop 0
crap 2
1
<?php namespace Arcanesoft\Media;
2
3
use Arcanesoft\Core\Bases\PackageServiceProvider;
4
5
/**
6
 * Class     MediaServiceProvider
7
 *
8
 * @package  Arcanesoft\Media
9
 * @author   ARCANEDEV <[email protected]>
10
 */
11
class MediaServiceProvider extends PackageServiceProvider
12
{
13
    /* -----------------------------------------------------------------
14
     |  Properties
15
     | -----------------------------------------------------------------
16
     */
17
18
    /**
19
     * Package name.
20
     *
21
     * @var string
22
     */
23
    protected $package = 'media';
24
25
    /* -----------------------------------------------------------------
26
     |  Main Functions
27
     | -----------------------------------------------------------------
28
     */
29
30
    /**
31
     * Register the service provider.
32
     */
33 80
    public function register()
34
    {
35 80
        parent::register();
36
37 80
        $this->registerConfig();
38 80
        $this->registerSidebarItems();
39 80
        $this->registerProviders([
40 80
            Providers\AuthorizationServiceProvider::class,
41
            Providers\RouteServiceProvider::class,
42
        ]);
43 80
        $this->registerConsoleServiceProvider(Providers\ConsoleServiceProvider::class);
44
45 80
        $this->syncFilesystemConfig();
46 80
        $this->registerMediaManager();
47 80
    }
48
49
    /**
50
     * Boot the service provider.
51
     */
52 80
    public function boot()
53
    {
54 80
        parent::boot();
55
56
        // Publishes
57 80
        $this->publishConfig();
58 80
        $this->publishViews();
59 80
        $this->publishTranslations();
60 80
        $this->publishSidebarItems();
61 80
        $this->publishAssets();
62 80
    }
63
64
    /**
65
     * Get the services provided by the provider.
66
     *
67
     * @return array
68
     */
69 2
    public function provides()
70
    {
71
        return [
72 2
            Contracts\Media::class,
73
        ];
74
    }
75
76
    /* -----------------------------------------------------------------
77
     |  Other Methods
78
     | -----------------------------------------------------------------
79
     */
80
81
    /**
82
     * Sync the filesystem config.
83
     */
84 80
    private function syncFilesystemConfig()
85
    {
86 80
        foreach ($this->config()->get('arcanesoft.media.filesystem.disks', []) as $disk => $config) {
87 80
            $this->config()->set("filesystems.disks.$disk", $config);
88
        }
89 80
    }
90
91
    /**
92
     * Register the media manager.
93
     */
94 80
    private function registerMediaManager()
95
    {
96 80
        $this->singleton(Contracts\Media::class, Media::class);
97 80
    }
98
99
    /**
100
     * Publish the assets.
101
     */
102 80
    protected function publishAssets()
103
    {
104 80
        $this->publishes([
105 80
            $this->getResourcesPath().DS.'assets'.DS => resource_path("assets/_{$this->vendor}/{$this->package}"),
106 80
        ], 'assets');
107 80
    }
108
}
109