@@ 10-74 (lines=65) @@ | ||
7 | use Nwidart\Modules\Traits\ModuleCommandTrait; |
|
8 | use Symfony\Component\Console\Input\InputArgument; |
|
9 | ||
10 | class EventMakeCommand extends GeneratorCommand |
|
11 | { |
|
12 | use ModuleCommandTrait; |
|
13 | ||
14 | protected $argumentName = 'name'; |
|
15 | ||
16 | /** |
|
17 | * The console command name. |
|
18 | * |
|
19 | * @var string |
|
20 | */ |
|
21 | protected $name = 'module:make-event'; |
|
22 | ||
23 | /** |
|
24 | * The console command description. |
|
25 | * |
|
26 | * @var string |
|
27 | */ |
|
28 | protected $description = 'Create a new event class for the specified module'; |
|
29 | ||
30 | public function getTemplateContents() |
|
31 | { |
|
32 | $module = $this->laravel['modules']->findOrFail($this->getModuleName()); |
|
33 | ||
34 | return (new Stub('/event.stub', [ |
|
35 | 'NAMESPACE' => $this->getClassNamespace($module), |
|
36 | 'CLASS' => $this->getClass(), |
|
37 | ]))->render(); |
|
38 | } |
|
39 | ||
40 | public function getDestinationFilePath() |
|
41 | { |
|
42 | $path = $this->laravel['modules']->getModulePath($this->getModuleName()); |
|
43 | ||
44 | $eventPath = GenerateConfigReader::read('event'); |
|
45 | ||
46 | return $path . $eventPath->getPath() . '/' . $this->getFileName() . '.php'; |
|
47 | } |
|
48 | ||
49 | /** |
|
50 | * @return string |
|
51 | */ |
|
52 | protected function getFileName() |
|
53 | { |
|
54 | return studly_case($this->argument('name')); |
|
55 | } |
|
56 | ||
57 | public function getDefaultNamespace() : string |
|
58 | { |
|
59 | return $this->laravel['modules']->config('paths.generator.event.path', 'Events'); |
|
60 | } |
|
61 | ||
62 | /** |
|
63 | * Get the console command arguments. |
|
64 | * |
|
65 | * @return array |
|
66 | */ |
|
67 | protected function getArguments() |
|
68 | { |
|
69 | return [ |
|
70 | ['name', InputArgument::REQUIRED, 'The name of the event.'], |
|
71 | ['module', InputArgument::OPTIONAL, 'The name of module will be used.'], |
|
72 | ]; |
|
73 | } |
|
74 | } |
|
75 |
@@ 10-84 (lines=75) @@ | ||
7 | use Nwidart\Modules\Traits\ModuleCommandTrait; |
|
8 | use Symfony\Component\Console\Input\InputArgument; |
|
9 | ||
10 | class MailMakeCommand extends GeneratorCommand |
|
11 | { |
|
12 | use ModuleCommandTrait; |
|
13 | ||
14 | /** |
|
15 | * The console command name. |
|
16 | * |
|
17 | * @var string |
|
18 | */ |
|
19 | protected $name = 'module:make-mail'; |
|
20 | ||
21 | /** |
|
22 | * The console command description. |
|
23 | * |
|
24 | * @var string |
|
25 | */ |
|
26 | protected $description = 'Create a new email class for the specified module'; |
|
27 | ||
28 | protected $argumentName = 'name'; |
|
29 | ||
30 | public function getDefaultNamespace() : string |
|
31 | { |
|
32 | return $this->laravel['modules']->config('paths.generator.emails.path', 'Emails'); |
|
33 | } |
|
34 | ||
35 | /** |
|
36 | * Get the console command arguments. |
|
37 | * |
|
38 | * @return array |
|
39 | */ |
|
40 | protected function getArguments() |
|
41 | { |
|
42 | return [ |
|
43 | ['name', InputArgument::REQUIRED, 'The name of the mailable.'], |
|
44 | ['module', InputArgument::OPTIONAL, 'The name of module will be used.'], |
|
45 | ]; |
|
46 | } |
|
47 | ||
48 | /** |
|
49 | * Get template contents. |
|
50 | * |
|
51 | * @return string |
|
52 | */ |
|
53 | protected function getTemplateContents() |
|
54 | { |
|
55 | $module = $this->laravel['modules']->findOrFail($this->getModuleName()); |
|
56 | ||
57 | return (new Stub('/mail.stub', [ |
|
58 | 'NAMESPACE' => $this->getClassNamespace($module), |
|
59 | 'CLASS' => $this->getClass(), |
|
60 | ]))->render(); |
|
61 | } |
|
62 | ||
63 | /** |
|
64 | * Get the destination file path. |
|
65 | * |
|
66 | * @return string |
|
67 | */ |
|
68 | protected function getDestinationFilePath() |
|
69 | { |
|
70 | $path = $this->laravel['modules']->getModulePath($this->getModuleName()); |
|
71 | ||
72 | $mailPath = GenerateConfigReader::read('emails'); |
|
73 | ||
74 | return $path . $mailPath->getPath() . '/' . $this->getFileName() . '.php'; |
|
75 | } |
|
76 | ||
77 | /** |
|
78 | * @return string |
|
79 | */ |
|
80 | private function getFileName() |
|
81 | { |
|
82 | return studly_case($this->argument('name')); |
|
83 | } |
|
84 | } |
|
85 |
@@ 11-86 (lines=76) @@ | ||
8 | use Nwidart\Modules\Traits\ModuleCommandTrait; |
|
9 | use Symfony\Component\Console\Input\InputArgument; |
|
10 | ||
11 | class MiddlewareMakeCommand extends GeneratorCommand |
|
12 | { |
|
13 | use ModuleCommandTrait; |
|
14 | ||
15 | /** |
|
16 | * The name of argument name. |
|
17 | * |
|
18 | * @var string |
|
19 | */ |
|
20 | protected $argumentName = 'name'; |
|
21 | ||
22 | /** |
|
23 | * The console command name. |
|
24 | * |
|
25 | * @var string |
|
26 | */ |
|
27 | protected $name = 'module:make-middleware'; |
|
28 | ||
29 | /** |
|
30 | * The console command description. |
|
31 | * |
|
32 | * @var string |
|
33 | */ |
|
34 | protected $description = 'Create a new middleware class for the specified module.'; |
|
35 | ||
36 | public function getDefaultNamespace() : string |
|
37 | { |
|
38 | return $this->laravel['modules']->config('paths.generator.filter.path', 'Http/Middleware'); |
|
39 | } |
|
40 | ||
41 | /** |
|
42 | * Get the console command arguments. |
|
43 | * |
|
44 | * @return array |
|
45 | */ |
|
46 | protected function getArguments() |
|
47 | { |
|
48 | return [ |
|
49 | ['name', InputArgument::REQUIRED, 'The name of the command.'], |
|
50 | ['module', InputArgument::OPTIONAL, 'The name of module will be used.'], |
|
51 | ]; |
|
52 | } |
|
53 | ||
54 | /** |
|
55 | * @return mixed |
|
56 | */ |
|
57 | protected function getTemplateContents() |
|
58 | { |
|
59 | $module = $this->laravel['modules']->findOrFail($this->getModuleName()); |
|
60 | ||
61 | return (new Stub('/middleware.stub', [ |
|
62 | 'NAMESPACE' => $this->getClassNamespace($module), |
|
63 | 'CLASS' => $this->getClass(), |
|
64 | ]))->render(); |
|
65 | } |
|
66 | ||
67 | /** |
|
68 | * @return mixed |
|
69 | */ |
|
70 | protected function getDestinationFilePath() |
|
71 | { |
|
72 | $path = $this->laravel['modules']->getModulePath($this->getModuleName()); |
|
73 | ||
74 | $middlewarePath = GenerateConfigReader::read('filter'); |
|
75 | ||
76 | return $path . $middlewarePath->getPath() . '/' . $this->getFileName() . '.php'; |
|
77 | } |
|
78 | ||
79 | /** |
|
80 | * @return string |
|
81 | */ |
|
82 | private function getFileName() |
|
83 | { |
|
84 | return Str::studly($this->argument('name')); |
|
85 | } |
|
86 | } |
|
87 |
@@ 10-84 (lines=75) @@ | ||
7 | use Nwidart\Modules\Traits\ModuleCommandTrait; |
|
8 | use Symfony\Component\Console\Input\InputArgument; |
|
9 | ||
10 | final class NotificationMakeCommand extends GeneratorCommand |
|
11 | { |
|
12 | use ModuleCommandTrait; |
|
13 | ||
14 | /** |
|
15 | * The console command name. |
|
16 | * |
|
17 | * @var string |
|
18 | */ |
|
19 | protected $name = 'module:make-notification'; |
|
20 | ||
21 | protected $argumentName = 'name'; |
|
22 | ||
23 | /** |
|
24 | * The console command description. |
|
25 | * |
|
26 | * @var string |
|
27 | */ |
|
28 | protected $description = 'Create a new notification class for the specified module.'; |
|
29 | ||
30 | public function getDefaultNamespace() : string |
|
31 | { |
|
32 | return $this->laravel['modules']->config('paths.generator.notifications.path', 'Notifications'); |
|
33 | } |
|
34 | ||
35 | /** |
|
36 | * Get template contents. |
|
37 | * |
|
38 | * @return string |
|
39 | */ |
|
40 | protected function getTemplateContents() |
|
41 | { |
|
42 | $module = $this->laravel['modules']->findOrFail($this->getModuleName()); |
|
43 | ||
44 | return (new Stub('/notification.stub', [ |
|
45 | 'NAMESPACE' => $this->getClassNamespace($module), |
|
46 | 'CLASS' => $this->getClass(), |
|
47 | ]))->render(); |
|
48 | } |
|
49 | ||
50 | /** |
|
51 | * Get the destination file path. |
|
52 | * |
|
53 | * @return string |
|
54 | */ |
|
55 | protected function getDestinationFilePath() |
|
56 | { |
|
57 | $path = $this->laravel['modules']->getModulePath($this->getModuleName()); |
|
58 | ||
59 | $notificationPath = GenerateConfigReader::read('notifications'); |
|
60 | ||
61 | return $path . $notificationPath->getPath() . '/' . $this->getFileName() . '.php'; |
|
62 | } |
|
63 | ||
64 | /** |
|
65 | * @return string |
|
66 | */ |
|
67 | private function getFileName() |
|
68 | { |
|
69 | return studly_case($this->argument('name')); |
|
70 | } |
|
71 | ||
72 | /** |
|
73 | * Get the console command arguments. |
|
74 | * |
|
75 | * @return array |
|
76 | */ |
|
77 | protected function getArguments() |
|
78 | { |
|
79 | return [ |
|
80 | ['name', InputArgument::REQUIRED, 'The name of the notification class.'], |
|
81 | ['module', InputArgument::OPTIONAL, 'The name of module will be used.'], |
|
82 | ]; |
|
83 | } |
|
84 | } |
|
85 |
@@ 11-86 (lines=76) @@ | ||
8 | use Nwidart\Modules\Traits\ModuleCommandTrait; |
|
9 | use Symfony\Component\Console\Input\InputArgument; |
|
10 | ||
11 | class PolicyMakeCommand extends GeneratorCommand |
|
12 | { |
|
13 | use ModuleCommandTrait; |
|
14 | ||
15 | /** |
|
16 | * The name of argument name. |
|
17 | * |
|
18 | * @var string |
|
19 | */ |
|
20 | protected $argumentName = 'name'; |
|
21 | ||
22 | /** |
|
23 | * The console command name. |
|
24 | * |
|
25 | * @var string |
|
26 | */ |
|
27 | protected $name = 'module:make-policy'; |
|
28 | ||
29 | /** |
|
30 | * The console command description. |
|
31 | * |
|
32 | * @var string |
|
33 | */ |
|
34 | protected $description = 'Create a new policy class for the specified module.'; |
|
35 | ||
36 | public function getDefaultNamespace() : string |
|
37 | { |
|
38 | return $this->laravel['modules']->config('paths.generator.policies.path', 'Policies'); |
|
39 | } |
|
40 | ||
41 | /** |
|
42 | * Get the console command arguments. |
|
43 | * |
|
44 | * @return array |
|
45 | */ |
|
46 | protected function getArguments() |
|
47 | { |
|
48 | return [ |
|
49 | ['name', InputArgument::REQUIRED, 'The name of the policy class.'], |
|
50 | ['module', InputArgument::OPTIONAL, 'The name of module will be used.'], |
|
51 | ]; |
|
52 | } |
|
53 | ||
54 | /** |
|
55 | * @return mixed |
|
56 | */ |
|
57 | protected function getTemplateContents() |
|
58 | { |
|
59 | $module = $this->laravel['modules']->findOrFail($this->getModuleName()); |
|
60 | ||
61 | return (new Stub('/policy.plain.stub', [ |
|
62 | 'NAMESPACE' => $this->getClassNamespace($module), |
|
63 | 'CLASS' => $this->getClass(), |
|
64 | ]))->render(); |
|
65 | } |
|
66 | ||
67 | /** |
|
68 | * @return mixed |
|
69 | */ |
|
70 | protected function getDestinationFilePath() |
|
71 | { |
|
72 | $path = $this->laravel['modules']->getModulePath($this->getModuleName()); |
|
73 | ||
74 | $policyPath = GenerateConfigReader::read('policies'); |
|
75 | ||
76 | return $path . $policyPath->getPath() . '/' . $this->getFileName() . '.php'; |
|
77 | } |
|
78 | ||
79 | /** |
|
80 | * @return string |
|
81 | */ |
|
82 | private function getFileName() |
|
83 | { |
|
84 | return Str::studly($this->argument('name')); |
|
85 | } |
|
86 | } |
|
87 |
@@ 11-86 (lines=76) @@ | ||
8 | use Nwidart\Modules\Traits\ModuleCommandTrait; |
|
9 | use Symfony\Component\Console\Input\InputArgument; |
|
10 | ||
11 | class RequestMakeCommand extends GeneratorCommand |
|
12 | { |
|
13 | use ModuleCommandTrait; |
|
14 | ||
15 | /** |
|
16 | * The name of argument name. |
|
17 | * |
|
18 | * @var string |
|
19 | */ |
|
20 | protected $argumentName = 'name'; |
|
21 | ||
22 | /** |
|
23 | * The console command name. |
|
24 | * |
|
25 | * @var string |
|
26 | */ |
|
27 | protected $name = 'module:make-request'; |
|
28 | ||
29 | /** |
|
30 | * The console command description. |
|
31 | * |
|
32 | * @var string |
|
33 | */ |
|
34 | protected $description = 'Create a new form request class for the specified module.'; |
|
35 | ||
36 | public function getDefaultNamespace() : string |
|
37 | { |
|
38 | return $this->laravel['modules']->config('paths.generator.request.path', 'Http/Requests'); |
|
39 | } |
|
40 | ||
41 | /** |
|
42 | * Get the console command arguments. |
|
43 | * |
|
44 | * @return array |
|
45 | */ |
|
46 | protected function getArguments() |
|
47 | { |
|
48 | return [ |
|
49 | ['name', InputArgument::REQUIRED, 'The name of the form request class.'], |
|
50 | ['module', InputArgument::OPTIONAL, 'The name of module will be used.'], |
|
51 | ]; |
|
52 | } |
|
53 | ||
54 | /** |
|
55 | * @return mixed |
|
56 | */ |
|
57 | protected function getTemplateContents() |
|
58 | { |
|
59 | $module = $this->laravel['modules']->findOrFail($this->getModuleName()); |
|
60 | ||
61 | return (new Stub('/request.stub', [ |
|
62 | 'NAMESPACE' => $this->getClassNamespace($module), |
|
63 | 'CLASS' => $this->getClass(), |
|
64 | ]))->render(); |
|
65 | } |
|
66 | ||
67 | /** |
|
68 | * @return mixed |
|
69 | */ |
|
70 | protected function getDestinationFilePath() |
|
71 | { |
|
72 | $path = $this->laravel['modules']->getModulePath($this->getModuleName()); |
|
73 | ||
74 | $requestPath = GenerateConfigReader::read('request'); |
|
75 | ||
76 | return $path . $requestPath->getPath() . '/' . $this->getFileName() . '.php'; |
|
77 | } |
|
78 | ||
79 | /** |
|
80 | * @return string |
|
81 | */ |
|
82 | private function getFileName() |
|
83 | { |
|
84 | return Str::studly($this->argument('name')); |
|
85 | } |
|
86 | } |
|
87 |
@@ 11-86 (lines=76) @@ | ||
8 | use Nwidart\Modules\Traits\ModuleCommandTrait; |
|
9 | use Symfony\Component\Console\Input\InputArgument; |
|
10 | ||
11 | class RuleMakeCommand extends GeneratorCommand |
|
12 | { |
|
13 | use ModuleCommandTrait; |
|
14 | ||
15 | /** |
|
16 | * The name of argument name. |
|
17 | * |
|
18 | * @var string |
|
19 | */ |
|
20 | protected $argumentName = 'name'; |
|
21 | ||
22 | /** |
|
23 | * The console command name. |
|
24 | * |
|
25 | * @var string |
|
26 | */ |
|
27 | protected $name = 'module:make-rule'; |
|
28 | ||
29 | /** |
|
30 | * The console command description. |
|
31 | * |
|
32 | * @var string |
|
33 | */ |
|
34 | protected $description = 'Create a new validation rule for the specified module.'; |
|
35 | ||
36 | public function getDefaultNamespace() : string |
|
37 | { |
|
38 | return $this->laravel['modules']->config('paths.generator.rules.path', 'Rules'); |
|
39 | } |
|
40 | ||
41 | /** |
|
42 | * Get the console command arguments. |
|
43 | * |
|
44 | * @return array |
|
45 | */ |
|
46 | protected function getArguments() |
|
47 | { |
|
48 | return [ |
|
49 | ['name', InputArgument::REQUIRED, 'The name of the rule class.'], |
|
50 | ['module', InputArgument::OPTIONAL, 'The name of module will be used.'], |
|
51 | ]; |
|
52 | } |
|
53 | ||
54 | /** |
|
55 | * @return mixed |
|
56 | */ |
|
57 | protected function getTemplateContents() |
|
58 | { |
|
59 | $module = $this->laravel['modules']->findOrFail($this->getModuleName()); |
|
60 | ||
61 | return (new Stub('/rule.stub', [ |
|
62 | 'NAMESPACE' => $this->getClassNamespace($module), |
|
63 | 'CLASS' => $this->getClass(), |
|
64 | ]))->render(); |
|
65 | } |
|
66 | ||
67 | /** |
|
68 | * @return mixed |
|
69 | */ |
|
70 | protected function getDestinationFilePath() |
|
71 | { |
|
72 | $path = $this->laravel['modules']->getModulePath($this->getModuleName()); |
|
73 | ||
74 | $rulePath = GenerateConfigReader::read('rules'); |
|
75 | ||
76 | return $path . $rulePath->getPath() . '/' . $this->getFileName() . '.php'; |
|
77 | } |
|
78 | ||
79 | /** |
|
80 | * @return string |
|
81 | */ |
|
82 | private function getFileName() |
|
83 | { |
|
84 | return Str::studly($this->argument('name')); |
|
85 | } |
|
86 | } |
|
87 |
@@ 11-69 (lines=59) @@ | ||
8 | use Nwidart\Modules\Traits\ModuleCommandTrait; |
|
9 | use Symfony\Component\Console\Input\InputArgument; |
|
10 | ||
11 | class TestMakeCommand extends GeneratorCommand |
|
12 | { |
|
13 | use ModuleCommandTrait; |
|
14 | ||
15 | protected $argumentName = 'name'; |
|
16 | protected $name = 'module:make-test'; |
|
17 | protected $description = 'Create a new test class for the specified module.'; |
|
18 | ||
19 | public function getDefaultNamespace() : string |
|
20 | { |
|
21 | return $this->laravel['modules']->config('paths.generator.test.path', 'Tests'); |
|
22 | } |
|
23 | ||
24 | /** |
|
25 | * Get the console command arguments. |
|
26 | * |
|
27 | * @return array |
|
28 | */ |
|
29 | protected function getArguments() |
|
30 | { |
|
31 | return [ |
|
32 | ['name', InputArgument::REQUIRED, 'The name of the form request class.'], |
|
33 | ['module', InputArgument::OPTIONAL, 'The name of module will be used.'], |
|
34 | ]; |
|
35 | } |
|
36 | ||
37 | /** |
|
38 | * @return mixed |
|
39 | */ |
|
40 | protected function getTemplateContents() |
|
41 | { |
|
42 | $module = $this->laravel['modules']->findOrFail($this->getModuleName()); |
|
43 | ||
44 | return (new Stub('/unit-test.stub', [ |
|
45 | 'NAMESPACE' => $this->getClassNamespace($module), |
|
46 | 'CLASS' => $this->getClass(), |
|
47 | ]))->render(); |
|
48 | } |
|
49 | ||
50 | /** |
|
51 | * @return mixed |
|
52 | */ |
|
53 | protected function getDestinationFilePath() |
|
54 | { |
|
55 | $path = $this->laravel['modules']->getModulePath($this->getModuleName()); |
|
56 | ||
57 | $testPath = GenerateConfigReader::read('test'); |
|
58 | ||
59 | return $path . $testPath->getPath() . '/' . $this->getFileName() . '.php'; |
|
60 | } |
|
61 | ||
62 | /** |
|
63 | * @return string |
|
64 | */ |
|
65 | private function getFileName() |
|
66 | { |
|
67 | return Str::studly($this->argument('name')); |
|
68 | } |
|
69 | } |
|
70 |