|
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\Contracts\Concord as ConcordContract; |
|
24
|
|
|
use Konekt\Concord\Contracts\Module; |
|
25
|
|
|
use Konekt\Concord\Module\Kind; |
|
26
|
|
|
use ReflectionClass; |
|
27
|
|
|
|
|
28
|
|
|
class BaseModuleServiceProvider extends ServiceProvider implements Module |
|
29
|
|
|
{ |
|
30
|
|
|
use HasModuleConfig; |
|
31
|
|
|
use AutoGeneratesModuleId; |
|
32
|
|
|
use HasDefaultConvention; |
|
33
|
|
|
use RegistersEnums; |
|
34
|
|
|
use ReadsManifestFile; |
|
35
|
|
|
|
|
36
|
|
|
private string $basePath; |
|
37
|
|
|
|
|
38
|
|
|
public function __construct($app) |
|
39
|
|
|
{ |
|
40
|
|
|
parent::__construct($app); |
|
41
|
|
|
|
|
42
|
|
|
$this->concord = $app->make(ConcordContract::class); |
|
43
|
|
|
$this->basePath = dirname(dirname((new ReflectionClass(static::class))->getFileName())); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
public function boot() |
|
47
|
|
|
{ |
|
48
|
|
|
if ($this->areMigrationsEnabled()) { |
|
49
|
|
|
//$this->registerMigrations(); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
if ($this->areModelsEnabled()) { |
|
53
|
|
|
//$this->registerModels(); |
|
54
|
|
|
$this->registerEnums(); |
|
55
|
|
|
//$this->registerRequestTypes(); |
|
56
|
|
|
} |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
public function getName(): string |
|
60
|
|
|
{ |
|
61
|
|
|
return $this->manifest(static::getConvention())->getName(); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
public function getVersion(): ?string |
|
65
|
|
|
{ |
|
66
|
|
|
return $this->manifest(static::getConvention())->getVersion(); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
public function getBasePath(): string |
|
70
|
|
|
{ |
|
71
|
|
|
return $this->basePath; |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
public function getNamespaceRoot(): string |
|
75
|
|
|
{ |
|
76
|
|
|
return ''; |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
public function getKind(): Kind |
|
80
|
|
|
{ |
|
81
|
|
|
return Kind::MODULE(); |
|
|
|
|
|
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
public function shortName() |
|
85
|
|
|
{ |
|
86
|
|
|
return ''; |
|
87
|
|
|
} |
|
88
|
|
|
} |
|
89
|
|
|
|