Merge pull request #17834 from colemanw/api4perm
[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 * $Id$
18 *
19 */
20
21
22 namespace Civi\Api4;
23
24 /**
25 * Retrieves information about all Api4 entities.
26 *
27 * @see \Civi\Api4\Generic\AbstractEntity
28 *
29 * @package Civi\Api4
30 */
31 class Entity extends Generic\AbstractEntity {
32
33 /**
34 * @param bool $checkPermissions
35 * @return Action\Entity\Get
36 */
37 public static function get($checkPermissions = TRUE) {
38 return (new Action\Entity\Get('Entity', __FUNCTION__))
39 ->setCheckPermissions($checkPermissions);
40 }
41
42 /**
43 * @param bool $checkPermissions
44 * @return Generic\BasicGetFieldsAction
45 */
46 public static function getFields($checkPermissions = TRUE) {
47 return (new Generic\BasicGetFieldsAction('Entity', __FUNCTION__, function() {
48 return [
49 [
50 'name' => 'name',
51 'description' => 'Entity name',
52 ],
53 [
54 'name' => 'title',
55 'description' => 'Localized title',
56 ],
57 [
58 'name' => 'description',
59 'description' => 'Description from docblock',
60 ],
61 [
62 'name' => 'comment',
63 'description' => 'Comments from docblock',
64 ],
65 [
66 'name' => 'icon',
67 'description' => 'crm-i icon class associated with this entity',
68 ],
69 [
70 'name' => 'dao',
71 'description' => 'Class name for dao-based entities',
72 ],
73 [
74 'name' => 'see',
75 'data_type' => 'Array',
76 'description' => 'Any @see annotations from docblock',
77 ],
78 ];
79 }))->setCheckPermissions($checkPermissions);
80 }
81
82 /**
83 * @param bool $checkPermissions
84 * @return Action\Entity\GetLinks
85 */
86 public static function getLinks($checkPermissions = TRUE) {
87 return (new Action\Entity\GetLinks('Entity', __FUNCTION__))
88 ->setCheckPermissions($checkPermissions);
89 }
90
91 /**
92 * @return array
93 */
94 public static function permissions() {
95 return [
96 'default' => ['access CiviCRM'],
97 ];
98 }
99
100 }