| @@ 9-86 (lines=78) @@ | ||
| 6 | use Nwidart\Modules\Traits\ModuleCommandTrait; |
|
| 7 | use Symfony\Component\Console\Input\InputArgument; |
|
| 8 | ||
| 9 | class GenerateJobCommand extends GeneratorCommand |
|
| 10 | { |
|
| 11 | use ModuleCommandTrait; |
|
| 12 | ||
| 13 | /** |
|
| 14 | * The console command name. |
|
| 15 | * |
|
| 16 | * @var string |
|
| 17 | */ |
|
| 18 | protected $name = 'module:make-job'; |
|
| 19 | ||
| 20 | /** |
|
| 21 | * The console command description. |
|
| 22 | * |
|
| 23 | * @var string |
|
| 24 | */ |
|
| 25 | protected $description = 'Generate a new Job Class for the specified module'; |
|
| 26 | ||
| 27 | protected $argumentName = 'name'; |
|
| 28 | ||
| 29 | /** |
|
| 30 | * Get the console command arguments. |
|
| 31 | * |
|
| 32 | * @return array |
|
| 33 | */ |
|
| 34 | protected function getArguments() |
|
| 35 | { |
|
| 36 | return [ |
|
| 37 | ['name', InputArgument::REQUIRED, 'The name of the job.'], |
|
| 38 | ['module', InputArgument::OPTIONAL, 'The name of module will be used.'], |
|
| 39 | ]; |
|
| 40 | } |
|
| 41 | ||
| 42 | /** |
|
| 43 | * Get template contents. |
|
| 44 | * |
|
| 45 | * @return string |
|
| 46 | */ |
|
| 47 | protected function getTemplateContents() |
|
| 48 | { |
|
| 49 | $module = $this->laravel['modules']->findOrFail($this->getModuleName()); |
|
| 50 | ||
| 51 | return (new Stub('/job.stub', [ |
|
| 52 | 'NAMESPACE' => $this->getClassNamespace($module), |
|
| 53 | 'CLASS' => $this->getClass(), |
|
| 54 | ]))->render(); |
|
| 55 | } |
|
| 56 | ||
| 57 | /** |
|
| 58 | * Get the destination file path. |
|
| 59 | * |
|
| 60 | * @return string |
|
| 61 | */ |
|
| 62 | protected function getDestinationFilePath() |
|
| 63 | { |
|
| 64 | $path = $this->laravel['modules']->getModulePath($this->getModuleName()); |
|
| 65 | ||
| 66 | $jobPath = $this->laravel['modules']->config('paths.generator.jobs'); |
|
| 67 | ||
| 68 | return $path . $jobPath . '/' . $this->getFileName() . '.php'; |
|
| 69 | } |
|
| 70 | ||
| 71 | /** |
|
| 72 | * @return string |
|
| 73 | */ |
|
| 74 | private function getFileName() |
|
| 75 | { |
|
| 76 | return studly_case($this->argument('name')); |
|
| 77 | } |
|
| 78 | ||
| 79 | /** |
|
| 80 | * @return string |
|
| 81 | */ |
|
| 82 | public function getDefaultNamespace() |
|
| 83 | { |
|
| 84 | return 'Jobs'; |
|
| 85 | } |
|
| 86 | } |
|
| 87 | ||
| @@ 9-86 (lines=78) @@ | ||
| 6 | use Nwidart\Modules\Traits\ModuleCommandTrait; |
|
| 7 | use Symfony\Component\Console\Input\InputArgument; |
|
| 8 | ||
| 9 | class GenerateMailCommand extends GeneratorCommand |
|
| 10 | { |
|
| 11 | use ModuleCommandTrait; |
|
| 12 | ||
| 13 | /** |
|
| 14 | * The console command name. |
|
| 15 | * |
|
| 16 | * @var string |
|
| 17 | */ |
|
| 18 | protected $name = 'module:make-mail'; |
|
| 19 | ||
| 20 | /** |
|
| 21 | * The console command description. |
|
| 22 | * |
|
| 23 | * @var string |
|
| 24 | */ |
|
| 25 | protected $description = 'Generate a new Mailable Class for the specified module'; |
|
| 26 | ||
| 27 | protected $argumentName = 'name'; |
|
| 28 | ||
| 29 | /** |
|
| 30 | * Get the console command arguments. |
|
| 31 | * |
|
| 32 | * @return array |
|
| 33 | */ |
|
| 34 | protected function getArguments() |
|
| 35 | { |
|
| 36 | return [ |
|
| 37 | ['name', InputArgument::REQUIRED, 'The name of the mailable.'], |
|
| 38 | ['module', InputArgument::OPTIONAL, 'The name of module will be used.'], |
|
| 39 | ]; |
|
| 40 | } |
|
| 41 | ||
| 42 | /** |
|
| 43 | * Get template contents. |
|
| 44 | * |
|
| 45 | * @return string |
|
| 46 | */ |
|
| 47 | protected function getTemplateContents() |
|
| 48 | { |
|
| 49 | $module = $this->laravel['modules']->findOrFail($this->getModuleName()); |
|
| 50 | ||
| 51 | return (new Stub('/mail.stub', [ |
|
| 52 | 'NAMESPACE' => $this->getClassNamespace($module), |
|
| 53 | 'CLASS' => $this->getClass(), |
|
| 54 | ]))->render(); |
|
| 55 | } |
|
| 56 | ||
| 57 | /** |
|
| 58 | * Get the destination file path. |
|
| 59 | * |
|
| 60 | * @return string |
|
| 61 | */ |
|
| 62 | protected function getDestinationFilePath() |
|
| 63 | { |
|
| 64 | $path = $this->laravel['modules']->getModulePath($this->getModuleName()); |
|
| 65 | ||
| 66 | $mailPath = $this->laravel['modules']->config('paths.generator.emails', 'Emails'); |
|
| 67 | ||
| 68 | return $path . $mailPath . '/' . $this->getFileName() . '.php'; |
|
| 69 | } |
|
| 70 | ||
| 71 | /** |
|
| 72 | * @return string |
|
| 73 | */ |
|
| 74 | private function getFileName() |
|
| 75 | { |
|
| 76 | return studly_case($this->argument('name')); |
|
| 77 | } |
|
| 78 | ||
| 79 | /** |
|
| 80 | * @return string |
|
| 81 | */ |
|
| 82 | public function getDefaultNamespace() |
|
| 83 | { |
|
| 84 | return $this->laravel['modules']->config('paths.generator.emails', 'Emails'); |
|
| 85 | } |
|
| 86 | } |
|
| 87 | ||
| @@ 9-86 (lines=78) @@ | ||
| 6 | use Nwidart\Modules\Traits\ModuleCommandTrait; |
|
| 7 | use Symfony\Component\Console\Input\InputArgument; |
|
| 8 | ||
| 9 | final class GenerateNotificationCommand extends GeneratorCommand |
|
| 10 | { |
|
| 11 | use ModuleCommandTrait; |
|
| 12 | ||
| 13 | /** |
|
| 14 | * The console command name. |
|
| 15 | * |
|
| 16 | * @var string |
|
| 17 | */ |
|
| 18 | protected $name = 'module:make-notification'; |
|
| 19 | ||
| 20 | protected $argumentName = 'name'; |
|
| 21 | ||
| 22 | /** |
|
| 23 | * The console command description. |
|
| 24 | * |
|
| 25 | * @var string |
|
| 26 | */ |
|
| 27 | protected $description = 'Generate new notification class for the specified module.'; |
|
| 28 | ||
| 29 | /** |
|
| 30 | * Get template contents. |
|
| 31 | * |
|
| 32 | * @return string |
|
| 33 | */ |
|
| 34 | protected function getTemplateContents() |
|
| 35 | { |
|
| 36 | $module = $this->laravel['modules']->findOrFail($this->getModuleName()); |
|
| 37 | ||
| 38 | return (new Stub('/notification.stub', [ |
|
| 39 | 'NAMESPACE' => $this->getClassNamespace($module), |
|
| 40 | 'CLASS' => $this->getClass(), |
|
| 41 | ]))->render(); |
|
| 42 | } |
|
| 43 | ||
| 44 | /** |
|
| 45 | * Get the destination file path. |
|
| 46 | * |
|
| 47 | * @return string |
|
| 48 | */ |
|
| 49 | protected function getDestinationFilePath() |
|
| 50 | { |
|
| 51 | $path = $this->laravel['modules']->getModulePath($this->getModuleName()); |
|
| 52 | ||
| 53 | $mailPath = $this->laravel['modules']->config('paths.generator.notifications', 'Notifications'); |
|
| 54 | ||
| 55 | return $path . $mailPath . '/' . $this->getFileName() . '.php'; |
|
| 56 | } |
|
| 57 | ||
| 58 | /** |
|
| 59 | * Get the console command arguments. |
|
| 60 | * |
|
| 61 | * @return array |
|
| 62 | */ |
|
| 63 | protected function getArguments() |
|
| 64 | { |
|
| 65 | return [ |
|
| 66 | ['name', InputArgument::REQUIRED, 'The name of the notification class.'], |
|
| 67 | ['module', InputArgument::OPTIONAL, 'The name of module will be used.'], |
|
| 68 | ]; |
|
| 69 | } |
|
| 70 | ||
| 71 | /** |
|
| 72 | * @return string |
|
| 73 | */ |
|
| 74 | private function getFileName() |
|
| 75 | { |
|
| 76 | return studly_case($this->argument('name')); |
|
| 77 | } |
|
| 78 | ||
| 79 | /** |
|
| 80 | * @return string |
|
| 81 | */ |
|
| 82 | public function getDefaultNamespace() |
|
| 83 | { |
|
| 84 | return $this->laravel['modules']->config('paths.generator.notifications', 'Notifications'); |
|
| 85 | } |
|
| 86 | } |
|
| 87 | ||
| @@ 10-88 (lines=79) @@ | ||
| 7 | use Nwidart\Modules\Traits\ModuleCommandTrait; |
|
| 8 | use Symfony\Component\Console\Input\InputArgument; |
|
| 9 | ||
| 10 | class MakePolicyCommand extends GeneratorCommand |
|
| 11 | { |
|
| 12 | use ModuleCommandTrait; |
|
| 13 | ||
| 14 | /** |
|
| 15 | * The name of argument name. |
|
| 16 | * |
|
| 17 | * @var string |
|
| 18 | */ |
|
| 19 | protected $argumentName = 'name'; |
|
| 20 | ||
| 21 | /** |
|
| 22 | * The console command name. |
|
| 23 | * |
|
| 24 | * @var string |
|
| 25 | */ |
|
| 26 | protected $name = 'module:make-policy'; |
|
| 27 | ||
| 28 | /** |
|
| 29 | * The console command description. |
|
| 30 | * |
|
| 31 | * @var string |
|
| 32 | */ |
|
| 33 | protected $description = 'Create a new policy for the specified module.'; |
|
| 34 | ||
| 35 | /** |
|
| 36 | * Get the console command arguments. |
|
| 37 | * |
|
| 38 | * @return array |
|
| 39 | */ |
|
| 40 | protected function getArguments() |
|
| 41 | { |
|
| 42 | return array( |
|
| 43 | array('name', InputArgument::REQUIRED, 'The name of the policy class.'), |
|
| 44 | array('module', InputArgument::OPTIONAL, 'The name of module will be used.'), |
|
| 45 | ); |
|
| 46 | } |
|
| 47 | ||
| 48 | /** |
|
| 49 | * @return mixed |
|
| 50 | */ |
|
| 51 | protected function getTemplateContents() |
|
| 52 | { |
|
| 53 | $module = $this->laravel['modules']->findOrFail($this->getModuleName()); |
|
| 54 | ||
| 55 | return (new Stub('/policy.plain.stub', [ |
|
| 56 | 'NAMESPACE' => $this->getClassNamespace($module), |
|
| 57 | 'CLASS' => $this->getClass(), |
|
| 58 | ]))->render(); |
|
| 59 | } |
|
| 60 | ||
| 61 | /** |
|
| 62 | * @return mixed |
|
| 63 | */ |
|
| 64 | protected function getDestinationFilePath() |
|
| 65 | { |
|
| 66 | $path = $this->laravel['modules']->getModulePath($this->getModuleName()); |
|
| 67 | ||
| 68 | $policyPath = $this->laravel['modules']->config('paths.generator.policies'); |
|
| 69 | ||
| 70 | return $path . $policyPath . '/' . $this->getFileName() . '.php'; |
|
| 71 | } |
|
| 72 | ||
| 73 | /** |
|
| 74 | * @return string |
|
| 75 | */ |
|
| 76 | private function getFileName() |
|
| 77 | { |
|
| 78 | return Str::studly($this->argument('name')); |
|
| 79 | } |
|
| 80 | ||
| 81 | /** |
|
| 82 | * @return string |
|
| 83 | */ |
|
| 84 | public function getDefaultNamespace() |
|
| 85 | { |
|
| 86 | return $this->laravel['modules']->config('paths.generator.policies', 'Policies'); |
|
| 87 | } |
|
| 88 | } |
|
| 89 | ||