I'm trying to extend the Member class with a DataExtension as it recommends in the docs and I've managed to attach my DataExtension to the Member class however I cannot access my newly defined methods on the Member object.
MemberExtension.php
<?php
/**
* Extends the standard SilverStripe Member DataObject
*/
class MemberExtension extends DataExtension {
private static $db = array(
'MemberExpires' => 'Date',
'Username' => 'Varchar'
);
/**
* Returns the Member Object for the username specified
*
* @param $id int the username
* @returns Member|null the Member object or null if not found
*/
public static function getByUsername(string $username) {
return Member::get()->filter('Username', $username)->first();
}
}
I'm adding the extension in the YAML config, I do a /dev/build and the new columns appear in the DB.
When I run
Object::get_extensions('Member')
it properly returns an array with my MemberExtension class.
However whenver I run
Member::getByUsername()
it always fails citing a "Fatal error: Call to undefined method Member::getByUsername()"
Am I doing this properly?
Is their anything I'm not grasping?
Thanks for your time.