mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-08 20:22:42 +01:00
72 lines
2.0 KiB
PHP
72 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use Illuminate\Support\Str;
|
|
use Illuminate\Console\Command;
|
|
use Symfony\Component\Console\Input\InputArgument;
|
|
use Symfony\Component\Console\Input\InputOption;
|
|
|
|
use Nwidart\Modules\Commands\GeneratorCommand;
|
|
use Nwidart\Modules\Support\Stub;
|
|
use Nwidart\Modules\Traits\ModuleCommandTrait;
|
|
|
|
class MakeClass extends GeneratorCommand
|
|
{
|
|
use ModuleCommandTrait;
|
|
|
|
protected $argumentName = 'name';
|
|
|
|
/**
|
|
* The name and signature of the console command.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $name = 'ninja:make-class';
|
|
|
|
/**
|
|
* The console command description.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $description = 'Create class stub';
|
|
|
|
protected function getArguments()
|
|
{
|
|
return [
|
|
['name', InputArgument::REQUIRED, 'The name of the datatable.'],
|
|
['module', InputArgument::REQUIRED, 'The name of module will be used.'],
|
|
['class', InputArgument::REQUIRED, 'The name of the class.'],
|
|
];
|
|
}
|
|
|
|
public function getTemplateContents()
|
|
{
|
|
$module = $this->laravel['modules']->findOrFail($this->getModuleName());
|
|
|
|
return (new Stub('/' . $this->argument('class') . '.stub', [
|
|
'NAMESPACE' => $this->getClassNamespace($module) . "\\" . config('modules.paths.generator.' . $this->argument('class')),
|
|
'LOWER_NAME' => $module->getLowerName(),
|
|
'CLASS' => $this->getClass(),
|
|
'STUDLY_NAME' => Str::studly($module->getLowerName()),
|
|
]))->render();
|
|
}
|
|
|
|
public function getDestinationFilePath()
|
|
{
|
|
$path = $this->laravel['modules']->getModulePath($this->getModuleName());
|
|
$seederPath = $this->laravel['modules']->config('paths.generator.' . $this->argument('class'));
|
|
|
|
return $path . $seederPath . '/' . $this->getFileName() . '.php';
|
|
}
|
|
|
|
/**
|
|
* @return string
|
|
*/
|
|
protected function getFileName()
|
|
{
|
|
return studly_case($this->argument('name')) . Str::studly($this->argument('class'));
|
|
}
|
|
|
|
}
|