Course: add Delete operation to /api/courses/{id} (admin only)#8675
Course: add Delete operation to /api/courses/{id} (admin only)#8675addow wants to merge 1 commit into
Conversation
Follow-up: filesystem and ResourceNode cleanup are not handledAfter further investigation, I want to flag a limitation of this implementation before it is merged. What happens when API Platform's default remove processor calls
The correct approach would be a custom The commented-out node-walking code in Options going forward:
Happy to implement option 2 if that is the preferred direction. |
Summary
Adds
DELETE /api/courses/{id}to the Course#[ApiResource], restricted toROLE_ADMIN.EntityManager::remove()+ flush)onDelete: CASCADEonresource_node_idhandles cleanup of the linked ResourceNodePatch) and Session (Delete)Notes
CourseVoter::DELETEgrants course teachers delete rights, which would be too permissive for a course-level delete. The explicitis_granted('ROLE_ADMIN')sidesteps the voter and restricts access correctly.Physical files (e.g. course illustrations on disk) are not automatically removed on delete — this is a pre-existing limitation shared by the legacy
CourseRepository::deleteCourse().