The downsides of that: (a) It pollutes the global name space with misc functions. (b) It is a pain to manage if you continue the trend and move beyond a few functions. (c) It goes against the OO philosophy that Cake pushes. (d) You can't do supporting protected or private scope functions to abstract the internal operations. (e) You can change the behavior without redefining the function or changing (in the view code) the name of all the functions you used to a new version.
For a single, never-will-be-repeated case, it might be an acceptable solution, but for anything that has to be maintainable over a period of time a utility class passed to the view and used in the controller is the (IMHO) best way to go. ++ Beatport DIGITAL DOWNLOAD NETWORK™ Ian Zepp - Software Engineer, RHCE, ZCE, CMDEV www.beatport.com - Access the world of club music™ -----Original Message----- From: RichardAtHome <[EMAIL PROTECTED]> Reply-To: [email protected] To: CakePHP <[email protected]> Subject: Re: Share Common Code Date: Fri, 20 Jun 2008 05:52:40 -0700 (PDT) or add the functions to app/config/bootstrap.php On Jun 20, 1:34 am, Ian Zepp <[EMAIL PROTECTED]> wrote: > Pass an object to view that has the methods you need. > > Ketan Patel wrote: > > I am baffled right now with a simple question. I want some specific > > functions to be available in the controllers as well as the views. > > What's the best way to do this? I don't want to duplicate same code in > > components as well as the helpers. Is there a straight forward way to > > do this? > > > I am thinking of adding to Vendor and then use it, but still not sure. > > If you know please reply. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
