I should mention that I both read from and write to the session...

Jeremy Burns
Class Outfit

jeremybu...@classoutfit.com
(t) +44 (0) 208 123 3822
(m) +44 (0) 7973 481949
Skype: jeremy_burns
http://www.classoutfit.com

On 3 Sep 2010, at 06:00, Dave Maharaj wrote:

> Place the code in the model and pass the Session data as vars from the
> controller?
> 
> 
> -----Original Message-----
> From: Jeremy Burns [mailto:jeremybu...@classoutfit.com] 
> Sent: September-03-10 2:24 AM
> To: CakePHP
> Subject: Component code
> 
> I have a chunk of code that appears in two controllers
> (orders_controller and order_items_controller) that is virtually
> identical in each case. I'd like to move it to a single location, so
> this sounds like an ideal candidate for a component.
> 
> Part of the code calls a function in the Order model, so whilst one
> calls it via $this->Order->function() the other calls it via $this-
>> OrderItem->Order->function(); hence the difference.
> 
> I could also consider moving the code into the Order model and calling
> it from both controllers, but unfortunately the code also refers to
> $this->Session, which is not allowed in models.
> 
> So I'm stuck. I can't move it to a component because a component can't
> call a model function, and I can't move it to a model because a model
> can't talk to the Session.
> 
> Any ideas?
> 
> Check out the new CakePHP Questions site http://cakeqs.org and help others
> with their CakePHP related questions.
> 
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at
> http://groups.google.com/group/cake-php?hl=en
> 
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
> 
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to