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

Using Class Constants

#1
We have defined some constants in our datawriter.

Is it ok, if we access them in other classes (controlller, model) with:
PHP:
   ...
        $dw->set('status', Ragtek_AS_DataWriter_Article::ARTICLE_REVIEW);
        $dw->save();
    }
or could there be any problems because of the xenforo autoloader or the event listeners (if an add-on extends our datawriter)?
 

Mike

XenForo developer
Staff member
#2
It should be fine.

However, if your class uses the XFCP system, you need to ensure that it's loaded that way rather than by the autoloader. Generally speaking, this will happen for you as you'll have created the class before you try to use a constant, but there are cases where that may not happen.