6 declare(strict_types=1);
10 use Composer\Package\Package;
11 use Composer\IO\IOInterface;
15 private $configurator;
23 $this->configurator = $configurator;
27 public function deploy(Package $package): void
29 if ($package->getType() !==
'magento2-module') {
33 $packageName = $package->getName();
34 if (0 !== strpos($packageName,
'magento/module-inventory')) {
38 $moduleName = $this->packageNameToModuleName($packageName);
39 $this->io->writeError(sprintf(
40 ' ...Module %s recognized as part of Magento Multi Source Inventory implementation',
44 $this->configurator->configure($moduleName);
47 private function packageNameToModuleName(
string $packageName): string
49 $nameWithDashes = substr($packageName, strlen(
'magento/module-'));
50 $nameInCamelCase = ucwords($nameWithDashes,
'-');
51 $nameWithoutDashes = str_replace(
'-',
'', $nameInCamelCase);
52 $nameWithVendorPrefix =
'Magento_' . $nameWithoutDashes;
53 $packageName = $nameWithVendorPrefix;
__construct(InventoryConfiguratorInterface $configurator, IOInterface $io)