forked from saloonphp/laravel-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakeConnector.php
More file actions
88 lines (75 loc) · 2.11 KB
/
MakeConnector.php
File metadata and controls
88 lines (75 loc) · 2.11 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
declare(strict_types=1);
namespace Saloon\Laravel\Console\Commands;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class MakeConnector extends MakeCommand
{
/**
* The console command name.
*
* @var string
*/
protected $name = 'saloon:connector';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Create a new Saloon connector class';
/**
* The type of class being generated.
*
* @var string
*/
protected $type = 'Saloon Connector';
/**
* The namespace to place the file
*
* @var string
*/
protected $namespace = '\Http\Integrations\{integration}';
protected function resolveStubName(): string
{
return $this->option('oauth')
? 'saloon.oauth-connector.stub'
: 'saloon.connector.stub';
}
/**
* Get the options for making a connector
*
* @return array<int, array<mixed>>
*/
protected function getOptions(): array
{
return [
['oauth', null, InputOption::VALUE_NONE, 'Whether the connector should include the OAuth boilerplate'],
];
}
/**
* Interact further with the user if they were prompted for missing arguments.
*
* @return void
*/
protected function afterPromptingForMissingArguments(InputInterface $input, OutputInterface $output)
{
if ($this->didReceiveOptions($input)) {
return;
}
$supportOauth = $this->confirm('Should the connector support OAuth? (Authorization Code Grant)');
$input->setOption('oauth', $supportOauth);
}
/**
* Prompt for missing input arguments using the returned questions.
*
* @return array<string, string|\Closure>
*/
protected function promptForMissingArgumentsUsing(): array
{
return [
...parent::promptForMissingArgumentsUsing(),
'name' => 'What should the saloon connector be named?',
];
}
}