Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

[Solved!]... does not have a method 'add_to_class'...


Go to End


11 Posts   2511 Views

Avatar
Vlad Belfort

Community Member, 55 Posts

22 April 2016 at 3:06am

That makes sense. I don't think it's an issue with the .yml setup, I tried moving things around but nada...

On the off-chance I tried doing this

  public static $add_to_class = array('UserManager', 'Member'); #tried 'Member', 'UserManager too
but that didn't do anything either -_-

This thing is incredibly irritating lol !! I tried searching online again in case I missed something but can't find any info on this...

Avatar
martimiz

Forum Moderator, 1391 Posts

22 April 2016 at 4:25am

Oh man, I am so very blind sometimes! :-( I totally missed this:

class UserManager extends Page_Controller {
...

So class UserManager actually isn't an Extension subclass, it's a Page_Controller subclass, so a fully operational content controller on its own :-) So if you try to add UserManager as an Extension to the Member class, as in:

Member:
  extensions:
    - UserManager

...the Config class wants to access its special Extension methods (like add_to_class()), which the Page_Controller obviously doesn't have. I don't know why your code would still function. Maybe because you are not actually using the UserManager as an Extension? Try removing the settings for UserManager, flush, and see what happens?

Sorry for not noticing this earlier (blush)

Avatar
Vlad Belfort

Community Member, 55 Posts

22 April 2016 at 11:24pm

Oh my god that was it!!! No more stupid warnings :D

Don't worry about that, you stuck with it and what matters is we got there in the end!

Thanks for the explanation, as I previously mentioned I wasn't that understanding of the whole extensions/yml part so I was throwing shit at the wall to see what stuck to get my module working - it worked with UserManager being in the .yml file so I assumed that was the correct way of doing what I was doing.

Cheers for all your help and time on this! Greatly appreciated :)
Definitely going to bookmark this for future reference, this post is literally the only explanation on the internet about that warning and what could cause it

Go to Top