mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
Merge pull request #2431 from muskie9/pull/pageTypeDropdown#2430
BUGFIX Page Type listed in Page Type dropdown when $can_be_root is false
This commit is contained in:
commit
6d7cc4f5c0
@ -2591,6 +2591,11 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
|
|||||||
foreach ($classes as $class) {
|
foreach ($classes as $class) {
|
||||||
$instance = singleton($class);
|
$instance = singleton($class);
|
||||||
|
|
||||||
|
//if the current page is root and the instance can't be, exclude
|
||||||
|
if (!$instance->config()->get('can_be_root') && $this->ParentID == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// if the current page type is this the same as the class type always show the page type in the list
|
// if the current page type is this the same as the class type always show the page type in the list
|
||||||
if ($this->ClassName != $instance->ClassName) {
|
if ($this->ClassName != $instance->ClassName) {
|
||||||
if ($instance instanceof HiddenClass) {
|
if ($instance instanceof HiddenClass) {
|
||||||
|
@ -1272,6 +1272,13 @@ class SiteTreeTest extends SapphireTest
|
|||||||
$this->loginWithPermission('CMS_ACCESS_CMSMain');
|
$this->loginWithPermission('CMS_ACCESS_CMSMain');
|
||||||
$this->assertArrayHasKey(SiteTreeTest_ClassA::class, $method->invoke($sitetree));
|
$this->assertArrayHasKey(SiteTreeTest_ClassA::class, $method->invoke($sitetree));
|
||||||
|
|
||||||
|
$this->logInWithPermission('ADMIN');
|
||||||
|
$rootPage = $this->objFromFixture(Page::class, 'home');
|
||||||
|
$nonRootPage = $this->objFromFixture(Page::class, 'staff');
|
||||||
|
|
||||||
|
$this->assertArrayNotHasKey(SiteTreeTest_NotRoot::class, $method->invoke($rootPage));
|
||||||
|
$this->assertArrayHasKey(SiteTreeTest_NotRoot::class, $method->invoke($nonRootPage));
|
||||||
|
|
||||||
Security::setCurrentUser(null);
|
Security::setCurrentUser(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user