Passed
Push — master ( c39ef6...1fc558 )
by Peter
05:09
created

ThemesServiceProvider::register()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 6
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
namespace PeterColes\Themes;
4
5
use Illuminate\Support\ServiceProvider;
6
7
class ThemesServiceProvider extends ServiceProvider
8
{
9
    /**
10
     * Perform post-registration booting of services.
11
     *
12
     * @return void
13
     */
14
    public function boot()
15
    {
16
        $this->publishes([
17
            __DIR__.'/../config/themes.php' => config_path('themes.php'),
18
        ]);
19
    }
20
21
    /**
22
     * Register any application services.
23
     *
24
     * @return void
25
     */
26
    public function register()
27
    {
28
        $this->registerViewFinder();
29
30
        $this->registerThemes();
31
    }
32
33
    /**
34
     * Re-register the view finder to use use local copy.
35
     *
36
     * @return void
37
     */
38
    protected function registerViewFinder()
39
    {
40
        $this->app['view.finder'] = $this->app->share(function($app) {
41
            $paths = $app['config']['view.paths'];
42
43
            return new FileViewFinder($app['files'], $paths);
44
        });
45
46
        // Apply this finder to the already-registered view factory
47
        $this->app['view']->setFinder($this->app['view.finder']);
48
    }
49
50
    /**
51
     * Register the themes service.
52
     *
53
     * @return void
54
     */
55
    protected function registerThemes()
56
    {
57
        $this->app->singleton('themes', function() {
58
            return new Themes;
59
        });
60
    }
61
}
62