Google Mail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Message from discussion setUp not called

View Parsed - Show only message text

MIME-Version: 1.0
Received: by 10.100.216.12 with SMTP id o12mr1723497ang.5.1246990159333; Tue, 
	07 Jul 2009 11:09:19 -0700 (PDT)
Date: Tue, 7 Jul 2009 11:09:17 -0700 (PDT)
X-IP: 79.117.78.208
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.12) 
	Gecko/20080201 Firefox/2.0.0.12,gzip(gfe),gzip(gfe)
Message-ID: <ce16d480-ad00-4644-a868-268fe968ade3@d4g2000yqa.googlegroups.com>
Subject: setUp not called
From: Alex Farcas <alex.far...@gmail.com>
To: doctrine-user <doctrine-user@googlegroups.com>
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

Hey guys,

For various reasons (like implementing extended validation with
specifications) i decided to extend DoctrineRecord. So assuming i have
the entity/class called Person, it would inherit from BasePerson (the
default behavior when autogenerated), and BasePerson would inherit
from My_Doctrine_Record. And of course, My_Doctrine_Record, inherits
from DoctrineRecord. So i just added a middle class, and did not let
BasePerson extend Doctrine_Record directly as it normally happens.

Now in Person, i have the setUp function where i add some entries into
an array, and the array is a member of Person. In order to retrieve a
Person i use this: $person = Doctrine::getTable( 'person' )->find
( (int)$id ); Everything works, the person is fetched, and i can play
with it, BUT, the array populated with the setUp method is empty!!

After some debug, it was clear that the array was populated correctly,
so the only explanation remaining was that the Person, was somehow
cloned, and the array got empty in the process. I debugged further,
overriding the constructor in My_Doctrine_Record, and added an "echo('
instance ')". In the setUp method of Person, i added "echo(' set-up
')";

So here's what was printed on the screen, when fetching a Person with
find: instance instance set-up instance.
Which means there were 3 instances of Person created, and only the
second one got it's setUp method called, and it was pretty obvious
that i was getting the last instance, since setUp was not called, and
my array was thus empty.

In the hope i explained things clearly, can anyone tell me why this is
happening, and how to fix it? I don't care that the class Person is
instantiated 3 times (rather wasteful and redundant i would say), but
i do care about my setUp method being called, or having the object
cloned properly (if cloning occurs on the third instance). In short i
need to be able to have that array member i was describing above (or
any member for that matter), keep it's values. Btw, the array member
is called $_specifications, so there isn't a naming conflict with one
of Doctrine_Record's members.



Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google