I am being picky about trying to keep things DRY but I would really be
able to have a component and a helper use the same code. In v1.1 I
could "cheat" by letting the helper pass along calls to $this-
>controller->MyComponent. In 1.2 this is no longer possible (AFAIK).

I have read other threads on this subject. Most of the answers were
variations of "controllers shouldn't ever use Helper functionality". I
agree but I think my situation is one where it is valid. Or at least
the code I have put in a Helper and a Component must be accessed from
both controllers and views.

I am using the very simplest form of language support. An array of
named labels and messages defined in a number of files (one for each
language). Very basic but enough for now.  A LanguageComponent needs
to be present to handle Flash-messages. A LanguageHelper needs to be
present for normal insertion into pages and elements.

Since every last bit of code in these two are identical (apart from
the name of the classes) I would like to get around the duplication.
The code is simple now but I will probably change how it works as I
need to during development. I then have to remember to make the same
alterations in two places. something I frequently forget.

Looking at the "internal" components and helpers. E.g. the Sesson
pair. I see that they include common functionality by uses(). This
includes any file in cake/libs/. Is there, or may we please have, a
similar function that cal include an application-specific "libs"
directory?

The workarounds I know of, all seem a bit dodgy:
- include / require all the code between the classes {} from file.
- put the code in a vendor directory

I don't have a handle on the new plugins system yet but it looks like
it was designed for something quite different?

And: No. I can't let a custom Flash message layout call the
LanguageHelper. Some messages need to be "sprinted" to include dynamic
data. Doing that via the Flash layout would result in some pretty
messy code with each setFlash() in the controllers if I could even get
it to work properly.

Any ideas you can share that could help me out with this problem?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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