Merge pull request #21890 from mariav0/patch-28
[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 'EntityBridge' => 'EntityBridge',
62 'OptionList' => 'OptionList',
63 ],
64 ],
65 [
66 'name' => 'description',
67 'description' => 'Description from docblock',
68 ],
69 [
70 'name' => 'comment',
71 'description' => 'Comments from docblock',
72 ],
73 [
74 'name' => 'icon',
75 'description' => 'crm-i icon class associated with this entity',
76 ],
77 [
78 'name' => 'dao',
79 'description' => 'Class name for dao-based entities',
80 ],
81 [
82 'name' => 'primary_key',
83 'type' => 'Array',
84 'description' => 'Name of unique identifier field(s) (e.g. [id])',
85 ],
86 [
87 'name' => 'label_field',
88 'description' => 'Field to show when displaying a record',
89 ],
90 [
91 'name' => 'searchable',
92 'description' => 'How should this entity be presented in search UIs',
93 'options' => [
94 'primary' => ts('Primary'),
95 'secondary' => ts('Secondary'),
96 'bridge' => ts('Bridge'),
97 'none' => ts('None'),
98 ],
99 ],
100 [
101 'name' => 'paths',
102 'data_type' => 'Array',
103 'description' => 'System paths for accessing this entity',
104 ],
105 [
106 'name' => 'see',
107 'data_type' => 'Array',
108 'description' => 'Any @see annotations from docblock',
109 ],
110 [
111 'name' => 'since',
112 'data_type' => 'String',
113 'description' => 'Version this API entity was added',
114 ],
115 [
116 'name' => 'class',
117 'data_type' => 'String',
118 'description' => 'PHP class name',
119 ],
120 [
121 'name' => 'bridge',
122 'data_type' => 'Array',
123 'description' => 'Connecting fields for EntityBridge types',
124 ],
125 [
126 'name' => 'ui_join_filters',
127 'data_type' => 'Array',
128 'description' => 'When joining entities in the UI, which fields should be presented by default in the ON clause',
129 ],
130 ];
131 }))->setCheckPermissions($checkPermissions);
132 }
133
134 /**
135 * @param bool $checkPermissions
136 * @deprecated
137 * @return Action\Entity\GetLinks
138 */
139 public static function getLinks($checkPermissions = TRUE) {
140 return (new Action\Entity\GetLinks('Entity', __FUNCTION__))
141 ->setCheckPermissions($checkPermissions);
142 }
143
144 /**
145 * @return array
146 */
147 public static function permissions() {
148 return [
149 'default' => ['access CiviCRM'],
150 ];
151 }
152
153 }