Use getManager instead of getEntityManager. (getEntityManager is deprecated since Symfony 2.1)