Wednesday, February 20, 2013

Re: Use Configure::read in $components

Then you should go with crickets approach and pass those values in afterwards (either via attributes or setters)


Am Mittwoch, 20. Februar 2013 12:17:05 UTC+1 schrieb Julien Itard:
Because all my Configure::write('Settings.*) are in my beforeFilter .. I load a modal to get the settings that's why this is not in bootstrap

Le mercredi 20 février 2013 12:12:16 UTC+1, Julien Itard a écrit :
Hello,
it seems that i can't use Configure::read() here, it return an empty string..

My code :

public function constructClasses() {
$this->components['TeamSpeak3.TeamSpeak3'] = array(
'uri' => 'serverquery://'.Configure::read("Settings.teamspeak_query_user").':'.Configure::read('Settings.teamspeak_query_password').'@'.Configure::read('Settings.teamspeak_ip').':10011/?server_port='.Configure::read('Settings.teamspeak_port').'&no_query_clients=1');

parent::constructClasses();

This code return : serverquery://:@:10011/?server_port=&no_query_clients=1

Le mercredi 20 février 2013 11:16:22 UTC+1, euromark a écrit :
unless he needs the uri in initialized() than this would be too late.
then one might have to overwrite constructClasses():

public function constructClasses() {
$this->components['TeamSpeak3.TeamSpeak3'] = array(
'uri' => Configure::read('Settings.ts_uri));

parent::constructClasses();
}    

Just don't put it in $components then.

Am Mittwoch, 20. Februar 2013 01:10:21 UTC+1 schrieb cricket:
On Tue, Feb 19, 2013 at 4:00 PM, Julien Itard <julie...@gmail.com> wrote:
> Hi there,
> here is my AppController :
>
> public $components = array(
>           'TeamSpeak3.TeamSpeak3' => array(
>                   'uri' => Configure::read('Settings.ts_uri)
>           )
> );
>
> I need to use a configure here but it doesn't work ... any idea ?
>
> Thx from France :)

Salut,

You can't do that when declaring a class variable because it depends
on runtime info.

public $components = array(
      'TeamSpeak3.TeamSpeak3'
);

function beforeFilter() {
    $this->TeamSpeak3->uri = Configure::read(Settings.ts_uri);
}

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments: