Google Mail Calendar Documents Reader Web more »
Help | Sign in
Google Groups Home
Message from discussion setUp not called
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:
Follow-up To:
Add Cc | Add Follow-up 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 that you hear
 
Alex Farcas  
View profile   Translate to Translated (View Original)
 More options 7 July, 19:09
From: Alex Farcas <alex.far...@gmail.com>
Date: Tue, 7 Jul 2009 11:09:17 -0700 (PDT)
Local: Tues 7 July 2009 19:09
Subject: setUp not called
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.

Alex


    Reply to author    Forward  
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.

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