Merge pull request #21957 from eileenmcnaughton/lang
[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 'ManagedEntity' => 'ManagedEntity',
62 'EntityBridge' => 'EntityBridge',
63 'OptionList' => 'OptionList',
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 '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' => 'searchable',
93 'description' => 'How should this entity be presented in search UIs',
94 'options' => [
95 'primary' => ts('Primary'),
96 'secondary' => ts('Secondary'),
97 'bridge' => ts('Bridge'),
98 'none' => ts('None'),
99 ],
100 ],
101 [
102 'name' => 'paths',
103 'data_type' => 'Array',
104 'description' => 'System paths for accessing this entity',
105 ],
106 [
107 'name' => 'see',
108 'data_type' => 'Array',
109 'description' => 'Any @see annotations from docblock',
110 ],
111 [
112 'name' => 'since',
113 'data_type' => 'String',
114 'description' => 'Version this API entity was added',
115 ],
116 [
117 'name' => 'class',
118 'data_type' => 'String',
119 'description' => 'PHP class name',
120 ],
121 [
122 'name' => 'bridge',
123 'data_type' => 'Array',
124 'description' => 'Connecting fields for EntityBridge types',
125 ],
126 [
127 'name' => 'ui_join_filters',
128 'data_type' => 'Array',
129 'description' => 'When joining entities in the UI, which fields should be presented by default in the ON clause',
130 ],
131 ];
132 }))->setCheckPermissions($checkPermissions);
133 }
134
135 /**
136 * @param bool $checkPermissions
137 * @deprecated
138 * @return Action\Entity\GetLinks
139 */
140 public static function getLinks($checkPermissions = TRUE) {
141 return (new Action\Entity\GetLinks('Entity', __FUNCTION__))
142 ->setCheckPermissions($checkPermissions);
143 }
144
145 /**
146 * @return array
147 */
148 public static function permissions() {
149 return [
150 'default' => ['access CiviCRM'],
151 ];
152 }
153
154 }