Commit | Line | Data |
---|---|---|
bf01b886 | 1 | <?php |
bf01b886 CW |
2 | /* |
3 | +--------------------------------------------------------------------+ | |
4 | | Copyright CiviCRM LLC. All rights reserved. | | |
5 | | | | |
6 | | This work is published under the GNU AGPLv3 license with some | | |
7 | | permitted exceptions and without any warranty. For full license | | |
8 | | and copyright information, see https://civicrm.org/licensing | | |
9 | +--------------------------------------------------------------------+ | |
10 | */ | |
bf01b886 CW |
11 | namespace Civi\Api4; |
12 | ||
13 | /** | |
14 | * RelationshipCache - readonly table to facilitate joining and finding contacts by relationship. | |
15 | * | |
c5076889 | 16 | * @searchable secondary |
bf01b886 | 17 | * @see \Civi\Api4\Relationship |
2f616560 | 18 | * @ui_join_filters near_relation |
d44cc3cb | 19 | * @since 5.29 |
bf01b886 CW |
20 | * @package Civi\Api4 |
21 | */ | |
22 | class RelationshipCache extends Generic\AbstractEntity { | |
465bc32a | 23 | use Generic\Traits\EntityBridge; |
bf01b886 CW |
24 | |
25 | /** | |
26 | * @param bool $checkPermissions | |
27 | * @return Generic\DAOGetAction | |
28 | */ | |
29 | public static function get($checkPermissions = TRUE) { | |
9f338c09 | 30 | return (new Generic\DAOGetAction(__CLASS__, __FUNCTION__)) |
bf01b886 CW |
31 | ->setCheckPermissions($checkPermissions); |
32 | } | |
33 | ||
34 | /** | |
35 | * @param bool $checkPermissions | |
36 | * @return Generic\DAOGetFieldsAction | |
37 | */ | |
38 | public static function getFields($checkPermissions = TRUE) { | |
9f338c09 | 39 | return (new Generic\DAOGetFieldsAction(__CLASS__, __FUNCTION__)) |
bf01b886 CW |
40 | ->setCheckPermissions($checkPermissions); |
41 | } | |
42 | ||
27d31a0f CW |
43 | /** |
44 | * @return array | |
45 | */ | |
46 | public static function getInfo() { | |
47 | $info = parent::getInfo(); | |
7e224460 | 48 | $info['bridge_title'] = ts('Relationship'); |
27d31a0f | 49 | $info['bridge'] = [ |
63f3df59 CW |
50 | 'near_contact_id' => [ |
51 | 'to' => 'far_contact_id', | |
1da0597e | 52 | 'label' => ts('Related Contacts'), |
63f3df59 CW |
53 | 'description' => ts('One or more related contacts'), |
54 | ], | |
27d31a0f | 55 | ]; |
e46f73c7 | 56 | if (\CRM_Core_Component::isEnabled('CiviCase')) { |
63f3df59 CW |
57 | $info['bridge']['case_id'] = [ |
58 | 'to' => 'far_contact_id', | |
59 | 'label' => ts('Case Roles'), | |
60 | 'description' => ts('Cases in which this contact has a role'), | |
61 | ]; | |
62 | } | |
27d31a0f CW |
63 | return $info; |
64 | } | |
65 | ||
bf01b886 | 66 | } |