Hi,

Everything you stated is correct. If you want to write some kind of abstract
code for object instantiation and pass the  short class name then you have
to do that to get the full class name.

- Jon

On Tue, Nov 9, 2010 at 7:13 PM, Thomas Rabaix <thomas.rab...@gmail.com>wrote:

> Hello,
>
> From the documentation, it is possible to call an entity inside a doctrine
> query with the shorthand notation : "MyBundle:Post"  [1]. Doctrine will look
> inside the Application and the Bundle to find where the class is defined.
> This point is very nice.
>
> However this point also means, we need to ask a service to request the
> correct fully qualify namespace of an Entity (ie
> Application\MyBundle\Entity\Post or Bundle\MyBundle\Entity\Post ). For now
> the only solution I found is to use the entity manager :
> $em->getClassMetadata('MyBundle:Post')->name
>
> So to instantiate a new Post object, we need to do something like :
>
> $class = $em->getClassMetadata('UrlShortenerBundle:Url')->name;
> $post = new $class;
>
> This situation introduce a dependency to the entity manager for any class
> which need to instantiate an object (the class might not want to persist the
> object).
>
> what do you think ?
>
>
> [1] http://docs.symfony-reloaded.org/guides/doctrine/orm/overview.html
>
>
>  --
> If you want to report a vulnerability issue on symfony, please send it to
> security at symfony-project.com
>
> You received this message because you are subscribed to the Google
> Groups "symfony developers" group.
> To post to this group, send email to symfony-devs@googlegroups.com
> To unsubscribe from this group, send email to
> symfony-devs+unsubscr...@googlegroups.com<symfony-devs%2bunsubscr...@googlegroups.com>
> For more options, visit this group at
> http://groups.google.com/group/symfony-devs?hl=en
>



-- 
Jonathan H. Wage
http://www.twitter.com/jwage

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony developers" group.
To post to this group, send email to symfony-devs@googlegroups.com
To unsubscribe from this group, send email to
symfony-devs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-devs?hl=en

Reply via email to