This repository was archived by the owner on Mar 8, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 249
Expand file tree
/
Copy pathRepositoryProvider.php
More file actions
141 lines (122 loc) · 3.39 KB
/
Copy pathRepositoryProvider.php
File metadata and controls
141 lines (122 loc) · 3.39 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<?php
namespace Bosnadev\Repositories\Providers;
use Illuminate\Support\Composer;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\ServiceProvider;
use Bosnadev\Repositories\Console\Commands\MakeCriteriaCommand;
use Bosnadev\Repositories\Console\Commands\MakeRepositoryCommand;
use Bosnadev\Repositories\Console\Commands\Creators\CriteriaCreator;
use Bosnadev\Repositories\Console\Commands\Creators\RepositoryCreator;
/**
* Class RepositoryProvider
*
* @package Bosnadev\Repositories\Providers
*/
class RepositoryProvider extends ServiceProvider
{
/**
* Indicates if loading of the provider is deferred.
*
* @var bool
*/
protected $defer = true;
/**
* Bootstrap the application services.
*
* @return void
*/
public function boot()
{
// Config path.
$config_path = __DIR__ . '/../../../../config/repositories.php';
// Publish config.
$this->publishes(
[$config_path => config_path('repositories.php')],
'repositories'
);
}
/**
* Register the application services.
*
* @return void
*/
public function register()
{
// Register bindings.
$this->registerBindings();
// Register make repository command.
$this->registerMakeRepositoryCommand();
// Register make criteria command.
$this->registerMakeCriteriaCommand();
// Register commands
$this->commands(['command.repository.make', 'command.criteria.make']);
// Config path.
$config_path = __DIR__ . '/../../../config/repositories.php';
// Merge config.
$this->mergeConfigFrom(
$config_path,
'repositories'
);
}
/**
* Register the bindings.
*/
protected function registerBindings()
{
// FileSystem.
$this->app->instance('FileSystem', new Filesystem());
// Composer.
$this->app->bind('Composer', function ($app)
{
return new Composer($app['FileSystem']);
});
// Repository creator.
$this->app->singleton('RepositoryCreator', function ($app)
{
return new RepositoryCreator($app['FileSystem']);
});
// Criteria creator.
$this->app->singleton('CriteriaCreator', function ($app)
{
return new CriteriaCreator($app['FileSystem']);
});
}
/**
* Register the make:repository command.
*/
protected function registerMakeRepositoryCommand()
{
// Make repository command.
$this->app->singleton('command.repository.make',
function($app)
{
return new MakeRepositoryCommand($app['RepositoryCreator'], $app['Composer']);
}
);
}
/**
* Register the make:criteria command.
*/
protected function registerMakeCriteriaCommand()
{
// Make criteria command.
$this->app->singleton('command.criteria.make',
function($app)
{
return new MakeCriteriaCommand($app['CriteriaCreator'], $app['Composer']);
}
);
}
/**
* Get the services provided by the provider.
*
* @return array
*/
public function provides()
{
return [
'command.repository.make',
'command.criteria.make'
];
}
}