|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This file is part of Laravel Zero. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Nuno Maduro <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace LaravelZero\Framework\Components; |
|
13
|
|
|
|
|
14
|
|
|
use Illuminate\Filesystem\Filesystem; |
|
15
|
|
|
use LaravelZero\Framework\Commands\Command; |
|
16
|
|
|
use LaravelZero\Framework\Contracts\Commands\Component\Installer; |
|
17
|
|
|
use LaravelZero\Framework\Contracts\Providers\Composer as ComposerContract; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* This is the Laravel Zero Framework Abstract Installer Implementation. |
|
21
|
|
|
*/ |
|
22
|
|
|
abstract class AbstractInstaller extends Command implements Installer |
|
23
|
|
|
{ |
|
24
|
|
|
/** |
|
25
|
|
|
* Holds an instance of Files. |
|
26
|
|
|
* |
|
27
|
|
|
* @var \Illuminate\Filesystem\Filesystem |
|
28
|
|
|
*/ |
|
29
|
|
|
protected $files; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* Holds an instance of composer. |
|
33
|
|
|
* |
|
34
|
|
|
* @var \LaravelZero\Framework\Contracts\Providers\Composer |
|
35
|
|
|
*/ |
|
36
|
|
|
protected $composer; |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* Installer constructor. |
|
40
|
|
|
* |
|
41
|
|
|
* @param \Illuminate\Filesystem\Filesystem $files |
|
42
|
|
|
* @param \LaravelZero\Framework\Contracts\Providers\Composer $composer |
|
43
|
|
|
*/ |
|
44
|
6 |
|
public function __construct(Filesystem $files, ComposerContract $composer) |
|
45
|
|
|
{ |
|
46
|
6 |
|
parent::__construct(); |
|
47
|
|
|
|
|
48
|
6 |
|
$this->files = $files; |
|
49
|
|
|
|
|
50
|
6 |
|
$this->composer = $composer; |
|
51
|
6 |
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* {@inheritdoc} |
|
55
|
|
|
*/ |
|
56
|
6 |
|
public function handle(): void |
|
57
|
|
|
{ |
|
58
|
6 |
|
$this->install(); |
|
59
|
6 |
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* Requires the provided package. |
|
63
|
|
|
* |
|
64
|
|
|
* @param string $package |
|
65
|
|
|
* |
|
66
|
|
|
* @return \LaravelZero\Framework\Contracts\Commands\Component\Installer |
|
67
|
|
|
*/ |
|
68
|
6 |
|
protected function require(string $package): Installer |
|
69
|
|
|
{ |
|
70
|
6 |
|
$this->task( |
|
|
|
|
|
|
71
|
6 |
|
'Require package via composer', |
|
72
|
6 |
|
function () use ($package) { |
|
73
|
6 |
|
return $this->composer->require($package); |
|
74
|
6 |
|
} |
|
75
|
|
|
); |
|
76
|
|
|
|
|
77
|
6 |
|
return $this; |
|
78
|
|
|
} |
|
79
|
|
|
} |
|
80
|
|
|
|
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: