Salah3id /
address-domains
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Salah3id\Domains\Commands; |
||
| 4 | |||
| 5 | use Illuminate\Foundation\Inspiring; |
||
| 6 | use Illuminate\Support\Str; |
||
| 7 | use Salah3id\Domains\Support\Config\GenerateConfigReader; |
||
| 8 | use Salah3id\Domains\Support\Stub; |
||
| 9 | use Salah3id\Domains\Traits\DomainCommandTrait; |
||
| 10 | use Symfony\Component\Console\Input\InputArgument; |
||
| 11 | |||
| 12 | class ComponentViewMakeCommand extends GeneratorCommand |
||
| 13 | { |
||
| 14 | use DomainCommandTrait; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * The name of argument name. |
||
| 18 | * |
||
| 19 | * @var string |
||
| 20 | */ |
||
| 21 | protected $argumentName = 'name'; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * The console command name. |
||
| 25 | * |
||
| 26 | * @var string |
||
| 27 | */ |
||
| 28 | protected $name = 'domain:make-component-view'; |
||
| 29 | |||
| 30 | /** |
||
| 31 | * The console command description. |
||
| 32 | * |
||
| 33 | * @var string |
||
| 34 | */ |
||
| 35 | protected $description = 'Create a new component-view for the specified domain.'; |
||
| 36 | |||
| 37 | /** |
||
| 38 | * Get the console command arguments. |
||
| 39 | * |
||
| 40 | * @return array |
||
| 41 | */ |
||
| 42 | protected function getArguments() |
||
| 43 | { |
||
| 44 | return [ |
||
| 45 | ['name', InputArgument::REQUIRED, 'The name of the component.'], |
||
| 46 | ['domain', InputArgument::OPTIONAL, 'The name of domain will be used.'], |
||
| 47 | ]; |
||
| 48 | } |
||
| 49 | |||
| 50 | /** |
||
| 51 | * @return mixed |
||
| 52 | */ |
||
| 53 | protected function getTemplateContents() |
||
| 54 | { |
||
| 55 | return (new Stub('/component-view.stub', ['QUOTE'=> Inspiring::quote()]))->render(); |
||
| 56 | } |
||
| 57 | |||
| 58 | /** |
||
| 59 | * @return mixed |
||
| 60 | */ |
||
| 61 | protected function getDestinationFilePath() |
||
| 62 | { |
||
| 63 | $path = $this->laravel['domains']->getDomainPath($this->getDomainName()); |
||
| 64 | $factoryPath = GenerateConfigReader::read('component-view'); |
||
| 65 | |||
| 66 | return $path . $factoryPath->getPath() . '/' . $this->getFileName(); |
||
| 67 | } |
||
| 68 | |||
| 69 | /** |
||
| 70 | * @return string |
||
| 71 | */ |
||
| 72 | private function getFileName() |
||
| 73 | { |
||
| 74 | return Str::lower($this->argument('name')) . '.blade.php'; |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 75 | } |
||
| 76 | } |
||
| 77 |