Re: ckaephp 2.0 using Configure::read in model construct method
If Configure::read() outputs right value, and this is really output from right place, your very first code in this thread is the one you need. My assumption was that you don't get right value by Configure::read() in model constructor because it is not set yet (I explained it before). And this still can be the case if you output this value in several places and confused by the right output from the wrong place. On 10 сен, 16:47, badben ba.dav...@gmail.com wrote: Thanks for you help but I am not sure that that is correct. Whilst I by no means pretend to be an expert at the inner workings of cakephp, the construct function in UserModel is called as the user model is first constructed, The parent::__construct() function in Model actually initializes the behaviours so my theory was that if I change the value of actsAs prior to parent::__construct() then I should be able to change the settings of the behavior. Also if I simply echo the value of configure::read(..) then the correct value is printed to the screen showing that the configure values have actually been set when the UserModel __construct() function is called. This at least makes sense to me, whether I am right or not is a completely different matter. -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: ckaephp 2.0 using Configure::read in model construct method
Thanks for you help but I am not sure that that is correct. Whilst I by no means pretend to be an expert at the inner workings of cakephp, the construct function in UserModel is called as the user model is first constructed, The parent::__construct() function in Model actually initializes the behaviours so my theory was that if I change the value of actsAs prior to parent::__construct() then I should be able to change the settings of the behavior. Also if I simply echo the value of configure::read(..) then the correct value is printed to the screen showing that the configure values have actually been set when the UserModel __construct() function is called. This at least makes sense to me, whether I am right or not is a completely different matter. -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
ckaephp 2.0 using Configure::read in model construct method
I am building a new application in cakephp 2.0 and am struggling using the configure function. I have a function in AppModel beforeFilter that load the settings from db into Configure using configure::write. I also have the following in my User Model: function __construct($id = false, $table = null, $ds = null) { $test = (integer)Configure::read('Setting.System.revision_limit'); $this-actsAs['Revision']['limit'] = $test; echo Configure::read('Setting.System.revision_limit'); parent::__construct($id = false, $table = null, $ds = null); } The problem is that $this-actsAs['Revision']['limit'] is set to null even though when I echo Configure::read('Setting.System.revision_limit'); it returns 20. However, if I change the __construct function to: function __construct($id = false, $table = null, $ds = null) { $test = 20; $this-actsAs['Revision']['limit'] = $test; //echo Configure::read('Setting.System.revision_limit'); parent::__construct($id = false, $table = null, $ds = null); } it seems to work but of course this will not help me. Does anybody know where I have gone wrong? Thanks -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: ckaephp 2.0 using Configure::read in model construct method
Hi, since you are setting Model::actsAs before the parent Model is initialized this is doomed to fail. Try the following: function __construct($id = false, $table = null, $ds = null) { parent::__construct($id, $table, $ds); $this-actsAs['Revision']['limit'] =Configure::read('Setting.System.revision_limit'); } Kind regards Thomas Am 09.09.2011 09:47, schrieb badben: I am building a new application in cakephp 2.0 and am struggling using the configure function. I have a function in AppModel beforeFilter that load the settings from db into Configure using configure::write. I also have the following in my User Model: function __construct($id = false, $table = null, $ds = null) { $test = (integer)Configure::read('Setting.System.revision_limit'); $this-actsAs['Revision']['limit'] = $test; echo Configure::read('Setting.System.revision_limit'); parent::__construct($id = false, $table = null, $ds = null); } The problem is that $this-actsAs['Revision']['limit'] is set to null even though when I echo Configure::read('Setting.System.revision_limit'); it returns 20. However, if I change the __construct function to: function __construct($id = false, $table = null, $ds = null) { $test = 20; $this-actsAs['Revision']['limit'] = $test; //echo Configure::read('Setting.System.revision_limit'); parent::__construct($id = false, $table = null, $ds = null); } it seems to work but of course this will not help me. Does anybody know where I have gone wrong? Thanks -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: ckaephp 2.0 using Configure::read in model construct method
Thanks. I have tried this and I still get the same issue unfortunately. any ideas of where to start looking if it is a problem with my setup? On Sep 9, 10:23 am, Thomas Ploch profipl...@googlemail.com wrote: Hi, since you are setting Model::actsAs before the parent Model is initialized this is doomed to fail. Try the following: function __construct($id = false, $table = null, $ds = null) { parent::__construct($id, $table, $ds); $this-actsAs['Revision']['limit'] =Configure::read('Setting.System.revision_limit'); } Kind regards Thomas Am 09.09.2011 09:47, schrieb badben: I am building a new application in cakephp 2.0 and am struggling using the configure function. I have a function in AppModel beforeFilter that load the settings from db into Configure using configure::write. I also have the following in my User Model: function __construct($id = false, $table = null, $ds = null) { $test = (integer)Configure::read('Setting.System.revision_limit'); $this-actsAs['Revision']['limit'] = $test; echo Configure::read('Setting.System.revision_limit'); parent::__construct($id = false, $table = null, $ds = null); } The problem is that $this-actsAs['Revision']['limit'] is set to null even though when I echo Configure::read('Setting.System.revision_limit'); it returns 20. However, if I change the __construct function to: function __construct($id = false, $table = null, $ds = null) { $test = 20; $this-actsAs['Revision']['limit'] = $test; //echo Configure::read('Setting.System.revision_limit'); parent::__construct($id = false, $table = null, $ds = null); } it seems to work but of course this will not help me. Does anybody know where I have gone wrong? Thanks -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: ckaephp 2.0 using Configure::read in model construct method
If you write into Configure in AppController::beforeFiler() it happens after models creation in most cases (at least prior Cake 2.0). So you better create some init function in model for this and call it manually after Configure set. In init function re-attach behavior with new params because changes to $this-actsAs won't have effect after model creation. On 9 сен, 16:45, badben ba.dav...@gmail.com wrote: Thanks. I have tried this and I still get the same issue unfortunately. any ideas of where to start looking if it is a problem with my setup? On Sep 9, 10:23 am, Thomas Ploch profipl...@googlemail.com wrote: Hi, since you are setting Model::actsAs before the parent Model is initialized this is doomed to fail. Try the following: function __construct($id = false, $table = null, $ds = null) { parent::__construct($id, $table, $ds); $this-actsAs['Revision']['limit'] =Configure::read('Setting.System.revision_limit'); } Kind regards Thomas Am 09.09.2011 09:47, schrieb badben: I am building a new application in cakephp 2.0 and am struggling using the configure function. I have a function in AppModel beforeFilter that load the settings from db into Configure using configure::write. I also have the following in my User Model: function __construct($id = false, $table = null, $ds = null) { $test = (integer)Configure::read('Setting.System.revision_limit'); $this-actsAs['Revision']['limit'] = $test; echo Configure::read('Setting.System.revision_limit'); parent::__construct($id = false, $table = null, $ds = null); } The problem is that $this-actsAs['Revision']['limit'] is set to null even though when I echo Configure::read('Setting.System.revision_limit'); it returns 20. However, if I change the __construct function to: function __construct($id = false, $table = null, $ds = null) { $test = 20; $this-actsAs['Revision']['limit'] = $test; //echo Configure::read('Setting.System.revision_limit'); parent::__construct($id = false, $table = null, $ds = null); } it seems to work but of course this will not help me. Does anybody know where I have gone wrong? Thanks -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php