Merge pull request #22724 from braders/feature/group-search-null-columns
[civicrm-core.git] / Civi / Api4 / Entity.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 * Retrieves information about all Api4 entities.
15 *
16 * @see \Civi\Api4\Generic\AbstractEntity
17 *
18 * @searchable none
19 * @since 5.19
20 * @package Civi\Api4
21 */
22 class Entity extends Generic\AbstractEntity {
23
24 /**
25 * @param bool $checkPermissions
26 * @return Action\Entity\Get
27 */
28 public static function get($checkPermissions = TRUE) {
29 return (new Action\Entity\Get('Entity', __FUNCTION__))
30 ->setCheckPermissions($checkPermissions);
31 }
32
33 /**
34 * @param bool $checkPermissions
35 * @return Generic\BasicGetFieldsAction
36 */
37 public static function getFields($checkPermissions = TRUE) {
38 return (new Generic\BasicGetFieldsAction('Entity', __FUNCTION__, function() {
39 return [
40 [
41 'name' => 'name',
42 'description' => 'Entity name',
43 ],
44 [
45 'name' => 'title',
46 'description' => 'Localized title (singular)',
47 ],
48 [
49 'name' => 'title_plural',
50 'description' => 'Localized title (plural)',
51 ],
52 [
53 'name' => 'type',
54 'data_type' => 'Array',
55 'description' => 'Base class for this entity',
56 'options' => [
57 'AbstractEntity' => 'AbstractEntity',
58 'DAOEntity' => 'DAOEntity',
59 'CustomValue' => 'CustomValue',
60 'BasicEntity' => 'BasicEntity',
61 'SortableEntity' => 'SortableEntity',
62 'ManagedEntity' => 'ManagedEntity',
63 'EntityBridge' => 'EntityBridge',
64 ],
65 ],
66 [
67 'name' => 'description',
68 'description' => 'Description from docblock',
69 ],
70 [
71 'name' => 'comment',
72 'description' => 'Comments from docblock',
73 ],
74 [
75 'name' => 'icon',
76 'description' => 'crm-i icon class associated with this entity',
77 ],
78 [
79 'name' => 'dao',
80 'description' => 'Class name for dao-based entities',
81 ],
82 [
83 'name' => 'primary_key',
84 'data_type' => 'Array',
85 'description' => 'Name of unique identifier field(s) (e.g. [id])',
86 ],
87 [
88 'name' => 'label_field',
89 'description' => 'Field to show when displaying a record',
90 ],
91 [
92 'name' => 'order_by',
93 'description' => 'Default column to sort results',
94 ],
95 [
96 'name' => 'searchable',
97 'description' => 'How should this entity be presented in search UIs',
98 'options' => [
99 'primary' => ts('Primary'),
100 'secondary' => ts('Secondary'),
101 'bridge' => ts('Bridge'),
102 'none' => ts('None'),
103 ],
104 ],
105 [
106 'name' => 'paths',
107 'data_type' => 'Array',
108 'description' => 'System paths for accessing this entity',
109 ],
110 [
111 'name' => 'see',
112 'data_type' => 'Array',
113 'description' => 'Any @see annotations from docblock',
114 ],
115 [
116 'name' => 'since',
117 'data_type' => 'String',
118 'description' => 'Version this API entity was added',
119 ],
120 [
121 'name' => 'class',
122 'data_type' => 'String',
123 'description' => 'PHP class name',
124 ],
125 [
126 'name' => 'bridge',
127 'data_type' => 'Array',
128 'description' => 'Connecting fields for EntityBridge types',
129 ],
130 [
131 'name' => 'ui_join_filters',
132 'data_type' => 'Array',
133 'description' => 'When joining entities in the UI, which fields should be presented by default in the ON clause',
134 ],
135 [
136 'name' => 'group_weights_by',
137 'data_type' => 'Array',
138 'description' => 'For sortable entities, what field groupings are used to order by weight',
139 ],
140 ];
141 }))->setCheckPermissions($checkPermissions);
142 }
143
144 /**
145 * @param bool $checkPermissions
146 * @deprecated
147 * @return Action\Entity\GetLinks
148 */
149 public static function getLinks($checkPermissions = TRUE) {
150 return (new Action\Entity\GetLinks('Entity', __FUNCTION__))
151 ->setCheckPermissions($checkPermissions);
152 }
153
154 /**
155 * @return array
156 */
157 public static function permissions() {
158 return [
159 'default' => ['access CiviCRM'],
160 ];
161 }
162
163 }