ChuckSiteServiceProvider::boot()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 0
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 2
rs 10
1
<?php
2
3
namespace Chuckbe\Chuckcms\Providers;
4
5
use Chuckbe\Chuckcms\Chuck\ModuleRepository;
6
use Chuckbe\Chuckcms\Chuck\SiteRepository;
7
use Chuckbe\Chuckcms\Models\Site;
8
use Exception;
9
use Illuminate\Support\ServiceProvider;
10
11
class ChuckSiteServiceProvider extends ServiceProvider
12
{
13
    /**
14
     * Bootstrap the application services.
15
     *
16
     * @return void
17
     */
18
    public function boot()
19
    {
20
        //
21
    }
22
23
    /**
24
     * Register the application services.
25
     *
26
     * @return void
27
     */
28
    public function register()
29
    {
30
        $this->app->singleton('ChuckSite', function () {
31
            $site = Site::first();
32
            if ($site == null) {
33
                throw new Exception('Whoops! No Site Defined...');
34
            }
35
36
            return new \Chuckbe\Chuckcms\Chuck\Accessors\Site($site, \App::make(SiteRepository::class), \App::make(ModuleRepository::class));
37
        });
38
    }
39
}
40