Deleting data

I'm developing a plugin that creates two types of entities: Projects and Roles. Roles belong to projects, so when a Project is deleted all its Roles should be deleted as well. Is there a well-established way in Elgg to maintain this relationship and to delete a Role when its Project is deleted? I can figure out how to do it manually, but I want to do it right, in a way that's less error prone (i.e., one where a mistake won't leave garbage data lying around, as is currently the case), and more in line with community standards. Thanks in advance!

  • For anyone who reads this in the future, I didn't receive a response so I performed deletion manually when a Project was deleted. Specifically, I maintained a field in each Project called 'roles' containing the GUID of each Role associated with the Project. When a Project is deleted, logic akin to the following occurs:  

    foreach (role in project roles)
        role->delete()
    project->delete()

     I hope that helps anyone who reads this!

  • The Right Way to do this is probably to set each role's container_guid to the associated project's guid. Deleting a container recursively deletes all contained entities as well.

Beginning Developers

Beginning Developers

This space is for newcomers, who wish to build a new plugin or to customize an existing one to their liking