XF 2.0 Extending the same class twice in two addons

Is this still the current answer with XF 2.1.x? I'm trying to extend \XF\Str\EmojiFormatter and XFCP_EmojiFormatter results in an error.

Like the above posters said, an abstract class doesn't need a class proxy. Everything else does pretty much minus a few areas I'd have to ask about to make sure. But a good way to make sure and find out is put one of the add-ons you own or a free add-on on your development board and look at the files. Most of them (not all) may have already extended a abstract class and you'll be able to see whether it was with XFCP_ or without.

But yes this would never change in 2.1 if it ever did. Since I can tell your unsure regardless of the posts use the method I said about viewing add-on code for educational purposes. You'll find many good add-ons doing the same thing :P
 
But yeah I just had a look at that file. That definitely needs a XFCP_ class proxy. It's not an abstract class. An abstract class will have the word abstract right before it's name.
 
Thanks, but I knew it wasn't an abstract class and it doesn't seem to get a proxy class generated for it. My question was more along the general lines about there being no way of identifying exactly what classes get proxied without doing some trial & error, especially if you're playing in an area not many others have already.
 
My question was more along the general lines about there being no way of identifying exactly what classes get proxied without doing some trial & error, especially if you're playing in an area not many others have already.

It's either trial & error or following the stack unfortunately. The quickest way for me is to create an extension and deliberately crash the code in my extension with invalid syntax.

Fwiw, the emoji formatter goes through the class proxy:
PHP:
$class = \XF::extendClass('XF\Str\EmojiFormatter');
$formatter = new $class($config);
XF\Str\Formatter::getEmojiFormatter() L950-951
 
Thanks, @Lukas W., for confirming and the example. :) After some much needed caffeine it's working as I realized my issue was not what I originally thought it was.

I haven't had coffee for nearly 3 weeks now and am forced to rely on diet soda; I may have to find a hazmat soon so I can go out and get my usual fix. 🤣
 
Top Bottom