Completed
Push — master ( d6ff33...d15a66 )
by ARCANEDEV
03:46
created

PackageServiceProvider::publishAll()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
ccs 0
cts 4
cp 0
crap 2
1
<?php namespace Arcanesoft\Core\Bases;
2
3
use Arcanedev\Support\PackageServiceProvider as ServiceProvider;
4
use Illuminate\Support\Str;
5
6
/**
7
 * Class     PackageServiceProvider
8
 *
9
 * @package  Arcanesoft\Core\Bases
10
 * @author   ARCANEDEV <[email protected]>
11
 */
12
abstract class PackageServiceProvider extends ServiceProvider
13
{
14
    /* ------------------------------------------------------------------------------------------------
15
     |  Properties
16
     | ------------------------------------------------------------------------------------------------
17
     */
18
    /**
19
     * Vendor name.
20
     *
21
     * @var string
22
     */
23
    protected $vendor = 'arcanesoft';
24
25
    /* ------------------------------------------------------------------------------------------------
26
     |  Getters & Setters
27
     | ------------------------------------------------------------------------------------------------
28
     */
29
    /**
30
     * Get config key.
31
     *
32
     * @return string
33
     */
34 4
    protected function getConfigKey()
35
    {
36 4
        return Str::slug("{$this->vendor} {$this->package}", '.');
37
    }
38
39
    /**
40
     * Get the sidebar folder.
41
     *
42
     * @return string
43
     */
44
    protected function getSidebarFolder()
45
    {
46
        return $this->getConfigFolder() . DS . 'sidebar';
47
    }
48
49
    /**
50
     * Get the sidebar config key.
51
     *
52
     * @return string
53
     */
54
    protected function getSidebarKey()
55
    {
56
        return "{$this->vendor}.sidebar.{$this->package}";
57
    }
58
59
    /* ------------------------------------------------------------------------------------------------
60
     |  Package Functions
61
     | ------------------------------------------------------------------------------------------------
62
     */
63
    /**
64
     * Publish all the package files.
65
     *
66
     * @param  bool  $load
67
     */
68
    protected function publishAll($load = true)
69
    {
70
        parent::publishAll($load);
71
72
        $this->publishSidebarItems();
73
    }
74
75
    /**
76
     * Publish the config file.
77
     */
78
    protected function publishConfig()
79
    {
80
        $this->publishes([
81
            $this->getConfigFile() => config_path("{$this->vendor}/{$this->package}.php"),
82
        ], 'config');
83
    }
84
85
    /**
86
     * Publish all the sidebar config files.
87
     */
88
    protected function publishSidebarItems()
89
    {
90
        $this->publishes([
91
            $this->getSidebarFolder() => config_path($this->vendor . DS . 'sidebar' . DS . $this->package)
92
        ], 'sidebar');
93
    }
94
95
    /**
96
     * Register all the sidebar config files.
97
     */
98
    protected function registerSidebarItems()
99
    {
100
        foreach ($this->filesystem()->glob($this->getSidebarFolder() . DS . '*.php') as $path) {
101
            $this->mergeConfigFrom($path, $this->getSidebarKey().'.'.basename($path, '.php'));
102
        }
103
    }
104
}
105