Refactor EntityToIdentifier stuff into ObjectToIdentifier

Remove hardcoded dependency on Doctrine ORM, and allow instead to register transformer for every persistence type (ORM, ODM, PHP-CR).

This is alternative approach to the #1244. Fixes #1199.