Ok, I have never regarded the vendors directory as a place to put my
code. I have viewed it exclusively as a place for "external" libraries
and PEAR stuff if needed.

Your suggestion should work since neither component nor helper uses
any cake functionality. They simply determine the current language and
lookup and return the labels when they are requested.

I'd better explain what I mean by problems using the helper for
flashes. The following is what a normal setFlash looks liek now:

$this->Session->setFlash( $this->Lang->show('save_ok') );
or for a flash using dynamic data:
$this->Session->setFlash( sprintf( $this->Lang->show('save_ok'), 'some
value', $this->Model->id) );

To use the helper in a flash-layout I would have to write something
like:

$this->Session->setFlash( $this->Lang->show('save_ok'),
'my_layout') );
not too bad but with a sprinted one:
$this->Session->setFlash( $this->Lang->show('save_ok'),  'my_layout',
array('args' =>array('some value',$this->Model->id)) );

And the flash-layout will have to take the values for sprintf() and
pass them along. Since they can be one, two or more I have to make use
of some php-feature I can't remember now to turn the array into
arguments for the function. IMHO not a lot of fun :) I'd rather not go
down this route.

I hope that explains why I want to avoid making the setFlash more
complex and put a lot of login in the flash-layout that really has
nothing to do with flashing messages. To me taking "User %s was saved"
and turning it into "User Martin was saved" does not belong in a
layout. I have it in my controllers now but plan to more the whole
thing into the language component/helper.

thanks for your suggestion regarding the vendors dir.

On Jan 21, 3:25 pm, nate <[EMAIL PROTECTED]> wrote:
> The simplest way to do it would be to write a base class, stick it in
> your vendors, and have the helper and component each extend it.  This
> is kind of cheating, but as long as your helper doesn't need any of
> the Helper base class functionality, you should be good.
>
> As far as the setFlash bit, Im not 100% sure what you mean, but
> sending your variables down to a custom flash layout should not result
> in messy code by any means, unless I'm not understanding your
> requirements here.
>
> On Jan 21, 8:07 am, "[EMAIL PROTECTED]"
>
> <[EMAIL PROTECTED]> wrote:
> > OMG! I'm so sorry for the language in the top paragraph.
> > Try this instead :)
>
> > "I am being picky about trying to keep things DRY and I would really
> > like be able to have a component and a helper use the same code."
--~--~---------~--~----~------------~-------~--~----~
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