What is the best way to alter simple functionality in a large method?

In this case, I'm working with the XenForo_ControllerPublic_Forum::actionForum() method. All I need to do is change this line:

$threadsPerPage = XenForo_Application::get('options')->discussionsPerPage;
and replace it with my own bit of code. What is the best way to do this? I know I could just copy the entire method into my extension method, but that is awfully hacky and a short term solution. If you had to change that line in the actionForum method, how would you go about it?

Chris D

XenForo developer
Staff member
You can temporarily override option values at run time:
XenForo_Application::getOptions()->set('discussionsPerPage', 999);
So you would just extend the class, and set the value before returning the parent:

public function actionForum()
    XenForo_Application::getOptions()->set('discussionsPerPage', 999);

    return parent::actionForum();
Boom. That's exactly what I was wanting to do, but I didn't mention it because I thought it might be the wrong way to go about it and didn't want to look stupid :)

Thanks Chris!