This repository has been archived on 2022-07-12. You can view files and clone it, but cannot push or open issues or pull requests.
opencase/modules/opencase_entities/src/CaseInvolvement.php

17 lines
483 B
PHP
Raw Normal View History

<?php
namespace Drupal\opencase_entities;
class CaseInvolvement {
public static function getLinkedActorId($account) {
return \Drupal\user\Entity\User::load($account->id())->get('field_linked_opencase_actor')->target_id;
}
public static function userIsInvolved($account, $case) {
$actorId = self::getLinkedActorId($account);
$involvedIds = array_column($case->actors_involved->getValue(), 'target_id');
return in_array($actorId, $involvedIds);
}
}