I've fixed the problem so that I get back my objects instead of
arrays. I'm not sure why, but using the getRepository method seems to
work i.e.

public function deleteAction($id)
    {
      $dm = $this->get('doctrine.odm.mongodb.document_manager');

      $project = $dm->getRepository('Big\ProjectBundle\Document
\Project')->find($id);

      $dm->remove($project);
      $dm->flush();

      return array('project' => $project);
    }

If anyone knows why that is the case please let me know.

Cheers,
Pete

On Apr 7, 11:05 pm, Poida <peter.lob...@gmail.com> wrote:
> Hi All,
>
> I hope I'm posting to the correct group! I am developing a new
> application based on: Symfony 2 PR9 w/ doctrine-mongodb and doctrine-
> mongodb-odm. I am using yaml annotations to generate my schema/
> documents. As far as I can tell the application is working correctly
> and I am able to find documents in the DB, however, the objects come
> back from the document manager as an array, not as a doctrine object.
>
> Here is some code for a delete method, it works except $project is an
> array, not a Big\ProjectBundle\Document\Project object:
>
>     /**
>      * @extra:Route("/{id}/delete")
>      * @extra:Template()
>      */
>     public function deleteAction($id)
>     {
>       $dm = $this->get('doctrine.odm.mongodb.document_manager');
>
>       $project = $dm
>         ->getDocumentCollection('Big\ProjectBundle\Document\Project')
>         ->findOne(array('_id' => new \MongoId($id)));
>
>       $dm->remove($project);
>       $dm->flush();
>
>       return array('project' => $project);
>     }
>
> var_dump($project) yields:
>
> array
>   '_id' =>
>     object(MongoId)[345]
>       public '$id' => string '4d9c49287baa57a40b000001' (length=24)
>   'name' => string
>   etc...
>
> Thank you for your help!
>
> Cheers,
> Pete

-- 
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