hi! have a look in the cache/*container*.php and look at the
getDoctrine_orm_*service methods. the Configuration class on
EntityManager gives you a way to configure the namespaces used in a
Dql query.

http://www.doctrine-project.org/api/orm/2.0/doctrine/orm/configuration.html#setEntityNamespaces()

not tested, but hope it helps!


On 12 sep, 13:39, VolCh <vol...@gmail.com> wrote:
> Hello!
>
> I try to play with sandbox and mongodb. Following the guide I create
> bundle, controller, etc. and try to get collection from mongodb:
>
> namespace Application\PageBundle\Controller;
>
> use Symfony\Framework\FoundationBundle\Controller;
>
> use Application\PageBundle\Document\Page;
>
> class PageController extends Controller
> {
>     public function createAction($title, $body)
>     {
>         $dm = $this->container-
>
> >getService('doctrine.odm.mongodb.document_manager');
>
>         $page = new Page();
>         $page->setTitle($title);
>         $page->setBody($body);
>
>         $dm->persist($page);
>         $dm->flush();
>
>         return $this->redirect($this->generateUrl('page_list'));
>     }
>     public function listAction()
>     {
>         $dm = $this->container-
>
> >getService('doctrine.odm.mongodb.document_manager');
>
>         $pages = $dm->find('Page');
>
>         return $this->render('PageBundle:Page:list', array('pages' =>
> $pages));
>     }
>
> }
>
> This isn't works in listAction(), i get:
> "500 Internal Server Error - ErrorException
> Warning: class_parents(): Class Page does not exist and could not be
> loaded in /home/volch/symfony2-sandbox/src/vendor/doctrine-mongodb/lib/
> Doctrine/ODM/MongoDB/Mapping/ClassMetadataFactory.php line 279"
>
> When I try "$dm->find('Application\PageBundle\Document\Page');" it's
> works fine.
>
> So I think to use find('Page') I must register in somewhere
> "Application\PageBundle\Document\Page" as "Page" or use "use
> Application\PageBundle\Document\Page;" somewhere else. But i can't
> find place for it.
>
> Please show me this place. Thanks.
>
> P.S. I use annotations in Application\PageBundle\Document\Page and
> they are works in createAction()

-- 
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 users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en

Reply via email to