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
23 * Provides virtual api entities for every multi-record custom group.
25 * This class is different from other apis in that it is not itself an entity, but allows every
26 * multi-record custom group to act like an entity.
28 * Each action takes the name of the custom group as a parameter, or in traditional syntax the entity is prefixed with 'Custom_'
30 * **Ex. OOP:** `\Civi\Api4\CustomValue::get('MyStuff')->addWhere('id', '=', 123);`
31 * **Non-OOP:** `civicrm_api4('Custom_MyStuff', 'get', ['where' => [['id', '=', 123]]]);`
33 * Note: This class does NOT extend AbstractEntity so it doesn't get mistaken for a "real" entity.
39 * @param string $customGroup
40 * @param bool $checkPermissions
41 * @return Action\CustomValue\Get
42 * @throws \API_Exception
44 public static function get($customGroup, $checkPermissions = TRUE) {
45 return (new Action\CustomValue\
Get($customGroup, __FUNCTION__
))
46 ->setCheckPermissions($checkPermissions);
50 * @param string $customGroup
51 * @param bool $checkPermissions
52 * @return Action\CustomValue\GetFields
53 * @throws \API_Exception
55 public static function getFields($customGroup = NULL, $checkPermissions = TRUE) {
56 return (new Action\CustomValue\
GetFields($customGroup, __FUNCTION__
))
57 ->setCheckPermissions($checkPermissions);
61 * @param string $customGroup
62 * @param bool $checkPermissions
63 * @return Action\CustomValue\Save
64 * @throws \API_Exception
66 public static function save($customGroup, $checkPermissions = TRUE) {
67 return (new Action\CustomValue\
Save($customGroup, __FUNCTION__
))
68 ->setCheckPermissions($checkPermissions);
72 * @param string $customGroup
73 * @param bool $checkPermissions
74 * @return Action\CustomValue\Create
75 * @throws \API_Exception
77 public static function create($customGroup, $checkPermissions = TRUE) {
78 return (new Action\CustomValue\
Create($customGroup, __FUNCTION__
))
79 ->setCheckPermissions($checkPermissions);
83 * @param string $customGroup
84 * @param bool $checkPermissions
85 * @return Action\CustomValue\Update
86 * @throws \API_Exception
88 public static function update($customGroup, $checkPermissions = TRUE) {
89 return (new Action\CustomValue\
Update($customGroup, __FUNCTION__
))
90 ->setCheckPermissions($checkPermissions);
94 * @param string $customGroup
95 * @param bool $checkPermissions
96 * @return Action\CustomValue\Delete
97 * @throws \API_Exception
99 public static function delete($customGroup, $checkPermissions = TRUE) {
100 return (new Action\CustomValue\
Delete($customGroup, __FUNCTION__
))
101 ->setCheckPermissions($checkPermissions);
105 * @param string $customGroup
106 * @param bool $checkPermissions
107 * @return Action\CustomValue\Replace
108 * @throws \API_Exception
110 public static function replace($customGroup, $checkPermissions = TRUE) {
111 return (new Action\CustomValue\
Replace($customGroup, __FUNCTION__
))
112 ->setCheckPermissions($checkPermissions);
116 * @param string $customGroup
117 * @param bool $checkPermissions
118 * @return Action\CustomValue\GetActions
119 * @throws \API_Exception
121 public static function getActions($customGroup = NULL, $checkPermissions = TRUE) {
122 return (new Action\CustomValue\
GetActions($customGroup, __FUNCTION__
))
123 ->setCheckPermissions($checkPermissions);
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'];