XF 2.2 is \XF\Pub\Controller\AbstractController extendable or not?

Earl

Well-known member
I am trying to override isDiscouraged method in \Pub\AbstractController class.
Everything looks good, but debugger not pause the execution at the breakpoint in extended code. the method (isDiscouraged) in base class executed correctly, but at the end of the code, it does not jump into my extended code.

I really appriciate if anyone can suggest a way to find what's wrong with it.
 
No, it's an abstract class. It is never created separately from other classes.
 
So technically there is no way to modify the behavior of isDiscouraged method. That's a shame.
You can change its behavior by extending a specific controller. In fact, most often overwriting a method for absolutely all classes is not a good idea, abstraction in this case allows you to avoid unexpected behavior in the controller. Using an AbstractController ensures that its methods behave in a certain way, which is essential for stable development.
 
You can change its behavior by extending a specific controller. In fact, most often overwriting a method for absolutely all classes is not a good idea, abstraction in this case allows you to avoid unexpected behavior in the controller. Using an AbstractController ensures that its methods behave in a certain way, which is essential for stable development.
Hmm that make absolutely sense
You can change its behavior by extending a specific controller

Unfortunately, there are only two references to the isDiscouraged() method in the whole xenforo code. One is from preDispatchType(). The other one is assertRegistrationActive(). There is no sign from any other specific controller because I believe the discourage system should be executed at the top level.
1686245837233.png

Anyway, I understand your point. Thanks for responding.
@Chris D Is there a reason we shouldn't touch the Discourage system?
 
Unfortunately, there are only two references to the isDiscouraged()method in the whole xenforo code. One is from preDispatchType(). The other one is assertRegistrationActive(). There is no sign from any other specific controller because I believe the discourage system should be executed at the top level.
In every controller that inherits AbstractController, this method can be overridden like any other from AbstractController
 
While you won't be able to modify \XF\Pub\Controller\AbstractController::isDiscouraged or call \XF\Pub\Controller\AbstractController::discourage, you can use the controller_pre_dispatch event to hook into roughly the same place for every controller.
 
While you won't be able to modify \XF\Pub\Controller\AbstractController::isDiscouraged or call \XF\Pub\Controller\AbstractController::discourage, you can use the controller_pre_dispatch event to hook into roughly the same place for every controller.
Fantastic! it worked
 
Top Bottom