Is this EVIL in cake?

View: New views
10 Messages — Rating Filter:   Alert me  

Is this EVIL in cake?

by lacenaepronta@gmail.com :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


HI,

I'm building a component that automatically sets the locale data
member of a translate behaviour.

In the action I look for the lang param, then call the component
method.

I'd like the component to set the locale data member in order to avoid
to do that in ANY action.

Something like that:

// ------- component class
function initialize(&controller, .....) {
  // HERE I SAVE THE CONTROLLER INSTANCE
  $this->controller = $controller;
  ....
}

function doSomething() {

}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@...
To unsubscribe from this group, send email to cake-php+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Is this EVIL in cake?

by lacenaepronta@gmail.com :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


SORRY, RETYPE AGAIN, I PRESSED THE SUBMIT BUTTON!!

HI,

I'm building a component that automatically sets the locale data
member of a translate behaviour.


In the action I look for the lang param, then call the component
method.


I'd like the component to set the locale data member in order to
avoid
to do that in ANY action.


Something like that:


// ------- component class
function initialize(&controller, .....) {
  // HERE I SAVE THE CONTROLLER INSTANCE
  $this->controller = $controller;
  ....



}


function doSomething() {
  // HERE I WANT TO ACCESS THE MODEL AND SET THE LOCALE
  $mod = $this->controller->.....
  $model->locale = $mySavedLocale;

}


IS THIS EVIL IN CAKE. IS THERE ANOTHER MVC ORIENTED METHOD?

THANKS!!






On 3 Nov, 14:44, "lacenaepro...@..." <lacenaepro...@...>
wrote:

> HI,
>
> I'm building a component that automatically sets the locale data
> member of a translate behaviour.
>
> In the action I look for the lang param, then call the component
> method.
>
> I'd like the component to set the locale data member in order to avoid
> to do that in ANY action.
>
> Something like that:
>
> // ------- component class
> function initialize(&controller, .....) {
>   // HERE I SAVE THE CONTROLLER INSTANCE
>   $this->controller = $controller;
>   ....
>
> }
>
> function doSomething() {
>
>
>
> }- Nascondi testo citato
>
> - Mostra testo citato -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@...
To unsubscribe from this group, send email to cake-php+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Is this EVIL in cake?

by euromark (munich) :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


there are some components that work that way
its not really evil...
in some cases this would be the appropriate way actually


On 3 Nov., 14:47, "lacenaepro...@..." <lacenaepro...@...>
wrote:

> SORRY, RETYPE AGAIN, I PRESSED THE SUBMIT BUTTON!!
>
> HI,
>
> I'm building a component that automatically sets the locale data
> member of a translate behaviour.
>
> In the action I look for the lang param, then call the component
> method.
>
> I'd like the component to set the locale data member in order to
> avoid
> to do that in ANY action.
>
> Something like that:
>
> // ------- component class
> function initialize(&controller, .....) {
>   // HERE I SAVE THE CONTROLLER INSTANCE
>   $this->controller = $controller;
>   ....
>
> }
>
> function doSomething() {
>   // HERE I WANT TO ACCESS THE MODEL AND SET THE LOCALE
>   $mod = $this->controller->.....
>   $model->locale = $mySavedLocale;
>
> }
>
> IS THIS EVIL IN CAKE. IS THERE ANOTHER MVC ORIENTED METHOD?
>
> THANKS!!
>
> On 3 Nov, 14:44, "lacenaepro...@..." <lacenaepro...@...>
> wrote:
>
> > HI,
>
> > I'm building a component that automatically sets the locale data
> > member of a translate behaviour.
>
> > In the action I look for the lang param, then call the component
> > method.
>
> > I'd like the component to set the locale data member in order to avoid
> > to do that in ANY action.
>
> > Something like that:
>
> > // ------- component class
> > function initialize(&controller, .....) {
> >   // HERE I SAVE THE CONTROLLER INSTANCE
> >   $this->controller = $controller;
> >   ....
>
> > }
>
> > function doSomething() {
>
> > }- Nascondi testo citato
>
> > - Mostra testo citato -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@...
To unsubscribe from this group, send email to cake-php+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Is this EVIL in cake?

by Miles J :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Or you could just do it in the AppController::beforeFilter().

On Nov 3, 7:52 am, "euromark (munich)" <dereurom...@...>
wrote:

