Completed
Push — master ( 868943...de56f4 )
by ARCANEDEV
02:45
created

PackageServiceProvider::filesystem()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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