I Marcelo. I have not tried to use the EM, but as far as I know, it is not
available in the Entity's scope, I will try to find out if this is correct,
because I'm interested in atomic queries.

Regards!

2011/6/22 Marcelo Prizmic <mpriz...@gmail.com>

> Oscar
>
> Thanks for the example!!
>
> Did you use entity manager in the uploadFile()?
>
> In my case I would need to make some queries inside the "preEvent"
> function. Do you know how?
>
> Marcelo
>
>
> 2011/6/21 oscar balladares <liebegr...@gmail.com>
>
>> Hi Marcelo; yes, of course:
>>
>> I'm currently using YML config instead of Annotations. I do really love to
>> separate metadata from Entities classes.
>>
>> You have to tell doctrine to enable LifeCycleCallback event like this:
>>
>> Oscar\HotelBundle\Entity\Foto:
>>     type:  entity
>>     table:  foto
>>     repositoryClass: Oscar\HotelBundle\Repo\FotoRepo
>>     id:
>>         id:
>>             type:  integer
>>             generator:
>>                 strategy:  AUTO
>>     fields:
>>         titulo:
>>             type:  string
>>             length: 100
>>          notnull: false
>>
>>     *lifecycleCallbacks:*
>> *        postPersist: [ uploadFile ]*
>>
>>
>> So you should have an uploadFile() method defined in the entity's class.
>>
>> When you call $em->flush() Doctrine will look for events prior or post
>> flushing. (prePersist, postPersist, preUpdate, postUpdate, preRemove,
>> postRemove)
>>
>> Class Foto
>> {
>> //private properties
>>
>> //public getters and setters
>>
>> public function uploadFile()
>> {
>>   //this is invoked after this entity is persisted.
>> }
>>
>> }
>>
>> In my case, every event is invoked properly, but preUpdate nor postUpdate;
>> If I would have misstyped prePersist: [ uploadFil*eIMisstypedThis* ]
>> the framework will thrown an exception telling me that such method doesn't
>> exist in the entity class; if I do the same for preUpdate, or postUpdate,
>> it will be ignored, like it doesn't check the method.
>>
>> Regards!
>>
>> 2011/6/20 Marcelo Prizmic <mpriz...@gmail.com>
>>
>>> Hi Oscar
>>> Could you post some code about how to use per or post events?
>>> Thanks
>>> Marcelo
>>>
>>>
>>> 2011/6/20 oscar balladares <liebegr...@gmail.com>
>>>
>>>> Hi everybody!.
>>>>
>>>> I'm using Yaml configuration for doctrine metadata.
>>>>
>>>> All others events (prePersist, postPersist, preRemove, postRemove) are
>>>> working properly, but not the preUpdate and PostUpdate.
>>>>
>>>> Of course, I'm just calling the 'persist' method of the $EntityManager:
>>>>
>>>> $em->persist($AlreadyInDatabaseEntityInstance);
>>>> $em->flush();
>>>>
>>>> The row in the database is updated actually, but the method is never
>>>> called.
>>>>
>>>> the easiest way to prove myself I'm not crazy, is that if the method
>>>> name that has been set in the metadata is not correct,
>>>> then when the Event is called, an exception will be thrown, i.e:
>>>>
>>>> preRemove: [ preRemoveMethod ]
>>>>
>>>> then I: $em->remove($entity)
>>>>
>>>> If the preRemoveMethod doesn't exist in the Entity class, then an
>>>> excepetion will be trhown.
>>>> In the other hand, preUpdate/postUpdate will be ignored completely. I
>>>> can:
>>>>
>>>> preUpdate: [ asdfasdfaThisMethodDoesNotExistInTheEntityClassaesrseres ]
>>>>
>>>> No exception will be thrown, knowing that such method doesn't exist at
>>>> all.
>>>>
>>>> (It won't happen with any other event).
>>>>
>>>> What could be wrong?
>>>>
>>>> Regards!
>>>>
>>>> --
>>>> 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
>>>>
>>>
>>>  --
>>> 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
>>>
>>
>>  --
>> 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
>>
>
>  --
> 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
>

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