So far we don't have this setup in the services. Make sure to set scope: prototype on the entity so that every instance of phpbb.boardrules.entity fetched is new (otherwise it will just give you the last used instance, which will be filled with the last row's data). See: https://github.com/phpbb/phpbb/blob/develop/phpBB/config/notifications.yml#L18

Inject $phpbb_container, don't use any globals.

This looks like it could be correct though (I've never used the nested set system myself).