From 4ee9cd5befaba4d335e54364aa50623908c9263f Mon Sep 17 00:00:00 2001 From: naomi Date: Mon, 9 May 2022 17:21:54 +0100 Subject: [PATCH] Started adding case count func to actor --- modules/opencase_entities/src/Entity/OCActor.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/modules/opencase_entities/src/Entity/OCActor.php b/modules/opencase_entities/src/Entity/OCActor.php index 49cac12..1c43a11 100644 --- a/modules/opencase_entities/src/Entity/OCActor.php +++ b/modules/opencase_entities/src/Entity/OCActor.php @@ -207,6 +207,16 @@ class OCActor extends RevisionableContentEntityBase implements OCActorInterface return $this; } + + public function getCountOfCaseProvisions(array $conditions = []): int { + $query = \Drupal::entityQuery('oc_case_provision'); + $query->condition('oc_provider', $this->id()); + // foreach($conditions as $condition) { + // $query->condition($condition); + // } + return count($query->execute()); + } + /** * {@inheritdoc} */ @@ -331,6 +341,11 @@ class OCActor extends RevisionableContentEntityBase implements OCActorInterface ->setDisplayConfigurable("form", true) ->setDisplayConfigurable("view", true); + $fields['total_cases'] = BaseFieldDefinition::create('integer') + ->setLabel(t('Number of Cases')) + ->setRevisionable(TRUE) + ->setDisplayConfigurable('view', true); + $fields['created'] = BaseFieldDefinition::create('created') ->setLabel(t('Created')) ->setDescription(t('The time that the entity was created.'));