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