Jump to:

5513 Posts in 1732 Topics by 1218 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Extending the Group class

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

Page: 1
Go to End
Author Topic: 555 Views
  • svandragt
    Avatar
    Community Member
    44 Posts

    Extending the Group class Link to this post

    I'm trying to add a method to the Group class using a DataExtension. The module I am modifying already adds DataExtensions to the Member and Member_Validating classes like this:

    protected static function on_register() {
    Object::add_extension('Member', 'ExternalAuthenticatedRole');
    Object::add_extension('Member_Validator', 'ExternalAuthenticatedRole_Validator');
    return parent::on_register();
    }

    So I added my own line, before line 2:

    Object::add_extension('Group', 'GroupObjectRole');

    I added a file called GroupObjectRole.php to the same folder, and added a class GroupObjectRole extends DataExtension. However this results in a fatal error:

    Fatal error: Object::add_extension() - Can't find extension class for "GroupObjectRole" in framework\core\Object.php on line 452

    What am I doing wrong?

  • martimiz
    Avatar
    Forum Moderator
    1067 Posts

    Re: Extending the Group class Link to this post

    Did you try doing a ?flush=all, or even a /dev/build?flush=1?

    Another error I've made is forget to add <?php to the top of the file, which I know is very stupid but gives the same resulting error

  • svandragt
    Avatar
    Community Member
    44 Posts

    Re: Extending the Group class Link to this post

    Done a /dev/build?flush=all and verified the <?php start but no luck.

  • IOTI
    Avatar
    Community Member
    189 Posts

    Re: Extending the Group class Link to this post

    Trying adding the

    Object::add_extension('Group', 'GroupObjectRole');

    to your _config.php in mysite(although this really shouldn't matter).

    Double check the spelling of GroupObjectRole in your php file... A mistake i've often made.

    And if you haven't try doing a ?flush=all without dev/build.

    555 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.