case provisions are deleted when case is deleted.

This commit is contained in:
naomi 2022-05-18 13:40:03 +01:00
parent 13fb920e69
commit 1c61f2f0a4
2 changed files with 13 additions and 0 deletions

View File

@ -91,6 +91,14 @@ class OCCase extends RevisionableContentEntityBase implements OCCaseInterface
];
}
public function deleteCaseProvisions(): void {
$query = \Drupal::entityQuery('oc_case_provision')
->condition('oc_case.target_id', $this->id());
$ids = $query->execute();
foreach($ids as $id) {
OCcaseProvision::load($id)->delete();
}
}
public static function defaultTarget()
{

View File

@ -6,6 +6,7 @@
use Drupal\Core\Render\Element;
use Drupal\Core\Access\AccessResult;
use Drupal\opencase_cases\Entity\OCCase;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\opencase_cases\Entity\OCCaseProvision;
@ -56,6 +57,10 @@ function opencase_oc_case_provision_update(OCCaseProvision $case_provision): voi
$case_provision->original->oc_provider->entity->calculateTotalCases();
}
function opencase_oc_case_delete(OCCase $case): void {
$case->deleteCaseProvisions();
}
/**
* Implements hook_page_attachments
*