Refactor
This commit is contained in:
@ -92,11 +92,21 @@ class OCCase extends RevisionableContentEntityBase implements OCCaseInterface
|
||||
}
|
||||
|
||||
public function deleteCaseProvisions(): void {
|
||||
$query = \Drupal::entityQuery('oc_case_provision')
|
||||
$this->deleteChildren('oc_case_provision');
|
||||
}
|
||||
public function deleteActivities(): void {
|
||||
$this->deleteChildren('oc_activity');
|
||||
}
|
||||
|
||||
|
||||
public function deleteChildren($child_entity_type):void {
|
||||
$query = \Drupal::entityQuery($child_entity_type)
|
||||
->condition('oc_case.target_id', $this->id());
|
||||
$ids = $query->execute();
|
||||
foreach($ids as $id) {
|
||||
OCcaseProvision::load($id)->delete();
|
||||
\Drupal::entityTypeManager()
|
||||
->getStorage($child_entity_type)
|
||||
->load($id)->delete();
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user