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

PHP Callback Method

Discussion in 'XenForo Development Discussions' started by Jeremy, Nov 7, 2010.

  1. Jeremy

    Jeremy XenForo Moderator Staff Member

    Has anyone figured out how XenForo checks to see if a callback method is valid? I'm trying to do some validation for the BB Code Manager that checks one of two things:
    a) That you don't define both methods of replacement (Simple & PHP)
    b) That the PHP call back method is valid.

    Now, I'm mainly looking at b) here (still trying to figure out how to setup checking the inputted data, but I'll get that soon). I have read and reread the add-on DataWriter and Controller. I'm at a loss here. Its probably something simple I'm missing again. (The last one was extremely simple, solved by Shadab.)
  2. Indigo

    Indigo Active Member

    You should be able to check it with is_callable(array($class, $method)).
  3. g0rn

    g0rn Well-Known Member

    It uses the following code (from library/XenForo/DataWriter/CodeEventListener.php)
            if ($this->isChanged('callback_class') || $this->isChanged('callback_method'))
    $class $this->get('callback_class');
    $method $this->get('callback_method');

                if (!
    XenForo_Application::autoload($class) || !method_exists($class$method))
    $this->error(new XenForo_Phrase('please_enter_valid_callback_method'), 'callback_method');
    You haven't found the code in the add-on datawriter as XenForo doesn't seem to check if add-on install/uninstall callbacks are valid, but it checks if callbacks defined for event listeners and pages are valid.
  4. Jeremy

    Jeremy XenForo Moderator Staff Member

    Thank you. I could have sworn add-ons checked it. It was driving me crazy that I couldn't find it. *sigh* I guess that's what you get for trying to read it in a hurry then again at 1 am.

Share This Page