> there are some components that work that way
> its not really evil...
> in some cases this would be the appropriate way actually
>
> On 3 Nov., 14:47, "lacenaepro...@..." <lacenaepro...@...>
> wrote:
>
> > SORRY, RETYPE AGAIN, I PRESSED THE SUBMIT BUTTON!!
>
> > HI,
>
> > I'm building a component that automatically sets the locale data
> > member of a translate behaviour.
>
> > In the action I look for the lang param, then call the component
> > method.
>
> > I'd like the component to set the locale data member in order to
> > avoid
> > to do that in ANY action.
>
> > Something like that:
>
> > // ------- component class
> > function initialize(&controller, .....) {
> >   // HERE I SAVE THE CONTROLLER INSTANCE
> >   $this->controller = $controller;
> >   ....
>
> > }
>
> > function doSomething() {
> >   // HERE I WANT TO ACCESS THE MODEL AND SET THE LOCALE
> >   $mod = $this->controller->.....
> >   $model->locale = $mySavedLocale;
>
> > }
>
> > IS THIS EVIL IN CAKE. IS THERE ANOTHER MVC ORIENTED METHOD?
>
> > THANKS!!
>
> > On 3 Nov, 14:44, "lacenaepro...@..." <lacenaepro...@...>
> > wrote:
>
> > > HI,
>
> > > I'm building a component that automatically sets the locale data
> > > member of a translate behaviour.
>
> > > In the action I look for the lang param, then call the component
> > > method.
>
> > > I'd like the component to set the locale data member in order to avoid
> > > to do that in ANY action.
>
> > > Something like that:
>
> > > // ------- component class
> > > function initialize(&controller, .....) {
> > >   // HERE I SAVE THE CONTROLLER INSTANCE
> > >   $this->controller = $controller;
> > >   ....
>
> > > }
>
> > > function doSomething() {
>
> > > }- Nascondi testo citato
>
> > > - Mostra testo citato -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@...
To unsubscribe from this group, send email to cake-php+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Is this EVIL in cake?

by lacenaepronta@gmail.com :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Thanks for the replies but now....HOW CAN I ACCESS THE MODEL FROM
WITHIN THE COMPONENT?




Dario



On 3 Nov, 18:35, Miles J <mileswjohn...@...> wrote:

> Or you could just do it in the AppController::beforeFilter().
>
> On Nov 3, 7:52 am, "euromark (munich)" <dereurom...@...>
> wrote:
>
>
>
> > there are some components that work that way
> > its not really evil...
> > in some cases this would be the appropriate way actually
>
> > On 3 Nov., 14:47, "lacenaepro...@..." <lacenaepro...@...>
> > wrote:
>
> > > SORRY, RETYPE AGAIN, I PRESSED THE SUBMIT BUTTON!!
>
> > > HI,
>
> > > I'm building a component that automatically sets the locale data
> > > member of a translate behaviour.
>
> > > In the action I look for the lang param, then call the component
> > > method.
>
> > > I'd like the component to set the locale data member in order to
> > > avoid
> > > to do that in ANY action.
>
> > > Something like that:
>
> > > // ------- component class
> > > function initialize(&controller, .....) {
> > >   // HERE I SAVE THE CONTROLLER INSTANCE
> > >   $this->controller = $controller;
> > >   ....
>
> > > }
>
> > > function doSomething() {
> > >   // HERE I WANT TO ACCESS THE MODEL AND SET THE LOCALE
> > >   $mod = $this->controller->.....
> > >   $model->locale = $mySavedLocale;
>
> > > }
>
> > > IS THIS EVIL IN CAKE. IS THERE ANOTHER MVC ORIENTED METHOD?
>
> > > THANKS!!
>
> > > On 3 Nov, 14:44, "lacenaepro...@..." <lacenaepro...@...>
> > > wrote:
>
> > > > HI,
>
> > > > I'm building a component that automatically sets the locale data
> > > > member of a translate behaviour.
>
> > > > In the action I look for the lang param, then call the component
> > > > method.
>
> > > > I'd like the component to set the locale data member in order to avoid
> > > > to do that in ANY action.
>
> > > > Something like that:
>
> > > > // ------- component class
> > > > function initialize(&controller, .....) {
> > > >   // HERE I SAVE THE CONTROLLER INSTANCE
> > > >   $this->controller = $controller;
> > > >   ....
>
> > > > }
>
> > > > function doSomething() {
>
> > > > }- Nascondi testo citato
>
> > > > - Mostra testo citato -- Nascondi testo citato
>
> - Mostra testo citato -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@...
To unsubscribe from this group, send email to cake-php+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Is this EVIL in cake?

by AD7six :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message




On 3 nov, 23:00, "lacenaepro...@..." <lacenaepro...@...>
wrote:
> Thanks for the replies but now....HOW CAN I ACCESS THE MODEL FROM
> WITHIN THE COMPONENT?

