How can I extend XenForo_ViewPublic_Helper_Message

AndyB

Well-known member
I would like to extend XenForo_ViewPublic_Helper_Message so that I may add my own code to the bbCodeWrapMessages function.

PHP:
public static function bbCodeWrapMessages(array &$messages, XenForo_BbCode_Parser $parser, array $options = array())
{
	$options += array(
		'showSignature' => XenForo_Visitor::getInstance()->get('content_show_signature'),
		'states' => array()
	);

	foreach ($messages AS &$message)
	{
		$message['messageHtml'] = XenForo_ViewPublic_Helper_Message::getBbCodeWrapper($message, $parser, $options);

		// I would like to add code here
		
	}
}
 
It isn't possible because that class is called statically. It can't be extended.
 
I would also like to know possible workarounds for this please.

I'm trying to add my own message filter to bbCodeWrapMessages before getBbCodeWrapper is called, or is there somewhere else better I can do this?

Code:
  public static function bbCodeWrapMessages(array &$messages, XenForo_BbCode_Parser $parser, array $options = array())
   {
     $options += array(
       'showSignature' => XenForo_Visitor::getInstance()->get('content_show_signature'),
       'states' => array()
     );

     foreach ($messages AS &$message)
     {
       $message['message'] = XenForo_ViewPublic_Helper_Message::MyFilter($message['message']);
       $message['messageHtml'] = XenForo_ViewPublic_Helper_Message::getBbCodeWrapper($message, $parser, $options);
     }
   }
 
Changed my plans, I found that XenForo_BbCode_Formatter_Base is extendable and the preFilterText function is much better for my purpose.
 
Back
Top Bottom