3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
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 +--------------------------------------------------------------------+
14 * Provides virtual api entities for every multi-record custom group.
16 * This class is different from other apis in that it is not itself an entity, but allows every
17 * multi-record custom group to act like an entity.
19 * Each action takes the name of the custom group as a parameter, or in traditional syntax the entity is prefixed with 'Custom_'
21 * **Ex. OOP:** `\Civi\Api4\CustomValue::get('MyStuff')->addWhere('id', '=', 123);`
22 * **Non-OOP:** `civicrm_api4('Custom_MyStuff', 'get', ['where' => [['id', '=', 123]]]);`
24 * Note: This class does NOT extend AbstractEntity so it doesn't get mistaken for a "real" entity.
30 * @param string $customGroup
31 * @param bool $checkPermissions
32 * @return Action\CustomValue\Get
33 * @throws \API_Exception
35 public static function get($customGroup, $checkPermissions = TRUE) {
36 return (new Action\CustomValue\
Get($customGroup, __FUNCTION__
))
37 ->setCheckPermissions($checkPermissions);
41 * @param string $customGroup
42 * @param bool $checkPermissions
43 * @return Action\CustomValue\GetFields
44 * @throws \API_Exception
46 public static function getFields($customGroup = NULL, $checkPermissions = TRUE) {
47 return (new Action\CustomValue\
GetFields($customGroup, __FUNCTION__
))
48 ->setCheckPermissions($checkPermissions);
52 * @param string $customGroup
53 * @param bool $checkPermissions
54 * @return Action\CustomValue\Save
55 * @throws \API_Exception
57 public static function save($customGroup, $checkPermissions = TRUE) {
58 return (new Action\CustomValue\
Save($customGroup, __FUNCTION__
))
59 ->setCheckPermissions($checkPermissions);
63 * @param string $customGroup
64 * @param bool $checkPermissions
65 * @return Action\CustomValue\Create
66 * @throws \API_Exception
68 public static function create($customGroup, $checkPermissions = TRUE) {
69 return (new Action\CustomValue\
Create($customGroup, __FUNCTION__
))
70 ->setCheckPermissions($checkPermissions);
74 * @param string $customGroup
75 * @param bool $checkPermissions
76 * @return Action\CustomValue\Update
77 * @throws \API_Exception
79 public static function update($customGroup, $checkPermissions = TRUE) {
80 return (new Action\CustomValue\
Update($customGroup, __FUNCTION__
))
81 ->setCheckPermissions($checkPermissions);
85 * @param string $customGroup
86 * @param bool $checkPermissions
87 * @return Action\CustomValue\Delete
88 * @throws \API_Exception
90 public static function delete($customGroup, $checkPermissions = TRUE) {
91 return (new Action\CustomValue\
Delete($customGroup, __FUNCTION__
))
92 ->setCheckPermissions($checkPermissions);
96 * @param string $customGroup
97 * @param bool $checkPermissions
98 * @return Generic\BasicReplaceAction
99 * @throws \API_Exception
101 public static function replace($customGroup, $checkPermissions = TRUE) {
102 return (new Generic\
BasicReplaceAction("Custom_$customGroup", __FUNCTION__
))
103 ->setCheckPermissions($checkPermissions);
107 * @param string $customGroup
108 * @param bool $checkPermissions
109 * @return Action\GetActions
110 * @throws \API_Exception
112 public static function getActions($customGroup = NULL, $checkPermissions = TRUE) {
113 return (new Action\
GetActions("Custom_$customGroup", __FUNCTION__
))
114 ->setCheckPermissions($checkPermissions);
118 * @return \Civi\Api4\Generic\CheckAccessAction
120 public static function checkAccess($customGroup) {
121 return new Generic\
CheckAccessAction("Custom_$customGroup", __FUNCTION__
);
125 * @see \Civi\Api4\Generic\AbstractEntity::permissions()
128 public static function permissions() {
130 $permissions = \CRM_Core_Permission
::getEntityActionPermissions();
132 // Merge permissions for this entity with the defaults
133 return \CRM_Utils_Array
::value($entity, $permissions, []) +
$permissions['default'];
137 * @see \Civi\Api4\Generic\AbstractEntity::getInfo()
140 public static function getInfo() {
142 'class' => __CLASS__
,
143 'type' => ['CustomValue'],
144 'searchable' => 'secondary',
145 'primary_key' => ['id'],
147 'https://docs.civicrm.org/user/en/latest/organising-your-data/creating-custom-fields/#multiple-record-fieldsets',
148 '\Civi\Api4\CustomGroup',