From d5fea841d600ee6ebb1358c486ddb52a8d3bd41a Mon Sep 17 00:00:00 2001 From: Gorrie Coe Date: Fri, 13 Apr 2018 12:31:08 +1200 Subject: [PATCH] Added getAuthor method so you don't need to add it to the object --- src/extensions/DataObjectHistory.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/extensions/DataObjectHistory.php b/src/extensions/DataObjectHistory.php index 69fef67..1fe715e 100644 --- a/src/extensions/DataObjectHistory.php +++ b/src/extensions/DataObjectHistory.php @@ -9,14 +9,15 @@ use SilverStripe\Forms\GridField\GridFieldPageCount; use SilverStripe\Forms\GridField\GridFieldToolbarHeader; use SilverStripe\Forms\GridField\GridFieldSortableHeader; -use Symbiote\GridFieldExtensions\GridFieldTitleHeader; use SilverStripe\Forms\GridField\GridFieldDetailForm; use SilverStripe\Forms\GridField\GridFieldDataColumns; use SilverStripe\Forms\GridField\GridFieldPaginator; use SilverStripe\Forms\GridField\GridFieldViewButton; +use SilverStripe\Security\Member; +use SilverStripe\Versioned\Versioned; +use Symbiote\GridFieldExtensions\GridFieldTitleHeader; use gorriecoe\DataObjectHistory\Forms\GridFieldHistoryButton; use gorriecoe\DataObjectHistory\Forms\HistoryGridFieldItemRequest; -use SilverStripe\Versioned\Versioned; /** * DataObjectHistory @@ -87,4 +88,16 @@ public function getHistoryFields() ->addExtraClass('grid-field--history') ); } + + /** + * @return Member + */ + public function getAuthor() + { + $owner = $this->owner; + if ($owner->AuthorID) { + return Member::get()->byId($owner->AuthorID); + } + return null; + } }