Commit | Line | Data |
---|---|---|
19b53e5b C |
1 | <?php |
2 | ||
380f3545 TO |
3 | /* |
4 | +--------------------------------------------------------------------+ | |
41498ac5 | 5 | | Copyright CiviCRM LLC. All rights reserved. | |
380f3545 | 6 | | | |
41498ac5 TO |
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 | | |
380f3545 TO |
10 | +--------------------------------------------------------------------+ |
11 | */ | |
12 | ||
13 | /** | |
14 | * | |
15 | * @package CRM | |
ca5cec67 | 16 | * @copyright CiviCRM LLC https://civicrm.org/licensing |
380f3545 TO |
17 | */ |
18 | ||
19 | ||
19b53e5b C |
20 | namespace Civi\Api4; |
21 | ||
22 | /** | |
f63756b0 CW |
23 | * Provides virtual api entities for every multi-record custom group. |
24 | * | |
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. | |
27 | * | |
28 | * Each action takes the name of the custom group as a parameter, or in traditional syntax the entity is prefixed with 'Custom_' | |
29 | * | |
136ca5bb CW |
30 | * **Ex. OOP:** `\Civi\Api4\CustomValue::get('MyStuff')->addWhere('id', '=', 123);` |
31 | * **Non-OOP:** `civicrm_api4('Custom_MyStuff', 'get', ['where' => [['id', '=', 123]]]);` | |
19b53e5b | 32 | * |
7b7c96e6 | 33 | * Note: This class does NOT extend AbstractEntity so it doesn't get mistaken for a "real" entity. |
19b53e5b C |
34 | * @package Civi\Api4 |
35 | */ | |
7b7c96e6 | 36 | class CustomValue { |
19b53e5b C |
37 | |
38 | /** | |
39 | * @param string $customGroup | |
40 | * @return Action\CustomValue\Get | |
f63756b0 | 41 | * @throws \API_Exception |
19b53e5b C |
42 | */ |
43 | public static function get($customGroup) { | |
44 | return new Action\CustomValue\Get($customGroup, __FUNCTION__); | |
45 | } | |
46 | ||
47 | /** | |
48 | * @param string $customGroup | |
49 | * @return Action\CustomValue\GetFields | |
f63756b0 | 50 | * @throws \API_Exception |
19b53e5b C |
51 | */ |
52 | public static function getFields($customGroup = NULL) { | |
53 | return new Action\CustomValue\GetFields($customGroup, __FUNCTION__); | |
54 | } | |
55 | ||
56 | /** | |
57 | * @param string $customGroup | |
58 | * @return Action\CustomValue\Save | |
f63756b0 | 59 | * @throws \API_Exception |
19b53e5b C |
60 | */ |
61 | public static function save($customGroup) { | |
62 | return new Action\CustomValue\Save($customGroup, __FUNCTION__); | |
63 | } | |
64 | ||
65 | /** | |
66 | * @param string $customGroup | |
67 | * @return Action\CustomValue\Create | |
f63756b0 | 68 | * @throws \API_Exception |
19b53e5b C |
69 | */ |
70 | public static function create($customGroup) { | |
71 | return new Action\CustomValue\Create($customGroup, __FUNCTION__); | |
72 | } | |
73 | ||
74 | /** | |
75 | * @param string $customGroup | |
76 | * @return Action\CustomValue\Update | |
f63756b0 | 77 | * @throws \API_Exception |
19b53e5b C |
78 | */ |
79 | public static function update($customGroup) { | |
80 | return new Action\CustomValue\Update($customGroup, __FUNCTION__); | |
81 | } | |
82 | ||
83 | /** | |
84 | * @param string $customGroup | |
85 | * @return Action\CustomValue\Delete | |
f63756b0 | 86 | * @throws \API_Exception |
19b53e5b C |
87 | */ |
88 | public static function delete($customGroup) { | |
89 | return new Action\CustomValue\Delete($customGroup, __FUNCTION__); | |
90 | } | |
91 | ||
92 | /** | |
93 | * @param string $customGroup | |
94 | * @return Action\CustomValue\Replace | |
f63756b0 | 95 | * @throws \API_Exception |
19b53e5b C |
96 | */ |
97 | public static function replace($customGroup) { | |
98 | return new Action\CustomValue\Replace($customGroup, __FUNCTION__); | |
99 | } | |
100 | ||
101 | /** | |
102 | * @param string $customGroup | |
103 | * @return Action\CustomValue\GetActions | |
f63756b0 | 104 | * @throws \API_Exception |
19b53e5b C |
105 | */ |
106 | public static function getActions($customGroup = NULL) { | |
107 | return new Action\CustomValue\GetActions($customGroup, __FUNCTION__); | |
108 | } | |
109 | ||
110 | /** | |
111 | * @inheritDoc | |
112 | */ | |
113 | public static function permissions() { | |
114 | $entity = 'contact'; | |
115 | $permissions = \CRM_Core_Permission::getEntityActionPermissions(); | |
116 | ||
117 | // Merge permissions for this entity with the defaults | |
118 | return \CRM_Utils_Array::value($entity, $permissions, []) + $permissions['default']; | |
119 | } | |
120 | ||
121 | } |