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   611 Views

Avatar
svandragt

Community Member, 44 Posts

12 September 2012 at 2:00am

Edited: 12/09/2012 2:02am

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

Forum Moderator, 1098 Posts

12 September 2012 at 2:18am

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

Community Member, 44 Posts

12 September 2012 at 3:24am

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

Avatar
IOTI

Community Member, 189 Posts

12 September 2012 at 3:45am

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.