1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Contains the BaseModuleServiceProvider class. |
7
|
|
|
* |
8
|
|
|
* @copyright Copyright (c) 2016 Attila Fulop |
9
|
|
|
* @author Attila Fulop |
10
|
|
|
* @license MIT |
11
|
|
|
* @since 2016-08-14 |
12
|
|
|
* |
13
|
|
|
*/ |
14
|
|
|
|
15
|
|
|
namespace Konekt\Concord; |
16
|
|
|
|
17
|
|
|
use Illuminate\Support\ServiceProvider; |
18
|
|
|
use Konekt\Concord\Concerns\AutoGeneratesModuleId; |
19
|
|
|
use Konekt\Concord\Concerns\HasDefaultConvention; |
20
|
|
|
use Konekt\Concord\Concerns\HasModuleConfig; |
21
|
|
|
use Konekt\Concord\Concerns\ReadsManifestFile; |
22
|
|
|
use Konekt\Concord\Concerns\RegistersEnums; |
23
|
|
|
use Konekt\Concord\Concerns\RegistersModels; |
24
|
|
|
use Konekt\Concord\Contracts\Concord as ConcordContract; |
25
|
|
|
use Konekt\Concord\Contracts\Module; |
26
|
|
|
use Konekt\Concord\Module\Kind; |
27
|
|
|
use ReflectionClass; |
28
|
|
|
|
29
|
|
|
class BaseModuleServiceProvider extends ServiceProvider implements Module |
30
|
|
|
{ |
31
|
|
|
use HasModuleConfig; |
32
|
|
|
use AutoGeneratesModuleId; |
33
|
|
|
use HasDefaultConvention; |
34
|
|
|
use RegistersEnums; |
35
|
|
|
use RegistersModels; |
36
|
|
|
use ReadsManifestFile; |
37
|
|
|
|
38
|
|
|
private string $basePath; |
39
|
|
|
|
40
|
|
|
public function __construct($app) |
41
|
|
|
{ |
42
|
|
|
parent::__construct($app); |
43
|
|
|
|
44
|
|
|
$this->concord = $app->make(ConcordContract::class); |
45
|
|
|
$this->basePath = dirname(dirname((new ReflectionClass(static::class))->getFileName())); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
public function boot() |
49
|
|
|
{ |
50
|
|
|
if ($this->areMigrationsEnabled()) { |
51
|
|
|
//$this->registerMigrations(); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
if ($this->areModelsEnabled()) { |
55
|
|
|
$this->registerModels(); |
56
|
|
|
$this->registerEnums(); |
57
|
|
|
//$this->registerRequestTypes(); |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
public function getName(): string |
62
|
|
|
{ |
63
|
|
|
return $this->manifest(static::getConvention())->getName(); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
public function getVersion(): ?string |
67
|
|
|
{ |
68
|
|
|
return $this->manifest(static::getConvention())->getVersion(); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
public function getBasePath(): string |
72
|
|
|
{ |
73
|
|
|
return $this->basePath; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
public function getNamespaceRoot(): string |
77
|
|
|
{ |
78
|
|
|
return ''; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
public function getKind(): Kind |
82
|
|
|
{ |
83
|
|
|
return Kind::MODULE(); |
|
|
|
|
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
public function shortName() |
87
|
|
|
{ |
88
|
|
|
return ''; |
89
|
|
|
} |
90
|
|
|
} |
91
|
|
|
|