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

Extending DataWriter_Discussion

Discussion in 'XenForo Development Discussions' started by mlx, Mar 30, 2011.

  1. mlx

    mlx Well-Known Member

    I'm trying to plug some code into DataWriter_Discussion::_updateUserMessageCount

    And for some reason I cannot get this to work. It's in the middle of the night so chances are I'm just doing something wrong.

    For simple testing reasons this is the code:

    ThreadCount\Listener\Discussion.php
    PHP:
    <?php

    class ThreadCount_Listener_Discussion
    {
        public static function 
    loadClassController($class, &$extend)
        {
            if (
    $class == 'XenForo_DataWriter_Discussion')
            {
                
    $extend[] = 'ThreadCount_DataWriter_Discussion';
            }
        }
    }
    ThreadCount\DataWriter\Discussion.php
    PHP:
    <?php

    class ThreadCount_DataWriter_Discussion extends XFCP_ThreadCount_DataWriter_Discussion
    {
        protected function 
    _updateUserMessageCount(array $messages$isDelete false)
        {
            echo 
    "test1";
            exit;
        }
    }
    Listen to Event: load_class_datawriter
    Execute Callback: ThreadCount_Listener_Discussion::loadClassController

    It's not working. Looks like it's not called at all. Even though callback is active.

    Any idea what's wrong there?
     
    Steve F likes this.
  2. Kier

    Kier XenForo Developer Staff Member

    Have you verified that loadClassController() is firing?
     
  3. Kier

    Kier XenForo Developer Staff Member

    Aah, got it. You are checking for XenForo_DataWriter_Discussion being instantiated. There's a teensy weensy problem with that:
    PHP:
    abstract class XenForo_DataWriter_Discussion extends XenForo_DataWriter

    {
    XenForo_DataWriter_Discussion is an abstract class and can not be instantiated.

    I suspect that the DataWriter you really want is XenForo_DataWriter_Discussion_Thread.
     
    mlx likes this.
  4. mlx

    mlx Well-Known Member

    Oh boy. I guess OOP is still confusing me from time to time. Thanks a lot Kier!
     
    Kier likes this.

Share This Page