For me when I find that I have functions that cross boundaries (needed in views, models, controllers) then I either move them to bootstrap (and loaded needed files as needed from within the call) or if it is a bigger 'thing' I go to vendors and load as needed.
-- (the old fart) the advice is free, the lack of crankiness will cost you - its a fine line between a real question and an idiot http://blog.samdevore.com/archives/2007/03/05/when-open-source-bugs-me/ http://blog.samdevore.com/cakephp-pages/my-cake-wont-bake/ http://blog.samdevore.com/cakephp-pages/i-cant-bake/ On Wed, Jan 28, 2009 at 10:38 AM, brian <[email protected]> wrote: > > 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 -~----------~----~----~----~------~----~------~--~---
