Skip to content

Commit 0a5d19b

Browse files
committed
Prevent doubling Sylius prefix in plugin name
1 parent ebaf9dc commit 0a5d19b

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

bin/rename-plugin.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,22 +231,26 @@ private function generateNameVariations(string $company, string $pluginName, boo
231231
];
232232
}
233233

234-
$syliusPlugin = 'Sylius' . $plugin;
234+
$hasSyliusPrefix = str_starts_with($pluginName, 'Sylius');
235+
$syliusPlugin = $hasSyliusPrefix ? $plugin : 'Sylius' . $plugin;
236+
$syliusPluginName = $hasSyliusPrefix ? $pluginName : 'Sylius' . $pluginName;
237+
235238
$fullClass = $company . $syliusPlugin;
236-
$extensionClass = $company . 'Sylius' . $pluginName . 'Extension';
239+
$extensionClass = $company . $syliusPluginName . 'Extension';
237240

238241
$companyKebab = $this->toKebabCase($company);
239242
$fullPluginKebab = $this->toKebabCase($syliusPlugin);
240243
$companySnake = $this->toSnakeCase($company);
244+
$pluginSnakeForDb = $hasSyliusPrefix ? $pluginSnake : 'sylius_' . $pluginSnake;
241245

242246
return [
243247
'company' => $company,
244248
'plugin' => $syliusPlugin,
245249
'fullClass' => $fullClass,
246250
'extensionClass' => $extensionClass,
247251
'package' => $companyKebab . '/' . $fullPluginKebab,
248-
'db' => $companySnake . '_sylius_' . $pluginSnake . '_plugin',
249-
'configKey' => $companySnake . '_sylius_' . $pluginSnake,
252+
'db' => $companySnake . '_' . $pluginSnakeForDb . '_plugin',
253+
'configKey' => $companySnake . '_' . $pluginSnakeForDb,
250254
];
251255
}
252256

0 commit comments

Comments
 (0)