From 7a93349169661fde2f12fa0fae49fa9e3e387d07 Mon Sep 17 00:00:00 2001 From: TheMilek Date: Wed, 25 Mar 2026 11:35:40 +0100 Subject: [PATCH] Resolve addcommand method based on existance to support both 6.4 and 8 of Symfony --- src/Sylius/Behat/Context/Cli/InstallerContext.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/Sylius/Behat/Context/Cli/InstallerContext.php b/src/Sylius/Behat/Context/Cli/InstallerContext.php index 7913682243..035a7607a1 100644 --- a/src/Sylius/Behat/Context/Cli/InstallerContext.php +++ b/src/Sylius/Behat/Context/Cli/InstallerContext.php @@ -70,7 +70,7 @@ final class InstallerContext implements Context public function iRunSyliusCommandLineInstaller(): void { $this->application = new Application($this->kernel); - $this->application->addCommand(new SetupCommand( + $this->addCommandHelper(new SetupCommand( $this->entityManager, $this->commandDirectoryChecker, $this->currencySetup, @@ -91,7 +91,7 @@ final class InstallerContext implements Context public function iRunSyliusInstallSampleDataCommand(): void { $this->application = new Application($this->kernel); - $this->application->addCommand(new InstallSampleDataCommand( + $this->addCommandHelper(new InstallSampleDataCommand( $this->entityManager, $this->commandDirectoryChecker, $this->publicDir, @@ -158,4 +158,15 @@ final class InstallerContext implements Context } catch (\Exception) { } } + + private function addCommandHelper(Command $command): void + { + if (method_exists($this->application, 'addCommand')) { + $this->application->addCommand($command); + + return; + } + + $this->application->add($command); + } }