|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace LaravelZero\Framework; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Events\Dispatcher; |
|
6
|
|
|
use Illuminate\Support\Traits\CapsuleManagerTrait; |
|
7
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
8
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
9
|
|
|
use Illuminate\Console\Application as BaseApplication; |
|
10
|
|
|
use Symfony\Component\Console\Command\Command; |
|
11
|
|
|
use Illuminate\Contracts\Events\Dispatcher as DispatcherContract; |
|
12
|
|
|
use Illuminate\Contracts\Container\Container as ContainerContract; |
|
13
|
|
|
use LaravelZero\Framework\Contracts\Application as ApplicationContract; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* This is the Zero Framework application class. |
|
17
|
|
|
* |
|
18
|
|
|
* @author Nuno Maduro <[email protected]> |
|
19
|
|
|
*/ |
|
20
|
|
|
class Application extends BaseApplication implements ApplicationContract |
|
21
|
|
|
{ |
|
22
|
|
|
use CapsuleManagerTrait; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* The application event dispatcher. |
|
26
|
|
|
* |
|
27
|
|
|
* @var \Illuminate\Contracts\Events\Dispatcher |
|
28
|
|
|
*/ |
|
29
|
|
|
protected $dispatcher; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* The current running command. |
|
33
|
|
|
* |
|
34
|
|
|
* @var \Symfony\Component\Console\Command\Command |
|
35
|
|
|
*/ |
|
36
|
|
|
protected $runningCommand; |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* Creates a new instance of the application. |
|
40
|
|
|
* |
|
41
|
|
|
* @param \Illuminate\Contracts\Container\Container|null $container |
|
42
|
|
|
* @param \Illuminate\Contracts\Events\Dispatcher|null $dispatcher |
|
43
|
|
|
* @param \LaravelZero\Framework\Bootstrappers\Factory|null $bootstrappersFactory |
|
44
|
|
|
*/ |
|
45
|
|
|
public function __construct( |
|
46
|
|
|
ContainerContract $container = null, |
|
47
|
|
|
DispatcherContract $dispatcher = null, |
|
48
|
|
|
Bootstrappers\Factory $bootstrappersFactory = null |
|
49
|
|
|
) { |
|
50
|
|
|
$this->setupContainer($container ?: new Container); |
|
51
|
|
|
$this->dispatcher = $dispatcher ?: new Dispatcher($this->container); |
|
52
|
|
|
static::$bootstrappers = ($bootstrappersFactory ?: new Bootstrappers\Factory)->make(); |
|
53
|
|
|
parent::__construct($this->container, $this->dispatcher, ''); |
|
54
|
|
|
|
|
55
|
|
|
$this->setCatchExceptions(true); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* Gets the name of the command based on input. |
|
60
|
|
|
* |
|
61
|
|
|
* Proxies to the Laravel default command if there is no application |
|
62
|
|
|
* default command. |
|
63
|
|
|
* |
|
64
|
|
|
* @param \Symfony\Component\Console\Input\InputInterface $input The input interface |
|
65
|
|
|
* |
|
66
|
|
|
* @return string|null |
|
67
|
|
|
*/ |
|
68
|
|
|
protected function getCommandName(InputInterface $input) |
|
69
|
|
|
{ |
|
70
|
|
|
if (($name = parent::getCommandName($input)) || ($defaultCommand = $this->container->make('config') |
|
71
|
|
|
->get('app.default-command')) === null) { |
|
72
|
|
|
return $name; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
return $this->container->make($defaultCommand) |
|
76
|
|
|
->getName(); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* {@inheritdoc} |
|
81
|
|
|
*/ |
|
82
|
|
|
protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output) |
|
83
|
|
|
{ |
|
84
|
|
|
|
|
85
|
|
|
return parent::doRunCommand($this->runningCommand = $command, $input, $output); |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
/** |
|
89
|
|
|
* {@inheritdoc} |
|
90
|
|
|
*/ |
|
91
|
|
|
public function getRunningCommand(): Command |
|
92
|
|
|
{ |
|
93
|
|
|
return $this->runningCommand; |
|
94
|
|
|
} |
|
95
|
|
|
} |
|
96
|
|
|
|