This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use Stack Overflow.

Command Pattern Doctrine Behavior

Requests for new symfony features.

Command Pattern Doctrine Behavior

by leny » Mon Jun 27, 2011 2:44 am

Hi everybody,

I'm trying with my company to use the command pattern with symfony.
The main first feature is when you submit a form with embed forms, even if one of those is invalid (a field too long for example), the other forms will be saved in database.
So a user with a lot of informations, with several telephones or anyelse, we'll be able to save all the valid phones, that'll help especially with the data concurrency when w'll add the last_modified concept..

In first, the command pattern is pretty simple to understand, we have got an Invoker Class which will execute unit command on every relation (phones for example).
I created a doctrine Behaviour in order to make it really simple to use.
Only 2 actions could be done :
- Add actAs : Transactional
- Rename the form extend class in BaseDoctrineForm.class.php

Here is the process used in the new TransactionalForm class :
override the form save method :
in the save method : check if the object has the doctrine template we talked about (Transactional)
in case, recreate as many forms as there are relations and execute the associated commands.

BUT...

I'm blocked here :
:arrow: The embed forms doesn't have their own csrf token, so I cannot check they're are valid before save them.
I tried a lot of things to patch this :
* disableCSRFProtection
* add the main csrf_token in each relation's taintedValues but no way... I still have the csrf_token required of csrf_token attack
:oops:

:arrow: The second thing is about the doctrine record save method, even if there is a primary key in the form, the save method execute an insert into, it seems to be linked with the isNew method but i'm not able to change this attribute... I tried to override the method in the behavior template but it doesn't works.

Project files : http://www.megaupload.com/?d=05VUDR8Q
So if you can help me on anything,I'd appreciate it
User avatar
leny
Junior Member
 
Posts: 5
Joined: Tue Nov 09, 2010 6:50 am