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

Extending DataWriter_Discussion

mlx

Well-known member
#1
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?
 

Kier

XenForo Developer
Staff member
#3
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.