Skip to content

Commit 477c787

Browse files
authored
ENGCOM-5517: magento/magento2#: Add description for the --type option of 'setup:db-declaration:generate-patch' command. #23868
2 parents 530ac29 + 138d857 commit 477c787

File tree

1 file changed

+35
-30
lines changed

1 file changed

+35
-30
lines changed

app/code/Magento/Developer/Console/Command/GeneratePatchCommand.php

Lines changed: 35 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -48,41 +48,42 @@ public function __construct(ComponentRegistrar $componentRegistrar)
4848
}
4949

5050
/**
51-
* Configure command
52-
*
5351
* @inheritdoc
52+
*
5453
* @throws InvalidArgumentException
5554
*/
5655
protected function configure()
5756
{
5857
$this->setName(self::COMMAND_NAME)
5958
->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+
);
8687

8788
parent::configure();
8889
}
@@ -92,16 +93,17 @@ protected function configure()
9293
*
9394
* @return string
9495
*/
95-
private function getPatchTemplate() : string
96+
private function getPatchTemplate(): string
9697
{
98+
// phpcs:ignore Magento2.Functions.DiscouragedFunction
9799
return file_get_contents(__DIR__ . '/patch_template.php.dist');
98100
}
99101

100102
/**
101103
* @inheritdoc
102104
* @throws \InvalidArgumentException
103105
*/
104-
protected function execute(InputInterface $input, OutputInterface $output) : int
106+
protected function execute(InputInterface $input, OutputInterface $output): int
105107
{
106108
$moduleName = $input->getArgument(self::MODULE_NAME);
107109
$patchName = $input->getArgument(self::INPUT_KEY_PATCH_NAME);
@@ -117,10 +119,13 @@ protected function execute(InputInterface $input, OutputInterface $output) : int
117119
$patchTemplateData = str_replace('%class%', $patchName, $patchTemplateData);
118120
$patchDir = $patchToFile = $modulePath . '/Setup/Patch/' . $preparedType;
119121

122+
// phpcs:ignore Magento2.Functions.DiscouragedFunction
120123
if (!is_dir($patchDir)) {
124+
// phpcs:ignore Magento2.Functions.DiscouragedFunction
121125
mkdir($patchDir, 0777, true);
122126
}
123127
$patchToFile = $patchDir . '/' . $patchName . '.php';
128+
// phpcs:ignore Magento2.Functions.DiscouragedFunction
124129
file_put_contents($patchToFile, $patchTemplateData);
125130
return Cli::RETURN_SUCCESS;
126131
}

0 commit comments

Comments
 (0)