fuel/docs

before()

acidm opened this issue · 6 comments

before()... " It will not be called if that method turns out not to exist. " This is not true, before method is called always.This is a bug in docs or core? When she should be called?

Obviously, the docs are correct. And so is the code.

If it would always be called, you would get a method before() not defined on the first controller that doesn't have a before method...

Ok please tell me why ,if i called not existed method "tester->noexists()" my request is redirected...
My request:
http://localhost/index.php/tester/noexists/

All config in fuelphp is default.

And code:

@acidm the before function is a substitute for a __constructor function. Because we use the constructor internally to set the Request and check for internal routing, we allow users to specify the before method. In your case, the before method redirects the user away, like with a normal constructor, this is always called. That's why it's redirected.

Ok thanks :) , but why in the docs is write " It will not be called if that method turns out not to exist." ?

It's if the before method does not exists in the controller class, not the other method.

ok thanks again :)