forked from nWidart/laravel-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLumenModulesServiceProvider.php
58 lines (49 loc) · 1.42 KB
/
LumenModulesServiceProvider.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
namespace Nwidart\Modules;
use Nwidart\Modules\Support\Stub;
class LumenModulesServiceProvider extends ModulesServiceProvider
{
/**
* Booting the package.
*/
public function boot()
{
$this->setupStubPath();
}
/**
* Register all modules.
*/
public function register()
{
$this->registerNamespaces();
$this->registerServices();
$this->registerModules();
$this->registerProviders();
}
/**
* Setup stub path.
*/
public function setupStubPath()
{
Stub::setBasePath(__DIR__ . '/Commands/stubs');
if (app('modules')->config('stubs.enabled') === true) {
Stub::setBasePath(app('modules')->config('stubs.path'));
}
}
/**
* {@inheritdoc}
*/
protected function registerServices()
{
$this->app->singleton(Contracts\RepositoryInterface::class, function ($app) {
$path = $app['config']->get('modules.paths.modules');
return new Lumen\LumenFileRepository($app, $path);
});
$this->app->singleton(Contracts\ActivatorInterface::class, function ($app) {
$activator = $app['config']->get('modules.activator');
$class = $app['config']->get('modules.activators.' . $activator)['class'];
return new $class($app);
});
$this->app->alias(Contracts\RepositoryInterface::class, 'modules');
}
}