|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace DigitalEquation\Teamwork\Console; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Console\Command; |
|
6
|
|
|
use Illuminate\Support\Str; |
|
7
|
|
|
|
|
8
|
|
|
class InstallCommand extends Command |
|
9
|
|
|
{ |
|
10
|
|
|
/** |
|
11
|
|
|
* The name and signature of the console command. |
|
12
|
|
|
* |
|
13
|
|
|
* @var string |
|
14
|
|
|
*/ |
|
15
|
|
|
protected $signature = 'teamwork:install'; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* The console command description. |
|
19
|
|
|
* |
|
20
|
|
|
* @var string |
|
21
|
|
|
*/ |
|
22
|
|
|
protected $description = 'Install all of the Teamwork resources'; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* Execute the console command. |
|
26
|
|
|
* |
|
27
|
|
|
* @return void |
|
28
|
|
|
*/ |
|
29
|
|
|
public function handle() |
|
30
|
|
|
{ |
|
31
|
|
|
$this->comment('Publishing Teamwork Service Provider...'); |
|
32
|
|
|
$this->callSilent('vendor:publish', ['--tag' => 'provider']); |
|
33
|
|
|
|
|
34
|
|
|
$this->comment('Publishing Teamwork Configuration...'); |
|
35
|
|
|
$this->callSilent('vendor:publish', ['--tag' => 'config']); |
|
36
|
|
|
|
|
37
|
|
|
$this->registerTeamworkServiceProvider(); |
|
38
|
|
|
|
|
39
|
|
|
$this->info('Teamwork scaffolding installed successfully.'); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* Register the Teamwork service provider in the application configuration file. |
|
44
|
|
|
* |
|
45
|
|
|
* @return void |
|
46
|
|
|
*/ |
|
47
|
|
|
protected function registerTeamworkServiceProvider() |
|
48
|
|
|
{ |
|
49
|
|
|
$namespace = Str::replaceLast('\\', '', $this->getAppNamespace()); |
|
|
|
|
|
|
50
|
|
|
|
|
51
|
|
|
$appConfig = file_get_contents(config_path('app.php')); |
|
52
|
|
|
|
|
53
|
|
|
if (Str::contains($appConfig, $namespace.'\\DigitalEquation\Teamwork\TeamworkServiceProvider::class')) { |
|
54
|
|
|
return; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
file_put_contents(config_path('app.php'), str_replace( |
|
58
|
|
|
'/* |
|
59
|
|
|
* Package Service Providers... |
|
60
|
|
|
*/'.PHP_EOL, |
|
61
|
|
|
'/* |
|
62
|
|
|
* Package Service Providers... |
|
63
|
|
|
*/'.PHP_EOL." DigitalEquation\Teamwork\TeamworkServiceProvider::class,".PHP_EOL, |
|
64
|
|
|
$appConfig |
|
65
|
|
|
)); |
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
|
If you implement
__calland you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.This is often the case, when
__callis implemented by a parent class and only the child class knows which methods exist: