Added function to cases for getting case provider ids
This commit is contained in:
@ -9,7 +9,6 @@ use Drupal\Core\Entity\RevisionableContentEntityBase;
|
||||
use Drupal\Core\Entity\RevisionableInterface;
|
||||
use Drupal\Core\Entity\EntityChangedTrait;
|
||||
use Drupal\Core\Entity\EntityTypeInterface;
|
||||
use Drupal\Core\Entity\EntityTypeManager;
|
||||
use Drupal\user\UserInterface;
|
||||
|
||||
/**
|
||||
@ -85,6 +84,10 @@ class OCCase extends RevisionableContentEntityBase implements OCCaseInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
||||
public static function loadFromUrlQueryParameter(string $param) {
|
||||
return self::load(\Drupal::request()->query->get($param));
|
||||
}
|
||||
public static function preCreate(EntityStorageInterface $storage_controller, array &$values)
|
||||
{
|
||||
parent::preCreate($storage_controller, $values);
|
||||
@ -93,7 +96,21 @@ class OCCase extends RevisionableContentEntityBase implements OCCaseInterface
|
||||
];
|
||||
}
|
||||
|
||||
public function getCaseProvisionIds(EntityTypeManager $etm): array {
|
||||
public function getCaseProviderIds(int $role_id = null): array {
|
||||
$case_provision_ids = $this->getCaseProvisionIds();
|
||||
$provider_ids = [];
|
||||
foreach($case_provision_ids as $id) {
|
||||
$provision = \Drupal::entityTypeManager()->getStorage('oc_case_provision')->load($id);
|
||||
if ($provision instanceOf OCCaseProvision) {
|
||||
if (is_null($role_id) || $role_id == $provision->get('oc_case_provider_role')->target_id) {
|
||||
$provider_ids[] = $provision->get('oc_provider')->target_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $provider_ids;
|
||||
}
|
||||
|
||||
private function getCaseProvisionIds(): array {
|
||||
$query = \Drupal::entityTypeManager()->getStorage('oc_case_provision')->getQuery();
|
||||
$query->condition('oc_case.target_id', $this->id());
|
||||
return $query->execute();
|
||||
|
Reference in New Issue
Block a user