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

[Solved] Invalid Controller Class

Discussion in 'XenForo Development Discussions' started by Adam K M, Aug 3, 2014.

  1. Adam K M

    Adam K M Active Member

    Hello,

    I'm trying to properly extend an already existing controller (account), but when I try to save the code event listener, I get the following error:
    invalidclass.png
    The Invalid class error isn't very descriptive, and I'm not quite sure what to do with it. Testing some classes that didn't exist, I also got the same error, so I suspect that XenForo is unable to locate my controller, but I have been unable to pinpoint where I've gone wrong with the naming/folder organisation .

    Here is the setup that I've currently got running on my development forum
    My LoadClassController
    PHP:
    <?php

    class ShortCut_GuidArea_LoadClassController
    {
        
    /**
         * Instruct the system that XenForo_ControllerPublic_Account
         * should be extended by our own class
         *
         * @param string $class
         * @param array $extend
         */
        
    public static function extendMemberController($class, array &$extend)
        {
            if (
    $class == 'XenForo_ControllerPublic_Account')
            {
                
    $extend[] = 'ShortCut_GuildArea_guildpage';
            }
        }
    }
    The directory:
    Code:
    /public_html/dev*/library/ShortCut/GuildArea
    * corresponds to the root of the installation.
    Any / All advice on what's going wrong is greatly appreciated. As for my guildpage class, it works properly (hooray!) if I insert it directly in the ControllerPublic_Account class (boo! bad practice!).
     
  2. Aayush

    Aayush Well-Known Member

    You are missing an 'l' in the spelling of the class

    PHP:
    <?php

    class ShortCut_GuildArea_LoadClassController
     
    Adam K M likes this.
  3. Aayush

    Aayush Well-Known Member

    Tip:
    Add this to event hint for a tiny performance boost: XenForo_ControllerPublic_Account
     
    Adam K M likes this.
  4. Adam K M

    Adam K M Active Member

    @Aayush
    I see! Thanks for the code hint as well!
     
    Aayush likes this.
  5. Adam K M

    Adam K M Active Member

    One last question - and I realise that this might go out of the scope of my original question, but...

    How do I go about 'packaging' a template along with my plugin? I looked at template modifications, however I don't see a way to have my plugin create a brand new template with itself.
     
  6. Chris D

    Chris D XenForo Developer Staff Member

    Create it within the Master Style and assign it to your add-on.
     
    Aayush and Adam K M like this.

Share This Page