ah I see you copied this code from the ModelManager in SonataDoctrinePHPCRAdminBundle