this is copy-pasted from symfony and needs to be adjusted.