Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
 
3
namespace Illuminate\Console;
4
 
5
trait ConfirmableTrait
6
{
7
    /**
8
     * Confirm before proceeding with the action.
9
     *
10
     * This method only asks for confirmation in production.
11
     *
12
     * @param  string  $warning
13
     * @param  \Closure|bool|null  $callback
14
     * @return bool
15
     */
16
    public function confirmToProceed($warning = 'Application In Production', $callback = null)
17
    {
18
        $callback = is_null($callback) ? $this->getDefaultConfirmCallback() : $callback;
19
 
20
        $shouldConfirm = value($callback);
21
 
22
        if ($shouldConfirm) {
23
            if ($this->hasOption('force') && $this->option('force')) {
24
                return true;
25
            }
26
 
27
            $this->components->alert($warning);
28
 
29
            $confirmed = $this->components->confirm('Do you really wish to run this command?');
30
 
31
            if (! $confirmed) {
32
                $this->newLine();
33
 
34
                $this->components->warn('Command canceled.');
35
 
36
                return false;
37
            }
38
        }
39
 
40
        return true;
41
    }
42
 
43
    /**
44
     * Get the default confirmation callback.
45
     *
46
     * @return \Closure
47
     */
48
    protected function getDefaultConfirmCallback()
49
    {
50
        return function () {
51
            return $this->getLaravel()->environment() === 'production';
52
        };
53
    }
54
}