Merge pull request #17895 from civicrm/5.28
[civicrm-core.git] / Civi / Api4 / Entity.php
1 <?php
2
3 /*
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC. All rights reserved. |
6 | |
7 | This work is published under the GNU AGPLv3 license with some |
8 | permitted exceptions and without any warranty. For full license |
9 | and copyright information, see https://civicrm.org/licensing |
10 +--------------------------------------------------------------------+
11 */
12
13 /**
14 *
15 * @package CRM
16 * @copyright CiviCRM LLC https://civicrm.org/licensing
17 */
18
19
20 namespace Civi\Api4;
21
22 /**
23 * Retrieves information about all Api4 entities.
24 *
25 * @see \Civi\Api4\Generic\AbstractEntity
26 *
27 * @package Civi\Api4
28 */
29 class Entity extends Generic\AbstractEntity {
30
31 /**
32 * @param bool $checkPermissions
33 * @return Action\Entity\Get
34 */
35 public static function get($checkPermissions = TRUE) {
36 return (new Action\Entity\Get('Entity', __FUNCTION__))
37 ->setCheckPermissions($checkPermissions);
38 }
39
40 /**
41 * @param bool $checkPermissions
42 * @return Generic\BasicGetFieldsAction
43 */
44 public static function getFields($checkPermissions = TRUE) {
45 return (new Generic\BasicGetFieldsAction('Entity', __FUNCTION__, function() {
46 return [
47 [
48 'name' => 'name',
49 'description' => 'Entity name',
50 ],
51 [
52 'name' => 'title',
53 'description' => 'Localized title',
54 ],
55 [
56 'name' => 'description',
57 'description' => 'Description from docblock',
58 ],
59 [
60 'name' => 'comment',
61 'description' => 'Comments from docblock',
62 ],
63 [
64 'name' => 'icon',
65 'description' => 'crm-i icon class associated with this entity',
66 ],
67 [
68 'name' => 'dao',
69 'description' => 'Class name for dao-based entities',
70 ],
71 [
72 'name' => 'see',
73 'data_type' => 'Array',
74 'description' => 'Any @see annotations from docblock',
75 ],
76 ];
77 }))->setCheckPermissions($checkPermissions);
78 }
79
80 /**
81 * @param bool $checkPermissions
82 * @return Action\Entity\GetLinks
83 */
84 public static function getLinks($checkPermissions = TRUE) {
85 return (new Action\Entity\GetLinks('Entity', __FUNCTION__))
86 ->setCheckPermissions($checkPermissions);
87 }
88
89 /**
90 * @return array
91 */
92 public static function permissions() {
93 return [
94 'default' => ['access CiviCRM'],
95 ];
96 }
97
98 }