mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
BUGFIX Page Type listed in Page Type dropdown when $can_be_root is false
resolves #2430
This commit is contained in:
parent
d33e36c032
commit
1b3a4aea96
@ -2567,6 +2567,11 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
|
||||
foreach ($classes as $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 ($this->ClassName != $instance->ClassName) {
|
||||
if ($instance instanceof HiddenClass) {
|
||||
|
@ -1272,6 +1272,13 @@ class SiteTreeTest extends SapphireTest
|
||||
$this->loginWithPermission('CMS_ACCESS_CMSMain');
|
||||
$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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user