Re: [symfony-users] Where to put the logic?

2009-12-04 Thread Georg Gell
Hi Stéphane, I don't understand what you mean. To clarify: I would like to put the business logic in the model. The business logic states in my case that no Client object can be without a User object. Following this reasoning, I added a postInsert() method in the Client object, that creates a

Re: [symfony-users] Where to put the logic?

2009-12-03 Thread Georg Gell
Hi Bernhard, actually I had the logic in a postInsert method of the Client class, which IMO made the most sense. But this lead to the following surprise: When I used $ symfony doctrine:data-load from a fixture with one client and one user I suddenly ended with two users instead of one. First

Re: [symfony-users] Where to put the logic?

2009-12-03 Thread Georg Gell
Where would you register the listener? If it is registered in the form action, this would only be an elaborate extension of the controller logic: instead of creating the Client object and afterwards the User object directly in the controller, I would register a listener in the controller that

Re: [symfony-users] Where to put the logic?

2009-12-03 Thread Stéphane
First, Hello (sorry) :-) I was assuming this was happening to one of your class; is this happening to all/other classes ? Before Printing, Think about Your Environmental Responsibility! Avant d'Imprimer, Pensez à Votre Responsabilitée Environnementale! On Thu, Dec 3, 2009 at 10:53 PM, Georg

[symfony-users] Where to put the logic?

2009-11-30 Thread Georg Gell
Hello, in my application, I would like to have this logic: When I add a client, I would like to autmatically add an admin user for the client. For me this belongs to the client object logic, and I have put it in postInsert. But if I use doctrine:data-dump and afterwards doctrine:data-load, I

Re: [symfony-users] Where to put the logic?

2009-11-30 Thread Bernhard Schussek
Hi Georg, Why don't you just override the save() method of the Client class? You could, for example, check whether any user is associated with the client and, if not, do it manually before calling parent::save(). I personally would prefer to put this logic into the form for creating the Client

Re: [symfony-users] Where to put the logic?

2009-11-30 Thread Stéphane
The controller isn't responsible for application logic. It must be in your model (if you can...). For this kind of case, I would prefer playing with events. For example, when user is created just dispatch an event like users.user.new or whatever sounds like. Then connect the app-logic method that