-
-
Notifications
You must be signed in to change notification settings - Fork 160
/
Copy pathViewInput.php
97 lines (85 loc) · 2.24 KB
/
ViewInput.php
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
89
90
91
92
93
94
95
96
97
<?php
namespace CrestApps\CodeGenerator\Models;
use CrestApps\CodeGenerator\Support\Helpers;
use CrestApps\CodeGenerator\Traits\LanguageTrait;
class ViewInput
{
use LanguageTrait;
/**
* The provided modelName
*
* @var string
*/
public $modelName;
/**
* The provided field's file name
*
* @var string
*/
public $resourceFile;
/**
* The provided views directory name
*
* @var string
*/
public $viewsDirectory;
/**
* The provided route's prefix
*
* @var string
*/
public $prefix;
/**
* Overrides existing view.
*
* @var string
*/
public $force;
/**
* The provided language's file name
*
* @var string
*/
public $languageFileName;
/**
* The provided layout name
*
* @var string
*/
public $layout;
/**
* Create a new input instance.
*
* @return void
*/
public function __construct(array $arguments, array $options = [])
{
$this->modelName = trim($arguments['model-name']);
$this->resourceFile = trim($options['resource-file']) ?: Helpers::makeJsonFileName($this->modelName);
$this->viewsDirectory = trim($options['views-directory']);
$prefix = trim($options['routes-prefix']);
$this->prefix = ($prefix == 'default-form') ? Helpers::makeRouteGroup($this->modelName) : $prefix;
$this->force = $options['force'];
$this->languageFileName = trim($options['language-filename']) ?: self::makeLocaleGroup($this->modelName);
$this->layout = trim($options['layout-name']);
$this->template = trim($options['template-name']);
}
/**
* Gets array of the parameters
*
* @return array
*/
public function getArrguments()
{
return [
'model-name' => $this->modelName,
'--resource-file' => $this->resourceFile,
'--views-directory' => $this->viewsDirectory,
'--routes-prefix' => $this->prefix,
'--language-filename' => $this->languageFileName,
'--layout-name' => $this->layout,
'--template-name' => $this->template,
'--force' => $this->force,
];
}
}