1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

The way to add some actions while extending controller

Discussion in 'XenForo Development Discussions' started by sonnb, Jul 18, 2012.

  1. sonnb

    sonnb Well-Known Member


    I'm confusing the way to add extra actions to controller.

    For example, after thread was created I need to set its state.

    - We could do this by rewrite the action (copy full code then edit) but by this way, our addon might conflict with other addons that also extending the controller.
    - Another way is execute parent::actionAddThread(); then add our actions.
    $return parent::actionAddThread();
            if (
    $return instanceof XenForo_ControllerResponse_Redirect && $return->responseCode == 200)
    $threadId =  $match[0][count($match[0])-1];
                if (
    $writer XenForo_DataWriter::create('XenForo_DataWriter_Discussion_Thread');
    $postWriter $writer->getFirstMessageDw();
    But you could see that we only are to get threadId by search thread id from redirectTarget since the parent controller return XenForo_ControllerResponse_Redirect.

    Is this an good way to do? Do you have any better way to perform this?
  2. sonnb

    sonnb Well-Known Member

    Just for more information: I need to do this inside controller because I need data from user's inputted data (not inside the code above).
  3. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    sonnb likes this.
  4. sonnb

    sonnb Well-Known Member

    Thanks for your information. I did not see that thread before :)

Share This Page