You can add public methods to a DataObject using the extension mechanism, for example:
class MyMemberExtension extends DataExtension
{
public function getHashId()
{
return sha1($this->owner->ID);
}
}
When applied to the Member
class, the example above would return the sha1
hash of the Member
ID by accessing the Member
via the protected property $this->owner
. Eg:
$member = Member::get()->byId(123);
var_dump($member->getHashId()); // string(40) "40bd001563085fc35165329ea1ff5c5ecbdbbeef"