@@ -48,41 +48,42 @@ public function __construct(ComponentRegistrar $componentRegistrar)
48
48
}
49
49
50
50
/**
51
- * Configure command
52
- *
53
51
* @inheritdoc
52
+ *
54
53
* @throws InvalidArgumentException
55
54
*/
56
55
protected function configure ()
57
56
{
58
57
$ this ->setName (self ::COMMAND_NAME )
59
58
->setDescription ('Generate patch and put it in specific folder. ' )
60
- ->setDefinition ([
61
- new InputArgument (
62
- self ::MODULE_NAME ,
63
- InputArgument::REQUIRED ,
64
- 'Module name '
65
- ),
66
- new InputArgument (
67
- self ::INPUT_KEY_PATCH_NAME ,
68
- InputArgument::REQUIRED ,
69
- 'Patch name '
70
- ),
71
- new InputOption (
72
- self ::INPUT_KEY_IS_REVERTABLE ,
73
- null ,
74
- InputOption::VALUE_OPTIONAL ,
75
- 'Check whether patch is revertable or not. ' ,
76
- false
77
- ),
78
- new InputOption (
79
- self ::INPUT_KEY_PATCH_TYPE ,
80
- null ,
81
- InputOption::VALUE_OPTIONAL ,
82
- 'Find out what type of patch should be generated. ' ,
83
- 'data '
84
- ),
85
- ]);
59
+ ->setDefinition (
60
+ [
61
+ new InputArgument (
62
+ self ::MODULE_NAME ,
63
+ InputArgument::REQUIRED ,
64
+ 'Module name '
65
+ ),
66
+ new InputArgument (
67
+ self ::INPUT_KEY_PATCH_NAME ,
68
+ InputArgument::REQUIRED ,
69
+ 'Patch name '
70
+ ),
71
+ new InputOption (
72
+ self ::INPUT_KEY_IS_REVERTABLE ,
73
+ null ,
74
+ InputOption::VALUE_OPTIONAL ,
75
+ 'Check whether patch is revertable or not. ' ,
76
+ false
77
+ ),
78
+ new InputOption (
79
+ self ::INPUT_KEY_PATCH_TYPE ,
80
+ null ,
81
+ InputOption::VALUE_OPTIONAL ,
82
+ 'Find out what type of patch should be generated. Available values: `data`, `schema`. ' ,
83
+ 'data '
84
+ ),
85
+ ]
86
+ );
86
87
87
88
parent ::configure ();
88
89
}
@@ -92,16 +93,17 @@ protected function configure()
92
93
*
93
94
* @return string
94
95
*/
95
- private function getPatchTemplate () : string
96
+ private function getPatchTemplate (): string
96
97
{
98
+ // phpcs:ignore Magento2.Functions.DiscouragedFunction
97
99
return file_get_contents (__DIR__ . '/patch_template.php.dist ' );
98
100
}
99
101
100
102
/**
101
103
* @inheritdoc
102
104
* @throws \InvalidArgumentException
103
105
*/
104
- protected function execute (InputInterface $ input , OutputInterface $ output ) : int
106
+ protected function execute (InputInterface $ input , OutputInterface $ output ): int
105
107
{
106
108
$ moduleName = $ input ->getArgument (self ::MODULE_NAME );
107
109
$ patchName = $ input ->getArgument (self ::INPUT_KEY_PATCH_NAME );
@@ -117,10 +119,13 @@ protected function execute(InputInterface $input, OutputInterface $output) : int
117
119
$ patchTemplateData = str_replace ('%class% ' , $ patchName , $ patchTemplateData );
118
120
$ patchDir = $ patchToFile = $ modulePath . '/Setup/Patch/ ' . $ preparedType ;
119
121
122
+ // phpcs:ignore Magento2.Functions.DiscouragedFunction
120
123
if (!is_dir ($ patchDir )) {
124
+ // phpcs:ignore Magento2.Functions.DiscouragedFunction
121
125
mkdir ($ patchDir , 0777 , true );
122
126
}
123
127
$ patchToFile = $ patchDir . '/ ' . $ patchName . '.php ' ;
128
+ // phpcs:ignore Magento2.Functions.DiscouragedFunction
124
129
file_put_contents ($ patchToFile , $ patchTemplateData );
125
130
return Cli::RETURN_SUCCESS ;
126
131
}
0 commit comments