How to get has_many objects in DataExtension object?


Question: How to get has_many objects in DataExtension object?

I have two classes Member and Activity. A member has many activities. I have a class MemberExtension which extends Member. Inside MemberExtension, we have a has_many array containing ‘Activities’. How do we get the list of Activities in MemberExtension?

We have tried the following:

Error: Uncaught Error: Call to undefined method MemberExtension::Activities()

Error: Uncaught BadMethodCallException: Object->__call(): the method 'Activities' does not exist on 'SilverStripe\Security\Member'

// MemberExtension class
class MemberExtension extends DataExtension {
	public static $has_many = [
		'Activities' => Activity::class

// Activity class
class Activity extends DataObject {
    private static $has_one = [
        'Member' => Member::class,

// Register MemberExtension in _config.php

In the extension code, you can just use $this->owner->Activities()

Anywhere else, you can just access the relation directly on the member object: $member->Activities()