Amends made requested during Pull Request

Requested by @andrewandante & @ScopeyNZ
This commit is contained in:
Lee Bradley 2019-10-30 09:02:18 +00:00
parent 31f99445bd
commit c8ccd6a8c4
3 changed files with 20 additions and 14 deletions

View File

@ -3,6 +3,7 @@ namespace SilverStripe\CMS\Controllers;
use SilverStripe\CMS\Model\RedirectorPage;
use SilverStripe\Control\Controller;
use SilverStripe\Core\Config\Config;
use SilverStripe\Core\Convert;
use SilverStripe\ORM\DataObject;
use SilverStripe\Versioned\Versioned;
@ -56,20 +57,18 @@ class SilverStripeNavigatorItem_LiveLink extends SilverStripeNavigatorItem
$record = $this->record;
return (
$record->hasExtension(Versioned::class)
&& $this->showLiveLink()
&& $record->hasStages()
&& $this->getLivePage()
&& $this->showLiveLink()
);
}
/**
* @return bool
*/
public function showLiveLink()
{
try {
return $this->record->config()->get('show_live_link');
} catch (\BadMethodCallException $e) {
// Not using `config()` or similar
return false;
}
return (bool)Config::inst()->get(get_class($this->record), 'show_live_link');
}
public function isActive()

View File

@ -3,6 +3,7 @@ namespace SilverStripe\CMS\Controllers;
use SilverStripe\CMS\Model\RedirectorPage;
use SilverStripe\Control\Controller;
use SilverStripe\Core\Config\Config;
use SilverStripe\Core\ClassInfo;
use SilverStripe\Core\Convert;
use SilverStripe\ORM\DataObject;
@ -62,20 +63,18 @@ class SilverStripeNavigatorItem_StageLink extends SilverStripeNavigatorItem
$record = $this->record;
return (
$record->hasExtension(Versioned::class)
&& $this->showStageLink()
&& $record->hasStages()
&& $this->getDraftPage()
&& $this->showStageLink()
);
}
/**
* @return bool
*/
public function showStageLink()
{
try {
return $this->record->config()->get('show_stage_link');
} catch (\BadMethodCallException $e) {
// Not using `config()` or similar
return false;
}
return (bool)Config::inst()->get(get_class($this->record), 'show_stage_link');
}
public function isActive()

View File

@ -137,8 +137,16 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
*/
protected static $_allowedChildren = array();
/**
* Determines if the Draft Preview panel will appear when in the CMS admin
* @var bool
*/
private static $show_stage_link = true;
/**
* Determines if the Live Preview panel will appear when in the CMS admin
* @var bool
*/
private static $show_live_link = true;
/**