Passed
Push — ft/appmove ( db87fd...97613e )
by Philippe
45:05 queued 26:47
created

ChiefProjectServiceProvider::boot()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 8
nc 1
nop 0
dl 0
loc 15
c 0
b 0
f 0
cc 1
rs 10
1
<?php
2
3
namespace Thinktomorrow\Chief\App\Providers;
4
5
use Thinktomorrow\Chief\Pages\Single;
6
use Thinktomorrow\Chief\Menu\MenuItem;
7
use Illuminate\Support\ServiceProvider;
8
use Thinktomorrow\Chief\Pages\PageManager;
9
use Thinktomorrow\Chief\Modules\TextModule;
10
use Thinktomorrow\Chief\Management\Register;
11
use Thinktomorrow\Chief\Modules\ModuleManager;
12
use Thinktomorrow\Chief\Modules\PagetitleModule;
13
use Illuminate\Database\Eloquent\Relations\Relation;
14
15
class ChiefProjectServiceProvider extends ServiceProvider
16
{
17
    public function boot()
18
    {
19
        // Out of the box morphables - the key 'singles' is the page's default morphKey.
20
        Relation::morphMap([
21
            'menuitem'  => MenuItem::class,
22
            'singles'   => Single::class,
23
            'text'      => TextModule::class,
24
            'pagetitle' => PagetitleModule::class,
25
        ]);
26
27
        // singles - text - pagetitle
28
        $this->registerPage(PageManager::class, Single::class);
29
30
        $this->registerManager(ModuleManager::class, TextModule::class, ['pagesection']);
31
        $this->registerManager(ModuleManager::class, PagetitleModule::class, ['pagesection']);
32
    }
33
34
    public function registerModule($class, $model, array $tags = [])
35
    {
36
        return $this->registerManager($class, $model, array_merge(['module'], $tags));
37
    }
38
39
    public function registerPage($class, $model, array $tags = [])
40
    {
41
        return $this->registerManager($class, $model, array_merge(['page'], $tags));
42
    }
43
44
    public function registerManager($class, $model, array $tags = [])
45
    {
46
        return app(Register::class)->register($class, $model, $tags);
47
    }
48
49
    public function register()
50
    {
51
        //
52
    }
53
}
54