1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Acacha\AdminLTETemplateLaravel\Console; |
4
|
|
|
|
5
|
|
|
use Acacha\AdminLTETemplateLaravel\Console\Traits\UseComposer; |
6
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
7
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
8
|
|
|
use Symfony\Component\Console\Input\InputOption; |
9
|
|
|
use Symfony\Component\Console\Command\Command; |
10
|
|
|
use Symfony\Component\Process\Process; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Class SocialCommand. |
14
|
|
|
*/ |
15
|
|
|
class SocialCommand extends Command |
16
|
|
|
{ |
17
|
|
|
use UseComposer; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Get package name to install. |
21
|
|
|
*/ |
22
|
|
|
protected function getPackageName() |
23
|
|
|
{ |
24
|
|
|
return 'acacha/laravel-social'; |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Configure the command options. |
29
|
|
|
*/ |
30
|
|
|
protected function configure() |
31
|
|
|
{ |
32
|
|
|
$this->ignoreValidationErrors(); |
33
|
|
|
|
34
|
|
|
$this->setName('social') |
35
|
|
|
->setDescription('Add Acacha Laravel Social Package: OAuth Social Login/Register support using Socialite into the current project.') |
36
|
|
|
->addOption( |
37
|
|
|
'dev', |
38
|
|
|
'-d', |
39
|
|
|
InputOption::VALUE_NONE, |
40
|
|
|
'Installs the latest "development" release' |
41
|
|
|
); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Execute the command. |
46
|
|
|
* |
47
|
|
|
* @param InputInterface $input |
48
|
|
|
* @param OutputInterface $output |
49
|
|
|
* |
50
|
|
|
* @return void |
51
|
|
|
*/ |
52
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
53
|
|
|
{ |
54
|
|
|
$process = new Process( |
55
|
|
|
$this->findComposer() .' require ' . $package = $this->getPackageName() . $this->getDevSuffix($input), |
56
|
|
|
null, |
57
|
|
|
null, |
58
|
|
|
null, |
59
|
|
|
null |
60
|
|
|
); |
61
|
|
|
|
62
|
|
|
$output->writeln('<info>Running composer require ' . $package .'</info>'); |
63
|
|
|
$process->run(function ($type, $line) use ($output) { |
64
|
|
|
$output->write($line); |
65
|
|
|
}); |
66
|
|
|
|
67
|
|
|
$this->runMakeSocial($output); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* Gets dev suffix. |
72
|
|
|
* |
73
|
|
|
* @param InputInterface $input |
74
|
|
|
* @return string |
75
|
|
|
*/ |
76
|
|
|
private function getDevSuffix(InputInterface $input) |
77
|
|
|
{ |
78
|
|
|
return $input->getOption('dev') ? ':dev-master' : ''; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* Run make social. |
83
|
|
|
* |
84
|
|
|
* @param OutputInterface $output |
85
|
|
|
*/ |
86
|
|
|
protected function runMakeSocial(OutputInterface $output) |
87
|
|
|
{ |
88
|
|
|
$output->writeln('<info>php artisan make:social</info>'); |
89
|
|
|
passthru('php artisan make:social'); |
90
|
|
|
} |
91
|
|
|
} |
92
|
|
|
|