SubEntity
Create a new subentity
drush generate subentity
Contrary to the drush generate content-entity
command, there is no new module
created with a subentity. A subentity should live in the main entity module.
It is possible to create a new entity without answering the questions one by one. Use the following syntax:
drush generate subentity --answers='{"machine_name":M,"entity_name":"myentity","entity_class":"MyEntity","label":"My Entity","bundle":"No"}'
Then install the database schema in a hook_update_N
:
function myentity_update_1001() {
Drupal::entityTypeManager()->clearCachedDefinitions();
$entity_type = Drupal::entityTypeManager()->getDefinition('myentity');
Drupal::entityDefinitionUpdateManager()->installEntityType($entity_type);
}
Technical details
ReferencedEntityAccessControlHandler
Handler for access control. Subentity does not have any permission on its own, it inherits from the main entity.
EntityHtmlRouteProvider
TBD.
ReferencedEntityForm
TBD.
EntitySettingsForm
TBD.
ReferencedEntityListBuilder
TBD.