* @return Generic\BasicGetFieldsAction
*/
public static function getFields($checkPermissions = TRUE) {
- return (new Generic\BasicGetFieldsAction('Entity', __FUNCTION__, function() {
+ return (new Generic\BasicGetFieldsAction('Entity', __FUNCTION__, function(Generic\BasicGetFieldsAction $getFields) {
return [
[
'name' => 'name',
'name' => 'type',
'data_type' => 'Array',
'description' => 'Base class for this entity',
- 'options' => [
- 'AbstractEntity' => 'AbstractEntity',
- 'DAOEntity' => 'DAOEntity',
- 'CustomValue' => 'CustomValue',
- 'BasicEntity' => 'BasicEntity',
- 'SortableEntity' => 'SortableEntity',
- 'ManagedEntity' => 'ManagedEntity',
- 'EntityBridge' => 'EntityBridge',
- ],
+ 'options' => $getFields->getLoadOptions() ? self::getEntityTypes() : TRUE,
],
[
'name' => 'description',
];
}
+ /**
+ * Collect the 'type' values from every entity.
+ *
+ * @return array
+ */
+ private static function getEntityTypes() {
+ $provider = \Civi::service('action_object_provider');
+ $entityTypes = [];
+ foreach ($provider->getEntities() as $entity) {
+ foreach ($entity['type'] ?? [] as $type) {
+ $entityTypes[$type] = $type;
+ }
+ }
+ return $entityTypes;
+ }
+
}