XF 2.0 Php Callback in Template Mod

Pierce

Well-known member
Im just starting to get a bit of time to look at xf2 but ive been banging my head for an hour and its time to ask.

I understand the concept of the old XF where you have:

Folder_Folder_File::method();

introducing a name space say:

Pierce/BBF

(and folder is src/Pierce/BBF)

And.. i have a folder called Callbacks with a file called Replace.php

so this file is: src/Pierce/BBF/Callbacks/Replace.php

The text is the exact same from 1.5:

The search text must be a full regular expression. The replace field must be in the form of className::methodName to call. The callback will receive one argument, an array of matches from the regular expression. It must return the updated template string.

So i have tried:

Pierce_BBF_Callbacks_Replace::getHtml
Pierce_BBF_Callbacks_Replace::getHtml()
Pierce/BBF/Callbacks/Replace::getHtml
Pierce/BBF/Callbacks/Replace::getHtml()

Various namespaces etc (i assume the name space is the project Pierce/BBF)...

Can somebody point me in the right direction?
 
PHP namespaces are separated by backslashes (\) not forward slashes.

Pierce\BBF\Callbacks\Replace::getHtml

That would expect to find the PHP class in the file src/addons/Pierce/BBF/Callbacks/Replace.php.

The code itself would look like:
PHP:
<?php

namespace Pierce\BBF\Callbacks;

class Replace
{
    public static function getHtml(array $matches)
    {
        // your code
    }
}
 
Top Bottom