Merge pull request #22242 from MegaphoneJon/reporting-85
[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' => 'table_name',
84 'description' => 'Name of sql table, if applicable',
85 ],
86 [
87 'name' => 'primary_key',
88 'data_type' => 'Array',
89 'description' => 'Name of unique identifier field(s) (e.g. [id])',
90 ],
91 [
92 'name' => 'label_field',
93 'description' => 'Field to show when displaying a record',
94 ],
95 [
96 'name' => 'order_by',
97 'description' => 'Default column to sort results',
98 ],
99 [
100 'name' => 'searchable',
101 'description' => 'How should this entity be presented in search UIs',
102 'options' => [
103 'primary' => ts('Primary'),
104 'secondary' => ts('Secondary'),
105 'bridge' => ts('Bridge'),
106 'none' => ts('None'),
107 ],
108 ],
109 [
110 'name' => 'paths',
111 'data_type' => 'Array',
112 'description' => 'System paths for accessing this entity',
113 ],
114 [
115 'name' => 'see',
116 'data_type' => 'Array',
117 'description' => 'Any @see annotations from docblock',
118 ],
119 [
120 'name' => 'since',
121 'data_type' => 'String',
122 'description' => 'Version this API entity was added',
123 ],
124 [
125 'name' => 'class',
126 'data_type' => 'String',
127 'description' => 'PHP class name',
128 ],
129 [
130 'name' => 'class_args',
131 'data_type' => 'Array',
132 'description' => 'Arguments needed by php action factory functions (used when multiple entities share a class, e.g. CustomValue).',
133 ],
134 [
135 'name' => 'bridge',
136 'data_type' => 'Array',
137 'description' => 'Connecting fields for EntityBridge types',
138 ],
139 [
140 'name' => 'ui_join_filters',
141 'data_type' => 'Array',
142 'description' => 'When joining entities in the UI, which fields should be presented by default in the ON clause',
143 ],
144 [
145 'name' => 'group_weights_by',
146 'data_type' => 'Array',
147 'description' => 'For sortable entities, what field groupings are used to order by weight',
148 ],
149 ];
150 }))->setCheckPermissions($checkPermissions);
151 }
152
153 /**
154 * @param bool $checkPermissions
155 * @deprecated
156 * @return Action\Entity\GetLinks
157 */
158 public static function getLinks($checkPermissions = TRUE) {
159 return (new Action\Entity\GetLinks('Entity', __FUNCTION__))
160 ->setCheckPermissions($checkPermissions);
161 }
162
163 /**
164 * @return array
165 */
166 public static function permissions() {
167 return [
168 'default' => ['access CiviCRM'],
169 ];
170 }
171
172 }