Skip to content

Commit

Permalink
Fix 301 Return value while running command console (#2396)
Browse files Browse the repository at this point in the history
* [FIX] Fix 301 Return value while running command console

* Add Magento\Framework\Console\Cli constants since deprecated Symfony\Component\Console\Command\Command

---------

Co-authored-by: Rok Popov Ledinski <rok.popov.ledinski90@gmail.com>
Co-authored-by: Can Demiralp <ecandemiralp@gmail.com>
Co-authored-by: hossam-adyen <132500300+hossam-adyen@users.noreply.github.com>
  • Loading branch information
4 people authored Jan 11, 2024
1 parent a01998b commit 898cf3a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 3 additions & 1 deletion Console/Command/EnablePaymentMethodsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Adyen\Payment\Helper\PaymentMethodsFactory;
use Adyen\Payment\Helper\ConfigFactory;
use Magento\Framework\Console\Cli;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
Expand Down Expand Up @@ -32,7 +33,7 @@ protected function configure(): void
/**
* @throws \Exception
*/
protected function execute(InputInterface $input, OutputInterface $output): void
protected function execute(InputInterface $input, OutputInterface $output)
{
$output->writeln('Starting enabling payment methods.');
$paymentMethods = $this->paymentMethodsFactory->create();
Expand All @@ -47,5 +48,6 @@ protected function execute(InputInterface $input, OutputInterface $output): void
}

$output->writeln('Completed enabling payment methods.');
return Cli::RETURN_SUCCESS;
}
}
8 changes: 7 additions & 1 deletion Console/Command/WebhookProcessorCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Adyen\Payment\Console\Command;

use Adyen\Payment\Cron\WebhookProcessor;
use Magento\Framework\Console\Cli;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
Expand Down Expand Up @@ -32,7 +33,12 @@ protected function configure()
protected function execute(InputInterface $input, OutputInterface $output)
{
$output->writeln('Starting webhook processor.');
$this->webhookProcessor->execute();
try {
$this->webhookProcessor->execute();
} catch (\Exception $e) {
return Cli::RETURN_FAILURE;
}
$output->writeln('Completed webhook processor execution.');
return Cli::RETURN_SUCCESS;
}
}

0 comments on commit 898cf3a

Please sign in to comment.