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:
Robbie Averill 2019-09-16 18:04:23 -07:00 committed by GitHub
commit 6d7cc4f5c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 0 deletions

View File

@ -2591,6 +2591,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) {

View File

@ -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);
}