Resolve "Create Route for Delete Translation"

Adds DELETE API endpoints for removing Canvas entity translations, for both content entities (canvas_page) and config entities (content_template, page_region).

Content entity (canvas_page):

  • Route: DELETE /canvas/api/v0/content/canvas_page/{canvas_page}/translations
  • Language is determined by the URL prefix (Drupal language negotiation) — there is no {language} path parameter.
  • Returns 204 No Content on success.
  • Returns 400 if the resolved translation is the default (Drupal negotiation falls back to the default when the requested language has no translation).
  • Access: canvas_page.update entity permission.
  • Controller: ApiTranslationControllers::delete()

Config entities (content_template, page_region):

  • Route: DELETE /canvas/api/v0/config/{entity_type_id}/{config_entity}/translations
  • Deletes the language config override for the current language.
  • Returns 204 No Content on success; 400 if no override exists for that language.
  • Access: translate configuration permission.
  • Controller: ApiTranslationControllers::deleteConfigTranslation()

Tests added to TranslationTest:

  • testDeleteCanvasPageTranslation() — covers 204 (success) and 400 (default or already-deleted translation) for canvas_page.
  • testDeleteConfigEntityTranslation() — data-provider test covering both content_template and page_region.

Testing instructions

As this has no UI until https://git.drupalcode.org/project/canvas/-/work_items/ 3591459 calls these routes, just ensure that tests pass and cover the need logic

AI Disclosure: large portions with made with Claude code(tedbow)

Closes #3591588 (closed)

Edited by Tim Plunkett

Merge request reports

Loading