I'm using the datasources plugin, but it is not used in this particular
controller nor in any class that is loaded there.

I tried to load the class using loadModel() instead but the result is the
same.

What I am doing is loading a model only if the user is not authenticated,
to check that this particular controller action is allowed to be used by
anonymous users. I don't need to have it always loaded, since when the used
is logged in normal Auth component executes and checks permissions.
And anyway putting the class in the uses array doesn't work because
controller classes are loaded after the beforeFilter() from what I read in
the dispatcher code. It seems so strange that models are not loaded in a
callback that is used so often.

One thing I noticed is that if I rename the model filename from User.php to
user.php them the model is loaded correctly...but this goes against the
conventions as far as I know.
Il giorno 13/gen/2013 00:08, "AD7six" <[email protected]> ha scritto:

>
>
> On Saturday, 12 January 2013 23:23:31 UTC+1, Stefano Campanella wrote:
>>
>> Hi all,
>> I am trying to find a way to successfully load a model in before Filter
>> without causing the explosion of my controller :D
>> I am working on CakePHP 2.3.0 RC2
>>
>> Basically, I am calling ClassRegistry::init() to load a model in
>> AppController's beforeFilter() and it works perfectly. The only problem is
>> that after this my controller fails to load its own model, it loads a
>> generic AppModel instead.
>> In particular, I have my UsersController which executes the
>> beforeFilter() of AppController, in which ClassRegistry::init('Group') is
>> called.
>> Then if any of my actions try to use $this->User they get an AppModel
>> object. If I comment out the ClassRegistry call, $this->User is correctly
>> loaded as User object.
>>
>> Is there a specific way to load a model in beforeFilter() or maybe there
>> is a bug in the framework?
>>
>
> are you using plugins?
>
> Using ClassRegistry::init in a controller isn't a normal thing to do - and
> neither is loading models like that in your beforeFilter (just put the
> model in your uses array) - what is it you're doing?
>
> AD
>
> --
> 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 post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> Visit this group at http://groups.google.com/group/cake-php?hl=en.
>
>
>

-- 
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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
Visit this group at http://groups.google.com/group/cake-php?hl=en.


Reply via email to