3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
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 +--------------------------------------------------------------------+
14 * Retrieves information about all Api4 entities.
16 * @see \Civi\Api4\Generic\AbstractEntity
22 class Entity
extends Generic\AbstractEntity
{
25 * @param bool $checkPermissions
26 * @return Action\Entity\Get
28 public static function get($checkPermissions = TRUE) {
29 return (new Action\Entity\
Get('Entity', __FUNCTION__
))
30 ->setCheckPermissions($checkPermissions);
34 * @param bool $checkPermissions
35 * @return Generic\BasicGetFieldsAction
37 public static function getFields($checkPermissions = TRUE) {
38 return (new Generic\
BasicGetFieldsAction('Entity', __FUNCTION__
, function(Generic\BasicGetFieldsAction
$getFields) {
42 'description' => 'Entity name',
46 'description' => 'Localized title (singular)',
49 'name' => 'title_plural',
50 'description' => 'Localized title (plural)',
54 'data_type' => 'Array',
55 'description' => 'Base class for this entity',
56 'options' => $getFields->getLoadOptions() ? self
::getEntityTypes() : TRUE,
59 'name' => 'description',
60 'description' => 'Description from docblock',
64 'description' => 'Comments from docblock',
68 'description' => 'crm-i icon class associated with this entity',
72 'description' => 'Class name for dao-based entities',
75 'name' => 'table_name',
76 'description' => 'Name of sql table, if applicable',
79 'name' => 'primary_key',
80 'data_type' => 'Array',
81 'description' => 'Name of unique identifier field(s) (e.g. [id])',
84 'name' => 'label_field',
85 'description' => 'Field to show when displaying a record',
89 'description' => 'Default column to sort results',
92 'name' => 'searchable',
93 'description' => 'How should this entity be presented in search UIs',
95 'primary' => ts('Primary'),
96 'secondary' => ts('Secondary'),
97 'bridge' => ts('Bridge'),
103 'data_type' => 'Array',
104 'description' => 'System paths for accessing this entity',
108 'data_type' => 'Array',
109 'description' => 'Any @see annotations from docblock',
113 'data_type' => 'String',
114 'description' => 'Version this API entity was added',
118 'data_type' => 'String',
119 'description' => 'PHP class name',
122 'name' => 'class_args',
123 'data_type' => 'Array',
124 'description' => 'Arguments needed by php action factory functions (used when multiple entities share a class, e.g. CustomValue).',
128 'data_type' => 'Array',
129 'description' => 'Connecting fields for EntityBridge types',
132 'name' => 'ui_join_filters',
133 'data_type' => 'Array',
134 'description' => 'When joining entities in the UI, which fields should be presented by default in the ON clause',
137 'name' => 'group_weights_by',
138 'data_type' => 'Array',
139 'description' => 'For sortable entities, what field groupings are used to order by weight',
142 }))->setCheckPermissions($checkPermissions);
146 * @param bool $checkPermissions
148 * @return Action\Entity\GetLinks
150 public static function getLinks($checkPermissions = TRUE) {
151 return (new Action\Entity\
GetLinks('Entity', __FUNCTION__
))
152 ->setCheckPermissions($checkPermissions);
158 public static function permissions() {
160 'default' => ['access CiviCRM'],
165 * Collect the 'type' values from every entity.
169 private static function getEntityTypes() {
170 $provider = \Civi
::service('action_object_provider');
172 foreach ($provider->getEntities() as $entity) {
173 foreach ($entity['type'] ??
[] as $type) {
174 $entityTypes[$type] = $type;