Skip to content

Commit

Permalink
FIX Handle edge case where controller does not have a url_segment def…
Browse files Browse the repository at this point in the history
…ined
  • Loading branch information
raissanorth committed Dec 21, 2017
1 parent 2fcfce8 commit 7bd7aab
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/Extensions/ShareDraftContentControllerExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace SilverStripe\ShareDraftContent\Extensions;

use SilverStripe\Core\Extension;
use SilverStripe\Security\Member;
use SilverStripe\Security\Security;

class ShareDraftContentControllerExtension extends Extension
Expand All @@ -20,7 +19,7 @@ class ShareDraftContentControllerExtension extends Extension
*/
public function MakeShareDraftLink()
{
if ($member = Member::currentUser()) {
if ($member = Security::getCurrentUser()) {
if ($this->owner->hasMethod('CurrentPage') && $this->owner->CurrentPage()->canEdit($member)) {
return $this->owner->CurrentPage()->ShareTokenLink();
} elseif ($this->owner->hasMethod('canEdit') && $this->owner->canEdit($member)) {
Expand All @@ -36,6 +35,9 @@ public function MakeShareDraftLink()
*/
public function getShareDraftLinkAction()
{
return $this->owner->Link('MakeShareDraftLink');
if ($this->owner->config()->get('url_segment')) {
return $this->owner->Link('MakeShareDraftLink');
}
return '';
}
}

0 comments on commit 7bd7aab

Please sign in to comment.