As I stated in the 2nd paragraph, I do have need for this
functionality in views. It's just this one instance that I require it
in the behavior. The TidyHelper is a wrapper for several different
libTidy functions. It's also not meant to be something that is used
solely for manipulating data before saving. Adding the routines I need
into the behavior would be a needless repetition.

I resolved this by simply importing the helper into this one behavior.
This works great. In the end, though, I'm going to refactor all of
this by using InheritableBehavior, which will allow me to properly set
up my models the way they really should be.

btw, I can't believe I was actually thinking of doing
$Model->controller->... I was thinking a bit too far outside the box
there, I guess.

On Wed, Jan 28, 2009 at 12:09 PM, Smelly_Eddie <[email protected]> wrote:
>
> 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 <[email protected]> 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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to