4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC. All rights reserved. |
7 | This work is published under the GNU AGPLv3 license with some |
8 | permitted exceptions and without any warranty. For full license |
9 | and copyright information, see https://civicrm.org/licensing |
10 +--------------------------------------------------------------------+
16 * @copyright CiviCRM LLC https://civicrm.org/licensing
22 * Provides virtual api entities for every multi-record custom group.
24 * This class is different from other apis in that it is not itself an entity, but allows every
25 * multi-record custom group to act like an entity.
27 * Each action takes the name of the custom group as a parameter, or in traditional syntax the entity is prefixed with 'Custom_'
29 * **Ex. OOP:** `\Civi\Api4\CustomValue::get('MyStuff')->addWhere('id', '=', 123);`
30 * **Non-OOP:** `civicrm_api4('Custom_MyStuff', 'get', ['where' => [['id', '=', 123]]]);`
32 * Note: This class does NOT extend AbstractEntity so it doesn't get mistaken for a "real" entity.
38 * @param string $customGroup
39 * @param bool $checkPermissions
40 * @return Action\CustomValue\Get
41 * @throws \API_Exception
43 public static function get($customGroup, $checkPermissions = TRUE) {
44 return (new Action\CustomValue\
Get($customGroup, __FUNCTION__
))
45 ->setCheckPermissions($checkPermissions);
49 * @param string $customGroup
50 * @param bool $checkPermissions
51 * @return Action\CustomValue\GetFields
52 * @throws \API_Exception
54 public static function getFields($customGroup = NULL, $checkPermissions = TRUE) {
55 return (new Action\CustomValue\
GetFields($customGroup, __FUNCTION__
))
56 ->setCheckPermissions($checkPermissions);
60 * @param string $customGroup
61 * @param bool $checkPermissions
62 * @return Action\CustomValue\Save
63 * @throws \API_Exception
65 public static function save($customGroup, $checkPermissions = TRUE) {
66 return (new Action\CustomValue\
Save($customGroup, __FUNCTION__
))
67 ->setCheckPermissions($checkPermissions);
71 * @param string $customGroup
72 * @param bool $checkPermissions
73 * @return Action\CustomValue\Create
74 * @throws \API_Exception
76 public static function create($customGroup, $checkPermissions = TRUE) {
77 return (new Action\CustomValue\
Create($customGroup, __FUNCTION__
))
78 ->setCheckPermissions($checkPermissions);
82 * @param string $customGroup
83 * @param bool $checkPermissions
84 * @return Action\CustomValue\Update
85 * @throws \API_Exception
87 public static function update($customGroup, $checkPermissions = TRUE) {
88 return (new Action\CustomValue\
Update($customGroup, __FUNCTION__
))
89 ->setCheckPermissions($checkPermissions);
93 * @param string $customGroup
94 * @param bool $checkPermissions
95 * @return Action\CustomValue\Delete
96 * @throws \API_Exception
98 public static function delete($customGroup, $checkPermissions = TRUE) {
99 return (new Action\CustomValue\
Delete($customGroup, __FUNCTION__
))
100 ->setCheckPermissions($checkPermissions);
104 * @param string $customGroup
105 * @param bool $checkPermissions
106 * @return Generic\BasicReplaceAction
107 * @throws \API_Exception
109 public static function replace($customGroup, $checkPermissions = TRUE) {
110 return (new Generic\
BasicReplaceAction("Custom_$customGroup", __FUNCTION__
, ['id', 'entity_id']))
111 ->setCheckPermissions($checkPermissions);
115 * @param string $customGroup
116 * @param bool $checkPermissions
117 * @return Action\GetActions
118 * @throws \API_Exception
120 public static function getActions($customGroup = NULL, $checkPermissions = TRUE) {
121 return (new Action\
GetActions("Custom_$customGroup", __FUNCTION__
))
122 ->setCheckPermissions($checkPermissions);
126 * @see \Civi\Api4\Generic\AbstractEntity::permissions()
129 public static function permissions() {
131 $permissions = \CRM_Core_Permission
::getEntityActionPermissions();
133 // Merge permissions for this entity with the defaults
134 return \CRM_Utils_Array
::value($entity, $permissions, []) +
$permissions['default'];
138 * @see \Civi\Api4\Generic\AbstractEntity::getInfo()
141 public static function getInfo() {
143 'class' => __CLASS__
,
144 'type' => ['CustomValue'],
145 'searchable' => 'secondary',
147 'https://docs.civicrm.org/user/en/latest/organising-your-data/creating-custom-fields/#multiple-record-fieldsets',
148 '\Civi\Api4\CustomGroup',