case provisions are deleted when case is deleted.
This commit is contained in:
parent
13fb920e69
commit
1c61f2f0a4
@ -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()
|
||||
{
|
||||
|
@ -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
|
||||
*
|
||||
|
Reference in New Issue
Block a user