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

Run Action after DW save

Discussion in 'XenForo Development Discussions' started by ragtek, Oct 11, 2010.

  1. ragtek

    ragtek Guest

    I'd like to run own code after the save action from XenForo_DataWriter_AddOn.
    How can i do this?
  2. dmnkhhn

    dmnkhhn Active Member

    There is a _postSave() method you could use in your DataWriter. :)

    More information:

    There are certain methods for certain events. The _postSave() method in a DataWriter gets called after the saving process.

    When you are extending a DataWriter, you can copy this method to your DataWriter to handle the stuff that needs to be done after the saving (updating counters etc.).

    Take a look at library/XenForo/DataWriter/Attachment.php (line 82) - there is even a method to handle the stuff that needs to be done before the saving (_preSave()).

    // Example from library/XenForo/DataWriter/Attachment.php
         * Post-save handling.
    protected function _postSave()
                UPDATE xf_attachment_data
                SET attach_count = attach_count + 1
                WHERE data_id = ?
  3. ragtek

    ragtek Guest

    thx, working like a charm

    // todo move to own class instead of creating new methods here
    class Ragtek_DeveloperTools_AddOn extends XFCP_Ragtek_DeveloperTools_AddOn
    $addOnId '';
    $path '';

        protected function 
            if (

    // create folder

Share This Page