How can I resolve `MyAcmeBundle:User` to `My\AcmeBundle\Entity\User` in Symfony2?

浪尽此生 提交于 2019-12-12 12:35:56

问题


How can I resolve logical entity names to full class names in Symfony2? Like MyAcmeBundle:User to My\AcmeBundle\Entity\User.


回答1:


You can get the ClassMetadata from the EntityManager which will resolve the namespace into a fully qualified class name.

<?php
echo $manager->getClassMetadata('MyAcmeBundle:User')->getName();


来源:https://stackoverflow.com/questions/11406697/how-can-i-resolve-myacmebundleuser-to-my-acmebundle-entity-user-in-symfony2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!