XF 2.0 Getting 'error_invalid_class' when adding a code event listener

mgl

Member
Hi,

I'm porting a XF1 addon to XF2. I've created the new addon via the CLI tool which created it in src/addons/MyCustomStuff/Visitor/
Here is my Visitor.php that is in that directory:
PHP:
<?php

namespace MyCustomStuff\Visitor;


class Visitor
{
    public static function visitor_setup(\XF\Entity\User &$visitor) {

    }
}



Everytime I try to add the code event listener for visitor_setup I get the invalid class error even though my addon is selected.

What am I missing?


Thank you
 
@Jake B. Thanks! That worked.

btw, `\MyCustomStuff\Visitor\Visitor` doesn't sound right... Should I rename my class or namespace to something else?
 
It's really personal preference for something like that, all of our listeners live in the AddOn\Id\Listener namespace, so for that we'd have things like:

ThemeHouse\AddOn\Listener\Visitor
ThemeHouse\AddOn\Listener\App
etc. as the full class name :)
 
  • Like
Reactions: mgl
Top Bottom