Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 10 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
Relationship | |
0.00% |
0 / 10 |
|
0.00% |
0 / 2 |
6 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
getRelationshipIdByContactId | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace Drupal\crm; |
4 | |
5 | use Drupal\Core\Entity\EntityTypeManagerInterface; |
6 | |
7 | /** |
8 | * Service description. |
9 | */ |
10 | class Relationship { |
11 | |
12 | /** |
13 | * The entity type manager. |
14 | * |
15 | * @var \Drupal\Core\Entity\EntityTypeManagerInterface |
16 | */ |
17 | protected $entityTypeManager; |
18 | |
19 | |
20 | /** |
21 | * The relationship storage. |
22 | * |
23 | * @var \Drupal\Core\Entity\EntityStorageInterface |
24 | */ |
25 | protected $relationshipStorage; |
26 | |
27 | /** |
28 | * Constructs a Relationship object. |
29 | * |
30 | * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager |
31 | * The entity type manager. |
32 | */ |
33 | public function __construct(EntityTypeManagerInterface $entity_type_manager) { |
34 | $this->entityTypeManager = $entity_type_manager; |
35 | $this->relationshipStorage = $entity_type_manager |
36 | ->getStorage('crm_relationship'); |
37 | } |
38 | |
39 | /** |
40 | * Method description. |
41 | */ |
42 | public function getRelationshipIdByContactId(int $contact_id) { |
43 | $query = $this->relationshipStorage->getQuery(); |
44 | $ids = $query |
45 | ->condition('status', 1) |
46 | ->condition('contacts', $contact_id) |
47 | ->accessCheck(TRUE) |
48 | ->execute(); |
49 | |
50 | return $ids; |
51 | } |
52 | |
53 | } |