1
|
|
|
<?php
|
2
|
|
|
|
3
|
|
|
namespace Resta\Console\Source\Client;
|
4
|
|
|
|
5
|
|
|
use Resta\Console\ConsoleOutputter;
|
6
|
|
|
use Resta\Console\ConsoleListAccessor;
|
7
|
|
|
use Resta\Foundation\PathManager\StaticPathModel;
|
8
|
|
|
use Resta\Support\Utils;
|
9
|
|
|
|
10
|
|
|
class Client extends ConsoleOutputter
|
11
|
|
|
{
|
12
|
|
|
use ConsoleListAccessor;
|
13
|
|
|
|
14
|
|
|
/**
|
15
|
|
|
* @var string
|
16
|
|
|
*/
|
17
|
|
|
public $type = 'client';
|
18
|
|
|
|
19
|
|
|
/**
|
20
|
|
|
* @var array
|
21
|
|
|
*/
|
22
|
|
|
protected $runnableMethods = [
|
23
|
|
|
'create'=>'Creates request object'
|
24
|
|
|
];
|
25
|
|
|
|
26
|
|
|
/**
|
27
|
|
|
* @var bool
|
28
|
|
|
*/
|
29
|
|
|
protected $projectStatus = true;
|
30
|
|
|
|
31
|
|
|
/**
|
32
|
|
|
* @var array
|
33
|
|
|
*/
|
34
|
|
|
public $commandRule=['name','client'];
|
35
|
|
|
|
36
|
|
|
/**
|
37
|
|
|
* @method create
|
38
|
|
|
* @return mixed
|
39
|
|
|
*/
|
40
|
|
|
public function create()
|
41
|
|
|
{
|
42
|
|
|
$name = $this->argument['name'];
|
43
|
|
|
$client = $this->argument['client'];
|
44
|
|
|
|
45
|
|
|
|
46
|
|
|
$this->directory['clientNameCreate'] = path()->request();
|
47
|
|
|
$this->argument['clientNameNamespace'] = Utils::getNamespace($this->directory['clientNameCreate']);
|
48
|
|
|
$this->directory['clientNameDir'] = $this->directory['clientNameCreate'].'/'.$name;
|
49
|
|
|
$this->directory['clientSource'] = $this->directory['clientNameDir'].'/'.$client;
|
50
|
|
|
$this->argument['clientSourceNamespace'] = Utils::getNamespace($this->directory['clientNameDir'].'/'.$client.'');
|
51
|
|
|
|
52
|
|
|
//set project directory
|
53
|
|
|
$this->file->makeDirectory($this);
|
54
|
|
|
|
55
|
|
|
if(!file_exists($this->directory['clientNameCreate'].'/Client.php')){
|
56
|
|
|
$this->touch['client/client'] = $this->directory['clientNameCreate'].'/Client.php';
|
57
|
|
|
$this->touch['client/clientGenerator'] = $this->directory['clientNameCreate'].'/ClientGenerator.php';
|
58
|
|
|
}
|
59
|
|
|
|
60
|
|
|
if(!file_exists($clientSourceName = $this->directory['clientSource'].'/'.$client.'.php')){
|
61
|
|
|
$this->touch['client/source'] = $clientSourceName.'';
|
62
|
|
|
//$this->touch['client/sourcegenerator'] = $this->directory['clientSource'].'/'.$client.'Generator.php';
|
63
|
|
|
}
|
64
|
|
|
|
65
|
|
|
if(!file_exists($this->directory['clientNameCreate'].'/ClientProvider.php')){
|
66
|
|
|
$this->touch['client/clientProvider'] = $this->directory['clientNameCreate'].'/ClientProvider.php';
|
67
|
|
|
}
|
68
|
|
|
|
69
|
|
|
$this->touch['client/clientGeneratorFile'] = $this->directory['clientSource'].'/'.$client.'Generator.php';
|
70
|
|
|
|
71
|
|
|
|
72
|
|
|
//set project touch
|
73
|
|
|
$this->file->touch($this);
|
74
|
|
|
|
75
|
|
|
exit();
|
|
|
|
|
76
|
|
|
echo $this->classical(' > Request called as "'.$request.'" has been successfully created in the '.app()->namespace()->optionalSource().'');
|
|
|
|
|
77
|
|
|
}
|
78
|
|
|
} |
In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.