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

XenForo action question

Discussion in 'General PHP and MySQL Discussions' started by LennardF1989, Sep 6, 2013.

  1. LennardF1989

    LennardF1989 Member

    As I got to know XenForo pretty well over the last few months and really loving how it works internally, I decided to setup a small CMS project roughly based on XenForo's methodology with its autoloading based on class-names and being able to dynamically resolve classes (which is a pretty darn simple yet smart and very effective system for add-ons).

    With that in place, I started to experiment a little and raised myself a question. When you define an action in a XenForo-controller, its in the following format:
    public function actionFoobar() {}
    If I wanted to retrieve an Id passed to the controller I'd have to do additional functions calls to do so.

    I was therefor wondering why you guys decided to go with that approach, rather than let the function-signature decide. For example:
    public function actionFoobar($id, $something = "Foobar") {}
    In this case, the following URL would get automatically parsed and passed to actionFoobar: index.php?test/foobar&id=0&ssomething=Test.

    I now implemented that last approach myself and it seems pretty useful.

Share This Page