1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Arcanedev\Support\Providers\Concerns; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Trait InteractsWithApplication |
9
|
|
|
* |
10
|
|
|
* @package Arcanedev\Support\Providers\Concerns |
11
|
|
|
* @author ARCANEDEV <[email protected]> |
12
|
|
|
* |
13
|
|
|
* @property \Illuminate\Foundation\Application|mixed $app |
14
|
|
|
*/ |
15
|
|
|
trait InteractsWithApplication |
16
|
|
|
{ |
17
|
|
|
/* ----------------------------------------------------------------- |
18
|
|
|
| Main Methods |
19
|
|
|
| ----------------------------------------------------------------- |
20
|
|
|
*/ |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Register a service provider. |
24
|
|
|
* |
25
|
|
|
* @param \Illuminate\Support\ServiceProvider|string $provider |
26
|
|
|
* @param bool $force |
27
|
|
|
* |
28
|
|
|
* @return \Illuminate\Support\ServiceProvider |
29
|
|
|
*/ |
30
|
|
|
protected function registerProvider($provider, $force = false) |
31
|
|
|
{ |
32
|
|
|
return $this->app->register($provider, $force); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Register multiple service providers. |
37
|
|
|
* |
38
|
|
|
* @param array $providers |
39
|
|
|
*/ |
40
|
|
|
protected function registerProviders(array $providers) |
41
|
|
|
{ |
42
|
|
|
foreach ($providers as $provider) { |
43
|
|
|
$this->registerProvider($provider); |
44
|
|
|
} |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Register a console service provider. |
49
|
|
|
* |
50
|
|
|
* @param \Illuminate\Support\ServiceProvider|string $provider |
51
|
|
|
* @param bool $force |
52
|
|
|
* |
53
|
|
|
* @return \Illuminate\Support\ServiceProvider|null |
54
|
|
|
*/ |
55
|
|
|
protected function registerConsoleServiceProvider($provider, $force = false) |
56
|
|
|
{ |
57
|
|
|
if ($this->app->runningInConsole()) { |
58
|
|
|
return $this->registerProvider($provider, $force); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
return null; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* Register the package's custom Artisan commands when running in console. |
66
|
|
|
* |
67
|
|
|
* @param array $commands |
68
|
|
|
*/ |
69
|
|
|
protected function registerCommands(array $commands) |
70
|
|
|
{ |
71
|
|
|
if ($this->app->runningInConsole()) { |
72
|
|
|
$this->commands($commands); |
|
|
|
|
73
|
|
|
} |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* Register a binding with the container. |
78
|
|
|
* |
79
|
|
|
* @param string $abstract |
80
|
|
|
* @param \Closure|string|null $concrete |
81
|
|
|
* @param bool $shared |
82
|
|
|
*/ |
83
|
|
|
protected function bind($abstract, $concrete = null, $shared = false) |
84
|
|
|
{ |
85
|
|
|
$this->app->bind($abstract, $concrete, $shared); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* Register a shared binding in the container. |
90
|
|
|
* |
91
|
|
|
* @param string|array $abstract |
92
|
|
|
* @param \Closure|string|null $concrete |
93
|
|
|
*/ |
94
|
|
|
protected function singleton($abstract, $concrete = null) |
95
|
|
|
{ |
96
|
|
|
$this->app->singleton($abstract, $concrete); |
97
|
|
|
} |
98
|
|
|
} |
99
|
|
|
|
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.