Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion __construct() not executing after a find()
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Maarten van Leeuwen  
View profile  
 More options Nov 10 2012, 9:53 am
From: Maarten van Leeuwen <mvanleeu...@gmail.com>
Date: Sat, 10 Nov 2012 15:53:07 +0100
Local: Sat, Nov 10 2012 9:53 am
Subject: Re: [doctrine-user] __construct() not executing after a find()

An entity that exists in your database is not a new entity so it does not have to be constructed. It should not matter if the domainobject you want to find in your repository is managed or must be fetched from a database first. Constructors are for new entities, not for persisted entities.

Regards,
Maarten van Leeuwen

Op 10 nov. 2012 om 02:44 heeft fesja <fes...@gmail.com> het volgende geschreven:

> Hi,

> I'm starting with Doctrine2 (previously in Doctrine1.2) and I have found something that seems strange and I don't understand.

> I do a query to get a place:

> <?php

> namespace TE\TestBundle\Entity;

> use Doctrine\ORM\EntityRepository;
> use Doctrine\ORM\AbstractQuery;

> class PlaceRepository extends EntityRepository
> {
>     public function find($id, $locale='en')
>     {
>         return $this->_em->createQuery('SELECT p, ptr FROM TE\TestBundle\Entity\Place p JOIN p.translations ptr
>             WHERE p.id = :id and ptr.locale = :locale')
>             ->setParameter('id', $id)
>             ->setParameter('locale', $locale)
>             ->getOneOrNullResult(AbstractQuery::HYDRATE_OBJECT);
>     }
> }

> It returns me an object of that Entity, but it doesn't execute the __construct() method.

> Could you explain me why and how is the philosophy about that, and how I have to manage those kinds of things. On this scenario, I wanted to inject a service to Place through the constructor.

> thanks!
> --
> You received this message because you are subscribed to the Google Groups "doctrine-user" group.
> To view this discussion on the web visit https://groups.google.com/d/msg/doctrine-user/-/JPfgRygNOLcJ.
> To post to this group, send email to doctrine-user@googlegroups.com.
> To unsubscribe from this group, send email to doctrine-user+unsubscribe@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/doctrine-user?hl=en.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.