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.

Customising the CMS

Extending the Group class


Reply

4 Posts   602 Views

Avatar
svandragt

12 September 2012 at 2:00am (Last edited: 12 September 2012 2:02am), Community Member, 44 Posts

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?

Avatar
martimiz

12 September 2012 at 2:18am Forum Moderator, 1091 Posts

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 :)

Avatar
svandragt

12 September 2012 at 3:24am Community Member, 44 Posts

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

Avatar
IOTI

12 September 2012 at 3:45am Community Member, 189 Posts

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.