Remove boilerplate code block from APIv4 classes
[civicrm-core.git] / Civi / Api4 / Entity.php
CommitLineData
19b53e5b 1<?php
380f3545
TO
2/*
3 +--------------------------------------------------------------------+
41498ac5 4 | Copyright CiviCRM LLC. All rights reserved. |
380f3545 5 | |
41498ac5
TO
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 |
380f3545
TO
9 +--------------------------------------------------------------------+
10 */
19b53e5b
C
11namespace Civi\Api4;
12
13/**
14 * Retrieves information about all Api4 entities.
15 *
0493ec47
CW
16 * @see \Civi\Api4\Generic\AbstractEntity
17 *
aa998597 18 * @searchable none
19b53e5b
C
19 * @package Civi\Api4
20 */
21class Entity extends Generic\AbstractEntity {
22
23 /**
6764a9d3 24 * @param bool $checkPermissions
19b53e5b
C
25 * @return Action\Entity\Get
26 */
6764a9d3
CW
27 public static function get($checkPermissions = TRUE) {
28 return (new Action\Entity\Get('Entity', __FUNCTION__))
29 ->setCheckPermissions($checkPermissions);
19b53e5b
C
30 }
31
32 /**
6764a9d3
CW
33 * @param bool $checkPermissions
34 * @return Generic\BasicGetFieldsAction
19b53e5b 35 */
6764a9d3
CW
36 public static function getFields($checkPermissions = TRUE) {
37 return (new Generic\BasicGetFieldsAction('Entity', __FUNCTION__, function() {
19b53e5b 38 return [
f827fe49
CW
39 [
40 'name' => 'name',
41 'description' => 'Entity name',
42 ],
60f88aac
CW
43 [
44 'name' => 'title',
9813ae79
CW
45 'description' => 'Localized title (singular)',
46 ],
47 [
48 'name' => 'title_plural',
49 'description' => 'Localized title (plural)',
60f88aac 50 ],
90908aac
CW
51 [
52 'name' => 'type',
465bc32a 53 'data_type' => 'Array',
90908aac 54 'description' => 'Base class for this entity',
465bc32a
CW
55 'options' => [
56 'AbstractEntity' => 'AbstractEntity',
57 'DAOEntity' => 'DAOEntity',
7430e70d 58 'CustomValue' => 'CustomValue',
465bc32a
CW
59 'BasicEntity' => 'BasicEntity',
60 'EntityBridge' => 'EntityBridge',
61 'OptionList' => 'OptionList',
62 ],
90908aac 63 ],
f827fe49
CW
64 [
65 'name' => 'description',
66 'description' => 'Description from docblock',
67 ],
68 [
69 'name' => 'comment',
70 'description' => 'Comments from docblock',
71 ],
60f88aac
CW
72 [
73 'name' => 'icon',
74 'description' => 'crm-i icon class associated with this entity',
75 ],
76 [
77 'name' => 'dao',
78 'description' => 'Class name for dao-based entities',
79 ],
482a26e2
CW
80 [
81 'name' => 'id_field',
82 'description' => 'Name of unique identifier field (e.g. "id")',
83 ],
8ab43c93 84 [
b441e024 85 'name' => 'label_field',
8ab43c93
CW
86 'description' => 'Field to show when displaying a record',
87 ],
09815e9c
CW
88 [
89 'name' => 'searchable',
aa998597
CW
90 'description' => 'How should this entity be presented in search UIs',
91 'options' => [
92 'primary' => ts('Primary'),
93 'secondary' => ts('Secondary'),
c5076889 94 'bridge' => ts('Bridge'),
aa998597
CW
95 'none' => ts('None'),
96 ],
09815e9c 97 ],
a7bd99ff
CW
98 [
99 'name' => 'paths',
100 'data_type' => 'Array',
101 'description' => 'System paths for accessing this entity',
102 ],
f827fe49
CW
103 [
104 'name' => 'see',
e15f9453 105 'data_type' => 'Array',
f827fe49
CW
106 'description' => 'Any @see annotations from docblock',
107 ],
c5368b3b
CW
108 [
109 'name' => 'bridge',
110 'data_type' => 'Array',
111 'description' => 'Connecting fields for EntityBridge types',
112 ],
2f616560
CW
113 [
114 'name' => 'ui_join_filters',
115 'data_type' => 'Array',
116 'description' => 'When joining entities in the UI, which fields should be presented by default in the ON clause',
117 ],
19b53e5b 118 ];
6764a9d3 119 }))->setCheckPermissions($checkPermissions);
19b53e5b
C
120 }
121
122 /**
6764a9d3 123 * @param bool $checkPermissions
19b53e5b
C
124 * @return Action\Entity\GetLinks
125 */
6764a9d3
CW
126 public static function getLinks($checkPermissions = TRUE) {
127 return (new Action\Entity\GetLinks('Entity', __FUNCTION__))
128 ->setCheckPermissions($checkPermissions);
19b53e5b
C
129 }
130
131 /**
132 * @return array
133 */
134 public static function permissions() {
135 return [
136 'default' => ['access CiviCRM'],
137 ];
138 }
139
140}