Wednesday, January 28, 2009

Re: access helper from behavior

Helpers are used for the presentation layer. And are ideally only
accessed from the views.

If you want to manipulate data in the behavior than the functionality
should be in a behavior. Why is that not the case, since it sounds
like you only use the tidy functionality before saving, and not before
presentation?

On Jan 27, 9:10 pm, brian <bally.z...@gmail.com> wrote:
> I'm writing a helper that wraps a bunch of libTidy functionality and
> will need to use this from a within a behavior's beforeSave(). I
> thought models could load helpers but see now that this isn't so. Is
> this new? I guess I've never done that before but I was so sure that
> this was the case. Is there some way to call a helper from a behavior?
>
> I could change this helper to be a component, and call it like
> $Model->controller->Tidy->whatever(), but that would mean that all of
> the view usage would then have to go through the controller's
> component. Rock, meet hard place.
>
> btw, I want to call Tidy from the behavior because I really would
> prefer to avoid having to do it in the controller in this specific
> instance. The field that holds the content which will require Tidy
> maintenance may not exist in some circumstances and the behavior takes
> care of deciding what needs to be done on beforeSave(). I want to
> leave the controller completely out of the loop on this as it will
> cause a lot of bloat, given add(), edit(), admin_add(), etc.
--~--~---------~--~----~------------~-------~--~----~
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+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: