I have defined a custom content entity. (You may find the details below.) If I create an entry in the table and a translation for the entry and then delete the translation it removes the entire entry.
/**
* @ContentEntityType(
* id = "my_custom_entity",
* label = @Translation("My Custom Entity"),
* handlers = {
* "storage" = "Drupal\Core\Entity\Sql\SqlContentEntityStorage",
* "access" = "Drupal\my_custom_entity\MyCustomEntityAccessControlHandler",
* "form" = {
* "default" = "Drupal\my_custom_entity\Form\MyCustomEntityForm",
* "delete" = "Drupal\my_custom_entity\Form\MyCustomEntityDeleteForm",
* },
* "list_builder" = "Drupal\my_custom_entity\Entity\Controller\MyCustomEntityListBuilder",
* "view_builder" = "Drupal\Core\Entity\EntityViewBuilder",
* "views_data" = "Drupal\my_custom_entity\MyCustomEntityViewsData",
* "translation" = "Drupal\content_translation\ContentTranslationHandler"
* },
* translatable = TRUE,
* base_table = "my_custom_entity",
* data_table = "my_custom_entity_field_data",
* fieldable = FALSE,
* entity_keys = {
* "id" = "id",
* "label" = "label",
* "langcode" = "langcode"
* },
* links = {
* "canonical" = "/my_custom_entity/{my_custom_entity}",
* "edit-form" = "/my_custom_entity/{my_custom_entity}/edit",
* "delete-form" = "/my_custom_entity/{my_custom_entity}/delete",
* "collection" = "/my_custom_entity/list"
* },
* list_cache_contexts = {"user"}
* )
*/
Update: I've made a bit of progress on this. The issue seems to be that the entity provides a delete-form. On account of this core/modules/content_translation/src/Access/ContentTranslationManageAccessCheck::access
ends up returning AccessResult::forbidden()
on line 85 (Drupal 8.3.7) when looking at the path /my_custom_entity/{my_custom_entity}/translations/delete/{language}
. Instead it uses /my_custom_entity/{my_custom_entity}/delete
. Now I've got to figure out what I'm supposed to do instead. The User entity does not declare a delete-form, but the Node entity does. My initial attempt at removing the delete-form key on my entity resulted in Uncaught PHP Exception Symfony\\Component\\Routing\\Exception\\RouteNotFoundException: "Route "entity.my_custom_entity.delete_form" does not exist." at /var/www/html/drupal8/core/lib/Drupal/Core/Routing/RouteProvider.php line 190
. However, I didn't actually uninstall and reinstall the module. I just visited the Extend page and cleared cache.