Merge pull request #22138 from eileenmcnaughton/cust_edit
[civicrm-core.git] / Civi / Api4 / RelationshipCache.php
1 <?php
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 */
11 namespace Civi\Api4;
12
13 /**
14 * RelationshipCache - readonly table to facilitate joining and finding contacts by relationship.
15 *
16 * @searchable secondary
17 * @see \Civi\Api4\Relationship
18 * @ui_join_filters near_relation
19 * @since 5.29
20 * @package Civi\Api4
21 */
22 class RelationshipCache extends Generic\AbstractEntity {
23 use Generic\Traits\EntityBridge;
24
25 /**
26 * @param bool $checkPermissions
27 * @return Generic\DAOGetAction
28 */
29 public static function get($checkPermissions = TRUE) {
30 return (new Generic\DAOGetAction(__CLASS__, __FUNCTION__))
31 ->setCheckPermissions($checkPermissions);
32 }
33
34 /**
35 * @param bool $checkPermissions
36 * @return Generic\DAOGetFieldsAction
37 */
38 public static function getFields($checkPermissions = TRUE) {
39 return (new Generic\DAOGetFieldsAction(__CLASS__, __FUNCTION__))
40 ->setCheckPermissions($checkPermissions);
41 }
42
43 /**
44 * @return array
45 */
46 public static function getInfo() {
47 $info = parent::getInfo();
48 $info['bridge_title'] = ts('Relationship');
49 $info['bridge'] = [
50 'near_contact_id' => [
51 'to' => 'far_contact_id',
52 'description' => ts('One or more related contacts'),
53 ],
54 ];
55 if (in_array('CiviCase', \Civi::settings()->get('enable_components'), TRUE)) {
56 $info['bridge']['case_id'] = [
57 'to' => 'far_contact_id',
58 'label' => ts('Case Roles'),
59 'description' => ts('Cases in which this contact has a role'),
60 ];
61 }
62 return $info;
63 }
64
65 }