Skip to content

Commit

Permalink
fix application delete (#4503)
Browse files Browse the repository at this point in the history
  • Loading branch information
aynsix authored Apr 29, 2024
1 parent df780d9 commit 9ffb992
Showing 1 changed file with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,31 @@ public function create($name, $type, $description, $applicationWebsite, User $cr

public function delete(ApiApplication $application)
{
// make sure all apiaccounts linked by apiApplication are also deleted
$accts = $this->om->getRepository('Phraseanet:ApiAccount')->findBy(['application' => $application]);

foreach ($accts as $account) {
// remove ApiOauthCodes before ApiAccount
$oauthCodes = $this->om->getRepository('Phraseanet:ApiOauthCode')->findByAccount($account);
foreach ($oauthCodes as $oauthCode) {
$this->om->remove($oauthCode);
}

$this->om->remove($account);
}

$deliveries = $this->om->getRepository('Phraseanet:WebhookEventDelivery')->findBy(['application' => $application]);

foreach ($deliveries as $delivery) {
$payloads = $this->om->getRepository('Phraseanet:WebhookEventPayload')->findBy(['delivery' => $delivery]);

foreach ($payloads as $payload) {
$this->om->remove($payload);
}

$this->om->remove($delivery);
}

$this->om->remove($application);
$this->om->flush();
}
Expand Down

0 comments on commit 9ffb992

Please sign in to comment.