Possibly to do a "hard" delete using delete() method?

Created on 4 June 2025, 3 days ago

Hello,

I'm looking at building some custom behaviour which means the user can optionally select to delete all related nodes from a group when a group gets deleted. At the moment, with Trash configured as it is the nodes get moved to the trash as expected. I'd also like to offer a "hard" delete option so nodes skip the trash and get fully/hard deleted immediately.

I can't currently see any way of doing this, but might have missed something. Any suggestions?

Thanks!

💬 Support request
Status

Active

Version

3.0

Component

Code

Created by

🇬🇧United Kingdom welly

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @welly
  • 🇬🇧United Kingdom welly

    It looks like this might do what I'm trying to do:

    $this->trashManager->executeInTrashContext('ignore', function () use ($node) {
      $node->delete();
    });
    

    At least it appears to be working. Would this be the correct approach?

  • 🇷🇴Romania amateescu

    Yup, that's the correct way to bypass trash and purge entities directly :)

  • 🇬🇧United Kingdom welly

    Great! Thanks very much. It seems to be working fine. Cheers!

Production build 0.71.5 2024