Nextrek
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
|
<?php namespace Illuminate\Console;
use Closure;
trait ConfirmableTrait {
/**
* Confirm before proceeding with the action
*
* @param string $warning
* @param \Closure $callback
* @return bool
*/
public function confirmToProceed($warning = 'Application In Production!', Closure $callback = null)
{
$shouldConfirm = $callback ?: $this->getDefaultConfirmCallback();
if (call_user_func($shouldConfirm))
{
if ($this->option('force')) return true;
$this->comment(str_repeat('*', strlen($warning) + 12));
$this->comment('* '.$warning.' *');
$this->comment(str_repeat('*', strlen($warning) + 12));
$this->output->writeln('');
$confirmed = $this->confirm('Do you really wish to run this command?');
if ( ! $confirmed)
{
$this->comment('Command Cancelled!');
return false;
}
}
return true;
}
/**
* Get the default confirmation callback.
*
* @return \Closure
*/
protected function getDefaultConfirmCallback()
{
return function() { return $this->getLaravel()->environment() == 'production'; };
}
}
|
Revision |
Author |
Commited |
Message |
1464
|
MOliva
|
Tue 13 Oct, 2020 11:16:56 +0000 |
|