Skip to content

Commit

Permalink
Get command bus from moduleAdapter
Browse files Browse the repository at this point in the history
  • Loading branch information
atomiix committed Jan 7, 2022
1 parent 571b769 commit d63643d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion classes/UpgradeTools/CoreUpgrader/CoreUpgrader80.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ protected function upgradeLanguage($lang)
$frontThemeModulesFolder
);
/** @var CommandBusInterface $commandBus */
$commandBus = $this->container->get('prestashop.core.command_bus');
$commandBus = $this->container->getModuleAdapter()->getCommandBus();

try {
$commandBus->handle($generateCommand);
Expand Down
20 changes: 20 additions & 0 deletions classes/UpgradeTools/ModuleAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ class ModuleAdapter
// Cached instance
private $moduleDataUpdater;

/** @var PrestaShop\PrestaShop\Core\CommandBus\TacticianCommandBusAdapter $commandBus */
private $commandBus;

public function __construct($db, $translator, $modulesPath, $tempPath, $upgradeVersion, ZipAction $zipAction, SymfonyAdapter $symfonyAdapter)
{
$this->db = $db;
Expand Down Expand Up @@ -80,6 +83,23 @@ public function getModuleDataUpdater()
return $this->moduleDataUpdater;
}

/**
* Available only from 1.7. Can't be called on PS 1.6.
*
* @return PrestaShop\PrestaShop\Core\CommandBus\TacticianCommandBusAdapter
*/
public function getCommandBus()
{
if (null === $this->commandBus) {
$this->commandBus = $this->symfonyAdapter
->initAppKernel()
->getContainer()
->get('prestashop.core.command_bus');
}

return $this->commandBus;
}

/**
* Upgrade action, disabling all modules not made by PrestaShop.
*
Expand Down

0 comments on commit d63643d

Please sign in to comment.