| 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 (singular)', |
| 54 | ], |
| 55 | [ |
| 56 | 'name' => 'title_plural', |
| 57 | 'description' => 'Localized title (plural)', |
| 58 | ], |
| 59 | [ |
| 60 | 'name' => 'type', |
| 61 | 'data_type' => 'Array', |
| 62 | 'description' => 'Base class for this entity', |
| 63 | 'options' => [ |
| 64 | 'AbstractEntity' => 'AbstractEntity', |
| 65 | 'DAOEntity' => 'DAOEntity', |
| 66 | 'BasicEntity' => 'BasicEntity', |
| 67 | 'EntityBridge' => 'EntityBridge', |
| 68 | 'OptionList' => 'OptionList', |
| 69 | ], |
| 70 | ], |
| 71 | [ |
| 72 | 'name' => 'description', |
| 73 | 'description' => 'Description from docblock', |
| 74 | ], |
| 75 | [ |
| 76 | 'name' => 'comment', |
| 77 | 'description' => 'Comments from docblock', |
| 78 | ], |
| 79 | [ |
| 80 | 'name' => 'icon', |
| 81 | 'description' => 'crm-i icon class associated with this entity', |
| 82 | ], |
| 83 | [ |
| 84 | 'name' => 'dao', |
| 85 | 'description' => 'Class name for dao-based entities', |
| 86 | ], |
| 87 | [ |
| 88 | 'name' => 'searchable', |
| 89 | 'description' => 'Should this entity be selectable in search kit UI', |
| 90 | ], |
| 91 | [ |
| 92 | 'name' => 'paths', |
| 93 | 'data_type' => 'Array', |
| 94 | 'description' => 'System paths for accessing this entity', |
| 95 | ], |
| 96 | [ |
| 97 | 'name' => 'see', |
| 98 | 'data_type' => 'Array', |
| 99 | 'description' => 'Any @see annotations from docblock', |
| 100 | ], |
| 101 | ]; |
| 102 | }))->setCheckPermissions($checkPermissions); |
| 103 | } |
| 104 | |
| 105 | /** |
| 106 | * @param bool $checkPermissions |
| 107 | * @return Action\Entity\GetLinks |
| 108 | */ |
| 109 | public static function getLinks($checkPermissions = TRUE) { |
| 110 | return (new Action\Entity\GetLinks('Entity', __FUNCTION__)) |
| 111 | ->setCheckPermissions($checkPermissions); |
| 112 | } |
| 113 | |
| 114 | /** |
| 115 | * @return array |
| 116 | */ |
| 117 | public static function permissions() { |
| 118 | return [ |
| 119 | 'default' => ['access CiviCRM'], |
| 120 | ]; |
| 121 | } |
| 122 | |
| 123 | } |