Skip to content

Commit

Permalink
Delete oauth consumer entry on integration:delete (#1287)
Browse files Browse the repository at this point in the history
  • Loading branch information
cmuench committed Sep 12, 2023
1 parent 788ddda commit 867fa63
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions src/N98/Magento/Command/Integration/DeleteCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace N98\Magento\Command\Integration;

use Exception;
use Magento\Integration\Api\OauthServiceInterface;
use Magento\Integration\Model\IntegrationService;
use N98\Magento\Command\AbstractMagentoCommand;
use Symfony\Component\Console\Command\Command;
Expand All @@ -22,7 +24,7 @@ class DeleteCommand extends AbstractMagentoCommand
private $integrationService;

/**
* @var OauthService
* @var OauthServiceInterface
*/
private $oauthService;

Expand All @@ -40,16 +42,18 @@ protected function configure()
}

public function inject(
IntegrationService $integrationService
IntegrationService $integrationService,
OauthServiceInterface $oauthService
) {
$this->integrationService = $integrationService;
$this->oauthService = $oauthService;
}

/**
* @param \Symfony\Component\Console\Input\InputInterface $input
* @param \Symfony\Component\Console\Output\OutputInterface $output
* @param InputInterface $input
* @param OutputInterface $output
* @return int
* @throws \Exception
* @throws Exception
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
Expand All @@ -66,6 +70,15 @@ protected function execute(InputInterface $input, OutputInterface $output)
}

$this->integrationService->delete($integrationModel->getId());

/**
* we have to delete the consumer entry, because there is no way
* reference on the database with cascade delete
*
* @see https://github.com/netz98/n98-magerun2/issues/1287
*/
$this->oauthService->deleteConsumer($integrationModel->getConsumerId());

$output->writeln(
sprintf(
'<info>Successfully deleted integration <comment>%s</comment> with ID: <comment>%d</comment></info>',
Expand Down

0 comments on commit 867fa63

Please sign in to comment.