$data is protected and not accessible here. Could you pass the entity to your function and then grab what's required from the getters?