you seem to have accidentally written most of your message(s) in
capital letters.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@...
To unsubscribe from this group, send email to cake-php+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Is this EVIL in cake?

by Amit-34 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


http://filchiprogrammer.wordpress.com/2008/08/27/followthemanual/

On Nov 3, 4:32 pm, AD7six <andydawso...@...> wrote:
> On 3 nov, 23:00, "lacenaepro...@..." <lacenaepro...@...>
> wrote:
>
> > Thanks for the replies but now....HOW CAN I ACCESS THE MODEL FROM
> > WITHIN THE COMPONENT?
>
> you seem to have accidentally written most of your message(s) in
> capital letters.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@...
To unsubscribe from this group, send email to cake-php+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Is this EVIL in cake?

by lacenaepronta@gmail.com :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


OK, I don't know if it is the same to import and use the model or to
use the default model of the controller.

In the action I save the model like this:

$this->Group->Save

So in the component I'd like to set the locale just before the save. I
would put the code in the initialize callback of the component:

....
$this->controller->[...access the group model somehow...]->locale =
the_new_locale;
....

Sorry, but I don't know if this is the same of importing the model and
use it. Pheraps the right question is:

Does '$this->Group' works on an INSTANCE or on the CLASS??

Answer this question, and I will be a happy man.


THANKS!!







On 4 Nov, 01:45, Amit <a...@...> wrote:

> http://filchiprogrammer.wordpress.com/2008/08/27/followthemanual/
>
> On Nov 3, 4:32 pm, AD7six <andydawso...@...> wrote:
>
>
>
> > On 3 nov, 23:00, "lacenaepro...@..." <lacenaepro...@...>
> > wrote:
>
> > > Thanks for the replies but now....HOW CAN I ACCESS THE MODEL FROM
> > > WITHIN THE COMPONENT?
>
> > you seem to have accidentally written most of your message(s) in
> > capital letters.- Nascondi testo citato
>
> - Mostra testo citato -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@...
To unsubscribe from this group, send email to cake-php+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Is this EVIL in cake?

by AD7six :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message




On 4 nov, 09:02, "lacenaepro...@..." <lacenaepro...@...>
wrote:

> OK, I don't know if it is the same to import and use the model or to
> use the default model of the controller.
>
> In the action I save the model like this:
>
> $this->Group->Save
>
> So in the component I'd like to set the locale just before the save. I
> would put the code in the initialize callback of the component:
>
> ....
> $this->controller->[...access the group model somehow...]->locale =
> the_new_locale;
> ....
>
> Sorry, but I don't know if this is the same of importing the model and
> use it. Pheraps the right question is:
>
> Does '$this->Group' works on an INSTANCE or on the CLASS??
>
> Answer this question, and I will be a happy man.
>
> THANKS!!

try

$this->controller->{$this->controller->modelClass}->locale =
'lowercase';

OR

ClassRegistry::init('ThisModel')->locale = 'lowercase';

Depending on if you want the controller's model irrespective of what
it is, or a specific model that may or may not be attached to the
controller.

hth,

AD
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@...
To unsubscribe from this group, send email to cake-php+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Is this EVIL in cake?

by lacenaepronta@gmail.com :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Thank you, the modelClass solution is perfect!!!!


Long life to AD7six.


On 4 Nov, 09:09, AD7six <andydawso...@...> wrote:

> On 4 nov, 09:02, "lacenaepro...@..." <lacenaepro...@...>
> wrote:
>
>
>
>
>
> > OK, I don't know if it is the same to import and use the model or to
> > use the default model of the controller.
>
> > In the action I save the model like this:
>
> > $this->Group->Save
>
> > So in the component I'd like to set the locale just before the save. I
> > would put the code in the initialize callback of the component:
>
> > ....
> > $this->controller->[...access the group model somehow...]->locale =
> > the_new_locale;
> > ....
>
> > Sorry, but I don't know if this is the same of importing the model and
> > use it. Pheraps the right question is:
>
> > Does '$this->Group' works on an INSTANCE or on the CLASS??
>
> > Answer this question, and I will be a happy man.
>
> > THANKS!!
>
> try
>
> $this->controller->{$this->controller->modelClass}->locale =
> 'lowercase';
>
> OR
>
> ClassRegistry::init('ThisModel')->locale = 'lowercase';
>
> Depending on if you want the controller's model irrespective of what
> it is, or a specific model that may or may not be attached to the
> controller.
>
> hth,
>
> AD- Nascondi testo citato
>
> - Mostra testo citato -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@...
To unsubscribe from this group, send email to cake-php+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---